diff options
Diffstat (limited to 'framework/source/services/tabwindowservice.cxx')
-rw-r--r-- | framework/source/services/tabwindowservice.cxx | 192 |
1 files changed, 169 insertions, 23 deletions
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: */ |