summaryrefslogtreecommitdiff
path: root/UnoControls/source/controls
diff options
context:
space:
mode:
Diffstat (limited to 'UnoControls/source/controls')
-rw-r--r--UnoControls/source/controls/OConnectionPointContainerHelper.cxx190
-rw-r--r--UnoControls/source/controls/OConnectionPointHelper.cxx275
-rw-r--r--UnoControls/source/controls/framecontrol.cxx606
-rw-r--r--UnoControls/source/controls/makefile.mk49
-rw-r--r--UnoControls/source/controls/progressbar.cxx494
-rw-r--r--UnoControls/source/controls/progressmonitor.cxx1070
-rw-r--r--UnoControls/source/controls/statusindicator.cxx562
7 files changed, 3246 insertions, 0 deletions
diff --git a/UnoControls/source/controls/OConnectionPointContainerHelper.cxx b/UnoControls/source/controls/OConnectionPointContainerHelper.cxx
new file mode 100644
index 000000000000..c5bd8cfce1e9
--- /dev/null
+++ b/UnoControls/source/controls/OConnectionPointContainerHelper.cxx
@@ -0,0 +1,190 @@
+/* -*- 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 "OConnectionPointContainerHelper.hxx"
+
+//______________________________________________________________________________________________________________
+// includes of other projects
+//______________________________________________________________________________________________________________
+
+//______________________________________________________________________________________________________________
+// include of my own project
+//______________________________________________________________________________________________________________
+#include "OConnectionPointHelper.hxx"
+
+//______________________________________________________________________________________________________________
+// namespaces
+//______________________________________________________________________________________________________________
+
+using namespace ::rtl ;
+using namespace ::osl ;
+using namespace ::cppu ;
+using namespace ::com::sun::star::uno ;
+using namespace ::com::sun::star::lang ;
+
+namespace unocontrols{
+
+//______________________________________________________________________________________________________________
+// construct/destruct
+//______________________________________________________________________________________________________________
+
+OConnectionPointContainerHelper::OConnectionPointContainerHelper( Mutex& aMutex )
+ : m_aSharedMutex ( aMutex )
+ , m_aMultiTypeContainer ( aMutex )
+{
+}
+
+OConnectionPointContainerHelper::~OConnectionPointContainerHelper()
+{
+}
+
+//____________________________________________________________________________________________________________
+// XInterface
+//____________________________________________________________________________________________________________
+
+Any SAL_CALL OConnectionPointContainerHelper::queryInterface( const Type& aType ) throw( RuntimeException )
+{
+ // Attention:
+ // Don't use mutex or guard in this method!!! Is a method of XInterface.
+
+ // Ask for my own supported interfaces ...
+ Any aReturn ( ::cppu::queryInterface( aType ,
+ static_cast< XConnectionPointContainer* > ( this )
+ )
+ );
+
+ // If searched interface not supported by this class ...
+ if ( aReturn.hasValue() == sal_False )
+ {
+ // ... ask baseclasses.
+ aReturn = OWeakObject::queryInterface( aType );
+ }
+
+ return aReturn ;
+}
+
+//____________________________________________________________________________________________________________
+// XInterface
+//____________________________________________________________________________________________________________
+
+void SAL_CALL OConnectionPointContainerHelper::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 OConnectionPointContainerHelper::release() throw()
+{
+ // Attention:
+ // Don't use mutex or guard in this method!!! Is a method of XInterface.
+
+ // Forward to baseclass
+ OWeakObject::release();
+}
+
+//______________________________________________________________________________________________________________
+// XConnectionPointContainer
+//______________________________________________________________________________________________________________
+
+Sequence< Type > SAL_CALL OConnectionPointContainerHelper::getConnectionPointTypes() throw( RuntimeException )
+{
+ // Container is threadsafe himself !
+ return m_aMultiTypeContainer.getContainedTypes();
+}
+
+//______________________________________________________________________________________________________________
+// XConnectionPointContainer
+//______________________________________________________________________________________________________________
+
+Reference< XConnectionPoint > SAL_CALL OConnectionPointContainerHelper::queryConnectionPoint( const Type& aType ) throw( RuntimeException )
+{
+ // Set default return value, if method failed.
+ Reference< XConnectionPoint > xConnectionPoint = Reference< XConnectionPoint >();
+
+ // Get all elements of the container, which have the searched type.
+ OInterfaceContainerHelper* pSpecialContainer = m_aMultiTypeContainer.getContainer( aType );
+ if ( pSpecialContainer && pSpecialContainer->getLength() > 0 )
+ {
+ // Ready for multithreading
+ MutexGuard aGuard( m_aSharedMutex );
+ // If this container contains elements, build a connectionpoint-instance.
+ OConnectionPointHelper* pNewConnectionPoint = new OConnectionPointHelper( m_aSharedMutex, this, aType );
+ xConnectionPoint = Reference< XConnectionPoint >( (OWeakObject*)pNewConnectionPoint, UNO_QUERY );
+ }
+
+ return xConnectionPoint ;
+}
+
+//______________________________________________________________________________________________________________
+// XConnectionPointContainer
+//______________________________________________________________________________________________________________
+
+void SAL_CALL OConnectionPointContainerHelper::advise( const Type& aType ,
+ const Reference< XInterface >& xListener ) throw( RuntimeException )
+{
+ // Container is threadsafe himself !
+ m_aMultiTypeContainer.addInterface( aType, xListener );
+}
+
+//______________________________________________________________________________________________________________
+// XConnectionPointContainer
+//______________________________________________________________________________________________________________
+
+void SAL_CALL OConnectionPointContainerHelper::unadvise( const Type& aType ,
+ const Reference< XInterface >& xListener ) throw( RuntimeException )
+{
+ // Container is threadsafe himself !
+ m_aMultiTypeContainer.removeInterface( aType, xListener );
+}
+
+//______________________________________________________________________________________________________________
+// public but impl method!
+// Is neccessary to get container member at OConnectionPoint-instance.
+//______________________________________________________________________________________________________________
+
+OMultiTypeInterfaceContainerHelper& OConnectionPointContainerHelper::impl_getMultiTypeContainer()
+{
+ // Impl methods are not threadsafe!
+ // "Parent" function must do this.
+ return m_aMultiTypeContainer;
+}
+
+} // namespace unocontrols
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/UnoControls/source/controls/OConnectionPointHelper.cxx b/UnoControls/source/controls/OConnectionPointHelper.cxx
new file mode 100644
index 000000000000..a8b174b01a3a
--- /dev/null
+++ b/UnoControls/source/controls/OConnectionPointHelper.cxx
@@ -0,0 +1,275 @@
+/* -*- 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 "OConnectionPointHelper.hxx"
+
+//______________________________________________________________________________________________________________
+// includes of other projects
+//______________________________________________________________________________________________________________
+
+//______________________________________________________________________________________________________________
+// include of my own project
+//______________________________________________________________________________________________________________
+#include "OConnectionPointContainerHelper.hxx"
+
+//______________________________________________________________________________________________________________
+// namespaces
+//______________________________________________________________________________________________________________
+
+using namespace ::rtl ;
+using namespace ::osl ;
+using namespace ::cppu ;
+using namespace ::com::sun::star::uno ;
+using namespace ::com::sun::star::lang ;
+
+namespace unocontrols{
+
+//______________________________________________________________________________________________________________
+// construct/destruct
+//______________________________________________________________________________________________________________
+
+OConnectionPointHelper::OConnectionPointHelper(
+ Mutex& aMutex ,
+ OConnectionPointContainerHelper* pContainerImplementation ,
+ Type aType
+) : m_aSharedMutex ( aMutex )
+ , m_oContainerWeakReference ( pContainerImplementation )
+ , m_pContainerImplementation ( pContainerImplementation )
+ , m_aInterfaceType ( aType )
+{
+}
+
+OConnectionPointHelper::~OConnectionPointHelper()
+{
+}
+
+//____________________________________________________________________________________________________________
+// XInterface
+//____________________________________________________________________________________________________________
+
+Any SAL_CALL OConnectionPointHelper::queryInterface( const Type& aType ) throw( RuntimeException )
+{
+ // Attention:
+ // Don't use mutex or guard in this method!!! Is a method of XInterface.
+
+ // Ask for my own supported interfaces ...
+ Any aReturn ( ::cppu::queryInterface( aType ,
+ static_cast< XConnectionPoint* > ( this )
+ )
+ );
+
+ // If searched interface not supported by this class ...
+ if ( aReturn.hasValue() == sal_False )
+ {
+ // ... ask baseclasses.
+ aReturn = OWeakObject::queryInterface( aType );
+ }
+
+ return aReturn ;
+}
+
+//____________________________________________________________________________________________________________
+// XInterface
+//____________________________________________________________________________________________________________
+
+void SAL_CALL OConnectionPointHelper::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 OConnectionPointHelper::release() throw()
+{
+ // Attention:
+ // Don't use mutex or guard in this method!!! Is a method of XInterface.
+
+ // Forward to baseclass
+ OWeakObject::release();
+}
+
+//______________________________________________________________________________________________________________
+// XConnectionPoint
+//______________________________________________________________________________________________________________
+
+Type SAL_CALL OConnectionPointHelper::getConnectionType() throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard( m_aSharedMutex );
+
+ // Set default return value, if method failed.
+ if ( impl_LockContainer() == sal_False )
+ {
+ // Container not exist! Its an runtime error.
+ throw RuntimeException();
+ }
+
+ // If container reference valid, return right type of supported interfaces of THIS connectionpoint.
+ Type aReturnType = m_aInterfaceType ;
+ // Don't forget this!
+ impl_UnlockContainer();
+
+ return aReturnType;
+}
+
+//______________________________________________________________________________________________________________
+// XConnectionPoint
+//______________________________________________________________________________________________________________
+
+Reference< XConnectionPointContainer > SAL_CALL OConnectionPointHelper::getConnectionPointContainer() throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard( m_aSharedMutex );
+ // Convert weakreference to correct uno3-reference and return value. It can be NULL, if container destroyed!
+ return Reference< XConnectionPointContainer >( m_oContainerWeakReference.get(), UNO_QUERY );
+}
+
+//______________________________________________________________________________________________________________
+// XConnectionPoint
+//______________________________________________________________________________________________________________
+
+void SAL_CALL OConnectionPointHelper::advise( const Reference< XInterface >& xListener ) throw( ListenerExistException ,
+ InvalidListenerException ,
+ RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard( m_aSharedMutex );
+
+ // If type of listener not the same for this special container ...
+ Any aCheckType = xListener->queryInterface( m_aInterfaceType );
+ if ( aCheckType.hasValue() )
+ {
+ // ... throw an exception.
+ throw InvalidListenerException();
+ }
+
+ // ListenerExistException is obsolete!?
+ // Its the same container for XConnectionPointContainer and XConnectionPoint. But only here we must control, if a listener already exist!?
+ // You can add a listener more then one time at XConnectionPointContainer, but here only one ...
+
+ // Operation is permitted only, if reference to container is valid!
+ if ( impl_LockContainer() == sal_False )
+ {
+ // Container not exist! Its an runtime error.
+ throw RuntimeException();
+ }
+ // Forward it to OConnectionPointHelperContainer!
+ m_pContainerImplementation->advise( m_aInterfaceType, xListener );
+ // Don't forget this!
+ impl_UnlockContainer();
+}
+
+//______________________________________________________________________________________________________________
+// XConnectionPoint
+//______________________________________________________________________________________________________________
+
+void SAL_CALL OConnectionPointHelper::unadvise( const Reference< XInterface >& xListener ) throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard( m_aSharedMutex );
+ // Operation is permitted only, if reference to container is valid!
+ if ( impl_LockContainer() == sal_False )
+ {
+ // Container not exist! Its an runtime error.
+ throw RuntimeException();
+
+ }
+ // Forward it to OConnectionPointHelperContainer!
+ m_pContainerImplementation->unadvise( m_aInterfaceType, xListener );
+ // Don't forget this!
+ impl_UnlockContainer();
+}
+
+//______________________________________________________________________________________________________________
+// XConnectionPoint
+//______________________________________________________________________________________________________________
+
+Sequence< Reference< XInterface > > SAL_CALL OConnectionPointHelper::getConnections() throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard( m_aSharedMutex );
+ // Operation is permitted only, if reference to container is valid!
+ if ( impl_LockContainer() == sal_False )
+ {
+ // Container not exist! Its an runtime error.
+ throw RuntimeException();
+ }
+ // Set default return value, if method failed.
+ Sequence< Reference< XInterface > > seqReturnConnections = Sequence< Reference< XInterface > >();
+ // Get reference to private member of OConnectionPointHelperContainer!
+ OMultiTypeInterfaceContainerHelper& aSharedContainer = m_pContainerImplementation->impl_getMultiTypeContainer();
+ // Get pointer to specialized container which hold all interfaces of searched type.
+ OInterfaceContainerHelper* pSpecialContainer = aSharedContainer.getContainer( m_aInterfaceType );
+ // Get elements of searched type, if somelse exist.
+ if ( pSpecialContainer != NULL )
+ {
+ seqReturnConnections = pSpecialContainer->getElements();
+ }
+ // Don't forget this!
+ impl_UnlockContainer();
+
+ return seqReturnConnections;
+}
+
+//______________________________________________________________________________________________________________
+// private method
+//______________________________________________________________________________________________________________
+
+sal_Bool OConnectionPointHelper::impl_LockContainer()
+{
+ // Convert weakreference to hard uno3-reference and return state.
+ // If this reference different from NULL, there exist a hard reference to container. Container-instance can't be destroyed.
+ // Don't forget to "unlock" this reference!
+ m_xLock = m_oContainerWeakReference.get();
+ return m_xLock.is();
+}
+
+//______________________________________________________________________________________________________________
+// private method
+//______________________________________________________________________________________________________________
+
+void OConnectionPointHelper::impl_UnlockContainer()
+{
+ // Free hard uno3-reference to container.
+ // see also "impl_LockContainer()"
+ m_xLock = Reference< XInterface >();
+}
+
+} // namespace unocontrols
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/UnoControls/source/controls/framecontrol.cxx b/UnoControls/source/controls/framecontrol.cxx
new file mode 100644
index 000000000000..006924c85e4e
--- /dev/null
+++ b/UnoControls/source/controls/framecontrol.cxx
@@ -0,0 +1,606 @@
+/* -*- 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 "framecontrol.hxx"
+
+//______________________________________________________________________________________________________________
+// includes of other projects
+//______________________________________________________________________________________________________________
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <osl/diagnose.h>
+
+//______________________________________________________________________________________________________________
+// include of my own project
+//______________________________________________________________________________________________________________
+
+//______________________________________________________________________________________________________________
+// namespaces
+//______________________________________________________________________________________________________________
+
+using namespace ::rtl ;
+using namespace ::osl ;
+using namespace ::cppu ;
+using namespace ::com::sun::star::uno ;
+using namespace ::com::sun::star::lang ;
+using namespace ::com::sun::star::beans ;
+using namespace ::com::sun::star::awt ;
+using namespace ::com::sun::star::frame ;
+using namespace ::com::sun::star::util ;
+
+namespace unocontrols{
+
+//______________________________________________________________________________________________________________
+// construct/destruct
+//______________________________________________________________________________________________________________
+
+FrameControl::FrameControl( const Reference< XMultiServiceFactory >& xFactory )
+ : BaseControl ( xFactory )
+ , OBroadcastHelper ( m_aMutex )
+ , OPropertySetHelper ( *SAL_STATIC_CAST( OBroadcastHelper *, this ) )
+ , m_aInterfaceContainer ( m_aMutex )
+ , m_aConnectionPointContainer ( m_aMutex )
+{
+}
+
+FrameControl::~FrameControl()
+{
+}
+
+//____________________________________________________________________________________________________________
+// XInterface
+//____________________________________________________________________________________________________________
+
+Any SAL_CALL FrameControl::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() )
+ {
+ // 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 ;
+}
+
+//____________________________________________________________________________________________________________
+// XInterface
+//____________________________________________________________________________________________________________
+
+void SAL_CALL FrameControl::acquire() throw()
+{
+ // Attention:
+ // Don't use mutex or guard in this method!!! Is a method of XInterface.
+
+ // Forward to baseclass
+ BaseControl::acquire();
+}
+
+//____________________________________________________________________________________________________________
+// XInterface
+//____________________________________________________________________________________________________________
+
+void SAL_CALL FrameControl::release() throw()
+{
+ // Attention:
+ // Don't use mutex or guard in this method!!! Is a method of XInterface.
+
+ // Forward to baseclass
+ BaseControl::release();
+}
+
+//____________________________________________________________________________________________________________
+// XTypeProvider
+//____________________________________________________________________________________________________________
+
+Sequence< Type > SAL_CALL FrameControl::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 ) ,
+ ::getCppuType(( const Reference< XConnectionPointContainer >*)NULL ) ,
+ BaseControl::getTypes()
+ );
+ // ... and set his address to static pointer!
+ pTypeCollection = &aTypeCollection ;
+ }
+ }
+
+ return pTypeCollection->getTypes();
+}
+
+//____________________________________________________________________________________________________________
+// XAggregation
+//____________________________________________________________________________________________________________
+
+Any SAL_CALL FrameControl::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< XConnectionPointContainer* > ( this )
+ )
+ );
+
+ // If searched interface not supported by this class ...
+ if ( aReturn.hasValue() == sal_False )
+ {
+ // ... ask baseclasses.
+ aReturn = OPropertySetHelper::queryInterface( aType );
+ if ( aReturn.hasValue() == sal_False )
+ {
+ aReturn = BaseControl::queryAggregation( aType );
+ }
+ }
+
+ return aReturn ;
+}
+
+//____________________________________________________________________________________________________________
+// XControl
+//____________________________________________________________________________________________________________
+
+void SAL_CALL FrameControl::createPeer( const Reference< XToolkit >& xToolkit ,
+ const Reference< XWindowPeer >& xParentPeer ) throw( RuntimeException )
+{
+ BaseControl::createPeer( xToolkit, xParentPeer );
+ if ( impl_getPeerWindow().is() )
+ {
+ if( m_sComponentURL.getLength() > 0 )
+ {
+ impl_createFrame( getPeer(), m_sComponentURL, m_seqLoaderArguments );
+ }
+ }
+}
+
+//____________________________________________________________________________________________________________
+// XControl
+//____________________________________________________________________________________________________________
+
+sal_Bool SAL_CALL FrameControl::setModel( const Reference< XControlModel >& /*xModel*/ ) throw( RuntimeException )
+{
+ // We have no model.
+ return sal_False ;
+}
+
+//____________________________________________________________________________________________________________
+// XControl
+//____________________________________________________________________________________________________________
+
+Reference< XControlModel > SAL_CALL FrameControl::getModel() throw( RuntimeException )
+{
+ // We have no model.
+ return Reference< XControlModel >();
+}
+
+//____________________________________________________________________________________________________________
+// XControl
+//____________________________________________________________________________________________________________
+
+void SAL_CALL FrameControl::dispose() throw( RuntimeException )
+{
+ impl_deleteFrame();
+ BaseControl::dispose();
+}
+
+//____________________________________________________________________________________________________________
+// XView
+//____________________________________________________________________________________________________________
+
+sal_Bool SAL_CALL FrameControl::setGraphics( const Reference< XGraphics >& /*xDevice*/ ) throw( RuntimeException )
+{
+ // it is not possible to print this control
+ return sal_False ;
+}
+
+//____________________________________________________________________________________________________________
+// XView
+//____________________________________________________________________________________________________________
+
+Reference< XGraphics > SAL_CALL FrameControl::getGraphics() throw( RuntimeException )
+{
+ // when its not posible to set graphics ! then its possible to return null
+ return Reference< XGraphics >();
+}
+
+//____________________________________________________________________________________________________________
+// XConnectionPointContainer
+//____________________________________________________________________________________________________________
+
+Sequence< Type > SAL_CALL FrameControl::getConnectionPointTypes() throw( RuntimeException )
+{
+ // Forwarded to helper class
+ return m_aConnectionPointContainer.getConnectionPointTypes();
+}
+
+//____________________________________________________________________________________________________________
+// XConnectionPointContainer
+//____________________________________________________________________________________________________________
+
+Reference< XConnectionPoint > SAL_CALL FrameControl::queryConnectionPoint( const Type& aType ) throw( RuntimeException )
+{
+ // Forwarded to helper class
+ return m_aConnectionPointContainer.queryConnectionPoint( aType );
+}
+
+//____________________________________________________________________________________________________________
+// XConnectionPointContainer
+//____________________________________________________________________________________________________________
+
+void SAL_CALL FrameControl::advise( const Type& aType ,
+ const Reference< XInterface >& xListener ) throw( RuntimeException )
+{
+ // Forwarded to helper class
+ m_aConnectionPointContainer.advise( aType, xListener );
+}
+
+//____________________________________________________________________________________________________________
+// XConnectionPointContainer
+//____________________________________________________________________________________________________________
+
+void SAL_CALL FrameControl::unadvise( const Type& aType ,
+ const Reference< XInterface >& xListener ) throw( RuntimeException )
+{
+ // Forwarded to helper class
+ m_aConnectionPointContainer.unadvise( aType, xListener );
+}
+
+//____________________________________________________________________________________________________________
+// impl but public method to register service
+//____________________________________________________________________________________________________________
+
+const Sequence< OUString > FrameControl::impl_getStaticSupportedServiceNames()
+{
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ Sequence< OUString > seqServiceNames( 1 );
+ seqServiceNames.getArray() [0] = OUString(RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_FRAMECONTROL ));
+ return seqServiceNames ;
+}
+
+//____________________________________________________________________________________________________________
+// impl but public method to register service
+//____________________________________________________________________________________________________________
+
+const OUString FrameControl::impl_getStaticImplementationName()
+{
+ return OUString(RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATIONNAME_FRAMECONTROL ));
+}
+
+//____________________________________________________________________________________________________________
+// OPropertySetHelper
+//____________________________________________________________________________________________________________
+
+sal_Bool FrameControl::convertFastPropertyValue( Any& rConvertedValue ,
+ Any& rOldValue ,
+ sal_Int32 nHandle ,
+ const Any& rValue ) throw( IllegalArgumentException )
+{
+ sal_Bool bReturn = sal_False ;
+ switch (nHandle)
+ {
+ case PROPERTYHANDLE_COMPONENTURL : rConvertedValue = rValue ;
+ rOldValue <<= m_sComponentURL ;
+ bReturn = sal_True ;
+ break ;
+
+ case PROPERTYHANDLE_LOADERARGUMENTS : rConvertedValue = rValue ;
+ rOldValue <<= m_seqLoaderArguments ;
+ bReturn = sal_True ;
+ break ;
+ }
+
+ if ( bReturn == sal_False )
+ {
+ throw IllegalArgumentException();
+ }
+
+ return bReturn ;
+}
+
+//____________________________________________________________________________________________________________
+// OPropertySetHelper
+//____________________________________________________________________________________________________________
+
+void FrameControl::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle ,
+ const Any& rValue )
+ throw ( ::com::sun::star::uno::Exception )
+{
+ // this method only set the value
+ MutexGuard aGuard (m_aMutex) ;
+ switch (nHandle)
+ {
+ case PROPERTYHANDLE_COMPONENTURL : rValue >>= m_sComponentURL ;
+ if (getPeer().is())
+ {
+ impl_createFrame ( getPeer(), m_sComponentURL, m_seqLoaderArguments ) ;
+ }
+ break ;
+
+ case PROPERTYHANDLE_LOADERARGUMENTS : rValue >>= m_seqLoaderArguments ;
+ break ;
+
+ default : OSL_ENSURE ( nHandle == -1, ERRORTEXT_VOSENSHURE ) ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// OPropertySetHelper
+//____________________________________________________________________________________________________________
+
+void FrameControl::getFastPropertyValue( Any& rRet ,
+ sal_Int32 nHandle ) const
+{
+ MutexGuard aGuard ( Mutex::getGlobalMutex() ) ;
+
+ switch (nHandle)
+ {
+ case PROPERTYHANDLE_COMPONENTURL : rRet <<= m_sComponentURL ;
+ break ;
+
+ case PROPERTYHANDLE_LOADERARGUMENTS : rRet <<= m_seqLoaderArguments ;
+ break ;
+
+ case PROPERTYHANDLE_FRAME : rRet <<= m_xFrame ;
+ break ;
+
+ default : OSL_ENSURE ( nHandle == -1, ERRORTEXT_VOSENSHURE ) ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// OPropertySetHelper
+//____________________________________________________________________________________________________________
+
+IPropertyArrayHelper& FrameControl::getInfoHelper()
+{
+ // Create a table that map names to index values.
+ static OPropertyArrayHelper* pInfo ;
+
+ if (!pInfo)
+ {
+ // global method must be guarded
+ MutexGuard aGuard ( Mutex::getGlobalMutex() ) ;
+
+ if (!pInfo)
+ {
+ pInfo = new OPropertyArrayHelper( impl_getStaticPropertyDescriptor(), sal_True );
+ }
+ }
+
+ return *pInfo ;
+}
+/*
+//--------------------------------------------------------------------------------------------------
+// start OConnectionPointContainerHelper
+//--------------------------------------------------------------------------------------------------
+Uik* FrameControl::getConnectionPointUiks ( sal_Int32* pCount ) const
+{
+ static Uik szUiks[] =
+ {
+ ((XEventListener*)NULL)->getSmartUik (),
+ ::getCppuType((const Reference< XPropertyChangeListener >*)0),
+ ::getCppuType((const Reference< XVetoableChangeListener >*)0),
+ ::getCppuType((const Reference< XPropertiesChangeListener >*)0)
+ } ;
+
+ *pCount = 4 ;
+
+ return szUiks ;
+}
+//--------------------------------------------------------------------------------------------------
+// end OConnectionPointContainerHelper
+//--------------------------------------------------------------------------------------------------
+*/
+
+//____________________________________________________________________________________________________________
+// OPropertySetHelper
+//____________________________________________________________________________________________________________
+
+Reference< XPropertySetInfo > SAL_CALL FrameControl::getPropertySetInfo() 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; pInfo is NULL - for the second call pInfo is different from NULL!
+ static Reference< XPropertySetInfo >* pInfo = (Reference< XPropertySetInfo >*)0 ;
+ if ( pInfo == (Reference< XPropertySetInfo >*)0 )
+ {
+ // Ready for multithreading
+ MutexGuard aGuard ( Mutex::getGlobalMutex () ) ;
+ // Control this pointer again, another instance can be faster then these!
+ if ( pInfo == (Reference< XPropertySetInfo >*)0 )
+ {
+ // Create structure of propertysetinfo for baseclass "OPropertySetHelper".
+ // (Use method "getInfoHelper()".)
+ static Reference< XPropertySetInfo > xInfo ( createPropertySetInfo ( getInfoHelper () ) ) ;
+ pInfo = &xInfo ;
+ }
+ }
+ return ( *pInfo ) ;
+}
+
+//____________________________________________________________________________________________________________
+// BaseControl
+//____________________________________________________________________________________________________________
+
+WindowDescriptor* FrameControl::impl_getWindowDescriptor( const Reference< XWindowPeer >& xParentPeer )
+{
+ WindowDescriptor* pDescriptor = new WindowDescriptor ;
+
+ pDescriptor->Type = WindowClass_CONTAINER ;
+ pDescriptor->ParentIndex = -1 ;
+ pDescriptor->Parent = xParentPeer ;
+ pDescriptor->Bounds = getPosSize () ;
+ pDescriptor->WindowAttributes = 0 ;
+
+ return pDescriptor ;
+}
+
+//____________________________________________________________________________________________________________
+// private method
+//____________________________________________________________________________________________________________
+
+void FrameControl::impl_createFrame( const Reference< XWindowPeer >& xPeer ,
+ const OUString& rURL ,
+ const Sequence< PropertyValue >& rArguments )
+{
+ Reference< XFrame > xOldFrame ;
+ Reference< XFrame > xNewFrame ;
+
+ {
+ MutexGuard aGuard ( m_aMutex ) ;
+ xOldFrame = m_xFrame ;
+ }
+
+ xNewFrame = Reference< XFrame > ( impl_getMultiServiceFactory()->createInstance ( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Frame")) ), UNO_QUERY ) ;
+ Reference< XDispatchProvider > xDSP ( xNewFrame, UNO_QUERY ) ;
+
+ if (xDSP.is())
+ {
+ Reference< XWindow > xWP ( xPeer, UNO_QUERY ) ;
+ xNewFrame->initialize ( xWP ) ;
+
+ // option
+ //xFrame->setName( "WhatYouWant" );
+
+ Reference< XURLTransformer > xTrans ( impl_getMultiServiceFactory()->createInstance ( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.URLTransformer")) ), UNO_QUERY ) ;
+ if(xTrans.is())
+ {
+ // load file
+ URL aURL ;
+
+ aURL.Complete = rURL ;
+ xTrans->parseStrict( aURL ) ;
+
+ Reference< XDispatch > xDisp = xDSP->queryDispatch ( aURL, OUString (), FrameSearchFlag::SELF ) ;
+ if (xDisp.is())
+ {
+ xDisp->dispatch ( aURL, rArguments ) ;
+ }
+ }
+ }
+
+ // set the frame
+ {
+ MutexGuard aGuard ( m_aMutex ) ;
+ m_xFrame = xNewFrame ;
+ }
+
+ // notify the listeners
+ sal_Int32 nFrameId = PROPERTYHANDLE_FRAME ;
+ Any aNewFrame ( &xNewFrame, ::getCppuType((const Reference< XFrame >*)0) ) ;
+ Any aOldFrame ( &xOldFrame, ::getCppuType((const Reference< XFrame >*)0) ) ;
+
+ fire ( &nFrameId, &aNewFrame, &aOldFrame, 1, sal_False ) ;
+
+ if (xOldFrame.is())
+ {
+ xOldFrame->dispose () ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// private method
+//____________________________________________________________________________________________________________
+
+void FrameControl::impl_deleteFrame()
+{
+ Reference< XFrame > xOldFrame;
+ Reference< XFrame > xNullFrame;
+
+ {
+ // do not dispose the frame in this guarded section (deadlock?)
+ MutexGuard aGuard( m_aMutex );
+ xOldFrame = m_xFrame;
+ m_xFrame = Reference< XFrame > ();
+ }
+
+ // notify the listeners
+ sal_Int32 nFrameId = PROPERTYHANDLE_FRAME;
+ Any aNewFrame( &xNullFrame, ::getCppuType((const Reference< XFrame >*)0) );
+ Any aOldFrame( &xOldFrame, ::getCppuType((const Reference< XFrame >*)0) );
+ fire( &nFrameId, &aNewFrame, &aOldFrame, 1, sal_False );
+
+ // dispose the frame
+ if( xOldFrame.is() )
+ xOldFrame->dispose();
+}
+
+//____________________________________________________________________________________________________________
+// private method
+//____________________________________________________________________________________________________________
+
+const Sequence< Property > FrameControl::impl_getStaticPropertyDescriptor()
+{
+ // All Properties of this implementation. The array must be sorted!
+ static const Property pPropertys[PROPERTY_COUNT] =
+ {
+ Property( OUString(RTL_CONSTASCII_USTRINGPARAM( PROPERTYNAME_COMPONENTURL )), PROPERTYHANDLE_COMPONENTURL , ::getCppuType((const OUString*)0) , PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED ),
+ Property( OUString(RTL_CONSTASCII_USTRINGPARAM( PROPERTYNAME_FRAME )), PROPERTYHANDLE_FRAME , ::getCppuType((const Reference< XFrame >*)0) , PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT ),
+ Property( OUString(RTL_CONSTASCII_USTRINGPARAM( PROPERTYNAME_LOADERARGUMENTS )), PROPERTYHANDLE_LOADERARGUMENTS , ::getCppuType((const Sequence< PropertyValue >*)0), PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED )
+ };
+
+ static const Sequence< Property > seqPropertys( pPropertys, PROPERTY_COUNT );
+
+ return seqPropertys ;
+}
+
+} // namespace unocontrols
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/UnoControls/source/controls/makefile.mk b/UnoControls/source/controls/makefile.mk
new file mode 100644
index 000000000000..20314ea8e321
--- /dev/null
+++ b/UnoControls/source/controls/makefile.mk
@@ -0,0 +1,49 @@
+#*************************************************************************
+#
+# 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=controls
+ENABLE_EXCEPTIONS=TRUE
+.IF "$(L10N_framework)"==""
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+SLOFILES=\
+ $(SLO)$/progressbar.obj \
+ $(SLO)$/framecontrol.obj \
+ $(SLO)$/progressmonitor.obj \
+ $(SLO)$/OConnectionPointHelper.obj \
+ $(SLO)$/OConnectionPointContainerHelper.obj \
+ $(SLO)$/statusindicator.obj
+
+# --- Targets ------------------------------------------------------
+.ENDIF # L10N_framework
+
+.INCLUDE : target.mk
diff --git a/UnoControls/source/controls/progressbar.cxx b/UnoControls/source/controls/progressbar.cxx
new file mode 100644
index 000000000000..f1054089040d
--- /dev/null
+++ b/UnoControls/source/controls/progressbar.cxx
@@ -0,0 +1,494 @@
+/* -*- 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 "progressbar.hxx"
+
+//____________________________________________________________________________________________________________
+// includes of other projects
+//____________________________________________________________________________________________________________
+#include <com/sun/star/awt/GradientStyle.hpp>
+#include <com/sun/star/awt/RasterOperation.hpp>
+#include <com/sun/star/awt/Gradient.hpp>
+#include <com/sun/star/awt/XGraphics.hpp>
+#include <tools/debug.hxx>
+#include <cppuhelper/typeprovider.hxx>
+
+#include <math.h>
+#include <limits.h>
+
+//____________________________________________________________________________________________________________
+// includes of my project
+//____________________________________________________________________________________________________________
+
+//____________________________________________________________________________________________________________
+// namespace
+//____________________________________________________________________________________________________________
+
+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{
+
+//____________________________________________________________________________________________________________
+// construct/destruct
+//____________________________________________________________________________________________________________
+
+ProgressBar::ProgressBar( const Reference< XMultiServiceFactory >& xFactory )
+ : BaseControl ( xFactory )
+ , m_bHorizontal ( PROGRESSBAR_DEFAULT_HORIZONTAL )
+ , m_aBlockSize ( PROGRESSBAR_DEFAULT_BLOCKDIMENSION )
+ , m_nForegroundColor ( PROGRESSBAR_DEFAULT_FOREGROUNDCOLOR )
+ , m_nBackgroundColor ( PROGRESSBAR_DEFAULT_BACKGROUNDCOLOR )
+ , m_nMinRange ( PROGRESSBAR_DEFAULT_MINRANGE )
+ , m_nMaxRange ( PROGRESSBAR_DEFAULT_MAXRANGE )
+ , m_nBlockValue ( PROGRESSBAR_DEFAULT_BLOCKVALUE )
+ , m_nValue ( PROGRESSBAR_DEFAULT_VALUE )
+{
+}
+
+ProgressBar::~ProgressBar()
+{
+}
+
+//____________________________________________________________________________________________________________
+// XInterface
+//____________________________________________________________________________________________________________
+
+Any SAL_CALL ProgressBar::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() )
+ {
+ // 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 ;
+}
+
+//____________________________________________________________________________________________________________
+// XInterface
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressBar::acquire() throw()
+{
+ // Attention:
+ // Don't use mutex or guard in this method!!! Is a method of XInterface.
+
+ // Forward to baseclass
+ BaseControl::acquire();
+}
+
+//____________________________________________________________________________________________________________
+// XInterface
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressBar::release() throw()
+{
+ // Attention:
+ // Don't use mutex or guard in this method!!! Is a method of XInterface.
+
+ // Forward to baseclass
+ BaseControl::release();
+}
+
+//____________________________________________________________________________________________________________
+// XTypeProvider
+//____________________________________________________________________________________________________________
+
+Sequence< Type > SAL_CALL ProgressBar::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< XProgressBar >*) NULL ) ,
+ BaseControl::getTypes()
+ );
+ // ... and set his address to static pointer!
+ pTypeCollection = &aTypeCollection ;
+ }
+ }
+
+ return pTypeCollection->getTypes();
+}
+
+//____________________________________________________________________________________________________________
+// XAggregation
+//____________________________________________________________________________________________________________
+
+Any SAL_CALL ProgressBar::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< XProgressBar* > ( this )
+ )
+ );
+
+ // If searched interface not supported by this class ...
+ if ( aReturn.hasValue() == sal_False )
+ {
+ // ... ask baseclasses.
+ aReturn = BaseControl::queryAggregation( aType );
+ }
+
+ return aReturn ;
+}
+
+//____________________________________________________________________________________________________________
+// XProgressBar
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressBar::setForegroundColor( sal_Int32 nColor ) throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard (m_aMutex) ;
+
+ // Safe color for later use.
+ m_nForegroundColor = nColor ;
+
+ // Repaint control
+ impl_paint ( 0, 0, impl_getGraphicsPeer() ) ;
+}
+
+//____________________________________________________________________________________________________________
+// XProgressBar
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressBar::setBackgroundColor ( sal_Int32 nColor ) throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard (m_aMutex) ;
+
+ // Safe color for later use.
+ m_nBackgroundColor = nColor ;
+
+ // Repaint control
+ impl_paint ( 0, 0, impl_getGraphicsPeer() ) ;
+}
+
+//____________________________________________________________________________________________________________
+// XProgressBar
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressBar::setValue ( sal_Int32 nValue ) throw( RuntimeException )
+{
+ // This method is defined for follow things:
+ // 1) Values >= _nMinRange
+ // 2) Values <= _nMaxRange
+
+ // Ready for multithreading
+ MutexGuard aGuard (m_aMutex) ;
+
+ // save impossible cases
+ // This method is only defined for valid values
+ DBG_ASSERT ( (( nValue >= m_nMinRange ) && ( nValue <= m_nMaxRange )), "ProgressBar::setValue()\nNot valid value.\n" ) ;
+
+ // If new value not valid ... do nothing in release version!
+ if (
+ ( nValue >= m_nMinRange ) &&
+ ( nValue <= m_nMaxRange )
+ )
+ {
+ // New value is ok => save this
+ m_nValue = nValue ;
+
+ // Repaint to display changes
+ impl_paint ( 0, 0, impl_getGraphicsPeer() ) ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// XProgressBar
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressBar::setRange ( sal_Int32 nMin, sal_Int32 nMax ) throw( RuntimeException )
+{
+ // This method is defined for follow things:
+ // 1) All values of sal_Int32
+ // 2) Min < Max
+ // 3) Min > Max
+
+ // save impossible cases
+ // This method is only defined for valid values
+ // If you ignore this, the release version wil produce an error "division by zero" in "ProgressBar::setValue()"!
+ DBG_ASSERT ( ( nMin != nMax ) , "ProgressBar::setRange()\nValues for MIN and MAX are the same. This is not allowed!\n" ) ;
+
+ // Ready for multithreading
+ MutexGuard aGuard (m_aMutex) ;
+
+ // control the values for min and max
+ if ( nMin < nMax )
+ {
+ // Take correct Min and Max
+ m_nMinRange = nMin ;
+ m_nMaxRange = nMax ;
+ }
+ else
+ {
+ // Change Min and Max automaticly
+ m_nMinRange = nMax ;
+ m_nMaxRange = nMin ;
+ }
+
+ // assure that m_nValue is within the range
+ if (!(m_nMinRange < m_nValue && m_nValue < m_nMaxRange))
+ m_nValue = m_nMinRange;
+
+ impl_recalcRange () ;
+
+ // Do not repaint the control at this place!!!
+ // An old "m_nValue" is set and can not be correct for this new range.
+ // Next call of "ProgressBar::setValue()" do this.
+}
+
+//____________________________________________________________________________________________________________
+// XProgressBar
+//____________________________________________________________________________________________________________
+
+sal_Int32 SAL_CALL ProgressBar::getValue () throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard (m_aMutex) ;
+
+ return ( m_nValue ) ;
+}
+
+//____________________________________________________________________________________________________________
+// XWindow
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressBar::setPosSize (
+ sal_Int32 nX,
+ sal_Int32 nY,
+ sal_Int32 nWidth,
+ sal_Int32 nHeight,
+ sal_Int16 nFlags
+) throw( RuntimeException )
+{
+ // Take old size BEFORE you set the new values at baseclass!
+ // You will control changes. At the other way, the values are the same!
+ Rectangle aBasePosSize = getPosSize () ;
+ BaseControl::setPosSize (nX, nY, nWidth, nHeight, nFlags) ;
+
+ // Do only, if size has changed.
+ if (
+ ( nWidth != aBasePosSize.Width ) ||
+ ( nHeight != aBasePosSize.Height )
+ )
+ {
+ impl_recalcRange ( ) ;
+ impl_paint ( 0, 0, impl_getGraphicsPeer () ) ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// XControl
+//____________________________________________________________________________________________________________
+
+sal_Bool SAL_CALL ProgressBar::setModel( const Reference< XControlModel >& /*xModel*/ ) throw( RuntimeException )
+{
+ // A model is not possible for this control.
+ return sal_False ;
+}
+
+//____________________________________________________________________________________________________________
+// XControl
+//____________________________________________________________________________________________________________
+
+Reference< XControlModel > SAL_CALL ProgressBar::getModel() throw( RuntimeException )
+{
+ // A model is not possible for this control.
+ return Reference< XControlModel >();
+}
+
+//____________________________________________________________________________________________________________
+// impl but public method to register service
+//____________________________________________________________________________________________________________
+
+const Sequence< OUString > ProgressBar::impl_getStaticSupportedServiceNames()
+{
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ Sequence< OUString > seqServiceNames( 1 );
+ seqServiceNames.getArray() [0] = OUString(RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_PROGRESSBAR ));
+ return seqServiceNames ;
+}
+
+//____________________________________________________________________________________________________________
+// impl but public method to register service
+//____________________________________________________________________________________________________________
+
+const OUString ProgressBar::impl_getStaticImplementationName()
+{
+ return OUString(RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATIONNAME_PROGRESSBAR ));
+}
+
+//____________________________________________________________________________________________________________
+// protected method
+//____________________________________________________________________________________________________________
+
+void ProgressBar::impl_paint ( sal_Int32 nX, sal_Int32 nY, const Reference< XGraphics > & rGraphics )
+{
+ // save impossible cases
+ DBG_ASSERT ( rGraphics.is(), "ProgressBar::paint()\nCalled with invalid Reference< XGraphics > ." ) ;
+
+ // This paint method ist not buffered !!
+ // Every request paint the completely control. ( but only, if peer exist )
+ if ( rGraphics.is () )
+ {
+ MutexGuard aGuard (m_aMutex) ;
+
+ // Clear background
+ // (same color for line and fill)
+ rGraphics->setFillColor ( m_nBackgroundColor ) ;
+ rGraphics->setLineColor ( m_nBackgroundColor ) ;
+ rGraphics->drawRect ( nX, nY, impl_getWidth(), impl_getHeight() ) ;
+
+ // same color for line and fill for blocks
+ rGraphics->setFillColor ( m_nForegroundColor ) ;
+ rGraphics->setLineColor ( m_nForegroundColor ) ;
+
+ sal_Int32 nBlockStart = 0 ; // = left site of new block
+ sal_Int32 nBlockCount = m_nBlockValue!=0.00 ? (sal_Int32)((m_nValue-m_nMinRange)/m_nBlockValue) : 0 ; // = number of next block
+
+ // Draw horizontal progressbar
+ // decision in "recalcRange()"
+ if (m_bHorizontal)
+ {
+ // Step to left side of window
+ nBlockStart = nX ;
+
+ for ( sal_Int16 i=1; i<=nBlockCount; ++i )
+ {
+ // step free field
+ nBlockStart += PROGRESSBAR_FREESPACE ;
+ // paint block
+ rGraphics->drawRect (nBlockStart, nY+PROGRESSBAR_FREESPACE, m_aBlockSize.Width, m_aBlockSize.Height) ;
+ // step next free field
+ nBlockStart += m_aBlockSize.Width ;
+ }
+ }
+ // draw vertikal progressbar
+ // decision in "recalcRange()"
+ else
+ {
+ // step to bottom side of window
+ nBlockStart = nY+impl_getHeight() ;
+ nBlockStart -= m_aBlockSize.Height ;
+
+ for ( sal_Int16 i=1; i<=nBlockCount; ++i )
+ {
+ // step free field
+ nBlockStart -= PROGRESSBAR_FREESPACE ;
+ // paint block
+ rGraphics->drawRect (nX+PROGRESSBAR_FREESPACE, nBlockStart, m_aBlockSize.Width, m_aBlockSize.Height) ;
+ // step next free field
+ nBlockStart -= m_aBlockSize.Height;
+ }
+ }
+
+ // Paint shadow border around the progressbar
+ rGraphics->setLineColor ( PROGRESSBAR_LINECOLOR_SHADOW ) ;
+ rGraphics->drawLine ( nX, nY, impl_getWidth(), nY ) ;
+ rGraphics->drawLine ( nX, nY, nX , impl_getHeight() ) ;
+
+ rGraphics->setLineColor ( PROGRESSBAR_LINECOLOR_BRIGHT ) ;
+ rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, impl_getWidth()-1, nY ) ;
+ rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, nX , impl_getHeight()-1 ) ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// protected method
+//____________________________________________________________________________________________________________
+
+void ProgressBar::impl_recalcRange ()
+{
+ MutexGuard aGuard (m_aMutex) ;
+
+ sal_Int32 nWindowWidth = impl_getWidth() ;
+ sal_Int32 nWindowHeight = impl_getHeight() ;
+ double fBlockHeight ;
+ double fBlockWidth ;
+ double fMaxBlocks ;
+
+ if( nWindowWidth > nWindowHeight )
+ {
+ m_bHorizontal = sal_True ;
+ fBlockHeight = (nWindowHeight-(2*PROGRESSBAR_FREESPACE)) ;
+ fBlockWidth = fBlockHeight ;
+ fMaxBlocks = nWindowWidth/(fBlockWidth+PROGRESSBAR_FREESPACE);
+ }
+ else
+ {
+ m_bHorizontal = sal_False ;
+ fBlockWidth = (nWindowWidth-(2*PROGRESSBAR_FREESPACE)) ;
+ fBlockHeight = fBlockWidth ;
+ fMaxBlocks = nWindowHeight/(fBlockHeight+PROGRESSBAR_FREESPACE);
+ }
+
+ double fRange = m_nMaxRange-m_nMinRange ;
+ double fBlockValue = fRange/fMaxBlocks ;
+
+ m_nBlockValue = fBlockValue ;
+ m_aBlockSize.Height = (sal_Int32)fBlockHeight;
+ m_aBlockSize.Width = (sal_Int32)fBlockWidth ;
+}
+
+} // namespace unocontrols
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/UnoControls/source/controls/progressmonitor.cxx b/UnoControls/source/controls/progressmonitor.cxx
new file mode 100644
index 000000000000..e039ff33925c
--- /dev/null
+++ b/UnoControls/source/controls/progressmonitor.cxx
@@ -0,0 +1,1070 @@
+/* -*- 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 "progressmonitor.hxx"
+
+//____________________________________________________________________________________________________________
+// includes of other projects
+//____________________________________________________________________________________________________________
+#include <com/sun/star/awt/GradientStyle.hpp>
+#include <com/sun/star/awt/RasterOperation.hpp>
+#include <com/sun/star/awt/Gradient.hpp>
+#include <com/sun/star/awt/XGraphics.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <tools/debug.hxx>
+#include <tools/solar.h>
+#include <algorithm>
+//____________________________________________________________________________________________________________
+// includes of my project
+//____________________________________________________________________________________________________________
+#include "progressbar.hxx"
+
+//____________________________________________________________________________________________________________
+// namespace
+//____________________________________________________________________________________________________________
+
+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 ::std::vector;
+using ::std::find;
+
+namespace unocontrols{
+
+//____________________________________________________________________________________________________________
+// construct/destruct
+//____________________________________________________________________________________________________________
+
+ProgressMonitor::ProgressMonitor( const Reference< XMultiServiceFactory >& xFactory )
+ : BaseContainerControl ( xFactory )
+{
+ // Its not allowed to work with member in this method (refcounter !!!)
+ // But with a HACK (++refcount) its "OK" :-(
+ ++m_refCount ;
+
+ // Create instances for fixedtext, button and progress ...
+ m_xTopic_Top = Reference< XFixedText > ( xFactory->createInstance ( OUString(RTL_CONSTASCII_USTRINGPARAM( FIXEDTEXT_SERVICENAME )) ), UNO_QUERY ) ;
+ m_xText_Top = Reference< XFixedText > ( xFactory->createInstance ( OUString(RTL_CONSTASCII_USTRINGPARAM( FIXEDTEXT_SERVICENAME )) ), UNO_QUERY ) ;
+ m_xTopic_Bottom = Reference< XFixedText > ( xFactory->createInstance ( OUString(RTL_CONSTASCII_USTRINGPARAM( FIXEDTEXT_SERVICENAME )) ), UNO_QUERY ) ;
+ m_xText_Bottom = Reference< XFixedText > ( xFactory->createInstance ( OUString(RTL_CONSTASCII_USTRINGPARAM( FIXEDTEXT_SERVICENAME )) ), UNO_QUERY ) ;
+ m_xButton = Reference< XButton > ( xFactory->createInstance ( OUString(RTL_CONSTASCII_USTRINGPARAM( BUTTON_SERVICENAME )) ), UNO_QUERY ) ;
+ m_xProgressBar = Reference< XProgressBar > ( xFactory->createInstance ( OUString(RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_PROGRESSBAR )) ), UNO_QUERY ) ;
+
+ // ... cast controls to Reference< XControl > (for "setModel"!) ...
+ Reference< XControl > xRef_Topic_Top ( m_xTopic_Top , UNO_QUERY ) ;
+ Reference< XControl > xRef_Text_Top ( m_xText_Top , UNO_QUERY ) ;
+ Reference< XControl > xRef_Topic_Bottom ( m_xTopic_Bottom , UNO_QUERY ) ;
+ Reference< XControl > xRef_Text_Bottom ( m_xText_Bottom , UNO_QUERY ) ;
+ Reference< XControl > xRef_Button ( m_xButton , UNO_QUERY ) ;
+ Reference< XControl > xRef_ProgressBar ( m_xProgressBar , UNO_QUERY ) ;
+
+ // ... set models ...
+ xRef_Topic_Top->setModel ( Reference< XControlModel > ( xFactory->createInstance ( OUString(RTL_CONSTASCII_USTRINGPARAM( FIXEDTEXT_MODELNAME )) ), UNO_QUERY ) ) ;
+ xRef_Text_Top->setModel ( Reference< XControlModel > ( xFactory->createInstance ( OUString(RTL_CONSTASCII_USTRINGPARAM( FIXEDTEXT_MODELNAME )) ), UNO_QUERY ) ) ;
+ xRef_Topic_Bottom->setModel ( Reference< XControlModel > ( xFactory->createInstance ( OUString(RTL_CONSTASCII_USTRINGPARAM( FIXEDTEXT_MODELNAME )) ), UNO_QUERY ) ) ;
+ xRef_Text_Bottom->setModel ( Reference< XControlModel > ( xFactory->createInstance ( OUString(RTL_CONSTASCII_USTRINGPARAM( FIXEDTEXT_MODELNAME )) ), UNO_QUERY ) ) ;
+ xRef_Button->setModel ( Reference< XControlModel > ( xFactory->createInstance ( OUString(RTL_CONSTASCII_USTRINGPARAM( BUTTON_MODELNAME )) ), UNO_QUERY ) ) ;
+ // ProgressBar has no model !!!
+
+ // ... and add controls to basecontainercontrol!
+ addControl ( OUString(RTL_CONSTASCII_USTRINGPARAM( CONTROLNAME_TEXT )) , xRef_Topic_Top ) ;
+ addControl ( OUString(RTL_CONSTASCII_USTRINGPARAM( CONTROLNAME_TEXT )) , xRef_Text_Top ) ;
+ addControl ( OUString(RTL_CONSTASCII_USTRINGPARAM( CONTROLNAME_TEXT )) , xRef_Topic_Bottom ) ;
+ addControl ( OUString(RTL_CONSTASCII_USTRINGPARAM( CONTROLNAME_TEXT )) , xRef_Text_Bottom ) ;
+ addControl ( OUString(RTL_CONSTASCII_USTRINGPARAM( CONTROLNAME_BUTTON )) , xRef_Button ) ;
+ addControl ( OUString(RTL_CONSTASCII_USTRINGPARAM( CONTROLNAME_PROGRESSBAR )) , xRef_ProgressBar ) ;
+
+ // FixedText make it automaticly visible by himself ... but not the progressbar !!!
+ // it must be set explicitly
+ Reference< XWindow > xWindowRef_ProgressBar( m_xProgressBar, UNO_QUERY );
+ xWindowRef_ProgressBar->setVisible( sal_True );
+
+ // Reset to defaults !!!
+ // (progressbar take automaticly its own defaults)
+ m_xButton->setLabel ( OUString(RTL_CONSTASCII_USTRINGPARAM( DEFAULT_BUTTONLABEL )) ) ;
+ m_xTopic_Top->setText ( OUString(RTL_CONSTASCII_USTRINGPARAM( PROGRESSMONITOR_DEFAULT_TOPIC )) ) ;
+ m_xText_Top->setText ( OUString(RTL_CONSTASCII_USTRINGPARAM( PROGRESSMONITOR_DEFAULT_TEXT )) ) ;
+ m_xTopic_Bottom->setText ( OUString(RTL_CONSTASCII_USTRINGPARAM( PROGRESSMONITOR_DEFAULT_TOPIC )) ) ;
+ m_xText_Bottom->setText ( OUString(RTL_CONSTASCII_USTRINGPARAM( PROGRESSMONITOR_DEFAULT_TEXT )) ) ;
+
+ --m_refCount ;
+}
+
+ProgressMonitor::~ProgressMonitor()
+{
+ impl_cleanMemory () ;
+}
+
+//____________________________________________________________________________________________________________
+// XInterface
+//____________________________________________________________________________________________________________
+
+Any SAL_CALL ProgressMonitor::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 = BaseContainerControl::impl_getDelegator();
+ if ( xDel.is() )
+ {
+ // 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 ;
+}
+
+//____________________________________________________________________________________________________________
+// XInterface
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressMonitor::acquire() throw()
+{
+ // Attention:
+ // Don't use mutex or guard in this method!!! Is a method of XInterface.
+
+ // Forward to baseclass
+ BaseControl::acquire();
+}
+
+//____________________________________________________________________________________________________________
+// XInterface
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressMonitor::release() throw()
+{
+ // Attention:
+ // Don't use mutex or guard in this method!!! Is a method of XInterface.
+
+ // Forward to baseclass
+ BaseControl::release();
+}
+
+//____________________________________________________________________________________________________________
+// XTypeProvider
+//____________________________________________________________________________________________________________
+
+Sequence< Type > SAL_CALL ProgressMonitor::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< XLayoutConstrains >*)NULL ) ,
+ ::getCppuType(( const Reference< XButton >*)NULL ) ,
+ ::getCppuType(( const Reference< XProgressMonitor >*)NULL ) ,
+ BaseContainerControl::getTypes()
+ );
+ // ... and set his address to static pointer!
+ pTypeCollection = &aTypeCollection ;
+ }
+ }
+
+ return pTypeCollection->getTypes();
+}
+
+//____________________________________________________________________________________________________________
+// XAggregation
+//____________________________________________________________________________________________________________
+
+Any SAL_CALL ProgressMonitor::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< XLayoutConstrains* > ( this ) ,
+ static_cast< XButton* > ( this ) ,
+ static_cast< XProgressMonitor* > ( this )
+ )
+ );
+
+ // If searched interface not supported by this class ...
+ if ( aReturn.hasValue() == sal_False )
+ {
+ // ... ask baseclasses.
+ aReturn = BaseControl::queryAggregation( aType );
+ }
+
+ return aReturn ;
+}
+
+//____________________________________________________________________________________________________________
+// XProgressMonitor
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressMonitor::addText(
+ const OUString& rTopic,
+ const OUString& rText,
+ sal_Bool bbeforeProgress
+) throw( RuntimeException )
+{
+ // Safe impossible cases
+ // Check valid call of this method.
+ DBG_ASSERT ( impl_debug_checkParameter ( rTopic, rText, bbeforeProgress ) , "ProgressMonitor::addText()\nCall without valid parameters!\n") ;
+ DBG_ASSERT ( !(impl_searchTopic ( rTopic, bbeforeProgress ) != NULL ) , "ProgresMonitor::addText()\nThe text already exist.\n" ) ;
+
+ // Do nothing (in Release), if topic already exist.
+ if ( impl_searchTopic ( rTopic, bbeforeProgress ) != NULL )
+ {
+ return ;
+ }
+
+ // Else ... take memory for new item ...
+ IMPL_TextlistItem* pTextItem = new IMPL_TextlistItem ;
+
+ if ( pTextItem != NULL )
+ {
+ // Set values ...
+ pTextItem->sTopic = rTopic ;
+ pTextItem->sText = rText ;
+
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex ) ;
+
+ // ... and insert it in right list.
+ if ( bbeforeProgress == sal_True )
+ {
+ maTextlist_Top.push_back( pTextItem );
+ }
+ else
+ {
+ maTextlist_Bottom.push_back( pTextItem );
+ }
+ }
+
+ // ... update window
+ impl_rebuildFixedText () ;
+ impl_recalcLayout () ;
+}
+
+//____________________________________________________________________________________________________________
+// XProgressMonitor
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressMonitor::removeText ( const OUString& rTopic, sal_Bool bbeforeProgress ) throw( RuntimeException )
+{
+ // Safe impossible cases
+ // Check valid call of this method.
+ DBG_ASSERT ( impl_debug_checkParameter ( rTopic, bbeforeProgress ), "ProgressMonitor::removeText()\nCall without valid parameters!\n" ) ;
+
+ // Search the topic ...
+ IMPL_TextlistItem* pSearchItem = impl_searchTopic ( rTopic, bbeforeProgress ) ;
+
+ if ( pSearchItem != NULL )
+ {
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex ) ;
+
+ // ... delete item from right list ...
+ if ( bbeforeProgress == sal_True )
+ {
+ vector< IMPL_TextlistItem* >::iterator
+ itr = find( maTextlist_Top.begin(), maTextlist_Top.end(), pSearchItem );
+ if (itr != maTextlist_Top.end())
+ maTextlist_Top.erase(itr);
+ }
+ else
+ {
+ vector< IMPL_TextlistItem* >::iterator
+ itr = find( maTextlist_Bottom.begin(), maTextlist_Bottom.end(), pSearchItem );
+ if (itr != maTextlist_Bottom.end())
+ maTextlist_Bottom.erase(itr);
+ }
+
+ delete pSearchItem ;
+
+ // ... and update window.
+ impl_rebuildFixedText () ;
+ impl_recalcLayout () ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// XProgressMonitor
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressMonitor::updateText (
+ const OUString& rTopic,
+ const OUString& rText,
+ sal_Bool bbeforeProgress
+) throw( RuntimeException )
+{
+ // Safe impossible cases
+ // Check valid call of this method.
+ DBG_ASSERT ( impl_debug_checkParameter ( rTopic, rText, bbeforeProgress ), "ProgressMonitor::updateText()\nCall without valid parameters!\n" ) ;
+
+ // Search topic ...
+ IMPL_TextlistItem* pSearchItem = impl_searchTopic ( rTopic, bbeforeProgress ) ;
+
+ if ( pSearchItem != NULL )
+ {
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex ) ;
+
+ // ... update text ...
+ pSearchItem->sText = rText ;
+
+ // ... and update window.
+ impl_rebuildFixedText () ;
+ impl_recalcLayout () ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// XProgressBar
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressMonitor::setForegroundColor ( sal_Int32 nColor ) throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex ) ;
+
+ if ( m_xProgressBar.is () )
+ {
+ m_xProgressBar->setForegroundColor ( nColor ) ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// XProgressBar
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressMonitor::setBackgroundColor ( sal_Int32 nColor ) throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex ) ;
+
+ if ( m_xProgressBar.is () )
+ {
+ m_xProgressBar->setBackgroundColor ( nColor ) ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// XProgressBar
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressMonitor::setValue ( sal_Int32 nValue ) throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex ) ;
+
+ if ( m_xProgressBar.is () )
+ {
+ m_xProgressBar->setValue ( nValue ) ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// XProgressBar
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressMonitor::setRange ( sal_Int32 nMin, sal_Int32 nMax ) throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex ) ;
+
+ if ( m_xProgressBar.is () )
+ {
+ m_xProgressBar->setRange ( nMin, nMax ) ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// XProgressBar
+//____________________________________________________________________________________________________________
+
+sal_Int32 SAL_CALL ProgressMonitor::getValue () throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex ) ;
+
+ if (m_xProgressBar.is())
+ {
+ return m_xProgressBar->getValue () ;
+ }
+
+ return 0 ;
+}
+
+//____________________________________________________________________________________________________________
+// XButton
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressMonitor::addActionListener ( const Reference< XActionListener > & rListener ) throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex ) ;
+
+ if ( m_xButton.is () )
+ {
+ m_xButton->addActionListener ( rListener ) ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// XButton
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressMonitor::removeActionListener ( const Reference< XActionListener > & rListener ) throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex ) ;
+
+ if ( m_xButton.is () )
+ {
+ m_xButton->removeActionListener ( rListener ) ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// XButton
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressMonitor::setLabel ( const OUString& rLabel ) throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex ) ;
+
+ if ( m_xButton.is () )
+ {
+ m_xButton->setLabel ( rLabel ) ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// XButton
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressMonitor::setActionCommand ( const OUString& rCommand ) throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex ) ;
+
+ if ( m_xButton.is () )
+ {
+ m_xButton->setActionCommand ( rCommand ) ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// XLayoutConstrains
+//____________________________________________________________________________________________________________
+
+Size SAL_CALL ProgressMonitor::getMinimumSize () throw( RuntimeException )
+{
+ return Size (PROGRESSMONITOR_DEFAULT_WIDTH, PROGRESSMONITOR_DEFAULT_HEIGHT) ;
+}
+
+//____________________________________________________________________________________________________________
+// XLayoutConstrains
+//____________________________________________________________________________________________________________
+
+Size SAL_CALL ProgressMonitor::getPreferredSize () throw( RuntimeException )
+{
+ // Ready for multithreading
+ ClearableMutexGuard aGuard ( m_aMutex ) ;
+
+ // get information about required place of child controls
+ Reference< XLayoutConstrains > xTopicLayout_Top ( m_xTopic_Top , UNO_QUERY ) ;
+ Reference< XLayoutConstrains > xTopicLayout_Bottom ( m_xTopic_Bottom , UNO_QUERY ) ;
+ Reference< XLayoutConstrains > xButtonLayout ( m_xButton , UNO_QUERY ) ;
+ Reference< XWindow > xProgressBarWindow ( m_xProgressBar , UNO_QUERY ) ;
+
+ Size aTopicSize_Top = xTopicLayout_Top->getPreferredSize ();
+ Size aTopicSize_Bottom = xTopicLayout_Bottom->getPreferredSize ();
+ Size aButtonSize = xButtonLayout->getPreferredSize ();
+ Rectangle aTempRectangle = xProgressBarWindow->getPosSize ();
+ Size aProgressBarSize = Size( aTempRectangle.Width, aTempRectangle.Height );
+
+ aGuard.clear () ;
+
+ // calc preferred size of progressmonitor
+ sal_Int32 nWidth = 0 ;
+ sal_Int32 nHeight = 0 ;
+
+ nWidth = 3 * PROGRESSMONITOR_FREEBORDER ;
+ nWidth += aProgressBarSize.Width ;
+
+ nHeight = 6 * PROGRESSMONITOR_FREEBORDER ;
+ nHeight += aTopicSize_Top.Height ;
+ nHeight += aProgressBarSize.Height ;
+ nHeight += aTopicSize_Bottom.Height;
+ nHeight += 2 ; // 1 for black line, 1 for white line = 3D-Line!
+ nHeight += aButtonSize.Height ;
+
+ // norm to minimum
+ if ( nWidth < PROGRESSMONITOR_DEFAULT_WIDTH )
+ {
+ nWidth = PROGRESSMONITOR_DEFAULT_WIDTH ;
+ }
+ if ( nHeight < PROGRESSMONITOR_DEFAULT_HEIGHT )
+ {
+ nHeight = PROGRESSMONITOR_DEFAULT_HEIGHT ;
+ }
+
+ // return to caller
+ return Size ( nWidth, nHeight ) ;
+}
+
+//____________________________________________________________________________________________________________
+// XLayoutConstrains
+//____________________________________________________________________________________________________________
+
+Size SAL_CALL ProgressMonitor::calcAdjustedSize ( const Size& /*rNewSize*/ ) throw( RuntimeException )
+{
+ return getPreferredSize () ;
+}
+
+//____________________________________________________________________________________________________________
+// XControl
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressMonitor::createPeer ( const Reference< XToolkit > & rToolkit, const Reference< XWindowPeer > & rParent ) throw( RuntimeException )
+{
+ if (!getPeer().is())
+ {
+ BaseContainerControl::createPeer ( rToolkit, rParent ) ;
+
+ // If user forget to call "setPosSize()", we have still a correct size.
+ // And a "MinimumSize" IS A "MinimumSize"!
+ // We change not the position of control at this point.
+ Size aDefaultSize = getMinimumSize () ;
+ setPosSize ( 0, 0, aDefaultSize.Width, aDefaultSize.Height, PosSize::SIZE ) ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// XControl
+//____________________________________________________________________________________________________________
+
+sal_Bool SAL_CALL ProgressMonitor::setModel ( const Reference< XControlModel > & /*rModel*/ ) throw( RuntimeException )
+{
+ // We have no model.
+ return sal_False ;
+}
+
+//____________________________________________________________________________________________________________
+// XControl
+//____________________________________________________________________________________________________________
+
+Reference< XControlModel > SAL_CALL ProgressMonitor::getModel () throw( RuntimeException )
+{
+ // We have no model.
+ // return (XControlModel*)this ;
+ return Reference< XControlModel > () ;
+}
+
+//____________________________________________________________________________________________________________
+// XComponent
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressMonitor::dispose () throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex ) ;
+
+ // "removeControl()" control the state of a reference
+ Reference< XControl > xRef_Topic_Top ( m_xTopic_Top , UNO_QUERY ) ;
+ Reference< XControl > xRef_Text_Top ( m_xText_Top , UNO_QUERY ) ;
+ Reference< XControl > xRef_Topic_Bottom ( m_xTopic_Bottom , UNO_QUERY ) ;
+ Reference< XControl > xRef_Text_Bottom ( m_xText_Bottom , UNO_QUERY ) ;
+ Reference< XControl > xRef_Button ( m_xButton , UNO_QUERY ) ;
+ Reference< XControl > xRef_ProgressBar ( m_xProgressBar , UNO_QUERY ) ;
+
+ removeControl ( xRef_Topic_Top ) ;
+ removeControl ( xRef_Text_Top ) ;
+ removeControl ( xRef_Topic_Bottom ) ;
+ removeControl ( xRef_Text_Bottom ) ;
+ removeControl ( xRef_Button ) ;
+ removeControl ( xRef_ProgressBar ) ;
+
+ // do'nt use "...->clear ()" or "... = XFixedText ()"
+ // when other hold a reference at this object !!!
+ xRef_Topic_Top->dispose () ;
+ xRef_Text_Top->dispose () ;
+ xRef_Topic_Bottom->dispose () ;
+ xRef_Text_Bottom->dispose () ;
+ xRef_Button->dispose () ;
+ xRef_ProgressBar->dispose () ;
+
+ BaseContainerControl::dispose () ;
+}
+
+//____________________________________________________________________________________________________________
+// XWindow
+//____________________________________________________________________________________________________________
+
+void SAL_CALL ProgressMonitor::setPosSize ( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nFlags ) throw( RuntimeException )
+{
+ Rectangle aBasePosSize = getPosSize () ;
+ BaseContainerControl::setPosSize (nX, nY, nWidth, nHeight, nFlags) ;
+
+ // if position or size changed
+ if (
+ ( nWidth != aBasePosSize.Width ) ||
+ ( nHeight != aBasePosSize.Height)
+ )
+ {
+ // calc new layout for controls
+ impl_recalcLayout () ;
+ // clear background (!)
+ // [Childs was repainted in "recalcLayout" by setPosSize() automaticly!]
+ getPeer()->invalidate(2);
+ // and repaint the control
+ impl_paint ( 0, 0, impl_getGraphicsPeer() ) ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// impl but public method to register service
+//____________________________________________________________________________________________________________
+
+const Sequence< OUString > ProgressMonitor::impl_getStaticSupportedServiceNames()
+{
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ Sequence< OUString > seqServiceNames( 1 );
+ seqServiceNames.getArray() [0] = OUString(RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_PROGRESSMONITOR ));
+ return seqServiceNames ;
+}
+
+//____________________________________________________________________________________________________________
+// impl but public method to register service
+//____________________________________________________________________________________________________________
+
+const OUString ProgressMonitor::impl_getStaticImplementationName()
+{
+ return OUString(RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATIONNAME_PROGRESSMONITOR ));
+}
+
+//____________________________________________________________________________________________________________
+// protected method
+//____________________________________________________________________________________________________________
+
+void ProgressMonitor::impl_paint ( sal_Int32 nX, sal_Int32 nY, const Reference< XGraphics > & rGraphics )
+{
+ if (rGraphics.is())
+ {
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex ) ;
+
+ // paint shadowed border around the progressmonitor
+ rGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_SHADOW ) ;
+ rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, impl_getWidth()-1, nY ) ;
+ rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, nX , impl_getHeight()-1 ) ;
+
+ rGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_BRIGHT ) ;
+ rGraphics->drawLine ( nX, nY, impl_getWidth(), nY ) ;
+ rGraphics->drawLine ( nX, nY, nX , impl_getHeight() ) ;
+
+ // Paint 3D-line
+ rGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_SHADOW ) ;
+ rGraphics->drawLine ( m_a3DLine.X, m_a3DLine.Y, m_a3DLine.X+m_a3DLine.Width, m_a3DLine.Y ) ;
+
+ rGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_BRIGHT ) ;
+ rGraphics->drawLine ( m_a3DLine.X, m_a3DLine.Y+1, m_a3DLine.X+m_a3DLine.Width, m_a3DLine.Y+1 ) ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// private method
+//____________________________________________________________________________________________________________
+
+void ProgressMonitor::impl_recalcLayout ()
+{
+ sal_Int32 nX_Button ;
+ sal_Int32 nY_Button ;
+ sal_Int32 nWidth_Button ;
+ sal_Int32 nHeight_Button ;
+
+ sal_Int32 nX_ProgressBar ;
+ sal_Int32 nY_ProgressBar ;
+ sal_Int32 nWidth_ProgressBar ;
+ sal_Int32 nHeight_ProgressBar ;
+
+ sal_Int32 nX_Text_Top ;
+ sal_Int32 nY_Text_Top ;
+ sal_Int32 nWidth_Text_Top ;
+ sal_Int32 nHeight_Text_Top ;
+
+ sal_Int32 nX_Topic_Top ;
+ sal_Int32 nY_Topic_Top ;
+ sal_Int32 nWidth_Topic_Top ;
+ sal_Int32 nHeight_Topic_Top ;
+
+ sal_Int32 nX_Text_Bottom ;
+ sal_Int32 nY_Text_Bottom ;
+ sal_Int32 nWidth_Text_Bottom ;
+ sal_Int32 nHeight_Text_Bottom ;
+
+ sal_Int32 nX_Topic_Bottom ;
+ sal_Int32 nY_Topic_Bottom ;
+ sal_Int32 nWidth_Topic_Bottom ;
+ sal_Int32 nHeight_Topic_Bottom ;
+
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex ) ;
+
+ // get information about required place of child controls
+ Reference< XLayoutConstrains > xTopicLayout_Top ( m_xTopic_Top , UNO_QUERY ) ;
+ Reference< XLayoutConstrains > xTextLayout_Top ( m_xText_Top , UNO_QUERY ) ;
+ Reference< XLayoutConstrains > xTopicLayout_Bottom ( m_xTopic_Bottom , UNO_QUERY ) ;
+ Reference< XLayoutConstrains > xTextLayout_Bottom ( m_xText_Bottom , UNO_QUERY ) ;
+ Reference< XLayoutConstrains > xButtonLayout ( m_xButton , UNO_QUERY ) ;
+
+ Size aTopicSize_Top = xTopicLayout_Top->getPreferredSize () ;
+ Size aTextSize_Top = xTextLayout_Top->getPreferredSize () ;
+ Size aTopicSize_Bottom = xTopicLayout_Bottom->getPreferredSize () ;
+ Size aTextSize_Bottom = xTextLayout_Bottom->getPreferredSize () ;
+ Size aButtonSize = xButtonLayout->getPreferredSize () ;
+
+ // calc position and size of child controls
+ // Button has preferred size!
+ nWidth_Button = aButtonSize.Width ;
+ nHeight_Button = aButtonSize.Height ;
+
+ // Left column before progressbar has preferred size and fixed position.
+ // But "Width" is oriented on left column below progressbar to!!! "max(...)"
+ nX_Topic_Top = PROGRESSMONITOR_FREEBORDER ;
+ nY_Topic_Top = PROGRESSMONITOR_FREEBORDER ;
+ nWidth_Topic_Top = Max ( aTopicSize_Top.Width, aTopicSize_Bottom.Width ) ;
+ nHeight_Topic_Top = aTopicSize_Top.Height ;
+
+ // Right column before progressbar has relativ position to left column ...
+ // ... and a size as rest of dialog size!
+ nX_Text_Top = nX_Topic_Top+nWidth_Topic_Top+PROGRESSMONITOR_FREEBORDER;
+ nY_Text_Top = nY_Topic_Top ;
+ nWidth_Text_Top = Max ( aTextSize_Top.Width, aTextSize_Bottom.Width ) ;
+ // Fix size of this column to minimum!
+ sal_Int32 nSummaryWidth = nWidth_Text_Top+nWidth_Topic_Top+(3*PROGRESSMONITOR_FREEBORDER) ;
+ if ( nSummaryWidth < PROGRESSMONITOR_DEFAULT_WIDTH )
+ nWidth_Text_Top = PROGRESSMONITOR_DEFAULT_WIDTH-nWidth_Topic_Top-(3*PROGRESSMONITOR_FREEBORDER);
+ // Fix size of column to maximum!
+ if ( nSummaryWidth > impl_getWidth() )
+ nWidth_Text_Top = impl_getWidth()-nWidth_Topic_Top-(3*PROGRESSMONITOR_FREEBORDER) ;
+ nHeight_Text_Top = nHeight_Topic_Top ;
+
+ // Position of progressbar is relativ to columns before.
+ // Progressbar.Width = Dialog.Width !!!
+ // Progressbar.Height = Button.Height
+ nX_ProgressBar = nX_Topic_Top ;
+ nY_ProgressBar = nY_Topic_Top+nHeight_Topic_Top+PROGRESSMONITOR_FREEBORDER ;
+ nWidth_ProgressBar = PROGRESSMONITOR_FREEBORDER+nWidth_Topic_Top+nWidth_Text_Top ;
+ nHeight_ProgressBar = nHeight_Button ;
+
+ // Oriented by left column before progressbar.
+ nX_Topic_Bottom = nX_Topic_Top ;
+ nY_Topic_Bottom = nY_ProgressBar+nHeight_ProgressBar+PROGRESSMONITOR_FREEBORDER ;
+ nWidth_Topic_Bottom = nWidth_Topic_Top ;
+ nHeight_Topic_Bottom = aTopicSize_Bottom.Height ;
+
+ // Oriented by right column before progressbar.
+ nX_Text_Bottom = nX_Topic_Bottom+nWidth_Topic_Bottom+PROGRESSMONITOR_FREEBORDER ;
+ nY_Text_Bottom = nY_Topic_Bottom ;
+ nWidth_Text_Bottom = nWidth_Text_Top ;
+ nHeight_Text_Bottom = nHeight_Topic_Bottom ;
+
+ // Oriented by progressbar.
+ nX_Button = nX_ProgressBar+nWidth_ProgressBar-nWidth_Button ;
+ nY_Button = nY_Topic_Bottom+nHeight_Topic_Bottom+PROGRESSMONITOR_FREEBORDER ;
+
+ // Calc offsets to center controls
+ sal_Int32 nDx ;
+ sal_Int32 nDy ;
+
+ nDx = ( (2*PROGRESSMONITOR_FREEBORDER)+nWidth_ProgressBar ) ;
+ nDy = ( (6*PROGRESSMONITOR_FREEBORDER)+nHeight_Topic_Top+nHeight_ProgressBar+nHeight_Topic_Bottom+2+nHeight_Button ) ;
+
+ // At this point use original dialog size to center controls!
+ nDx = (impl_getWidth ()/2)-(nDx/2) ;
+ nDy = (impl_getHeight()/2)-(nDy/2) ;
+
+ if ( nDx<0 )
+ {
+ nDx=0 ;
+ }
+ if ( nDy<0 )
+ {
+ nDy=0 ;
+ }
+
+ // Set new position and size on all controls
+ Reference< XWindow > xRef_Topic_Top ( m_xTopic_Top , UNO_QUERY ) ;
+ Reference< XWindow > xRef_Text_Top ( m_xText_Top , UNO_QUERY ) ;
+ Reference< XWindow > xRef_Topic_Bottom ( m_xTopic_Bottom , UNO_QUERY ) ;
+ Reference< XWindow > xRef_Text_Bottom ( m_xText_Bottom , UNO_QUERY ) ;
+ Reference< XWindow > xRef_Button ( m_xButton , UNO_QUERY ) ;
+ Reference< XWindow > xRef_ProgressBar ( m_xProgressBar , UNO_QUERY ) ;
+
+ xRef_Topic_Top->setPosSize ( nDx+nX_Topic_Top , nDy+nY_Topic_Top , nWidth_Topic_Top , nHeight_Topic_Top , 15 ) ;
+ xRef_Text_Top->setPosSize ( nDx+nX_Text_Top , nDy+nY_Text_Top , nWidth_Text_Top , nHeight_Text_Top , 15 ) ;
+ xRef_Topic_Bottom->setPosSize ( nDx+nX_Topic_Bottom , nDy+nY_Topic_Bottom , nWidth_Topic_Bottom , nHeight_Topic_Bottom , 15 ) ;
+ xRef_Text_Bottom->setPosSize ( nDx+nX_Text_Bottom , nDy+nY_Text_Bottom , nWidth_Text_Bottom , nHeight_Text_Bottom , 15 ) ;
+ xRef_Button->setPosSize ( nDx+nX_Button , nDy+nY_Button , nWidth_Button , nHeight_Button , 15 ) ;
+ xRef_ProgressBar->setPosSize ( nDx+nX_ProgressBar , nDy+nY_ProgressBar , nWidth_ProgressBar , nHeight_ProgressBar , 15 ) ;
+
+ m_a3DLine.X = nDx+nX_Topic_Top ;
+ m_a3DLine.Y = nDy+nY_Topic_Bottom+nHeight_Topic_Bottom+(PROGRESSMONITOR_FREEBORDER/2) ;
+ m_a3DLine.Width = nWidth_ProgressBar ;
+ m_a3DLine.Height = nHeight_ProgressBar ;
+
+ // All childcontrols make an implicit repaint in setPosSize()!
+ // Make it also for this 3D-line ...
+ Reference< XGraphics > xGraphics = impl_getGraphicsPeer () ;
+
+ xGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_SHADOW ) ;
+ xGraphics->drawLine ( m_a3DLine.X, m_a3DLine.Y, m_a3DLine.X+m_a3DLine.Width, m_a3DLine.Y ) ;
+
+ xGraphics->setLineColor ( PROGRESSMONITOR_LINECOLOR_BRIGHT ) ;
+ xGraphics->drawLine ( m_a3DLine.X, m_a3DLine.Y+1, m_a3DLine.X+m_a3DLine.Width, m_a3DLine.Y+1 ) ;
+}
+
+//____________________________________________________________________________________________________________
+// private method
+//____________________________________________________________________________________________________________
+
+void ProgressMonitor::impl_rebuildFixedText ()
+{
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex ) ;
+
+ // Rebuild fixedtext before progress
+
+ // Rebuild left site of text
+ if (m_xTopic_Top.is())
+ {
+ OUString aCollectString ;
+
+ // Collect all topics from list and format text.
+ // "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!!
+ for ( size_t n = 0; n < maTextlist_Top.size(); ++n )
+ {
+ IMPL_TextlistItem* pSearchItem = maTextlist_Top[ n ];
+ aCollectString += pSearchItem->sTopic ;
+ aCollectString += OUString(RTL_CONSTASCII_USTRINGPARAM("\n")) ;
+ }
+ aCollectString += OUString(RTL_CONSTASCII_USTRINGPARAM("\0")) ; // It's better :-)
+
+ m_xTopic_Top->setText ( aCollectString ) ;
+ }
+
+ // Rebuild right site of text
+ if (m_xText_Top.is())
+ {
+ OUString aCollectString ;
+
+ // Collect all topics from list and format text.
+ // "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!!
+ for ( size_t n = 0; n < maTextlist_Top.size(); ++n )
+ {
+ IMPL_TextlistItem* pSearchItem = maTextlist_Top[ n ];
+ aCollectString += pSearchItem->sText ;
+ aCollectString += OUString(RTL_CONSTASCII_USTRINGPARAM("\n")) ;
+ }
+ aCollectString += OUString(RTL_CONSTASCII_USTRINGPARAM("\0")) ; // It's better :-)
+
+ m_xText_Top->setText ( aCollectString ) ;
+ }
+
+ // Rebuild fixedtext below progress
+
+ // Rebuild left site of text
+ if (m_xTopic_Bottom.is())
+ {
+ OUString aCollectString ;
+
+ // Collect all topics from list and format text.
+ // "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!!
+ for ( size_t n = 0; n < maTextlist_Bottom.size(); ++n )
+ {
+ IMPL_TextlistItem* pSearchItem = maTextlist_Bottom[ n ];
+ aCollectString += pSearchItem->sTopic ;
+ aCollectString += OUString(RTL_CONSTASCII_USTRINGPARAM("\n")) ;
+ }
+ aCollectString += OUString(RTL_CONSTASCII_USTRINGPARAM("\0")) ; // It's better :-)
+
+ m_xTopic_Bottom->setText ( aCollectString ) ;
+ }
+
+ // Rebuild right site of text
+ if (m_xText_Bottom.is())
+ {
+ OUString aCollectString ;
+
+ // Collect all topics from list and format text.
+ // "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!!
+ for ( size_t n = 0; n < maTextlist_Bottom.size(); ++n )
+ {
+ IMPL_TextlistItem* pSearchItem = maTextlist_Bottom[ n ];
+ aCollectString += pSearchItem->sText ;
+ aCollectString += OUString(RTL_CONSTASCII_USTRINGPARAM("\n")) ;
+ }
+ aCollectString += OUString(RTL_CONSTASCII_USTRINGPARAM("\0")) ; // It's better :-)
+
+ m_xText_Bottom->setText ( aCollectString ) ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// private method
+//____________________________________________________________________________________________________________
+
+void ProgressMonitor::impl_cleanMemory ()
+{
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex ) ;
+
+ // Delete all of lists.
+
+ for ( size_t nPosition = 0; nPosition < maTextlist_Top.size() ; ++nPosition )
+ {
+ IMPL_TextlistItem* pSearchItem = maTextlist_Top[ nPosition ];
+ delete pSearchItem ;
+ }
+ maTextlist_Top.clear();
+
+ for ( size_t nPosition = 0; nPosition < maTextlist_Bottom.size() ; ++nPosition )
+ {
+ IMPL_TextlistItem* pSearchItem = maTextlist_Bottom[ nPosition ];
+ delete pSearchItem ;
+ }
+ maTextlist_Bottom.clear();
+}
+
+//____________________________________________________________________________________________________________
+// private method
+//____________________________________________________________________________________________________________
+
+IMPL_TextlistItem* ProgressMonitor::impl_searchTopic ( const OUString& rTopic, sal_Bool bbeforeProgress )
+{
+ // Get right textlist for following operations.
+ ::std::vector< IMPL_TextlistItem* >* pTextList ;
+
+ // Ready for multithreading
+ ClearableMutexGuard aGuard ( m_aMutex ) ;
+
+ if ( bbeforeProgress == sal_True )
+ {
+ pTextList = &maTextlist_Top ;
+ }
+ else
+ {
+ pTextList = &maTextlist_Bottom ;
+ }
+
+ // Switch off guard.
+ aGuard.clear () ;
+
+ // Search the topic in textlist.
+ size_t nPosition = 0;
+ size_t nCount = pTextList->size();
+
+ for ( nPosition = 0; nPosition < nCount ; ++nPosition )
+ {
+ IMPL_TextlistItem* pSearchItem = pTextList->at( nPosition );
+
+ if ( pSearchItem->sTopic == rTopic )
+ {
+ // We have found this topic ... return a valid pointer.
+ return pSearchItem ;
+ }
+ }
+
+ // We have'nt found this topic ... return a nonvalid pointer.
+ return NULL ;
+}
+
+//____________________________________________________________________________________________________________
+// debug methods
+//____________________________________________________________________________________________________________
+
+#ifdef DBG_UTIL
+
+// addText, updateText
+sal_Bool ProgressMonitor::impl_debug_checkParameter (
+ const OUString& rTopic,
+ const OUString& rText,
+ sal_Bool /*bbeforeProgress*/
+) {
+ // Check "rTopic"
+ if ( &rTopic == NULL ) return sal_False ; // NULL-pointer for reference ???!!!
+ if ( rTopic.getLength () < 1 ) return sal_False ; // ""
+
+ // Check "rText"
+ if ( &rText == NULL ) return sal_False ; // NULL-pointer for reference ???!!!
+ if ( rText.getLength () < 1 ) return sal_False ; // ""
+
+ // "bbeforeProgress" is valid in everyway!
+
+ // Parameter OK ... return sal_True.
+ return sal_True ;
+}
+
+// removeText
+sal_Bool ProgressMonitor::impl_debug_checkParameter ( const OUString& rTopic, sal_Bool /*bbeforeProgress*/ )
+{
+ // Check "rTopic"
+ if ( &rTopic == NULL ) return sal_False ; // NULL-pointer for reference ???!!!
+ if ( rTopic.getLength () < 1 ) return sal_False ; // ""
+
+ // "bbeforeProgress" is valid in everyway!
+
+ // Parameter OK ... return sal_True.
+ return sal_True ;
+}
+
+#endif // #ifdef DBG_UTIL
+
+} // namespace unocontrols
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/UnoControls/source/controls/statusindicator.cxx b/UnoControls/source/controls/statusindicator.cxx
new file mode 100644
index 000000000000..1c5aed70a28c
--- /dev/null
+++ b/UnoControls/source/controls/statusindicator.cxx
@@ -0,0 +1,562 @@
+/* -*- 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 "statusindicator.hxx"
+
+//____________________________________________________________________________________________________________
+// includes of other projects
+//____________________________________________________________________________________________________________
+#include <com/sun/star/awt/InvalidateStyle.hpp>
+#include <com/sun/star/awt/WindowAttribute.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <tools/debug.hxx>
+
+//____________________________________________________________________________________________________________
+// includes of my project
+//____________________________________________________________________________________________________________
+#include "progressbar.hxx"
+
+//____________________________________________________________________________________________________________
+// namespace
+//____________________________________________________________________________________________________________
+
+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::task ;
+
+namespace unocontrols{
+
+//____________________________________________________________________________________________________________
+// construct/destruct
+//____________________________________________________________________________________________________________
+
+StatusIndicator::StatusIndicator( const Reference< XMultiServiceFactory >& xFactory )
+ : BaseContainerControl ( xFactory )
+{
+ // Its not allowed to work with member in this method (refcounter !!!)
+ // But with a HACK (++refcount) its "OK" :-(
+ ++m_refCount ;
+
+ // Create instances for fixedtext and progress ...
+ m_xText = Reference< XFixedText > ( xFactory->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM( FIXEDTEXT_SERVICENAME )) ), UNO_QUERY );
+ m_xProgressBar = Reference< XProgressBar > ( xFactory->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_PROGRESSBAR )) ), UNO_QUERY );
+ // ... cast controls to Reference< XControl > and set model ...
+ // ( ProgressBar has no model !!! )
+ Reference< XControl > xTextControl ( m_xText , UNO_QUERY );
+ Reference< XControl > xProgressControl ( m_xProgressBar, UNO_QUERY );
+ xTextControl->setModel( Reference< XControlModel >( xFactory->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM( FIXEDTEXT_MODELNAME )) ), UNO_QUERY ) );
+ // ... and add controls to basecontainercontrol!
+ addControl( OUString(RTL_CONSTASCII_USTRINGPARAM( CONTROLNAME_TEXT )), xTextControl );
+ addControl( OUString(RTL_CONSTASCII_USTRINGPARAM( CONTROLNAME_PROGRESSBAR )), xProgressControl );
+ // FixedText make it automaticly visible by himself ... but not the progressbar !!!
+ // it must be set explicitly
+ Reference< XWindow > xProgressWindow( m_xProgressBar, UNO_QUERY );
+ xProgressWindow->setVisible( sal_True );
+ // Reset to defaults !!!
+ // (progressbar take automaticly its own defaults)
+ m_xText->setText( OUString(RTL_CONSTASCII_USTRINGPARAM( STATUSINDICATOR_DEFAULT_TEXT )) );
+
+ --m_refCount ;
+}
+
+StatusIndicator::~StatusIndicator()
+{
+ // Release all references
+ m_xText = Reference< XFixedText >();
+ m_xProgressBar = Reference< XProgressBar >();
+}
+
+//____________________________________________________________________________________________________________
+// XInterface
+//____________________________________________________________________________________________________________
+
+Any SAL_CALL StatusIndicator::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 = BaseContainerControl::impl_getDelegator();
+ if ( xDel.is() )
+ {
+ // 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 ;
+}
+
+//____________________________________________________________________________________________________________
+// XInterface
+//____________________________________________________________________________________________________________
+
+void SAL_CALL StatusIndicator::acquire() throw()
+{
+ // Attention:
+ // Don't use mutex or guard in this method!!! Is a method of XInterface.
+
+ // Forward to baseclass
+ BaseControl::acquire();
+}
+
+//____________________________________________________________________________________________________________
+// XInterface
+//____________________________________________________________________________________________________________
+
+void SAL_CALL StatusIndicator::release() throw()
+{
+ // Attention:
+ // Don't use mutex or guard in this method!!! Is a method of XInterface.
+
+ // Forward to baseclass
+ BaseControl::release();
+}
+
+//____________________________________________________________________________________________________________
+// XTypeProvider
+//____________________________________________________________________________________________________________
+
+Sequence< Type > SAL_CALL StatusIndicator::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< XLayoutConstrains >*)NULL ) ,
+ ::getCppuType(( const Reference< XStatusIndicator >*)NULL ) ,
+ BaseContainerControl::getTypes()
+ );
+ // ... and set his address to static pointer!
+ pTypeCollection = &aTypeCollection ;
+ }
+ }
+
+ return pTypeCollection->getTypes();
+}
+
+//____________________________________________________________________________________________________________
+// XAggregation
+//____________________________________________________________________________________________________________
+
+Any SAL_CALL StatusIndicator::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< XLayoutConstrains* > ( this ) ,
+ static_cast< XStatusIndicator* > ( this )
+ )
+ );
+
+ // If searched interface not supported by this class ...
+ if ( aReturn.hasValue() == sal_False )
+ {
+ // ... ask baseclasses.
+ aReturn = BaseControl::queryAggregation( aType );
+ }
+
+ return aReturn ;
+}
+
+//____________________________________________________________________________________________________________
+// XStatusIndicator
+//____________________________________________________________________________________________________________
+
+void SAL_CALL StatusIndicator::start( const OUString& sText, sal_Int32 nRange ) throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard( m_aMutex );
+
+ // Initialize status controls with given values.
+ m_xText->setText( sText );
+ m_xProgressBar->setRange( 0, nRange );
+ // force repaint ... fixedtext has changed !
+ impl_recalcLayout ( WindowEvent(static_cast< OWeakObject* >(this),0,0,impl_getWidth(),impl_getHeight(),0,0,0,0) ) ;
+}
+
+//____________________________________________________________________________________________________________
+// XStatusIndicator
+//____________________________________________________________________________________________________________
+
+void SAL_CALL StatusIndicator::end() throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard( m_aMutex );
+
+ // Clear values of status controls.
+ m_xText->setText( OUString() );
+ m_xProgressBar->setValue( 0 );
+ setVisible( sal_False );
+}
+
+//____________________________________________________________________________________________________________
+// XStatusIndicator
+//____________________________________________________________________________________________________________
+
+void SAL_CALL StatusIndicator::setText( const OUString& sText ) throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard( m_aMutex );
+
+ // Take text on right control
+ m_xText->setText( sText );
+}
+
+//____________________________________________________________________________________________________________
+// XStatusIndicator
+//____________________________________________________________________________________________________________
+
+void SAL_CALL StatusIndicator::setValue( sal_Int32 nValue ) throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard( m_aMutex );
+
+ // Take value on right control
+ m_xProgressBar->setValue( nValue );
+}
+
+//____________________________________________________________________________________________________________
+// XStatusIndicator
+//____________________________________________________________________________________________________________
+
+void SAL_CALL StatusIndicator::reset() throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard( m_aMutex );
+
+ // Clear values of status controls.
+ // (Don't hide the window! User will reset current values ... but he will not finish using of indicator!)
+ m_xText->setText( OUString() );
+ m_xProgressBar->setValue( 0 );
+}
+
+//____________________________________________________________________________________________________________
+// XLayoutConstrains
+//____________________________________________________________________________________________________________
+
+Size SAL_CALL StatusIndicator::getMinimumSize () throw( RuntimeException )
+{
+ return Size (STATUSINDICATOR_DEFAULT_WIDTH, STATUSINDICATOR_DEFAULT_HEIGHT) ;
+}
+
+//____________________________________________________________________________________________________________
+// XLayoutConstrains
+//____________________________________________________________________________________________________________
+
+Size SAL_CALL StatusIndicator::getPreferredSize () throw( RuntimeException )
+{
+ // Ready for multithreading
+ ClearableMutexGuard aGuard ( m_aMutex ) ;
+
+ // get information about required place of child controls
+ Reference< XLayoutConstrains > xTextLayout ( m_xText, UNO_QUERY );
+ Size aTextSize = xTextLayout->getPreferredSize();
+
+ aGuard.clear () ;
+
+ // calc preferred size of status indicator
+ sal_Int32 nWidth = impl_getWidth() ;
+ sal_Int32 nHeight = (2*STATUSINDICATOR_FREEBORDER)+aTextSize.Height ;
+
+ // norm to minimum
+ if ( nWidth<STATUSINDICATOR_DEFAULT_WIDTH )
+ {
+ nWidth = STATUSINDICATOR_DEFAULT_WIDTH ;
+ }
+ if ( nHeight<STATUSINDICATOR_DEFAULT_HEIGHT )
+ {
+ nHeight = STATUSINDICATOR_DEFAULT_HEIGHT ;
+ }
+
+ // return to caller
+ return Size ( nWidth, nHeight ) ;
+}
+
+//____________________________________________________________________________________________________________
+// XLayoutConstrains
+//____________________________________________________________________________________________________________
+
+Size SAL_CALL StatusIndicator::calcAdjustedSize ( const Size& /*rNewSize*/ ) throw( RuntimeException )
+{
+ return getPreferredSize () ;
+}
+
+//____________________________________________________________________________________________________________
+// XControl
+//____________________________________________________________________________________________________________
+
+void SAL_CALL StatusIndicator::createPeer (
+ const Reference< XToolkit > & rToolkit,
+ const Reference< XWindowPeer > & rParent
+) throw( RuntimeException )
+{
+ if( getPeer().is() == sal_False )
+ {
+ BaseContainerControl::createPeer( rToolkit, rParent );
+
+ // If user forget to call "setPosSize()", we have still a correct size.
+ // And a "MinimumSize" IS A "MinimumSize"!
+ // We change not the position of control at this point.
+ Size aDefaultSize = getMinimumSize () ;
+ setPosSize ( 0, 0, aDefaultSize.Width, aDefaultSize.Height, PosSize::SIZE ) ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// XControl
+//____________________________________________________________________________________________________________
+
+sal_Bool SAL_CALL StatusIndicator::setModel ( const Reference< XControlModel > & /*rModel*/ ) throw( RuntimeException )
+{
+ // We have no model.
+ return sal_False ;
+}
+
+//____________________________________________________________________________________________________________
+// XControl
+//____________________________________________________________________________________________________________
+
+Reference< XControlModel > SAL_CALL StatusIndicator::getModel () throw( RuntimeException )
+{
+ // We have no model.
+ // return (XControlModel*)this ;
+ return Reference< XControlModel > () ;
+}
+
+//____________________________________________________________________________________________________________
+// XComponent
+//____________________________________________________________________________________________________________
+
+void SAL_CALL StatusIndicator::dispose () throw( RuntimeException )
+{
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex ) ;
+
+ // "removeControl()" control the state of a reference
+ Reference< XControl > xTextControl ( m_xText , UNO_QUERY );
+ Reference< XControl > xProgressControl ( m_xProgressBar, UNO_QUERY );
+
+ removeControl( xTextControl );
+ removeControl( xProgressControl );
+
+ // do'nt use "...->clear ()" or "... = XFixedText ()"
+ // when other hold a reference at this object !!!
+ xTextControl->dispose();
+ xProgressControl->dispose();
+ BaseContainerControl::dispose();
+}
+
+//____________________________________________________________________________________________________________
+// XWindow
+//____________________________________________________________________________________________________________
+
+void SAL_CALL StatusIndicator::setPosSize (
+ sal_Int32 nX,
+ sal_Int32 nY,
+ sal_Int32 nWidth,
+ sal_Int32 nHeight,
+ sal_Int16 nFlags
+) throw( RuntimeException )
+{
+ Rectangle aBasePosSize = getPosSize () ;
+ BaseContainerControl::setPosSize (nX, nY, nWidth, nHeight, nFlags) ;
+
+ // if position or size changed
+ if (
+ ( nWidth != aBasePosSize.Width ) ||
+ ( nHeight != aBasePosSize.Height)
+ )
+ {
+ // calc new layout for controls
+ impl_recalcLayout ( WindowEvent(static_cast< OWeakObject* >(this),0,0,nWidth,nHeight,0,0,0,0) ) ;
+ // clear background (!)
+ // [Childs was repainted in "recalcLayout" by setPosSize() automaticly!]
+ getPeer()->invalidate(2);
+ // and repaint the control
+ impl_paint ( 0, 0, impl_getGraphicsPeer() ) ;
+ }
+}
+
+//____________________________________________________________________________________________________________
+// impl but public method to register service
+//____________________________________________________________________________________________________________
+
+const Sequence< OUString > StatusIndicator::impl_getStaticSupportedServiceNames()
+{
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ Sequence< OUString > seqServiceNames( 1 );
+ seqServiceNames.getArray() [0] = OUString(RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_STATUSINDICATOR ));
+ return seqServiceNames ;
+}
+
+//____________________________________________________________________________________________________________
+// impl but public method to register service
+//____________________________________________________________________________________________________________
+
+const OUString StatusIndicator::impl_getStaticImplementationName()
+{
+ return OUString(RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATIONNAME_STATUSINDICATOR ));
+}
+
+//____________________________________________________________________________________________________________
+// protected method
+//____________________________________________________________________________________________________________
+
+WindowDescriptor* StatusIndicator::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("floatingwindow")) ;
+ pDescriptor->ParentIndex = -1 ;
+ pDescriptor->Parent = xParentPeer ;
+ pDescriptor->Bounds = getPosSize () ;
+
+ return pDescriptor ;
+}
+
+//____________________________________________________________________________________________________________
+// protected method
+//____________________________________________________________________________________________________________
+
+void StatusIndicator::impl_paint ( sal_Int32 nX, sal_Int32 nY, const Reference< XGraphics > & rGraphics )
+{
+ // This paint method ist not buffered !!
+ // Every request paint the completely control. ( but only, if peer exist )
+ if ( rGraphics.is () )
+ {
+ MutexGuard aGuard (m_aMutex) ;
+
+ // background = gray
+ Reference< XWindowPeer > xPeer( impl_getPeerWindow(), UNO_QUERY );
+ if( xPeer.is() == sal_True )
+ xPeer->setBackground( STATUSINDICATOR_BACKGROUNDCOLOR );
+
+ // FixedText background = gray
+ Reference< XControl > xTextControl( m_xText, UNO_QUERY );
+ xPeer = xTextControl->getPeer();
+ if( xPeer.is() == sal_True )
+ xPeer->setBackground( STATUSINDICATOR_BACKGROUNDCOLOR );
+
+ // Progress background = gray
+ xPeer = Reference< XWindowPeer >( m_xProgressBar, UNO_QUERY );
+ if( xPeer.is() == sal_True )
+ xPeer->setBackground( STATUSINDICATOR_BACKGROUNDCOLOR );
+
+ // paint shadow border
+ rGraphics->setLineColor ( STATUSINDICATOR_LINECOLOR_BRIGHT );
+ rGraphics->drawLine ( nX, nY, impl_getWidth(), nY );
+ rGraphics->drawLine ( nX, nY, nX , impl_getHeight() );
+
+ rGraphics->setLineColor ( STATUSINDICATOR_LINECOLOR_SHADOW );
+ rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, impl_getWidth()-1, nY );
+ rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, nX , impl_getHeight()-1 );
+ }
+}
+
+//____________________________________________________________________________________________________________
+// protected method
+//____________________________________________________________________________________________________________
+
+void StatusIndicator::impl_recalcLayout ( const WindowEvent& aEvent )
+{
+ sal_Int32 nX_ProgressBar ;
+ sal_Int32 nY_ProgressBar ;
+ sal_Int32 nWidth_ProgressBar ;
+ sal_Int32 nHeight_ProgressBar ;
+ sal_Int32 nX_Text ;
+ sal_Int32 nY_Text ;
+ sal_Int32 nWidth_Text ;
+ sal_Int32 nHeight_Text ;
+
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex ) ;
+
+ // get information about required place of child controls
+ Size aWindowSize ( aEvent.Width, aEvent.Height );
+ Reference< XLayoutConstrains > xTextLayout ( m_xText, UNO_QUERY );
+ Size aTextSize = xTextLayout->getPreferredSize();
+
+ if( aWindowSize.Width < STATUSINDICATOR_DEFAULT_WIDTH )
+ {
+ aWindowSize.Width = STATUSINDICATOR_DEFAULT_WIDTH;
+ }
+ if( aWindowSize.Height < STATUSINDICATOR_DEFAULT_HEIGHT )
+ {
+ aWindowSize.Height = STATUSINDICATOR_DEFAULT_HEIGHT;
+ }
+
+ // calc position and size of child controls
+ nX_Text = STATUSINDICATOR_FREEBORDER ;
+ nY_Text = STATUSINDICATOR_FREEBORDER ;
+ nWidth_Text = aTextSize.Width ;
+ nHeight_Text = aTextSize.Height ;
+
+ nX_ProgressBar = nX_Text+nWidth_Text+STATUSINDICATOR_FREEBORDER ;
+ nY_ProgressBar = nY_Text ;
+ nWidth_ProgressBar = aWindowSize.Width-nWidth_Text-(3*STATUSINDICATOR_FREEBORDER) ;
+ nHeight_ProgressBar = nHeight_Text ;
+
+ // Set new position and size on all controls
+ Reference< XWindow > xTextWindow ( m_xText , UNO_QUERY );
+ Reference< XWindow > xProgressWindow ( m_xProgressBar, UNO_QUERY );
+
+ xTextWindow->setPosSize ( nX_Text , nY_Text , nWidth_Text , nHeight_Text , 15 ) ;
+ xProgressWindow->setPosSize ( nX_ProgressBar, nY_ProgressBar, nWidth_ProgressBar, nHeight_ProgressBar , 15 ) ;
+}
+
+} // namespace unocontrols
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */