summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-01-13 15:20:34 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-01-16 06:42:12 +0000
commit0160109aae49189f5cc9bed60db3c7084003e471 (patch)
tree16f9bf6ff40926049a48ac2a956cf4cc97e40d58 /toolkit
parent8a1108a0c7bf8e531d9771a5ca29a81a2aeea167 (diff)
XUnoTunnel->dynamic_cast in GridColumn
And use the concrete type in DefaultGridColumnModel, which already makes such an assumption Change-Id: I4c91d46f1889ebe22b6c031a8aabe4e8957addec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145531 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/source/controls/grid/defaultgridcolumnmodel.cxx37
-rw-r--r--toolkit/source/controls/grid/gridcolumn.cxx13
-rw-r--r--toolkit/source/controls/grid/gridcolumn.hxx6
3 files changed, 11 insertions, 45 deletions
diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx
index 87b55be96ee2..64cf2a61b3e2 100644
--- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx
+++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx
@@ -85,7 +85,7 @@ public:
virtual void SAL_CALL disposing() override;
private:
- typedef ::std::vector< css::uno::Reference< css::awt::grid::XGridColumn > > Columns;
+ typedef ::std::vector< rtl::Reference< GridColumn > > Columns;
::comphelper::OInterfaceContainerHelper3<XContainerListener> m_aContainerListeners;
Columns m_aColumns;
@@ -111,16 +111,9 @@ private:
++col
)
{
- Reference< css::util::XCloneable > const xCloneable( *col, UNO_QUERY_THROW );
- Reference< XGridColumn > const xClone( xCloneable->createClone(), UNO_QUERY_THROW );
+ rtl::Reference< GridColumn > const xClone( new GridColumn(**col) );
- GridColumn* const pGridColumn = comphelper::getFromUnoTunnel<GridColumn>( xClone );
- if ( pGridColumn == nullptr )
- throw RuntimeException( "invalid clone source implementation", *this );
- // that's indeed a RuntimeException, not an IllegalArgumentException or some such:
- // a DefaultGridColumnModel implementation whose columns are not GridColumn implementations
- // is borked.
- pGridColumn->setIndex( col - i_copySource.m_aColumns.begin() );
+ xClone->setIndex( col - i_copySource.m_aColumns.begin() );
aColumns.push_back( xClone );
}
@@ -150,11 +143,11 @@ private:
{
::comphelper::ComponentGuard aGuard( *this, rBHelper );
- GridColumn* const pGridColumn = comphelper::getFromUnoTunnel<GridColumn>( i_column );
+ GridColumn* const pGridColumn = dynamic_cast<GridColumn*>( i_column.get() );
if ( pGridColumn == nullptr )
throw css::lang::IllegalArgumentException( "invalid column implementation", *this, 1 );
- m_aColumns.push_back( i_column );
+ m_aColumns.push_back( pGridColumn );
sal_Int32 index = m_aColumns.size() - 1;
pGridColumn->setIndex( index );
@@ -189,13 +182,7 @@ private:
++updatePos, ++columnIndex
)
{
- GridColumn* pColumnImpl = comphelper::getFromUnoTunnel<GridColumn>( *updatePos );
- if ( !pColumnImpl )
- {
- SAL_WARN( "toolkit.controls", "DefaultGridColumnModel::removeColumn: invalid column implementation!" );
- continue;
- }
-
+ GridColumn* pColumnImpl = updatePos->get();
pColumnImpl->setIndex( columnIndex );
}
@@ -223,7 +210,7 @@ private:
Sequence< Reference< XGridColumn > > SAL_CALL DefaultGridColumnModel::getColumns()
{
::comphelper::ComponentGuard aGuard( *this, rBHelper );
- return ::comphelper::containerToSequence( m_aColumns );
+ return ::comphelper::containerToSequence<Reference<XGridColumn>>( m_aColumns );
}
@@ -254,7 +241,7 @@ private:
ContainerEvent aEvent;
aEvent.Source = *this;
aEvent.Accessor <<= sal_Int32( lastColIndex );
- aEvent.Element <<= m_aColumns[ lastColIndex ];
+ aEvent.Element <<= Reference<XGridColumn>(m_aColumns[ lastColIndex ]);
aRemovedColumns.push_back( aEvent );
m_aColumns.erase( m_aColumns.begin() + lastColIndex );
@@ -264,7 +251,6 @@ private:
for ( sal_Int32 i=0; i<rowElements; ++i )
{
::rtl::Reference< GridColumn > const pGridColumn = new GridColumn();
- Reference< XGridColumn > const xColumn( pGridColumn );
OUString colTitle = "Column " + OUString::number( i + 1 );
pGridColumn->setTitle( colTitle );
pGridColumn->setColumnWidth( 80 /* APPFONT */ );
@@ -275,10 +261,10 @@ private:
ContainerEvent aEvent;
aEvent.Source = *this;
aEvent.Accessor <<= i;
- aEvent.Element <<= xColumn;
+ aEvent.Element <<= Reference<XGridColumn>(pGridColumn);
aInsertedColumns.push_back( aEvent );
- m_aColumns.push_back( xColumn );
+ m_aColumns.push_back( pGridColumn );
pGridColumn->setIndex( i );
}
}
@@ -355,8 +341,7 @@ private:
{
try
{
- const Reference< XComponent > xColComponent( m_aColumns[ 0 ], UNO_QUERY_THROW );
- xColComponent->dispose();
+ m_aColumns[ 0 ]->dispose();
}
catch( const Exception& )
{
diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx
index 11a03e647236..9a0b515b6229 100644
--- a/toolkit/source/controls/grid/gridcolumn.cxx
+++ b/toolkit/source/controls/grid/gridcolumn.cxx
@@ -274,19 +274,6 @@ namespace toolkit
{
return new GridColumn( *this );
}
-
-
- sal_Int64 SAL_CALL GridColumn::getSomething( const Sequence< sal_Int8 >& i_identifier )
- {
- return comphelper::getSomethingImpl(i_identifier, this);
- }
-
-
- const Sequence< sal_Int8 > & GridColumn::getUnoTunnelId() noexcept
- {
- static const comphelper::UnoIdInit aId;
- return aId.getSeq();
- }
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
diff --git a/toolkit/source/controls/grid/gridcolumn.hxx b/toolkit/source/controls/grid/gridcolumn.hxx
index 8008c077d867..9d79e85f14ed 100644
--- a/toolkit/source/controls/grid/gridcolumn.hxx
+++ b/toolkit/source/controls/grid/gridcolumn.hxx
@@ -22,7 +22,6 @@
#include <com/sun/star/awt/grid/XGridColumn.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/style/HorizontalAlignment.hpp>
#include <comphelper/compbase.hxx>
@@ -33,7 +32,6 @@ namespace toolkit
typedef comphelper::WeakComponentImplHelper < css::awt::grid::XGridColumn
, css::lang::XServiceInfo
- , css::lang::XUnoTunnel
> GridColumn_Base;
class GridColumn final : public GridColumn_Base
{
@@ -78,10 +76,6 @@ public:
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
- // XUnoTunnel and friends
- virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& i_identifier ) override;
- static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId() noexcept;
-
// attribute access
void setIndex( sal_Int32 const i_index );