summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-05-18 18:56:29 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-05-19 05:49:32 +0000
commit313426e466ea36dccd20d22104000dee340e501e (patch)
tree15946c0a219847fbc6aa93089b5c2f5513a6d5da
parente480b2cf3e362760de8e35cbb950104e47ebe7ec (diff)
tdf#99926 Add "Save as template" to Save dropdown
Change-Id: Ia594e69e46253eb2db4fcf27ca108323a3d45f5f Reviewed-on: https://gerrit.libreoffice.org/25113 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
-rw-r--r--framework/source/uielement/saveasmenucontroller.cxx39
1 files changed, 24 insertions, 15 deletions
diff --git a/framework/source/uielement/saveasmenucontroller.cxx b/framework/source/uielement/saveasmenucontroller.cxx
index 5c9a93404b1c..a69bb42e5374 100644
--- a/framework/source/uielement/saveasmenucontroller.cxx
+++ b/framework/source/uielement/saveasmenucontroller.cxx
@@ -59,6 +59,7 @@ public:
private:
virtual void impl_setPopupMenu() override;
+ bool isCommandAvailable(const OUString & sCommand);
};
SaveAsMenuController::SaveAsMenuController( const uno::Reference< uno::XComponentContext >& xContext ) :
@@ -80,23 +81,31 @@ void SaveAsMenuController::impl_setPopupMenu()
if ( pPopupMenu )
pVCLPopupMenu = pPopupMenu->GetMenu();
- if ( pVCLPopupMenu )
- {
- pVCLPopupMenu->InsertItem( ".uno:SaveAs", m_xFrame );
+ if ( !pVCLPopupMenu )
+ return;
+
+ pVCLPopupMenu->InsertItem( ".uno:SaveAs", m_xFrame );
+
+ // Add Save As Template/Save Remote File commands only where they are supported.
+ OUString sSaveAsTemplate(".uno:SaveAsTemplate");
+ if (isCommandAvailable(sSaveAsTemplate))
+ pVCLPopupMenu->InsertItem( sSaveAsTemplate, m_xFrame );
+ OUString sSaveRemote(".uno:SaveAsRemote");
+ if (isCommandAvailable(sSaveRemote))
+ pVCLPopupMenu->InsertItem( sSaveRemote, m_xFrame );
+}
- // Add Save Remote File command only where it's supported.
+bool SaveAsMenuController::isCommandAvailable(const OUString & sCommand) {
css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( m_xFrame, css::uno::UNO_QUERY );
- if ( xDispatchProvider.is() )
- {
- css::util::URL aTargetURL;
- aTargetURL.Complete = ".uno:SaveAsRemote";
- m_xURLTransformer->parseStrict( aTargetURL );
-
- css::uno::Reference< css::frame::XDispatch > xDispatch( xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 ) );
- if ( xDispatch.is() )
- pVCLPopupMenu->InsertItem( aTargetURL.Complete, m_xFrame );
- }
- }
+ if ( !xDispatchProvider.is() )
+ return false;
+
+ css::util::URL aTargetURL;
+ aTargetURL.Complete = sCommand;
+ m_xURLTransformer->parseStrict( aTargetURL );
+
+ css::uno::Reference< css::frame::XDispatch > xDispatch( xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 ) );
+ return xDispatch.is();
}
// XStatusListener