diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-03-22 12:22:09 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-03-22 19:58:38 +0000 |
commit | 6f59baf135f42f9c281148184b1b1f16e3902442 (patch) | |
tree | a852f1c3d1ac40af472671f3aa798b9b05ae162e /chart2/source/tools | |
parent | f6da444a9e2b239d8905d6cdb845c7be8d8ce66f (diff) |
use more concrete type in chart2
Change-Id: If67a4f0fe75554e14c3030c68374607b76d5b840
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149336
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/source/tools')
-rw-r--r-- | chart2/source/tools/ObjectIdentifier.cxx | 39 | ||||
-rw-r--r-- | chart2/source/tools/TitleHelper.cxx | 46 |
2 files changed, 48 insertions, 37 deletions
diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx index b72ac1c1f1d0..587aace2f3d8 100644 --- a/chart2/source/tools/ObjectIdentifier.cxx +++ b/chart2/source/tools/ObjectIdentifier.cxx @@ -288,6 +288,25 @@ bool ObjectIdentifier::operator<( const ObjectIdentifier& rOID ) const } OUString ObjectIdentifier::createClassifiedIdentifierForObject( + const rtl::Reference< ::chart::Title >& xTitle + , const rtl::Reference<::chart::ChartModel>& xChartModel ) +{ + TitleHelper::eTitleType aTitleType; + OUString aRet; + const std::u16string_view aObjectID; + const std::u16string_view aDragMethodServiceName; + const std::u16string_view aDragParameterString; + if( TitleHelper::getTitleType( aTitleType, xTitle, xChartModel ) ) + { + enum ObjectType eObjectType = OBJECTTYPE_TITLE; + OUString aParentParticle = lcl_getTitleParentParticle( aTitleType ); + aRet = ObjectIdentifier::createClassifiedIdentifierWithParent( + eObjectType, aObjectID, aParentParticle, aDragMethodServiceName, aDragParameterString ); + } + return aRet; +} + +OUString ObjectIdentifier::createClassifiedIdentifierForObject( const Reference< uno::XInterface >& xObject , const rtl::Reference<::chart::ChartModel>& xChartModel ) { @@ -302,20 +321,8 @@ OUString ObjectIdentifier::createClassifiedIdentifierForObject( try { //title - Reference< XTitle > xTitle( xObject, uno::UNO_QUERY ); - if( xTitle.is() ) - { - TitleHelper::eTitleType aTitleType; - if( TitleHelper::getTitleType( aTitleType, xTitle, xChartModel ) ) - { - eObjectType = OBJECTTYPE_TITLE; - aParentParticle = lcl_getTitleParentParticle( aTitleType ); - aRet = ObjectIdentifier::createClassifiedIdentifierWithParent( - eObjectType, aObjectID, aParentParticle, aDragMethodServiceName, aDragParameterString ); - } - return aRet; - - } + if( ::chart::Title* pTitle = dynamic_cast<::chart::Title*>(xObject.get()) ) + return createClassifiedIdentifierForObject(rtl::Reference<Title>(pTitle), xChartModel); uno::Reference<chart2::XDataTable> xDataTable(xObject, uno::UNO_QUERY); if (xDataTable.is()) @@ -1113,8 +1120,8 @@ Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet( case OBJECTTYPE_TITLE: { TitleHelper::eTitleType aTitleType = getTitleTypeForCID( rObjectCID ); - Reference< XTitle > xTitle( TitleHelper::getTitle( aTitleType, xChartModel ) ); - xObjectProperties.set( xTitle, uno::UNO_QUERY ); + rtl::Reference< Title > xTitle( TitleHelper::getTitle( aTitleType, xChartModel ) ); + xObjectProperties = xTitle; } break; case OBJECTTYPE_LEGEND: diff --git a/chart2/source/tools/TitleHelper.cxx b/chart2/source/tools/TitleHelper.cxx index cbc3543dc78e..f84298ab8c4d 100644 --- a/chart2/source/tools/TitleHelper.cxx +++ b/chart2/source/tools/TitleHelper.cxx @@ -139,20 +139,23 @@ uno::Reference< XTitled > lcl_getTitleParent( TitleHelper::eTitleType nTitleInde } -uno::Reference< XTitle > TitleHelper::getTitle( TitleHelper::eTitleType nTitleIndex +rtl::Reference< Title > TitleHelper::getTitle( TitleHelper::eTitleType nTitleIndex , ChartModel& rModel ) { if(nTitleIndex == TitleHelper::MAIN_TITLE) - return rModel.getTitleObject(); + return rModel.getTitleObject2(); rtl::Reference< Diagram > xDiagram = rModel.getFirstChartDiagram(); uno::Reference< XTitled > xTitled( lcl_getTitleParent( nTitleIndex, xDiagram ) ); - if( xTitled.is()) - return xTitled->getTitleObject(); - return nullptr; + if( !xTitled ) + return nullptr; + uno::Reference<XTitle> xTitle = xTitled->getTitleObject(); + auto pTitle = dynamic_cast<Title*>(xTitle.get()); + assert(!xTitle || pTitle); + return pTitle; } -uno::Reference< XTitle > TitleHelper::getTitle( TitleHelper::eTitleType nTitleIndex +rtl::Reference< Title > TitleHelper::getTitle( TitleHelper::eTitleType nTitleIndex , const rtl::Reference<ChartModel>& xModel ) { uno::Reference< XTitled > xTitled; @@ -167,22 +170,24 @@ uno::Reference< XTitle > TitleHelper::getTitle( TitleHelper::eTitleType nTitleIn xDiagram = xModel->getFirstChartDiagram(); xTitled = lcl_getTitleParent( nTitleIndex, xDiagram ); } - if( xTitled.is()) - return xTitled->getTitleObject(); - return nullptr; + if( !xTitled ) + return nullptr; + uno::Reference<XTitle> xTitle = xTitled->getTitleObject(); + Title* pTitle = dynamic_cast<Title*>(xTitle.get()); + assert(!xTitle || pTitle); + return pTitle; } -uno::Reference< XTitle > TitleHelper::createOrShowTitle( +rtl::Reference< Title > TitleHelper::createOrShowTitle( TitleHelper::eTitleType eTitleType , const OUString& rTitleText , const rtl::Reference<ChartModel>& xModel , const uno::Reference< uno::XComponentContext > & xContext ) { - uno::Reference< chart2::XTitle > xTitled( TitleHelper::getTitle( eTitleType, xModel ) ); + rtl::Reference< Title > xTitled( TitleHelper::getTitle( eTitleType, xModel ) ); if( xTitled.is()) { - css::uno::Reference<css::beans::XPropertySet> xProps(xTitled, css::uno::UNO_QUERY_THROW); - xProps->setPropertyValue("Visible",css::uno::Any(true)); + xTitled->setPropertyValue("Visible",css::uno::Any(true)); return xTitled; } else @@ -191,7 +196,7 @@ uno::Reference< XTitle > TitleHelper::createOrShowTitle( } } -uno::Reference< XTitle > TitleHelper::createTitle( +rtl::Reference< Title > TitleHelper::createTitle( TitleHelper::eTitleType eTitleType , const OUString& rTitleText , const rtl::Reference<ChartModel>& xModel @@ -289,7 +294,7 @@ uno::Reference< XTitle > TitleHelper::createTitle( } -OUString TitleHelper::getCompleteString( const uno::Reference< XTitle >& xTitle ) +OUString TitleHelper::getCompleteString( const rtl::Reference< Title >& xTitle ) { if(!xTitle.is()) return OUString(); @@ -301,7 +306,7 @@ OUString TitleHelper::getCompleteString( const uno::Reference< XTitle >& xTitle } void TitleHelper::setCompleteString( const OUString& rNewText - , const uno::Reference< XTitle >& xTitle + , const rtl::Reference< Title >& xTitle , const uno::Reference< uno::XComponentContext > & xContext , const float * pDefaultCharHeight /* = 0 */ ) { @@ -312,9 +317,8 @@ void TitleHelper::setCompleteString( const OUString& rNewText OUString aNewText = rNewText; bool bStacked = false; - uno::Reference< beans::XPropertySet > xTitleProperties( xTitle, uno::UNO_QUERY ); - if( xTitleProperties.is() ) - xTitleProperties->getPropertyValue( "StackCharacters" ) >>= bStacked; + if( xTitle.is() ) + xTitle->getPropertyValue( "StackCharacters" ) >>= bStacked; if( bStacked ) { @@ -384,13 +388,13 @@ void TitleHelper::removeTitle( TitleHelper::eTitleType nTitleIndex } bool TitleHelper::getTitleType( eTitleType& rType - , const css::uno::Reference< css::chart2::XTitle >& xTitle + , const rtl::Reference< Title >& xTitle , const rtl::Reference<ChartModel>& xModel ) { if( !xTitle.is() || !xModel.is() ) return false; - Reference< chart2::XTitle > xCurrentTitle; + rtl::Reference< Title > xCurrentTitle; for( sal_Int32 nTitleType = TITLE_BEGIN; nTitleType < NORMAL_TITLE_END; nTitleType++ ) { xCurrentTitle = TitleHelper::getTitle( static_cast<eTitleType>(nTitleType), xModel ); |