[Libreoffice-commits] core.git: cui/source
Maxim Monastirsky
momonasmon at gmail.com
Tue May 9 16:49:55 UTC 2017
cui/source/customize/cfg.cxx | 45 +++++++++++++++++++++++++++++++------------
cui/source/inc/cfg.hxx | 2 -
2 files changed, 34 insertions(+), 13 deletions(-)
New commits:
commit a7851b522cd0e33c391037c1aaa901b8d675ad7a
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Tue May 9 14:51:57 2017 +0300
tdf#103491 Show correct label for the current UI element type
Change-Id: Ia7ad3c9e6d70fd47aa8346403682a17a70c5c237
Reviewed-on: https://gerrit.libreoffice.org/37432
Reviewed-by: Maxim Monastirsky <momonasmon at gmail.com>
Tested-by: Maxim Monastirsky <momonasmon at gmail.com>
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 5122f35908ee..92c3422731ce 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -22,6 +22,7 @@
#include <cassert>
#include <stdlib.h>
#include <time.h>
+#include <typeinfo>
#include <vcl/commandinfoprovider.hxx>
#include <vcl/help.hxx>
@@ -949,12 +950,12 @@ MenuSaveInData::GetEntries()
if ( m_xMenuSettings.is() )
{
- LoadSubMenus( m_xMenuSettings, OUString(), pRootEntry );
+ LoadSubMenus( m_xMenuSettings, OUString(), pRootEntry, false );
}
else if ( GetDefaultData() != nullptr )
{
// If the doc has no config settings use module config settings
- LoadSubMenus( GetDefaultData()->m_xMenuSettings, OUString(), pRootEntry );
+ LoadSubMenus( GetDefaultData()->m_xMenuSettings, OUString(), pRootEntry, false );
}
}
@@ -971,10 +972,8 @@ MenuSaveInData::SetEntries( SvxEntries* pNewEntries )
pRootEntry->SetEntries( pNewEntries );
}
-bool SaveInData::LoadSubMenus(
- const uno::Reference< container::XIndexAccess >& xMenuSettings,
- const OUString& rBaseTitle,
- SvxConfigEntry* pParentData )
+bool SaveInData::LoadSubMenus( const uno::Reference< container::XIndexAccess >& xMenuSettings,
+ const OUString& rBaseTitle, SvxConfigEntry* pParentData, bool bContextMenu )
{
SvxEntries* pEntries = pParentData->GetEntries();
@@ -1019,14 +1018,29 @@ bool SaveInData::LoadSubMenus(
uno::Sequence< beans::PropertyValue > aPropSeq;
if ( a >>= aPropSeq )
{
+ OUString aMenuLabel;
for ( sal_Int32 i = 0; i < aPropSeq.getLength(); ++i )
{
- if ( aPropSeq[i].Name == ITEM_DESCRIPTOR_LABEL )
+ if ( bContextMenu )
+ {
+ if ( aPropSeq[i].Name == "PopupLabel" )
+ {
+ aPropSeq[i].Value >>= aLabel;
+ break;
+ }
+ else if ( aPropSeq[i].Name == "Label" )
+ {
+ aPropSeq[i].Value >>= aMenuLabel;
+ }
+ }
+ else if ( aPropSeq[i].Name == "Label" )
{
aPropSeq[i].Value >>= aLabel;
break;
}
}
+ if ( aLabel.isEmpty() )
+ aLabel = aMenuLabel;
}
}
@@ -1055,7 +1069,7 @@ bool SaveInData::LoadSubMenus(
subMenuTitle += stripHotKey( aLabel );
- LoadSubMenus( xSubMenu, subMenuTitle, pEntry );
+ LoadSubMenus( xSubMenu, subMenuTitle, pEntry, bContextMenu );
}
}
else
@@ -1315,7 +1329,7 @@ SvxEntries* ContextMenuSaveInData::GetEntries()
SvxConfigEntry* pEntry = new SvxConfigEntry( aUIMenuName, aUrl, true );
pEntry->SetMain();
m_pRootEntry->GetEntries()->push_back( pEntry );
- LoadSubMenus( xPopupMenu, aUIMenuName, pEntry );
+ LoadSubMenus( xPopupMenu, aUIMenuName, pEntry, true );
}
}
@@ -1360,7 +1374,7 @@ SvxEntries* ContextMenuSaveInData::GetEntries()
SvxConfigEntry* pEntry = new SvxConfigEntry( aUIMenuName, aUrl, true, true );
pEntry->SetMain();
m_pRootEntry->GetEntries()->push_back( pEntry );
- LoadSubMenus( xPopupMenu, aUIMenuName, pEntry );
+ LoadSubMenus( xPopupMenu, aUIMenuName, pEntry, true );
}
}
std::sort( m_pRootEntry->GetEntries()->begin(), m_pRootEntry->GetEntries()->end(), EntrySort );
@@ -2123,8 +2137,15 @@ SvTreeListEntry* SvxConfigPage::AddFunction(
return nullptr;
}
+ OUString aDisplayName;
OUString aModuleId = vcl::CommandInfoProvider::GetModuleIdentifier( m_xFrame );
- OUString aDisplayName = vcl::CommandInfoProvider::GetMenuLabelForCommand( aURL, aModuleId );
+
+ if ( typeid(*pCurrentSaveInData) == typeid(ContextMenuSaveInData) )
+ aDisplayName = vcl::CommandInfoProvider::GetPopupLabelForCommand( aURL, aModuleId );
+ else if ( typeid(*pCurrentSaveInData) == typeid(MenuSaveInData) )
+ aDisplayName = vcl::CommandInfoProvider::GetMenuLabelForCommand( aURL, aModuleId );
+ else
+ aDisplayName = vcl::CommandInfoProvider::GetLabelForCommand( aURL, aModuleId );
SvxConfigEntry* pNewEntryData =
new SvxConfigEntry( aDisplayName, aURL, false );
@@ -4315,7 +4336,7 @@ void ToolbarSaveInData::LoadToolbar(
{
for ( sal_Int32 i = 0; i < aPropSeq.getLength(); ++i )
{
- if ( aPropSeq[i].Name == ITEM_DESCRIPTOR_LABEL )
+ if ( aPropSeq[i].Name == "Name" )
{
aPropSeq[i].Value >>= aLabel;
break;
diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx
index 40dc23710dc7..329b69526522 100644
--- a/cui/source/inc/cfg.hxx
+++ b/cui/source/inc/cfg.hxx
@@ -105,7 +105,7 @@ protected:
bool LoadSubMenus(
const css::uno::Reference< css::container::XIndexAccess >& xMenuSettings,
- const OUString& rBaseTitle, SvxConfigEntry* pParentData );
+ const OUString& rBaseTitle, SvxConfigEntry* pParentData, bool bContextMenu );
public:
More information about the Libreoffice-commits
mailing list