2009-08-26 13:11:27 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2009-08-26 13:11:27 +00:00
|
|
|
*
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
|
|
*
|
|
|
|
* This file is part of OpenOffice.org.
|
|
|
|
*
|
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#include "precompiled_toolkit.hxx"
|
|
|
|
#include "gridcolumn.hxx"
|
2010-12-07 13:50:47 +01:00
|
|
|
|
2009-08-26 13:11:27 +00:00
|
|
|
#include <comphelper/sequence.hxx>
|
|
|
|
#include <toolkit/helper/servicenames.hxx>
|
|
|
|
|
2010-03-22 11:17:10 +01:00
|
|
|
#define COLWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColWidth" ))
|
|
|
|
#define MAXWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MaxWidth" ))
|
|
|
|
#define MINWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MinWidth" ))
|
|
|
|
#define PREFWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "PrefWidth" ))
|
|
|
|
#define HALIGN ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "HAlign" ))
|
|
|
|
#define TITLE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Title" ))
|
|
|
|
#define COLRESIZE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnResize" ))
|
|
|
|
|
2009-08-26 13:11:27 +00:00
|
|
|
namespace toolkit
|
|
|
|
{
|
2010-12-07 13:50:47 +01:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::awt;
|
|
|
|
using namespace ::com::sun::star::awt::grid;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::style;
|
|
|
|
|
|
|
|
//==================================================================================================================
|
|
|
|
//= DefaultGridColumnModel
|
|
|
|
//==================================================================================================================
|
|
|
|
GridColumn::GridColumn()
|
|
|
|
:GridColumn_Base( m_aMutex )
|
|
|
|
,m_aIdentifier()
|
|
|
|
,m_nIndex(0)
|
|
|
|
,m_nColumnWidth(4)
|
|
|
|
,m_nPreferredWidth(0)
|
|
|
|
,m_nMaxWidth(0)
|
|
|
|
,m_nMinWidth(0)
|
|
|
|
,m_bResizeable(true)
|
|
|
|
,m_eHorizontalAlign(HorizontalAlignment(0))
|
|
|
|
{
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
GridColumn::~GridColumn()
|
|
|
|
{
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2010-12-17 14:07:29 +01:00
|
|
|
void GridColumn::broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue, ::osl::ClearableMutexGuard& i_Guard )
|
2010-12-07 13:50:47 +01:00
|
|
|
{
|
|
|
|
Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
|
|
|
|
GridColumnEvent aEvent( xSource, name, oldValue, newValue, m_nIndex);
|
2010-02-12 17:05:02 +01:00
|
|
|
|
2010-12-17 14:07:29 +01:00
|
|
|
::cppu::OInterfaceContainerHelper* pIter = rBHelper.getContainer( XGridColumnListener::static_type() );
|
|
|
|
|
|
|
|
i_Guard.clear();
|
|
|
|
if( pIter )
|
|
|
|
pIter->notifyEach( &XGridColumnListener::columnChanged, aEvent );
|
2010-12-07 13:50:47 +01:00
|
|
|
}
|
2010-02-12 17:05:02 +01:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
::com::sun::star::uno::Any SAL_CALL GridColumn::getIdentifier() throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2010-12-17 14:07:29 +01:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2010-12-07 13:50:47 +01:00
|
|
|
return m_aIdentifier;
|
|
|
|
}
|
2010-02-12 17:05:02 +01:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL GridColumn::setIdentifier(const ::com::sun::star::uno::Any & value) throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
value >>= m_aIdentifier;
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
::sal_Int32 SAL_CALL GridColumn::getColumnWidth() throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2010-12-17 14:07:29 +01:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2010-12-07 13:50:47 +01:00
|
|
|
return m_nColumnWidth;
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL GridColumn::setColumnWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2010-12-17 14:07:29 +01:00
|
|
|
::osl::ClearableMutexGuard aGuard( m_aMutex );
|
|
|
|
if ( m_nColumnWidth == value )
|
|
|
|
return;
|
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
m_nColumnWidth = value;
|
2010-12-17 14:07:29 +01:00
|
|
|
broadcast_changed( COLWIDTH, Any( m_nColumnWidth ), Any( value ), aGuard );
|
2010-12-07 13:50:47 +01:00
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
::sal_Int32 SAL_CALL GridColumn::getPreferredWidth() throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2010-12-17 14:07:29 +01:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2010-12-07 13:50:47 +01:00
|
|
|
return m_nPreferredWidth;
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL GridColumn::setPreferredWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2010-12-17 14:07:29 +01:00
|
|
|
::osl::ClearableMutexGuard aGuard( m_aMutex );
|
|
|
|
if ( m_nPreferredWidth == value )
|
|
|
|
return;
|
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
m_nPreferredWidth = value;
|
2010-12-17 14:07:29 +01:00
|
|
|
broadcast_changed( PREFWIDTH, Any( m_nPreferredWidth ), Any( value ), aGuard );
|
2010-12-07 13:50:47 +01:00
|
|
|
}
|
2010-02-12 17:05:02 +01:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
::sal_Int32 SAL_CALL GridColumn::getMaxWidth() throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2010-12-17 14:07:29 +01:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2010-12-07 13:50:47 +01:00
|
|
|
return m_nMaxWidth;
|
|
|
|
}
|
2010-02-12 17:05:02 +01:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL GridColumn::setMaxWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2010-12-17 14:07:29 +01:00
|
|
|
::osl::ClearableMutexGuard aGuard( m_aMutex );
|
|
|
|
if ( m_nMaxWidth == value )
|
|
|
|
return;
|
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
m_nMaxWidth = value;
|
2010-12-17 14:07:29 +01:00
|
|
|
broadcast_changed( MAXWIDTH, Any( m_nMaxWidth ), Any( value ), aGuard );
|
2010-12-07 13:50:47 +01:00
|
|
|
}
|
2010-02-12 17:05:02 +01:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
::sal_Int32 SAL_CALL GridColumn::getMinWidth() throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2010-12-17 14:07:29 +01:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2010-12-07 13:50:47 +01:00
|
|
|
return m_nMinWidth;
|
|
|
|
}
|
2010-02-12 17:05:02 +01:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL GridColumn::setMinWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2010-12-17 14:07:29 +01:00
|
|
|
::osl::ClearableMutexGuard aGuard( m_aMutex );
|
|
|
|
if ( m_nMinWidth == value )
|
|
|
|
return;
|
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
m_nMinWidth = value;
|
2010-12-17 14:07:29 +01:00
|
|
|
broadcast_changed( MINWIDTH, Any( m_nMinWidth ), Any( value ), aGuard );
|
2010-12-07 13:50:47 +01:00
|
|
|
}
|
2010-03-22 11:17:10 +01:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
::rtl::OUString SAL_CALL GridColumn::getTitle() throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2010-12-17 14:07:29 +01:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2010-12-07 13:50:47 +01:00
|
|
|
return m_sTitle;
|
|
|
|
}
|
2010-03-22 11:17:10 +01:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL GridColumn::setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2010-12-17 14:07:29 +01:00
|
|
|
::osl::ClearableMutexGuard aGuard( m_aMutex );
|
|
|
|
if ( m_sTitle == value )
|
|
|
|
return;
|
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
m_sTitle = value;
|
2010-12-17 14:07:29 +01:00
|
|
|
broadcast_changed( TITLE, Any( m_sTitle ), Any( value ), aGuard );
|
2010-12-07 13:50:47 +01:00
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
sal_Bool SAL_CALL GridColumn::getResizeable() throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2010-12-17 14:07:29 +01:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2010-12-07 13:50:47 +01:00
|
|
|
return m_bResizeable;
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL GridColumn::setResizeable(sal_Bool value) throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2010-12-17 14:07:29 +01:00
|
|
|
::osl::ClearableMutexGuard aGuard( m_aMutex );
|
|
|
|
if ( m_bResizeable == value )
|
|
|
|
return;
|
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
m_bResizeable = value;
|
2010-12-17 14:07:29 +01:00
|
|
|
broadcast_changed( COLRESIZE, Any( m_bResizeable ), Any( value ), aGuard );
|
2010-12-07 13:50:47 +01:00
|
|
|
}
|
2010-03-22 11:17:10 +01:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2010-12-17 14:07:29 +01:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2010-12-07 13:50:47 +01:00
|
|
|
return m_eHorizontalAlign;
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2010-12-17 14:07:29 +01:00
|
|
|
::osl::ClearableMutexGuard aGuard( m_aMutex );
|
|
|
|
if ( m_eHorizontalAlign == align )
|
|
|
|
return;
|
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
m_eHorizontalAlign = align;
|
2010-12-17 14:07:29 +01:00
|
|
|
broadcast_changed( HALIGN, Any( m_eHorizontalAlign ), Any( align ), aGuard );
|
2010-12-07 13:50:47 +01:00
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2010-12-17 14:25:50 +01:00
|
|
|
void SAL_CALL GridColumn::addGridColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException)
|
2010-12-07 13:50:47 +01:00
|
|
|
{
|
|
|
|
rBHelper.addListener( XGridColumnListener::static_type(), xListener );
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2010-12-17 14:25:50 +01:00
|
|
|
void SAL_CALL GridColumn::removeGridColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException)
|
2010-12-07 13:50:47 +01:00
|
|
|
{
|
|
|
|
rBHelper.removeListener( XGridColumnListener::static_type(), xListener );
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL GridColumn::dispose() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
// simply disambiguate, the base class handles this
|
|
|
|
GridColumn_Base::dispose();
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL GridColumn::addEventListener( const Reference< XEventListener >& i_listener ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
// simply disambiguate, the base class handles this
|
|
|
|
GridColumn_Base::addEventListener( i_listener );
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL GridColumn::removeEventListener( const Reference< XEventListener >& i_listener ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
// simply disambiguate, the base class handles this
|
|
|
|
GridColumn_Base::removeEventListener( i_listener );
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL GridColumn::setIndex(sal_Int32 _nIndex) throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
m_nIndex = _nIndex;
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
::rtl::OUString SAL_CALL GridColumn::getImplementationName( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.toolkit.GridColumn" ) );
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
sal_Bool SAL_CALL GridColumn::supportsService( const ::rtl::OUString& i_serviceName ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
const Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames() );
|
|
|
|
for ( sal_Int32 i=0; i<aServiceNames.getLength(); ++i )
|
|
|
|
if ( aServiceNames[i] == i_serviceName )
|
|
|
|
return sal_True;
|
|
|
|
return sal_False;
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL GridColumn::getSupportedServiceNames( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
const ::rtl::OUString aServiceName( ::rtl::OUString::createFromAscii( szServiceName_GridColumn ) );
|
|
|
|
const Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 );
|
|
|
|
return aSeq;
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
}
|
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL GridColumn_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& )
|
2009-08-26 13:11:27 +00:00
|
|
|
{
|
2010-12-07 13:50:47 +01:00
|
|
|
return *( new ::toolkit::GridColumn );
|
2009-08-26 13:11:27 +00:00
|
|
|
}
|
|
|
|
|