Convert RID_MENU_APP_PREVIEW to xml

Change-Id: I8601c0d9c23c6b1fe191391a56602173fe600e20
This commit is contained in:
Maxim Monastirsky 2017-01-30 23:36:03 +02:00
parent ca1cb1b4ac
commit 93ada372b0
8 changed files with 66 additions and 65 deletions

View file

@ -16,6 +16,7 @@ $(eval $(call gb_UIConfig_add_menubarfiles,modules/dbapp,\
$(eval $(call gb_UIConfig_add_popupmenufiles,modules/dbapp,\
dbaccess/uiconfig/dbapp/popupmenu/edit \
dbaccess/uiconfig/dbapp/popupmenu/new \
dbaccess/uiconfig/dbapp/popupmenu/preview \
))
$(eval $(call gb_UIConfig_add_statusbarfiles,modules/dbapp,\

View file

@ -31,6 +31,7 @@
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/container/XContainer.hpp>
#include <com/sun/star/form/XLoadable.hpp>
#include <com/sun/star/frame/thePopupMenuControllerFactory.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <com/sun/star/frame/Frame.hpp>
#include <com/sun/star/frame/FrameSearchFlag.hpp>
@ -48,6 +49,7 @@
#include <com/sun/star/ucb/XCommandProcessor.hpp>
#include <com/sun/star/ucb/Command.hpp>
#include <com/sun/star/util/XCloseable.hpp>
#include <comphelper/propertyvalue.hxx>
#include <comphelper/string.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include "AppView.hxx"
@ -59,8 +61,10 @@
#include "dbaccess_slotid.hrc"
#include "databaseobjectview.hxx"
#include "imageprovider.hxx"
#include <vcl/commandinfoprovider.hxx>
#include <vcl/waitobj.hxx>
#include <vcl/settings.hxx>
#include <toolkit/awt/vclxmenu.hxx>
#include <tools/stream.hxx>
#include <rtl/ustrbuf.hxx>
#include "svtools/treelistentry.hxx"
@ -187,13 +191,14 @@ OAppDetailPageHelper::OAppDetailPageHelper(vcl::Window* _pParent,OAppBorderWindo
,m_aBorder(VclPtr<Window>::Create(this,WB_BORDER | WB_READONLY))
,m_aPreview(VclPtr<OPreviewWindow>::Create(m_aBorder.get()))
,m_aDocumentInfo(VclPtr< ::svtools::ODocumentInfoPreview>::Create(m_aBorder.get(), WB_LEFT | WB_VSCROLL | WB_READONLY) )
,m_aMenu( VclPtr<PopupMenu>::Create( ModuleRes( RID_MENU_APP_PREVIEW ) ) )
,m_ePreviewMode(_ePreviewMode)
{
m_aBorder->SetBorderStyle(WindowBorderStyle::MONO);
m_aTBPreview->SetOutStyle(TOOLBOX_STYLE_FLAT);
m_aTBPreview->InsertItem(SID_DB_APP_DISABLE_PREVIEW,m_aMenu->GetItemText(SID_DB_APP_DISABLE_PREVIEW),ToolBoxItemBits::LEFT|ToolBoxItemBits::DROPDOWN|ToolBoxItemBits::AUTOSIZE|ToolBoxItemBits::RADIOCHECK);
m_aTBPreview->InsertItem(SID_DB_APP_DISABLE_PREVIEW,
vcl::CommandInfoProvider::Instance().GetCommandPropertyFromModule(".uno:DBDisablePreview", "com.sun.star.sdb.OfficeDatabaseDocument"),
ToolBoxItemBits::LEFT|ToolBoxItemBits::DROPDOWN|ToolBoxItemBits::AUTOSIZE|ToolBoxItemBits::RADIOCHECK);
m_aTBPreview->SetHelpId(HID_APP_VIEW_PREVIEW_CB);
m_aTBPreview->SetDropdownClickHdl( LINK( this, OAppDetailPageHelper, OnDropdownClickHdl ) );
m_aTBPreview->Enable();
@ -240,7 +245,6 @@ void OAppDetailPageHelper::dispose()
rpBox.disposeAndClear();
}
}
m_aMenu.disposeAndClear();
m_pTablePreview.disposeAndClear();
m_aDocumentInfo.disposeAndClear();
m_aPreview.disposeAndClear();
@ -971,25 +975,28 @@ void OAppDetailPageHelper::switchPreview(PreviewMode _eMode,bool _bForce)
getBorderWin().getView()->getAppController().previewChanged(static_cast<sal_Int32>(m_ePreviewMode));
sal_uInt16 nSelectedAction = SID_DB_APP_DISABLE_PREVIEW;
OUString aCommand;
switch ( m_ePreviewMode )
{
case E_PREVIEWNONE:
nSelectedAction = SID_DB_APP_DISABLE_PREVIEW;
aCommand = ".uno:DBDisablePreview";
break;
case E_DOCUMENT:
nSelectedAction = SID_DB_APP_VIEW_DOC_PREVIEW;
aCommand = ".uno:DBShowDocPreview";
break;
case E_DOCUMENTINFO:
if ( getBorderWin().getView()->getAppController().isCommandEnabled(SID_DB_APP_VIEW_DOCINFO_PREVIEW) )
nSelectedAction = SID_DB_APP_VIEW_DOCINFO_PREVIEW;
aCommand = ".uno:DBShowDocInfoPreview";
else
{
m_ePreviewMode = E_PREVIEWNONE;
aCommand = ".uno:DBDisablePreview";
}
break;
}
m_aMenu->CheckItem(nSelectedAction);
m_aTBPreview->SetItemText(SID_DB_APP_DISABLE_PREVIEW, stripTrailingDots(m_aMenu->GetItemText(nSelectedAction)));
OUString aCommandLabel = vcl::CommandInfoProvider::Instance().GetCommandPropertyFromModule(aCommand, "com.sun.star.sdb.OfficeDatabaseDocument");
m_aTBPreview->SetItemText(SID_DB_APP_DISABLE_PREVIEW, stripTrailingDots(aCommandLabel));
Resize();
// simulate a selectionChanged event at the controller, to force the preview to be updated
@ -1151,21 +1158,25 @@ IMPL_LINK_NOARG(OAppDetailPageHelper, OnDropdownClickHdl, ToolBox*, void)
m_aTBPreview->Update();
// execute the menu
ScopedVclPtrInstance<PopupMenu> aMenu( ModuleRes( RID_MENU_APP_PREVIEW ) );
css::uno::Reference<css::uno::XComponentContext> xContext(getBorderWin().getView()->getORB());
css::uno::Reference<css::frame::XUIControllerFactory> xPopupMenuFactory(css::frame::thePopupMenuControllerFactory::get(xContext));
if (!xPopupMenuFactory.is())
return;
const sal_uInt16 pActions[] = { SID_DB_APP_DISABLE_PREVIEW
, SID_DB_APP_VIEW_DOC_PREVIEW
, SID_DB_APP_VIEW_DOCINFO_PREVIEW
};
css::uno::Sequence<css::uno::Any> aArgs {
css::uno::makeAny(comphelper::makePropertyValue("InToolbar", true)),
css::uno::makeAny(comphelper::makePropertyValue("ModuleIdentifier", OUString("com.sun.star.sdb.OfficeDatabaseDocument"))),
css::uno::makeAny(comphelper::makePropertyValue("Frame", getBorderWin().getView()->getAppController().getFrame())) };
for(unsigned short nAction : pActions)
{
aMenu->CheckItem(nAction,m_aMenu->IsItemChecked(nAction));
}
aMenu->EnableItem( SID_DB_APP_VIEW_DOCINFO_PREVIEW, getBorderWin().getView()->getAppController().isCommandEnabled(SID_DB_APP_VIEW_DOCINFO_PREVIEW) );
css::uno::Reference<css::frame::XPopupMenuController> xPopupController(
xPopupMenuFactory->createInstanceWithArgumentsAndContext(".uno:DBPreview", aArgs, xContext), css::uno::UNO_QUERY);
// no disabled entries
aMenu->RemoveDisabledEntries();
if (!xPopupController.is())
return;
rtl::Reference<VCLXPopupMenu> xPopupMenu(new VCLXPopupMenu);
xPopupController->setPopupMenu(xPopupMenu.get());
VclPtr<PopupMenu> aMenu(static_cast<PopupMenu*>(xPopupMenu->GetMenu()));
sal_uInt16 nSelectedAction = aMenu->Execute(m_aTBPreview.get(), m_aTBPreview->GetItemRect( SID_DB_APP_DISABLE_PREVIEW ));
// "cleanup" the toolbox state
@ -1176,8 +1187,11 @@ IMPL_LINK_NOARG(OAppDetailPageHelper, OnDropdownClickHdl, ToolBox*, void)
{
m_aTBPreview->SetItemText(SID_DB_APP_DISABLE_PREVIEW, stripTrailingDots(aMenu->GetItemText(nSelectedAction)));
Resize();
getBorderWin().getView()->getAppController().executeChecked(nSelectedAction,Sequence<PropertyValue>());
}
css::uno::Reference<css::lang::XComponent> xComponent(xPopupController, css::uno::UNO_QUERY);
if (xComponent.is())
xComponent->dispose();
}
void OAppDetailPageHelper::KeyInput( const KeyEvent& rKEvt )

View file

@ -86,7 +86,6 @@ namespace dbaui
VclPtr< ::svtools::ODocumentInfoPreview>
m_aDocumentInfo;
VclPtr<vcl::Window> m_pTablePreview;
ScopedVclPtr<PopupMenu> m_aMenu;
PreviewMode m_ePreviewMode;
css::uno::Reference < css::frame::XFrame2 >
m_xFrame;

View file

@ -173,40 +173,6 @@ String STR_QUERY_CLOSEDOCUMENTS
Text [ en-US ] = "The connection type has been altered.\nFor the changes to take effect, all forms, reports, queries and tables must be closed.\n\nDo you want to close all documents now?" ;
};
Menu RID_MENU_APP_PREVIEW
{
ItemList =
{
MenuItem
{
Identifier = SID_DB_APP_DISABLE_PREVIEW;
Text[ en-US ] = "None";
Command = ".uno:DBDisablePreview";
Checkable = TRUE;
RadioCheck = TRUE;
AutoCheck = TRUE;
};
MenuItem
{
Identifier = SID_DB_APP_VIEW_DOCINFO_PREVIEW;
Text[ en-US ] = "Document Information";
Command = ".uno:DBShowDocInfoPreview";
Checkable = TRUE;
RadioCheck = TRUE;
AutoCheck = TRUE;
};
MenuItem
{
Identifier = SID_DB_APP_VIEW_DOC_PREVIEW;
Text[ en-US ] = "Document";
Command = ".uno:DBShowDocPreview";
Checkable = TRUE;
RadioCheck = TRUE;
AutoCheck = TRUE;
};
};
};
String RID_STR_FORM
{
Text [ en-US ] = "Form";

View file

@ -129,7 +129,6 @@
#define RID_QUERYFUNCTION_POPUPMENU RID_MENU_START + 6
#define RID_TABLEDESIGNROWPOPUPMENU RID_MENU_START + 7
#define RID_SBA_RTF_PKEYPOPUP RID_MENU_START + 9
#define RID_MENU_APP_PREVIEW RID_MENU_START + 12
#define MENU_BROWSER_DEFAULTCONTEXT RID_MENU_START + 14
#define RID_MENU_JOINVIEW_CONNECTION RID_MENU_START + 16
#define RID_MENU_JOINVIEW_TABLE RID_MENU_START + 17

View file

@ -88,13 +88,7 @@
<menu:menuseparator/>
<menu:menuitem menu:id=".uno:AvailableToolbars"/>
<menu:menuitem menu:id=".uno:StatusBarVisible"/>
<menu:menu menu:id=".uno:DBPreview">
<menu:menupopup>
<menu:menuitem menu:id=".uno:DBDisablePreview" menu:style="radio"/>
<menu:menuitem menu:id=".uno:DBShowDocInfoPreview" menu:style="radio"/>
<menu:menuitem menu:id=".uno:DBShowDocPreview" menu:style="radio"/>
</menu:menupopup>
</menu:menu>
<menu:menuitem menu:id=".uno:DBPreview"/>
<menu:menuseparator/>
<menu:menu menu:id=".uno:DBSort">
<menu:menupopup>

View file

@ -0,0 +1,14 @@
<?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:menupopup xmlns:menu="http://openoffice.org/2001/menu">
<menu:menuitem menu:id=".uno:DBDisablePreview" menu:style="radio"/>
<menu:menuitem menu:id=".uno:DBShowDocInfoPreview" menu:style="radio"/>
<menu:menuitem menu:id=".uno:DBShowDocPreview" menu:style="radio"/>
</menu:menupopup>

View file

@ -425,6 +425,20 @@
<value>refreshdata</value>
</prop>
</node>
<node oor:name="c35" oor:op="replace">
<prop oor:name="Command">
<value>.uno:DBPreview</value>
</prop>
<prop oor:name="Module">
<value>com.sun.star.sdb.OfficeDatabaseDocument</value>
</prop>
<prop oor:name="Controller">
<value>com.sun.star.comp.framework.ResourceMenuController</value>
</prop>
<prop oor:name="Value">
<value>preview</value>
</prop>
</node>
</node>
<node oor:name="ToolBar">
<node oor:name="ZoomToolBox" oor:op="replace">