summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-12-11 17:18:13 +0200
committerNoel Grandin <noel@peralex.com>2012-12-21 09:12:07 +0200
commite93a0018871ebea4da1959c72c06f3c7f4dc7b27 (patch)
tree3f9b5b2dcde5d428e182966ace4a641aafe231c4
parentecae523d9603eaf7ff0acc98682576813e50c94a (diff)
fdo#46808, Adapt frame::PopupMenuControllerFactory UNO service to new style
Required creating a new merged interface. The service interface is going to be shared by some other services, which is why it's name is != the service name. Change-Id: I9af3c27b367807147a0052fb6fa4e42eb1ad32de
-rw-r--r--desktop/source/app/app.cxx26
-rw-r--r--framework/inc/services.h1
-rw-r--r--framework/inc/uielement/menubarmanager.hxx3
-rw-r--r--framework/inc/uifactory/toolbarcontrollerfactory.hxx10
-rw-r--r--framework/source/uielement/menubarmanager.cxx65
-rw-r--r--framework/source/uielement/popupmenucontroller.cxx9
-rw-r--r--framework/source/uifactory/popupmenucontrollerfactory.cxx2
-rw-r--r--offapi/UnoApi_offapi.mk3
-rw-r--r--offapi/com/sun/star/frame/PopupMenuControllerFactory.idl28
-rw-r--r--offapi/com/sun/star/frame/XToolbarControllerFactory.idl65
10 files changed, 120 insertions, 92 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index a83296f95e03..493f19065491 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -38,6 +38,7 @@
#include <com/sun/star/frame/GlobalEventBroadcaster.hpp>
#include <com/sun/star/frame/XSessionManagerListener.hpp>
#include <com/sun/star/frame/XSynchronousDispatch.hpp>
+#include <com/sun/star/frame/PopupMenuControllerFactory.hpp>
#include <com/sun/star/document/CorruptedFilterConfigurationException.hpp>
#include <com/sun/star/configuration/CorruptedConfigurationException.hpp>
#include <com/sun/star/configuration/theDefaultProvider.hpp>
@@ -2149,21 +2150,16 @@ void Desktop::PreloadConfigurationData()
// preload popup menu controller factories. As all controllers are in the same
// configuration file they also get preloaded!
- Reference< ::com::sun::star::frame::XUIControllerRegistration > xPopupMenuControllerFactory(
- rFactory->createInstance(
- rtl::OUString( "com.sun.star.frame.PopupMenuControllerFactory" )),
- UNO_QUERY );
- if ( xPopupMenuControllerFactory.is() )
+ Reference< css::frame::XToolbarControllerFactory > xPopupMenuControllerFactory =
+ css::frame::PopupMenuControllerFactory::create( xContext );
+ try
+ {
+ xPopupMenuControllerFactory->hasController(
+ rtl::OUString( ".uno:CharFontName" ),
+ OUString() );
+ }
+ catch ( const ::com::sun::star::uno::Exception& )
{
- try
- {
- xPopupMenuControllerFactory->hasController(
- rtl::OUString( ".uno:CharFontName" ),
- OUString() );
- }
- catch ( const ::com::sun::star::uno::Exception& )
- {
- }
}
// preload filter configuration
@@ -2207,8 +2203,6 @@ void Desktop::OpenClients()
const CommandLineArgs& rArgs = GetCommandLineArgs();
SvtInternalOptions aInternalOptions;
- Reference<XMultiServiceFactory> rFactory = ::comphelper::getProcessServiceFactory();
-
if (!rArgs.IsQuickstart())
{
sal_Bool bShowHelp = sal_False;
diff --git a/framework/inc/services.h b/framework/inc/services.h
index cfec934588e2..6606328fcab5 100644
--- a/framework/inc/services.h
+++ b/framework/inc/services.h
@@ -54,7 +54,6 @@ namespace framework{
#define SERVICENAME_DETECTORFACTORY DECLARE_ASCII("com.sun.star.document.ExtendedTypeDetectionFactory" )
#define SERVICENAME_SCRIPTCONVERTER DECLARE_ASCII("com.sun.star.script.Converter" )
#define SERVICENAME_LAYOUTMANAGER DECLARE_ASCII("com.sun.star.frame.LayoutManager" )
-#define SERVICENAME_POPUPMENUCONTROLLERFACTORY DECLARE_ASCII("com.sun.star.frame.PopupMenuControllerFactory" )
#define SERVICENAME_POPUPMENUCONTROLLER DECLARE_ASCII("com.sun.star.frame.PopupMenuController" )
#define SERVICENAME_UICONFIGURATIONMANAGER DECLARE_ASCII("com.sun.star.ui.UIConfigurationManager" )
#define SERVICENAME_MODULEUICONFIGURATIONMANAGER DECLARE_ASCII("com.sun.star.ui.ModuleUIConfigurationManager" )
diff --git a/framework/inc/uielement/menubarmanager.hxx b/framework/inc/uielement/menubarmanager.hxx
index 741551a51248..13397cca3ea0 100644
--- a/framework/inc/uielement/menubarmanager.hxx
+++ b/framework/inc/uielement/menubarmanager.hxx
@@ -34,6 +34,7 @@
#include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/frame/FeatureStateEvent.hpp>
#include <com/sun/star/frame/XFrameActionListener.hpp>
+#include <com/sun/star/frame/XToolbarControllerFactory.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/frame/XPopupMenuController.hpp>
#include <com/sun/star/awt/XSystemDependentMenuPeer.hpp>
@@ -235,7 +236,7 @@ class MenuBarManager : public com::sun::star::frame::XStatusListener
Menu* m_pVCLMenu;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xUICommandLabels;
- ::com::sun::star::uno::Reference< ::com::sun::star::frame::XUIControllerRegistration > m_xPopupMenuControllerRegistration;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XToolbarControllerFactory > m_xPopupMenuControllerRegistration;
::std::vector< MenuItemHandler* > m_aMenuItemHandlerVector;
::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xDispatchProvider;
diff --git a/framework/inc/uifactory/toolbarcontrollerfactory.hxx b/framework/inc/uifactory/toolbarcontrollerfactory.hxx
index 1e989a770441..c750a44fb9d2 100644
--- a/framework/inc/uifactory/toolbarcontrollerfactory.hxx
+++ b/framework/inc/uifactory/toolbarcontrollerfactory.hxx
@@ -29,10 +29,9 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XTypeProvider.hpp>
-#include <com/sun/star/lang/XMultiComponentFactory.hpp>
-#include <com/sun/star/frame/XUIControllerRegistration.hpp>
+#include <com/sun/star/frame/XToolbarControllerFactory.hpp>
-#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/implbase2.hxx>
#include <rtl/ustring.hxx>
namespace framework
@@ -40,9 +39,8 @@ namespace framework
class ConfigurationAccess_ControllerFactory;
class ToolbarControllerFactory : protected ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses.
- public ::cppu::WeakImplHelper3< com::sun::star::lang::XServiceInfo,
- com::sun::star::lang::XMultiComponentFactory,
- com::sun::star::frame::XUIControllerRegistration>
+ public ::cppu::WeakImplHelper2< com::sun::star::lang::XServiceInfo,
+ com::sun::star::frame::XToolbarControllerFactory>
{
public:
ToolbarControllerFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx
index f12dca4a8cab..49c35c4cc83f 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -36,6 +36,7 @@
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/frame/XFramesSupplier.hpp>
#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/frame/PopupMenuControllerFactory.hpp>
#include <com/sun/star/container/XEnumeration.hpp>
#include <com/sun/star/util/XStringWidth.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
@@ -188,9 +189,7 @@ MenuBarManager::MenuBarManager(
, m_nSymbolsStyle( SvtMiscOptions().GetCurrentSymbolsStyle() )
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::MenuBarManager" );
- m_xPopupMenuControllerRegistration = Reference< ::com::sun::star::frame::XUIControllerRegistration >(
- getServiceFactory()->createInstance( rtl::OUString( "com.sun.star.frame.PopupMenuControllerFactory" )),
- UNO_QUERY );
+ m_xPopupMenuControllerRegistration = PopupMenuControllerFactory::create( comphelper::getComponentContext(getServiceFactory()) );
FillMenuManager( pMenu, rFrame, rDispatchProvider, rModuleIdentifier, bDelete, bDeleteChildren );
}
@@ -1195,37 +1194,33 @@ sal_Bool MenuBarManager::CreatePopupMenuController( MenuItemHandler* pMenuItemHa
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::CreatePopupMenuController" );
rtl::OUString aItemCommand( pMenuItemHandler->aMenuItemURL );
- // Try instanciate a popup menu controller. It is stored in the menu item handler.
- Reference< XMultiComponentFactory > xPopupMenuControllerFactory( m_xPopupMenuControllerRegistration, UNO_QUERY );
- if ( xPopupMenuControllerFactory.is() )
+ // Try instantiate a popup menu controller. It is stored in the menu item handler.
+ Sequence< Any > aSeq( 2 );
+ PropertyValue aPropValue;
+
+ aPropValue.Name = rtl::OUString( "ModuleName" );
+ aPropValue.Value <<= m_aModuleIdentifier;
+ aSeq[0] <<= aPropValue;
+ aPropValue.Name = rtl::OUString( "Frame" );
+ aPropValue.Value <<= m_xFrame;
+ aSeq[1] <<= aPropValue;
+
+ Reference< XComponentContext > xComponentContext(
+ comphelper::getComponentContext( getServiceFactory() ) );
+
+ Reference< XPopupMenuController > xPopupMenuController(
+ m_xPopupMenuControllerRegistration->createInstanceWithArgumentsAndContext(
+ aItemCommand,
+ aSeq,
+ xComponentContext ),
+ UNO_QUERY );
+
+ if ( xPopupMenuController.is() )
{
- Sequence< Any > aSeq( 2 );
- PropertyValue aPropValue;
-
- aPropValue.Name = rtl::OUString( "ModuleName" );
- aPropValue.Value <<= m_aModuleIdentifier;
- aSeq[0] <<= aPropValue;
- aPropValue.Name = rtl::OUString( "Frame" );
- aPropValue.Value <<= m_xFrame;
- aSeq[1] <<= aPropValue;
-
- Reference< XComponentContext > xComponentContext(
- comphelper::getComponentContext( getServiceFactory() ) );
-
- Reference< XPopupMenuController > xPopupMenuController(
- xPopupMenuControllerFactory->createInstanceWithArgumentsAndContext(
- aItemCommand,
- aSeq,
- xComponentContext ),
- UNO_QUERY );
-
- if ( xPopupMenuController.is() )
- {
- // Provide our awt popup menu to the popup menu controller
- pMenuItemHandler->xPopupMenuController = xPopupMenuController;
- xPopupMenuController->setPopupMenu( pMenuItemHandler->xPopupMenu );
- return sal_True;
- }
+ // Provide our awt popup menu to the popup menu controller
+ pMenuItemHandler->xPopupMenuController = xPopupMenuController;
+ xPopupMenuController->setPopupMenu( pMenuItemHandler->xPopupMenu );
+ return sal_True;
}
return sal_False;
@@ -2028,9 +2023,7 @@ void MenuBarManager::Init(const Reference< XFrame >& rFrame,AddonMenu* pAddonMen
m_bIsBookmarkMenu = sal_True;
rtl::OUString aModuleIdentifier;
- m_xPopupMenuControllerRegistration = Reference< ::com::sun::star::frame::XUIControllerRegistration >(
- getServiceFactory()->createInstance( rtl::OUString( "com.sun.star.frame.PopupMenuControllerFactory" )),
- UNO_QUERY );
+ m_xPopupMenuControllerRegistration = PopupMenuControllerFactory::create( comphelper::getComponentContext(getServiceFactory()) );
Reference< XStatusListener > xStatusListener;
Reference< XDispatch > xDispatch;
diff --git a/framework/source/uielement/popupmenucontroller.cxx b/framework/source/uielement/popupmenucontroller.cxx
index fd41cffb1a65..772a3aa15bb3 100644
--- a/framework/source/uielement/popupmenucontroller.cxx
+++ b/framework/source/uielement/popupmenucontroller.cxx
@@ -20,6 +20,7 @@
#include <com/sun/star/awt/XPopupMenu.hpp>
#include <com/sun/star/frame/XPopupMenuController.hpp>
+#include <com/sun/star/frame/PopupMenuControllerFactory.hpp>
#include <toolkit/helper/vclunohelper.hxx>
@@ -156,7 +157,10 @@ void SAL_CALL PopupMenuController::doubleClick() throw (RuntimeException)
bool PopupMenuController::CreatePopupMenuController() throw (Exception)
{
- Reference< XMultiComponentFactory > xPopupMenuControllerRegistration( getServiceManager()->createInstance( SERVICENAME_POPUPMENUCONTROLLERFACTORY ), UNO_QUERY_THROW );
+ Reference< XComponentContext > xComponentContext(
+ comphelper::getComponentContext( getServiceManager() ) );
+
+ Reference< XToolbarControllerFactory > xPopupMenuControllerRegistration = PopupMenuControllerFactory::create( xComponentContext );
Sequence< Any > aSeq( 2 );
PropertyValue aPropValue;
@@ -168,9 +172,6 @@ bool PopupMenuController::CreatePopupMenuController() throw (Exception)
aPropValue.Value <<= m_xFrame;
aSeq[1] <<= aPropValue;
- Reference< XComponentContext > xComponentContext(
- comphelper::getComponentContext( getServiceManager() ) );
-
Reference< XPopupMenuController > xPopupMenuController( xPopupMenuControllerRegistration->createInstanceWithArgumentsAndContext( getCommandURL(), aSeq, xComponentContext ), UNO_QUERY );
if ( xPopupMenuController.is() )
{
diff --git a/framework/source/uifactory/popupmenucontrollerfactory.cxx b/framework/source/uifactory/popupmenucontrollerfactory.cxx
index 34dd936f7b72..90a58477a9b2 100644
--- a/framework/source/uifactory/popupmenucontrollerfactory.cxx
+++ b/framework/source/uifactory/popupmenucontrollerfactory.cxx
@@ -54,7 +54,7 @@ namespace framework
//*****************************************************************************************************************
DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( PopupMenuControllerFactory ,
::cppu::OWeakObject ,
- SERVICENAME_POPUPMENUCONTROLLERFACTORY ,
+ DECLARE_ASCII("com.sun.star.frame.PopupMenuControllerFactory"),
IMPLEMENTATIONNAME_POPUPMENUCONTROLLERFACTORY
)
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 55c1d38443da..7fe2cbba85b4 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -129,6 +129,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/frame,\
GlobalEventBroadcaster \
MediaTypeDetectionHelper \
ModuleManager \
+ PopupMenuControllerFactory \
ToolBarControllerFactory \
UICommandDescription \
))
@@ -839,7 +840,6 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/frame,\
FramesContainer \
LayoutManager \
PopupMenuController \
- PopupMenuControllerFactory \
ProtocolHandler \
SessionManager \
Settings \
@@ -2534,6 +2534,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/frame,\
XTitleChangeBroadcaster \
XTitleChangeListener \
XToolbarController \
+ XToolbarControllerFactory \
XToolbarControllerListener \
XTransientDocumentsDocumentContentFactory \
XUIControllerRegistration \
diff --git a/offapi/com/sun/star/frame/PopupMenuControllerFactory.idl b/offapi/com/sun/star/frame/PopupMenuControllerFactory.idl
index 03e0fd8098a6..674112b66cc7 100644
--- a/offapi/com/sun/star/frame/PopupMenuControllerFactory.idl
+++ b/offapi/com/sun/star/frame/PopupMenuControllerFactory.idl
@@ -20,8 +20,7 @@
#ifndef __com_sun_star_frame_PopupMenuControllerFactory_idl__
#define __com_sun_star_frame_PopupMenuControllerFactory_idl__
-#include <com/sun/star/lang/XMultiComponentFactory.idl>
-#include <com/sun/star/frame/XUIControllerRegistration.idl>
+#include <com/sun/star/frame/XToolbarControllerFactory.idl>
module com { module sun { module star { module frame {
@@ -38,30 +37,7 @@ module com { module sun { module star { module frame {
@since OOo 2.0
*/
-service PopupMenuControllerFactory
-{
- /** this interface provides functions to create new instances of a registered pop-up menu controller.
-
- <p>
- Use <member scope="com.sun.star.lang">XMultiComponentFactory::createInstanceWithArguments()</member> to create
- a new pop-up menu controller instance. Use the CommandURL as the service specifier.
-
- This call supports the following arguments provided as <type scope="com::sun::star::beans">PropertyValue</type>:
- <ul>
- <li><b>Frame</b><br>specifies the <type scope="com::sun::star::frame">XFrame</type>
- instance to which the pop-up menu controller belongs to. This property must be provided to
- the pop-up menu controller, otherwise it cannot dispatch its internal commands.</li>
- <li><b>ModuleIdentifier</b><br>optional string that specifies in which module context the pop-up menu
- controller should be created.</li>
- </ul>
- </p>
- */
- interface com::sun::star::lang::XMultiComponentFactory;
-
- /** provides functions to query for, register and deregister a pop-up menu controller.
- */
- interface com::sun::star::frame::XUIControllerRegistration;
-};
+service PopupMenuControllerFactory : XToolbarControllerFactory;
}; }; }; };
diff --git a/offapi/com/sun/star/frame/XToolbarControllerFactory.idl b/offapi/com/sun/star/frame/XToolbarControllerFactory.idl
new file mode 100644
index 000000000000..8f3ac8ce0d4d
--- /dev/null
+++ b/offapi/com/sun/star/frame/XToolbarControllerFactory.idl
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef __com_sun_star_frame_XToolbarControllerFactory_idl__
+#define __com_sun_star_frame_XToolbarControllerFactory_idl__
+
+#include <com/sun/star/lang/XMultiComponentFactory.idl>
+#include <com/sun/star/frame/XUIControllerRegistration.idl>
+
+
+module com { module sun { module star { module frame {
+
+
+/** Provides a unified interface for the new-style PopupMenuControllerFactory service to implement.
+
+ @since LibreOffice 4.1
+*/
+
+interface XToolbarControllerFactory
+{
+ /** this interface provides functions to create new instances of a registered pop-up menu controller.
+
+ <p>
+ Use <member scope="com.sun.star.lang">XMultiComponentFactory::createInstanceWithArguments()</member> to create
+ a new pop-up menu controller instance. Use the CommandURL as the service specifier.
+
+ This call supports the following arguments provided as <type scope="com::sun::star::beans">PropertyValue</type>:
+ <ul>
+ <li><b>Frame</b><br>specifies the <type scope="com::sun::star::frame">XFrame</type>
+ instance to which the pop-up menu controller belongs to. This property must be provided to
+ the pop-up menu controller, otherwise it cannot dispatch its internal commands.</li>
+ <li><b>ModuleIdentifier</b><br>optional string that specifies in which module context the pop-up menu
+ controller should be created.</li>
+ </ul>
+ </p>
+ */
+ interface com::sun::star::lang::XMultiComponentFactory;
+
+ /** provides functions to query for, register and deregister a pop-up menu controller.
+ */
+ interface com::sun::star::frame::XUIControllerRegistration;
+};
+
+}; }; }; };
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */