diff options
-rw-r--r-- | cui/source/dialogs/hldocntp.cxx | 18 | ||||
-rw-r--r-- | framework/source/uielement/newmenucontroller.cxx | 28 | ||||
-rw-r--r-- | include/unotools/dynamicmenuoptions.hxx | 20 | ||||
-rw-r--r-- | sfx2/source/appl/shutdowniconaqua.mm | 11 | ||||
-rw-r--r-- | sfx2/source/appl/shutdowniconw32.cxx | 13 | ||||
-rw-r--r-- | unotools/source/config/dynamicmenuoptions.cxx | 51 |
6 files changed, 44 insertions, 97 deletions
diff --git a/cui/source/dialogs/hldocntp.cxx b/cui/source/dialogs/hldocntp.cxx index 1a201f8421c3..3a582764f40e 100644 --- a/cui/source/dialogs/hldocntp.cxx +++ b/cui/source/dialogs/hldocntp.cxx @@ -157,23 +157,13 @@ void SvxHyperlinkNewDocTp::FillDocumentList() { weld::WaitObject aWaitObj(mpDialog->getDialog()); - uno::Sequence< uno::Sequence< beans::PropertyValue > > - aDynamicMenuEntries( SvtDynamicMenuOptions().GetMenu( EDynamicMenuType::NewMenu ) ); + std::vector<SvtDynMenuEntry> aDynamicMenuEntries( SvtDynamicMenuOptions().GetMenu( EDynamicMenuType::NewMenu ) ); - sal_uInt32 i, nCount = aDynamicMenuEntries.getLength(); - for ( i = 0; i < nCount; i++ ) + for ( const SvtDynMenuEntry & rDynamicMenuEntry : aDynamicMenuEntries ) { - const uno::Sequence< beans::PropertyValue >& rDynamicMenuEntry = aDynamicMenuEntries[ i ]; + OUString aDocumentUrl = rDynamicMenuEntry.sURL; + OUString aTitle = rDynamicMenuEntry.sTitle; - OUString aDocumentUrl, aTitle; - - for ( const beans::PropertyValue& e : rDynamicMenuEntry ) - { - if ( e.Name == DYNAMICMENU_PROPERTYNAME_URL ) - e.Value >>= aDocumentUrl; - else if ( e.Name == DYNAMICMENU_PROPERTYNAME_TITLE ) - e.Value >>= aTitle; - } //#i96822# business cards, labels and database should not be inserted here if( aDocumentUrl == "private:factory/swriter?slot=21051" || aDocumentUrl == "private:factory/swriter?slot=21052" || diff --git a/framework/source/uielement/newmenucontroller.cxx b/framework/source/uielement/newmenucontroller.cxx index feb9df4bf408..76f7bc6eb194 100644 --- a/framework/source/uielement/newmenucontroller.cxx +++ b/framework/source/uielement/newmenucontroller.cxx @@ -325,40 +325,24 @@ void NewMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > const & if(xMenuItemDispatch == nullptr) return; - const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > aDynamicMenuEntries = + const std::vector< SvtDynMenuEntry > aDynamicMenuEntries = SvtDynamicMenuOptions().GetMenu( m_bNewMenu ? EDynamicMenuType::NewMenu : EDynamicMenuType::WizardMenu ); - OUString aTitle; - OUString aURL; - OUString aTargetFrame; - OUString aImageId; sal_uInt16 nItemId = 1; for ( const auto& aDynamicMenuEntry : aDynamicMenuEntries ) { - for ( const auto& aProperty : aDynamicMenuEntry ) - { - if ( aProperty.Name == DYNAMICMENU_PROPERTYNAME_URL ) - aProperty.Value >>= aURL; - else if ( aProperty.Name == DYNAMICMENU_PROPERTYNAME_TITLE ) - aProperty.Value >>= aTitle; - else if ( aProperty.Name == DYNAMICMENU_PROPERTYNAME_IMAGEIDENTIFIER ) - aProperty.Value >>= aImageId; - else if ( aProperty.Name == DYNAMICMENU_PROPERTYNAME_TARGETNAME ) - aProperty.Value >>= aTargetFrame; - } - - if ( aTitle.isEmpty() && aURL.isEmpty() ) + if ( aDynamicMenuEntry.sTitle.isEmpty() && aDynamicMenuEntry.sURL.isEmpty() ) continue; - if ( aURL == "private:separator" ) + if ( aDynamicMenuEntry.sURL == "private:separator" ) pVCLPopupMenu->InsertSeparator(); else { - pVCLPopupMenu->InsertItem( nItemId, aTitle ); - pVCLPopupMenu->SetItemCommand( nItemId, aURL ); + pVCLPopupMenu->InsertItem( nItemId, aDynamicMenuEntry.sTitle ); + pVCLPopupMenu->SetItemCommand( nItemId, aDynamicMenuEntry.sURL ); - void* nAttributePtr = MenuAttributes::CreateAttribute( aTargetFrame, aImageId ); + void* nAttributePtr = MenuAttributes::CreateAttribute( aDynamicMenuEntry.sTargetName, aDynamicMenuEntry.sImageIdentifier ); pVCLPopupMenu->SetUserValue( nItemId, nAttributePtr, MenuAttributes::ReleaseAttribute ); nItemId++; diff --git a/include/unotools/dynamicmenuoptions.hxx b/include/unotools/dynamicmenuoptions.hxx index a2bb84e0acd8..c3526f9b141c 100644 --- a/include/unotools/dynamicmenuoptions.hxx +++ b/include/unotools/dynamicmenuoptions.hxx @@ -28,14 +28,16 @@ namespace com::sun::star::beans { struct PropertyValue; } namespace osl { class Mutex; } -/*-************************************************************************************************************ - @descr The method GetList() returns a list of property values. - Use follow defines to separate values by names. -*//*-*************************************************************************************************************/ -#define DYNAMICMENU_PROPERTYNAME_URL "URL" -#define DYNAMICMENU_PROPERTYNAME_TITLE "Title" -#define DYNAMICMENU_PROPERTYNAME_IMAGEIDENTIFIER "ImageIdentifier" -#define DYNAMICMENU_PROPERTYNAME_TARGETNAME "TargetName" +/*-**************************************************************************************************************** + @descr struct to hold information about one menu entry. +****************************************************************************************************************-*/ +struct SvtDynMenuEntry +{ + OUString sURL; + OUString sTitle; + OUString sImageIdentifier; + OUString sTargetName; +}; /*-************************************************************************************************************ @descr You can use these enum values to specify right menu if you call our interface methods. @@ -77,7 +79,7 @@ class SAL_WARN_UNUSED UNOTOOLS_DLLPUBLIC SvtDynamicMenuOptions final : public ut @onerror We return an empty list. *//*-*****************************************************************************************************/ - css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > GetMenu( EDynamicMenuType eMenu ) const; + std::vector< SvtDynMenuEntry > GetMenu( EDynamicMenuType eMenu ) const; private: /*-**************************************************************************************************** diff --git a/sfx2/source/appl/shutdowniconaqua.mm b/sfx2/source/appl/shutdowniconaqua.mm index 3fa4d61443a0..4a4404654eff 100644 --- a/sfx2/source/appl/shutdowniconaqua.mm +++ b/sfx2/source/appl/shutdowniconaqua.mm @@ -414,15 +414,12 @@ void aqua_init_systray() // collect the URLs of the entries in the File/New menu SvtModuleOptions aModuleOptions; std::set< OUString > aFileNewAppsAvailable; - SvtDynamicMenuOptions aOpt; - css::uno::Sequence < css::uno::Sequence < css::beans::PropertyValue > > const aNewMenu = aOpt.GetMenu( EDynamicMenuType::NewMenu ); + std::vector < SvtDynMenuEntry > const aNewMenu = SvtDynamicMenuOptions().GetMenu( EDynamicMenuType::NewMenu ); - for ( auto const & newMenuProp : aNewMenu ) + for ( SvtDynMenuEntry const & newMenuProp : aNewMenu ) { - comphelper::SequenceAsHashMap aEntryItems( newMenuProp ); - OUString sURL( aEntryItems.getUnpackedValueOrDefault( "URL", OUString() ) ); - if ( sURL.getLength() ) - aFileNewAppsAvailable.insert( sURL ); + if ( !newMenuProp.sURL.isEmpty() ) + aFileNewAppsAvailable.insert( newMenuProp.sURL ); } // describe the menu entries for launching the applications diff --git a/sfx2/source/appl/shutdowniconw32.cxx b/sfx2/source/appl/shutdowniconw32.cxx index 05b855f4cad4..0f1aa36301d7 100644 --- a/sfx2/source/appl/shutdowniconw32.cxx +++ b/sfx2/source/appl/shutdowniconw32.cxx @@ -150,16 +150,11 @@ static HMENU createSystrayMenu( ) // collect the URLs of the entries in the File/New menu ::std::set< OUString > aFileNewAppsAvailable; - SvtDynamicMenuOptions aOpt; - Sequence < Sequence < PropertyValue > > const aNewMenu = aOpt.GetMenu( EDynamicMenuType::NewMenu ); - const OUString sURLKey( "URL" ); - - for ( auto const & newMenuProp : aNewMenu ) + std::vector< SvtDynMenuEntry > const aNewMenu = SvtDynamicMenuOptions().GetMenu( EDynamicMenuType::NewMenu ); + for ( SvtDynMenuEntry const & newMenuProp : aNewMenu ) { - ::comphelper::SequenceAsHashMap aEntryItems( newMenuProp ); - OUString sURL( aEntryItems.getUnpackedValueOrDefault( sURLKey, OUString() ) ); - if ( sURL.getLength() ) - aFileNewAppsAvailable.insert( sURL ); + if ( !newMenuProp.sURL.isEmpty() ) + aFileNewAppsAvailable.insert( newMenuProp.sURL ); } // describe the menu entries for launching the applications diff --git a/unotools/source/config/dynamicmenuoptions.cxx b/unotools/source/config/dynamicmenuoptions.cxx index 2421d228fdf0..b0d74c931deb 100644 --- a/unotools/source/config/dynamicmenuoptions.cxx +++ b/unotools/source/config/dynamicmenuoptions.cxx @@ -39,6 +39,11 @@ using namespace ::osl; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; +#define DYNAMICMENU_PROPERTYNAME_URL "URL" +#define DYNAMICMENU_PROPERTYNAME_TITLE "Title" +#define DYNAMICMENU_PROPERTYNAME_IMAGEIDENTIFIER "ImageIdentifier" +#define DYNAMICMENU_PROPERTYNAME_TARGETNAME "TargetName" + #define ROOTNODE_MENUS "Office.Common/Menus/" #define PATHDELIMITER "/" @@ -52,25 +57,10 @@ using namespace ::com::sun::star::beans; #define PROPERTYCOUNT 4 -#define OFFSET_URL 0 -#define OFFSET_TITLE 1 -#define OFFSET_IMAGEIDENTIFIER 2 -#define OFFSET_TARGETNAME 3 - #define PATHPREFIX_SETUP "m" namespace { -/*-**************************************************************************************************************** - @descr struct to hold information about one menu entry. -****************************************************************************************************************-*/ -struct SvtDynMenuEntry -{ - OUString sURL; - OUString sTitle; - OUString sImageIdentifier; - OUString sTargetName; -}; /*-**************************************************************************************************************** @descr support simple menu structures and operations on it @@ -97,39 +87,28 @@ class SvtDynMenu // Notice: We build a property list with 4 entries and set it on result list then. // Separator entries will be packed in another way then normal entries! We define // special string "sSeparator" to perform too ... - Sequence< Sequence< PropertyValue > > GetList() const + std::vector< SvtDynMenuEntry > GetList() const { sal_Int32 nSetupCount = static_cast<sal_Int32>(lSetupEntries.size()); sal_Int32 nUserCount = static_cast<sal_Int32>(lUserEntries.size()); sal_Int32 nStep = 0; - Sequence< PropertyValue > lProperties ( PROPERTYCOUNT ); - Sequence< Sequence< PropertyValue > > lResult ( nSetupCount+nUserCount ); + std::vector< SvtDynMenuEntry > lResult ( nSetupCount+nUserCount ); OUString sSeparator ( "private:separator" ); - lProperties[OFFSET_URL ].Name = PROPERTYNAME_URL; - lProperties[OFFSET_TITLE ].Name = PROPERTYNAME_TITLE; - lProperties[OFFSET_IMAGEIDENTIFIER].Name = PROPERTYNAME_IMAGEIDENTIFIER; - lProperties[OFFSET_TARGETNAME ].Name = PROPERTYNAME_TARGETNAME; - for( const auto& pList : {&lSetupEntries, &lUserEntries} ) { for( const auto& rItem : *pList ) { + SvtDynMenuEntry entry; if( rItem.sURL == sSeparator ) { - lProperties[OFFSET_URL ].Value <<= sSeparator; - lProperties[OFFSET_TITLE ].Value <<= OUString(); - lProperties[OFFSET_IMAGEIDENTIFIER ].Value <<= OUString(); - lProperties[OFFSET_TARGETNAME ].Value <<= OUString(); + entry.sURL = sSeparator; } else { - lProperties[OFFSET_URL ].Value <<= rItem.sURL; - lProperties[OFFSET_TITLE ].Value <<= rItem.sTitle; - lProperties[OFFSET_IMAGEIDENTIFIER ].Value <<= rItem.sImageIdentifier; - lProperties[OFFSET_TARGETNAME ].Value <<= rItem.sTargetName; + entry = rItem; } - lResult[nStep] = lProperties; + lResult[nStep] = entry; ++nStep; } } @@ -169,7 +148,7 @@ class SvtDynamicMenuOptions_Impl : public ConfigItem => The code exist only for one time and isn't duplicated for every instance! *//*-*****************************************************************************************************/ - Sequence< Sequence< PropertyValue > > GetMenu ( EDynamicMenuType eMenu ) const; + std::vector< SvtDynMenuEntry > GetMenu ( EDynamicMenuType eMenu ) const; private: @@ -405,9 +384,9 @@ void SvtDynamicMenuOptions_Impl::ImplCommit() // public method -Sequence< Sequence< PropertyValue > > SvtDynamicMenuOptions_Impl::GetMenu( EDynamicMenuType eMenu ) const +std::vector< SvtDynMenuEntry > SvtDynamicMenuOptions_Impl::GetMenu( EDynamicMenuType eMenu ) const { - Sequence< Sequence< PropertyValue > > lReturn; + std::vector< SvtDynMenuEntry > lReturn; switch( eMenu ) { case EDynamicMenuType::NewMenu : @@ -536,7 +515,7 @@ SvtDynamicMenuOptions::~SvtDynamicMenuOptions() // public method -Sequence< Sequence< PropertyValue > > SvtDynamicMenuOptions::GetMenu( EDynamicMenuType eMenu ) const +std::vector< SvtDynMenuEntry > SvtDynamicMenuOptions::GetMenu( EDynamicMenuType eMenu ) const { MutexGuard aGuard( GetOwnStaticMutex() ); return m_pImpl->GetMenu( eMenu ); |