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" ))
|
|
|
|
#define UPDATE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "UpdateWidth" ))
|
|
|
|
|
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
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void GridColumn::broadcast( broadcast_column_type eType, const GridColumnEvent& aEvent )
|
2010-03-22 11:17:10 +01:00
|
|
|
{
|
2010-12-07 13:50:47 +01:00
|
|
|
::cppu::OInterfaceContainerHelper* pIter = rBHelper.getContainer( XGridColumnListener::static_type() );
|
|
|
|
if( pIter )
|
2010-03-22 11:17:10 +01:00
|
|
|
{
|
2010-12-07 13:50:47 +01:00
|
|
|
::cppu::OInterfaceIteratorHelper aListIter(*pIter);
|
|
|
|
while(aListIter.hasMoreElements())
|
2010-03-22 11:17:10 +01:00
|
|
|
{
|
2010-12-07 13:50:47 +01:00
|
|
|
XGridColumnListener* pListener = static_cast<XGridColumnListener*>(aListIter.next());
|
|
|
|
switch( eType )
|
|
|
|
{
|
|
|
|
case column_attribute_changed: pListener->columnChanged(aEvent); break;
|
|
|
|
}
|
2010-03-22 11:17:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void GridColumn::broadcast_changed(::rtl::OUString name, Any oldValue, Any newValue)
|
|
|
|
{
|
|
|
|
Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
|
|
|
|
GridColumnEvent aEvent( xSource, name, oldValue, newValue, m_nIndex);
|
|
|
|
broadcast( column_attribute_changed, aEvent);
|
|
|
|
}
|
2010-02-12 17:05:02 +01:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL GridColumn::updateColumn(const ::rtl::OUString& name, sal_Int32 width) throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
if(PREFWIDTH == name)
|
|
|
|
m_nPreferredWidth = width;
|
|
|
|
else if (COLWIDTH == name)
|
|
|
|
m_nColumnWidth = width;
|
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
broadcast_changed(UPDATE, Any(m_nColumnWidth), Any());
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
m_nColumnWidth = value;
|
|
|
|
broadcast_changed(COLWIDTH, Any(m_nColumnWidth),Any(value));
|
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
broadcast_changed(UPDATE, Any(m_nPreferredWidth), Any());
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
m_nPreferredWidth = value;
|
|
|
|
broadcast_changed(PREFWIDTH, Any(m_nPreferredWidth),Any(value));
|
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
m_nMaxWidth = value;
|
|
|
|
broadcast_changed(MAXWIDTH, Any(m_nMaxWidth),Any(value));
|
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
m_nMinWidth = value;
|
|
|
|
broadcast_changed(MINWIDTH, Any(m_nMinWidth),Any(value));
|
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
m_sTitle = value;
|
|
|
|
broadcast_changed(TITLE, Any(m_sTitle),Any(value));
|
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
m_bResizeable = value;
|
|
|
|
broadcast_changed(COLRESIZE, Any(m_bResizeable),Any(value));
|
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
m_eHorizontalAlign = align;
|
|
|
|
broadcast_changed(HALIGN, Any(m_eHorizontalAlign),Any(align));
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL GridColumn::addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
rBHelper.addListener( XGridColumnListener::static_type(), xListener );
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-12-07 13:50:47 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL GridColumn::removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|