Kaydet (Commit) 1b70f748 authored tarafından Tamás Zolnai's avatar Tamás Zolnai Kaydeden (comit) Andras Timar

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

Reviewed-on: https://gerrit.libreoffice.org/67904
Tested-by: Jenkins
Reviewed-by: 's avatarTamás Zolnai <tamas.zolnai@collabora.com>
(cherry picked from commit dc3a2546)

Change-Id: I459f489c15ea7a25514f379b1800b926cc2087ce
Reviewed-on: https://gerrit.libreoffice.org/67920Reviewed-by: 's avatarAndras Timar <andras.timar@collabora.com>
Tested-by: 's avatarAndras Timar <andras.timar@collabora.com>
üst 1195bca0
...@@ -178,6 +178,7 @@ namespace framework ...@@ -178,6 +178,7 @@ namespace framework
void implts_reset( bool bAttach ); void implts_reset( bool bAttach );
void implts_updateMenuBarClose(); void implts_updateMenuBarClose();
bool implts_resetMenuBar(); bool implts_resetMenuBar();
void implts_createMSCompatibleMenuBar(const OUString& rName);
// locking // locking
......
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
#include <comphelper/uno3.hxx> #include <comphelper/uno3.hxx>
#include <rtl/instance.hxx> #include <rtl/instance.hxx>
#include <unotools/cmdoptions.hxx> #include <unotools/cmdoptions.hxx>
#include <unotools/compatibilityviewoptions.hxx>
#include <rtl/ref.hxx> #include <rtl/ref.hxx>
#include <rtl/strbuf.hxx> #include <rtl/strbuf.hxx>
...@@ -159,6 +160,14 @@ void LayoutManager::implts_createMenuBar(const OUString& rMenuBarName) ...@@ -159,6 +160,14 @@ void LayoutManager::implts_createMenuBar(const OUString& rMenuBarName)
{ {
SolarMutexClearableGuard aWriteLock; 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()) if (!m_bInplaceMenuSet && !m_xMenuBar.is())
{ {
m_xMenuBar = implts_createElement( rMenuBarName ); m_xMenuBar = implts_createElement( rMenuBarName );
...@@ -211,6 +220,8 @@ void LayoutManager::impl_clearUpMenuBar() ...@@ -211,6 +220,8 @@ void LayoutManager::impl_clearUpMenuBar()
{ {
implts_lock(); implts_lock();
implts_resetInplaceMenuBar();
// Clear up VCL menu bar to prepare shutdown // Clear up VCL menu bar to prepare shutdown
if ( m_xContainerWindow.is() ) if ( m_xContainerWindow.is() )
{ {
...@@ -2536,6 +2547,60 @@ bool LayoutManager::implts_resetMenuBar() ...@@ -2536,6 +2547,60 @@ bool LayoutManager::implts_resetMenuBar()
return false; 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) IMPL_LINK_NOARG(LayoutManager, MenuBarClose, void*, void)
{ {
SolarMutexClearableGuard aReadLock; SolarMutexClearableGuard aReadLock;
......
...@@ -6547,6 +6547,11 @@ ...@@ -6547,6 +6547,11 @@
<value xml:lang="en-US">Navigate</value> <value xml:lang="en-US">Navigate</value>
</prop> </prop>
</node> </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>
</node> </node>
</oor:component-data> </oor:component-data>
...@@ -11,6 +11,7 @@ $(eval $(call gb_UIConfig_UIConfig,modules/swriter)) ...@@ -11,6 +11,7 @@ $(eval $(call gb_UIConfig_UIConfig,modules/swriter))
$(eval $(call gb_UIConfig_add_menubarfiles,modules/swriter,\ $(eval $(call gb_UIConfig_add_menubarfiles,modules/swriter,\
sw/uiconfig/swriter/menubar/menubar \ sw/uiconfig/swriter/menubar/menubar \
sw/uiconfig/swriter/menubar/mscompatibleformsmenu \
)) ))
$(eval $(call gb_UIConfig_add_popupmenufiles,modules/swriter,\ $(eval $(call gb_UIConfig_add_popupmenufiles,modules/swriter,\
......
<?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>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment