[Libreoffice-commits] core.git: 2 commits - framework/inc framework/source officecfg/registry sw/uiconfig sw/UIConfig_swriter.mk

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Feb 16 15:12:56 UTC 2019


 framework/inc/services/layoutmanager.hxx                             |    2 
 framework/source/layoutmanager/layoutmanager.cxx                     |  169 +++++++---
 officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu |    5 
 sw/UIConfig_swriter.mk                                               |    1 
 sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml                |   29 +
 5 files changed, 158 insertions(+), 48 deletions(-)

New commits:
commit dc3a2546bd0ad0afe20cba9940934405174fd593
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Fri Feb 15 18:37:40 2019 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Sat Feb 16 16:12:48 2019 +0100

    MSForms: Introduce a new Forms menu which is compatible with MS Word
    
    * It's a Writer only menu by now
    * Displayed when the compatibility option is set
    * The menubar is changed during creation, so the option
    has an effect only after a restart.
    * MS compatible Forms menu contains only some ActiveX controls now
    
    Change-Id: I459f489c15ea7a25514f379b1800b926cc2087ce
    Reviewed-on: https://gerrit.libreoffice.org/67904
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/framework/inc/services/layoutmanager.hxx b/framework/inc/services/layoutmanager.hxx
index 1cd9f1d99ff7..6e15d58e2442 100644
--- a/framework/inc/services/layoutmanager.hxx
+++ b/framework/inc/services/layoutmanager.hxx
@@ -178,6 +178,7 @@ namespace framework
             void implts_reset( bool bAttach );
             void implts_updateMenuBarClose();
             bool implts_resetMenuBar();
+            void implts_createMSCompatibleMenuBar(const OUString& rName);
 
             //  locking
 
diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx
index b48e69c3b9e6..5cb364df9285 100644
--- a/framework/source/layoutmanager/layoutmanager.cxx
+++ b/framework/source/layoutmanager/layoutmanager.cxx
@@ -74,6 +74,7 @@
 #include <comphelper/uno3.hxx>
 #include <rtl/instance.hxx>
 #include <unotools/cmdoptions.hxx>
+#include <unotools/compatibilityviewoptions.hxx>
 
 #include <rtl/ref.hxx>
 #include <rtl/strbuf.hxx>
@@ -157,6 +158,14 @@ void LayoutManager::implts_createMenuBar(const OUString& rMenuBarName)
 {
     SolarMutexClearableGuard aWriteLock;
 
+    // Create a customized menu if compatibility mode is on
+    SvtCompatibilityViewOptions aCompOptions;
+    if( aCompOptions.HasMSOCompatibleFormsMenu() && m_aModuleIdentifier == "com.sun.star.text.TextDocument" )
+    {
+        implts_createMSCompatibleMenuBar(rMenuBarName);
+    }
+
+    // Create the default menubar otherwise
     if (!m_bInplaceMenuSet && !m_xMenuBar.is())
     {
         m_xMenuBar = implts_createElement( rMenuBarName );
@@ -209,6 +218,8 @@ void LayoutManager::impl_clearUpMenuBar()
 {
     implts_lock();
 
+    implts_resetInplaceMenuBar();
+
     // Clear up VCL menu bar to prepare shutdown
     if ( m_xContainerWindow.is() )
     {
@@ -2524,6 +2535,60 @@ bool LayoutManager::implts_resetMenuBar()
     return false;
 }
 
+void LayoutManager::implts_createMSCompatibleMenuBar( const OUString& aName )
+{
+    SolarMutexClearableGuard aWriteLock;
+
+    // Find Forms menu in the original menubar
+    m_xMenuBar = implts_createElement( aName );
+    uno::Reference< XUIElementSettings > xMenuBarSettings(m_xMenuBar, UNO_QUERY);
+    uno::Reference< container::XIndexReplace > xMenuIndex(xMenuBarSettings->getSettings(true), UNO_QUERY);
+
+    sal_Int32 nFormsMenu = -1;
+    for (sal_Int32 nIndex = 0; nIndex < xMenuIndex->getCount(); ++nIndex)
+    {
+        uno::Sequence< beans::PropertyValue > aProps;
+        xMenuIndex->getByIndex( nIndex ) >>= aProps;
+        OUString aCommand;
+        for (sal_Int32 nSeqInd = 0; nSeqInd < aProps.getLength(); ++nSeqInd)
+        {
+            if (aProps[nSeqInd].Name == "CommandURL")
+            {
+                aProps[nSeqInd].Value >>= aCommand;
+                break;
+            }
+        }
+
+        if (aCommand == ".uno:FormatFormMenu")
+            nFormsMenu = nIndex;
+    }
+    assert(nFormsMenu != -1);
+
+    // Create the MS compatible Forms menu
+    css::uno::Reference< css::ui::XUIElement > xFormsMenu = implts_createElement( "private:resource/menubar/mscompatibleformsmenu" );
+    if(!xFormsMenu.is())
+        return;
+
+    // Merge the MS compatible Forms menu into the menubar
+    uno::Reference< XUIElementSettings > xFormsMenuSettings(xFormsMenu, UNO_QUERY);
+    uno::Reference< container::XIndexAccess > xFormsMenuIndex(xFormsMenuSettings->getSettings(true));
+
+    assert(xFormsMenuIndex->getCount() >= 1);
+    uno::Sequence< beans::PropertyValue > aNewFormsMenu;
+    xFormsMenuIndex->getByIndex( 0 ) >>= aNewFormsMenu;
+    xMenuIndex->replaceByIndex(nFormsMenu, uno::makeAny(aNewFormsMenu));
+
+    setMergedMenuBar( xMenuIndex );
+
+    // Clear up the temporal forms menubar
+    Reference< XComponent > xFormsMenuComp( xFormsMenu, UNO_QUERY );
+    if ( xFormsMenuComp.is() )
+        xFormsMenuComp->dispose();
+    xFormsMenu.clear();
+
+    aWriteLock.clear();
+}
+
 IMPL_LINK_NOARG(LayoutManager, MenuBarClose, void*, void)
 {
     SolarMutexClearableGuard aReadLock;
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
index 5e0316d6795e..200656e87d43 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -6809,6 +6809,11 @@
           <value xml:lang="en-US">More Fields</value>
         </prop>
       </node>
+      <node oor:name=".uno:MSCompatActiveXControls" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">ActiveX Controls</value>
+        </prop>
+      </node>
     </node>
   </node>
 </oor:component-data>
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk
index 4bb3adb83cee..5e03ab5d3d7f 100644
--- a/sw/UIConfig_swriter.mk
+++ b/sw/UIConfig_swriter.mk
@@ -11,6 +11,7 @@ $(eval $(call gb_UIConfig_UIConfig,modules/swriter))
 
 $(eval $(call gb_UIConfig_add_menubarfiles,modules/swriter,\
 	sw/uiconfig/swriter/menubar/menubar \
+	sw/uiconfig/swriter/menubar/mscompatibleformsmenu \
 ))
 
 $(eval $(call gb_UIConfig_add_popupmenufiles,modules/swriter,\
diff --git a/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml b/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml
new file mode 100644
index 000000000000..4b8f5ea0e714
--- /dev/null
+++ b/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+-->
+<menu:menubar xmlns:menu="http://openoffice.org/2001/menu">
+  <menu:menu menu:id=".uno:FormatFormMenu">
+    <menu:menupopup>
+      <menu:menuitem menu:id=".uno:SwitchControlDesignMode"/>
+      <menu:menuitem menu:id=".uno:ControlProperties"/>
+      <menu:menuseparator/>
+      <menu:menu menu:id=".uno:MSCompatActiveXControls">
+        <menu:menupopup>
+          <menu:menuitem menu:id=".uno:Label"/>
+          <menu:menuitem menu:id=".uno:Edit"/>
+          <menu:menuitem menu:id=".uno:CheckBox"/>
+          <menu:menuitem menu:id=".uno:RadioButton"/>
+          <menu:menuitem menu:id=".uno:ListBox"/>
+          <menu:menuitem menu:id=".uno:Pushbutton"/>
+          <menu:menuitem menu:id=".uno:DateField"/>
+        </menu:menupopup>
+      </menu:menu>
+    </menu:menupopup>
+  </menu:menu>
+</menu:menubar>
commit 5599dfc71b4bd0a2f9130cb51a0dc8fe7eaf9fdb
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Fri Feb 15 18:36:25 2019 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Sat Feb 16 16:12:34 2019 +0100

    MSForms: Extract menu creation to a separate method
    
    No functional change is intended.
    
    Change-Id: Ieb88e746b08c6a6daac14c08a206db73cbeef8a9
    Reviewed-on: https://gerrit.libreoffice.org/67903
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/framework/inc/services/layoutmanager.hxx b/framework/inc/services/layoutmanager.hxx
index eaecc6fa8e87..1cd9f1d99ff7 100644
--- a/framework/inc/services/layoutmanager.hxx
+++ b/framework/inc/services/layoutmanager.hxx
@@ -173,6 +173,7 @@ namespace framework
 
             //  menu bar
 
+            void implts_createMenuBar( const OUString& rMenuBarName );
             void impl_clearUpMenuBar();
             void implts_reset( bool bAttach );
             void implts_updateMenuBarClose();
diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx
index ae58c71deb72..b48e69c3b9e6 100644
--- a/framework/source/layoutmanager/layoutmanager.cxx
+++ b/framework/source/layoutmanager/layoutmanager.cxx
@@ -153,6 +153,57 @@ LayoutManager::~LayoutManager()
     m_pGlobalSettings.reset();
 }
 
+void LayoutManager::implts_createMenuBar(const OUString& rMenuBarName)
+{
+    SolarMutexClearableGuard aWriteLock;
+
+    if (!m_bInplaceMenuSet && !m_xMenuBar.is())
+    {
+        m_xMenuBar = implts_createElement( rMenuBarName );
+        if ( m_xMenuBar.is() )
+        {
+            SolarMutexGuard aGuard;
+
+            SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow );
+            if ( pSysWindow )
+            {
+                Reference< awt::XMenuBar > xMenuBar;
+
+                Reference< XPropertySet > xPropSet( m_xMenuBar, UNO_QUERY );
+                if ( xPropSet.is() )
+                {
+                    try
+                    {
+                        xPropSet->getPropertyValue("XMenuBar") >>= xMenuBar;
+                    }
+                    catch (const beans::UnknownPropertyException&)
+                    {
+                    }
+                    catch (const lang::WrappedTargetException&)
+                    {
+                    }
+                }
+
+                if ( xMenuBar.is() )
+                {
+                    VCLXMenu* pAwtMenuBar = VCLXMenu::GetImplementation( xMenuBar );
+                    if ( pAwtMenuBar )
+                    {
+                        MenuBar* pMenuBar = static_cast<MenuBar*>(pAwtMenuBar->GetMenu());
+                        if ( pMenuBar )
+                        {
+                            pSysWindow->SetMenuBar(pMenuBar);
+                            pMenuBar->SetDisplayable( m_bMenuVisible );
+                            implts_updateMenuBarClose();
+                        }
+                    }
+                }
+            }
+        }
+    }
+    aWriteLock.clear();
+}
+
 // Internal helper function
 void LayoutManager::impl_clearUpMenuBar()
 {
@@ -1379,7 +1430,6 @@ void SAL_CALL LayoutManager::createElement( const OUString& aName )
 
     SolarMutexClearableGuard aReadLock;
     Reference< XFrame > xFrame = m_xFrame;
-    bool    bInPlaceMenu = m_bInplaceMenuSet;
     aReadLock.clear();
 
     if ( !xFrame.is() )
@@ -1415,55 +1465,13 @@ void SAL_CALL LayoutManager::createElement( const OUString& aName )
             bMustBeLayouted = m_xToolbarManager->isLayoutDirty();
         }
         else if ( aElementType.equalsIgnoreAsciiCase("menubar") &&
-                  aElementName.equalsIgnoreAsciiCase("menubar") )
+                  aElementName.equalsIgnoreAsciiCase("menubar") &&
+                  implts_isFrameOrWindowTop(xFrame) )
         {
-            // #i38743# don't create a menubar if frame isn't top
-            if ( !bInPlaceMenu && !m_xMenuBar.is() && implts_isFrameOrWindowTop( xFrame ))
-            {
-                m_xMenuBar = implts_createElement( aName );
-                if ( m_xMenuBar.is() )
-                {
-                    SolarMutexGuard aGuard;
+            implts_createMenuBar( aName );
+            if (m_bMenuVisible)
+                bNotify = true;
 
-                    SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow );
-                    if ( pSysWindow )
-                    {
-                        Reference< awt::XMenuBar > xMenuBar;
-
-                        Reference< XPropertySet > xPropSet( m_xMenuBar, UNO_QUERY );
-                        if ( xPropSet.is() )
-                        {
-                            try
-                            {
-                                xPropSet->getPropertyValue("XMenuBar") >>= xMenuBar;
-                            }
-                            catch (const beans::UnknownPropertyException&)
-                            {
-                            }
-                            catch (const lang::WrappedTargetException&)
-                            {
-                            }
-                        }
-
-                        if ( xMenuBar.is() )
-                        {
-                            VCLXMenu* pAwtMenuBar = VCLXMenu::GetImplementation( xMenuBar );
-                            if ( pAwtMenuBar )
-                            {
-                                MenuBar* pMenuBar = static_cast<MenuBar*>(pAwtMenuBar->GetMenu());
-                                if ( pMenuBar )
-                                {
-                                    pSysWindow->SetMenuBar(pMenuBar);
-                                    pMenuBar->SetDisplayable( m_bMenuVisible );
-                                    if ( m_bMenuVisible )
-                                        bNotify = true;
-                                    implts_updateMenuBarClose();
-                                }
-                            }
-                        }
-                    }
-                }
-            }
             aWriteLock.clear();
         }
         else if ( aElementType.equalsIgnoreAsciiCase("statusbar") &&


More information about the Libreoffice-commits mailing list