[Libreoffice-commits] core.git: Branch 'feature/gsoc15-open-remote-files-dialog' - framework/source sfx2/source

Maxim Monastirsky momonasmon at gmail.com
Mon Jul 20 00:29:21 PDT 2015


 framework/source/uielement/recentfilesmenucontroller.cxx |   62 +++++++++------
 sfx2/source/toolbox/tbxitem.cxx                          |    6 +
 2 files changed, 45 insertions(+), 23 deletions(-)

New commits:
commit ea0ff1f9ded1725a3e42d57de73ff89483a7ae5b
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date:   Fri Jul 17 10:12:06 2015 +0300

    Don't show open remote entry in the recent doc menu
    
    We use the same menu controller for both the Open toolbar
    button and the Recent Documents menu. While it's
    reasonable to put the open remote file command under the
    open button, it has nothing to do with recent documents,
    so it shouldn't appear there.
    
    Also don't add the "No Document" entry in case the open
    remote entry is visible. The whole point of the "No
    Document" entry is that we can't leave the menu empty,
    but if there is another visible entry, it's not needed.
    
    Change-Id: Ibefbdc6dc7d1d49f555d8ee23f67b47eba19b445
    
    Signed-off-by: Szymon Kłos <eszkadev at gmail.com>

diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx b/framework/source/uielement/recentfilesmenucontroller.cxx
index a2c3432..61d2f02 100644
--- a/framework/source/uielement/recentfilesmenucontroller.cxx
+++ b/framework/source/uielement/recentfilesmenucontroller.cxx
@@ -60,7 +60,8 @@ class RecentFilesMenuController :  public svt::PopupMenuControllerBase
     using svt::PopupMenuControllerBase::disposing;
 
 public:
-    RecentFilesMenuController( const uno::Reference< uno::XComponentContext >& xContext );
+    RecentFilesMenuController( const uno::Reference< uno::XComponentContext >& xContext,
+                               const uno::Sequence< uno::Any >& args );
     virtual ~RecentFilesMenuController();
 
     // XServiceInfo
@@ -115,12 +116,25 @@ private:
 
     std::vector< RecentFile > m_aRecentFilesItems;
     bool                  m_bDisabled : 1;
+    bool m_bShowRemote;
 };
 
-RecentFilesMenuController::RecentFilesMenuController( const uno::Reference< uno::XComponentContext >& xContext ) :
+RecentFilesMenuController::RecentFilesMenuController( const uno::Reference< uno::XComponentContext >& xContext,
+                                                      const uno::Sequence< uno::Any >& args ) :
     svt::PopupMenuControllerBase( xContext ),
-    m_bDisabled( false )
+    m_bDisabled( false ),
+    m_bShowRemote( false )
 {
+    css::beans::PropertyValue aPropValue;
+    for ( sal_Int32 i = 0; i < args.getLength(); ++i )
+    {
+        args[i] >>= aPropValue;
+        if ( aPropValue.Name == "ShowRemote" )
+        {
+            aPropValue.Value >>= m_bShowRemote;
+            break;
+        }
+    }
 }
 
 RecentFilesMenuController::~RecentFilesMenuController()
@@ -227,26 +241,30 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >
                                         FWK_RESSTR(STR_CLEAR_RECENT_FILES_HELP) );
 
             // Open remote menu entry
-            pVCLPopupMenu->InsertItem( sal_uInt16( nCount + 2 ),
-                                       FWK_RESSTR(STR_OPEN_REMOTE) );
-            pVCLPopupMenu->SetItemCommand( sal_uInt16( nCount + 2 ),
-                                           OUString( CMD_OPEN_REMOTE ) );
+            if ( m_bShowRemote )
+            {
+                pVCLPopupMenu->InsertItem( sal_uInt16( nCount + 2 ),
+                                           FWK_RESSTR(STR_OPEN_REMOTE) );
+                pVCLPopupMenu->SetItemCommand( sal_uInt16( nCount + 2 ),
+                                               OUString( CMD_OPEN_REMOTE ) );
+            }
         }
         else
         {
-            // No recent documents => insert "no document" string
-            pVCLPopupMenu->InsertItem( 1, FWK_RESSTR(STR_NODOCUMENT) );
-            // Do not disable it, otherwise the Toolbar controller and MenuButton
-            // will display SV_RESID_STRING_NOSELECTIONPOSSIBLE instead of STR_NODOCUMENT
-            pVCLPopupMenu->SetItemBits( 1, pVCLPopupMenu->GetItemBits( 1 ) | MenuItemBits::NOSELECT );
-
-            pVCLPopupMenu->InsertSeparator();
-
-            // Open remote menu entry
-            pVCLPopupMenu->InsertItem( sal_uInt16( 2 ),
-                                       FWK_RESSTR(STR_OPEN_REMOTE) );
-            pVCLPopupMenu->SetItemCommand( sal_uInt16( 2 ),
-                                           OUString( CMD_OPEN_REMOTE ) );
+            if ( m_bShowRemote )
+            {
+                // Open remote menu entry
+                pVCLPopupMenu->InsertItem( 1, FWK_RESSTR(STR_OPEN_REMOTE) );
+                pVCLPopupMenu->SetItemCommand( 1, CMD_OPEN_REMOTE );
+            }
+            else
+            {
+                // No recent documents => insert "no document" string
+                pVCLPopupMenu->InsertItem( 1, FWK_RESSTR(STR_NODOCUMENT) );
+                // Do not disable it, otherwise the Toolbar controller and MenuButton
+                // will display SV_RESID_STRING_NOSELECTIONPOSSIBLE instead of STR_NODOCUMENT
+                pVCLPopupMenu->SetItemBits( 1, pVCLPopupMenu->GetItemBits( 1 ) | MenuItemBits::NOSELECT );
+            }
         }
     }
 }
@@ -444,9 +462,9 @@ IMPL_STATIC_LINK( RecentFilesMenuController, ExecuteHdl_Impl, LoadRecentFile*, p
 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
 com_sun_star_comp_framework_RecentFilesMenuController_get_implementation(
     css::uno::XComponentContext *context,
-    css::uno::Sequence<css::uno::Any> const &)
+    css::uno::Sequence<css::uno::Any> const &args)
 {
-    return cppu::acquire(new RecentFilesMenuController(context));
+    return cppu::acquire(new RecentFilesMenuController(context, args));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx
index aae7ef3..c432b02 100644
--- a/sfx2/source/toolbox/tbxitem.cxx
+++ b/sfx2/source/toolbox/tbxitem.cxx
@@ -1371,7 +1371,7 @@ VclPtr<SfxPopupWindow> SfxRecentFilesToolBoxControl::CreatePopupWindow()
     sal_uInt16 nItemId = GetId();
     ::Rectangle aRect( rBox.GetItemRect( nItemId ) );
 
-    Sequence< Any > aArgs( 2 );
+    Sequence< Any > aArgs( 3 );
     PropertyValue aPropValue;
 
     aPropValue.Name = "CommandURL";
@@ -1382,6 +1382,10 @@ VclPtr<SfxPopupWindow> SfxRecentFilesToolBoxControl::CreatePopupWindow()
     aPropValue.Value <<= m_xFrame;
     aArgs[1] <<= aPropValue;
 
+    aPropValue.Name = "ShowRemote";
+    aPropValue.Value <<= true;
+    aArgs[2] <<= aPropValue;
+
     uno::Reference< frame::XPopupMenuController > xPopupController( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
                 "com.sun.star.comp.framework.RecentFilesMenuController", aArgs, m_xContext ), UNO_QUERY );
 


More information about the Libreoffice-commits mailing list