From 0a9020a84da16385f1d5ba0fd9992433450dfd3c Mon Sep 17 00:00:00 2001 From: Tamás Zolnai Date: Fri, 15 Feb 2019 18:37:40 +0100 Subject: MSForms: Introduce a new Forms menu which is compatible with MS Word MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 Reviewed-on: https://gerrit.libreoffice.org/67904 Tested-by: Jenkins Reviewed-by: Tamás Zolnai (cherry picked from commit dc3a2546bd0ad0afe20cba9940934405174fd593) Change-Id: I459f489c15ea7a25514f379b1800b926cc2087ce Reviewed-on: https://gerrit.libreoffice.org/67920 Reviewed-by: Andras Timar Tested-by: Andras Timar --- framework/inc/services/layoutmanager.hxx | 1 + framework/source/layoutmanager/layoutmanager.cxx | 65 ++++++++++++++++++++++ .../org/openoffice/Office/UI/GenericCommands.xcu | 5 ++ sw/UIConfig_swriter.mk | 1 + .../swriter/menubar/mscompatibleformsmenu.xml | 29 ++++++++++ 5 files changed, 101 insertions(+) create mode 100644 sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml 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 8520b7bd8bad..86182188c708 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -73,6 +73,7 @@ #include #include #include +#include #include #include @@ -156,6 +157,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 ); @@ -208,6 +217,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 2bc7f9584a3a..fee50cba3d59 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -6829,6 +6829,11 @@ More Fields + + + ActiveX Controls + + diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk index bba8c908e805..99d2eebfb39a 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 @@ + + + + + + + + + + + + + + + + + + + + + + -- cgit