framework/source/uielement/saveasmenucontroller.cxx |   39 ++++++++++++--------
 1 file changed, 24 insertions(+), 15 deletions(-)

New commits:
commit 313426e466ea36dccd20d22104000dee340e501e
Author: Samuel Mehrbrodt <samuel.mehrbr...@cib.de>
Date:   Wed May 18 18:56:29 2016 +0200

    tdf#99926 Add "Save as template" to Save dropdown
    
    Change-Id: Ia594e69e46253eb2db4fcf27ca108323a3d45f5f
    Reviewed-on: https://gerrit.libreoffice.org/25113
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de>
    Tested-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de>

diff --git a/framework/source/uielement/saveasmenucontroller.cxx 
b/framework/source/uielement/saveasmenucontroller.cxx
index 5c9a934..a69bb42 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
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to