summaryrefslogtreecommitdiff
path: root/framework/source/uifactory
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2014-01-09 20:36:26 +0100
committerMatúš Kukan <matus.kukan@collabora.com>2014-02-06 12:03:27 +0100
commit813b0f60e86de5e0ebf678691a9ff405e293bf86 (patch)
tree92c9599cc87a400527e7efb3808642a4c90498b7 /framework/source/uifactory
parent094f92bb789ecd24793c5843bfae13e79122fc5a (diff)
fwk: Constructor feature for single-instance FooBarFactories.
Converted them as usual service implementations. Otherwise - if static singletons are used - it does not show menu for some reason. Change-Id: I0673d0bfbba268728a3fa676f2af95aa6c74bbb2
Diffstat (limited to 'framework/source/uifactory')
-rw-r--r--framework/source/uifactory/menubarfactory.cxx45
-rw-r--r--framework/source/uifactory/statusbarfactory.cxx73
-rw-r--r--framework/source/uifactory/toolboxfactory.cxx76
3 files changed, 104 insertions, 90 deletions
diff --git a/framework/source/uifactory/menubarfactory.cxx b/framework/source/uifactory/menubarfactory.cxx
index b9739602839a..3395854bae57 100644
--- a/framework/source/uifactory/menubarfactory.cxx
+++ b/framework/source/uifactory/menubarfactory.cxx
@@ -19,26 +19,20 @@
#include <uifactory/menubarfactory.hxx>
-#include <threadhelp/resetableguard.hxx>
-#include "services.h"
#include <uielement/menubarwrapper.hxx>
-#include <com/sun/star/util/XURLTransformer.hpp>
#include <com/sun/star/frame/ModuleManager.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include <vcl/menu.hxx>
#include <vcl/svapp.hxx>
#include <rtl/ustrbuf.hxx>
-//_________________________________________________________________________________________________________________
-// Defines
-//_________________________________________________________________________________________________________________
-
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::frame;
@@ -49,27 +43,8 @@ using namespace ::com::sun::star::ui;
namespace framework
{
-//*****************************************************************************************************************
-// XInterface, XTypeProvider, XServiceInfo
-//*****************************************************************************************************************
-DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2( MenuBarFactory ,
- ::cppu::OWeakObject ,
- SERVICENAME_MENUBARFACTORY ,
- IMPLEMENTATIONNAME_MENUBARFACTORY
- )
-
-DEFINE_INIT_SERVICE ( MenuBarFactory, {} )
-
-MenuBarFactory::MenuBarFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ) :
- ThreadHelpBase()
- , m_xContext( xContext )
- , m_xModuleManager( ModuleManager::create( xContext ) )
-{
-}
-MenuBarFactory::MenuBarFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,bool ) :
- ThreadHelpBase(&Application::GetSolarMutex())
- , m_xContext( xContext )
- , m_xModuleManager( ModuleManager::create( xContext ) )
+MenuBarFactory::MenuBarFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext )
+ : m_xContext( xContext )
{
}
@@ -84,11 +59,11 @@ Reference< XUIElement > SAL_CALL MenuBarFactory::createUIElement(
throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException )
{
// SAFE
- ResetableGuard aLock( m_aLock );
+ SolarMutexClearableGuard g;
MenuBarWrapper* pMenuBarWrapper = new MenuBarWrapper( m_xContext );
Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pMenuBarWrapper, UNO_QUERY );
- Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = m_xModuleManager;
- aLock.unlock();
+ Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = ModuleManager::create( m_xContext );
+ g.clear();
CreateUIElement(ResourceURL, Args, "MenuOnly", "private:resource/menubar/", xMenuBar, xModuleManager, m_xContext);
return xMenuBar;
}
@@ -184,4 +159,12 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL
} // namespace framework
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_framework_MenuBarFactory_get_implementation(
+ css::uno::XComponentContext *context,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new framework::MenuBarFactory(context));
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uifactory/statusbarfactory.cxx b/framework/source/uifactory/statusbarfactory.cxx
index 729e1b719996..ac30f93cd81c 100644
--- a/framework/source/uifactory/statusbarfactory.cxx
+++ b/framework/source/uifactory/statusbarfactory.cxx
@@ -17,27 +17,15 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <uifactory/statusbarfactory.hxx>
-#include <uifactory/menubarfactory.hxx>
+#include <com/sun/star/frame/ModuleManager.hpp>
+#include <uifactory/menubarfactory.hxx>
#include <uielement/statusbarwrapper.hxx>
-#include <threadhelp/resetableguard.hxx>
-
-#include <com/sun/star/util/XURLTransformer.hpp>
-#include <com/sun/star/frame/XFrame.hpp>
-#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
-
-#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
+#include <cppuhelper/supportsservice.hxx>
#include <vcl/svapp.hxx>
#include <rtl/ustrbuf.hxx>
-//_________________________________________________________________________________________________________________
-// Defines
-//_________________________________________________________________________________________________________________
-
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::frame;
@@ -45,22 +33,41 @@ using namespace com::sun::star::beans;
using namespace com::sun::star::util;
using namespace ::com::sun::star::ui;
-namespace framework
+using namespace framework;
+
+namespace {
+
+class StatusBarFactory : public MenuBarFactory
{
+public:
+ StatusBarFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext );
+
+ virtual OUString SAL_CALL getImplementationName()
+ throw (css::uno::RuntimeException)
+ {
+ return OUString("com.sun.star.comp.framework.StatusBarFactory");
+ }
+
+ virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
+ throw (css::uno::RuntimeException)
+ {
+ return cppu::supportsService(this, ServiceName);
+ }
-//*****************************************************************************************************************
-// XInterface, XTypeProvider, XServiceInfo
-//*****************************************************************************************************************
-DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2( StatusBarFactory ,
- ::cppu::OWeakObject ,
- SERVICENAME_STATUSBARFACTORY ,
- IMPLEMENTATIONNAME_STATUSBARFACTORY
- )
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
+ throw (css::uno::RuntimeException)
+ {
+ css::uno::Sequence< OUString > aSeq(1);
+ aSeq[0] = OUString("com.sun.star.ui.StatusBarFactory");
+ return aSeq;
+ }
-DEFINE_INIT_SERVICE ( StatusBarFactory, {} )
+ // XUIElementFactory
+ virtual css::uno::Reference< css::ui::XUIElement > SAL_CALL createUIElement( const OUString& ResourceURL, const css::uno::Sequence< css::beans::PropertyValue >& Args ) throw ( css::container::NoSuchElementException, css::lang::IllegalArgumentException, css::uno::RuntimeException );
+};
StatusBarFactory::StatusBarFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ) :
- MenuBarFactory( xContext,true )
+ MenuBarFactory( xContext )
{
}
@@ -71,15 +78,23 @@ Reference< XUIElement > SAL_CALL StatusBarFactory::createUIElement(
throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException )
{
// SAFE
- ResetableGuard aLock( m_aLock );
+ SolarMutexClearableGuard g;
StatusBarWrapper* pWrapper = new StatusBarWrapper( m_xContext );
Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pWrapper, UNO_QUERY );
- Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = m_xModuleManager;
- aLock.unlock();
+ Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = ModuleManager::create( m_xContext );
+ g.clear();
MenuBarFactory::CreateUIElement(ResourceURL, Args, NULL, "private:resource/statusbar/", xMenuBar, xModuleManager, m_xContext );
return xMenuBar;
}
}
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_framework_StatusBarFactory_get_implementation(
+ css::uno::XComponentContext *context,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new StatusBarFactory(context));
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uifactory/toolboxfactory.cxx b/framework/source/uifactory/toolboxfactory.cxx
index fe0104c28e3b..ad64f4b06832 100644
--- a/framework/source/uifactory/toolboxfactory.cxx
+++ b/framework/source/uifactory/toolboxfactory.cxx
@@ -17,25 +17,13 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <uifactory/toolboxfactory.hxx>
-
-#include <uielement/toolbarwrapper.hxx>
-#include <threadhelp/resetableguard.hxx>
-
-#include <com/sun/star/util/XURLTransformer.hpp>
-#include <com/sun/star/frame/XFrame.hpp>
-#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
-
-#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
+#include <cppuhelper/supportsservice.hxx>
#include <vcl/svapp.hxx>
#include <rtl/ustrbuf.hxx>
-
-//_________________________________________________________________________________________________________________
-// Defines
-//_________________________________________________________________________________________________________________
+#include <uielement/toolbarwrapper.hxx>
+#include <uifactory/menubarfactory.hxx>
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
@@ -43,23 +31,43 @@ using namespace com::sun::star::frame;
using namespace com::sun::star::beans;
using namespace com::sun::star::util;
using namespace ::com::sun::star::ui;
+using namespace framework;
-namespace framework
+namespace {
+
+class ToolBoxFactory : public MenuBarFactory
{
+public:
+ ToolBoxFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext );
+
+ virtual OUString SAL_CALL getImplementationName()
+ throw (css::uno::RuntimeException)
+ {
+ return OUString("com.sun.star.comp.framework.ToolBarFactory");
+ }
+
+ virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
+ throw (css::uno::RuntimeException)
+ {
+ return cppu::supportsService(this, ServiceName);
+ }
-//*****************************************************************************************************************
-// XInterface, XTypeProvider, XServiceInfo
-//*****************************************************************************************************************
-DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2( ToolBoxFactory ,
- ::cppu::OWeakObject ,
- SERVICENAME_TOOLBARFACTORY ,
- IMPLEMENTATIONNAME_TOOLBARFACTORY
- )
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
+ throw (css::uno::RuntimeException)
+ {
+ css::uno::Sequence< OUString > aSeq(1);
+ aSeq[0] = OUString("com.sun.star.ui.ToolBarFactory");
+ return aSeq;
+ }
-DEFINE_INIT_SERVICE ( ToolBoxFactory, {} )
+ // XUIElementFactory
+ virtual css::uno::Reference< css::ui::XUIElement > SAL_CALL createUIElement(
+ const OUString& ResourceURL, const css::uno::Sequence< css::beans::PropertyValue >& Args )
+ throw ( css::container::NoSuchElementException, css::lang::IllegalArgumentException, css::uno::RuntimeException );
+};
ToolBoxFactory::ToolBoxFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ) :
- MenuBarFactory( xContext,true )
+ MenuBarFactory( xContext )
{
}
@@ -69,15 +77,23 @@ Reference< XUIElement > SAL_CALL ToolBoxFactory::createUIElement(
const Sequence< PropertyValue >& Args )
throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException )
{
- ResetableGuard aLock( m_aLock );
+ SolarMutexClearableGuard g;
ToolBarWrapper* pWrapper = new ToolBarWrapper( m_xContext );
Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pWrapper, UNO_QUERY );
- Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = m_xModuleManager;
- aLock.unlock();
+ Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = ModuleManager::create(m_xContext);
+ g.clear();
CreateUIElement(ResourceURL, Args, "PopupMode", "private:resource/toolbar/", xMenuBar, xModuleManager, m_xContext);
return xMenuBar;
}
}
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_framework_ToolBarFactory_get_implementation(
+ css::uno::XComponentContext *context,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ToolBoxFactory(context));
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */