summaryrefslogtreecommitdiff
path: root/sfx2/workben
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@sun.com>2010-04-07 22:36:26 +0200
committerFrank Schoenheit [fs] <frank.schoenheit@sun.com>2010-04-07 22:36:26 +0200
commit1cf2a482871ba237ec9470b88da074b97a2dbf41 (patch)
treec9b0520fa86bf4512a198524483f970525da9843 /sfx2/workben
parentf0cd4535a2d40ce66c346596bedbc7eac97a0b63 (diff)
slidecopy: improved the generic TaskPane, now filled from the configuration, including a small sample extension
still some way to go .... open items include: - add to all affected applications - respect the ImageURL property of the config data - clarify how this interacts with SD's Drawing Framework, and Impress' TaskPane - re-activate the previously-active tool panel when opening the pane again - obtain the XAccessible from the tool panel - title when docked - proper TAB handling when multiple panel/drawers exist
Diffstat (limited to 'sfx2/workben')
-rw-r--r--sfx2/workben/custompanel/Factories.xcu21
-rw-r--r--sfx2/workben/custompanel/WriterWindowState.xcu15
-rw-r--r--sfx2/workben/custompanel/ctp_factory.cxx164
-rw-r--r--sfx2/workben/custompanel/ctp_factory.hxx83
-rw-r--r--sfx2/workben/custompanel/ctp_panel.cxx233
-rw-r--r--sfx2/workben/custompanel/ctp_panel.hxx117
-rw-r--r--sfx2/workben/custompanel/ctp_services.cxx92
-rw-r--r--sfx2/workben/custompanel/description.xml16
-rw-r--r--sfx2/workben/custompanel/makefile.mk94
-rw-r--r--sfx2/workben/custompanel/manifest.xml10
10 files changed, 845 insertions, 0 deletions
diff --git a/sfx2/workben/custompanel/Factories.xcu b/sfx2/workben/custompanel/Factories.xcu
new file mode 100644
index 000000000000..88e6a4df14f8
--- /dev/null
+++ b/sfx2/workben/custompanel/Factories.xcu
@@ -0,0 +1,21 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<oor:component-data oor:name="Factories" oor:package="org.openoffice.Office.UI" 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="Registered">
+ <node oor:name="UIElementFactories">
+ <node oor:name="org.openoffice.exeample.CustomToolPanel" oor:op="replace">
+ <prop oor:name="Type">
+ <value>toolpanel</value>
+ </prop>
+ <prop oor:name="Name">
+ <value>org.openoffice.example.custompanel</value>
+ </prop>
+ <prop oor:name="Module">
+ <value/>
+ </prop>
+ <prop oor:name="FactoryImplementation">
+ <value>org.openoffice.example.colorpanel.ToolPanelFactory</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/sfx2/workben/custompanel/WriterWindowState.xcu b/sfx2/workben/custompanel/WriterWindowState.xcu
new file mode 100644
index 000000000000..1110d8a6fdaa
--- /dev/null
+++ b/sfx2/workben/custompanel/WriterWindowState.xcu
@@ -0,0 +1,15 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<oor:component-data oor:name="WriterWindowState" oor:package="org.openoffice.Office.UI" 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="UIElements">
+ <node oor:name="States">
+ <node oor:name="private:resource/toolpanel/org.openoffice.example.custompanel" oor:op="replace">
+ <prop oor:name="UIName" oor:type="xs:string">
+ <value xml:lang="en-US">Soylent Green</value>
+ </prop>
+ <prop oor:name="Visible" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/sfx2/workben/custompanel/ctp_factory.cxx b/sfx2/workben/custompanel/ctp_factory.cxx
new file mode 100644
index 000000000000..462709e7ad2c
--- /dev/null
+++ b/sfx2/workben/custompanel/ctp_factory.cxx
@@ -0,0 +1,164 @@
+/*************************************************************************
+ * 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_sfx2.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/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::lang::NotInitializedException;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::lang::XComponent;
+ using ::com::sun::star::ui::XUIElement;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::container::NoSuchElementException;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::awt::XWindow;
+ /** === end UNO using === **/
+
+ //==================================================================================================================
+ //= ToolPanelFactory
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ ToolPanelFactory::ToolPanelFactory( const Reference< XComponentContext >& i_rContext )
+ :m_xContext( i_rContext )
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ToolPanelFactory::~ToolPanelFactory()
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Reference< XUIElement > SAL_CALL ToolPanelFactory::createUIElement( const ::rtl::OUString& i_rResourceURL, const Sequence< PropertyValue >& i_rArgs ) throw (NoSuchElementException, IllegalArgumentException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !i_rResourceURL.equalsAscii( "private:resource/toolpanel/org.openoffice.example.custompanel" ) )
+ throw NoSuchElementException( i_rResourceURL, *this );
+
+ // retrieve the parent window
+ Reference< XWindow > xParentWindow;
+ const PropertyValue* pArg = i_rArgs.getConstArray();
+ const PropertyValue* pArgEnd = i_rArgs.getConstArray() + i_rArgs.getLength();
+ for ( ; pArg != pArgEnd; ++pArg )
+ {
+ if ( pArg->Name.equalsAscii( "ParentWindow" ) )
+ {
+ xParentWindow.set( pArg->Value, UNO_QUERY );
+ break;
+ }
+ }
+ if ( !xParentWindow.is() )
+ {
+ OSL_ENSURE( false, "ToolPanelFactory::createUIElement: no parent window in the args!" );
+ throw IllegalArgumentException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No parent window provided in the creation arguments. Cannot create tool panel." ) ),
+ *this,
+ 2
+ );
+ }
+
+ /// create the panel
+ Reference< XUIElement > xUIElement( new PanelUIElement( m_xContext, xParentWindow, i_rResourceURL ) );
+ return xUIElement;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ToolPanelFactory::getImplementationName( ) throw (RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ToolPanelFactory::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.example.custompanel.ToolPanelFactory" ) );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::sal_Bool SAL_CALL ToolPanelFactory::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 ToolPanelFactory::getSupportedServiceNames() throw (RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL ToolPanelFactory::getSupportedServiceNames_static() throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aServiceNames(1);
+ aServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.example.colorpanel.ToolPanelFactory" ) );
+ return aServiceNames;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL ToolPanelFactory::Create( const Reference< XComponentContext >& i_rContext ) throw (RuntimeException)
+ {
+ return *( new ToolPanelFactory( i_rContext ) );
+ }
+
+//......................................................................................................................
+} } // namespace sd::colortoolpanel
+//......................................................................................................................
diff --git a/sfx2/workben/custompanel/ctp_factory.hxx b/sfx2/workben/custompanel/ctp_factory.hxx
new file mode 100644
index 000000000000..8a359f59caaf
--- /dev/null
+++ b/sfx2/workben/custompanel/ctp_factory.hxx
@@ -0,0 +1,83 @@
+/*************************************************************************
+ * 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/ui/XUIElementFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/basemutex.hxx>
+
+//......................................................................................................................
+namespace sd { namespace colortoolpanel
+{
+//......................................................................................................................
+
+ class FactoryGuard;
+
+ //==================================================================================================================
+ //= ToolPanelFactory
+ //==================================================================================================================
+ typedef ::cppu::WeakImplHelper2 < ::com::sun::star::ui::XUIElementFactory
+ , ::com::sun::star::lang::XServiceInfo
+ > ToolPanelFactory_Base;
+ class ToolPanelFactory :public ::cppu::BaseMutex
+ ,public ToolPanelFactory_Base
+ {
+ public:
+ ToolPanelFactory(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_rContext
+ );
+ ~ToolPanelFactory();
+
+ // XUIElementFactory
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > SAL_CALL createUIElement( const ::rtl::OUString& i_rResourceURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rArgs ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::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);
+
+ private:
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
+ m_xContext;
+ };
+
+//......................................................................................................................
+} } // namespace sd::colortoolpanel
+//......................................................................................................................
+
+#endif // SD_WORKBENCH_CTP_FACTORY_HXX
diff --git a/sfx2/workben/custompanel/ctp_panel.cxx b/sfx2/workben/custompanel/ctp_panel.cxx
new file mode 100644
index 000000000000..c159b65e497e
--- /dev/null
+++ b/sfx2/workben/custompanel/ctp_panel.cxx
@@ -0,0 +1,233 @@
+/*************************************************************************
+ * 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_sfx2.hxx"
+
+#include "ctp_panel.hxx"
+
+/** === begin UNO includes === **/
+#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::uno::XComponentContext;
+ using ::com::sun::star::awt::XWindow;
+ 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< XWindow >& i_rParentWindow )
+ :SingleColorPanel_Base( m_aMutex )
+ ,m_xWindow()
+ {
+ // retrieve the parent window for our to-be-created pane window
+ Reference< XWindowPeer > xParentPeer( i_rParentWindow, UNO_QUERY );
+
+ osl_incrementInterlockedCount( &m_refCount );
+ if ( xParentPeer.is() )
+ {
+ m_xWindow = lcl_createPlainWindow_nothrow( i_rContext, xParentPeer );
+ m_xWindow->addPaintListener( this );
+ if ( m_xWindow.is() )
+ {
+ const Rectangle aPanelAnchorSize( i_rParentWindow->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.is() )
+ throw DisposedException( ::rtl::OUString(), *this );
+ return m_xWindow;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ 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();
+ }
+
+ //==================================================================================================================
+ //= PanelUIElement
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ PanelUIElement::PanelUIElement( const Reference< XComponentContext >& i_rContext, const Reference< XWindow >& i_rParentWindow,
+ const ::rtl::OUString& i_rResourceURL )
+ :PanelUIElement_Base( m_aMutex )
+ ,m_sResourceURL( i_rResourceURL )
+ ,m_xToolPanel( new SingleColorPanel( i_rContext, i_rParentWindow ) )
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ PanelUIElement::~PanelUIElement()
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL PanelUIElement::getRealInterface( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_xToolPanel.is() )
+ throw DisposedException();
+ return m_xToolPanel;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL PanelUIElement::disposing()
+ {
+ Reference< XComponent > xPanelComponent( m_xToolPanel, UNO_QUERY_THROW );
+ m_xToolPanel.clear();
+ xPanelComponent->dispose();
+ }
+
+//......................................................................................................................
+} } // namespace sd::colortoolpanel
+//......................................................................................................................
diff --git a/sfx2/workben/custompanel/ctp_panel.hxx b/sfx2/workben/custompanel/ctp_panel.hxx
new file mode 100644
index 000000000000..c3882e3afe98
--- /dev/null
+++ b/sfx2/workben/custompanel/ctp_panel.hxx
@@ -0,0 +1,117 @@
+/*************************************************************************
+ * 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/view/XToolPanel.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/awt/XPaintListener.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/ui/XUIElement.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/compbase2.hxx>
+#include <cppuhelper/compbase1.hxx>
+#include <cppuhelper/basemutex.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+//......................................................................................................................
+namespace sd { namespace colortoolpanel
+{
+//......................................................................................................................
+
+ //==================================================================================================================
+ //= SingleColorPanel
+ //==================================================================================================================
+ typedef ::cppu::WeakComponentImplHelper2 < ::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::awt::XWindow >& i_rParentWindow
+ );
+
+ // XToolPanel
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL getWindow() 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::awt::XWindow > m_xWindow;
+ };
+
+ //==================================================================================================================
+ //= PanelUIElement
+ //==================================================================================================================
+ typedef ::cppu::WeakComponentImplHelper1 < ::com::sun::star::ui::XUIElement
+ > PanelUIElement_Base;
+ class PanelUIElement :public ::cppu::BaseMutex
+ ,public PanelUIElement_Base
+ {
+ public:
+ PanelUIElement(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& i_rParentWindow,
+ const ::rtl::OUString& i_rResourceURL
+ );
+
+ // XUIElement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getRealInterface( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+
+ protected:
+ ~PanelUIElement();
+
+ private:
+ const ::rtl::OUString m_sResourceURL;
+ ::com::sun::star::uno::Reference< ::com::sun::star::view::XToolPanel >
+ m_xToolPanel;
+ };
+
+//......................................................................................................................
+} } // namespace sd::colortoolpanel
+//......................................................................................................................
+
+#endif // SD_WORKBENCH_CTP_PANEL_HXX
diff --git a/sfx2/workben/custompanel/ctp_services.cxx b/sfx2/workben/custompanel/ctp_services.cxx
new file mode 100644
index 000000000000..4164e8bc1629
--- /dev/null
+++ b/sfx2/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_sfx2.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[] =
+ {
+ {
+ ToolPanelFactory::Create,
+ ToolPanelFactory::getImplementationName_static,
+ ToolPanelFactory::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/sfx2/workben/custompanel/description.xml b/sfx2/workben/custompanel/description.xml
new file mode 100644
index 000000000000..7b85d64eaf69
--- /dev/null
+++ b/sfx2/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.3" d:name="OpenOffice.org 3.3"/>
+ </dependencies>
+</description>
diff --git a/sfx2/workben/custompanel/makefile.mk b/sfx2/workben/custompanel/makefile.mk
new file mode 100644
index 000000000000..b31625b1b9ab
--- /dev/null
+++ b/sfx2/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=sfx2
+
+TARGET=custompanel
+ENABLE_EXCEPTIONS=TRUE
+LIBTARGET=NO
+EXTENSIONNAME:=custom-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= \
+ $(CPPULIB) \
+ $(SALLIB) \
+ $(SALHELPERLIB) \
+ $(CPPUHELPERLIB)
+
+SHL1VERSIONMAP=$(SOLARSRC)/solenv/src/component.map
+SHL1LIBS= $(LIB1TARGET)
+SHL1DEF= $(MISC)/$(SHL1TARGET).def
+SHL1RPATH= OXT
+DEF1NAME= $(SHL1TARGET)
+
+# create Extension -----------------------------
+
+COMPONENT_CONFIGDEST=.
+
+COMPONENT_XCU = \
+ $(EXTENSIONDIR)/WriterWindowState.xcu \
+ $(EXTENSIONDIR)/Factories.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/sfx2/workben/custompanel/manifest.xml b/sfx2/workben/custompanel/manifest.xml
new file mode 100644
index 000000000000..b57e3a8fbe0d
--- /dev/null
+++ b/sfx2/workben/custompanel/manifest.xml
@@ -0,0 +1,10 @@
+<?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="custompanel.unoSHARED_EXTENSION"/>
+ <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data"
+ manifest:full-path="WriterWindowState.xcu"/>
+ <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data"
+ manifest:full-path="Factories.xcu"/>
+</manifest:manifest>