diff options
Diffstat (limited to 'framework')
-rw-r--r-- | framework/inc/services/tabwindowservice.hxx | 194 | ||||
-rw-r--r-- | framework/source/register/registerservices.cxx | 2 | ||||
-rw-r--r-- | framework/source/services/tabwindowservice.cxx | 192 | ||||
-rw-r--r-- | framework/util/fwk.component | 3 |
4 files changed, 171 insertions, 220 deletions
diff --git a/framework/inc/services/tabwindowservice.hxx b/framework/inc/services/tabwindowservice.hxx deleted file mode 100644 index 88366c565eb7..000000000000 --- a/framework/inc/services/tabwindowservice.hxx +++ /dev/null @@ -1,194 +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_SERVICES_TABWINDOWSERVICE_HXX -#define INCLUDED_FRAMEWORK_INC_SERVICES_TABWINDOWSERVICE_HXX - -/** Attention: stl headers must(!) be included at first. Otherwise it can make trouble - with solaris headers ... -*/ -#include <vector> - -#include <classes/fwktabwindow.hxx> -#include <classes/propertysethelper.hxx> -#include <threadhelp/threadhelpbase.hxx> -#include <macros/generic.hxx> -#include <macros/xinterface.hxx> -#include <macros/xtypeprovider.hxx> -#include <macros/xserviceinfo.hxx> -#include <general.h> -#include <stdtypes.h> - -#include <com/sun/star/awt/XSimpleTabController.hpp> -#include <com/sun/star/awt/XWindow.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> - -#include <cppuhelper/weak.hxx> -#include <vcl/window.hxx> - -namespace framework{ - -struct TTabPageInfo -{ - public: - - TTabPageInfo() - : m_nIndex ( -1 ) - , m_bCreated (sal_False) - , m_pPage ( NULL ) - , m_lProperties ( ) - {} - - TTabPageInfo(::sal_Int32 nID) - : m_nIndex ( nID ) - , m_bCreated (sal_False) - , m_pPage ( NULL ) - , m_lProperties ( ) - {} - - public: - - ::sal_Int32 m_nIndex; - ::sal_Bool m_bCreated; - FwkTabPage* m_pPage; - css::uno::Sequence< css::beans::NamedValue > m_lProperties; -}; - -typedef ::boost::unordered_map< ::sal_Int32 , - TTabPageInfo , - Int32HashCode , - ::std::equal_to< ::sal_Int32 > > TTabPageInfoHash; - -/*-************************************************************************************************************//** - @short implements a helper service providing a dockable tab control window -*//*-*************************************************************************************************************/ - -class TabWindowService : public css::lang::XTypeProvider - , public css::lang::XServiceInfo - , public css::awt::XSimpleTabController - , public css::lang::XComponent - , public ThreadHelpBase - , public TransactionBase - , public PropertySetHelper - , public ::cppu::OWeakObject -{ - //------------------------------------------------------------------------------------------------------------- - // public methods - //------------------------------------------------------------------------------------------------------------- - - public: - - //--------------------------------------------------------------------------------------------------------- - // constructor / destructor - //--------------------------------------------------------------------------------------------------------- - - TabWindowService( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); - virtual ~TabWindowService(); - - //--------------------------------------------------------------------------------------------------------- - // XInterface, XTypeProvider, XServiceInfo - //--------------------------------------------------------------------------------------------------------- - - FWK_DECLARE_XINTERFACE - FWK_DECLARE_XTYPEPROVIDER - DECLARE_XSERVICEINFO - - //--------------------------------------------------------------------------------------------------------- - // XSimpleTabController - //--------------------------------------------------------------------------------------------------------- - - virtual sal_Int32 SAL_CALL insertTab() throw ( css::uno::RuntimeException ); - virtual void SAL_CALL removeTab( sal_Int32 nID ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException ); - virtual void SAL_CALL setTabProps( sal_Int32 nID, const css::uno::Sequence< css::beans::NamedValue >& aProperties ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException ); - virtual css::uno::Sequence< css::beans::NamedValue > SAL_CALL getTabProps( sal_Int32 nID ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException ); - virtual void SAL_CALL activateTab( sal_Int32 nID ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException ); - virtual sal_Int32 SAL_CALL getActiveTabID() throw ( css::uno::RuntimeException ); - virtual void SAL_CALL addTabListener( const css::uno::Reference< css::awt::XTabListener >& Listener ) throw ( css::uno::RuntimeException ); - virtual void SAL_CALL removeTabListener( const css::uno::Reference< css::awt::XTabListener >& Listener ) throw ( css::uno::RuntimeException ); - - //--------------------------------------------------------------------------------------------------------- - // XComponent - //--------------------------------------------------------------------------------------------------------- - - virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException ); - virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw ( css::uno::RuntimeException ); - virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw ( css::uno::RuntimeException ); - - //------------------------------------------------------------------------------------------------------------- - // protected methods - //------------------------------------------------------------------------------------------------------------- - - protected: - - //------------------------------------------------------------------------------------------------------------- - // private methods - //------------------------------------------------------------------------------------------------------------- - - private: - - void impl_initializePropInfo(); - virtual void SAL_CALL impl_setPropertyValue(const OUString& sProperty, - sal_Int32 nHandle , - const css::uno::Any& aValue ); - virtual css::uno::Any SAL_CALL impl_getPropertyValue(const OUString& sProperty, - sal_Int32 nHandle ); - - DECL_DLLPRIVATE_LINK( EventListener, VclSimpleEvent * ); - - void impl_checkTabIndex (::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException); - TTabPageInfoHash::iterator impl_getTabPageInfo(::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException); - FwkTabWindow* mem_TabWin (); - //------------------------------------------------------------------------------------------------------------- - // variables - // (should be private everyway!) - //------------------------------------------------------------------------------------------------------------- - - private: - - /// reference to factory, which has created this instance - css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; - - /// the tab window as XWindow ( to hold window* alive !) - css::uno::Reference< css::awt::XWindow > m_xTabWin; - - /// the VCL tab window - FwkTabWindow* m_pTabWin; - - /// container of inserted tab pages - TTabPageInfoHash m_lTabPageInfos; - - /// container of the added TabListener - ::cppu::OMultiTypeInterfaceContainerHelper m_lListener; - - /// counter of the tabpage indexes - ::sal_Int32 m_nPageIndexCounter; - - /// index of the current active page - ::sal_Int32 m_nCurrentPageIndex; - - /// title of the tabcontrolled window - OUString m_sTitle; - -}; // class TabWindowService - -} // namespace framework - -#endif // INCLUDED_FRAMEWORK_INC_SERVICES_TABWINDOWSERVICE_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/source/register/registerservices.cxx b/framework/source/register/registerservices.cxx index 8cced2d96412..b6796d8e8b97 100644 --- a/framework/source/register/registerservices.cxx +++ b/framework/source/register/registerservices.cxx @@ -35,7 +35,6 @@ =================================================================================================================*/ #include <services/urltransformer.hxx> #include <services/desktop.hxx> -#include <services/tabwindowservice.hxx> #include <services/frame.hxx> #include <services/modulemanager.hxx> #include <jobs/jobexecutor.hxx> @@ -107,7 +106,6 @@ COMPONENTGETFACTORY ( fwk, IFFACTORY( ::framework::ImageManager ) else IFFACTORY( ::framework::LangSelectionStatusbarController ) else IFFACTORY( ::framework::WindowContentFactoryManager ) else - IFFACTORY( ::framework::TabWindowService ) else IFFACTORY( ::framework::SubstitutePathVariables ) else IFFACTORY( ::framework::PathSettings ) else IFFACTORY( ::framework::ContextChangeEventMultiplexer ) diff --git a/framework/source/services/tabwindowservice.cxx b/framework/source/services/tabwindowservice.cxx index 5cb09b9ec20a..3aae564236df 100644 --- a/framework/source/services/tabwindowservice.cxx +++ b/framework/source/services/tabwindowservice.cxx @@ -17,24 +17,169 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <services/tabwindowservice.hxx> #include <classes/fwktabwindow.hxx> #include <threadhelp/resetableguard.hxx> #include <services.h> #include <properties.h> #include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/awt/XSimpleTabController.hpp> +#include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <cppuhelper/supportsservice.hxx> +#include <cppuhelper/weak.hxx> #include <toolkit/helper/vclunohelper.hxx> +#include <rtl/ref.hxx> #include <rtl/ustrbuf.hxx> #include <vcl/svapp.hxx> +#include <vcl/window.hxx> +#include <classes/propertysethelper.hxx> +#include <threadhelp/threadhelpbase.hxx> +#include <macros/generic.hxx> +#include <macros/xinterface.hxx> +#include <macros/xtypeprovider.hxx> +#include <macros/xserviceinfo.hxx> +#include <general.h> +#include <stdtypes.h> -namespace framework{ +using namespace framework; -//***************************************************************************************************************** -// css::uno::XInterface, XTypeProvider, XServiceInfo -//***************************************************************************************************************** +namespace { + +struct TTabPageInfo +{ + public: + + TTabPageInfo() + : m_nIndex ( -1 ) + , m_bCreated (sal_False) + , m_pPage ( NULL ) + , m_lProperties ( ) + {} + + TTabPageInfo(::sal_Int32 nID) + : m_nIndex ( nID ) + , m_bCreated (sal_False) + , m_pPage ( NULL ) + , m_lProperties ( ) + {} + + public: + + ::sal_Int32 m_nIndex; + ::sal_Bool m_bCreated; + FwkTabPage* m_pPage; + css::uno::Sequence< css::beans::NamedValue > m_lProperties; +}; + +typedef ::boost::unordered_map< ::sal_Int32 , + TTabPageInfo , + Int32HashCode , + ::std::equal_to< ::sal_Int32 > > TTabPageInfoHash; + +/*-************************************************************************************************************//** + @short implements a helper service providing a dockable tab control window +*//*-*************************************************************************************************************/ + +class TabWindowService : public css::lang::XTypeProvider + , public css::lang::XServiceInfo + , public css::awt::XSimpleTabController + , public css::lang::XComponent + , public ThreadHelpBase + , public TransactionBase + , public PropertySetHelper + , public ::cppu::OWeakObject +{ +public: + TabWindowService(); + virtual ~TabWindowService(); + + void onCreate(); + + FWK_DECLARE_XINTERFACE + FWK_DECLARE_XTYPEPROVIDER + + virtual OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException) + { + return OUString("com.sun.star.comp.framework.TabWindowService"); + } + + 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.ui.dialogs.TabContainerWindow"); + return aSeq; + } + + //--------------------------------------------------------------------------------------------------------- + // XSimpleTabController + //--------------------------------------------------------------------------------------------------------- + + virtual sal_Int32 SAL_CALL insertTab() throw ( css::uno::RuntimeException ); + virtual void SAL_CALL removeTab( sal_Int32 nID ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException ); + virtual void SAL_CALL setTabProps( sal_Int32 nID, const css::uno::Sequence< css::beans::NamedValue >& aProperties ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException ); + virtual css::uno::Sequence< css::beans::NamedValue > SAL_CALL getTabProps( sal_Int32 nID ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException ); + virtual void SAL_CALL activateTab( sal_Int32 nID ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException ); + virtual sal_Int32 SAL_CALL getActiveTabID() throw ( css::uno::RuntimeException ); + virtual void SAL_CALL addTabListener( const css::uno::Reference< css::awt::XTabListener >& Listener ) throw ( css::uno::RuntimeException ); + virtual void SAL_CALL removeTabListener( const css::uno::Reference< css::awt::XTabListener >& Listener ) throw ( css::uno::RuntimeException ); + + //--------------------------------------------------------------------------------------------------------- + // XComponent + //--------------------------------------------------------------------------------------------------------- + + virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException ); + virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw ( css::uno::RuntimeException ); + virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw ( css::uno::RuntimeException ); + +private: + + void impl_initializePropInfo(); + virtual void SAL_CALL impl_setPropertyValue(const OUString& sProperty, + sal_Int32 nHandle , + const css::uno::Any& aValue ); + virtual css::uno::Any SAL_CALL impl_getPropertyValue(const OUString& sProperty, + sal_Int32 nHandle ); + + DECL_DLLPRIVATE_LINK( EventListener, VclSimpleEvent * ); + + void impl_checkTabIndex (::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException); + TTabPageInfoHash::iterator impl_getTabPageInfo(::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException); + FwkTabWindow* mem_TabWin (); + +private: + + /// the tab window as XWindow ( to hold window* alive !) + css::uno::Reference< css::awt::XWindow > m_xTabWin; + + /// the VCL tab window + FwkTabWindow* m_pTabWin; + + /// container of inserted tab pages + TTabPageInfoHash m_lTabPageInfos; + + /// container of the added TabListener + ::cppu::OMultiTypeInterfaceContainerHelper m_lListener; + + /// counter of the tabpage indexes + ::sal_Int32 m_nPageIndexCounter; + + /// index of the current active page + ::sal_Int32 m_nCurrentPageIndex; + + /// title of the tabcontrolled window + OUString m_sTitle; +}; DEFINE_XINTERFACE_6 ( TabWindowService , OWeakObject , @@ -55,23 +200,11 @@ DEFINE_XTYPEPROVIDER_6 ( TabWindowService , css::beans::XPropertySetInfo ) -DEFINE_XSERVICEINFO_MULTISERVICE ( TabWindowService , - OWeakObject , - SERVICENAME_TABWINDOWSERVICE , - IMPLEMENTATIONNAME_TABWINDOWSERVICE - ) - -DEFINE_INIT_SERVICE ( TabWindowService, - { - impl_initializePropInfo(); - m_aTransactionManager.setWorkingMode( E_WORK ); - } - ) //***************************************************************************************************************** // constructor //***************************************************************************************************************** -TabWindowService::TabWindowService( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ) +TabWindowService::TabWindowService() // Init baseclasses first // Attention: // Don't change order of initialization! @@ -86,7 +219,6 @@ TabWindowService::TabWindowService( const css::uno::Reference< css::lang::XMulti , OWeakObject ( ) // Init member - , m_xFactory ( xFactory ) , m_xTabWin ( ) , m_pTabWin ( NULL ) , m_lTabPageInfos ( ) @@ -94,9 +226,12 @@ TabWindowService::TabWindowService( const css::uno::Reference< css::lang::XMulti , m_nPageIndexCounter ( 1 ) , m_nCurrentPageIndex ( 0 ) { - // Safe impossible cases. - // Method not defined for all incoming parameter. - SAL_WARN_IF( !xFactory.is(), "fwk", "TabWindowService::TabWindowService(): Invalid parameter detected!" ); +} + +void TabWindowService::onCreate() +{ + impl_initializePropInfo(); + m_aTransactionManager.setWorkingMode( E_WORK ); } //***************************************************************************************************************** @@ -443,6 +578,17 @@ FwkTabWindow* TabWindowService::mem_TabWin () return pWin; } -} // namespace framework +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_comp_framework_TabWindowService_get_implementation( + css::uno::XComponentContext *, + css::uno::Sequence<css::uno::Any> const &) +{ + rtl::Reference<TabWindowService> x(new TabWindowService); + x->onCreate(); + 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 a1fe849c0d58..1971d4a9d124 100644 --- a/framework/util/fwk.component +++ b/framework/util/fwk.component @@ -130,7 +130,8 @@ <implementation name="com.sun.star.comp.framework.jobs.JobDispatch"> <service name="com.sun.star.frame.ProtocolHandler"/> </implementation> - <implementation name="com.sun.star.comp.framework.TabWindowService"> + <implementation name="com.sun.star.comp.framework.TabWindowService" + constructor="com_sun_star_comp_framework_TabWindowService_get_implementation"> <service name="com.sun.star.ui.dialogs.TabContainerWindow"/> </implementation> <implementation name="org.apache.openoffice.comp.framework.OpenToolbarController" |