Bugzilla – Attachment 137469 Details for
Bug 108458
Label changes for Toolbar use degrade function listing in the Customize dialog--have duplicate entries on the list
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
dirty patch to demonstrate a concept, don't push!
0001-aliases-WIP.patch (text/plain), 20.07 KB, created by
Maxim Monastirsky
on 2017-11-02 16:01:32 UTC
(
hide
)
Description:
dirty patch to demonstrate a concept, don't push!
Filename:
MIME Type:
Creator:
Maxim Monastirsky
Created:
2017-11-02 16:01:32 UTC
Size:
20.07 KB
patch
obsolete
>From 58e70ffbbf4098b154cedf0ed8ef2db281e51a85 Mon Sep 17 00:00:00 2001 >From: Maxim Monastirsky <momonasmon@gmail.com> >Date: Thu, 2 Nov 2017 16:09:23 +0200 >Subject: [PATCH] aliases WIP > >Change-Id: I8bfcf5a8518d8e2063d77eacebe45c0915ead502 >--- > framework/inc/uielement/uicommanddescription.hxx | 1 + > .../source/uielement/uicommanddescription.cxx | 130 +++++++++++++++++---- > icon-themes/tango/links.txt | 2 +- > .../openoffice/Office/UI/DrawImpressCommands.xcu | 18 ++- > .../org/openoffice/Office/UI/GenericCommands.xcu | 15 +++ > .../schema/org/openoffice/Office/UI/Commands.xcs | 5 + > sd/uiconfig/simpress/menubar/menubar.xml | 2 +- > sd/uiconfig/simpress/toolbar/commontaskbar.xml | 2 +- > sw/uiconfig/swriter/menubar/menubar.xml | 2 +- > sw/uiconfig/swriter/toolbar/standardbar.xml | 2 +- > 10 files changed, 141 insertions(+), 38 deletions(-) > >diff --git a/framework/inc/uielement/uicommanddescription.hxx b/framework/inc/uielement/uicommanddescription.hxx >index 92a2362b25a3..b86e8dfc4ed1 100644 >--- a/framework/inc/uielement/uicommanddescription.hxx >+++ b/framework/inc/uielement/uicommanddescription.hxx >@@ -87,6 +87,7 @@ public: > css::uno::Reference< css::uno::XComponentContext > m_xContext; > ModuleToCommandFileMap m_aModuleToCommandFileMap; > UICommandsHashMap m_aUICommandsHashMap; >+ UICommandsHashMap m_aWrapCommandsHashMap; > css::uno::Reference< css::container::XNameAccess > m_xGenericUICommands; > css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager; > }; >diff --git a/framework/source/uielement/uicommanddescription.cxx b/framework/source/uielement/uicommanddescription.cxx >index bd199b6891b1..b50738db1cb0 100644 >--- a/framework/source/uielement/uicommanddescription.cxx >+++ b/framework/source/uielement/uicommanddescription.cxx >@@ -26,16 +26,19 @@ > #include <com/sun/star/beans/PropertyValue.hpp> > #include <com/sun/star/beans/XPropertySet.hpp> > #include <com/sun/star/frame/ModuleManager.hpp> >+#include <com/sun/star/frame/theUICommandDescription.hpp> > #include <com/sun/star/configuration/theDefaultProvider.hpp> > #include <com/sun/star/container/XNameAccess.hpp> > #include <com/sun/star/container/XNameContainer.hpp> > #include <com/sun/star/container/XContainer.hpp> > >+#include <rtl/ref.hxx> > #include <rtl/ustrbuf.hxx> > #include <cppuhelper/implbase.hxx> > #include <unotools/configmgr.hxx> > > #include <vcl/mnemonic.hxx> >+#include <comphelper/processfactory.hxx> > #include <comphelper/propertysequence.hxx> > #include <comphelper/sequence.hxx> > #include <comphelper/string.hxx> >@@ -60,12 +63,13 @@ const sal_Int32 COMMAND_PROPERTY_MIRROR = 4; > > namespace framework > { >- >+class UICommandWrapper; > // Configuration access class for PopupMenuControllerFactory implementation > > class ConfigurationAccess_UICommand : // Order is necessary for right initialization! > public ::cppu::WeakImplHelper<XNameAccess,XContainerListener> > { >+ friend class UICommandWrapper; > osl::Mutex m_aMutex; > public: > ConfigurationAccess_UICommand( const OUString& aModuleName, const Reference< XNameAccess >& xGenericUICommands, const Reference< XComponentContext >& rxContext ); >@@ -122,12 +126,15 @@ class ConfigurationAccess_UICommand : // Order is necessary for right initializa > void impl_fill(const Reference< XNameAccess >& _xConfigAccess,bool _bPopup, > std::vector< OUString >& aImageCommandVector, > std::vector< OUString >& aImageRotateVector, >- std::vector< OUString >& aImageMirrorVector); >+ std::vector< OUString >& aImageMirrorVector, >+ const OUString& rMainCommand = OUString(), >+ CmdToInfoMap* pCmdInfo = nullptr); > > private: > typedef std::unordered_map< OUString, > CmdToInfoMap > CommandToInfoCache; >- >+ typedef std::unordered_map< OUString, >+ std::unordered_map< OUString, CmdToInfoMap > > CommandContextsCache; > void initializeConfigAccess(); > > OUString m_aConfigCmdAccess; >@@ -156,13 +163,68 @@ class ConfigurationAccess_UICommand : // Order is necessary for right initializa > Sequence< OUString > m_aCommandImageList; > Sequence< OUString > m_aCommandRotateImageList; > Sequence< OUString > m_aCommandMirrorImageList; >- CommandToInfoCache m_aCmdInfoCache; >+ CommandToInfoCache m_aCmdInfoCache; >+ CommandContextsCache m_aAliasesCache; > bool m_bConfigAccessInitialized; > bool m_bCacheFilled; > bool m_bGenericDataRetrieved; > }; > >-// XInterface, XTypeProvider >+class UICommandWrapper : public ::cppu::WeakImplHelper<XNameAccess> >+{ >+public: >+ UICommandWrapper( const OUString& rModuleName, ConfigurationAccess_UICommand* rUICommands ) : >+ aModuleName( rModuleName ), aUICommands( rUICommands ) {} >+ >+ // XElementAccess >+ css::uno::Type SAL_CALL getElementType() override >+ { >+ return aUICommands->getElementType(); >+ } >+ sal_Bool SAL_CALL hasElements() override >+ { >+ return aUICommands->hasElements(); >+ } >+ >+ // XNameAccess >+ css::uno::Any SAL_CALL getByName( const OUString& aName ) override >+ { >+ const auto& item = aUICommands->m_aAliasesCache.find(aName); >+ if (item != aUICommands->m_aAliasesCache.end()) >+ { >+ const auto& iitem = item->second.find(aModuleName); >+ if (iitem != item->second.end() ) >+ { >+ if ( !iitem->second.bCommandNameCreated ) >+ aUICommands->fillInfoFromResult( iitem->second, iitem->second.aLabel ); >+ >+ return Any( comphelper::InitPropertySequence( { >+ { aUICommands->m_aPropLabel, makeAny( !iitem->second.aContextLabel.isEmpty() ? >+ iitem->second.aContextLabel : iitem->second.aLabel ) }, >+ { aUICommands->m_aPropName, makeAny( iitem->second.aCommandName ) }, >+ { aUICommands->m_aPropPopup, makeAny( iitem->second.bPopup ) }, >+ { aUICommands->m_aPropProperties, makeAny( iitem->second.nProperties ) }, >+ { aUICommands->m_aPropPopupLabel, makeAny( iitem->second.aPopupLabel ) }, >+ { aUICommands->m_aPropTooltipLabel, makeAny( iitem->second.aTooltipLabel ) }, >+ { aUICommands->m_aPropIsExperimental, makeAny( iitem->second.bIsExperimental ) }, >+ } ) ); >+ } >+ } >+ return aUICommands->getByName( aName ); >+ } >+ css::uno::Sequence< OUString > SAL_CALL getElementNames() override >+ { >+ return aUICommands->getElementNames(); >+ } >+ sal_Bool SAL_CALL hasByName( const OUString& aName ) override >+ { >+ return aUICommands->hasByName( aName ); >+ } >+ >+private: >+ OUString aModuleName; >+ rtl::Reference< ConfigurationAccess_UICommand > aUICommands; >+}; > > ConfigurationAccess_UICommand::ConfigurationAccess_UICommand( const OUString& aModuleName, const Reference< XNameAccess >& rGenericUICommands, const Reference< XComponentContext>& rxContext ) : > m_aConfigCmdAccess( CONFIGURATION_ROOT_ACCESS ), >@@ -317,10 +379,15 @@ Any ConfigurationAccess_UICommand::getSequenceFromCache( const OUString& aComman > void ConfigurationAccess_UICommand::impl_fill(const Reference< XNameAccess >& _xConfigAccess,bool _bPopup, > std::vector< OUString >& aImageCommandVector, > std::vector< OUString >& aImageRotateVector, >- std::vector< OUString >& aImageMirrorVector) >+ std::vector< OUString >& aImageMirrorVector, >+ const OUString& rMainCommand, CmdToInfoMap* pCmdInfo) > { > if ( _xConfigAccess.is() ) > { >+ Reference< XNameAccess > xUIDesc; >+ if ( !rMainCommand.isEmpty() ) >+ xUIDesc = css::frame::theUICommandDescription::get(comphelper::getProcessComponentContext()); >+ > Sequence< OUString> aNameSeq = _xConfigAccess->getElementNames(); > const sal_Int32 nCount = aNameSeq.getLength(); > for ( sal_Int32 i = 0; i < nCount; i++ ) >@@ -331,6 +398,12 @@ void ConfigurationAccess_UICommand::impl_fill(const Reference< XNameAccess >& _x > if ( xNameAccess.is() ) > { > CmdToInfoMap aCmdToInfo; >+ if ( pCmdInfo ) >+ { >+ aCmdToInfo.bIsExperimental = pCmdInfo->bIsExperimental; >+ aCmdToInfo.nProperties = pCmdInfo->nProperties; >+ aCmdToInfo.aTargetURL = rMainCommand; >+ } > > aCmdToInfo.bPopup = _bPopup; > xNameAccess->getByName( m_aPropUILabel ) >>= aCmdToInfo.aLabel; >@@ -341,14 +414,25 @@ void ConfigurationAccess_UICommand::impl_fill(const Reference< XNameAccess >& _x > xNameAccess->getByName( m_aPropUIIsExperimental ) >>= aCmdToInfo.bIsExperimental; > xNameAccess->getByName( m_aPropProperties ) >>= aCmdToInfo.nProperties; > >- m_aCmdInfoCache.emplace( aNameSeq[i], aCmdToInfo ); >+ if ( xUIDesc.is() && xUIDesc->hasByName( aNameSeq[i]) ) >+ { >+ m_aAliasesCache[rMainCommand][aNameSeq[i]] = aCmdToInfo; >+ continue; >+ } >+ >+ Reference< XNameAccess > xContextNameAccess; >+ xNameAccess->getByName( "Contexts" ) >>= xContextNameAccess; >+ impl_fill( xContextNameAccess, _bPopup, aImageCommandVector, aImageRotateVector, aImageMirrorVector, aNameSeq[i], &aCmdToInfo ); >+ >+ const OUString aCommandName( rMainCommand.isEmpty() ? aNameSeq[i] : rMainCommand + "-" + aNameSeq[i] ); >+ m_aCmdInfoCache.emplace( aCommandName, aCmdToInfo ); > > if ( aCmdToInfo.nProperties & COMMAND_PROPERTY_IMAGE ) >- aImageCommandVector.push_back( aNameSeq[i] ); >+ aImageCommandVector.push_back( aCommandName ); > if ( aCmdToInfo.nProperties & COMMAND_PROPERTY_ROTATE ) >- aImageRotateVector.push_back( aNameSeq[i] ); >+ aImageRotateVector.push_back( aCommandName ); > if ( aCmdToInfo.nProperties & COMMAND_PROPERTY_MIRROR ) >- aImageMirrorVector.push_back( aNameSeq[i] ); >+ aImageMirrorVector.push_back( aCommandName ); > } > } > catch (const css::lang::WrappedTargetException&) >@@ -654,6 +738,13 @@ Any SAL_CALL UICommandDescription::getByName( const OUString& aName ) > > osl::MutexGuard g(rBHelper.rMutex); > >+ UICommandsHashMap::iterator pWrapIter = m_aWrapCommandsHashMap.find( aName ); >+ if ( pWrapIter != m_aWrapCommandsHashMap.end() ) >+ { >+ a <<= pWrapIter->second; >+ return a; >+ } >+ > ModuleToCommandFileMap::const_iterator pM2CIter = m_aModuleToCommandFileMap.find( aName ); > if ( pM2CIter != m_aModuleToCommandFileMap.end() ) > { >@@ -661,18 +752,13 @@ Any SAL_CALL UICommandDescription::getByName( const OUString& aName ) > UICommandsHashMap::iterator pIter = m_aUICommandsHashMap.find( aCommandFile ); > if ( pIter != m_aUICommandsHashMap.end() ) > { >- if ( pIter->second.is() ) >- a <<= pIter->second; >- else >- { >- Reference< XNameAccess > xUICommands; >- ConfigurationAccess_UICommand* pUICommands = new ConfigurationAccess_UICommand( aCommandFile, >- m_xGenericUICommands, >- m_xContext ); >- xUICommands.set( static_cast< cppu::OWeakObject* >( pUICommands ),UNO_QUERY ); >- pIter->second = xUICommands; >- a <<= xUICommands; >- } >+ if ( !pIter->second.is() ) >+ pIter->second.set( new ConfigurationAccess_UICommand( aCommandFile, m_xGenericUICommands, m_xContext ) ); >+ >+ ConfigurationAccess_UICommand* pUICommands = static_cast< ConfigurationAccess_UICommand* >( pIter->second.get() ); >+ Reference< XNameAccess > xUICommands( new UICommandWrapper( aName, pUICommands ) ); >+ m_aWrapCommandsHashMap.emplace( aName, xUICommands ); >+ a <<= xUICommands; > } > } > else if ( !m_aPrivateResourceURL.isEmpty() && aName.startsWith( m_aPrivateResourceURL ) ) >diff --git a/icon-themes/tango/links.txt b/icon-themes/tango/links.txt >index e73922a59a92..d84df38b50cd 100644 >--- a/icon-themes/tango/links.txt >+++ b/icon-themes/tango/links.txt >@@ -558,7 +558,6 @@ cmd/lc_mailmergepreventry.png cmd/lc_prevrecord.png > cmd/sc_mailmergepreventry.png cmd/sc_prevrecord.png > > # Slide command aliases >-cmd/lc_insertslide.png cmd/lc_insertpage.png > cmd/lc_duplicateslide.png cmd/lc_duplicatepage.png > cmd/lc_deleteslide.png cmd/lc_deletepage.png > cmd/lc_moveslidefirst.png cmd/lc_movepagefirst.png >@@ -624,3 +623,4 @@ cmd/sc_formatframemenu.png cmd/sc_inserttextframe.png > cmd/lc_charmapcontrol.png cmd/lc_insertsymbol.png > cmd/sc_charmapcontrol.png cmd/sc_insertsymbol.png > >+cmd/lc_adddirect-toolbar.png cmd/lc_adddirect.png >diff --git a/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu >index 03f2f4ce606c..6339d3cc9d15 100644 >--- a/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu >+++ b/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu >@@ -695,17 +695,13 @@ > <prop oor:name="Properties" oor:type="xs:int"> > <value>1</value> > </prop> >- </node> >- <node oor:name=".uno:InsertSlide" oor:op="replace"> >- <prop oor:name="Label" oor:type="xs:string"> >- <value xml:lang="en-US">~New Slide</value> >- </prop> >- <prop oor:name="TargetURL" oor:type="xs:string"> >- <value>.uno:InsertPage</value> >- </prop> >- <prop oor:name="Properties" oor:type="xs:int"> >- <value>1</value> >- </prop> >+ <node oor:name="Contexts"> >+ <node oor:name="com.sun.star.presentation.PresentationDocument" oor:op="replace"> >+ <prop oor:name="Label" oor:type="xs:string"> >+ <value xml:lang="en-US">~New Slide</value> >+ </prop> >+ </node> >+ </node> > </node> > <node oor:name=".uno:ImportFromFile" oor:op="replace"> > <prop oor:name="Label" oor:type="xs:string"> >diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu >index 69ee7b984ae9..c4ec1252e88b 100644 >--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu >+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu >@@ -2743,6 +2743,21 @@ > <prop oor:name="Properties" oor:type="xs:int"> > <value>1</value> > </prop> >+ <node oor:name="Contexts"> >+ <node oor:name="toolbar" oor:op="replace"> >+ <prop oor:name="Label" oor:type="xs:string"> >+ <value xml:lang="en-US">toolbar label</value> >+ </prop> >+ <prop oor:name="Properties" oor:type="xs:int"> >+ <value>1</value> >+ </prop> >+ </node> >+ <node oor:name="another_context" oor:op="replace"> >+ <prop oor:name="Label" oor:type="xs:string"> >+ <value xml:lang="en-US">another label</value> >+ </prop> >+ </node> >+ </node> > </node> > <node oor:name=".uno:OutlineDown" oor:op="replace"> > <prop oor:name="Label" oor:type="xs:string"> >diff --git a/officecfg/registry/schema/org/openoffice/Office/UI/Commands.xcs b/officecfg/registry/schema/org/openoffice/Office/UI/Commands.xcs >index b82a25ac835a..a4bed8d399e1 100644 >--- a/officecfg/registry/schema/org/openoffice/Office/UI/Commands.xcs >+++ b/officecfg/registry/schema/org/openoffice/Office/UI/Commands.xcs >@@ -26,6 +26,11 @@ > <info> > <desc>Provides a mapping between commands and their textual representation on the user interface.</desc> > </info> >+ <set oor:name="Contexts" oor:node-type="LabelType"> >+ <info> >+ <desc>aliases</desc> >+ </info> >+ </set> > <prop oor:name="Label" oor:type="xs:string" oor:localized="true"> > <info> > <desc>A localized text that describes the command. Will be used instead of ContextLabel, PopupLabel and TooltipLabel if those are not specified.</desc> >diff --git a/sd/uiconfig/simpress/menubar/menubar.xml b/sd/uiconfig/simpress/menubar/menubar.xml >index 0de1b9dadd42..63e1397b9f2b 100644 >--- a/sd/uiconfig/simpress/menubar/menubar.xml >+++ b/sd/uiconfig/simpress/menubar/menubar.xml >@@ -483,7 +483,7 @@ > </menu:menu> > <menu:menu menu:id=".uno:SlideMenu"> > <menu:menupopup> >- <menu:menuitem menu:id=".uno:InsertSlide"/> >+ <menu:menuitem menu:id=".uno:InsertPage"/> > <menu:menuitem menu:id=".uno:ImportSlideFromFile"/> > <menu:menuitem menu:id=".uno:DuplicateSlide"/> > <menu:menuitem menu:id=".uno:DeleteSlide"/> >diff --git a/sd/uiconfig/simpress/toolbar/commontaskbar.xml b/sd/uiconfig/simpress/toolbar/commontaskbar.xml >index 9df003a0e0dc..73999372725a 100644 >--- a/sd/uiconfig/simpress/toolbar/commontaskbar.xml >+++ b/sd/uiconfig/simpress/toolbar/commontaskbar.xml >@@ -18,7 +18,7 @@ > * the License at http://www.apache.org/licenses/LICENSE-2.0 . > --> > <toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink"> >- <toolbar:toolbaritem xlink:href=".uno:InsertSlide"/> >+ <toolbar:toolbaritem xlink:href=".uno:InsertPage"/> > <toolbar:toolbaritem xlink:href=".uno:DuplicateSlide"/> > <toolbar:toolbaritem xlink:href=".uno:RenameSlide" toolbar:visible="false"/> > <toolbar:toolbaritem xlink:href=".uno:DeleteSlide"/> >diff --git a/sw/uiconfig/swriter/menubar/menubar.xml b/sw/uiconfig/swriter/menubar/menubar.xml >index a87ff5fea7f0..c875513fb891 100644 >--- a/sw/uiconfig/swriter/menubar/menubar.xml >+++ b/sw/uiconfig/swriter/menubar/menubar.xml >@@ -19,7 +19,7 @@ > <menu:menubar xmlns:menu="http://openoffice.org/2001/menu" menu:id="menubar"> > <menu:menu menu:id=".uno:PickList"> > <menu:menupopup> >- <menu:menuitem menu:id=".uno:AddDirect"/> >+ <menu:menuitem menu:id=".uno:AddDirect-another_context"/> > <menu:menuitem menu:id=".uno:OpenFromWriter"/> > <menu:menuitem menu:id=".uno:OpenRemote"/> > <menu:menuitem menu:id=".uno:RecentFileList"/> >diff --git a/sw/uiconfig/swriter/toolbar/standardbar.xml b/sw/uiconfig/swriter/toolbar/standardbar.xml >index 10c5b6edf05b..37102d61d6b6 100644 >--- a/sw/uiconfig/swriter/toolbar/standardbar.xml >+++ b/sw/uiconfig/swriter/toolbar/standardbar.xml >@@ -19,7 +19,7 @@ > --> > <toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink"> > <toolbar:toolbaritem xlink:href=".uno:OpenUrl" toolbar:visible="false"/> >- <toolbar:toolbaritem xlink:href=".uno:AddDirect"/> >+ <toolbar:toolbaritem xlink:href=".uno:AddDirect-toolbar"/> > <toolbar:toolbaritem xlink:href=".uno:NewDoc" toolbar:visible="false"/> > <toolbar:toolbaritem xlink:href=".uno:OpenFromWriter"/> > <toolbar:toolbaritem xlink:href=".uno:OpenRemote" toolbar:visible="false"/> >-- >2.14.3 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 108458
: 137469