summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2017-04-23 14:56:49 +0300
committerMaxim Monastirsky <momonasmon@gmail.com>2017-04-23 19:50:14 +0300
commit94490fdf76ff9aec05774a6dbbb0b42d87812969 (patch)
tree64c890b211f57b96857197a85ccfe610cf42f2af /sfx2
parent654d78834c9e16cd5d57af6ad59b1dd3c80ca467 (diff)
tdf#95845 Use CommandInfoProvider
And a few unused theUICommandDescription includes. Change-Id: Ic80dbfb91e5e7662723efe0cb4090416994adabd
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/dialog/templdlg.cxx76
-rw-r--r--sfx2/source/view/viewsh.cxx1
2 files changed, 19 insertions, 58 deletions
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index af4ee87f3c6f..bd5684b947a2 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -19,6 +19,7 @@
#include <memory>
+#include <vcl/commandinfoprovider.hxx>
#include <vcl/menu.hxx>
#include <vcl/settings.hxx>
#include <svl/intitem.hxx>
@@ -32,7 +33,6 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/frame/ModuleManager.hpp>
#include <com/sun/star/frame/UnknownModuleException.hpp>
-#include <com/sun/star/frame/theUICommandDescription.hpp>
#include <officecfg/Office/Common.hxx>
#include <sfx2/sfxhelp.hxx>
@@ -2154,24 +2154,6 @@ VclPtr<PopupMenu> SfxCommonTemplateDialog_Impl::CreateContextMenu()
return mxMenu;
}
-static OUString lcl_GetLabel(uno::Any& rAny)
-{
- OUString sRet;
- uno::Sequence< beans::PropertyValue >aPropSeq;
- if ( rAny >>= aPropSeq )
- {
- for( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
- {
- if ( aPropSeq[i].Name == "Label" )
- {
- aPropSeq[i].Value >>= sRet;
- break;
- }
- }
- }
- return sRet;
-}
-
SfxTemplateDialog_Impl::SfxTemplateDialog_Impl(SfxBindings* pB, SfxTemplatePanelControl* pDlgWindow)
: SfxCommonTemplateDialog_Impl(pB, pDlgWindow)
, m_pFloat(pDlgWindow)
@@ -2414,45 +2396,25 @@ IMPL_LINK( SfxTemplateDialog_Impl, ToolBoxRClick, ToolBox *, pBox, void )
{
//create a popup menu in Writer
ScopedVclPtrInstance<PopupMenu> pMenu;
- uno::Reference< container::XNameAccess > xNameAccess(
- frame::theUICommandDescription::get(
- ::comphelper::getProcessComponentContext()) );
- uno::Reference< container::XNameAccess > xUICommands;
OUString sTextDoc("com.sun.star.text.TextDocument");
- if(xNameAccess->hasByName(sTextDoc))
- {
- uno::Any a = xNameAccess->getByName( sTextDoc );
- a >>= xUICommands;
- }
- if(!xUICommands.is())
- return;
- try
- {
- uno::Any aCommand = xUICommands->getByName(".uno:StyleNewByExample");
- OUString sLabel = lcl_GetLabel( aCommand );
- pMenu->InsertItem( SID_STYLE_NEW_BY_EXAMPLE, sLabel );
- pMenu->SetHelpId(SID_STYLE_NEW_BY_EXAMPLE, HID_TEMPLDLG_NEWBYEXAMPLE);
-
- aCommand = xUICommands->getByName(".uno:StyleUpdateByExample");
- sLabel = lcl_GetLabel( aCommand );
-
- pMenu->InsertItem( SID_STYLE_UPDATE_BY_EXAMPLE, sLabel );
- pMenu->SetHelpId(SID_STYLE_UPDATE_BY_EXAMPLE, HID_TEMPLDLG_UPDATEBYEXAMPLE);
-
- aCommand = xUICommands->getByName(".uno:LoadStyles");
- sLabel = lcl_GetLabel( aCommand );
- pMenu->InsertItem( SID_TEMPLATE_LOAD, sLabel );
- pMenu->SetHelpId(SID_TEMPLATE_LOAD, ".uno:LoadStyles");
-
- pMenu->SetSelectHdl(LINK(this, SfxTemplateDialog_Impl, MenuSelectHdl));
- pMenu->Execute( pBox,
- pBox->GetItemRect(nEntry),
- PopupMenuFlags::ExecuteDown );
- pBox->EndSelection();
- }
- catch (const uno::Exception&)
- {
- }
+
+ OUString sLabel = vcl::CommandInfoProvider::GetPopupLabelForCommand(".uno:StyleNewByExample", sTextDoc);
+ pMenu->InsertItem( SID_STYLE_NEW_BY_EXAMPLE, sLabel );
+ pMenu->SetHelpId(SID_STYLE_NEW_BY_EXAMPLE, HID_TEMPLDLG_NEWBYEXAMPLE);
+
+ sLabel = vcl::CommandInfoProvider::GetPopupLabelForCommand(".uno:StyleUpdateByExample", sTextDoc);
+ pMenu->InsertItem( SID_STYLE_UPDATE_BY_EXAMPLE, sLabel );
+ pMenu->SetHelpId(SID_STYLE_UPDATE_BY_EXAMPLE, HID_TEMPLDLG_UPDATEBYEXAMPLE);
+
+ sLabel = vcl::CommandInfoProvider::GetPopupLabelForCommand(".uno:LoadStyles", sTextDoc);
+ pMenu->InsertItem( SID_TEMPLATE_LOAD, sLabel );
+ pMenu->SetHelpId(SID_TEMPLATE_LOAD, ".uno:LoadStyles");
+
+ pMenu->SetSelectHdl(LINK(this, SfxTemplateDialog_Impl, MenuSelectHdl));
+ pMenu->Execute( pBox,
+ pBox->GetItemRect(nEntry),
+ PopupMenuFlags::ExecuteDown );
+ pBox->EndSelection();
pBox->Invalidate();
}
}
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index a8ba5f70adc3..57408af1eb10 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -37,7 +37,6 @@
#include <com/sun/star/container/XContainerQuery.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
-#include <com/sun/star/frame/theUICommandDescription.hpp>
#include <cppuhelper/implbase.hxx>
#include <osl/file.hxx>