diff options
Diffstat (limited to 'chart2')
24 files changed, 150 insertions, 84 deletions
diff --git a/chart2/inc/ChartModel.hxx b/chart2/inc/ChartModel.hxx index 8c876d8b95e6..c8b34562e0b4 100644 --- a/chart2/inc/ChartModel.hxx +++ b/chart2/inc/ChartModel.hxx @@ -76,6 +76,7 @@ class ChartTypeTemplate; class InternalDataProvider; class NameContainer; class PageBackground; +class Title; namespace impl { @@ -167,8 +168,7 @@ private: // Diagram Access rtl::Reference< ::chart::Diagram > m_xDiagram; - css::uno::Reference< css::chart2::XTitle > - m_xTitle; + rtl::Reference< ::chart::Title > m_xTitle; rtl::Reference< ::chart::PageBackground > m_xPageBackground; @@ -475,6 +475,9 @@ public: const rtl::Reference< ::chart::ChartTypeManager > & getTypeManager() const { return m_xChartTypeManager; } + rtl::Reference< ::chart::Title > getTitleObject2() const; + void setTitleObject( const rtl::Reference< ::chart::Title >& Title ); + private: void dumpAsXml(xmlTextWriterPtr pWriter) const; diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx index 3a59015d9e67..594209d4fbf3 100644 --- a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx @@ -75,12 +75,12 @@ WrappedTitleStringProperty::WrappedTitleStringProperty( const Reference< uno::XC void WrappedTitleStringProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const { - Reference< chart2::XTitle > xTitle(xInnerPropertySet,uno::UNO_QUERY); - if(xTitle.is()) + Title* pTitle = dynamic_cast<Title*>(xInnerPropertySet.get()); + if(pTitle) { OUString aString; rOuterValue >>= aString; - TitleHelper::setCompleteString( aString, xTitle, m_xContext ); + TitleHelper::setCompleteString( aString, pTitle, m_xContext ); } } Any WrappedTitleStringProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const diff --git a/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx index 5493f0744700..2b047ebfaf82 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx @@ -287,7 +287,7 @@ Any WrappedAxisTitleExistenceProperty::getPropertyValue( const Reference< beans: { bool bHasTitle = false; - Reference< chart2::XTitle > xTitle( TitleHelper::getTitle( m_eTitleType, m_spChart2ModelContact->getDocumentModel() ) ); + rtl::Reference< Title > xTitle( TitleHelper::getTitle( m_eTitleType, m_spChart2ModelContact->getDocumentModel() ) ); if( xTitle.is() && !TitleHelper::getCompleteString( xTitle ).isEmpty() ) bHasTitle = true; diff --git a/chart2/source/controller/dialogs/ObjectNameProvider.cxx b/chart2/source/controller/dialogs/ObjectNameProvider.cxx index 2a2b2dcce89a..f3356724db53 100644 --- a/chart2/source/controller/dialogs/ObjectNameProvider.cxx +++ b/chart2/source/controller/dialogs/ObjectNameProvider.cxx @@ -410,9 +410,9 @@ OUString ObjectNameProvider::getTitleName( std::u16string_view rObjectCID { OUString aRet; - Reference< XTitle > xTitle( - ObjectIdentifier::getObjectPropertySet( rObjectCID , xChartModel ), uno::UNO_QUERY ); - if( xTitle.is() ) + rtl::Reference<Title> xTitle = + dynamic_cast<Title*>(ObjectIdentifier::getObjectPropertySet( rObjectCID , xChartModel ).get()); + if( xTitle ) { TitleHelper::eTitleType eType; if( TitleHelper::getTitleType( eType, xTitle, xChartModel ) ) diff --git a/chart2/source/controller/dialogs/TitleDialogData.cxx b/chart2/source/controller/dialogs/TitleDialogData.cxx index 2a8b74465a78..16b6820fded1 100644 --- a/chart2/source/controller/dialogs/TitleDialogData.cxx +++ b/chart2/source/controller/dialogs/TitleDialogData.cxx @@ -61,7 +61,7 @@ void TitleDialogData::readFromModel( const rtl::Reference<::chart::ChartModel>& nTitleIndex < +TitleHelper::NORMAL_TITLE_END; nTitleIndex++) { - uno::Reference< XTitle > xTitle = TitleHelper::getTitle( + rtl::Reference< Title > xTitle = TitleHelper::getTitle( static_cast< TitleHelper::eTitleType >( nTitleIndex ), xChartModel ); pExistenceList[nTitleIndex] = xTitle.is(); pTextList[nTitleIndex]=TitleHelper::getCompleteString( xTitle ); @@ -96,7 +96,7 @@ bool TitleDialogData::writeDifferenceToModel( else if( !pOldState || ( pOldState->aTextList[nN] != aTextList[nN] ) ) { //change content - uno::Reference< XTitle > xTitle( + rtl::Reference< Title > xTitle( TitleHelper::getTitle( static_cast< TitleHelper::eTitleType >( nN ), xChartModel ) ); if(xTitle.is()) { diff --git a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx index 5f460be987cd..558b028271bc 100644 --- a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx +++ b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx @@ -143,10 +143,10 @@ AllTitleItemConverter::AllTitleItemConverter( { for(sal_Int32 nTitle = TitleHelper::TITLE_BEGIN; nTitle < TitleHelper::NORMAL_TITLE_END; nTitle++ ) { - uno::Reference< chart2::XTitle > xTitle( TitleHelper::getTitle( TitleHelper::eTitleType(nTitle), xChartModel ) ); + rtl::Reference< Title > xTitle( TitleHelper::getTitle( TitleHelper::eTitleType(nTitle), xChartModel ) ); if(!xTitle.is()) continue; - uno::Reference< beans::XPropertySet > xObjectProperties( xTitle, uno::UNO_QUERY); + uno::Reference< beans::XPropertySet > xObjectProperties( xTitle ); m_aConverters.emplace_back( new ::chart::wrapper::TitleItemConverter( xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory, nullptr)); diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index 8902e85fec4d..9ffae0d2bebc 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -813,7 +813,7 @@ void ChartController::executeDispatch_InsertAxisTitle() { try { - uno::Reference< XTitle > xTitle; + rtl::Reference< Title > xTitle; { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( diff --git a/chart2/source/controller/main/ChartController_Properties.cxx b/chart2/source/controller/main/ChartController_Properties.cxx index 7f20576ab756..dad8b3f9f72d 100644 --- a/chart2/source/controller/main/ChartController_Properties.cxx +++ b/chart2/source/controller/main/ChartController_Properties.cxx @@ -352,7 +352,7 @@ OUString lcl_getTitleCIDForCommand( std::string_view rDispatchCommand, const rtl else if( rDispatchCommand == "SecondaryYTitle" ) nTitleType = TitleHelper::SECONDARY_Y_AXIS_TITLE; - uno::Reference< XTitle > xTitle( TitleHelper::getTitle( nTitleType, xChartModel ) ); + rtl::Reference< Title > xTitle( TitleHelper::getTitle( nTitleType, xChartModel ) ); return ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, xChartModel ); } diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx b/chart2/source/controller/main/ChartController_TextEdit.cxx index 07a35a533b0c..fbc8df4ed6b0 100644 --- a/chart2/source/controller/main/ChartController_TextEdit.cxx +++ b/chart2/source/controller/main/ChartController_TextEdit.cxx @@ -144,8 +144,8 @@ bool ChartController::EndTextEdit() // lock controllers till end of block ControllerLockGuardUNO aCLGuard( getChartModel() ); - TitleHelper::setCompleteString( aString, uno::Reference< - css::chart2::XTitle >::query( xPropSet ), m_xCC ); + Title* pTitle = dynamic_cast<Title*>(xPropSet.get()); + TitleHelper::setCompleteString( aString, pTitle, m_xCC ); OSL_ENSURE(m_pTextActionUndoGuard, "ChartController::EndTextEdit: no TextUndoGuard!"); if (m_pTextActionUndoGuard) diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index 20a0c2f6b3da..6240e241be8a 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -215,9 +215,9 @@ void ChartController::executeDispatch_NewArrangement() eType < TitleHelper::NORMAL_TITLE_END; ++eType ) { - Reference< beans::XPropertyState > xTitleState( + rtl::Reference< Title > xTitleState = TitleHelper::getTitle( - static_cast< TitleHelper::eTitleType >( eType ), xModel ), uno::UNO_QUERY ); + static_cast< TitleHelper::eTitleType >( eType ), xModel ); if( xTitleState.is()) xTitleState->setPropertyToDefault( "RelativePosition"); } diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 540cedb4d6fa..e993cdeb80f2 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -1195,7 +1195,7 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) bool bIsAxisVisible = AxisHelper::isAxisVisible( xAxis ); bool bIsMajorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, true /*bMainGrid*/, xDiagram ); bool bIsMinorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, false /*bMainGrid*/, xDiagram ); - bool bHasTitle = !TitleHelper::getCompleteString( xAxis->getTitleObject() ).isEmpty(); + bool bHasTitle = !TitleHelper::getCompleteString( xAxis->getTitleObject2() ).isEmpty(); if( eObjectType != OBJECTTYPE_AXIS && bIsAxisVisible ) lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatAxis" ); diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx index 3b9bac2cbfb9..01534405e0b7 100644 --- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx +++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx @@ -146,12 +146,11 @@ void setLegendOverlay(const css::uno::Reference<css::frame::XModel>& xModel, boo bool isTitleVisible(const rtl::Reference<::chart::ChartModel>& xModel, TitleHelper::eTitleType eTitle) { - css::uno::Reference<css::uno::XInterface> xTitle = TitleHelper::getTitle(eTitle, xModel); + rtl::Reference<Title> xTitle = TitleHelper::getTitle(eTitle, xModel); if (!xTitle.is()) return false; - css::uno::Reference<css::beans::XPropertySet> xPropSet(xTitle, css::uno::UNO_QUERY_THROW); - css::uno::Any aAny = xPropSet->getPropertyValue("Visible"); + css::uno::Any aAny = xTitle->getPropertyValue("Visible"); bool bVisible = aAny.get<bool>(); return bVisible; } diff --git a/chart2/source/inc/Axis.hxx b/chart2/source/inc/Axis.hxx index eecd9b4a1fca..db064e2d682b 100644 --- a/chart2/source/inc/Axis.hxx +++ b/chart2/source/inc/Axis.hxx @@ -31,6 +31,7 @@ namespace chart { +class Title; namespace impl { @@ -101,6 +102,9 @@ public: virtual void SAL_CALL removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + rtl::Reference< ::chart::Title > getTitleObject2() const; + void setTitleObject( const rtl::Reference< ::chart::Title >& xNewTitle ); + private: // ____ XModifyListener ____ virtual void SAL_CALL modified( @@ -126,7 +130,7 @@ private: css::uno::Sequence< css::uno::Reference< css::beans::XPropertySet > > m_aSubGridProperties; - css::uno::Reference< css::chart2::XTitle > m_xTitle; + rtl::Reference< ::chart::Title > m_xTitle; }; } // namespace chart diff --git a/chart2/source/inc/ObjectIdentifier.hxx b/chart2/source/inc/ObjectIdentifier.hxx index 00fd5a176d44..c6d0c724bd3c 100644 --- a/chart2/source/inc/ObjectIdentifier.hxx +++ b/chart2/source/inc/ObjectIdentifier.hxx @@ -112,6 +112,9 @@ public: const css::uno::Reference< css::uno::XInterface >& xObject , const rtl::Reference<::chart::ChartModel>& xChartModel ); static OUString createClassifiedIdentifierForObject( + const rtl::Reference< ::chart::Title >& xObject + , const rtl::Reference<::chart::ChartModel>& xChartModel ); + static OUString createClassifiedIdentifierForObject( const rtl::Reference< ::chart::Legend >& xObject , const rtl::Reference<::chart::ChartModel>& xChartModel ); static OUString createClassifiedIdentifierForObject( diff --git a/chart2/source/inc/Title.hxx b/chart2/source/inc/Title.hxx index 9fb7c2d100c6..2f21b6040232 100644 --- a/chart2/source/inc/Title.hxx +++ b/chart2/source/inc/Title.hxx @@ -40,7 +40,7 @@ typedef ::cppu::WeakImplHelper< Title_Base; } -class Title final : +class OOO_DLLPUBLIC_CHARTTOOLS Title final : public impl::Title_Base, public ::property::OPropertySet { @@ -58,7 +58,6 @@ public: /// merge XTypeProvider implementations DECLARE_XTYPEPROVIDER() -private: explicit Title( const Title & rOther ); // ____ OPropertySet ____ @@ -84,6 +83,8 @@ private: virtual void SAL_CALL removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override; +private: + // ____ XModifyListener ____ virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override; diff --git a/chart2/source/inc/TitleHelper.hxx b/chart2/source/inc/TitleHelper.hxx index 5eafa8bced23..ac9f9618799b 100644 --- a/chart2/source/inc/TitleHelper.hxx +++ b/chart2/source/inc/TitleHelper.hxx @@ -22,6 +22,7 @@ #include <rtl/ref.hxx> #include <rtl/ustring.hxx> #include "charttoolsdllapi.hxx" +#include "Title.hxx" namespace chart { class ChartModel; } namespace chart { class ReferenceSizeProvider; } @@ -52,23 +53,21 @@ public: TITLE_AT_STANDARD_Y_AXIS_POSITION //equals the X_AXIS_TITLE for barchart }; - static css::uno::Reference< css::chart2::XTitle > + static rtl::Reference< ::chart::Title > getTitle( eTitleType nTitleIndex , ChartModel& rModel ); - static css::uno::Reference< css::chart2::XTitle > + static rtl::Reference< ::chart::Title > getTitle( eTitleType nTitleIndex , const rtl::Reference< ::chart::ChartModel >& xModel ); - static css::uno::Reference< - css::chart2::XTitle > + static rtl::Reference< ::chart::Title > createTitle( eTitleType nTitleIndex , const OUString& rTitleText , const rtl::Reference< ::chart::ChartModel >& xModel , const css::uno::Reference< css::uno::XComponentContext > & xContext , ReferenceSizeProvider * pRefSizeProvider = nullptr ); - static css::uno::Reference< - css::chart2::XTitle > + static rtl::Reference< ::chart::Title > createOrShowTitle( eTitleType nTitleIndex , const OUString& rTitleText , const rtl::Reference< ::chart::ChartModel >& xModel @@ -77,14 +76,14 @@ public: static void removeTitle( eTitleType nTitleIndex , const rtl::Reference< ::chart::ChartModel >& xModel ); - static OUString getCompleteString( const css::uno::Reference< css::chart2::XTitle >& xTitle ); + static OUString getCompleteString( const rtl::Reference< ::chart::Title >& xTitle ); static void setCompleteString( const OUString& rNewText - , const css::uno::Reference< css::chart2::XTitle >& xTitle + , const rtl::Reference< ::chart::Title >& xTitle , const css::uno::Reference< css::uno::XComponentContext > & xContext , const float * pDefaultCharHeight = nullptr ); static bool getTitleType( eTitleType& rType - , const css::uno::Reference< css::chart2::XTitle >& xTitle + , const rtl::Reference< ::chart::Title >& xTitle , const rtl::Reference< ::chart::ChartModel >& xModel ); static void hideTitle( eTitleType nTitleIndex, const rtl::Reference< ::chart::ChartModel > & xModel); diff --git a/chart2/source/model/main/Axis.cxx b/chart2/source/model/main/Axis.cxx index 0f8715011b92..f00455f51c4f 100644 --- a/chart2/source/model/main/Axis.cxx +++ b/chart2/source/model/main/Axis.cxx @@ -27,6 +27,7 @@ #include <AxisHelper.hxx> #include <EventListenerHelper.hxx> #include <ModifyListenerHelper.hxx> +#include <Title.hxx> #include <unonames.hxx> #include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp> @@ -356,7 +357,8 @@ Axis::Axis( const Axis & rOther ) : lcl_CloneSubGrids( rOther.m_aSubGridProperties, m_aSubGridProperties ); ModifyListenerHelper::addListenerToAllSequenceElements( m_aSubGridProperties, m_xModifyEventForwarder ); - m_xTitle.set( CloneHelper::CreateRefClone< chart2::XTitle >()( rOther.m_xTitle )); + if ( rOther.m_xTitle ) + m_xTitle = new Title( *rOther.m_xTitle ); if( m_xTitle.is()) ModifyListenerHelper::addListener( m_xTitle, m_xModifyEventForwarder ); } @@ -494,10 +496,23 @@ Reference< chart2::XTitle > SAL_CALL Axis::getTitleObject() return m_xTitle; } +rtl::Reference< Title > Axis::getTitleObject2() const +{ + MutexGuard aGuard( m_aMutex ); + return m_xTitle; +} + void SAL_CALL Axis::setTitleObject( const Reference< chart2::XTitle >& xNewTitle ) { + rtl::Reference<Title> xTitle = dynamic_cast<Title*>(xNewTitle.get()); + assert(!xNewTitle || xTitle); + setTitleObject(xTitle); +} + +void Axis::setTitleObject( const rtl::Reference< Title >& xNewTitle ) +{ Reference< util::XModifyListener > xModifyEventForwarder; - Reference< chart2::XTitle > xOldTitle; + rtl::Reference< Title > xOldTitle; { MutexGuard aGuard( m_aMutex ); xOldTitle = m_xTitle; diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 56a143548ab3..b56dc1d74981 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -151,7 +151,9 @@ ChartModel::ChartModel( const ChartModel & rOther ) m_xOldModelAgg->setDelegator( *this ); Reference< util::XModifyListener > xListener; - Reference< chart2::XTitle > xNewTitle = CreateRefClone< chart2::XTitle >()( rOther.m_xTitle ); + rtl::Reference< Title > xNewTitle; + if ( rOther.m_xTitle ) + xNewTitle = new Title(*rOther.m_xTitle); rtl::Reference< ::chart::Diagram > xNewDiagram; if (rOther.m_xDiagram.is()) xNewDiagram = new ::chart::Diagram( *rOther.m_xDiagram ); @@ -540,7 +542,7 @@ void SAL_CALL ChartModel::dispose() m_xOwnNumberFormatsSupplier.clear(); m_xChartTypeManager.clear(); m_xDiagram.clear(); - DisposeHelper::DisposeAndClear( m_xTitle ); + m_xTitle.clear(); m_xPageBackground.clear(); m_xXMLNamespaceMap.clear(); @@ -928,7 +930,20 @@ uno::Reference< chart2::XTitle > SAL_CALL ChartModel::getTitleObject() return m_xTitle; } -void SAL_CALL ChartModel::setTitleObject( const uno::Reference< chart2::XTitle >& xTitle ) +rtl::Reference< Title > ChartModel::getTitleObject2() const +{ + MutexGuard aGuard( m_aModelMutex ); + return m_xTitle; +} + +void SAL_CALL ChartModel::setTitleObject( const uno::Reference< chart2::XTitle >& xNewTitle ) +{ + rtl::Reference<Title> xTitle = dynamic_cast<Title*>(xNewTitle.get()); + assert(!xNewTitle || xTitle); + setTitleObject(xTitle); +} + +void ChartModel::setTitleObject( const rtl::Reference< Title >& xTitle ) { { MutexGuard aGuard( m_aModelMutex ); 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 ); diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index db742930ce29..fdc75aa155e0 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -1072,7 +1072,7 @@ std::shared_ptr<VTitle> lcl_createTitle( TitleHelper::eTitleType eType nXDistance = 450; // 1/100 mm } - uno::Reference< XTitle > xTitle( TitleHelper::getTitle( eType, rModel ) ); + rtl::Reference< Title > xTitle( TitleHelper::getTitle( eType, rModel ) ); OUString aCompleteString = TitleHelper::getCompleteString(xTitle); if (aCompleteString.isEmpty() || !VTitle::isVisible(xTitle)) return apVTitle; @@ -1109,8 +1109,7 @@ std::shared_ptr<VTitle> lcl_createTitle( TitleHelper::eTitleType eType rbAutoPosition = true; awt::Point aNewPosition(0,0); chart2::RelativePosition aRelativePosition; - uno::Reference<beans::XPropertySet> xProp(xTitle, uno::UNO_QUERY); - if (xProp.is() && (xProp->getPropertyValue("RelativePosition") >>= aRelativePosition)) + if (xTitle.is() && (xTitle->getPropertyValue("RelativePosition") >>= aRelativePosition)) { rbAutoPosition = false; diff --git a/chart2/source/view/main/ExplicitValueProvider.cxx b/chart2/source/view/main/ExplicitValueProvider.cxx index fc1307fe8820..3479bd3f703b 100644 --- a/chart2/source/view/main/ExplicitValueProvider.cxx +++ b/chart2/source/view/main/ExplicitValueProvider.cxx @@ -120,13 +120,13 @@ awt::Rectangle ExplicitValueProvider::AddSubtractAxisTitleSizes( awt::Rectangle aRet(rPositionAndSize); //add axis title sizes to the diagram size - uno::Reference<chart2::XTitle> xTitle_Height( + rtl::Reference<::chart::Title> xTitle_Height( TitleHelper::getTitle(TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION, rModel)); - uno::Reference<chart2::XTitle> xTitle_Width( + rtl::Reference<::chart::Title> xTitle_Width( TitleHelper::getTitle(TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION, rModel)); - uno::Reference<chart2::XTitle> xSecondTitle_Height( + rtl::Reference<::chart::Title> xSecondTitle_Height( TitleHelper::getTitle(TitleHelper::SECONDARY_X_AXIS_TITLE, rModel)); - uno::Reference<chart2::XTitle> xSecondTitle_Width( + rtl::Reference<::chart::Title> xSecondTitle_Width( TitleHelper::getTitle(TitleHelper::SECONDARY_Y_AXIS_TITLE, rModel)); if (xTitle_Height.is() || xTitle_Width.is() || xSecondTitle_Height.is() || xSecondTitle_Width.is()) diff --git a/chart2/source/view/main/VTitle.cxx b/chart2/source/view/main/VTitle.cxx index ddc97dde6406..e820e75f9c8b 100644 --- a/chart2/source/view/main/VTitle.cxx +++ b/chart2/source/view/main/VTitle.cxx @@ -20,6 +20,7 @@ #include "VTitle.hxx" #include <CommonConverters.hxx> #include <ShapeFactory.hxx> +#include <Title.hxx> #include <com/sun/star/chart2/XTitle.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <utility> @@ -91,6 +92,19 @@ void VTitle::changePosition( const awt::Point& rPos ) } } +bool VTitle::isVisible(const rtl::Reference< Title >& xTitle) { + if (!xTitle.is()) { + return false; + } + bool bShow = true; + try { + xTitle->getPropertyValue("Visible") >>= bShow; + } catch (const uno::Exception &) { + DBG_UNHANDLED_EXCEPTION("chart2"); + } + return bShow; +} + bool VTitle::isVisible(const uno::Reference< XTitle >& xTitle) { if (!xTitle.is()) { return false; diff --git a/chart2/source/view/main/VTitle.hxx b/chart2/source/view/main/VTitle.hxx index 3db5461f3c5b..a0c999dae957 100644 --- a/chart2/source/view/main/VTitle.hxx +++ b/chart2/source/view/main/VTitle.hxx @@ -34,6 +34,7 @@ class SvxShapeText; namespace chart { +class Title; class VTitle final { @@ -55,6 +56,8 @@ public: void changePosition( const css::awt::Point& rPos ); static bool isVisible( const css::uno::Reference< css::chart2::XTitle > & xTitle); + static bool isVisible( + const rtl::Reference< ::chart::Title > & xTitle); private: rtl::Reference<SvxShapeGroupAnyD> m_xTarget; |