summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2014-01-16 23:15:46 +0100
committerMatúš Kukan <matus.kukan@collabora.com>2014-01-17 12:25:11 +0100
commit307878b6e2418e34478456e650d1f0fe1636bd8a (patch)
tree09b994acf151e272adf0c60ccafd189530437b72
parent9622a8072c5ef2af537e492cdd242d85ee22d4d7 (diff)
fwk: Constructor feature for ControlMenuController.
Change-Id: I789205c1bc9ceefda003d9887ac4409625539537
-rw-r--r--framework/inc/uielement/controlmenucontroller.hxx98
-rw-r--r--framework/source/register/registerservices.cxx2
-rw-r--r--framework/source/uielement/controlmenucontroller.cxx113
-rw-r--r--framework/util/fwk.component3
4 files changed, 91 insertions, 125 deletions
diff --git a/framework/inc/uielement/controlmenucontroller.hxx b/framework/inc/uielement/controlmenucontroller.hxx
deleted file mode 100644
index 14f601e79eb1..000000000000
--- a/framework/inc/uielement/controlmenucontroller.hxx
+++ /dev/null
@@ -1,98 +0,0 @@
-/* -*- 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 INCLUDED_FRAMEWORK_INC_UIELEMENT_CONTROLMENUCONTROLLER_HXX
-#define INCLUDED_FRAMEWORK_INC_UIELEMENT_CONTROLMENUCONTROLLER_HXX
-
-#include <macros/xserviceinfo.hxx>
-#include <stdtypes.h>
-
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/lang/XTypeProvider.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/frame/XFrame.hpp>
-#include <com/sun/star/frame/XDispatch.hpp>
-#include <com/sun/star/frame/XStatusListener.hpp>
-#include <com/sun/star/frame/XPopupMenuController.hpp>
-#include <com/sun/star/frame/status/Verb.hpp>
-#include <com/sun/star/frame/XModel.hpp>
-
-#include <svtools/popupmenucontrollerbase.hxx>
-#include <toolkit/awt/vclxmenu.hxx>
-#include <cppuhelper/weak.hxx>
-#include <rtl/ustring.hxx>
-
-class PopupMenu;
-namespace framework
-{
- class ControlMenuController : public svt::PopupMenuControllerBase
- {
- using svt::PopupMenuControllerBase::disposing;
-
- public:
- ControlMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
- virtual ~ControlMenuController();
-
- // XServiceInfo
- DECLARE_XSERVICEINFO
-
- // XPopupMenuController
- virtual void SAL_CALL updatePopupMenu() throw (::com::sun::star::uno::RuntimeException);
-
- // XInitialization
- virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
-
- // XStatusListener
- virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
-
- // XMenuListener
- virtual void SAL_CALL itemActivated( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException);
-
- // XEventListener
- virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException );
-
- private:
- virtual void impl_setPopupMenu();
- virtual void impl_select(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& _xDispatch,const ::com::sun::star::util::URL& aURL);
-
- class UrlToDispatchMap : public ::boost::unordered_map< OUString,
- com::sun::star::uno::Reference< com::sun::star::frame::XDispatch >,
- OUStringHash,
- ::std::equal_to< OUString > >
- {
- public:
- inline void free()
- {
- UrlToDispatchMap().swap( *this );
- }
- };
-
- void updateImagesPopupMenu( PopupMenu* pPopupMenu );
- void fillPopupMenu( com::sun::star::uno::Reference< com::sun::star::awt::XPopupMenu >& rPopupMenu );
-
- sal_Bool m_bShowMenuImages : 1;
- PopupMenu* m_pResPopupMenu;
- UrlToDispatchMap m_aURLToDispatchMap;
- };
-}
-
-#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_CONTROLMENUCONTROLLER_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/register/registerservices.cxx b/framework/source/register/registerservices.cxx
index 748da64ad214..53efb71b4e8d 100644
--- a/framework/source/register/registerservices.cxx
+++ b/framework/source/register/registerservices.cxx
@@ -37,7 +37,6 @@
#include <jobs/jobexecutor.hxx>
#include <uifactory/uielementfactorymanager.hxx>
#include <uifactory/uicontrollerfactory.hxx>
-#include <uielement/controlmenucontroller.hxx>
#include <uielement/uicommanddescription.hxx>
#include <uiconfiguration/moduleuicfgsupplier.hxx>
#include <uiconfiguration/moduleuiconfigurationmanager.hxx>
@@ -62,7 +61,6 @@ COMPONENTGETFACTORY ( fwk,
IFFACTORY( ::framework::JobExecutor ) else
IFFACTORY( ::framework::UIElementFactoryManager ) else
IFFACTORY( ::framework::PopupMenuControllerFactory ) else
- IFFACTORY( ::framework::ControlMenuController ) else
IFFACTORY( ::framework::UICommandDescription ) else
IFFACTORY( ::framework::ModuleUIConfigurationManagerSupplier ) else
IFFACTORY( ::framework::ModuleUIConfigurationManager ) else
diff --git a/framework/source/uielement/controlmenucontroller.cxx b/framework/source/uielement/controlmenucontroller.cxx
index b5e4302ba93a..a3846d46bcf9 100644
--- a/framework/source/uielement/controlmenucontroller.cxx
+++ b/framework/source/uielement/controlmenucontroller.cxx
@@ -17,29 +17,30 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <sal/macros.h>
-#include <uielement/controlmenucontroller.hxx>
+#include <sal/config.h>
#include <threadhelp/resetableguard.hxx>
-#include "services.h"
+#include <stdtypes.h>
-#include <com/sun/star/awt/XDevice.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/awt/MenuItemStyle.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp>
-#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
-#include <com/sun/star/container/XNameContainer.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/frame/XStatusListener.hpp>
+#include <com/sun/star/frame/XPopupMenuController.hpp>
+#include <cppuhelper/supportsservice.hxx>
#include <vcl/menu.hxx>
#include <vcl/svapp.hxx>
#include <vcl/i18nhelp.hxx>
+#include <rtl/ref.hxx>
#include <rtl/ustrbuf.hxx>
-#include <rtl/strbuf.hxx>
#include <svl/solar.hrc>
#include <tools/rcid.h>
#include <vcl/image.hxx>
#include <svtools/menuoptions.hxx>
+#include <svtools/popupmenucontrollerbase.hxx>
#include <osl/mutex.hxx>
// Copied from svx
@@ -163,28 +164,82 @@ static const char* aCommands[] =
".uno:ConvertToSpinButton"
};
-//_________________________________________________________________________________________________________________
-// Defines
-//_________________________________________________________________________________________________________________
-
+using namespace css;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::frame;
using namespace com::sun::star::beans;
-using namespace com::sun::star::util;
-using namespace com::sun::star::style;
-using namespace com::sun::star::container;
-namespace framework
+namespace {
+
+class ControlMenuController : public svt::PopupMenuControllerBase
{
+ using svt::PopupMenuControllerBase::disposing;
+
+public:
+ ControlMenuController( const uno::Reference< uno::XComponentContext >& xContext );
+ virtual ~ControlMenuController();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName()
+ throw (css::uno::RuntimeException)
+ {
+ return OUString("com.sun.star.comp.framework.ControlMenuController");
+ }
+
+ virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
+ throw (css::uno::RuntimeException)
+ {
+ return cppu::supportsService(this, ServiceName);
+ }
+
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
+ throw (css::uno::RuntimeException)
+ {
+ css::uno::Sequence< OUString > aSeq(1);
+ aSeq[0] = OUString("com.sun.star.frame.PopupMenuController");
+ return aSeq;
+ }
+
+
+ // XPopupMenuController
+ virtual void SAL_CALL updatePopupMenu() throw (uno::RuntimeException);
-DEFINE_XSERVICEINFO_MULTISERVICE_2 ( ControlMenuController ,
- OWeakObject ,
- SERVICENAME_POPUPMENUCONTROLLER ,
- IMPLEMENTATIONNAME_CONTROLMENUCONTROLLER
- )
+ // XInitialization
+ virtual void SAL_CALL initialize( const uno::Sequence< uno::Any >& aArguments ) throw (uno::Exception, uno::RuntimeException);
-DEFINE_INIT_SERVICE ( ControlMenuController, {} )
+ // XStatusListener
+ virtual void SAL_CALL statusChanged( const frame::FeatureStateEvent& Event ) throw ( uno::RuntimeException );
+
+ // XMenuListener
+ virtual void SAL_CALL itemActivated( const awt::MenuEvent& rEvent ) throw (uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const lang::EventObject& Source ) throw ( uno::RuntimeException );
+
+private:
+ virtual void impl_setPopupMenu();
+ virtual void impl_select(const uno::Reference< frame::XDispatch >& _xDispatch,const util::URL& aURL);
+
+ class UrlToDispatchMap : public ::boost::unordered_map< OUString,
+ uno::Reference< frame::XDispatch >,
+ OUStringHash,
+ ::std::equal_to< OUString > >
+ {
+ public:
+ inline void free()
+ {
+ UrlToDispatchMap().swap( *this );
+ }
+ };
+
+ void updateImagesPopupMenu( PopupMenu* pPopupMenu );
+ void fillPopupMenu( uno::Reference< awt::XPopupMenu >& rPopupMenu );
+
+ sal_Bool m_bShowMenuImages : 1;
+ PopupMenu* m_pResPopupMenu;
+ UrlToDispatchMap m_aURLToDispatchMap;
+};
ControlMenuController::ControlMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ) :
svt::PopupMenuControllerBase( xContext ),
@@ -372,7 +427,7 @@ void SAL_CALL ControlMenuController::updatePopupMenu() throw (::com::sun::star::
if ( m_xFrame.is() && m_xPopupMenu.is() )
{
- URL aTargetURL;
+ css::util::URL aTargetURL;
Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
fillPopupMenu( m_xPopupMenu );
m_aURLToDispatchMap.free();
@@ -403,4 +458,14 @@ void SAL_CALL ControlMenuController::initialize( const Sequence< Any >& aArgumen
}
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_framework_ControlMenuController_get_implementation(
+ css::uno::XComponentContext *context,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ rtl::Reference<ControlMenuController> x(new ControlMenuController(context));
+ x->acquire();
+ return static_cast<cppu::OWeakObject *>(x.get());
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/util/fwk.component b/framework/util/fwk.component
index 9dc825a31551..8121154ed74c 100644
--- a/framework/util/fwk.component
+++ b/framework/util/fwk.component
@@ -29,7 +29,8 @@
<implementation name="com.sun.star.comp.framework.AutoRecovery">
<service name="com.sun.star.frame.AutoRecovery"/>
</implementation>
- <implementation name="com.sun.star.comp.framework.ControlMenuController">
+ <implementation name="com.sun.star.comp.framework.ControlMenuController"
+ constructor="com_sun_star_comp_framework_ControlMenuController_get_implementation">
<service name="com.sun.star.frame.PopupMenuController"/>
</implementation>
<implementation name="com.sun.star.comp.framework.Desktop">