diff options
Diffstat (limited to 'UnoControls/source/base')
-rw-r--r-- | UnoControls/source/base/basecontainercontrol.cxx | 636 | ||||
-rw-r--r-- | UnoControls/source/base/basecontrol.cxx | 1022 | ||||
-rw-r--r-- | UnoControls/source/base/makefile.mk | 46 | ||||
-rw-r--r-- | UnoControls/source/base/multiplexer.cxx | 530 | ||||
-rw-r--r-- | UnoControls/source/base/registercontrols.cxx | 181 |
5 files changed, 0 insertions, 2415 deletions
diff --git a/UnoControls/source/base/basecontainercontrol.cxx b/UnoControls/source/base/basecontainercontrol.cxx deleted file mode 100644 index 123449f10..000000000 --- a/UnoControls/source/base/basecontainercontrol.cxx +++ /dev/null @@ -1,636 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -//____________________________________________________________________________________________________________ -// my own includes -//____________________________________________________________________________________________________________ - -#include "basecontainercontrol.hxx" - -//____________________________________________________________________________________________________________ -// includes of other projects -//____________________________________________________________________________________________________________ -#include <cppuhelper/typeprovider.hxx> - -//____________________________________________________________________________________________________________ -// includes of my own project -//____________________________________________________________________________________________________________ - -//____________________________________________________________________________________________________________ -// namespaces -//____________________________________________________________________________________________________________ - -using namespace ::cppu ; -using namespace ::osl ; -using namespace ::rtl ; -using namespace ::com::sun::star::uno ; -using namespace ::com::sun::star::lang ; -using namespace ::com::sun::star::awt ; -using namespace ::com::sun::star::container ; - -namespace unocontrols{ - -//____________________________________________________________________________________________________________ -// construct/destruct -//____________________________________________________________________________________________________________ - -BaseContainerControl::BaseContainerControl( const Reference< XMultiServiceFactory >& xFactory ) - : BaseControl ( xFactory ) - , m_aListeners ( m_aMutex ) -{ -} - -BaseContainerControl::~BaseContainerControl() -{ - impl_cleanMemory(); -} - -//____________________________________________________________________________________________________________ -// XInterface -//____________________________________________________________________________________________________________ - -Any SAL_CALL BaseContainerControl::queryInterface( const Type& rType ) throw( RuntimeException ) -{ - // Attention: - // Don't use mutex or guard in this method!!! Is a method of XInterface. - Any aReturn ; - Reference< XInterface > xDel = BaseControl::impl_getDelegator(); - if ( xDel.is() == sal_True ) - { - // If an delegator exist, forward question to his queryInterface. - // Delegator will ask his own queryAggregation! - aReturn = xDel->queryInterface( rType ); - } - else - { - // If an delegator unknown, forward question to own queryAggregation. - aReturn = queryAggregation( rType ); - } - - return aReturn ; -} - -//____________________________________________________________________________________________________________ -// XTypeProvider -//____________________________________________________________________________________________________________ - -Sequence< Type > SAL_CALL BaseContainerControl::getTypes() throw( RuntimeException ) -{ - // Optimize this method ! - // We initialize a static variable only one time. And we don't must use a mutex at every call! - // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL! - static OTypeCollection* pTypeCollection = NULL ; - - if ( pTypeCollection == NULL ) - { - // Ready for multithreading; get global mutex for first call of this method only! see before - MutexGuard aGuard( Mutex::getGlobalMutex() ); - - // Control these pointer again ... it can be, that another instance will be faster then these! - if ( pTypeCollection == NULL ) - { - // Create a static typecollection ... - static OTypeCollection aTypeCollection ( ::getCppuType(( const Reference< XControlModel >*)NULL ) , - ::getCppuType(( const Reference< XControlContainer >*)NULL ) , - BaseControl::getTypes() - ); - // ... and set his address to static pointer! - pTypeCollection = &aTypeCollection ; - } - } - - return pTypeCollection->getTypes(); -} - -//____________________________________________________________________________________________________________ -// XAggregation -//____________________________________________________________________________________________________________ - -Any SAL_CALL BaseContainerControl::queryAggregation( const Type& aType ) throw( RuntimeException ) -{ - // Ask for my own supported interfaces ... - // Attention: XTypeProvider and XInterface are supported by OComponentHelper! - Any aReturn ( ::cppu::queryInterface( aType , - static_cast< XControlModel* > ( this ) , - static_cast< XControlContainer* > ( this ) - ) - ); - - // If searched interface supported by this class ... - if ( aReturn.hasValue() == sal_True ) - { - // ... return this information. - return aReturn ; - } - else - { - // Else; ... ask baseclass for interfaces! - return BaseControl::queryAggregation( aType ); - } -} - -//____________________________________________________________________________________________________________ -// XControl -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseContainerControl::createPeer( const Reference< XToolkit >& xToolkit , - const Reference< XWindowPeer >& xParent ) throw( RuntimeException ) -{ - if ( getPeer().is() == sal_False ) - { - // create own peer - BaseControl::createPeer( xToolkit, xParent ); - - // create peers at all childs - Sequence< Reference< XControl > > seqControlList = getControls(); - sal_uInt32 nControls = seqControlList.getLength(); - - for ( sal_uInt32 n=0; n<nControls; n++ ) - { - seqControlList.getArray()[n]->createPeer( xToolkit, getPeer() ); - } - - // activate new tab order - impl_activateTabControllers(); - - } -} - -//____________________________________________________________________________________________________________ -// XControl -//____________________________________________________________________________________________________________ - -sal_Bool SAL_CALL BaseContainerControl::setModel( const Reference< XControlModel >& ) throw( RuntimeException ) -{ - // This object has NO model. - return sal_False ; -} - -//____________________________________________________________________________________________________________ -// XControl -//____________________________________________________________________________________________________________ - -Reference< XControlModel > SAL_CALL BaseContainerControl::getModel() throw( RuntimeException ) -{ - // This object has NO model. - // return (XControlModel*)this ; - return Reference< XControlModel >(); -} - -//____________________________________________________________________________________________________________ -// XComponent -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseContainerControl::dispose() throw( RuntimeException ) -{ - // Zuerst der Welt mitteilen, da� der Container wegfliegt. Dieses ist um einiges - // schneller wenn die Welt sowohl an den Controls als auch am Container horcht - - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - - // remove listeners - EventObject aObject ; - - aObject.Source = Reference< XComponent > ( (XControlContainer*)this, UNO_QUERY ); - m_aListeners.disposeAndClear( aObject ); - - // remove controls - Sequence< Reference< XControl > > seqCtrls = getControls(); - Reference< XControl > * pCtrls = seqCtrls.getArray(); - sal_uInt32 nCtrls = seqCtrls.getLength(); - size_t nMaxCount = maControlInfoList.size(); - size_t nCount = 0; - - for ( nCount = 0; nCount < nMaxCount; ++nCount ) - { - delete maControlInfoList[ nCount ]; - } - maControlInfoList.clear(); - - for ( nCount = 0; nCount < nCtrls; ++nCount ) - { - pCtrls [ nCount ] -> removeEventListener ( static_cast< XEventListener* >( static_cast< XWindowListener* >( this ) ) ) ; - pCtrls [ nCount ] -> dispose ( ) ; - } - - // call baseclass - BaseControl::dispose(); -} - -//____________________________________________________________________________________________________________ -// XEventListener -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseContainerControl::disposing( const EventObject& rEvent ) throw( RuntimeException ) -{ - Reference< XControl > xControl( rEvent.Source, UNO_QUERY ); - - // "removeControl" remove only, when control is an active control - removeControl( xControl ); -} - -//____________________________________________________________________________________________________________ -// XControlContainer -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseContainerControl::addControl ( const OUString& rName, const Reference< XControl > & rControl ) throw( RuntimeException ) -{ - if ( !rControl.is () ) - return; - - // take memory for new item - IMPL_ControlInfo* pNewControl = new IMPL_ControlInfo ; - - if (pNewControl!=(IMPL_ControlInfo*)0) - { - // Ready for multithreading - MutexGuard aGuard (m_aMutex) ; - - // set control - pNewControl->sName = rName ; - pNewControl->xControl = rControl ; - - // and insert in list - maControlInfoList.push_back( pNewControl ) ; - - // initialize new control - pNewControl->xControl->setContext ( (OWeakObject*)this ) ; - pNewControl->xControl->addEventListener ( static_cast< XEventListener* >( static_cast< XWindowListener* >( this ) ) ) ; - - // when container has a peer ... - if (getPeer().is()) - { - // .. then create a peer on child - pNewControl->xControl->createPeer ( getPeer()->getToolkit(), getPeer() ) ; - impl_activateTabControllers () ; - } - - // Send message to all listener - OInterfaceContainerHelper* pInterfaceContainer = m_aListeners.getContainer( ::getCppuType((const Reference< XContainerListener >*)0) ) ; - - if (pInterfaceContainer) - { - // Build event - ContainerEvent aEvent ; - - aEvent.Source = *this ; - aEvent.Element <<= rControl ; - - // Get all listener - OInterfaceIteratorHelper aIterator (*pInterfaceContainer) ; - - // Send event - while ( aIterator.hasMoreElements() ) - { - ((XContainerListener*)aIterator.next())->elementInserted (aEvent) ; - } - } - } -} - -//____________________________________________________________________________________________________________ -// XControlContainer -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseContainerControl::addContainerListener ( const Reference< XContainerListener > & rListener ) throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard ( m_aMutex ) ; - - m_aListeners.addInterface ( ::getCppuType((const Reference< XContainerListener >*)0), rListener ) ; -} - -//____________________________________________________________________________________________________________ -// XControlContainer -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseContainerControl::removeControl ( const Reference< XControl > & rControl ) throw( RuntimeException ) -{ - if ( rControl.is() ) - { - // Ready for multithreading - MutexGuard aGuard (m_aMutex) ; - - size_t nControls = maControlInfoList.size(); - - for ( size_t n = 0; n < nControls; n++ ) - { - // Search for right control - IMPL_ControlInfo* pControl = maControlInfoList[ n ] ; - if ( rControl == pControl->xControl ) - { - //.is it found ... remove listener from control - pControl->xControl->removeEventListener (static_cast< XEventListener* >( static_cast< XWindowListener* >( this ) )) ; - pControl->xControl->setContext ( Reference< XInterface > () ) ; - - // ... free memory - delete pControl ; - ::std::vector<IMPL_ControlInfo*>::iterator itr = maControlInfoList.begin(); - ::std::advance(itr, n); - maControlInfoList.erase(itr); - - // Send message to all other listener - OInterfaceContainerHelper * pInterfaceContainer = m_aListeners.getContainer( ::getCppuType((const Reference< XContainerListener >*)0) ) ; - - if (pInterfaceContainer) - { - ContainerEvent aEvent ; - - aEvent.Source = *this ; - aEvent.Element <<= rControl ; - - OInterfaceIteratorHelper aIterator (*pInterfaceContainer) ; - - while ( aIterator.hasMoreElements() ) - { - ((XContainerListener*)aIterator.next())->elementRemoved (aEvent) ; - } - } - // Break "for" ! - break ; - } - } - } -} - -//____________________________________________________________________________________________________________ -// XControlContainer -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseContainerControl::removeContainerListener ( const Reference< XContainerListener > & rListener ) throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard ( m_aMutex ) ; - - m_aListeners.removeInterface ( ::getCppuType((const Reference< XContainerListener >*)0), rListener ) ; -} - -//____________________________________________________________________________________________________________ -// XControlContainer -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseContainerControl::setStatusText ( const OUString& rStatusText ) throw( RuntimeException ) -{ - // go down to each parent - Reference< XControlContainer > xContainer ( getContext(), UNO_QUERY ) ; - - if ( xContainer.is () ) - { - xContainer->setStatusText ( rStatusText ) ; - } -} - -//____________________________________________________________________________________________________________ -// XControlContainer -//____________________________________________________________________________________________________________ - -Reference< XControl > SAL_CALL BaseContainerControl::getControl ( const OUString& rName ) throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard ( Mutex::getGlobalMutex() ) ; - - Reference< XControl > xRetControl = Reference< XControl > (); - size_t nControls = maControlInfoList.size(); - - // Search for right control - for( size_t nCount = 0; nCount < nControls; ++nCount ) - { - IMPL_ControlInfo* pSearchControl = maControlInfoList[ nCount ]; - - if ( pSearchControl->sName == rName ) - { - // We have found it ... - // Break operation and return. - return pSearchControl->xControl ; - } - } - - // We have not found it ... return NULL. - return Reference< XControl > () ; -} - -//____________________________________________________________________________________________________________ -// XControlContainer -//____________________________________________________________________________________________________________ - -Sequence< Reference< XControl > > SAL_CALL BaseContainerControl::getControls () throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard ( Mutex::getGlobalMutex() ) ; - - size_t nControls = maControlInfoList.size(); - size_t nCount = 0; - Sequence< Reference< XControl > > aDescriptor ( nControls ) ; - Reference< XControl > * pDestination = aDescriptor.getArray () ; - - // Copy controls to sequence - for( nCount = 0; nCount < nControls; ++nCount ) - { - IMPL_ControlInfo* pCopyControl = maControlInfoList[ nCount ]; - pDestination [ nCount ] = pCopyControl->xControl ; - } - - // Return sequence - return aDescriptor ; -} - -//____________________________________________________________________________________________________________ -// XUnoControlContainer -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseContainerControl::addTabController ( const Reference< XTabController > & rTabController ) throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard (m_aMutex) ; - - sal_uInt32 nOldCount = m_xTabControllerList.getLength () ; - Sequence< Reference< XTabController > > aNewList ( nOldCount + 1 ) ; - sal_uInt32 nCount = 0 ; - - // Copy old elements of sequence to new list. - for ( nCount = 0; nCount < nOldCount; ++nCount ) - { - aNewList.getArray () [nCount] = m_xTabControllerList.getConstArray () [nCount] ; - } - - // Add new controller - aNewList.getArray () [nOldCount] = rTabController ; - - // change old and new list - m_xTabControllerList = aNewList ; -} - -//____________________________________________________________________________________________________________ -// XUnoControlContainer -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseContainerControl::removeTabController ( const Reference< XTabController > & rTabController ) throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard (m_aMutex) ; - - sal_uInt32 nMaxCount = m_xTabControllerList.getLength () ; - sal_uInt32 nCount = 0 ; - - // Search right tabcontroller ... - for ( nCount = 0; nCount < nMaxCount; ++nCount ) - { - if ( m_xTabControllerList.getConstArray () [nCount] == rTabController ) - { - // ... if is it found ... remove it from list. - m_xTabControllerList.getArray()[ nCount ] = Reference< XTabController >() ; - break ; - } - } -} - -//____________________________________________________________________________________________________________ -// XUnoControlContainer -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseContainerControl::setTabControllers ( const Sequence< Reference< XTabController > >& rTabControllers ) throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard (m_aMutex) ; - - m_xTabControllerList = rTabControllers ; -} - -Sequence<Reference< XTabController > > SAL_CALL BaseContainerControl::getTabControllers () throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard (m_aMutex) ; - - return m_xTabControllerList ; -} - -//____________________________________________________________________________________________________________ -// XWindow -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseContainerControl::setVisible ( sal_Bool bVisible ) throw( RuntimeException ) -{ - // override baseclass definition - BaseControl::setVisible ( bVisible ) ; - - // is it a top window ? - if ( !getContext().is() && bVisible ) - { - // then show it automaticly - createPeer ( Reference< XToolkit > (), Reference< XWindowPeer > () ) ; - } -} - -//____________________________________________________________________________________________________________ -// protected method -//____________________________________________________________________________________________________________ - -WindowDescriptor* BaseContainerControl::impl_getWindowDescriptor ( const Reference< XWindowPeer > & rParentPeer ) -{ - // - used from "createPeer()" to set the values of an WindowDescriptor !!! - // - if you will change the descriptor-values, you must override thid virtuell function - // - the caller must release the memory for this dynamical descriptor !!! - - WindowDescriptor * aDescriptor = new WindowDescriptor ; - - aDescriptor->Type = WindowClass_CONTAINER ; - aDescriptor->WindowServiceName = OUString(RTL_CONSTASCII_USTRINGPARAM("window")) ; - aDescriptor->ParentIndex = -1 ; - aDescriptor->Parent = rParentPeer ; - aDescriptor->Bounds = getPosSize () ; - aDescriptor->WindowAttributes = 0 ; - - return aDescriptor ; -} - -//____________________________________________________________________________________________________________ -// protected method -//____________________________________________________________________________________________________________ - -void BaseContainerControl::impl_paint ( sal_Int32 /*nX*/, sal_Int32 /*nY*/, const Reference< XGraphics > & /*rGraphics*/ ) -{ -/* - if (rGraphics.is()) - { - for ( size_t n = maControlInfoList.size(); n; ) - { - ControlInfo* pSearchControl = maControlInfoList[ --n ]; - pSearchControl->xControl->paint ( nX, nY, rGraphics ) ; - } - } -*/ -} - -//____________________________________________________________________________________________________________ -// private method -//____________________________________________________________________________________________________________ - -void BaseContainerControl::impl_activateTabControllers () -{ - // Ready for multithreading - MutexGuard aGuard (m_aMutex) ; - - sal_uInt32 nMaxCount = m_xTabControllerList.getLength () ; - sal_uInt32 nCount = 0 ; - - for ( nCount = 0; nCount < nMaxCount; ++nCount ) - { - m_xTabControllerList.getArray () [nCount]->setContainer ( this ) ; - m_xTabControllerList.getArray () [nCount]->activateTabOrder ( ) ; - } -} - -//____________________________________________________________________________________________________________ -// private method -//____________________________________________________________________________________________________________ - -void BaseContainerControl::impl_cleanMemory () -{ - // Get count of listitems. - size_t nMaxCount = maControlInfoList.size(); - size_t nCount = 0; - - // Delete all items. - for ( nCount = 0; nCount < nMaxCount; ++nCount ) - { - // Delete everytime first element of list! - // We count from 0 to MAX, where "MAX=count of items" BEFORE we delete some elements! - // If we use "GetObject ( nCount )" ... it can be, that we have an index greater then count of current elements! - - IMPL_ControlInfo* pSearchControl = maControlInfoList[ nCount ]; - delete pSearchControl; - } - - // Delete list himself. - maControlInfoList.clear (); -} - -} // namespace unocontrols - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/base/basecontrol.cxx b/UnoControls/source/base/basecontrol.cxx deleted file mode 100644 index 90e0e601e..000000000 --- a/UnoControls/source/base/basecontrol.cxx +++ /dev/null @@ -1,1022 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -//____________________________________________________________________________________________________________ -// my own include -//____________________________________________________________________________________________________________ - -#include "basecontrol.hxx" - -//____________________________________________________________________________________________________________ -// includes of other projects -//____________________________________________________________________________________________________________ -#include <com/sun/star/awt/XDevice.hpp> -#include <com/sun/star/awt/XDisplayBitmap.hpp> -#include <com/sun/star/awt/DeviceInfo.hpp> -#include <com/sun/star/awt/WindowAttribute.hpp> -#include <com/sun/star/awt/PosSize.hpp> -#include <cppuhelper/typeprovider.hxx> - -//____________________________________________________________________________________________________________ -// includes of my own project -//____________________________________________________________________________________________________________ - -//____________________________________________________________________________________________________________ -// namespaces -//____________________________________________________________________________________________________________ - -using namespace ::cppu ; -using namespace ::osl ; -using namespace ::rtl ; -using namespace ::com::sun::star::uno ; -using namespace ::com::sun::star::lang ; -using namespace ::com::sun::star::awt ; - -namespace unocontrols{ - -//____________________________________________________________________________________________________________ -// defines -//____________________________________________________________________________________________________________ - -#define DEFAULT_PMULTIPLEXER NULL -#define DEFAULT_X 0 -#define DEFAULT_Y 0 -#define DEFAULT_WIDTH 100 -#define DEFAULT_HEIGHT 100 -#define DEFAULT_VISIBLE sal_False -#define DEFAULT_INDESIGNMODE sal_False -#define DEFAULT_ENABLE sal_True -#define SERVICE_VCLTOOLKIT "com.sun.star.awt.Toolkit" - -//____________________________________________________________________________________________________________ -// construct/destruct -//____________________________________________________________________________________________________________ - -BaseControl::BaseControl( const Reference< XMultiServiceFactory >& xFactory ) - : IMPL_MutexContainer ( ) - , OComponentHelper ( m_aMutex ) - , m_xFactory ( xFactory ) - , m_pMultiplexer ( DEFAULT_PMULTIPLEXER ) - , m_nX ( DEFAULT_X ) - , m_nY ( DEFAULT_Y ) - , m_nWidth ( DEFAULT_WIDTH ) - , m_nHeight ( DEFAULT_HEIGHT ) - , m_bVisible ( DEFAULT_VISIBLE ) - , m_bInDesignMode ( DEFAULT_INDESIGNMODE ) - , m_bEnable ( DEFAULT_ENABLE ) -{ -} - -BaseControl::~BaseControl() -{ -} - -//____________________________________________________________________________________________________________ -// XInterface -//____________________________________________________________________________________________________________ - -Any SAL_CALL BaseControl::queryInterface( const Type& rType ) throw( RuntimeException ) -{ - Any aReturn ; - if ( m_xDelegator.is() == sal_True ) - { - // If an delegator exist, forward question to his queryInterface. - // Delegator will ask his own queryAggregation! - aReturn = m_xDelegator->queryInterface( rType ); - } - else - { - // If an delegator unknown, forward question to own queryAggregation. - aReturn = queryAggregation( rType ); - } - - return aReturn ; -} - -//____________________________________________________________________________________________________________ -// XInterface -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::acquire() throw() -{ - // Attention: - // Don't use mutex or guard in this method!!! Is a method of XInterface. - - // Forward to baseclass - OComponentHelper::acquire(); -} - -//____________________________________________________________________________________________________________ -// XInterface -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::release() throw() -{ - // Attention: - // Don't use mutex or guard in this method!!! Is a method of XInterface. - - // Forward to baseclass - OComponentHelper::release(); -} - -//____________________________________________________________________________________________________________ -// XTypeProvider -//____________________________________________________________________________________________________________ - -Sequence< Type > SAL_CALL BaseControl::getTypes() throw( RuntimeException ) -{ - // Optimize this method ! - // We initialize a static variable only one time. And we don't must use a mutex at every call! - // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL! - static OTypeCollection* pTypeCollection = NULL ; - - if ( pTypeCollection == NULL ) - { - // Ready for multithreading; get global mutex for first call of this method only! see before - MutexGuard aGuard( Mutex::getGlobalMutex() ); - - // Control these pointer again ... it can be, that another instance will be faster then these! - if ( pTypeCollection == NULL ) - { - // Create a static typecollection ... - static OTypeCollection aTypeCollection( ::getCppuType(( const Reference< XPaintListener >*)NULL ) , - ::getCppuType(( const Reference< XWindowListener>*)NULL ) , - ::getCppuType(( const Reference< XView >*)NULL ) , - ::getCppuType(( const Reference< XWindow >*)NULL ) , - ::getCppuType(( const Reference< XServiceInfo >*)NULL ) , - ::getCppuType(( const Reference< XControl >*)NULL ) , - OComponentHelper::getTypes() - ); - - // ... and set his address to static pointer! - pTypeCollection = &aTypeCollection ; - } - } - - return pTypeCollection->getTypes(); -} - -//____________________________________________________________________________________________________________ -// XTypeProvider -//____________________________________________________________________________________________________________ - -Sequence< sal_Int8 > SAL_CALL BaseControl::getImplementationId() throw( RuntimeException ) -{ - // Create one Id for all instances of this class. - // Use ethernet address to do this! (sal_True) - - // Optimize this method - // We initialize a static variable only one time. And we don't must use a mutex at every call! - // For the first call; pID is NULL - for the second call pID is different from NULL! - static OImplementationId* pID = NULL ; - - if ( pID == NULL ) - { - // Ready for multithreading; get global mutex for first call of this method only! see before - MutexGuard aGuard( Mutex::getGlobalMutex() ); - - // Control these pointer again ... it can be, that another instance will be faster then these! - if ( pID == NULL ) - { - // Create a new static ID ... - static OImplementationId aID( sal_False ); - // ... and set his address to static pointer! - pID = &aID ; - } - } - - return pID->getImplementationId(); -} - -//____________________________________________________________________________________________________________ -// XAggregation -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::setDelegator( const Reference< XInterface >& xDel ) throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - m_xDelegator = xDel; -} - -//____________________________________________________________________________________________________________ -// XAggregation -//____________________________________________________________________________________________________________ - -Any SAL_CALL BaseControl::queryAggregation( const Type& aType ) throw( RuntimeException ) -{ - // Ask for my own supported interfaces ... - // Attention: XTypeProvider and XInterface are supported by OComponentHelper! - Any aReturn ( ::cppu::queryInterface( aType , - static_cast< XPaintListener*> ( this ) , - static_cast< XWindowListener*> ( this ) , - static_cast< XView* > ( this ) , - static_cast< XWindow* > ( this ) , - static_cast< XServiceInfo* > ( this ) , - static_cast< XControl* > ( this ) - ) - ); - - // If searched interface supported by this class ... - if ( aReturn.hasValue() == sal_True ) - { - // ... return this information. - return aReturn ; - } - else - { - // Else; ... ask baseclass for interfaces! - return OComponentHelper::queryAggregation( aType ); - } -} - -//____________________________________________________________________________________________________________ -// XServiceInfo -//____________________________________________________________________________________________________________ - -OUString SAL_CALL BaseControl::getImplementationName() throw( RuntimeException ) -{ - return impl_getStaticImplementationName(); -} - -//____________________________________________________________________________________________________________ -// XServiceInfo -//____________________________________________________________________________________________________________ - -sal_Bool SAL_CALL BaseControl::supportsService( const OUString& sServiceName ) throw( RuntimeException ) -{ - Sequence< OUString > seqServiceNames = getSupportedServiceNames(); - const OUString* pArray = seqServiceNames.getConstArray(); - for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ ) - { - if ( pArray[nCounter] == sServiceName ) - { - return sal_True ; - } - } - return sal_False ; -} - -//____________________________________________________________________________________________________________ -// XServiceInfo -//____________________________________________________________________________________________________________ - -Sequence< OUString > SAL_CALL BaseControl::getSupportedServiceNames() throw( RuntimeException ) -{ - return impl_getStaticSupportedServiceNames(); -} - -//____________________________________________________________________________________________________________ -// XComponent -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::dispose() throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - - if ( m_pMultiplexer != NULL ) - { - // to all other paint, focus, etc. - m_pMultiplexer->disposeAndClear(); - } - - // set the service manager to disposed - OComponentHelper::dispose(); - - // release context and peer - m_xContext = Reference< XInterface >(); - impl_releasePeer(); - - // release view - if ( m_xGraphicsView.is() == sal_True ) - { - m_xGraphicsView = Reference< XGraphics >(); - } -} - -//____________________________________________________________________________________________________________ -// XComponent -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::addEventListener( const Reference< XEventListener >& xListener ) throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - OComponentHelper::addEventListener( xListener ); -} - -//____________________________________________________________________________________________________________ -// XComponent -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::removeEventListener( const Reference< XEventListener >& xListener ) throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - OComponentHelper::removeEventListener( xListener ); -} - -//____________________________________________________________________________________________________________ -// XControl -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::createPeer( const Reference< XToolkit >& xToolkit , - const Reference< XWindowPeer >& xParentPeer ) throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - - if ( m_xPeer.is() == sal_False ) - { - // use method "BaseControl::getWindowDescriptor()" fot change window attributes !!! - WindowDescriptor* pDescriptor = impl_getWindowDescriptor( xParentPeer ); - - if ( m_bVisible == sal_True ) - { - pDescriptor->WindowAttributes |= WindowAttribute::SHOW ; - } - - // very slow under remote conditions! - // create the window on the server - Reference< XToolkit > xLocalToolkit = xToolkit ; - if ( xLocalToolkit.is() == sal_False ) - { - // but first create wellknown toolkit, if it not exist - xLocalToolkit = Reference< XToolkit > ( m_xFactory->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM( SERVICE_VCLTOOLKIT )) ), UNO_QUERY ); - } - m_xPeer = xLocalToolkit->createWindow( *pDescriptor ); - m_xPeerWindow = Reference< XWindow >( m_xPeer, UNO_QUERY ); - - // don't forget to release the memory! - delete pDescriptor ; - - if ( m_xPeerWindow.is() == sal_True ) - { - if ( m_pMultiplexer != NULL ) - { - m_pMultiplexer->setPeer( m_xPeerWindow ); - } - - // create new referenz to xgraphics for painting on a peer - // and add a paint listener - Reference< XDevice > xDevice( m_xPeerWindow, UNO_QUERY ); - - if ( xDevice.is() == sal_True ) - { - m_xGraphicsPeer = xDevice->createGraphics(); - } - - if ( m_xGraphicsPeer.is() == sal_True ) - { - addPaintListener( this ); - addWindowListener( this ); - } - - // PosSize_POSSIZE defined in <stardiv/uno/awt/window.hxx> - m_xPeerWindow->setPosSize( m_nX, m_nY, m_nWidth, m_nHeight, PosSize::POSSIZE ); - m_xPeerWindow->setEnable( m_bEnable ); - m_xPeerWindow->setVisible( m_bVisible && !m_bInDesignMode ); - } - } -} - -//____________________________________________________________________________________________________________ -// XControl -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::setContext( const Reference< XInterface >& xContext ) throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - m_xContext = xContext ; -} - -//____________________________________________________________________________________________________________ -// XControl -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::setDesignMode( sal_Bool bOn ) throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - m_bInDesignMode = bOn ; -} - -//____________________________________________________________________________________________________________ -// XControl -//____________________________________________________________________________________________________________ - -Reference< XInterface > SAL_CALL BaseControl::getContext() throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - return m_xContext ; -} - -//____________________________________________________________________________________________________________ -// XControl -//____________________________________________________________________________________________________________ - -Reference< XWindowPeer > SAL_CALL BaseControl::getPeer() throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - return m_xPeer ; -} - -//____________________________________________________________________________________________________________ -// XControl -//____________________________________________________________________________________________________________ - -Reference< XView > SAL_CALL BaseControl::getView() throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - return Reference< XView >( (OWeakObject*)this, UNO_QUERY ); -} - -//____________________________________________________________________________________________________________ -// XControl -//____________________________________________________________________________________________________________ - -sal_Bool SAL_CALL BaseControl::isDesignMode() throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - return m_bInDesignMode ; -} - -//____________________________________________________________________________________________________________ -// XControl -//____________________________________________________________________________________________________________ - -sal_Bool SAL_CALL BaseControl::isTransparent() throw( RuntimeException ) -{ - return sal_False ; -} - -//____________________________________________________________________________________________________________ -// XWindow -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::setPosSize( sal_Int32 nX , - sal_Int32 nY , - sal_Int32 nWidth , - sal_Int32 nHeight , - sal_Int16 nFlags ) throw( RuntimeException ) -{ - // - change size and position of window and save the values - // - "nFlags" declared in <stardiv/uno/awt/window.hxx> ("#define PosSize_X .....") - - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - - sal_Bool bChanged = sal_False ; - - if ( nFlags & PosSize::X ) - { - bChanged |= m_nX != nX, m_nX = nX ; - } - - if ( nFlags & PosSize::Y ) - { - bChanged |= m_nY != nY, m_nY = nY ; - } - - if ( nFlags & PosSize::WIDTH ) - { - bChanged |= m_nWidth != nWidth, m_nWidth = nWidth ; - } - - if ( nFlags & PosSize::HEIGHT ) - { - bChanged |= m_nHeight != nHeight, m_nHeight = nHeight ; - } - - if ( bChanged && m_xPeerWindow.is() ) - { - m_xPeerWindow->setPosSize( m_nX, m_nY, m_nWidth, m_nHeight, nFlags ); - } -} - -//____________________________________________________________________________________________________________ -// XWindow -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::setVisible( sal_Bool bVisible ) throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - - // Set new state of flag - m_bVisible = bVisible ; - - if ( m_xPeerWindow.is() == sal_True ) - { - // Set it also on peerwindow - m_xPeerWindow->setVisible( m_bVisible ); - } -} - -//____________________________________________________________________________________________________________ -// XWindow -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::setEnable( sal_Bool bEnable ) throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - - // Set new state of flag - m_bEnable = bEnable ; - - if ( m_xPeerWindow.is() == sal_True ) - { - // Set it also on peerwindow - m_xPeerWindow->setEnable( m_bEnable ); - } -} - -//____________________________________________________________________________________________________________ -// XWindow -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::setFocus() throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - - if ( m_xPeerWindow.is() == sal_True ) - { - m_xPeerWindow->setFocus(); - } -} - -//____________________________________________________________________________________________________________ -// XWindow -//____________________________________________________________________________________________________________ - -Rectangle SAL_CALL BaseControl::getPosSize() throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - return Rectangle( m_nX, m_nY , m_nWidth, m_nHeight ); -} - -//____________________________________________________________________________________________________________ -// XWindow -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::addWindowListener( const Reference< XWindowListener >& xListener ) throw( RuntimeException ) -{ - impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XWindowListener >*)0), xListener ); -} - -//____________________________________________________________________________________________________________ -// XWindow -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::addFocusListener( const Reference< XFocusListener >& xListener ) throw( RuntimeException ) -{ - impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XFocusListener >*)0), xListener ); -} - -//____________________________________________________________________________________________________________ -// XWindow -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::addKeyListener( const Reference< XKeyListener >& xListener ) throw( RuntimeException ) -{ - impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XKeyListener >*)0), xListener ); -} - -//____________________________________________________________________________________________________________ -// XWindow -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::addMouseListener( const Reference< XMouseListener >& xListener ) throw( RuntimeException ) -{ - impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XMouseListener >*)0), xListener ); -} - -//____________________________________________________________________________________________________________ -// XWindow -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::addMouseMotionListener( const Reference< XMouseMotionListener >& xListener ) throw( RuntimeException ) -{ - impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XMouseMotionListener >*)0), xListener ); -} - -//____________________________________________________________________________________________________________ -// XWindow -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::addPaintListener( const Reference< XPaintListener >& xListener ) throw( RuntimeException ) -{ - impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XPaintListener >*)0), xListener ); -} - -//____________________________________________________________________________________________________________ -// XWindow -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::removeWindowListener( const Reference< XWindowListener >& xListener ) throw( RuntimeException ) -{ - impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XWindowListener >*)0), xListener ); -} - -//____________________________________________________________________________________________________________ -// XWindow -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::removeFocusListener( const Reference< XFocusListener >& xListener ) throw( RuntimeException ) -{ - impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XFocusListener >*)0), xListener ); -} - -//____________________________________________________________________________________________________________ -// XWindow -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::removeKeyListener( const Reference< XKeyListener >& xListener ) throw( RuntimeException ) -{ - impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XKeyListener >*)0), xListener ); -} - -//____________________________________________________________________________________________________________ -// XWindow -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::removeMouseListener( const Reference< XMouseListener >& xListener ) throw( RuntimeException ) -{ - impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XMouseListener >*)0), xListener ); -} - -//____________________________________________________________________________________________________________ -// XWindow -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::removeMouseMotionListener( const Reference< XMouseMotionListener >& xListener ) throw( RuntimeException ) -{ - impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XMouseMotionListener >*)0), xListener ); -} - -//____________________________________________________________________________________________________________ -// XWindow -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::removePaintListener( const Reference< XPaintListener >& xListener ) throw( RuntimeException ) -{ - impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XPaintListener >*)0), xListener ); -} - -//____________________________________________________________________________________________________________ -// XView -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::draw( sal_Int32 nX , - sal_Int32 nY ) throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - - // - paint to an view - // - use the method "paint()" - // - see also "windowPaint()" - impl_paint( nX, nY, m_xGraphicsView ); -} - -//____________________________________________________________________________________________________________ -// XView -//____________________________________________________________________________________________________________ - -sal_Bool SAL_CALL BaseControl::setGraphics( const Reference< XGraphics >& xDevice ) throw( RuntimeException ) -{ - // - set the graphics for an view - // - in this class exist 2 graphics-member ... one for peer[_xGraphicsPeer] and one for view[_xGraphicsView] - // - they are used by "windowPaint() and draw()", forwarded to "paint ()" - sal_Bool bReturn = sal_False ; - if ( xDevice.is() == sal_True ) - { - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - - m_xGraphicsView = xDevice ; - bReturn = sal_True ; - } - - return bReturn ; -} - -//____________________________________________________________________________________________________________ -// XView -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::setZoom( float /*fZoomX*/ , - float /*fZoomY*/ ) throw( RuntimeException ) -{ - // Not implemented yet -} - -//____________________________________________________________________________________________________________ -// XView -//____________________________________________________________________________________________________________ - -Reference< XGraphics > SAL_CALL BaseControl::getGraphics() throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - return m_xGraphicsView ; -} - -//____________________________________________________________________________________________________________ -// XView -//____________________________________________________________________________________________________________ - -Size SAL_CALL BaseControl::getSize() throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - return Size( m_nWidth, m_nHeight ); -} - -//____________________________________________________________________________________________________________ -// XEventListener -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::disposing( const EventObject& /*aSource*/ ) throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - - // - release ALL references - // - it must be !!! - if ( m_xGraphicsPeer.is() == sal_True ) - { - removePaintListener( this ); - removeWindowListener( this ); - m_xGraphicsPeer = Reference< XGraphics >(); - } - - if ( m_xGraphicsView.is() == sal_True ) - { - m_xGraphicsView = Reference< XGraphics >(); - } -} - -//____________________________________________________________________________________________________________ -// XPaintListener -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::windowPaint( const PaintEvent& /*aEvent*/ ) throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - - // - repaint the peer - // - use the method "paint ()" for painting on a peer and a print device !!! - // - see also "draw ()" - impl_paint( 0, 0, m_xGraphicsPeer ); -} - -//____________________________________________________________________________________________________________ -// XWindowListener -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::windowResized( const WindowEvent& aEvent ) throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - - m_nWidth = aEvent.Width ; - m_nHeight = aEvent.Height ; - WindowEvent aMappedEvent = aEvent; - aMappedEvent.X = 0; - aMappedEvent.Y = 0; - impl_recalcLayout( aMappedEvent ); -} - -//____________________________________________________________________________________________________________ -// XWindowListener -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::windowMoved( const WindowEvent& aEvent ) throw( RuntimeException ) -{ - // Ready for multithreading - MutexGuard aGuard( m_aMutex ); - - m_nWidth = aEvent.Width ; - m_nHeight = aEvent.Height ; - WindowEvent aMappedEvent = aEvent; - aMappedEvent.X = 0; - aMappedEvent.Y = 0; - impl_recalcLayout( aMappedEvent ); -} - -//____________________________________________________________________________________________________________ -// XWindowListener -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::windowShown( const EventObject& /*aEvent*/ ) throw( RuntimeException ) -{ -} - -//____________________________________________________________________________________________________________ -// XWindowListener -//____________________________________________________________________________________________________________ - -void SAL_CALL BaseControl::windowHidden( const EventObject& /*aEvent*/ ) throw( RuntimeException ) -{ -} - -//____________________________________________________________________________________________________________ -// impl but public method to register service in DLL -// (In this BASE-implementation not implemented! Overwrite it in derived classes.) -//____________________________________________________________________________________________________________ - -const Sequence< OUString > BaseControl::impl_getStaticSupportedServiceNames() -{ - return Sequence< OUString >(); -} - -//____________________________________________________________________________________________________________ -// impl but public method to register service in DLL -// (In this BASE-implementation not implemented! Overwrite it in derived classes.) -//____________________________________________________________________________________________________________ - -const OUString BaseControl::impl_getStaticImplementationName() -{ - return OUString(); -} - -//____________________________________________________________________________________________________________ -// protected method -//____________________________________________________________________________________________________________ - -const Reference< XMultiServiceFactory > BaseControl::impl_getMultiServiceFactory() -{ - return m_xFactory ; -} - -//____________________________________________________________________________________________________________ -// protected method -//____________________________________________________________________________________________________________ - -const Reference< XWindow > BaseControl::impl_getPeerWindow() -{ - return m_xPeerWindow ; -} - -//____________________________________________________________________________________________________________ -// protected method -//____________________________________________________________________________________________________________ - -const Reference< XGraphics > BaseControl::impl_getGraphicsPeer() -{ - return m_xGraphicsPeer ; -} - -//____________________________________________________________________________________________________________ -// protected method -//____________________________________________________________________________________________________________ - -const sal_Int32& BaseControl::impl_getWidth() -{ - return m_nWidth ; -} - -//____________________________________________________________________________________________________________ -// protected method -//____________________________________________________________________________________________________________ - -const sal_Int32& BaseControl::impl_getHeight() -{ - return m_nHeight ; -} - -//____________________________________________________________________________________________________________ -// protected method -//____________________________________________________________________________________________________________ - -WindowDescriptor* BaseControl::impl_getWindowDescriptor( const Reference< XWindowPeer >& xParentPeer ) -{ - // - used from "createPeer()" to set the values of an ::com::sun::star::awt::WindowDescriptor !!! - // - if you will change the descriptor-values, you must override this virtuell function - // - the caller must release the memory for this dynamical descriptor !!! - - WindowDescriptor* pDescriptor = new WindowDescriptor ; - - pDescriptor->Type = WindowClass_SIMPLE ; - pDescriptor->WindowServiceName = OUString(RTL_CONSTASCII_USTRINGPARAM("window")) ; - pDescriptor->ParentIndex = -1 ; - pDescriptor->Parent = xParentPeer ; - pDescriptor->Bounds = getPosSize () ; - pDescriptor->WindowAttributes = 0 ; - - return pDescriptor ; -} - -//____________________________________________________________________________________________________________ -// protected method -//____________________________________________________________________________________________________________ - -void BaseControl::impl_paint( sal_Int32 /*nX*/ , - sal_Int32 /*nY*/ , - const Reference< XGraphics >& /*xGraphics*/ ) -{ - // - one paint method for peer AND view !!! - // (see also => "windowPaint()" and "draw()") - // - not used in this implementation, but its not necessary to make it pure virtual !!! -} - -//____________________________________________________________________________________________________________ -// protected method -//____________________________________________________________________________________________________________ - -void BaseControl::impl_recalcLayout( const WindowEvent& /*aEvent*/ ) -{ - // We need as virtual function to support automaticly resizing of derived controls! - // But we make it not pure virtual because it's not neccessary for all derived classes! -} - -//____________________________________________________________________________________________________________ -// protected method -//____________________________________________________________________________________________________________ - -Reference< XInterface > BaseControl::impl_getDelegator() -{ - return m_xDelegator ; -} - -//____________________________________________________________________________________________________________ -// private method -//____________________________________________________________________________________________________________ - -void BaseControl::impl_releasePeer() -{ - if ( m_xPeer.is() == sal_True ) - { - if ( m_xGraphicsPeer.is() == sal_True ) - { - removePaintListener( this ); - removeWindowListener( this ); - m_xGraphicsPeer = Reference< XGraphics >(); - } - - m_xPeer->dispose(); - m_xPeerWindow = Reference< XWindow >(); - m_xPeer = Reference< XWindowPeer >(); - - if ( m_pMultiplexer != NULL ) - { - // take changes on multiplexer - m_pMultiplexer->setPeer( Reference< XWindow >() ); - } - } -} - -//____________________________________________________________________________________________________________ -// private method -//____________________________________________________________________________________________________________ - -OMRCListenerMultiplexerHelper* BaseControl::impl_getMultiplexer() -{ - if ( m_pMultiplexer == NULL ) - { - m_pMultiplexer = new OMRCListenerMultiplexerHelper( (XWindow*)this, m_xPeerWindow ); - m_xMultiplexer = Reference< XInterface >( (OWeakObject*)m_pMultiplexer, UNO_QUERY ); - } - - return m_pMultiplexer ; -} - -} // namespace unocontrols - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/base/makefile.mk b/UnoControls/source/base/makefile.mk deleted file mode 100644 index 66b87395a..000000000 --- a/UnoControls/source/base/makefile.mk +++ /dev/null @@ -1,46 +0,0 @@ -#************************************************************************* -# -# 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=UnoControls -TARGET=base -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ----------------------------------------------------- - -.INCLUDE : $(PRJ)$/util$/makefile.pmk - -# --- Files -------------------------------------------------------- - -SLOFILES= $(SLO)$/multiplexer.obj \ - $(SLO)$/basecontrol.obj \ - $(SLO)$/basecontainercontrol.obj \ - $(SLO)$/registercontrols.obj - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk diff --git a/UnoControls/source/base/multiplexer.cxx b/UnoControls/source/base/multiplexer.cxx deleted file mode 100644 index d7be8569a..000000000 --- a/UnoControls/source/base/multiplexer.cxx +++ /dev/null @@ -1,530 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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 "multiplexer.hxx" - -#include <osl/diagnose.h> - -using namespace ::cppu ; -using namespace ::osl ; -using namespace ::com::sun::star::uno ; -using namespace ::com::sun::star::awt ; -using namespace ::com::sun::star::lang ; - -namespace unocontrols{ - -//____________________________________________________________________________________________________________ -// macros -//____________________________________________________________________________________________________________ - -#define MULTIPLEX( INTERFACE, METHOD, EVENTTYP, EVENT ) \ - \ - /* First get all interfaces from container with right type.*/ \ - OInterfaceContainerHelper* pContainer = m_aListenerHolder.getContainer( ::getCppuType((const Reference< INTERFACE >*)0) ); \ - /* Do the follow only, if elements in container exist.*/ \ - if( pContainer != NULL ) \ - { \ - OInterfaceIteratorHelper aIterator( *pContainer ); \ - EVENTTYP aLocalEvent = EVENT; \ - /* Remark: The control is the event source not the peer.*/ \ - /* We must change the source of the event. */ \ - aLocalEvent.Source = m_xControl ; \ - /* Is the control not destroyed? */ \ - if( aLocalEvent.Source.is() == sal_True ) \ - { \ - if( aIterator.hasMoreElements() ) \ - { \ - INTERFACE * pListener = (INTERFACE *)aIterator.next(); \ - try \ - { \ - pListener->METHOD( aLocalEvent ); \ - } \ - catch( RuntimeException& ) \ - { \ - /* Ignore all system exceptions from the listener! */ \ - } \ - } \ - } \ - } - -//____________________________________________________________________________________________________________ -// construct/destruct -//____________________________________________________________________________________________________________ - -OMRCListenerMultiplexerHelper::OMRCListenerMultiplexerHelper( const Reference< XWindow >& xControl , - const Reference< XWindow >& xPeer ) - : m_xPeer ( xPeer ) - , m_xControl ( xControl ) - , m_aListenerHolder ( m_aMutex ) -{ -} - -OMRCListenerMultiplexerHelper::OMRCListenerMultiplexerHelper( const OMRCListenerMultiplexerHelper& /*aCopyInstance*/ ) - : XFocusListener() - , XWindowListener() - , XKeyListener() - , XMouseListener() - , XMouseMotionListener() - , XPaintListener() - , XTopWindowListener() - , OWeakObject() - , m_aListenerHolder ( m_aMutex ) -{ -} - -OMRCListenerMultiplexerHelper::~OMRCListenerMultiplexerHelper() -{ -} - -//____________________________________________________________________________________________________________ -// XInterface -//____________________________________________________________________________________________________________ - -Any SAL_CALL OMRCListenerMultiplexerHelper::queryInterface( const Type& rType ) throw( RuntimeException ) -{ - // Attention: - // Don't use mutex or guard in this method!!! Is a method of XInterface. - - // Ask for my own supported interfaces ... - // Attention: XTypeProvider and XInterface are supported by OComponentHelper! - Any aReturn ( ::cppu::queryInterface( rType , - static_cast< XWindowListener* > ( this ) , - static_cast< XKeyListener* > ( this ) , - static_cast< XFocusListener* > ( this ) , - static_cast< XMouseListener* > ( this ) , - static_cast< XMouseMotionListener* > ( this ) , - static_cast< XPaintListener* > ( this ) , - static_cast< XTopWindowListener* > ( this ) , - static_cast< XTopWindowListener* > ( this ) - ) - ); - - // If searched interface supported by this class ... - if ( aReturn.hasValue() == sal_True ) - { - // ... return this information. - return aReturn ; - } - else - { - // Else; ... ask baseclass for interfaces! - return OWeakObject::queryInterface( rType ); - } -} - -//____________________________________________________________________________________________________________ -// XInterface -//____________________________________________________________________________________________________________ - -void SAL_CALL OMRCListenerMultiplexerHelper::acquire() throw() -{ - // Attention: - // Don't use mutex or guard in this method!!! Is a method of XInterface. - - // Forward to baseclass - OWeakObject::acquire(); -} - -//____________________________________________________________________________________________________________ -// XInterface -//____________________________________________________________________________________________________________ - -void SAL_CALL OMRCListenerMultiplexerHelper::release() throw() -{ - // Attention: - // Don't use mutex or guard in this method!!! Is a method of XInterface. - - // Forward to baseclass - OWeakObject::release(); -} - -//____________________________________________________________________________________________________________ -// operator -//____________________________________________________________________________________________________________ - -OMRCListenerMultiplexerHelper::operator Reference< XInterface >() const -{ - return ((OWeakObject*)this) ; -} - -//____________________________________________________________________________________________________________ -// container method -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::setPeer( const Reference< XWindow >& xPeer ) -{ - MutexGuard aGuard( m_aMutex ); - if( m_xPeer != xPeer ) - { - if( m_xPeer.is() ) - { - // get all types from the listener added to the peer - Sequence< Type > aContainedTypes = m_aListenerHolder.getContainedTypes(); - const Type* pArray = aContainedTypes.getConstArray(); - sal_Int32 nCount = aContainedTypes.getLength(); - // loop over all listener types and remove the listeners from the peer - for( sal_Int32 i=0; i<nCount; i++ ) - impl_unadviseFromPeer( m_xPeer, pArray[i] ); - } - m_xPeer = xPeer; - if( m_xPeer.is() ) - { - // get all types from the listener added to the peer - Sequence< Type > aContainedTypes = m_aListenerHolder.getContainedTypes(); - const Type* pArray = aContainedTypes.getConstArray(); - sal_Int32 nCount = aContainedTypes.getLength(); - // loop over all listener types and add the listeners to the peer - for( sal_Int32 i = 0; i < nCount; i++ ) - impl_adviseToPeer( m_xPeer, pArray[i] ); - } - } -} - -//____________________________________________________________________________________________________________ -// container method -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::disposeAndClear() -{ - EventObject aEvent ; - aEvent.Source = m_xControl ; - m_aListenerHolder.disposeAndClear( aEvent ); -} - -//____________________________________________________________________________________________________________ -// container method -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::advise( const Type& aType , - const Reference< XInterface >& xListener ) -{ - MutexGuard aGuard( m_aMutex ); - if( m_aListenerHolder.addInterface( aType, xListener ) == 1 ) - { - // the first listener is added - if( m_xPeer.is() ) - { - impl_adviseToPeer( m_xPeer, aType ); - } - } -} - -//____________________________________________________________________________________________________________ -// container method -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::unadvise( const Type& aType , - const Reference< XInterface >& xListener ) -{ - MutexGuard aGuard( m_aMutex ); - if( m_aListenerHolder.removeInterface( aType, xListener ) == 0 ) - { - // the last listener is removed - if ( m_xPeer.is() ) - { - impl_unadviseFromPeer( m_xPeer, aType ); - } - } -} - -//____________________________________________________________________________________________________________ -// XEventListener -//____________________________________________________________________________________________________________ - -void SAL_CALL OMRCListenerMultiplexerHelper::disposing( const EventObject& /*aSource*/ ) throw( RuntimeException ) -{ - MutexGuard aGuard( m_aMutex ); - // peer is disposed, clear the reference - m_xPeer = Reference< XWindow >(); -} - -//____________________________________________________________________________________________________________ -// XFcousListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::focusGained(const FocusEvent& aEvent ) throw( RuntimeException ) -{ - MULTIPLEX( XFocusListener, focusGained, FocusEvent, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XFcousListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::focusLost(const FocusEvent& aEvent ) throw( RuntimeException ) -{ - MULTIPLEX( XFocusListener, focusLost, FocusEvent, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XWindowListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::windowResized(const WindowEvent& aEvent ) throw( RuntimeException ) -{ - MULTIPLEX( XWindowListener, windowResized, WindowEvent, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XWindowListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::windowMoved(const WindowEvent& aEvent ) throw( RuntimeException ) -{ - MULTIPLEX( XWindowListener, windowMoved, WindowEvent, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XWindowListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::windowShown(const EventObject& aEvent ) throw( RuntimeException ) -{ - MULTIPLEX( XWindowListener, windowShown, EventObject, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XWindowListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::windowHidden(const EventObject& aEvent ) throw( RuntimeException ) -{ - MULTIPLEX( XWindowListener, windowHidden, EventObject, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XKeyListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::keyPressed(const KeyEvent& aEvent) throw( RuntimeException ) -{ - MULTIPLEX( XKeyListener, keyPressed, KeyEvent, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XKeyListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::keyReleased(const KeyEvent& aEvent) throw( RuntimeException ) -{ - MULTIPLEX( XKeyListener, keyReleased, KeyEvent, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XMouseListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::mousePressed(const MouseEvent& aEvent) throw( RuntimeException ) -{ - MULTIPLEX( XMouseListener, mousePressed, MouseEvent, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XMouseListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::mouseReleased(const MouseEvent& aEvent) throw( RuntimeException ) -{ - MULTIPLEX( XMouseListener, mouseReleased, MouseEvent, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XMouseListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::mouseEntered(const MouseEvent& aEvent) throw( RuntimeException ) -{ - MULTIPLEX( XMouseListener, mouseEntered, MouseEvent, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XMouseListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::mouseExited(const MouseEvent& aEvent) throw( RuntimeException ) -{ - MULTIPLEX( XMouseListener, mouseExited, MouseEvent, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XMouseMotionListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::mouseDragged(const MouseEvent& aEvent) throw( RuntimeException ) -{ - MULTIPLEX( XMouseMotionListener, mouseDragged, MouseEvent, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XMouseMotionListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::mouseMoved(const MouseEvent& aEvent) throw( RuntimeException ) -{ - MULTIPLEX( XMouseMotionListener, mouseMoved, MouseEvent, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XPaintListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::windowPaint(const PaintEvent& aEvent) throw( RuntimeException ) -{ - MULTIPLEX( XPaintListener, windowPaint, PaintEvent, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XTopWindowListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::windowOpened(const EventObject& aEvent) throw( RuntimeException ) -{ - MULTIPLEX( XTopWindowListener, windowOpened, EventObject, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XTopWindowListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::windowClosing( const EventObject& aEvent ) throw( RuntimeException ) -{ - MULTIPLEX( XTopWindowListener, windowClosing, EventObject, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XTopWindowListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::windowClosed( const EventObject& aEvent ) throw( RuntimeException ) -{ - MULTIPLEX( XTopWindowListener, windowClosed, EventObject, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XTopWindowListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::windowMinimized( const EventObject& aEvent ) throw( RuntimeException ) -{ - MULTIPLEX( XTopWindowListener, windowMinimized, EventObject, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XTopWindowListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::windowNormalized( const EventObject& aEvent ) throw( RuntimeException ) -{ - MULTIPLEX( XTopWindowListener, windowNormalized, EventObject, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XTopWindowListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::windowActivated( const EventObject& aEvent ) throw( RuntimeException ) -{ - MULTIPLEX( XTopWindowListener, windowActivated, EventObject, aEvent ) -} - -//____________________________________________________________________________________________________________ -// XTopWindowListener -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::windowDeactivated( const EventObject& aEvent ) throw( RuntimeException ) -{ - MULTIPLEX( XTopWindowListener, windowDeactivated, EventObject, aEvent ) -} - -//____________________________________________________________________________________________________________ -// protected method -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::impl_adviseToPeer( const Reference< XWindow >& xPeer , - const Type& aType ) -{ - // add a listener to the source (peer) - if( aType == ::getCppuType((const Reference< XWindowListener >*)0) ) - xPeer->addWindowListener( this ); - else if( aType == ::getCppuType((const Reference< XKeyListener >*)0) ) - xPeer->addKeyListener( this ); - else if( aType == ::getCppuType((const Reference< XFocusListener >*)0) ) - xPeer->addFocusListener( this ); - else if( aType == ::getCppuType((const Reference< XMouseListener >*)0) ) - xPeer->addMouseListener( this ); - else if( aType == ::getCppuType((const Reference< XMouseMotionListener >*)0) ) - xPeer->addMouseMotionListener( this ); - else if( aType == ::getCppuType((const Reference< XPaintListener >*)0) ) - xPeer->addPaintListener( this ); - else if( aType == ::getCppuType((const Reference< XTopWindowListener >*)0) ) - { - Reference< XTopWindow > xTop( xPeer, UNO_QUERY ); - if( xTop.is() ) - xTop->addTopWindowListener( this ); - } - else - { - OSL_FAIL( "unknown listener" ); - } -} - -//____________________________________________________________________________________________________________ -// protected method -//____________________________________________________________________________________________________________ - -void OMRCListenerMultiplexerHelper::impl_unadviseFromPeer( const Reference< XWindow >& xPeer , - const Type& aType ) -{ - // the last listener is removed, remove the listener from the source (peer) - if( aType == ::getCppuType((const Reference< XWindowListener >*)0) ) - xPeer->removeWindowListener( this ); - else if( aType == ::getCppuType((const Reference< XKeyListener >*)0) ) - xPeer->removeKeyListener( this ); - else if( aType == ::getCppuType((const Reference< XFocusListener >*)0) ) - xPeer->removeFocusListener( this ); - else if( aType == ::getCppuType((const Reference< XMouseListener >*)0) ) - xPeer->removeMouseListener( this ); - else if( aType == ::getCppuType((const Reference< XMouseMotionListener >*)0) ) - xPeer->removeMouseMotionListener( this ); - else if( aType == ::getCppuType((const Reference< XPaintListener >*)0) ) - xPeer->removePaintListener( this ); - else if( aType == ::getCppuType((const Reference< XTopWindowListener >*)0) ) - { - Reference< XTopWindow > xTop( xPeer, UNO_QUERY ); - if( xTop.is() ) - xTop->removeTopWindowListener( this ); - } - else - { - OSL_FAIL( "unknown listener" ); - } -} - -} // namespace unocontrols - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/base/registercontrols.cxx b/UnoControls/source/base/registercontrols.cxx deleted file mode 100644 index f786c9285..000000000 --- a/UnoControls/source/base/registercontrols.cxx +++ /dev/null @@ -1,181 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -//______________________________________________________________________________________________________________ -// includes of other projects -//______________________________________________________________________________________________________________ - -#include <cppuhelper/factory.hxx> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <com/sun/star/registry/XRegistryKey.hpp> -#include <com/sun/star/container/XSet.hpp> - -#include <stdio.h> - -//______________________________________________________________________________________________________________ -// includes of my own project -//______________________________________________________________________________________________________________ - -//============================================================================= -// Add new include line to use new services. -//============================================================================= -#include "framecontrol.hxx" -#include "progressbar.hxx" -#include "progressmonitor.hxx" -#include "statusindicator.hxx" -//============================================================================= - -//______________________________________________________________________________________________________________ -// namespaces -//______________________________________________________________________________________________________________ - -using namespace ::rtl ; -using namespace ::cppu ; -using namespace ::unocontrols ; -using namespace ::com::sun::star::uno ; -using namespace ::com::sun::star::container ; -using namespace ::com::sun::star::lang ; -using namespace ::com::sun::star::registry ; - -//______________________________________________________________________________________________________________ -// macros -//______________________________________________________________________________________________________________ - -//****************************************************************************************************************************** -#define CREATEINSTANCE(CLASS) \ - \ - static Reference< XInterface > SAL_CALL CLASS##_createInstance ( const Reference< XMultiServiceFactory >& rServiceManager ) throw ( Exception ) \ - { \ - return Reference< XInterface >( *(OWeakObject*)(new CLASS( rServiceManager )) ); \ - } - -//****************************************************************************************************************************** -#define CREATEFACTORY_ONEINSTANCE(CLASS) \ - \ - /* Create right factory ... */ \ - xFactory = Reference< XSingleServiceFactory > \ - ( \ - cppu::createOneInstanceFactory ( xServiceManager , \ - CLASS::impl_getStaticImplementationName () , \ - CLASS##_createInstance , \ - CLASS::impl_getStaticSupportedServiceNames () ) \ - ) ; \ - -//****************************************************************************************************************************** -#define CREATEFACTORY_SINGLE(CLASS) \ - \ - /* Create right factory ... */ \ - xFactory = Reference< XSingleServiceFactory > \ - ( \ - cppu::createSingleFactory ( xServiceManager , \ - CLASS::impl_getStaticImplementationName () , \ - CLASS##_createInstance , \ - CLASS::impl_getStaticSupportedServiceNames () ) \ - ) ; \ - -//****************************************************************************************************************************** -#define IF_NAME_CREATECOMPONENTFACTORY_ONEINSTANCE(CLASS) \ - \ - if ( CLASS::impl_getStaticImplementationName().equals( OUString::createFromAscii( pImplementationName ) ) ) \ - { \ - CREATEFACTORY_ONEINSTANCE ( CLASS ) \ - } - -//****************************************************************************************************************************** -#define IF_NAME_CREATECOMPONENTFACTORY_SINGLE(CLASS) \ - \ - if ( CLASS::impl_getStaticImplementationName().equals( OUString::createFromAscii( pImplementationName ) ) ) \ - { \ - CREATEFACTORY_SINGLE ( CLASS ) \ - } - -//______________________________________________________________________________________________________________ -// declare functions to create a new instance of service -//______________________________________________________________________________________________________________ - -//============================================================================= -// Add new macro line to use new services. -// -// !!! ATTENTION !!! -// Write no ";" at end of line! (see macro) -//============================================================================= -CREATEINSTANCE ( FrameControl ) -CREATEINSTANCE ( ProgressBar ) -CREATEINSTANCE ( ProgressMonitor ) -CREATEINSTANCE ( StatusIndicator ) -//============================================================================= - -//______________________________________________________________________________________________________________ -// create right component factory -//______________________________________________________________________________________________________________ - -extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplementationName , - void* pServiceManager , - void* /*pRegistryKey*/ ) -{ - // Set default return value for this operation - if it failed. - void* pReturn = NULL ; - - if ( - ( pImplementationName != NULL ) && - ( pServiceManager != NULL ) - ) - { - // Define variables which are used in following macros. - Reference< XSingleServiceFactory > xFactory ; - Reference< XMultiServiceFactory > xServiceManager( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ; - - //============================================================================= - // Add new macro line to handle new service. - // - // !!! ATTENTION !!! - // Write no ";" at end of line and dont forget "else" ! (see macro) - //============================================================================= - IF_NAME_CREATECOMPONENTFACTORY_SINGLE( FrameControl ) - else - IF_NAME_CREATECOMPONENTFACTORY_SINGLE( ProgressBar ) - else - IF_NAME_CREATECOMPONENTFACTORY_SINGLE( ProgressMonitor ) - else - IF_NAME_CREATECOMPONENTFACTORY_SINGLE( StatusIndicator ) - //============================================================================= - - // Factory is valid - service was found. - if ( xFactory.is() ) - { - xFactory->acquire(); - pReturn = xFactory.get(); - } - } - - // Return with result of this operation. - return pReturn ; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |