sw/inc/unochart.hxx | 21 ++----- sw/source/core/unocore/unochart.cxx | 105 +++++++++++++----------------------- 2 files changed, 47 insertions(+), 79 deletions(-)
New commits: commit 827f4af430cbeb74ee03537e7a9c4dfcfff51c0f Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Jan 18 10:15:12 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Jan 18 17:21:13 2023 +0000 remove XUnoTunnel in SwChartDataSequence we can just use the concrete type, instead of casting Change-Id: I947b45eb454328390e077654bbf677f6a0fe8a89 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145740 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/inc/unochart.hxx b/sw/inc/unochart.hxx index e6373460f853..d56b3356da0a 100644 --- a/sw/inc/unochart.hxx +++ b/sw/inc/unochart.hxx @@ -22,7 +22,6 @@ #include <map> #include <set> -#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/chart2/data/XDataProvider.hpp> #include <com/sun/star/chart2/data/XDataSource.hpp> #include <com/sun/star/chart2/data/XDataSequence.hpp> @@ -90,6 +89,8 @@ public: void Disconnect(); }; +class SwChartDataSequence; + typedef cppu::WeakImplHelper < css::chart2::data::XDataProvider, @@ -107,14 +108,14 @@ class SwChartDataProvider final : // see set definition below... struct lt_DataSequenceRef { - bool operator()( css::uno::WeakReference< css::chart2::data::XDataSequence > xWRef1, css::uno::WeakReference< css::chart2::data::XDataSequence > xWRef2 ) const + bool operator()( const unotools::WeakReference< SwChartDataSequence > & xWRef1, const unotools::WeakReference< SwChartDataSequence >& xWRef2 ) const { - css::uno::Reference< css::chart2::data::XDataSequence > xRef1( xWRef1 ); - css::uno::Reference< css::chart2::data::XDataSequence > xRef2( xWRef2 ); + rtl::Reference< SwChartDataSequence > xRef1( xWRef1 ); + rtl::Reference< SwChartDataSequence > xRef2( xWRef2 ); return xRef1.get() < xRef2.get(); } }; - typedef std::set< css::uno::WeakReference < css::chart2::data::XDataSequence >, lt_DataSequenceRef > Set_DataSequenceRef_t; + typedef std::set< unotools::WeakReference < SwChartDataSequence >, lt_DataSequenceRef > Set_DataSequenceRef_t; // map of data-sequence sets for each table typedef std::map< const SwTable *, Set_DataSequenceRef_t > Map_Set_DataSequenceRef_t; @@ -171,8 +172,8 @@ public: virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; - void AddDataSequence( const SwTable &rTable, css::uno::Reference< css::chart2::data::XDataSequence > const &rxDataSequence ); - void RemoveDataSequence( const SwTable &rTable, css::uno::Reference< css::chart2::data::XDataSequence > const &rxDataSequence ); + void AddDataSequence( const SwTable &rTable, rtl::Reference< SwChartDataSequence > const &rxDataSequence ); + void RemoveDataSequence( const SwTable &rTable, rtl::Reference< SwChartDataSequence > const &rxDataSequence ); // will send modified events for all data-sequences of the table // tdf#122995 added Immediate-Mode to allow non-timer-delayed Chart invalidation @@ -221,7 +222,6 @@ typedef cppu::WeakImplHelper css::util::XCloneable, css::beans::XPropertySet, css::lang::XServiceInfo, - css::lang::XUnoTunnel, css::util::XModifiable, css::lang::XEventListener, css::lang::XComponent @@ -257,11 +257,6 @@ public: const std::shared_ptr<SwUnoCursor>& pTableCursor ); virtual ~SwChartDataSequence() override; - static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; - // XDataSequence virtual css::uno::Sequence< css::uno::Any > SAL_CALL getData() override; virtual OUString SAL_CALL getSourceRangeRepresentation() override; diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index 34af9f068002..14be7d0c711e 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -1403,12 +1403,12 @@ uno::Sequence< OUString > SAL_CALL SwChartDataProvider::getSupportedServiceNames return { "com.sun.star.chart2.data.DataProvider"}; } -void SwChartDataProvider::AddDataSequence( const SwTable &rTable, uno::Reference< chart2::data::XDataSequence > const &rxDataSequence ) +void SwChartDataProvider::AddDataSequence( const SwTable &rTable, rtl::Reference< SwChartDataSequence > const &rxDataSequence ) { m_aDataSequences[ &rTable ].insert( rxDataSequence ); } -void SwChartDataProvider::RemoveDataSequence( const SwTable &rTable, uno::Reference< chart2::data::XDataSequence > const &rxDataSequence ) +void SwChartDataProvider::RemoveDataSequence( const SwTable &rTable, rtl::Reference< SwChartDataSequence > const &rxDataSequence ) { m_aDataSequences[ &rTable ].erase( rxDataSequence ); } @@ -1423,10 +1423,9 @@ void SwChartDataProvider::InvalidateTable( const SwTable *pTable, bool bImmediat pTable->GetFrameFormat()->GetDoc()->getIDocumentChartDataProviderAccess().GetChartControllerHelper().StartOrContinueLocking(); const Set_DataSequenceRef_t &rSet = m_aDataSequences[ pTable ]; - for (const auto& rItem : rSet) + for (const unotools::WeakReference<SwChartDataSequence>& rItem : rSet) { - uno::Reference< chart2::data::XDataSequence > xTemp(rItem); // temporary needed for g++ 3.3.5 - uno::Reference< util::XModifiable > xRef( xTemp, uno::UNO_QUERY ); + rtl::Reference< SwChartDataSequence > xRef(rItem); if (xRef.is()) { // mark the sequence as 'dirty' and notify listeners @@ -1456,31 +1455,26 @@ void SwChartDataProvider::DeleteBox( const SwTable *pTable, const SwTableBox &rB Set_DataSequenceRef_t::iterator aDelIt; // iterator used for deletion when appropriate while (aIt != aEndIt) { - SwChartDataSequence *pDataSeq = nullptr; bool bNowEmpty = false; bool bSeqDisposed = false; // check if weak reference is still valid... - uno::Reference< chart2::data::XDataSequence > xTemp(*aIt); - if (xTemp.is()) + rtl::Reference< SwChartDataSequence > pDataSeq(*aIt); + if (pDataSeq.is()) { // then delete that table box (check if implementation cursor needs to be adjusted) - pDataSeq = static_cast< SwChartDataSequence * >( xTemp.get() ); - if (pDataSeq) + try { - try - { - bNowEmpty = pDataSeq->DeleteBox( rBox ); - } - catch (const lang::DisposedException&) - { - bNowEmpty = true; - bSeqDisposed = true; - } - - if (bNowEmpty) - aDelIt = aIt; + bNowEmpty = pDataSeq->DeleteBox( rBox ); } + catch (const lang::DisposedException&) + { + bNowEmpty = true; + bSeqDisposed = true; + } + + if (bNowEmpty) + aDelIt = aIt; } ++aIt; @@ -1508,10 +1502,9 @@ void SwChartDataProvider::DisposeAllDataSequences( const SwTable *pTable ) //! would become invalid. const Set_DataSequenceRef_t aSet( m_aDataSequences[ pTable ] ); - for (const auto& rItem : aSet) + for (const unotools::WeakReference<SwChartDataSequence>& rItem : aSet) { - uno::Reference< chart2::data::XDataSequence > xTemp(rItem); // temporary needed for g++ 3.3.5 - uno::Reference< lang::XComponent > xRef( xTemp, uno::UNO_QUERY ); + rtl::Reference< SwChartDataSequence > xRef(rItem); if (xRef.is()) { xRef->dispose(); @@ -1580,35 +1573,30 @@ void SwChartDataProvider::AddRowCols( // iterate over all data-sequences for the table const Set_DataSequenceRef_t &rSet = m_aDataSequences[ &rTable ]; - for (const auto& rItem : rSet) + for (const unotools::WeakReference<SwChartDataSequence>& rItem : rSet) { - uno::Reference< chart2::data::XDataSequence > xTemp(rItem); // temporary needed for g++ 3.3.5 - uno::Reference< chart2::data::XTextualDataSequence > xRef( xTemp, uno::UNO_QUERY ); - if (xRef.is()) + rtl::Reference< SwChartDataSequence > pDataSeq(rItem); + if (pDataSeq.is()) { - const sal_Int32 nLen = xRef->getTextualData().getLength(); + const sal_Int32 nLen = pDataSeq->getTextualData().getLength(); if (nLen > 1) // value data-sequence ? { - auto pDataSeq = comphelper::getFromUnoTunnel<SwChartDataSequence>(xRef); - if (pDataSeq) - { - SwRangeDescriptor aDesc; - pDataSeq->FillRangeDesc( aDesc ); + SwRangeDescriptor aDesc; + pDataSeq->FillRangeDesc( aDesc ); - chart::ChartDataRowSource eDRSource = chart::ChartDataRowSource_COLUMNS; - if (aDesc.nTop == aDesc.nBottom && aDesc.nLeft != aDesc.nRight) - eDRSource = chart::ChartDataRowSource_ROWS; + chart::ChartDataRowSource eDRSource = chart::ChartDataRowSource_COLUMNS; + if (aDesc.nTop == aDesc.nBottom && aDesc.nLeft != aDesc.nRight) + eDRSource = chart::ChartDataRowSource_ROWS; - if (!bAddCols && eDRSource == chart::ChartDataRowSource_COLUMNS) - { - // add rows: extend affected columns by newly added row cells - pDataSeq->ExtendTo( true, nFirstNewRow, nLines ); - } - else if (bAddCols && eDRSource == chart::ChartDataRowSource_ROWS) - { - // add cols: extend affected rows by newly added column cells - pDataSeq->ExtendTo( false, nFirstNewCol, nLines ); - } + if (!bAddCols && eDRSource == chart::ChartDataRowSource_COLUMNS) + { + // add rows: extend affected columns by newly added row cells + pDataSeq->ExtendTo( true, nFirstNewRow, nLines ); + } + else if (bAddCols && eDRSource == chart::ChartDataRowSource_ROWS) + { + // add cols: extend affected rows by newly added column cells + pDataSeq->ExtendTo( false, nFirstNewCol, nLines ); } } } @@ -1785,8 +1773,7 @@ SwChartDataSequence::SwChartDataSequence( const SwTable* pTable = SwTable::FindTable( &rTableFormat ); if (pTable) { - uno::Reference< chart2::data::XDataSequence > xRef(this); - m_xDataProvider->AddDataSequence( *pTable, xRef ); + m_xDataProvider->AddDataSequence( *pTable, this ); m_xDataProvider->addEventListener( static_cast< lang::XEventListener * >(this) ); } else { @@ -1832,8 +1819,7 @@ SwChartDataSequence::SwChartDataSequence( const SwChartDataSequence &rObj ) : const SwTable* pTable = SwTable::FindTable( GetFrameFormat() ); if (pTable) { - uno::Reference< chart2::data::XDataSequence > xRef(this); - m_xDataProvider->AddDataSequence( *pTable, xRef ); + m_xDataProvider->AddDataSequence( *pTable, this ); m_xDataProvider->addEventListener( static_cast< lang::XEventListener * >(this) ); } else { @@ -1862,18 +1848,6 @@ SwChartDataSequence::~SwChartDataSequence() { } -const uno::Sequence< sal_Int8 > & SwChartDataSequence::getUnoTunnelId() -{ - static const comphelper::UnoIdInit theSwChartDataSequenceUnoTunnelId; - return theSwChartDataSequenceUnoTunnelId.getSeq(); -} - -sal_Int64 SAL_CALL SwChartDataSequence::getSomething( const uno::Sequence< sal_Int8 > &rId ) -{ - return comphelper::getSomethingImpl(rId, this); -} - - OUString SAL_CALL SwChartDataSequence::getSourceRangeRepresentation( ) { SolarMutexGuard aGuard; @@ -2228,8 +2202,7 @@ void SAL_CALL SwChartDataSequence::dispose( ) const SwTable* pTable = SwTable::FindTable( GetFrameFormat() ); if (pTable) { - uno::Reference< chart2::data::XDataSequence > xRef(this); - m_xDataProvider->RemoveDataSequence( *pTable, xRef ); + m_xDataProvider->RemoveDataSequence( *pTable, this ); } else { OSL_FAIL( "table missing" );