summaryrefslogtreecommitdiff
path: root/toolkit/source/controls
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2011-01-10 15:48:16 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2011-01-10 15:48:16 +0100
commit858b82e990dee4558dbe3fe3c026d806f5acd524 (patch)
treefe1390674ef24ec85a1a4e4c750e80f59584661c /toolkit/source/controls
parent34f93e97f28bdfc6ee731fd7213588fe505cbd2f (diff)
gridsort: removed XGridColumn::setIndex - don't really want to have something like this at the public API
Diffstat (limited to 'toolkit/source/controls')
-rw-r--r--toolkit/source/controls/grid/defaultgridcolumnmodel.cxx18
-rw-r--r--toolkit/source/controls/grid/gridcolumn.cxx45
-rw-r--r--toolkit/source/controls/grid/gridcolumn.hxx15
3 files changed, 61 insertions, 17 deletions
diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx
index acd02f37db1c..d417a1432bd2 100644
--- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx
+++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx
@@ -127,12 +127,13 @@ namespace toolkit
{
::osl::ClearableMutexGuard aGuard( m_aMutex );
- if ( !i_column.is() )
- throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+ GridColumn* const pGridColumn = GridColumn::getImplementation( i_column );
+ if ( pGridColumn == NULL )
+ throw IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "invalid column implementation" ) ), *this, 1 );
m_aColumns.push_back( i_column );
sal_Int32 index = m_aColumns.size() - 1;
- i_column->setIndex( index );
+ pGridColumn->setIndex( index );
// fire insertion notifications
ContainerEvent aEvent;
@@ -154,7 +155,7 @@ namespace toolkit
if ( ( i_columnIndex < 0 ) || ( size_t( i_columnIndex ) >= m_aColumns.size() ) )
throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
- Columns::iterator pos = m_aColumns.begin() + i_columnIndex;
+ Columns::iterator const pos = m_aColumns.begin() + i_columnIndex;
Reference< XGridColumn > const xColumn( *pos );
m_aColumns.erase( pos );
@@ -212,12 +213,13 @@ namespace toolkit
// add new columns
for ( sal_Int32 i=0; i<rowElements; ++i )
{
- const Reference< XGridColumn > xColumn( m_aContext.createComponent( "com.sun.star.awt.grid.GridColumn" ), UNO_QUERY_THROW );
+ ::rtl::Reference< GridColumn > const pGridColumn = new GridColumn();
+ Reference< XGridColumn > const xColumn( pGridColumn.get() );
::rtl::OUStringBuffer colTitle;
colTitle.appendAscii( "Column " );
colTitle.append( i );
- xColumn->setTitle( colTitle.makeStringAndClear() );
- xColumn->setPreferredWidth( 80 /* APPFONT */ );
+ pGridColumn->setTitle( colTitle.makeStringAndClear() );
+ pGridColumn->setPreferredWidth( 80 /* APPFONT */ );
ContainerEvent aEvent;
aEvent.Source = *this;
@@ -226,7 +228,7 @@ namespace toolkit
aInsertedColumns.push_back( aEvent );
m_aColumns.push_back( xColumn );
- xColumn->setIndex( i );
+ pGridColumn->setIndex( i );
}
}
diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx
index cc0790beb651..711affab8017 100644
--- a/toolkit/source/controls/grid/gridcolumn.cxx
+++ b/toolkit/source/controls/grid/gridcolumn.cxx
@@ -29,6 +29,7 @@
#include "gridcolumn.hxx"
#include <comphelper/sequence.hxx>
+#include <cppuhelper/typeprovider.hxx>
#include <toolkit/helper/servicenames.hxx>
#define COLWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColWidth" ))
@@ -56,7 +57,7 @@ namespace toolkit
GridColumn::GridColumn()
:GridColumn_Base( m_aMutex )
,m_aIdentifier()
- ,m_nIndex(0)
+ ,m_nIndex(-1)
,m_nColumnWidth(4)
,m_nPreferredWidth(0)
,m_nMaxWidth(0)
@@ -71,7 +72,7 @@ namespace toolkit
:cppu::BaseMutex()
,GridColumn_Base( m_aMutex )
,m_aIdentifier( i_copySource.m_aIdentifier )
- ,m_nIndex( i_copySource.m_nIndex )
+ ,m_nIndex( -1 )
,m_nColumnWidth( i_copySource.m_nColumnWidth )
,m_nPreferredWidth( i_copySource.m_nPreferredWidth )
,m_nMaxWidth( i_copySource.m_nMaxWidth )
@@ -89,8 +90,8 @@ namespace toolkit
//------------------------------------------------------------------------------------------------------------------
void GridColumn::broadcast_changed( ::rtl::OUString name, Any i_oldValue, Any i_newValue, ::osl::ClearableMutexGuard& i_Guard )
{
- Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
- GridColumnEvent aEvent( xSource, name, i_oldValue, i_newValue, m_nIndex);
+ Reference< XInterface > const xSource( static_cast< ::cppu::OWeakObject* >( this ) );
+ GridColumnEvent const aEvent( xSource, name, i_oldValue, i_newValue, m_nIndex);
::cppu::OInterfaceContainerHelper* pIter = rBHelper.getContainer( XGridColumnListener::static_type() );
@@ -272,9 +273,17 @@ namespace toolkit
}
//------------------------------------------------------------------------------------------------------------------
- void SAL_CALL GridColumn::setIndex(sal_Int32 _nIndex) throw (::com::sun::star::uno::RuntimeException)
+ ::sal_Int32 SAL_CALL GridColumn::getIndex() throw (RuntimeException)
{
- m_nIndex = _nIndex;
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return m_nIndex;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void GridColumn::setIndex( sal_Int32 const i_index )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_nIndex = i_index;
}
//------------------------------------------------------------------------------------------------------------------
@@ -306,6 +315,30 @@ namespace toolkit
{
return new GridColumn( *this );
}
+
+ //------------------------------------------------------------------------------------------------------------------
+ sal_Int64 SAL_CALL GridColumn::getSomething( const Sequence< sal_Int8 >& i_identifier ) throw(RuntimeException)
+ {
+ if ( ( i_identifier.getLength() == 16 ) && ( i_identifier == getUnoTunnelId() ) )
+ return ::sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ) );
+ return 0;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Sequence< sal_Int8 > GridColumn::getUnoTunnelId() throw()
+ {
+ static ::cppu::OImplementationId const aId;
+ return aId.getImplementationId();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ GridColumn* GridColumn::getImplementation( const Reference< XInterface >& i_component )
+ {
+ Reference< XUnoTunnel > const xTunnel( i_component, UNO_QUERY );
+ if ( xTunnel.is() )
+ return reinterpret_cast< GridColumn* >( ::sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething( getUnoTunnelId() ) ) );
+ return NULL;
+ }
}
::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 >& )
diff --git a/toolkit/source/controls/grid/gridcolumn.hxx b/toolkit/source/controls/grid/gridcolumn.hxx
index a099e9c2c01d..89d6da0c8cd2 100644
--- a/toolkit/source/controls/grid/gridcolumn.hxx
+++ b/toolkit/source/controls/grid/gridcolumn.hxx
@@ -33,7 +33,7 @@
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
-#include <cppuhelper/compbase2.hxx>
+#include <cppuhelper/compbase3.hxx>
#include <cppuhelper/basemutex.hxx>
#include <rtl/ref.hxx>
#include <vector>
@@ -43,8 +43,9 @@
namespace toolkit
{
-typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::awt::grid::XGridColumn
+typedef ::cppu::WeakComponentImplHelper3 < ::com::sun::star::awt::grid::XGridColumn
, ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::lang::XUnoTunnel
> GridColumn_Base;
class GridColumn :public ::cppu::BaseMutex
,public GridColumn_Base
@@ -69,6 +70,7 @@ public:
virtual void SAL_CALL setResizeable(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getIndex() throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::style::HorizontalAlignment SAL_CALL getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setHorizontalAlign(::com::sun::star::style::HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL addGridColumnListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
@@ -87,7 +89,14 @@ public:
virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setIndex(sal_Int32 _nIndex)throw (::com::sun::star::uno::RuntimeException);
+ // XUnoTunnel and friends
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& i_identifier ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelId() throw();
+ static GridColumn* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& i_component );
+
+ // attribute access
+ void setIndex( sal_Int32 const i_index );
+
private:
void broadcast_changed(
::rtl::OUString name,