summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2020-11-30 21:19:52 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-12-02 08:01:57 +0100
commit264498b4baeb4d451c17153ae354bf9c241709eb (patch)
tree1a04f7e410b1d427333578870e95d896fc55c6c6 /unotools
parent70a7ed7fe8959988b58c0ef3c3f04a2a7db0625b (diff)
simplify SvtDynamicMenuOptions
just use the struct instead of passing around sequence of sequence of PropertyValue Change-Id: Ic03c066962a10daac6f83f30413a5ab09e1bfd5f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106915 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/config/dynamicmenuoptions.cxx51
1 files changed, 15 insertions, 36 deletions
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 );