2010-08-12 17:44:19 +02:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_toolkit.hxx"
|
|
|
|
|
|
|
|
#include <toolkit/controls/tabpagecontainer.hxx>
|
|
|
|
|
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
|
|
|
#include <toolkit/helper/unopropertyarrayhelper.hxx>
|
|
|
|
#include <toolkit/helper/property.hxx>
|
2010-09-02 14:32:02 +02:00
|
|
|
#include <toolkit/controls/geometrycontrolmodel.hxx>
|
2010-08-12 17:44:19 +02:00
|
|
|
#include <com/sun/star/awt/XVclWindowPeer.hpp>
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#include <osl/diagnose.h>
|
2010-08-27 12:13:59 +02:00
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#include <vos/mutex.hxx>
|
2010-08-12 17:44:19 +02:00
|
|
|
#include <com/sun/star/awt/XControlModel.hpp>
|
2010-08-27 12:13:59 +02:00
|
|
|
#include <tools/diagnose_ex.h>
|
2010-08-12 17:44:19 +02:00
|
|
|
|
|
|
|
using ::rtl::OUString;
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::view;
|
|
|
|
|
2010-08-27 12:13:59 +02:00
|
|
|
#define WRONG_TYPE_EXCEPTION "Type must be ::com::sun::star::awt::tab::XTabPageModel!"
|
2010-08-12 17:44:19 +02:00
|
|
|
// ----------------------------------------------------
|
|
|
|
// class UnoControlTabPageContainerModel
|
|
|
|
// ----------------------------------------------------
|
2011-02-03 09:41:02 +01:00
|
|
|
UnoControlTabPageContainerModel::UnoControlTabPageContainerModel( const Reference< XMultiServiceFactory >& i_factory )
|
|
|
|
:UnoControlTabPageContainerModel_Base( i_factory )
|
|
|
|
,maContainerListeners( *this )
|
2010-08-12 17:44:19 +02:00
|
|
|
{
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_BORDER );
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR );
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_ENABLED );
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_HELPURL );
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
|
|
|
|
ImplRegisterProperty( BASEPROPERTY_TEXT );
|
|
|
|
}
|
|
|
|
|
2010-08-27 12:13:59 +02:00
|
|
|
::rtl::OUString UnoControlTabPageContainerModel::getServiceName() throw(RuntimeException)
|
2010-08-12 17:44:19 +02:00
|
|
|
{
|
|
|
|
return ::rtl::OUString::createFromAscii( szServiceName_UnoControlTabPageContainerModel );
|
|
|
|
}
|
|
|
|
|
|
|
|
uno::Any UnoControlTabPageContainerModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
|
|
|
|
{
|
|
|
|
switch(nPropId)
|
|
|
|
{
|
|
|
|
case BASEPROPERTY_DEFAULTCONTROL:
|
|
|
|
return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlTabPageContainer ) );
|
2010-09-02 14:32:02 +02:00
|
|
|
case BASEPROPERTY_BORDER:
|
2010-09-03 11:29:29 +02:00
|
|
|
return uno::makeAny((sal_Int16) 0); // No Border
|
2010-08-12 17:44:19 +02:00
|
|
|
default:
|
|
|
|
return UnoControlModel::ImplGetDefaultValue( nPropId );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
::cppu::IPropertyArrayHelper& UnoControlTabPageContainerModel::getInfoHelper()
|
|
|
|
{
|
|
|
|
static UnoPropertyArrayHelper* pHelper = NULL;
|
|
|
|
if ( !pHelper )
|
|
|
|
{
|
|
|
|
com::sun::star::uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
|
|
|
|
pHelper = new UnoPropertyArrayHelper( aIDs );
|
|
|
|
}
|
|
|
|
return *pHelper;
|
|
|
|
}
|
2010-08-27 12:13:59 +02:00
|
|
|
Reference< ::com::sun::star::beans::XPropertySetInfo > UnoControlTabPageContainerModel::getPropertySetInfo( ) throw(RuntimeException)
|
2010-08-12 17:44:19 +02:00
|
|
|
{
|
2010-08-27 12:13:59 +02:00
|
|
|
static Reference< ::com::sun::star::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
|
2010-08-12 17:44:19 +02:00
|
|
|
return xInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL UnoControlTabPageContainerModel::insertByIndex( ::sal_Int32 nIndex, const com::sun::star::uno::Any& aElement) throw (IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException)
|
|
|
|
{
|
2010-08-27 12:13:59 +02:00
|
|
|
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
|
|
|
|
uno::Reference < ::awt::tab::XTabPageModel > xTabPageModel;
|
|
|
|
if(aElement >>= xTabPageModel)
|
2010-08-12 17:44:19 +02:00
|
|
|
{
|
|
|
|
if ( sal_Int32( m_aTabPageVector.size()) ==nIndex )
|
2010-08-27 12:13:59 +02:00
|
|
|
m_aTabPageVector.push_back( xTabPageModel );
|
2010-08-12 17:44:19 +02:00
|
|
|
else if ( sal_Int32( m_aTabPageVector.size()) > nIndex )
|
|
|
|
{
|
2010-08-27 12:13:59 +02:00
|
|
|
std::vector< uno::Reference< ::awt::tab::XTabPageModel > >::iterator aIter = m_aTabPageVector.begin();
|
2010-08-12 17:44:19 +02:00
|
|
|
aIter += nIndex;
|
2010-08-27 12:13:59 +02:00
|
|
|
m_aTabPageVector.insert( aIter, xTabPageModel );
|
2010-08-12 17:44:19 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
throw IndexOutOfBoundsException( ::rtl::OUString(), (OWeakObject *)this );
|
2010-08-27 12:13:59 +02:00
|
|
|
ContainerEvent aEvent;
|
|
|
|
aEvent.Source = *this;
|
|
|
|
aEvent.Element <<= aElement;
|
|
|
|
aEvent.Accessor <<= ::rtl::OUString::valueOf(nIndex);
|
|
|
|
maContainerListeners.elementInserted( aEvent );
|
2010-08-12 17:44:19 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
throw IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( WRONG_TYPE_EXCEPTION )),
|
|
|
|
(OWeakObject *)this, 2 );
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL UnoControlTabPageContainerModel::removeByIndex( ::sal_Int32 /*Index*/ ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
// XIndexReplace
|
|
|
|
void SAL_CALL UnoControlTabPageContainerModel::replaceByIndex( ::sal_Int32 /*Index*/, const uno::Any& /*Element*/ ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// XIndexAccess
|
|
|
|
::sal_Int32 SAL_CALL UnoControlTabPageContainerModel::getCount( ) throw (uno::RuntimeException)
|
|
|
|
{
|
2010-08-27 12:13:59 +02:00
|
|
|
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
|
|
|
|
return sal_Int32( m_aTabPageVector.size());
|
2010-08-12 17:44:19 +02:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
uno::Any SAL_CALL UnoControlTabPageContainerModel::getByIndex( ::sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
|
|
|
|
{
|
2010-08-27 12:13:59 +02:00
|
|
|
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
|
|
|
|
if ( nIndex < 0 || nIndex > sal_Int32(m_aTabPageVector.size()) )
|
|
|
|
throw lang::IndexOutOfBoundsException();
|
|
|
|
return uno::makeAny(m_aTabPageVector[nIndex]);
|
2010-08-12 17:44:19 +02:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// XElementAccess
|
|
|
|
uno::Type SAL_CALL UnoControlTabPageContainerModel::getElementType( ) throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return ::getCppuType(static_cast< Reference< com::sun::star::awt::XControlModel>* >(NULL));
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
::sal_Bool SAL_CALL UnoControlTabPageContainerModel::hasElements( ) throw (uno::RuntimeException)
|
|
|
|
{
|
2010-08-27 12:13:59 +02:00
|
|
|
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
|
|
|
|
return !m_aTabPageVector.empty();
|
2010-08-12 17:44:19 +02:00
|
|
|
}
|
|
|
|
// XContainer
|
|
|
|
void UnoControlTabPageContainerModel::addContainerListener( const Reference< XContainerListener >& l ) throw(RuntimeException)
|
|
|
|
{
|
2010-08-27 12:13:59 +02:00
|
|
|
maContainerListeners.addInterface( l );
|
2010-08-12 17:44:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void UnoControlTabPageContainerModel::removeContainerListener( const Reference< XContainerListener >& l ) throw(RuntimeException)
|
|
|
|
{
|
2010-08-27 12:13:59 +02:00
|
|
|
maContainerListeners.removeInterface( l );
|
2010-08-12 17:44:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------
|
|
|
|
// class UnoControlTabPageContainer
|
|
|
|
// ----------------------------------------------------
|
2011-02-03 09:41:02 +01:00
|
|
|
UnoControlTabPageContainer::UnoControlTabPageContainer( const Reference< XMultiServiceFactory >& i_factory )
|
|
|
|
:UnoControlTabPageContainer_Base( i_factory )
|
|
|
|
,m_aTabPageListeners( *this )
|
2010-08-12 17:44:19 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString UnoControlTabPageContainer::GetComponentServiceName()
|
|
|
|
{
|
|
|
|
return OUString::createFromAscii( "TabPageContainer" );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL UnoControlTabPageContainer::dispose( ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
lang::EventObject aEvt;
|
|
|
|
aEvt.Source = (::cppu::OWeakObject*)this;
|
|
|
|
m_aTabPageListeners.disposeAndClear( aEvt );
|
|
|
|
UnoControl::dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
void UnoControlTabPageContainer::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
UnoControlBase::createPeer( rxToolkit, rParentPeer );
|
|
|
|
|
|
|
|
Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW );
|
2010-08-27 12:13:59 +02:00
|
|
|
if ( m_aTabPageListeners.getLength() )
|
|
|
|
xTPContainer->addTabPageListener(&m_aTabPageListeners);
|
2010-08-12 17:44:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// XTabPageContainer
|
|
|
|
|
2010-08-27 12:13:59 +02:00
|
|
|
::sal_Int16 SAL_CALL UnoControlTabPageContainer::getActiveTabPageID() throw (RuntimeException)
|
2010-08-12 17:44:19 +02:00
|
|
|
{
|
2010-08-27 12:13:59 +02:00
|
|
|
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
|
|
|
|
Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW );
|
|
|
|
return xTPContainer->getActiveTabPageID();
|
2010-08-12 17:44:19 +02:00
|
|
|
}
|
2010-08-27 12:13:59 +02:00
|
|
|
void SAL_CALL UnoControlTabPageContainer::setActiveTabPageID( ::sal_Int16 _activetabpageid ) throw (RuntimeException)
|
2010-08-12 17:44:19 +02:00
|
|
|
{
|
2010-08-27 12:13:59 +02:00
|
|
|
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
|
|
|
|
Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW );
|
|
|
|
xTPContainer->setActiveTabPageID(_activetabpageid);
|
2010-08-12 17:44:19 +02:00
|
|
|
}
|
2010-08-27 12:13:59 +02:00
|
|
|
::sal_Int32 SAL_CALL UnoControlTabPageContainer::getTabPageCount( ) throw (RuntimeException)
|
2010-08-12 17:44:19 +02:00
|
|
|
{
|
2010-08-27 12:13:59 +02:00
|
|
|
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
|
|
|
|
Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW );
|
|
|
|
return xTPContainer->getTabPageCount();
|
2010-08-12 17:44:19 +02:00
|
|
|
}
|
2010-08-27 12:13:59 +02:00
|
|
|
::sal_Bool SAL_CALL UnoControlTabPageContainer::isTabPageActive( ::sal_Int16 tabPageIndex ) throw (RuntimeException)
|
2010-08-12 17:44:19 +02:00
|
|
|
{
|
2010-08-27 12:13:59 +02:00
|
|
|
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
|
|
|
|
Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW );
|
|
|
|
return xTPContainer->isTabPageActive(tabPageIndex);
|
2010-08-12 17:44:19 +02:00
|
|
|
}
|
2010-08-27 12:13:59 +02:00
|
|
|
Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL UnoControlTabPageContainer::getTabPage( ::sal_Int16 tabPageIndex ) throw (RuntimeException)
|
2010-08-12 17:44:19 +02:00
|
|
|
{
|
2010-08-27 12:13:59 +02:00
|
|
|
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
|
|
|
|
Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW );
|
|
|
|
return xTPContainer->getTabPage(tabPageIndex);
|
2010-08-12 17:44:19 +02:00
|
|
|
}
|
2010-08-27 12:13:59 +02:00
|
|
|
Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL UnoControlTabPageContainer::getTabPageByID( ::sal_Int16 tabPageID ) throw (RuntimeException)
|
2010-08-12 17:44:19 +02:00
|
|
|
{
|
2010-08-27 12:13:59 +02:00
|
|
|
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
|
|
|
|
Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW );
|
|
|
|
return xTPContainer->getTabPageByID(tabPageID);
|
2010-08-12 17:44:19 +02:00
|
|
|
}
|
2010-08-27 12:13:59 +02:00
|
|
|
void SAL_CALL UnoControlTabPageContainer::addTabPageListener( const Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (RuntimeException)
|
2010-08-12 17:44:19 +02:00
|
|
|
{
|
|
|
|
m_aTabPageListeners.addInterface( listener );
|
2010-09-06 10:26:04 +02:00
|
|
|
if( getPeer().is() && m_aTabPageListeners.getLength() == 1 )
|
|
|
|
{
|
|
|
|
uno::Reference < awt::tab::XTabPageContainer > xTabPageContainer( getPeer(), uno::UNO_QUERY );
|
|
|
|
xTabPageContainer->addTabPageListener( &m_aTabPageListeners );
|
|
|
|
}
|
2010-08-12 17:44:19 +02:00
|
|
|
}
|
2010-08-27 12:13:59 +02:00
|
|
|
void SAL_CALL UnoControlTabPageContainer::removeTabPageListener( const Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (RuntimeException)
|
2010-08-12 17:44:19 +02:00
|
|
|
{
|
2010-09-06 10:26:04 +02:00
|
|
|
if( getPeer().is() && m_aTabPageListeners.getLength() == 1 )
|
|
|
|
{
|
|
|
|
uno::Reference < awt::tab::XTabPageContainer > xTabPageContainer( getPeer(), uno::UNO_QUERY );
|
|
|
|
xTabPageContainer->addTabPageListener( &m_aTabPageListeners );
|
|
|
|
}
|
2010-08-12 17:44:19 +02:00
|
|
|
m_aTabPageListeners.removeInterface( listener );
|
|
|
|
}
|
|
|
|
|
2010-08-27 12:13:59 +02:00
|
|
|
void UnoControlTabPageContainer::updateFromModel()
|
2010-08-12 17:44:19 +02:00
|
|
|
{
|
2010-08-27 12:13:59 +02:00
|
|
|
UnoControlTabPageContainer_Base::updateFromModel();
|
|
|
|
Reference< XContainerListener > xContainerListener( getPeer(), UNO_QUERY );
|
|
|
|
ENSURE_OR_RETURN_VOID( xContainerListener.is(), "UnoListBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
|
|
|
|
|
|
|
|
ContainerEvent aEvent;
|
|
|
|
aEvent.Source = getModel();
|
|
|
|
Sequence< Reference< XControl > > aControls = getControls();
|
|
|
|
const Reference< XControl >* pCtrls = aControls.getConstArray();
|
|
|
|
const Reference< XControl >* pCtrlsEnd = pCtrls + aControls.getLength();
|
|
|
|
|
|
|
|
for ( ; pCtrls < pCtrlsEnd; ++pCtrls )
|
|
|
|
{
|
|
|
|
aEvent.Element <<= *pCtrls;
|
|
|
|
xContainerListener->elementInserted( aEvent );
|
|
|
|
}
|
2010-08-12 17:44:19 +02:00
|
|
|
}
|
2010-08-27 12:13:59 +02:00
|
|
|
void SAL_CALL UnoControlTabPageContainer::addControl( const ::rtl::OUString& Name, const Reference< ::com::sun::star::awt::XControl >& Control ) throw (RuntimeException)
|
2010-08-12 17:44:19 +02:00
|
|
|
{
|
2010-08-27 12:13:59 +02:00
|
|
|
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
|
|
|
|
ControlContainerBase::addControl(Name,Control);
|
|
|
|
Reference< XContainerListener > xContainerListener( getPeer(), UNO_QUERY );
|
|
|
|
ContainerEvent aEvent;
|
|
|
|
aEvent.Source = getModel();
|
|
|
|
aEvent.Element <<= Control;
|
|
|
|
xContainerListener->elementInserted( aEvent );
|
2010-08-12 17:44:19 +02:00
|
|
|
}
|
|
|
|
|