diff options
Diffstat (limited to 'sd/workben')
-rw-r--r-- | sd/workben/custompanel/Impress.xcu | 34 | ||||
-rw-r--r-- | sd/workben/custompanel/colorpanel.map | 8 | ||||
-rw-r--r-- | sd/workben/custompanel/ctp_factory.cxx | 195 | ||||
-rw-r--r-- | sd/workben/custompanel/ctp_factory.hxx | 114 | ||||
-rw-r--r-- | sd/workben/custompanel/ctp_panel.cxx | 239 | ||||
-rw-r--r-- | sd/workben/custompanel/ctp_panel.hxx | 98 | ||||
-rw-r--r-- | sd/workben/custompanel/ctp_services.cxx | 92 | ||||
-rw-r--r-- | sd/workben/custompanel/delzip | 0 | ||||
-rw-r--r-- | sd/workben/custompanel/description.xml | 16 | ||||
-rw-r--r-- | sd/workben/custompanel/makefile.mk | 94 | ||||
-rw-r--r-- | sd/workben/custompanel/manifest.xml | 8 |
11 files changed, 898 insertions, 0 deletions
diff --git a/sd/workben/custompanel/Impress.xcu b/sd/workben/custompanel/Impress.xcu new file mode 100644 index 000000000000..6f8ced4924f3 --- /dev/null +++ b/sd/workben/custompanel/Impress.xcu @@ -0,0 +1,34 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!DOCTYPE oor:component-data SYSTEM "../../../../component-update.dtd"> +<oor:component-data oor:name="Impress" oor:package="org.openoffice.Office" xmlns:install="http://openoffice.org/2004/installation" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <node oor:name="MultiPaneGUI"> + <node oor:name="ToolPanel"> + <node oor:name="CustomPanels"> + <node oor:name="org.openoffice.example.colorpanel.SingleColorPanel" oor:op="replace"> + <prop oor:name="ResourceURL" oor:type="xs:string"> + <value>private:resource/toolpanel/SingleColorView</value> + </prop> + <prop oor:name="DisplayTitle" oor:type="xs:string"> + <value>Single Color Panel</value> + </prop> + </node> + </node> + </node> + <node oor:name="Framework"> + <node oor:name="ResourceFactories"> + <node oor:name="org.openoffice.example.colorpanel.1" oor:op="replace"> + <prop oor:name="ServiceName"> + <value>org.openoffice.example.colorpanel.ResourceFactory</value> + </prop> + <node oor:name="ResourceList"> + <node oor:name="SingleColorView" oor:op="replace"> + <prop oor:name="URL"> + <value>private:resource/toolpanel/SingleColorView</value> + </prop> + </node> + </node> + </node> + </node> + </node> + </node> +</oor:component-data> diff --git a/sd/workben/custompanel/colorpanel.map b/sd/workben/custompanel/colorpanel.map new file mode 100644 index 000000000000..f4ed78b9e970 --- /dev/null +++ b/sd/workben/custompanel/colorpanel.map @@ -0,0 +1,8 @@ +UDK_3_0_0 { + global: + component_getImplementationEnvironment; + component_writeInfo; + component_getFactory; + local: + *; +}; diff --git a/sd/workben/custompanel/ctp_factory.cxx b/sd/workben/custompanel/ctp_factory.cxx new file mode 100644 index 000000000000..f63e487fdc3e --- /dev/null +++ b/sd/workben/custompanel/ctp_factory.cxx @@ -0,0 +1,195 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#include "precompiled_sd.hxx" + +#include "ctp_factory.hxx" +#include "ctp_panel.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/lang/NotInitializedException.hpp> +#include <com/sun/star/lang/IllegalArgumentException.hpp> +#include <com/sun/star/drawing/framework/XResourceFactoryManager.hpp> +#include <com/sun/star/lang/XComponent.hpp> +/** === end UNO includes === **/ + +//...................................................................................................................... +namespace sd { namespace colortoolpanel +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::uno::XComponentContext; + using ::com::sun::star::drawing::framework::XResourceId; + using ::com::sun::star::drawing::framework::XResource; + using ::com::sun::star::lang::NotInitializedException; + using ::com::sun::star::lang::IllegalArgumentException; + using ::com::sun::star::drawing::framework::XResourceFactoryManager; + using ::com::sun::star::lang::WrappedTargetException; + using ::com::sun::star::lang::XComponent; + /** === end UNO using === **/ + + //================================================================================================================== + //= helper + //================================================================================================================== + namespace + { + const ::rtl::OUString& lcl_getSingleColorViewURL() + { + static ::rtl::OUString s_sSingleColorViewURL( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolpanel/SingleColorView" ) ); + return s_sSingleColorViewURL; + } + } + + //================================================================================================================== + //= ResourceFactory + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + ResourceFactory::ResourceFactory( const Reference< XComponentContext >& i_rContext ) + :m_xContext( i_rContext ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + ResourceFactory::~ResourceFactory() + { + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XResource > SAL_CALL ResourceFactory::createResource( const Reference< XResourceId >& i_rResourceId ) throw (RuntimeException, IllegalArgumentException, WrappedTargetException) + { + FactoryGuard aGuard( *this ); + if ( !i_rResourceId.is() ) + throw IllegalArgumentException( ::rtl::OUString::createFromAscii( "illegal resource ID" ), *this, 1 ); + + const ::rtl::OUString sResourceURL( i_rResourceId->getResourceURL() ); + if ( sResourceURL != lcl_getSingleColorViewURL() ) + throw IllegalArgumentException( ::rtl::OUString::createFromAscii( "unsupported resource URL" ), *this, 1 ); + + return new SingleColorPanel( m_xContext, m_xControllerManager->getConfigurationController(), i_rResourceId ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL ResourceFactory::releaseResource( const Reference< XResource >& i_rResource ) throw (RuntimeException) + { + FactoryGuard aGuard( *this ); + + // here, we could decide to actually not destroy the resource, but cache it. In this case, we would need + // to re-parent the VCL window to another, temporary window, or *at least* hide it. + + // However, for the simplicity of this example, we will simply dispose the component here, which will destroy + // all associated resources, including the VCL window. + Reference< XComponent > xComponent( i_rResource, UNO_QUERY_THROW ); + xComponent->dispose(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL ResourceFactory::getImplementationName( ) throw (RuntimeException) + { + return getImplementationName_static(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL ResourceFactory::getImplementationName_static( ) throw (RuntimeException) + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.example.colorpanel.ResourceFactory" ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool SAL_CALL ResourceFactory::supportsService( const ::rtl::OUString& i_rServiceName ) throw (RuntimeException) + { + const Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames() ); + for ( const ::rtl::OUString* serviceName = aServiceNames.getConstArray(); + serviceName != aServiceNames.getConstArray() + aServiceNames.getLength(); + ++serviceName + ) + { + if ( i_rServiceName == *serviceName ) + return sal_True; + } + return sal_False; + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL ResourceFactory::getSupportedServiceNames() throw (RuntimeException) + { + return getSupportedServiceNames_static(); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL ResourceFactory::getSupportedServiceNames_static() throw (RuntimeException) + { + Sequence< ::rtl::OUString > aServiceNames(1); + aServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.example.colorpanel.ResourceFactory" ) ); + return aServiceNames; + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XInterface > SAL_CALL ResourceFactory::Create( const Reference< XComponentContext >& i_rContext ) throw (RuntimeException) + { + return *( new ResourceFactory( i_rContext ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + void ResourceFactory::checkInitialized( GuardAccess ) const + { + if ( !m_xControllerManager.is() ) + throw NotInitializedException( ::rtl::OUString(), *const_cast< ResourceFactory* >( this ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + void ResourceFactory::checkDisposed( GuardAccess ) const + { + // cannot be disposed currently ... + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL ResourceFactory::initialize( const Sequence< Any >& i_rArguments ) throw (Exception, RuntimeException) + { + if ( !i_rArguments.getLength() ) + throw IllegalArgumentException(); + + FactoryGuard aGuard( *this, false ); + m_xControllerManager.set( i_rArguments[0], UNO_QUERY_THROW ); + + Reference< XResourceFactoryManager > xFactoryManager( m_xControllerManager->getConfigurationController(), UNO_QUERY_THROW ); + xFactoryManager->addResourceFactory( lcl_getSingleColorViewURL(), this ); + } + +//...................................................................................................................... +} } // namespace sd::colortoolpanel +//...................................................................................................................... diff --git a/sd/workben/custompanel/ctp_factory.hxx b/sd/workben/custompanel/ctp_factory.hxx new file mode 100644 index 000000000000..ab6cb3f6a9db --- /dev/null +++ b/sd/workben/custompanel/ctp_factory.hxx @@ -0,0 +1,114 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SD_WORKBENCH_CTP_FACTORY_HXX +#define SD_WORKBENCH_CTP_FACTORY_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/drawing/framework/XResourceFactory.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/drawing/framework/XControllerManager.hpp> +/** === end UNO includes === **/ + +#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/basemutex.hxx> + +//...................................................................................................................... +namespace sd { namespace colortoolpanel +{ +//...................................................................................................................... + + class FactoryGuard; + + //================================================================================================================== + //= ResourceFactory + //================================================================================================================== + typedef ::cppu::WeakImplHelper3 < ::com::sun::star::drawing::framework::XResourceFactory + , ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::lang::XInitialization + > ResourceFactory_Base; + class ResourceFactory :public ::cppu::BaseMutex + ,public ResourceFactory_Base + { + public: + ResourceFactory( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_rContext + ); + ~ResourceFactory(); + + // XResourceFactory + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResource > SAL_CALL createResource( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResourceId >& xResourceId ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException); + virtual void SAL_CALL releaseResource( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResource >& xResource ) throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo - static versions + static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_rContext ) 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); + + public: + struct GuardAccess { friend class FactoryGuard; private: GuardAccess() { } }; + + void checkInitialized( GuardAccess ) const; + void checkDisposed( GuardAccess ) const; + ::osl::Mutex& getMutex( GuardAccess ) { return m_aMutex; } + + private: + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > + m_xContext; + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XControllerManager > + m_xControllerManager; + }; + + class FactoryGuard + { + public: + FactoryGuard( ResourceFactory& i_rFactory, const bool i_bNeedInit = true ) + :m_aGuard( i_rFactory.getMutex( ResourceFactory::GuardAccess() ) ) + { + i_rFactory.checkDisposed( ResourceFactory::GuardAccess() ); + if ( i_bNeedInit ) + i_rFactory.checkInitialized( ResourceFactory::GuardAccess() ); + } + + protected: + ::osl::MutexGuard m_aGuard; + }; + +//...................................................................................................................... +} } // namespace sd::colortoolpanel +//...................................................................................................................... + +#endif // SD_WORKBENCH_CTP_FACTORY_HXX diff --git a/sd/workben/custompanel/ctp_panel.cxx b/sd/workben/custompanel/ctp_panel.cxx new file mode 100644 index 000000000000..7fb8ed8aeabe --- /dev/null +++ b/sd/workben/custompanel/ctp_panel.cxx @@ -0,0 +1,239 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#include "precompiled_sd.hxx" + +#include "ctp_panel.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/drawing/framework/XPane.hpp> +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/awt/XWindowPeer.hpp> +#include <com/sun/star/awt/XToolkit.hpp> +#include <com/sun/star/awt/WindowClass.hpp> +#include <com/sun/star/awt/WindowAttribute.hpp> +#include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/awt/XDevice.hpp> +#include <com/sun/star/awt/XGraphics.hpp> +/** === end UNO includes === **/ + +#include <tools/diagnose_ex.h> + +//...................................................................................................................... +namespace sd { namespace colortoolpanel +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::drawing::framework::XConfigurationController; + using ::com::sun::star::drawing::framework::XResourceId; + using ::com::sun::star::uno::XComponentContext; + using ::com::sun::star::drawing::framework::XPane; + using ::com::sun::star::awt::XWindow; + using ::com::sun::star::rendering::XCanvas; + using ::com::sun::star::lang::DisposedException; + using ::com::sun::star::awt::XWindowPeer; + using ::com::sun::star::lang::XMultiComponentFactory; + using ::com::sun::star::awt::XToolkit; + using ::com::sun::star::awt::WindowDescriptor; + using ::com::sun::star::awt::WindowClass_SIMPLE; + using ::com::sun::star::awt::Rectangle; + using ::com::sun::star::awt::PaintEvent; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::awt::XDevice; + using ::com::sun::star::awt::XGraphics; + /** === end UNO using === **/ + namespace WindowAttribute = ::com::sun::star::awt::WindowAttribute; + namespace PosSize = ::com::sun::star::awt::PosSize; + + //================================================================================================================== + //= helpers + //================================================================================================================== + namespace + { + Reference< XWindow > lcl_createPlainWindow_nothrow( const Reference< XComponentContext >& i_rContext, + const Reference< XWindowPeer >& i_rParentWindow ) + { + try + { + ENSURE_OR_THROW( i_rContext.is(), "illegal component context" ); + Reference< XMultiComponentFactory > xFactory( i_rContext->getServiceManager(), UNO_SET_THROW ); + Reference< XToolkit > xToolkit( xFactory->createInstanceWithContext( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.Toolkit" ) ), + i_rContext + ), UNO_QUERY_THROW ); + + WindowDescriptor aWindow; + aWindow.Type = WindowClass_SIMPLE; + aWindow.WindowServiceName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "window" ) ); + aWindow.Parent = i_rParentWindow; + aWindow.WindowAttributes = WindowAttribute::BORDER; + + Reference< XWindowPeer > xWindow( xToolkit->createWindow( aWindow ), UNO_SET_THROW ); + return Reference< XWindow >( xWindow, UNO_QUERY_THROW ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return NULL; + } + } + //================================================================================================================== + //= class SingleColorPanel + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + SingleColorPanel::SingleColorPanel( const Reference< XComponentContext >& i_rContext, + const Reference< XConfigurationController >& i_rConfigController, const Reference< XResourceId >& i_rResourceId ) + :SingleColorPanel_Base( m_aMutex ) + ,m_xContext( i_rContext ) + ,m_xResourceId( i_rResourceId ) + ,m_xWindow() + { + ENSURE_OR_THROW( i_rConfigController.is(), "invalid configuration controller" ); + ENSURE_OR_THROW( m_xResourceId.is(), "invalid resource id" ); + + // retrieve the parent window for our to-be-created pane window + Reference< XWindow > xParentWindow; + Reference< XWindowPeer > xParentPeer; + try + { + Reference< XResource > xAnchor( i_rConfigController->getResource( m_xResourceId->getAnchor() ), UNO_SET_THROW ); + Reference< XPane > xAnchorPane( xAnchor, UNO_QUERY_THROW ); + xParentWindow.set( xAnchorPane->getWindow(), UNO_SET_THROW ); + xParentPeer.set( xParentWindow, UNO_QUERY_THROW ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + osl_incrementInterlockedCount( &m_refCount ); + if ( xParentWindow.is() ) + { + m_xWindow = lcl_createPlainWindow_nothrow( m_xContext, xParentPeer ); + m_xWindow->addPaintListener( this ); + if ( m_xWindow.is() ) + { + const Rectangle aPanelAnchorSize( xParentWindow->getPosSize() ); + m_xWindow->setPosSize( 0, 0, aPanelAnchorSize.Width, aPanelAnchorSize.Height, PosSize::POSSIZE ); + m_xWindow->setVisible( sal_True ); + } + } + osl_decrementInterlockedCount( &m_refCount ); + } + + //------------------------------------------------------------------------------------------------------------------ + SingleColorPanel::~SingleColorPanel() + { + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XWindow > SAL_CALL SingleColorPanel::getWindow( ) throw (RuntimeException) + { + ::osl::MutexGuard aGuard( m_aMutex ); + if ( !m_xWindow.get() ) + throw DisposedException( ::rtl::OUString(), *this ); + return m_xWindow; + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XResourceId > SAL_CALL SingleColorPanel::getResourceId( ) throw (RuntimeException) + { + ::osl::MutexGuard aGuard( m_aMutex ); + if ( !m_xWindow.is() ) + throw DisposedException( ::rtl::OUString(), *this ); + return m_xResourceId; + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool SAL_CALL SingleColorPanel::isAnchorOnly( ) throw (RuntimeException) + { + ::osl::MutexGuard aGuard( m_aMutex ); + if ( !m_xWindow.is() ) + throw DisposedException( ::rtl::OUString(), *this ); + return sal_False; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SingleColorPanel::windowPaint( const PaintEvent& i_rEvent ) throw (RuntimeException) + { + try + { + const Reference< XDevice > xDevice( i_rEvent.Source, UNO_QUERY_THROW ); + const Reference< XGraphics > xGraphics( xDevice->createGraphics(), UNO_SET_THROW ); + xGraphics->setFillColor( 0x80 << 8 ); + xGraphics->setLineColor( 0x80 << 16 ); + + const Reference< XWindow > xWindow( i_rEvent.Source, UNO_QUERY_THROW ); + const Rectangle aWindowRect( xWindow->getPosSize() ); + xGraphics->drawRect( 0, 0, aWindowRect.Width - 1, aWindowRect.Height - 1 ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SingleColorPanel::disposing( const EventObject& i_rSource ) throw (RuntimeException) + { + (void)i_rSource; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SingleColorPanel::disposing() + { + ::osl::MutexGuard aGuard( m_aMutex ); + if ( !m_xWindow.is() ) + // already disposed + return; + m_xWindow->removePaintListener( this ); + try + { + Reference< XComponent > xWindowComp( m_xWindow, UNO_QUERY_THROW ); + xWindowComp->dispose(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + m_xWindow.clear(); + } + +//...................................................................................................................... +} } // namespace sd::colortoolpanel +//...................................................................................................................... diff --git a/sd/workben/custompanel/ctp_panel.hxx b/sd/workben/custompanel/ctp_panel.hxx new file mode 100644 index 000000000000..f991cc80516c --- /dev/null +++ b/sd/workben/custompanel/ctp_panel.hxx @@ -0,0 +1,98 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SD_WORKBENCH_CTP_PANEL_HXX +#define SD_WORKBENCH_CTP_PANEL_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/drawing/framework/XView.hpp> +#include <com/sun/star/view/XToolPanel.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/drawing/framework/XConfigurationController.hpp> +#include <com/sun/star/drawing/framework/XResourceId.hpp> +#include <com/sun/star/awt/XPaintListener.hpp> +/** === end UNO includes === **/ + +#include <cppuhelper/compbase3.hxx> +#include <cppuhelper/basemutex.hxx> + +#include <boost/scoped_ptr.hpp> + +//...................................................................................................................... +namespace sd { namespace colortoolpanel +{ +//...................................................................................................................... + + //================================================================================================================== + //= class SingleColorPanel + //================================================================================================================== + typedef ::cppu::WeakComponentImplHelper3 < ::com::sun::star::drawing::framework::XView + , ::com::sun::star::view::XToolPanel + , ::com::sun::star::awt::XPaintListener + > SingleColorPanel_Base; + class SingleColorPanel :public ::cppu::BaseMutex + ,public SingleColorPanel_Base + { + public: + SingleColorPanel( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_rContext, + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XConfigurationController >& i_rConfigController, + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResourceId >& i_rResourceId + ); + + // XToolPanel + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL getWindow( ) throw (::com::sun::star::uno::RuntimeException); + + // XView + // (no methods) + + // XResource + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResourceId > SAL_CALL getResourceId( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isAnchorOnly( ) throw (::com::sun::star::uno::RuntimeException); + + // XPaintListener + virtual void SAL_CALL windowPaint( const ::com::sun::star::awt::PaintEvent& e ) 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); + + // XComponent equivalents + virtual void SAL_CALL disposing(); + + protected: + ~SingleColorPanel(); + + private: + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::framework::XResourceId > m_xResourceId; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xWindow; + }; + +//...................................................................................................................... +} } // namespace sd::colortoolpanel +//...................................................................................................................... + +#endif // SD_WORKBENCH_CTP_PANEL_HXX diff --git a/sd/workben/custompanel/ctp_services.cxx b/sd/workben/custompanel/ctp_services.cxx new file mode 100644 index 000000000000..67fd5af14c7b --- /dev/null +++ b/sd/workben/custompanel/ctp_services.cxx @@ -0,0 +1,92 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#include "precompiled_sd.hxx" + +#include "ctp_factory.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +#include <cppuhelper/implementationentry.hxx> + +//...................................................................................................................... +namespace sd { namespace colortoolpanel +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + /** === end UNO using === **/ + + //================================================================================================================== + //= descriptors for the services implemented in this component + //================================================================================================================== + static struct ::cppu::ImplementationEntry s_aServiceEntries[] = + { + { + ResourceFactory::Create, + ResourceFactory::getImplementationName_static, + ResourceFactory::getSupportedServiceNames_static, + ::cppu::createSingleComponentFactory, NULL, 0 + }, + { 0, 0, 0, 0, 0, 0 } + }; + +//...................................................................................................................... +} } // namespace sd::colortoolpanel +//...................................................................................................................... + +extern "C" +{ + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** ) + { + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Bool SAL_CALL component_writeInfo( void * pServiceManager, void * pRegistryKey ) + { + return ::cppu::component_writeInfoHelper( pServiceManager, pRegistryKey, ::sd::colortoolpanel::s_aServiceEntries ); + } + + //------------------------------------------------------------------------------------------------------------------ + void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) + { + return ::cppu::component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , ::sd::colortoolpanel::s_aServiceEntries ); + } +} diff --git a/sd/workben/custompanel/delzip b/sd/workben/custompanel/delzip new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/sd/workben/custompanel/delzip diff --git a/sd/workben/custompanel/description.xml b/sd/workben/custompanel/description.xml new file mode 100644 index 000000000000..a1dbdf4f125d --- /dev/null +++ b/sd/workben/custompanel/description.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<description + xmlns="http://openoffice.org/extensions/description/2006" + xmlns:d="http://openoffice.org/extensions/description/2006" + xmlns:xlink="http://www.w3.org/1999/xlink"> + + <identifier value="UPDATED_IDENTIFIER"/> + <version value="0.1" /> + <platform value="UPDATED_SUPPORTED_PLATFORM" /> + <display-name> + <name lang="en-US">Custom Tool Panel Example</name> + </display-name> + <dependencies> + <OpenOffice.org-minimal-version value="3.2" d:name="OpenOffice.org 3.2"/> + </dependencies> +</description> diff --git a/sd/workben/custompanel/makefile.mk b/sd/workben/custompanel/makefile.mk new file mode 100644 index 000000000000..586d3a43cc9c --- /dev/null +++ b/sd/workben/custompanel/makefile.mk @@ -0,0 +1,94 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=../.. +PRJNAME=sd + +TARGET=colorpanel +ENABLE_EXCEPTIONS=TRUE +LIBTARGET=NO +EXTENSIONNAME:=colored-tool-panel + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +#------------------------------------------------------------------- + +#---- extension version +EXTENSION_VERSION_BASE=0.1 +.IF ( "$(CWS_WORK_STAMP)" == "" ) || ( "$(UPDATER)" == "YES" ) + EXTENSION_VERSION=$(EXTENSION_VERSION_BASE) +.ELSE + EXTENSION_VERSION=$(EXTENSION_VERSION_BASE).cws.$(CWS_WORK_STAMP) +.ENDIF + +#---- extension title package name +EXTENSION_TITLE=Custom Tool Panel Example +EXTENSION_ZIPNAME=$(EXTENSIONNAME)-$(EXTENSION_VERSION_BASE)-$(RTL_OS:l)-$(RTL_ARCH:l) + +#-------------------------------------------------- + +SHL1DLLPRE= +SHL1TARGET=$(TARGET).uno +LIB1TARGET=$(SLB)/$(SHL1TARGET).lib +LIB1OBJFILES= \ + $(SLO)/ctp_factory.obj \ + $(SLO)/ctp_services.obj \ + $(SLO)/ctp_panel.obj + +SHL1STDLIBS= \ + $(TOOLSLIB) \ + $(CPPULIB) \ + $(SALLIB) \ + $(SALHELPERLIB) \ + $(CPPUHELPERLIB) + +SHL1VERSIONMAP=$(TARGET).map +SHL1LIBS= $(LIB1TARGET) +SHL1DEF= $(MISC)/$(SHL1TARGET).def +SHL1RPATH= OXT +DEF1NAME= $(SHL1TARGET) + +# create Extension ----------------------------- + +COMPONENT_CONFIGDEST=. + +COMPONENT_XCU = \ + $(EXTENSIONDIR)/Impress.xcu + +COMPONENT_LIBRARIES = \ + $(EXTENSIONDIR)$/$(SHL1TARGET)$(DLLPOST) + +# ........ dependencies for packaging the extension ........ +EXTENSION_PACKDEPS=makefile.mk + +# --- Targets ------------------------------------------------------ +.INCLUDE : extension_pre.mk +.INCLUDE : target.mk +.INCLUDE : extension_post.mk + diff --git a/sd/workben/custompanel/manifest.xml b/sd/workben/custompanel/manifest.xml new file mode 100644 index 000000000000..96f62afe4e27 --- /dev/null +++ b/sd/workben/custompanel/manifest.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE manifest:manifest PUBLIC "-//OpenOffice.org//DTD Manifest 1.0//EN" "Manifest.dtd"> +<manifest:manifest xmlns:manifest="http://openoffice.org/2001/manifest"> + <manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-component;type=native" + manifest:full-path="colorpanel.unoSHARED_EXTENSION"/> + <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data" + manifest:full-path="Impress.xcu"/> +</manifest:manifest> |