diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-19 10:04:48 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-19 11:38:51 +0100 |
commit | 4ab36ed96f9dce18bad751c67bb447d3783f3aba (patch) | |
tree | 938a87660a12a5826b0eb95862b32d72143e00cd /chart2 | |
parent | a27296ded79e9eb8fa325ea05fcd560d171cabbd (diff) |
use more concrete types in chart2, ChartModel
Change-Id: I36b6ac63ce62e0eb0e9bec951d582f39aed3be25
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128592
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
32 files changed, 341 insertions, 366 deletions
diff --git a/chart2/source/controller/inc/ChartController.hxx b/chart2/source/controller/inc/ChartController.hxx index 451a3bfe9a52..01019e39473e 100644 --- a/chart2/source/controller/inc/ChartController.hxx +++ b/chart2/source/controller/inc/ChartController.hxx @@ -336,24 +336,24 @@ public: css::uno::Reference<css::uno::XInterface> const & getChartView() const; + rtl::Reference<::chart::ChartModel> getChartModel(); + private: class TheModel : public salhelper::SimpleReferenceObject { public: - explicit TheModel( const css::uno::Reference< - css::frame::XModel > & xModel ); + explicit TheModel( const rtl::Reference<::chart::ChartModel> & xModel ); virtual ~TheModel() override; void addListener( ChartController* pController ); void removeListener( ChartController* pController ); void tryTermination(); - const css::uno::Reference< css::frame::XModel >& + const rtl::Reference<::chart::ChartModel>& getModel() const { return m_xModel;} private: - css::uno::Reference< css::frame::XModel > m_xModel; - css::uno::Reference< css::util::XCloseable > m_xCloseable; + rtl::Reference<::chart::ChartModel> m_xModel; //the ownership between model and controller is not clear at first //each controller might consider himself as owner of the model first diff --git a/chart2/source/controller/inc/CommandDispatchContainer.hxx b/chart2/source/controller/inc/CommandDispatchContainer.hxx index 1ed026597d73..ae95313c0f20 100644 --- a/chart2/source/controller/inc/CommandDispatchContainer.hxx +++ b/chart2/source/controller/inc/CommandDispatchContainer.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include <cppuhelper/weakref.hxx> +#include <unotools/weakref.hxx> #include <o3tl/sorted_vector.hxx> #include <map> @@ -33,7 +33,7 @@ namespace com::sun::star::util { struct URL; } namespace chart { - +class ChartModel; class DrawCommandDispatch; class ShapeController; @@ -73,7 +73,7 @@ public: const css::uno::Reference< css::uno::XComponentContext > & xContext ); void setModel( - const css::uno::Reference< css::frame::XModel > & xModel ); + const rtl::Reference<::chart::ChartModel> & xModel ); /** Set a chart dispatcher that is used for all commands contained in rChartCommands @@ -122,7 +122,7 @@ private: mutable tDisposeVector m_aToBeDisposedDispatches; css::uno::Reference< css::uno::XComponentContext > m_xContext; - css::uno::WeakReference< css::frame::XModel > m_xModel; + unotools::WeakReference< ::chart::ChartModel > m_xModel; css::uno::Reference< css::frame::XDispatch > m_xChartDispatcher; o3tl::sorted_vector< OUString > m_aChartCommands; diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 19c314da2635..751afe7f30ee 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -122,12 +122,10 @@ ChartController::~ChartController() stopDoubleClickWaiting(); } -ChartController::TheModel::TheModel( const uno::Reference< frame::XModel > & xModel ) : +ChartController::TheModel::TheModel( const rtl::Reference<::chart::ChartModel> & xModel ) : m_xModel( xModel ), m_bOwnership( true ) { - m_xCloseable = - uno::Reference< util::XCloseable >( xModel, uno::UNO_QUERY ); } ChartController::TheModel::~TheModel() @@ -136,33 +134,22 @@ ChartController::TheModel::~TheModel() void ChartController::TheModel::addListener( ChartController* pController ) { - if(m_xCloseable.is()) + if(m_xModel) { //if you need to be able to veto against the destruction of the model // you must add as a close listener //otherwise you 'can' add as closelistener or 'must' add as dispose event listener - m_xCloseable->addCloseListener( + m_xModel->addCloseListener( static_cast<util::XCloseListener*>(pController) ); } - else if( m_xModel.is() ) - { - //we need to add as dispose event listener - m_xModel->addEventListener( - static_cast<util::XCloseListener*>(pController) ); - } - } void ChartController::TheModel::removeListener( ChartController* pController ) { - if(m_xCloseable.is()) - m_xCloseable->removeCloseListener( - static_cast<util::XCloseListener*>(pController) ); - - else if( m_xModel.is() ) - m_xModel->removeEventListener( + if(m_xModel) + m_xModel->removeCloseListener( static_cast<util::XCloseListener*>(pController) ); } @@ -173,7 +160,7 @@ void ChartController::TheModel::tryTermination() try { - if(m_xCloseable.is()) + if(m_xModel.is()) { try { @@ -181,7 +168,7 @@ void ChartController::TheModel::tryTermination() //I think yes, because there might be other CloseListeners later in the list which might be interested still //but make sure that we do not throw the CloseVetoException here ourselves //so stop listening before trying to terminate or check the source of queryclosing event - m_xCloseable->close(true); + m_xModel->close(true); m_bOwnership = false; } @@ -196,12 +183,6 @@ void ChartController::TheModel::tryTermination() } } - else if( m_xModel.is() ) - { - //@todo correct?? - m_xModel->dispose(); - return; - } } catch(const uno::Exception&) { @@ -436,8 +417,7 @@ void SAL_CALL ChartController::attachFrame( m_xViewWindow.set( pChartWindow->GetComponentInterface(), uno::UNO_QUERY ); pChartWindow->Show(); m_apDropTargetHelper.reset( - new ChartDropTargetHelper( pChartWindow->GetDropTarget(), - uno::Reference< chart2::XChartDocument >( getModel(), uno::UNO_QUERY ))); + new ChartDropTargetHelper( pChartWindow->GetDropTarget(), getChartModel())); impl_createDrawViewController(); } @@ -529,7 +509,7 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent if( m_aSelection.hasSelection() ) this->impl_selectObjectAndNotiy(); else - ChartModelHelper::triggerRangeHighlighting( getModel() ); + ChartModelHelper::triggerRangeHighlighting( getChartModel() ); impl_initializeAccessible(); @@ -557,7 +537,10 @@ sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XMo return false; //behave passive if already disposed or suspended aGuard.clear(); - TheModelRef aNewModelRef( new TheModel( xModel), m_aModelMutex); + ::chart::ChartModel* pChartModel = dynamic_cast<::chart::ChartModel*>(xModel.get()); + assert(!xModel || pChartModel); + + TheModelRef aNewModelRef( new TheModel(pChartModel), m_aModelMutex); TheModelRef aOldModelRef(m_aModel,m_aModelMutex); m_aModel = aNewModelRef; @@ -571,9 +554,8 @@ sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XMo aOldModelRef->removeListener( this ); #ifdef TEST_ENABLE_MODIFY_LISTENER - uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aOldModelRef->getModel(),uno::UNO_QUERY ); - if( xMBroadcaster.is()) - xMBroadcaster->removeModifyListener( this ); + if( aOldModelRef->getModel().is()) + aOldModelRef->getModel()->removeModifyListener( this ); #endif } @@ -601,9 +583,8 @@ sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XMo aGuard.clear(); #ifdef TEST_ENABLE_MODIFY_LISTENER - uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aNewModelRef->getModel(),uno::UNO_QUERY ); - if( xMBroadcaster.is()) - xMBroadcaster->addModifyListener( this ); + if( aNewModelRef->getModel().is()) + aNewModelRef->getModel()->addModifyListener( this ); #endif // #i119999# Do not do this per default to allow the user to deselect the chart OLE with a single press to ESC @@ -644,6 +625,11 @@ uno::Reference< frame::XFrame > SAL_CALL ChartController::getFrame() uno::Reference< frame::XModel > SAL_CALL ChartController::getModel() { + return getChartModel(); +} + +rtl::Reference<::chart::ChartModel> ChartController::getChartModel() +{ //provides access to currently attached model //returns the currently attached model @@ -652,7 +638,7 @@ uno::Reference< frame::XModel > SAL_CALL ChartController::getModel() if(aModelRef.is()) return aModelRef->getModel(); - return uno::Reference< frame::XModel > (); + return nullptr; } uno::Any SAL_CALL ChartController::getViewData() @@ -822,9 +808,8 @@ void SAL_CALL ChartController::dispose() #ifdef TEST_ENABLE_MODIFY_LISTENER try { - uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aModelRef->getModel(),uno::UNO_QUERY ); - if( xMBroadcaster.is()) - xMBroadcaster->removeModifyListener( this ); + if( aModelRef->getModel().is()) + aModelRef->getModel()->removeModifyListener( this ); } catch( const uno::Exception & ) { @@ -881,7 +866,7 @@ void SAL_CALL ChartController::queryClosing( if( !aModelRef.is() ) return; - if( aModelRef->getModel() != rSource.Source ) + if( uno::Reference<XInterface>(static_cast<cppu::OWeakObject*>(aModelRef->getModel().get())) != rSource.Source ) { OSL_FAIL( "queryClosing was called on a controller from an unknown source" ); return; @@ -925,7 +910,7 @@ bool ChartController::impl_releaseThisModel( bool bReleaseModel = false; { ::osl::Guard< ::osl::Mutex > aGuard( m_aModelMutex ); - if( m_aModel.is() && m_aModel->getModel() == xModel ) + if( m_aModel.is() && uno::Reference< uno::XInterface >(static_cast<cppu::OWeakObject*>(m_aModel->getModel().get())) == xModel ) { m_aModel = nullptr; m_xUndoManager.clear(); @@ -1342,7 +1327,7 @@ void ChartController::executeDispatch_ChartType() SolarMutexGuard aSolarGuard; //prepare and open dialog - ChartTypeDialog aDlg(GetChartFrame(), getModel()); + ChartTypeDialog aDlg(GetChartFrame(), getChartModel()); if (aDlg.run() == RET_OK) { impl_adaptDataSeriesAutoResize(); @@ -1353,14 +1338,14 @@ void ChartController::executeDispatch_ChartType() void ChartController::executeDispatch_SourceData() { //convert properties to ItemSet - uno::Reference< XChartDocument > xChartDoc( getModel(), uno::UNO_QUERY ); + rtl::Reference< ::chart::ChartModel > xChartDoc = getChartModel(); OSL_ENSURE( xChartDoc.is(), "Invalid XChartDocument" ); if( !xChartDoc.is() ) return; // If there is a data table we should ask user if we really want to destroy it // and switch to data ranges. - ChartModel& rModel = dynamic_cast<ChartModel&>(*xChartDoc); + ChartModel& rModel = *xChartDoc; if ( rModel.hasInternalDataProvider() ) { // Check if we will able to create data provider later @@ -1404,12 +1389,12 @@ void ChartController::executeDispatch_SourceData() void ChartController::executeDispatch_MoveSeries( bool bForward ) { - ControllerLockGuardUNO aCLGuard( getModel() ); + ControllerLockGuardUNO aCLGuard( getChartModel() ); //get selected series OUString aObjectCID(m_aSelection.getSelectedCID()); uno::Reference< XDataSeries > xGivenDataSeries( ObjectIdentifier::getDataSeriesForCID( //yyy todo also legend entries and labels? - aObjectCID, getModel() ) ); + aObjectCID, getChartModel() ) ); UndoGuardWithSelection aUndoGuard( ActionDescriptionProvider::createDescription( @@ -1417,7 +1402,7 @@ void ChartController::executeDispatch_MoveSeries( bool bForward ) SchResId(STR_OBJECT_DATASERIES)), m_xUndoManager ); - bool bChanged = DiagramHelper::moveSeries( ChartModelHelper::findDiagram( getModel() ), xGivenDataSeries, bForward ); + bool bChanged = DiagramHelper::moveSeries( ChartModelHelper::findDiagram( uno::Reference<chart2::XChartDocument>(getChartModel()) ), xGivenDataSeries, bForward ); if( bChanged ) { m_aSelection.setSelection( ObjectIdentifier::getMovedSeriesCID( aObjectCID, bForward ) ); diff --git a/chart2/source/controller/main/ChartController_EditData.cxx b/chart2/source/controller/main/ChartController_EditData.cxx index e9820cab3cce..4f0a979956b0 100644 --- a/chart2/source/controller/main/ChartController_EditData.cxx +++ b/chart2/source/controller/main/ChartController_EditData.cxx @@ -19,6 +19,7 @@ #include <ChartWindow.hxx> #include <ChartController.hxx> +#include <ChartModel.hxx> #include <dlg_DataEditor.hxx> #include "UndoGuard.hxx" @@ -37,7 +38,7 @@ namespace chart void ChartController::executeDispatch_EditData() { - Reference< chart2::XChartDocument > xChartDoc( getModel(), uno::UNO_QUERY ); + rtl::Reference<::chart::ChartModel> xChartDoc( getChartModel(), uno::UNO_QUERY ); if (xChartDoc.is()) { SolarMutexGuard aSolarGuard; diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index 04c27782c375..1620c1ec5c1f 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -94,7 +94,7 @@ void ChartController::executeDispatch_InsertAxes() try { InsertAxisOrGridDialogData aDialogInput; - uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram(getModel()); + uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram(uno::Reference<chart2::XChartDocument>(getChartModel())); AxisHelper::getAxisOrGridExistence( aDialogInput.aExistenceList, xDiagram ); AxisHelper::getAxisOrGridPossibilities( aDialogInput.aPossibilityList, xDiagram ); @@ -103,7 +103,7 @@ void ChartController::executeDispatch_InsertAxes() if (aDlg.run() == RET_OK) { // lock controllers till end of block - ControllerLockGuardUNO aCLGuard( getModel() ); + ControllerLockGuardUNO aCLGuard( getChartModel() ); InsertAxisOrGridDialogData aDialogOutput; aDlg.getResult(aDialogOutput); @@ -132,7 +132,7 @@ void ChartController::executeDispatch_InsertGrid() try { InsertAxisOrGridDialogData aDialogInput; - uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram(getModel()); + uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram(uno::Reference<chart2::XChartDocument>(getChartModel())); AxisHelper::getAxisOrGridExistence( aDialogInput.aExistenceList, xDiagram, false ); AxisHelper::getAxisOrGridPossibilities( aDialogInput.aPossibilityList, xDiagram, false ); @@ -141,7 +141,7 @@ void ChartController::executeDispatch_InsertGrid() if (aDlg.run() == RET_OK) { // lock controllers till end of block - ControllerLockGuardUNO aCLGuard( getModel() ); + ControllerLockGuardUNO aCLGuard( getChartModel() ); InsertAxisOrGridDialogData aDialogOutput; aDlg.getResult( aDialogOutput ); bool bChanged = AxisHelper::changeVisibilityOfGrids( xDiagram @@ -166,17 +166,17 @@ void ChartController::executeDispatch_InsertTitles() try { TitleDialogData aDialogInput; - aDialogInput.readFromModel( getModel() ); + aDialogInput.readFromModel( getChartModel() ); SolarMutexGuard aGuard; SchTitleDlg aDlg(GetChartFrame(), aDialogInput); if (aDlg.run() == RET_OK) { // lock controllers till end of block - ControllerLockGuardUNO aCLGuard( getModel() ); + ControllerLockGuardUNO aCLGuard( getChartModel() ); TitleDialogData aDialogOutput(impl_createReferenceSizeProvider()); aDlg.getResult(aDialogOutput); - bool bChanged = aDialogOutput.writeDifferenceToModel( getModel(), m_xCC, &aDialogInput ); + bool bChanged = aDialogOutput.writeDifferenceToModel( getChartModel(), m_xCC, &aDialogInput ); if( bChanged ) aUndoGuard.commit(); } @@ -223,12 +223,12 @@ void ChartController::executeDispatch_OpenLegendDialog() //prepare and open dialog SolarMutexGuard aGuard; SchLegendDlg aDlg(GetChartFrame(), m_xCC); - aDlg.init( getModel() ); + aDlg.init( getChartModel() ); if (aDlg.run() == RET_OK) { // lock controllers till end of block - ControllerLockGuardUNO aCLGuard( getModel() ); - aDlg.writeToModel( getModel() ); + ControllerLockGuardUNO aCLGuard( getChartModel() ); + aDlg.writeToModel( getChartModel() ); aUndoGuard.commit(); } } @@ -247,7 +247,7 @@ void ChartController::executeDispatch_InsertMenu_DataLabels() //if a series is selected insert labels for that series only: uno::Reference< chart2::XDataSeries > xSeries = - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel()); + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel()); if( xSeries.is() ) { // add labels @@ -266,7 +266,7 @@ void ChartController::executeDispatch_InsertMenu_DataLabels() try { wrapper::AllDataLabelItemConverter aItemConverter( - getModel(), + getChartModel(), m_pDrawModelWrapper->GetItemPool(), m_pDrawModelWrapper->getSdrModel(), uno::Reference< lang::XMultiServiceFactory >( getModel(), uno::UNO_QUERY )); @@ -288,7 +288,7 @@ void ChartController::executeDispatch_InsertMenu_DataLabels() SfxItemSet aOutItemSet = aItemConverter.CreateEmptyItemSet(); aDlg.FillItemSet(aOutItemSet); // lock controllers till end of block - ControllerLockGuardUNO aCLGuard( getModel() ); + ControllerLockGuardUNO aCLGuard( getChartModel() ); bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now if( bChanged ) aUndoGuard.commit(); @@ -307,7 +307,7 @@ void ChartController::executeDispatch_InsertMeanValue() ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_AVERAGE_LINE )), m_xUndoManager ); lcl_InsertMeanValueLine( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), - getModel() ) ); + getChartModel() ) ); aUndoGuard.commit(); } @@ -319,7 +319,7 @@ void ChartController::executeDispatch_InsertMenu_MeanValues() m_xUndoManager ); uno::Reference< chart2::XDataSeries > xSeries = - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ); + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xSeries.is() ) { //if a series is selected insert mean value only for that series: @@ -328,7 +328,7 @@ void ChartController::executeDispatch_InsertMenu_MeanValues() else { std::vector< uno::Reference< chart2::XDataSeries > > aSeries( - DiagramHelper::getDataSeriesFromDiagram( ChartModelHelper::findDiagram( getModel() ))); + DiagramHelper::getDataSeriesFromDiagram( ChartModelHelper::findDiagram( uno::Reference<chart2::XChartDocument>(getChartModel()) ))); for( const auto& xSrs : aSeries ) lcl_InsertMeanValueLine( xSrs ); @@ -341,7 +341,7 @@ void ChartController::executeDispatch_InsertMenu_Trendlines() OUString aCID = m_aSelection.getSelectedCID(); uno::Reference< chart2::XDataSeries > xSeries = - ObjectIdentifier::getDataSeriesForCID( aCID, getModel() ); + ObjectIdentifier::getDataSeriesForCID( aCID, getChartModel() ); if( !xSeries.is() ) return; @@ -352,7 +352,7 @@ void ChartController::executeDispatch_InsertMenu_Trendlines() void ChartController::executeDispatch_InsertTrendline() { uno::Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer( - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel()), uno::UNO_QUERY ); + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel()), uno::UNO_QUERY ); if( !xRegressionCurveContainer.is() ) return; @@ -384,7 +384,7 @@ void ChartController::executeDispatch_InsertTrendline() ObjectIdentifier::createDataCurveCID( ObjectIdentifier::getSeriesParticleFromCID( m_aSelection.getSelectedCID()), RegressionCurveHelper::getRegressionCurveIndex( xRegressionCurveContainer, xCurve ), false )); - aDialogParameter.init( getModel() ); + aDialogParameter.init( getChartModel() ); ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get()); SolarMutexGuard aGuard; SchAttribTabDlg aDialog( @@ -400,7 +400,7 @@ void ChartController::executeDispatch_InsertTrendline() const SfxItemSet* pOutItemSet = aDialog.GetOutputItemSet(); if( pOutItemSet ) { - ControllerLockGuardUNO aCLGuard( getModel() ); + ControllerLockGuardUNO aCLGuard( getChartModel() ); aItemConverter.ApplyItemSet( *pOutItemSet ); } aUndoGuard.commit(); @@ -413,7 +413,7 @@ void ChartController::executeDispatch_InsertErrorBars( bool bYError ) //if a series is selected insert error bars for that series only: uno::Reference< chart2::XDataSeries > xSeries = - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ); + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xSeries.is()) { @@ -442,7 +442,7 @@ void ChartController::executeDispatch_InsertErrorBars( bool bYError ) ObjectPropertiesDialogParameter aDialogParameter( ObjectIdentifier::createClassifiedIdentifierWithParent( objType, u"", m_aSelection.getSelectedCID())); - aDialogParameter.init( getModel() ); + aDialogParameter.init( getChartModel() ); ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get()); SolarMutexGuard aGuard; SchAttribTabDlg aDlg( @@ -451,7 +451,7 @@ void ChartController::executeDispatch_InsertErrorBars( bool bYError ) uno::Reference< util::XNumberFormatsSupplier >( getModel(), uno::UNO_QUERY ) ); aDlg.SetAxisMinorStepWidthForErrorBarDecimals( - InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( getModel(), + InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( getChartModel(), m_xChartView, m_aSelection.getSelectedCID())); // note: when a user pressed "OK" but didn't change any settings in the @@ -461,7 +461,7 @@ void ChartController::executeDispatch_InsertErrorBars( bool bYError ) const SfxItemSet* pOutItemSet = aDlg.GetOutputItemSet(); if( pOutItemSet ) { - ControllerLockGuardUNO aCLGuard( getModel() ); + ControllerLockGuardUNO aCLGuard( getChartModel() ); aItemConverter.ApplyItemSet( *pOutItemSet ); } aUndoGuard.commit(); @@ -479,7 +479,7 @@ void ChartController::executeDispatch_InsertErrorBars( bool bYError ) try { wrapper::AllSeriesStatisticsConverter aItemConverter( - getModel(), m_pDrawModelWrapper->GetItemPool() ); + getChartModel(), m_pDrawModelWrapper->GetItemPool() ); SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet(); aItemConverter.FillItemSet( aItemSet ); @@ -487,11 +487,11 @@ void ChartController::executeDispatch_InsertErrorBars( bool bYError ) SolarMutexGuard aGuard; InsertErrorBarsDialog aDlg( GetChartFrame(), aItemSet, - uno::Reference< chart2::XChartDocument >( getModel(), uno::UNO_QUERY ), + getChartModel(), bYError ? ErrorBarResources::ERROR_BAR_Y : ErrorBarResources::ERROR_BAR_X); aDlg.SetAxisMinorStepWidthForErrorBarDecimals( - InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( getModel(), m_xChartView, OUString() ) ); + InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( getChartModel(), m_xChartView, OUString() ) ); if (aDlg.run() == RET_OK) { @@ -499,7 +499,7 @@ void ChartController::executeDispatch_InsertErrorBars( bool bYError ) aDlg.FillItemSet( aOutItemSet ); // lock controllers till end of block - ControllerLockGuardUNO aCLGuard( getModel() ); + ControllerLockGuardUNO aCLGuard( getChartModel() ); bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now if( bChanged ) aUndoGuard.commit(); @@ -515,11 +515,11 @@ void ChartController::executeDispatch_InsertErrorBars( bool bYError ) void ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2 ) { uno::Reference< chart2::XRegressionCurve > xRegCurve( - ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); + ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), uno::Reference<chart2::XChartDocument>(getChartModel()) ), uno::UNO_QUERY ); if( !xRegCurve.is() ) { uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ), uno::UNO_QUERY ); xRegCurve.set( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) ); } if( !xRegCurve.is()) @@ -543,7 +543,7 @@ void ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2 ) void ChartController::executeDispatch_InsertR2Value() { uno::Reference< beans::XPropertySet > xEqProp = - ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ); + ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), uno::Reference<chart2::XChartDocument>(getChartModel()) ); if( xEqProp.is()) { UndoGuard aUndoGuard( @@ -558,7 +558,7 @@ void ChartController::executeDispatch_InsertR2Value() void ChartController::executeDispatch_DeleteR2Value() { uno::Reference< beans::XPropertySet > xEqProp = - ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ); + ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), uno::Reference<chart2::XChartDocument>(getChartModel()) ); if( xEqProp.is()) { UndoGuard aUndoGuard( @@ -573,7 +573,7 @@ void ChartController::executeDispatch_DeleteR2Value() void ChartController::executeDispatch_DeleteMeanValue() { uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ), uno::UNO_QUERY ); if( xRegCurveCnt.is()) { UndoGuard aUndoGuard( @@ -588,7 +588,7 @@ void ChartController::executeDispatch_DeleteMeanValue() void ChartController::executeDispatch_DeleteTrendline() { uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ), uno::UNO_QUERY ); if( xRegCurveCnt.is()) { UndoGuard aUndoGuard( @@ -603,7 +603,7 @@ void ChartController::executeDispatch_DeleteTrendline() void ChartController::executeDispatch_DeleteTrendlineEquation() { uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ), uno::UNO_QUERY ); if( xRegCurveCnt.is()) { UndoGuard aUndoGuard( @@ -618,7 +618,7 @@ void ChartController::executeDispatch_DeleteTrendlineEquation() void ChartController::executeDispatch_DeleteErrorBars( bool bYError ) { uno::Reference< chart2::XDataSeries > xDataSeries( - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() )); + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() )); if( xDataSeries.is()) { UndoGuard aUndoGuard( @@ -633,7 +633,7 @@ void ChartController::executeDispatch_DeleteErrorBars( bool bYError ) void ChartController::executeDispatch_InsertDataLabels() { uno::Reference< chart2::XDataSeries > xSeries = - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ); + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xSeries.is() ) { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Insert, @@ -649,14 +649,14 @@ void ChartController::executeDispatch_InsertDataLabel() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_LABEL )), m_xUndoManager ); - DataSeriesHelper::insertDataLabelToPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ) ); + DataSeriesHelper::insertDataLabelToPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), uno::Reference<chart2::XChartDocument>(getChartModel()) ) ); aUndoGuard.commit(); } void ChartController::executeDispatch_DeleteDataLabels() { uno::Reference< chart2::XDataSeries > xSeries = - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ); + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xSeries.is() ) { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Delete, @@ -672,7 +672,7 @@ void ChartController::executeDispatch_DeleteDataLabel() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Delete, SchResId( STR_OBJECT_LABEL )), m_xUndoManager ); - DataSeriesHelper::deleteDataLabelsFromPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ) ); + DataSeriesHelper::deleteDataLabelsFromPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), uno::Reference<chart2::XChartDocument>(getChartModel()) ) ); aUndoGuard.commit(); } @@ -681,7 +681,7 @@ void ChartController::executeDispatch_ResetAllDataPoints() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Format, SchResId( STR_OBJECT_DATAPOINTS )), m_xUndoManager ); - uno::Reference< chart2::XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ); + uno::Reference< chart2::XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xSeries.is() ) xSeries->resetAllDataPoints(); aUndoGuard.commit(); @@ -691,7 +691,7 @@ void ChartController::executeDispatch_ResetDataPoint() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Format, SchResId( STR_OBJECT_DATAPOINT )), m_xUndoManager ); - uno::Reference< chart2::XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ); + uno::Reference< chart2::XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xSeries.is() ) { sal_Int32 nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() ); @@ -711,11 +711,11 @@ void ChartController::executeDispatch_InsertAxisTitle() ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_TITLE )), m_xUndoManager ); - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() ); sal_Int32 nDimensionIndex = -1; sal_Int32 nCooSysIndex = -1; sal_Int32 nAxisIndex = -1; - AxisHelper::getIndicesForAxis( xAxis, ChartModelHelper::findDiagram(getModel()), nCooSysIndex, nDimensionIndex, nAxisIndex ); + AxisHelper::getIndicesForAxis( xAxis, ChartModelHelper::findDiagram(uno::Reference<chart2::XChartDocument>(getChartModel())), nCooSysIndex, nDimensionIndex, nAxisIndex ); TitleHelper::eTitleType eTitleType = TitleHelper::X_AXIS_TITLE; if( nDimensionIndex==0 ) @@ -726,7 +726,7 @@ void ChartController::executeDispatch_InsertAxisTitle() eTitleType = TitleHelper::Z_AXIS_TITLE; std::unique_ptr< ReferenceSizeProvider > apRefSizeProvider( impl_createReferenceSizeProvider()); - xTitle = TitleHelper::createTitle( eTitleType, ObjectNameProvider::getTitleNameByType(eTitleType), getModel(), m_xCC, apRefSizeProvider.get() ); + xTitle = TitleHelper::createTitle( eTitleType, ObjectNameProvider::getTitleNameByType(eTitleType), getChartModel(), m_xCC, apRefSizeProvider.get() ); aUndoGuard.commit(); } } @@ -745,7 +745,7 @@ void ChartController::executeDispatch_InsertAxis() try { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xAxis.is() ) { AxisHelper::makeAxisVisible( xAxis ); @@ -767,7 +767,7 @@ void ChartController::executeDispatch_DeleteAxis() try { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xAxis.is() ) { AxisHelper::makeAxisInvisible( xAxis ); @@ -789,7 +789,7 @@ void ChartController::executeDispatch_InsertMajorGrid() try { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xAxis.is() ) { AxisHelper::makeGridVisible( xAxis->getGridProperties() ); @@ -811,7 +811,7 @@ void ChartController::executeDispatch_DeleteMajorGrid() try { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xAxis.is() ) { AxisHelper::makeGridInvisible( xAxis->getGridProperties() ); @@ -833,7 +833,7 @@ void ChartController::executeDispatch_InsertMinorGrid() try { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xAxis.is() ) { const Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() ); @@ -857,7 +857,7 @@ void ChartController::executeDispatch_DeleteMinorGrid() try { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xAxis.is() ) { const Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() ); diff --git a/chart2/source/controller/main/ChartController_Position.cxx b/chart2/source/controller/main/ChartController_Position.cxx index 4b9479c78dab..f57a3b8e8f96 100644 --- a/chart2/source/controller/main/ChartController_Position.cxx +++ b/chart2/source/controller/main/ChartController_Position.cxx @@ -183,7 +183,7 @@ void ChartController::executeDispatch_PositionAndSize(const ::css::uno::Sequence awt::Rectangle aNewObjectRect; lcl_getPositionAndSizeFromItemSet( aItemSet, aNewObjectRect, ToSize(aOldObjectRect) ); - awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) ); + awt::Size aPageSize( ChartModelHelper::getPageSize( getChartModel() ) ); awt::Rectangle aPageRect( 0,0,aPageSize.Width,aPageSize.Height ); bool bChanged = false; @@ -193,7 +193,7 @@ void ChartController::executeDispatch_PositionAndSize(const ::css::uno::Sequence bChanged = DiagramHelper::switchDiagramPositioningToExcludingPositioning(rModel, false , true); } - bool bMoved = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID(), getModel() + bool bMoved = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID(), getChartModel() , aNewObjectRect, aOldObjectRect, aPageRect ); if( bMoved || bChanged ) aUndoGuard.commit(); diff --git a/chart2/source/controller/main/ChartController_Properties.cxx b/chart2/source/controller/main/ChartController_Properties.cxx index 965df27134f6..f3a0d309cce7 100644 --- a/chart2/source/controller/main/ChartController_Properties.cxx +++ b/chart2/source/controller/main/ChartController_Properties.cxx @@ -41,6 +41,7 @@ #include <AxisHelper.hxx> #include <TitleHelper.hxx> #include <ChartTypeHelper.hxx> +#include <ChartModel.hxx> #include <ColorPerPointHelper.hxx> #include <DiagramHelper.hxx> #include <ControllerLockGuard.hxx> @@ -71,7 +72,7 @@ namespace { wrapper::ItemConverter* createItemConverter( - const OUString & aObjectCID, const uno::Reference<frame::XModel>& xChartModel, + const OUString & aObjectCID, const rtl::Reference<::chart::ChartModel>& xChartModel, const uno::Reference<uno::XComponentContext>& xContext, SdrModel& rDrawModel, ExplicitValueProvider* pExplicitValueProvider, ReferenceSizeProvider const * pRefSizeProvider ) { @@ -90,7 +91,7 @@ wrapper::ItemConverter* createItemConverter( if( !bAffectsMultipleObjects ) { uno::Reference< beans::XPropertySet > xObjectProperties = - ObjectIdentifier::getObjectPropertySet( aObjectCID, xChartModel ); + ObjectIdentifier::getObjectPropertySet( aObjectCID, uno::Reference<chart2::XChartDocument>(xChartModel )); if(!xObjectProperties.is()) return nullptr; //create itemconverter for a single object @@ -99,7 +100,7 @@ wrapper::ItemConverter* createItemConverter( case OBJECTTYPE_PAGE: pItemConverter = new wrapper::GraphicPropertyItemConverter( xObjectProperties, rDrawModel.GetItemPool(), - rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), + rDrawModel, xChartModel, wrapper::GraphicObjectType::LineAndFillProperties ); break; case OBJECTTYPE_TITLE: @@ -110,7 +111,7 @@ wrapper::ItemConverter* createItemConverter( pItemConverter = new wrapper::TitleItemConverter( xObjectProperties, rDrawModel.GetItemPool(), rDrawModel, - uno::Reference<lang::XMultiServiceFactory>(xChartModel, uno::UNO_QUERY), + xChartModel, pRefSize.get()); } break; @@ -122,7 +123,7 @@ wrapper::ItemConverter* createItemConverter( pItemConverter = new wrapper::LegendItemConverter( xObjectProperties, rDrawModel.GetItemPool(), rDrawModel, - uno::Reference<lang::XMultiServiceFactory>(xChartModel, uno::UNO_QUERY), + xChartModel, pRefSize.get()); } break; @@ -134,7 +135,7 @@ wrapper::ItemConverter* createItemConverter( case OBJECTTYPE_DIAGRAM_FLOOR: pItemConverter = new wrapper::GraphicPropertyItemConverter( xObjectProperties, rDrawModel.GetItemPool(), - rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), + rDrawModel, xChartModel, wrapper::GraphicObjectType::LineAndFillProperties ); break; case OBJECTTYPE_AXIS: @@ -144,7 +145,7 @@ wrapper::ItemConverter* createItemConverter( pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize())); uno::Reference< beans::XPropertySet > xDiaProp; - xDiaProp.set( ChartModelHelper::findDiagram( xChartModel ), uno::UNO_QUERY ); + xDiaProp.set( ChartModelHelper::findDiagram( uno::Reference<chart2::XChartDocument>(xChartModel) ), uno::UNO_QUERY ); // the second property set contains the property CoordinateOrigin // nOriginIndex is the index of the corresponding index of the @@ -160,7 +161,7 @@ wrapper::ItemConverter* createItemConverter( pItemConverter = new wrapper::AxisItemConverter( xObjectProperties, rDrawModel.GetItemPool(), rDrawModel, - uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), + xChartModel, &aExplicitScale, &aExplicitIncrement, pRefSize.get() ); } @@ -180,7 +181,7 @@ wrapper::ItemConverter* createItemConverter( sal_Int32 nNumberFormat = ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties ); sal_Int32 nPercentNumberFormat = ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel( - xObjectProperties,uno::Reference<util::XNumberFormatsSupplier>(xChartModel, uno::UNO_QUERY)); + xObjectProperties, xChartModel); pItemConverter = new wrapper::TextLabelItemConverter( xChartModel, xObjectProperties, xSeries, @@ -201,7 +202,7 @@ wrapper::ItemConverter* createItemConverter( uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( aObjectCID, xChartModel ); uno::Reference< XChartType > xChartType = ChartModelHelper::getChartTypeOfSeries( xChartModel, xSeries ); - uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); + uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( uno::Reference<chart2::XChartDocument>(xChartModel) ) ); sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); if( !ChartTypeHelper::isSupportingAreaProperties( xChartType, nDimensionCount ) ) eMapTo = wrapper::GraphicObjectType::LineDataPoint; @@ -233,11 +234,11 @@ wrapper::ItemConverter* createItemConverter( } sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties ); sal_Int32 nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel( - xObjectProperties,uno::Reference< util::XNumberFormatsSupplier >(xChartModel, uno::UNO_QUERY)); + xObjectProperties, xChartModel); pItemConverter = new wrapper::DataPointItemConverter( xChartModel, xContext, xObjectProperties, xSeries, rDrawModel.GetItemPool(), rDrawModel, - uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), + xChartModel, eMapTo, pRefSize.get(), bDataSeries, bUseSpecialFillColor, nSpecialFillColor, true, nNumberFormat, nPercentNumberFormat, nPointIndex ); break; @@ -247,7 +248,7 @@ wrapper::ItemConverter* createItemConverter( case OBJECTTYPE_DATA_AVERAGE_LINE: pItemConverter = new wrapper::GraphicPropertyItemConverter( xObjectProperties, rDrawModel.GetItemPool(), - rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), + rDrawModel, xChartModel, wrapper::GraphicObjectType::LineProperties ); break; @@ -256,7 +257,7 @@ wrapper::ItemConverter* createItemConverter( case OBJECTTYPE_DATA_ERRORS_Z: pItemConverter = new wrapper::ErrorBarItemConverter( xChartModel, xObjectProperties, rDrawModel.GetItemPool(), - rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY )); + rDrawModel, xChartModel); break; case OBJECTTYPE_DATA_CURVE: @@ -264,7 +265,7 @@ wrapper::ItemConverter* createItemConverter( xObjectProperties, uno::Reference< chart2::XRegressionCurveContainer >( ObjectIdentifier::getDataSeriesForCID( aObjectCID, xChartModel ), uno::UNO_QUERY ), rDrawModel.GetItemPool(), rDrawModel, - uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY )); + xChartModel); break; case OBJECTTYPE_DATA_CURVE_EQUATION: { @@ -274,7 +275,7 @@ wrapper::ItemConverter* createItemConverter( pItemConverter = new wrapper::RegressionEquationItemConverter( xObjectProperties, rDrawModel.GetItemPool(), rDrawModel, - uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), + xChartModel, pRefSize.get()); break; } @@ -284,7 +285,7 @@ wrapper::ItemConverter* createItemConverter( case OBJECTTYPE_DATA_STOCK_GAIN: pItemConverter = new wrapper::GraphicPropertyItemConverter( xObjectProperties, rDrawModel.GetItemPool(), - rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), + rDrawModel, xChartModel, wrapper::GraphicObjectType::LineAndFillProperties ); break; default: //OBJECTTYPE_UNKNOWN @@ -298,7 +299,7 @@ wrapper::ItemConverter* createItemConverter( { case OBJECTTYPE_TITLE: pItemConverter = new wrapper::AllTitleItemConverter( xChartModel, rDrawModel.GetItemPool(), - rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY )); + rDrawModel, xChartModel); break; case OBJECTTYPE_AXIS: { @@ -314,7 +315,7 @@ wrapper::ItemConverter* createItemConverter( case OBJECTTYPE_GRID: case OBJECTTYPE_SUBGRID: pItemConverter = new wrapper::AllGridItemConverter( xChartModel, rDrawModel.GetItemPool(), - rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY )); + rDrawModel, xChartModel); break; default: //for this type it is not supported to change all elements at once break; @@ -324,7 +325,7 @@ wrapper::ItemConverter* createItemConverter( return pItemConverter; } -OUString lcl_getTitleCIDForCommand( std::string_view rDispatchCommand, const uno::Reference< frame::XModel > & xChartModel ) +OUString lcl_getTitleCIDForCommand( std::string_view rDispatchCommand, const rtl::Reference<::chart::ChartModel> & xChartModel ) { if( rDispatchCommand == "AllTitles") return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_TITLE, u"ALLELEMENTS" ); @@ -347,7 +348,7 @@ OUString lcl_getTitleCIDForCommand( std::string_view rDispatchCommand, const uno return ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, xChartModel ); } -OUString lcl_getAxisCIDForCommand( std::string_view rDispatchCommand, const uno::Reference< frame::XModel >& xChartModel ) +OUString lcl_getAxisCIDForCommand( std::string_view rDispatchCommand, const rtl::Reference<::chart::ChartModel>& xChartModel ) { if( rDispatchCommand == "DiagramAxisAll") return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_AXIS, u"ALLELEMENTS" ); @@ -375,14 +376,14 @@ OUString lcl_getAxisCIDForCommand( std::string_view rDispatchCommand, const uno: nDimensionIndex=1; bMainAxis=false; } - uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); + uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( uno::Reference<chart2::XChartDocument>(xChartModel) ) ); uno::Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram ) ); return ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, xChartModel ); } -OUString lcl_getGridCIDForCommand( std::string_view rDispatchCommand, const uno::Reference< frame::XModel >& xChartModel ) +OUString lcl_getGridCIDForCommand( std::string_view rDispatchCommand, const rtl::Reference<::chart::ChartModel>& xChartModel ) { - uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); + uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( uno::Reference<chart2::XChartDocument>(xChartModel) ) ); if( rDispatchCommand == "DiagramGridAll") return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_GRID, u"ALLELEMENTS" ); @@ -432,13 +433,12 @@ OUString lcl_getErrorCIDForCommand( const ObjectType eDispatchType, const Object return ObjectIdentifier::createClassifiedIdentifierWithParent( eDispatchType, u"", rSelectedCID ); } -OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const uno::Reference< XChartDocument > & xChartDocument, const OUString& rSelectedCID ) +OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const rtl::Reference<::chart::ChartModel> & xChartDocument, const OUString& rSelectedCID ) { ObjectType eObjectType = OBJECTTYPE_UNKNOWN; - uno::Reference< frame::XModel > xChartModel = xChartDocument; const ObjectType eSelectedType = ObjectIdentifier::getObjectType( rSelectedCID ); - uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rSelectedCID, xChartModel ); + uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rSelectedCID, xChartDocument ); uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( xSeries, uno::UNO_QUERY ); //legend @@ -474,7 +474,7 @@ OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const un || rDispatchCommand == "AllTitles" ) { - return lcl_getTitleCIDForCommand( rDispatchCommand, xChartModel ); + return lcl_getTitleCIDForCommand( rDispatchCommand, xChartDocument ); } //axis else if( rDispatchCommand == "DiagramAxisX" @@ -485,7 +485,7 @@ OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const un || rDispatchCommand == "DiagramAxisAll" ) { - return lcl_getAxisCIDForCommand( rDispatchCommand, xChartModel ); + return lcl_getAxisCIDForCommand( rDispatchCommand, xChartDocument ); } //grid else if( rDispatchCommand == "DiagramGridYMain" @@ -497,7 +497,7 @@ OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const un || rDispatchCommand == "DiagramGridAll" ) { - return lcl_getGridCIDForCommand( rDispatchCommand, xChartModel ); + return lcl_getGridCIDForCommand( rDispatchCommand, xChartDocument ); } //data series else if( rDispatchCommand == "FormatDataSeries" ) @@ -592,8 +592,8 @@ OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const un return rSelectedCID; else { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartModel ); - return ObjectIdentifier::createClassifiedIdentifierForObject( xAxis , xChartModel ); + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartDocument ); + return ObjectIdentifier::createClassifiedIdentifierForObject( xAxis , xChartDocument ); } } // major grid @@ -603,8 +603,8 @@ OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const un return rSelectedCID; else { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartModel ); - return ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel ); + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartDocument ); + return ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartDocument ); } } @@ -615,8 +615,8 @@ OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const un return rSelectedCID; else { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartModel ); - return ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel, 0 /*sub grid index*/ ); + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartDocument ); + return ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartDocument, 0 /*sub grid index*/ ); } } // title @@ -652,7 +652,7 @@ OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const un void ChartController::executeDispatch_FormatObject(std::u16string_view rDispatchCommand) { - uno::Reference< XChartDocument > xChartDocument( getModel(), uno::UNO_QUERY ); + rtl::Reference<::chart::ChartModel> xChartDocument( getChartModel() ); OString aCommand( OUStringToOString( rDispatchCommand, RTL_TEXTENCODING_ASCII_US ) ); OUString rObjectCID = lcl_getObjectCIDForCommand( aCommand, xChartDocument, m_aSelection.getSelectedCID() ); executeDlg_ObjectProperties( rObjectCID ); @@ -722,7 +722,7 @@ bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( } if( eObjectType==OBJECTTYPE_DIAGRAM_WALL || eObjectType==OBJECTTYPE_DIAGRAM_FLOOR ) { - if( !DiagramHelper::isSupportingFloorAndWall( ChartModelHelper::findDiagram( getModel() ) ) ) + if( !DiagramHelper::isSupportingFloorAndWall( ChartModelHelper::findDiagram( uno::Reference<chart2::XChartDocument>(getChartModel()) ) ) ) return bRet; } @@ -731,7 +731,7 @@ bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( std::unique_ptr<ReferenceSizeProvider> pRefSizeProv(impl_createReferenceSizeProvider()); std::unique_ptr<wrapper::ItemConverter> pItemConverter( - createItemConverter( rObjectCID, getModel(), m_xCC, + createItemConverter( rObjectCID, getChartModel(), m_xCC, m_pDrawModelWrapper->getSdrModel(), comphelper::getFromUnoTunnel<ExplicitValueProvider>(m_xChartView), pRefSizeProv.get())); @@ -748,7 +748,7 @@ bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( //prepare dialog ObjectPropertiesDialogParameter aDialogParameter( rObjectCID ); - aDialogParameter.init( getModel() ); + aDialogParameter.init( getChartModel() ); ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get() ); SolarMutexGuard aGuard; @@ -761,12 +761,12 @@ bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( if(aDialogParameter.HasSymbolProperties()) { uno::Reference< beans::XPropertySet > xObjectProperties = - ObjectIdentifier::getObjectPropertySet( rObjectCID, getModel() ); - wrapper::DataPointItemConverter aSymbolItemConverter( getModel(), m_xCC - , xObjectProperties, ObjectIdentifier::getDataSeriesForCID( rObjectCID, getModel() ) + ObjectIdentifier::getObjectPropertySet( rObjectCID, uno::Reference<chart2::XChartDocument>(getChartModel()) ); + wrapper::DataPointItemConverter aSymbolItemConverter( getChartModel(), m_xCC + , xObjectProperties, ObjectIdentifier::getDataSeriesForCID( rObjectCID, getChartModel() ) , m_pDrawModelWrapper->getSdrModel().GetItemPool() , m_pDrawModelWrapper->getSdrModel() - , uno::Reference< lang::XMultiServiceFactory >( getModel(), uno::UNO_QUERY ) + , getChartModel() , wrapper::GraphicObjectType::FilledDataPoint ); SfxItemSet aSymbolShapeProperties(aSymbolItemConverter.CreateEmptyItemSet() ); @@ -780,7 +780,7 @@ bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( if( aDialogParameter.HasStatisticProperties() ) { aDlg.SetAxisMinorStepWidthForErrorBarDecimals( - InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( getModel(), m_xChartView, rObjectCID ) ); + InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( getChartModel(), m_xChartView, rObjectCID ) ); } //open the dialog @@ -789,7 +789,7 @@ bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( const SfxItemSet* pOutItemSet = aDlg.GetOutputItemSet(); if(pOutItemSet) { - ControllerLockGuardUNO aCLGuard( getModel()); + ControllerLockGuardUNO aCLGuard( getChartModel()); (void)pItemConverter->ApplyItemSet(*pOutItemSet); //model should be changed now bRet = true; } @@ -814,7 +814,7 @@ void ChartController::executeDispatch_View3D() //open dialog SolarMutexGuard aSolarGuard; - View3DDialog aDlg(GetChartFrame(), getModel()); + View3DDialog aDlg(GetChartFrame(), getChartModel()); if (aDlg.run() == RET_OK) aUndoGuard.commit(); } diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx b/chart2/source/controller/main/ChartController_TextEdit.cxx index f2aa1b5db47f..adc7b3cb0dda 100644 --- a/chart2/source/controller/main/ChartController_TextEdit.cxx +++ b/chart2/source/controller/main/ChartController_TextEdit.cxx @@ -23,6 +23,7 @@ #include "UndoGuard.hxx" #include <DrawViewWrapper.hxx> #include <ChartWindow.hxx> +#include <ChartModel.hxx> #include <TitleHelper.hxx> #include <ObjectIdentifier.hxx> #include <ControllerLockGuard.hxx> @@ -135,10 +136,10 @@ bool ChartController::EndTextEdit() if ( !aObjectCID.isEmpty() ) { uno::Reference< beans::XPropertySet > xPropSet = - ObjectIdentifier::getObjectPropertySet( aObjectCID, getModel() ); + ObjectIdentifier::getObjectPropertySet( aObjectCID, uno::Reference<chart2::XChartDocument>(getChartModel()) ); // lock controllers till end of block - ControllerLockGuardUNO aCLGuard( getModel() ); + ControllerLockGuardUNO aCLGuard( getChartModel() ); TitleHelper::setCompleteString( aString, uno::Reference< css::chart2::XTitle >::query( xPropSet ), m_xCC ); diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index 7f86b0aaa799..2ba1c61bda3d 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -92,16 +92,15 @@ namespace bool lcl_deleteDataSeries( const OUString & rCID, - const Reference< frame::XModel > & xModel, + const rtl::Reference<::chart::ChartModel> & xModel, const Reference< document::XUndoManager > & xUndoManager ) { bool bResult = false; uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rCID, xModel )); - uno::Reference< chart2::XChartDocument > xChartDoc( xModel, uno::UNO_QUERY ); - if( xSeries.is() && xChartDoc.is()) + if( xSeries.is() && xModel.is()) { uno::Reference< chart2::XChartType > xChartType( - DataSeriesHelper::getChartTypeOfSeries( xSeries, xChartDoc->getFirstDiagram())); + DataSeriesHelper::getChartTypeOfSeries( xSeries, xModel->getFirstDiagram())); if( xChartType.is()) { UndoGuard aUndoGuard( @@ -109,7 +108,7 @@ bool lcl_deleteDataSeries( ActionDescriptionProvider::ActionType::Delete, SchResId( STR_OBJECT_DATASERIES )), xUndoManager ); - Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel ) ); + Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( uno::Reference<chart2::XChartDocument>(xModel) ) ); uno::Reference< chart2::XAxis > xAxis( DiagramHelper::getAttachedAxis( xSeries, xDiagram ) ); DataSeriesHelper::deleteSeries( xSeries, xChartType ); @@ -125,13 +124,13 @@ bool lcl_deleteDataSeries( bool lcl_deleteDataCurve( const OUString & rCID, - const Reference< frame::XModel > & xModel, + const rtl::Reference<::chart::ChartModel> & xModel, const Reference< document::XUndoManager > & xUndoManager ) { bool bResult = false; uno::Reference< beans::XPropertySet > xProperties( - ObjectIdentifier::getObjectPropertySet( rCID, xModel)); + ObjectIdentifier::getObjectPropertySet( rCID, uno::Reference<chart2::XChartDocument>(xModel))); uno::Reference< chart2::XRegressionCurve > xRegressionCurve( xProperties, uno::UNO_QUERY ); @@ -139,7 +138,7 @@ bool lcl_deleteDataCurve( { uno::Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer( ObjectIdentifier::getObjectPropertySet( - ObjectIdentifier::getFullParentParticle( rCID ), xModel), uno::UNO_QUERY ); + ObjectIdentifier::getFullParentParticle( rCID ), uno::Reference<chart2::XChartDocument>(xModel)), uno::UNO_QUERY ); if( xRegressionCurveContainer.is()) { @@ -161,10 +160,9 @@ bool lcl_deleteDataCurve( std::unique_ptr<ReferenceSizeProvider> ChartController::impl_createReferenceSizeProvider() { - awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) ); + awt::Size aPageSize( ChartModelHelper::getPageSize( getChartModel() ) ); - return std::make_unique<ReferenceSizeProvider>( - aPageSize, Reference<chart2::XChartDocument>(getModel(), uno::UNO_QUERY)); + return std::make_unique<ReferenceSizeProvider>(aPageSize, getChartModel()); } void ChartController::impl_adaptDataSeriesAutoResize() @@ -181,8 +179,8 @@ void ChartController::executeDispatch_NewArrangement() try { - Reference< frame::XModel > xModel( getModel() ); - Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel )); + rtl::Reference<::chart::ChartModel> xModel( getChartModel() ); + Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( uno::Reference<chart2::XChartDocument>(xModel) )); if( xDiagram.is()) { UndoGuard aUndoGuard( @@ -243,7 +241,7 @@ void ChartController::executeDispatch_ScaleText() UndoGuard aUndoGuard( SchResId( STR_ACTION_SCALE_TEXT ), m_xUndoManager ); - ControllerLockGuardUNO aCtlLockGuard( getModel() ); + ControllerLockGuardUNO aCtlLockGuard( getChartModel() ); std::unique_ptr<ReferenceSizeProvider> pRefSizeProv(impl_createReferenceSizeProvider()); OSL_ASSERT(pRefSizeProv); @@ -607,7 +605,7 @@ bool ChartController::executeDispatch_Delete() ActionDescriptionProvider::ActionType::Delete, SchResId( STR_OBJECT_TITLE )), m_xUndoManager ); TitleHelper::removeTitle( - ObjectIdentifier::getTitleTypeForCID( aCID ), getModel() ); + ObjectIdentifier::getTitleTypeForCID( aCID ), getChartModel() ); bReturn = true; aUndoGuard.commit(); break; @@ -633,7 +631,7 @@ bool ChartController::executeDispatch_Delete() } case OBJECTTYPE_DATA_SERIES: - bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xUndoManager ); + bReturn = lcl_deleteDataSeries( aCID, getChartModel(), m_xUndoManager ); break; case OBJECTTYPE_LEGEND_ENTRY: @@ -642,14 +640,14 @@ bool ChartController::executeDispatch_Delete() ObjectIdentifier::getFullParentParticle( aCID )); if( eParentObjectType == OBJECTTYPE_DATA_SERIES ) { - bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xUndoManager ); + bReturn = lcl_deleteDataSeries( aCID, getChartModel(), m_xUndoManager ); } else if( eParentObjectType == OBJECTTYPE_DATA_CURVE ) { sal_Int32 nEndPos = aCID.lastIndexOf(':'); OUString aParentCID = aCID.copy(0, nEndPos); - bReturn = lcl_deleteDataCurve(aParentCID, getModel(), m_xUndoManager ); + bReturn = lcl_deleteDataCurve(aParentCID, getChartModel(), m_xUndoManager ); } else if( eParentObjectType == OBJECTTYPE_DATA_AVERAGE_LINE ) { @@ -663,7 +661,7 @@ bool ChartController::executeDispatch_Delete() { uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( ObjectIdentifier::getObjectPropertySet( - ObjectIdentifier::getFullParentParticle( aCID ), getModel()), uno::UNO_QUERY ); + ObjectIdentifier::getFullParentParticle( aCID ), uno::Reference<chart2::XChartDocument>(getChartModel())), uno::UNO_QUERY ); if( xRegCurveCnt.is()) { UndoGuard aUndoGuard( @@ -679,18 +677,18 @@ bool ChartController::executeDispatch_Delete() case OBJECTTYPE_DATA_CURVE: { - bReturn = lcl_deleteDataCurve( aCID, getModel(), m_xUndoManager ); + bReturn = lcl_deleteDataCurve( aCID, getChartModel(), m_xUndoManager ); } break; case OBJECTTYPE_DATA_CURVE_EQUATION: { uno::Reference< beans::XPropertySet > xEqProp( - ObjectIdentifier::getObjectPropertySet( aCID, getModel())); + ObjectIdentifier::getObjectPropertySet( aCID, uno::Reference<chart2::XChartDocument>(getChartModel()))); if( xEqProp.is()) { - uno::Reference< frame::XModel > xModel( getModel() ); + rtl::Reference<::chart::ChartModel> xModel( getChartModel() ); UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Delete, SchResId( STR_OBJECT_CURVE_EQUATION )), @@ -713,7 +711,7 @@ bool ChartController::executeDispatch_Delete() case OBJECTTYPE_DATA_ERRORS_Z: { uno::Reference< beans::XPropertySet > xErrorBarProp( - ObjectIdentifier::getObjectPropertySet( aCID, getModel() )); + ObjectIdentifier::getObjectPropertySet( aCID, uno::Reference<chart2::XChartDocument>(getChartModel()) )); if( xErrorBarProp.is()) { TranslateId pId; @@ -725,7 +723,7 @@ bool ChartController::executeDispatch_Delete() else pId = STR_OBJECT_ERROR_BARS_Z; - uno::Reference< frame::XModel > xModel( getModel() ); + rtl::Reference<::chart::ChartModel> xModel( getChartModel() ); UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Delete, SchResId(pId)), @@ -746,7 +744,7 @@ bool ChartController::executeDispatch_Delete() case OBJECTTYPE_DATA_LABEL: { uno::Reference< beans::XPropertySet > xObjectProperties = - ObjectIdentifier::getObjectPropertySet( aCID, getModel() ); + ObjectIdentifier::getObjectPropertySet( aCID, uno::Reference<chart2::XChartDocument>(getChartModel()) ); if( xObjectProperties.is() ) { UndoGuard aUndoGuard( @@ -764,7 +762,7 @@ bool ChartController::executeDispatch_Delete() aLabel.ShowSeriesName = false; if( aObjectType == OBJECTTYPE_DATA_LABELS ) { - uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( aCID, getModel() )); + uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( aCID, getChartModel() )); DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, CHART_UNONAME_LABEL, uno::Any(aLabel) ); DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any() ); } @@ -858,7 +856,7 @@ void ChartController::executeDispatch_ToggleGridHorizontal() { UndoGuard aUndoGuard( SchResId( STR_ACTION_TOGGLE_GRID_HORZ ), m_xUndoManager ); - Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( getModel() )); + Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( uno::Reference<chart2::XChartDocument>(getChartModel()) )); if( !xDiagram.is()) return; @@ -891,7 +889,7 @@ void ChartController::executeDispatch_ToggleGridVertical() { UndoGuard aUndoGuard( SchResId( STR_ACTION_TOGGLE_GRID_VERTICAL ), m_xUndoManager ); - Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( getModel() )); + Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( uno::Reference<chart2::XChartDocument>(getChartModel()) )); if( !xDiagram.is()) return; @@ -925,11 +923,11 @@ void ChartController::executeDispatch_FillColor(sal_uInt32 nColor) try { OUString aCID( m_aSelection.getSelectedCID() ); - const uno::Reference< frame::XModel >& xChartModel = getModel(); + rtl::Reference<::chart::ChartModel> xChartModel = getChartModel(); if( xChartModel.is() ) { Reference< beans::XPropertySet > xPointProperties( - ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ) ); + ObjectIdentifier::getObjectPropertySet( aCID, uno::Reference<chart2::XChartDocument>(xChartModel) ) ); if( xPointProperties.is() ) xPointProperties->setPropertyValue( "FillColor", uno::Any( nColor ) ); } @@ -948,12 +946,12 @@ void ChartController::executeDispatch_FillGradient(OUString sJSONGradient) try { OUString aCID( m_aSelection.getSelectedCID() ); - const uno::Reference< frame::XModel >& xChartModel = getModel(); + rtl::Reference<::chart::ChartModel> xChartModel = getChartModel(); if( xChartModel.is() ) { Reference< beans::XPropertySet > xPropSet( - ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ) ); + ObjectIdentifier::getObjectPropertySet( aCID, uno::Reference<chart2::XChartDocument>(xChartModel) ) ); if( xPropSet.is() ) { @@ -962,7 +960,7 @@ void ChartController::executeDispatch_FillGradient(OUString sJSONGradient) + OUString::number(static_cast<sal_Int32>(aXGradient.GetAngle().get())); OUString aNewName = PropertyHelper::addGradientUniqueNameToTable(css::uno::Any(aGradient), - css::uno::Reference<css::lang::XMultiServiceFactory>(xChartModel, css::uno::UNO_QUERY_THROW), + xChartModel, aPrefferedName); xPropSet->setPropertyValue("FillGradientName", css::uno::Any(aNewName)); @@ -980,11 +978,11 @@ void ChartController::executeDispatch_LineColor(sal_uInt32 nColor) try { OUString aCID( m_aSelection.getSelectedCID() ); - const uno::Reference< frame::XModel >& xChartModel = getModel(); + rtl::Reference<::chart::ChartModel> xChartModel = getChartModel(); if( xChartModel.is() ) { Reference< beans::XPropertySet > xPropSet( - ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ) ); + ObjectIdentifier::getObjectPropertySet( aCID, uno::Reference<chart2::XChartDocument>(xChartModel) ) ); ObjectType eType = ObjectIdentifier::getObjectType(aCID); if (eType == OBJECTTYPE_DIAGRAM) @@ -1010,11 +1008,11 @@ void ChartController::executeDispatch_LineWidth(sal_uInt32 nWidth) try { OUString aCID( m_aSelection.getSelectedCID() ); - const uno::Reference< frame::XModel >& xChartModel = getModel(); + rtl::Reference<::chart::ChartModel> xChartModel = getChartModel(); if( xChartModel.is() ) { Reference< beans::XPropertySet > xPropSet( - ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ) ); + ObjectIdentifier::getObjectPropertySet( aCID, uno::Reference<chart2::XChartDocument>(xChartModel) ) ); ObjectType eType = ObjectIdentifier::getObjectType(aCID); if (eType == OBJECTTYPE_DIAGRAM) @@ -1071,11 +1069,11 @@ void ChartController::executeDispatch_LOKPieSegmentDragging( int nOffset ) try { OUString aCID( m_aSelection.getSelectedCID() ); - const uno::Reference< frame::XModel >& xChartModel = getModel(); + rtl::Reference<::chart::ChartModel> xChartModel = getChartModel(); if( xChartModel.is() ) { Reference< beans::XPropertySet > xPointProperties( - ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ) ); + ObjectIdentifier::getObjectPropertySet( aCID, uno::Reference<chart2::XChartDocument>(xChartModel) ) ); if( xPointProperties.is() ) xPointProperties->setPropertyValue( "Offset", uno::Any( nOffset / 100.0 ) ); } diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 76ccba722e54..24f5255ad380 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -250,7 +250,7 @@ void SAL_CALL ChartController::setPosSize( //todo: for standalone chart: detect whether we are standalone //change map mode to fit new size - awt::Size aModelPageSize = ChartModelHelper::getPageSize( getModel() ); + awt::Size aModelPageSize = ChartModelHelper::getPageSize( getChartModel() ); sal_Int32 nScaleXNumerator = aLogicSize.Width(); sal_Int32 nScaleXDenominator = aModelPageSize.Width; sal_Int32 nScaleYNumerator = aLogicSize.Height(); @@ -666,7 +666,7 @@ void ChartController::execute_MouseButtonDown( const MouseEvent& rMEvt ) rMEvt.IsRight(), m_bWaitingForDoubleClick ); - if( !m_aSelection.isRotateableObjectSelected( getModel() ) ) + if( !m_aSelection.isRotateableObjectSelected( getChartModel() ) ) { m_eDragMode = SdrDragMode::Move; pDrawViewWrapper->SetDragMode(m_eDragMode); @@ -699,14 +699,14 @@ void ChartController::execute_MouseButtonDown( const MouseEvent& rMEvt ) else if( eKind==SdrHdlKind::UpperLeft || eKind==SdrHdlKind::UpperRight || eKind==SdrHdlKind::LowerLeft || eKind==SdrHdlKind::LowerRight ) eRotationDirection = DragMethod_RotateDiagram::ROTATIONDIRECTION_Z; } - pDragMethod = new DragMethod_RotateDiagram( *pDrawViewWrapper, m_aSelection.getSelectedCID(), getModel(), eRotationDirection ); + pDragMethod = new DragMethod_RotateDiagram( *pDrawViewWrapper, m_aSelection.getSelectedCID(), getChartModel(), eRotationDirection ); } } else { OUString aDragMethodServiceName( ObjectIdentifier::getDragMethodServiceName( m_aSelection.getSelectedCID() ) ); if( aDragMethodServiceName == ObjectIdentifier::getPieSegmentDragMethodServiceName() ) - pDragMethod = new DragMethod_PieSegment( *pDrawViewWrapper, m_aSelection.getSelectedCID(), getModel() ); + pDragMethod = new DragMethod_PieSegment( *pDrawViewWrapper, m_aSelection.getSelectedCID(), getChartModel() ); } pDrawViewWrapper->SdrView::BegDragObj(aMPos, nullptr, pHitSelectionHdl, nDrgLog, pDragMethod); } @@ -739,7 +739,7 @@ void ChartController::execute_MouseMove( const MouseEvent& rMEvt ) void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) { - ControllerLockGuardUNO aCLGuard( getModel() ); + ControllerLockGuardUNO aCLGuard( getChartModel() ); bool bMouseUpWithoutMouseDown = !m_bWaitingForMouseUp; m_bWaitingForMouseUp = false; bool bNotifySelectionChange = false; @@ -839,7 +839,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) { tools::Rectangle aObjectRect = pObj->GetSnapRect(); tools::Rectangle aOldObjectRect = pObj->GetLastBoundRect(); - awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) ); + awt::Size aPageSize( ChartModelHelper::getPageSize( getChartModel() ) ); tools::Rectangle aPageRect( 0,0,aPageSize.Width,aPageSize.Height ); const E3dObject* pE3dObject(dynamic_cast< const E3dObject*>(pObj)); @@ -870,7 +870,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) bChanged = DiagramHelper::switchDiagramPositioningToExcludingPositioning( *pModel, false , true ); bool bMoved = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID() - , getModel() + , getChartModel() , awt::Rectangle(aObjectRect.Left(),aObjectRect.Top(),aObjectRect.getWidth(),aObjectRect.getHeight()) , awt::Rectangle(aOldObjectRect.Left(), aOldObjectRect.Top(), 0, 0) , awt::Rectangle(aPageRect.Left(),aPageRect.Top(),aPageRect.getWidth(),aPageRect.getHeight()) ); @@ -893,7 +893,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) if( !bDraggingDone ) //mouse wasn't moved while dragging { bool bClickedTwiceOnDragableObject = SelectionHelper::isDragableObjectHitTwice( aMPos, m_aSelection.getSelectedCID(), *pDrawViewWrapper ); - bool bIsRotateable = m_aSelection.isRotateableObjectSelected( getModel() ); + bool bIsRotateable = m_aSelection.isRotateableObjectSelected( getChartModel() ); //toggle between move and rotate if( bIsRotateable && bClickedTwiceOnDragableObject && m_eDragMode==SdrDragMode::Move ) @@ -1031,7 +1031,7 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) xPopupMenu->insertSeparator( -1 ); ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ); - Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( getModel() ); + Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( uno::Reference<chart2::XChartDocument>(getChartModel()) ); OUString aFormatCommand( lcl_getFormatCommandForObjectCID( m_aSelection.getSelectedCID() ) ); lcl_insertMenuCommand( xPopupMenu, nUniqueId++, aFormatCommand ); @@ -1041,7 +1041,7 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) if( eObjectType == OBJECTTYPE_DATA_SERIES || eObjectType == OBJECTTYPE_DATA_POINT ) { bool bIsPoint = ( eObjectType == OBJECTTYPE_DATA_POINT ); - uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ); + uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); uno::Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY ); Reference< chart2::XRegressionCurve > xTrendline( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xCurveCnt ) ); bool bHasEquation = RegressionCurveHelper::hasEquation( xTrendline ); @@ -1197,7 +1197,7 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) else if( eObjectType == OBJECTTYPE_AXIS || eObjectType == OBJECTTYPE_GRID || eObjectType == OBJECTTYPE_SUBGRID ) { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xAxis.is() && xDiagram.is() ) { sal_Int32 nDimensionIndex = -1; @@ -1382,7 +1382,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) if( ! bReturn ) { // Navigation (Tab/F3/Home/End) - uno::Reference< XChartDocument > xChartDoc( getModel(), uno::UNO_QUERY ); + rtl::Reference<::chart::ChartModel> xChartDoc( getChartModel() ); ObjectKeyNavigation aObjNav( m_aSelection.getSelectedOID(), xChartDoc, comphelper::getFromUnoTunnel<ExplicitValueProvider>( m_xChartView )); awt::KeyEvent aKeyEvent( ::svt::AcceleratorExecute::st_VCLKey2AWTKey( aKeyCode )); bReturn = aObjNav.handleKeyEvent( aKeyEvent ); @@ -1394,7 +1394,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) { aNewSelection = aNewOID.getAny(); } - if ( m_eDragMode == SdrDragMode::Rotate && !SelectionHelper::isRotateableObject( aNewOID.getObjectCID(), getModel() ) ) + if ( m_eDragMode == SdrDragMode::Rotate && !SelectionHelper::isRotateableObject( aNewOID.getObjectCID(), getChartModel() ) ) { m_eDragMode = SdrDragMode::Move; } @@ -1522,7 +1522,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) if (pObj) { tools::Rectangle aRect = pObj->GetSnapRect(); - awt::Size aPageSize(ChartModelHelper::getPageSize(getModel())); + awt::Size aPageSize(ChartModelHelper::getPageSize(getChartModel())); if ((fShiftAmountX > 0.0 && (aRect.Right() + fShiftAmountX > aPageSize.Width)) || (fShiftAmountX < 0.0 && (aRect.Left() + fShiftAmountX < 0)) || (fShiftAmountY > 0.0 && (aRect.Bottom() + fShiftAmountY > aPageSize.Height)) || @@ -1530,7 +1530,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) bReturn = false; else bReturn = PositionAndSizeHelper::moveObject( - m_aSelection.getSelectedCID(), getModel(), + m_aSelection.getSelectedCID(), getChartModel(), awt::Rectangle(aRect.Left() + fShiftAmountX, aRect.Top() + fShiftAmountY, aRect.getWidth(), aRect.getHeight()), awt::Rectangle(aRect.Left(), aRect.Top(), 0, 0), awt::Rectangle(0, 0, aPageSize.Width, aPageSize.Height)); @@ -1548,7 +1548,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) { awt::Point aPos( xShape->getPosition() ); awt::Size aSize( xShape->getSize() ); - awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) ); + awt::Size aPageSize( ChartModelHelper::getPageSize( getChartModel() ) ); aPos.X = static_cast< tools::Long >( static_cast< double >( aPos.X ) + fShiftAmountX ); aPos.Y = static_cast< tools::Long >( static_cast< double >( aPos.Y ) + fShiftAmountY ); if( aPos.X + aSize.Width > aPageSize.Width ) @@ -1628,9 +1628,9 @@ bool ChartController::requestQuickHelp( OUString & rOutQuickHelpText, awt::Rectangle & rOutEqualRect ) { - uno::Reference< frame::XModel > xChartModel; + rtl::Reference<::chart::ChartModel> xChartModel; if( m_aModel.is()) - xChartModel.set( getModel() ); + xChartModel = getChartModel(); if( !xChartModel.is()) return false; @@ -1789,9 +1789,9 @@ bool ChartController::impl_moveOrResizeObject( bool bResult = false; bool bNeedResize = ( eType == CENTERED_RESIZE_OBJECT ); - uno::Reference< frame::XModel > xChartModel( getModel() ); + rtl::Reference<::chart::ChartModel> xChartModel( getChartModel() ); uno::Reference< beans::XPropertySet > xObjProp( - ObjectIdentifier::getObjectPropertySet( rCID, xChartModel )); + ObjectIdentifier::getObjectPropertySet( rCID, uno::Reference<chart2::XChartDocument>(xChartModel) )); if( xObjProp.is()) { awt::Size aRefSize = ChartModelHelper::getPageSize( xChartModel ); @@ -1870,7 +1870,7 @@ bool ChartController::impl_DragDataPoint( const OUString & rCID, double fAdditio sal_Int32 nDataPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( rCID ); uno::Reference< chart2::XDataSeries > xSeries( - ObjectIdentifier::getDataSeriesForCID( rCID, getModel() )); + ObjectIdentifier::getDataSeriesForCID( rCID, getChartModel() )); if( xSeries.is()) { try @@ -2051,7 +2051,7 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent ) { if( (m_eDragMode == SdrDragMode::Rotate) && SelectionHelper::isRotateableObject( aHitObjectCID - , getModel() ) ) + , getChartModel() ) ) pChartWindow->SetPointer( PointerStyle::Rotate ); else { @@ -2079,7 +2079,7 @@ css::uno::Reference<css::uno::XInterface> const & ChartController::getChartView( void ChartController::sendPopupRequest(OUString const & rCID, tools::Rectangle aRectangle) { - ChartModel* pChartModel = dynamic_cast<ChartModel*>(m_aModel->getModel().get()); + ChartModel* pChartModel = m_aModel->getModel().get(); if (!pChartModel) return; diff --git a/chart2/source/controller/main/ChartDropTargetHelper.cxx b/chart2/source/controller/main/ChartDropTargetHelper.cxx index 15272dfc5963..ceb599569e16 100644 --- a/chart2/source/controller/main/ChartDropTargetHelper.cxx +++ b/chart2/source/controller/main/ChartDropTargetHelper.cxx @@ -19,6 +19,7 @@ #include "ChartDropTargetHelper.hxx" #include <DataSourceHelper.hxx> +#include <ChartModel.hxx> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/data/XDataProvider.hpp> @@ -60,7 +61,7 @@ namespace chart ChartDropTargetHelper::ChartDropTargetHelper( const Reference< datatransfer::dnd::XDropTarget >& rxDropTarget, - const Reference< chart2::XChartDocument > & xChartDocument ) : + const rtl::Reference<::chart::ChartModel> & xChartDocument ) : DropTargetHelper( rxDropTarget ), m_xChartDocument( xChartDocument ) {} @@ -109,10 +110,9 @@ sal_Int8 ChartDropTargetHelper::ExecuteDrop( const ExecuteDropEvent& rEvt ) if( aStrings.size() >= 3 && aStrings[0] == "soffice" ) { OUString aRangeString( aStrings[2] ); - Reference< container::XChild > xChild( m_xChartDocument, uno::UNO_QUERY ); - if( xChild.is()) + if( m_xChartDocument.is()) { - Reference< frame::XModel > xParentModel( xChild->getParent(), uno::UNO_QUERY ); + Reference< frame::XModel > xParentModel( m_xChartDocument->getParent(), uno::UNO_QUERY ); if( xParentModel.is() && m_xChartDocument.is()) { diff --git a/chart2/source/controller/main/ChartDropTargetHelper.hxx b/chart2/source/controller/main/ChartDropTargetHelper.hxx index 84c8dfe98f45..4955d6eaea43 100644 --- a/chart2/source/controller/main/ChartDropTargetHelper.hxx +++ b/chart2/source/controller/main/ChartDropTargetHelper.hxx @@ -19,6 +19,7 @@ #pragma once #include <vcl/transfer.hxx> +#include <rtl/ref.hxx> namespace com::sun::star { namespace chart2 { @@ -28,6 +29,7 @@ namespace com::sun::star { namespace chart { +class ChartModel; class ChartDropTargetHelper : public DropTargetHelper { @@ -35,7 +37,7 @@ public: ChartDropTargetHelper() = delete; explicit ChartDropTargetHelper( const css::uno::Reference< css::datatransfer::dnd::XDropTarget >& rxDropTarget, - const css::uno::Reference< css::chart2::XChartDocument > & xChartDocument ); + const rtl::Reference<::chart::ChartModel> & xChartDocument ); virtual ~ChartDropTargetHelper() override; protected: @@ -46,7 +48,7 @@ protected: private: bool satisfiesPrerequisites() const; - css::uno::Reference< css::chart2::XChartDocument > m_xChartDocument; + rtl::Reference<::chart::ChartModel> m_xChartDocument; }; } // namespace chart diff --git a/chart2/source/controller/main/ChartModelClone.cxx b/chart2/source/controller/main/ChartModelClone.cxx index 6348aee6e6f9..dfb089d566e8 100644 --- a/chart2/source/controller/main/ChartModelClone.cxx +++ b/chart2/source/controller/main/ChartModelClone.cxx @@ -60,36 +60,33 @@ namespace chart // = helper namespace { - Reference< XModel > lcl_cloneModel( const Reference< XModel > & xModel ) + rtl::Reference<::chart::ChartModel> lcl_cloneModel( const rtl::Reference<::chart::ChartModel> & xModel ) { - Reference< XModel > xResult; try { - const Reference< XCloneable > xCloneable( xModel, UNO_QUERY_THROW ); - xResult.set( xCloneable->createClone(), UNO_QUERY_THROW ); + return new ChartModel(*xModel); } catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION("chart2"); } - return xResult; + return nullptr; } } // = ChartModelClone - ChartModelClone::ChartModelClone( const Reference< XModel >& i_model, const ModelFacet i_facet ) + ChartModelClone::ChartModelClone( const rtl::Reference<::chart::ChartModel>& i_model, const ModelFacet i_facet ) { - m_xModelClone.set( lcl_cloneModel( i_model ) ); + m_xModelClone = lcl_cloneModel( i_model ); try { if ( i_facet == E_MODEL_WITH_DATA ) { - const Reference< XChartDocument > xChartDoc( m_xModelClone, UNO_QUERY_THROW ); - ENSURE_OR_THROW( xChartDoc->hasInternalDataProvider(), "invalid chart model" ); + ENSURE_OR_THROW( m_xModelClone && m_xModelClone->hasInternalDataProvider(), "invalid chart model" ); - const Reference< XCloneable > xCloneable( xChartDoc->getDataProvider(), UNO_QUERY_THROW ); + const Reference< XCloneable > xCloneable( m_xModelClone->getDataProvider(), UNO_QUERY_THROW ); m_xDataClone.set( xCloneable->createClone(), UNO_QUERY_THROW ); } @@ -116,15 +113,6 @@ namespace chart if ( impl_isDisposed() ) return; - try - { - Reference< XComponent > xComp( m_xModelClone, UNO_QUERY_THROW ); - xComp->dispose(); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } m_xModelClone.clear(); m_xDataClone.clear(); m_aSelection.clear(); @@ -139,7 +127,7 @@ namespace chart return E_MODEL; } - void ChartModelClone::applyToModel( const Reference< XModel >& i_model ) const + void ChartModelClone::applyToModel( const rtl::Reference<::chart::ChartModel>& i_model ) const { applyModelContentToModel( i_model, m_xModelClone, m_xDataClone ); @@ -179,8 +167,9 @@ namespace chart } } - void ChartModelClone::applyModelContentToModel( const Reference< XModel >& i_model, - const Reference< XModel >& i_modelToCopyFrom, const Reference< XInternalDataProvider >& i_data ) + void ChartModelClone::applyModelContentToModel( const rtl::Reference<::chart::ChartModel>& i_model, + const rtl::Reference<::chart::ChartModel>& i_modelToCopyFrom, + const Reference< XInternalDataProvider >& i_data ) { ENSURE_OR_RETURN_VOID( i_model.is(), "ChartModelElement::applyModelContentToModel: invalid source model!" ); ENSURE_OR_RETURN_VOID( i_modelToCopyFrom.is(), "ChartModelElement::applyModelContentToModel: invalid source model!" ); @@ -188,25 +177,20 @@ namespace chart { // locked controllers of destination ControllerLockGuardUNO aLockedControllers( i_model ); - Reference< XChartDocument > xSource( i_modelToCopyFrom, UNO_QUERY_THROW ); - Reference< XChartDocument > xDestination( i_model, UNO_QUERY_THROW ); // propagate the correct flag for plotting of hidden values to the data provider and all used sequences - ChartModel& rModel = dynamic_cast<ChartModel&>(*i_model); - ChartModelHelper::setIncludeHiddenCells(ChartModelHelper::isIncludeHiddenCells( i_modelToCopyFrom ), rModel); + ChartModelHelper::setIncludeHiddenCells(ChartModelHelper::isIncludeHiddenCells( i_modelToCopyFrom ), *i_model); // diagram - xDestination->setFirstDiagram( xSource->getFirstDiagram() ); + i_model->setFirstDiagram( i_modelToCopyFrom->getFirstDiagram() ); // main title - Reference< XTitled > xDestinationTitled( xDestination, UNO_QUERY_THROW ); - Reference< XTitled > xSourceTitled( xSource, UNO_QUERY_THROW ); - xDestinationTitled->setTitleObject( xSourceTitled->getTitleObject() ); + i_model->setTitleObject( i_modelToCopyFrom->getTitleObject() ); // page background ::comphelper::copyProperties( - xSource->getPageBackground(), - xDestination->getPageBackground() ); + i_modelToCopyFrom->getPageBackground(), + i_model->getPageBackground() ); // apply data (not applied in standard Undo) if ( i_data.is() ) @@ -214,10 +198,10 @@ namespace chart // register all sequences at the internal data provider to get adapted // indexes when columns are added/removed - if ( xDestination->hasInternalDataProvider() ) + if ( i_model->hasInternalDataProvider() ) { - Reference< XInternalDataProvider > xNewDataProvider( xDestination->getDataProvider(), UNO_QUERY ); - Reference< XDataSource > xUsedData( DataSourceHelper::getUsedData( i_model ) ); + Reference< XInternalDataProvider > xNewDataProvider( i_model->getDataProvider(), UNO_QUERY ); + Reference< XDataSource > xUsedData( DataSourceHelper::getUsedData( *i_model ) ); if ( xUsedData.is() && xNewDataProvider.is() ) { const Sequence< Reference< XLabeledDataSequence > > aData( xUsedData->getDataSequences() ); @@ -230,11 +214,9 @@ namespace chart } // restore modify status - Reference< XModifiable > xSourceMod( xSource, UNO_QUERY ); - Reference< XModifiable > xDestMod( xDestination, UNO_QUERY ); - if ( xSourceMod.is() && xDestMod.is() && !xSourceMod->isModified() ) + if ( !i_modelToCopyFrom->isModified() ) { - xDestMod->setModified( false ); + i_model->setModified( false ); } // \-- locked controllers of destination } diff --git a/chart2/source/controller/main/ChartModelClone.hxx b/chart2/source/controller/main/ChartModelClone.hxx index e5f052eb7046..41cf7fc10924 100644 --- a/chart2/source/controller/main/ChartModelClone.hxx +++ b/chart2/source/controller/main/ChartModelClone.hxx @@ -21,12 +21,14 @@ #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Reference.h> +#include <rtl/ref.hxx> namespace com::sun::star::chart2 { class XInternalDataProvider; } namespace com::sun::star::frame { class XModel; } namespace chart { +class ChartModel; enum ModelFacet { @@ -39,7 +41,7 @@ namespace chart { public: ChartModelClone( - const css::uno::Reference< css::frame::XModel >& i_model, + const rtl::Reference<::chart::ChartModel>& i_model, const ModelFacet i_facet ); @@ -50,11 +52,11 @@ namespace chart ModelFacet getFacet() const; - void applyToModel( const css::uno::Reference< css::frame::XModel >& i_model ) const; + void applyToModel( const rtl::Reference<::chart::ChartModel>& i_model ) const; static void applyModelContentToModel( - const css::uno::Reference< css::frame::XModel > & i_model, - const css::uno::Reference< css::frame::XModel > & i_modelToCopyFrom, + const rtl::Reference<::chart::ChartModel> & i_model, + const rtl::Reference<::chart::ChartModel> & i_modelToCopyFrom, const css::uno::Reference< css::chart2::XInternalDataProvider > & i_data ); void dispose(); @@ -63,7 +65,7 @@ namespace chart bool impl_isDisposed() const { return !m_xModelClone.is(); } private: - css::uno::Reference< css::frame::XModel > m_xModelClone; + rtl::Reference<::chart::ChartModel> m_xModelClone; css::uno::Reference< css::chart2::XInternalDataProvider > m_xDataClone; css::uno::Any m_aSelection; }; diff --git a/chart2/source/controller/main/CommandDispatchContainer.cxx b/chart2/source/controller/main/CommandDispatchContainer.cxx index 69528aa67fa1..05eea58de66d 100644 --- a/chart2/source/controller/main/CommandDispatchContainer.cxx +++ b/chart2/source/controller/main/CommandDispatchContainer.cxx @@ -23,6 +23,7 @@ #include <DisposeHelper.hxx> #include "DrawCommandDispatch.hxx" #include "ShapeController.hxx" +#include <ChartModel.hxx> #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/frame/XModel.hpp> @@ -48,13 +49,13 @@ CommandDispatchContainer::CommandDispatchContainer( } void CommandDispatchContainer::setModel( - const Reference< frame::XModel > & xModel ) + const rtl::Reference<::chart::ChartModel> & xModel ) { // remove all existing dispatcher that base on the old model m_aCachedDispatches.clear(); DisposeHelper::DisposeAllElements( m_aToBeDisposedDispatches ); m_aToBeDisposedDispatches.clear(); - m_xModel = xModel; + m_xModel = xModel.get(); } void CommandDispatchContainer::setChartDispatch( @@ -83,7 +84,7 @@ Reference< frame::XDispatch > CommandDispatchContainer::getDispatchForURL( } else { - uno::Reference< frame::XModel > xModel( m_xModel ); + rtl::Reference< ::chart::ChartModel > xModel( m_xModel ); if( xModel.is() && ( rURL.Path == "Undo" || rURL.Path == "Redo" || rURL.Path == "GetUndoStrings" || rURL.Path == "GetRedoStrings" ) ) diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx b/chart2/source/controller/main/ControllerCommandDispatch.cxx index 2f0e13f56155..2f125e020b7e 100644 --- a/chart2/source/controller/main/ControllerCommandDispatch.cxx +++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx @@ -106,7 +106,7 @@ struct ControllerState ControllerState(); void update( const Reference< frame::XController > & xController, - const Reference< frame::XModel > & xModel ); + const rtl::Reference<::chart::ChartModel> & xModel ); // -- State variables ------- bool bHasSelectedObject; @@ -173,7 +173,7 @@ ControllerState::ControllerState() : void ControllerState::update( const Reference< frame::XController > & xController, - const Reference< frame::XModel > & xModel ) + const rtl::Reference<::chart::ChartModel> & xModel ) { Reference< view::XSelectionSupplier > xSelectionSupplier( xController, uno::UNO_QUERY ); @@ -193,7 +193,7 @@ void ControllerState::update( bIsPositionableObject = (aObjectType != OBJECTTYPE_DATA_POINT) && aSelOID.isDragableObject(); bIsTextObject = aObjectType == OBJECTTYPE_TITLE; - uno::Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel )); + uno::Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( uno::Reference<chart2::XChartDocument>(xModel) )); bIsFormateableObjectSelected = bHasSelectedObject && aSelOID.isAutoGeneratedObject(); if( aObjectType==OBJECTTYPE_DIAGRAM || aObjectType==OBJECTTYPE_DIAGRAM_WALL || aObjectType==OBJECTTYPE_DIAGRAM_FLOOR ) bIsFormateableObjectSelected = DiagramHelper::isSupportingFloorAndWall( xDiagram ); @@ -205,12 +205,12 @@ void ControllerState::update( bIsDeleteableObjectSelected = ChartController::isObjectDeleteable( aSelObj ); bMayMoveSeriesForward = (aObjectType!=OBJECTTYPE_DATA_POINT) && DiagramHelper::isSeriesMoveable( - ChartModelHelper::findDiagram( xModel ), + ChartModelHelper::findDiagram( uno::Reference<chart2::XChartDocument>(xModel) ), xGivenDataSeries, MOVE_SERIES_FORWARD ); bMayMoveSeriesBackward = (aObjectType!=OBJECTTYPE_DATA_POINT) && DiagramHelper::isSeriesMoveable( - ChartModelHelper::findDiagram( xModel ), + ChartModelHelper::findDiagram( uno::Reference<chart2::XChartDocument>(xModel) ), xGivenDataSeries, MOVE_SERIES_BACKWARD ); @@ -284,7 +284,7 @@ void ControllerState::update( bMayFormatTrendline = true; bMayDeleteTrendline = true; uno::Reference< chart2::XRegressionCurve > xRegCurve( - ObjectIdentifier::getObjectPropertySet( aSelObjCID, xModel ), uno::UNO_QUERY ); + ObjectIdentifier::getObjectPropertySet( aSelObjCID, uno::Reference<chart2::XChartDocument>(xModel) ), uno::UNO_QUERY ); // Trendline Equation bMayFormatTrendlineEquation = bMayDeleteTrendlineEquation = RegressionCurveHelper::hasEquation( xRegCurve ); @@ -297,7 +297,7 @@ void ControllerState::update( try { uno::Reference< beans::XPropertySet > xEquationProperties = - ObjectIdentifier::getObjectPropertySet( aSelObjCID, xModel ); + ObjectIdentifier::getObjectPropertySet( aSelObjCID, uno::Reference<chart2::XChartDocument>(xModel) ); if( xEquationProperties.is() ) xEquationProperties->getPropertyValue( "ShowCorrelationCoefficient" ) >>= bHasR2Value; } @@ -325,7 +325,7 @@ struct ModelState { ModelState(); - void update( const Reference< frame::XModel > & xModel ); + void update( const rtl::Reference<::chart::ChartModel> & xModel ); bool HasAnyAxis() const; bool HasAnyGrid() const; @@ -397,15 +397,11 @@ ModelState::ModelState() : bSupportsAxes(false) {} -void ModelState::update( const Reference< frame::XModel > & xModel ) +void ModelState::update( const rtl::Reference<::chart::ChartModel> & xModel ) { - Reference< chart2::XChartDocument > xChartDoc( xModel, uno::UNO_QUERY ); - Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel )); + Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( uno::Reference<chart2::XChartDocument>(xModel) )); - bIsReadOnly = true; - Reference< frame::XStorable > xStorable( xModel, uno::UNO_QUERY ); - if( xStorable.is()) - bIsReadOnly = xStorable->isReadonly(); + bIsReadOnly = xModel->isReadonly(); sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); @@ -414,11 +410,10 @@ void ModelState::update( const Reference< frame::XModel > & xModel ) bSupportsAxes = ChartTypeHelper::isSupportingMainAxis( xFirstChartType, nDimensionCount, 0 ); bIsThreeD = (nDimensionCount == 3); - if (xChartDoc.is()) + if (xModel.is()) { - ChartModel& rModel = dynamic_cast<ChartModel&>(*xChartDoc); - bHasOwnData = rModel.hasInternalDataProvider(); - bHasDataFromPivotTable = !bHasOwnData && rModel.isDataFromPivotTable(); + bHasOwnData = xModel->hasInternalDataProvider(); + bHasDataFromPivotTable = !bHasOwnData && xModel->isDataFromPivotTable(); } bHasMainTitle = TitleHelper::getTitle( TitleHelper::MAIN_TITLE, xModel ).is(); @@ -443,7 +438,7 @@ void ModelState::update( const Reference< frame::XModel > & xModel ) bHasHelpZGrid = bSupportsAxes && AxisHelper::isGridShown( 2, 0, false, xDiagram ); bHasAutoScaledText = - (ReferenceSizeProvider::getAutoResizeState( xChartDoc ) == + (ReferenceSizeProvider::getAutoResizeState( xModel ) == ReferenceSizeProvider::AUTO_RESIZE_YES); bHasLegend = LegendHelper::hasLegend( xDiagram ); @@ -491,11 +486,10 @@ void ControllerCommandDispatch::initialize() if( !m_xChartController.is()) return; - Reference< frame::XModel > xModel( m_xChartController->getModel()); - Reference< util::XModifyBroadcaster > xModifyBroadcaster( xModel, uno::UNO_QUERY ); - OSL_ASSERT( xModifyBroadcaster.is()); - if( xModifyBroadcaster.is()) - xModifyBroadcaster->addModifyListener( this ); + rtl::Reference<::chart::ChartModel> xModel( m_xChartController->getChartModel()); + OSL_ASSERT( xModel.is()); + if( xModel.is()) + xModel->addModifyListener( this ); // Listen selection modifications (Arrangement feature - issue 63017). if( m_xSelectionSupplier.is() ) @@ -795,14 +789,14 @@ void SAL_CALL ControllerCommandDispatch::modified( const lang::EventObject& aEve // Update the "ModelState" Struct. if( m_apModelState && m_xChartController.is()) { - m_apModelState->update( m_xChartController->getModel()); + m_apModelState->update( m_xChartController->getChartModel()); bUpdateCommandAvailability = true; } // Update the "ControllerState" Struct. if( m_apControllerState && m_xChartController.is()) { - m_apControllerState->update( m_xChartController, m_xChartController->getModel()); + m_apControllerState->update( m_xChartController, m_xChartController->getChartModel()); bUpdateCommandAvailability = true; } @@ -825,7 +819,7 @@ void SAL_CALL ControllerCommandDispatch::selectionChanged( const lang::EventObje // Update the "ControllerState" Struct. if( m_apControllerState && m_xChartController.is()) { - m_apControllerState->update( m_xChartController, m_xChartController->getModel()); + m_apControllerState->update( m_xChartController, m_xChartController->getChartModel()); updateCommandAvailability(); } diff --git a/chart2/source/controller/main/DragMethod_Base.cxx b/chart2/source/controller/main/DragMethod_Base.cxx index 9e01d5c3bd7b..d1885e333077 100644 --- a/chart2/source/controller/main/DragMethod_Base.cxx +++ b/chart2/source/controller/main/DragMethod_Base.cxx @@ -19,7 +19,7 @@ #include "DragMethod_Base.hxx" #include <DrawViewWrapper.hxx> - +#include <ChartModel.hxx> #include <ObjectNameProvider.hxx> #include <ObjectIdentifier.hxx> @@ -36,13 +36,13 @@ using ::com::sun::star::uno::WeakReference; DragMethod_Base::DragMethod_Base( DrawViewWrapper& rDrawViewWrapper , const OUString& rObjectCID - , const Reference< frame::XModel >& xChartModel + , const rtl::Reference<::chart::ChartModel>& xChartModel , ActionDescriptionProvider::ActionType eActionType ) : SdrDragMethod( rDrawViewWrapper ) , m_rDrawViewWrapper(rDrawViewWrapper) , m_aObjectCID(rObjectCID) , m_eActionType( eActionType ) - , m_xChartModel( WeakReference< frame::XModel >(xChartModel) ) + , m_xChartModel( xChartModel.get() ) { setMoveOnly(true); } @@ -50,9 +50,9 @@ DragMethod_Base::~DragMethod_Base() { } -Reference< frame::XModel > DragMethod_Base::getChartModel() const +rtl::Reference<::chart::ChartModel> DragMethod_Base::getChartModel() const { - return Reference< frame::XModel >( m_xChartModel ); + return m_xChartModel.get(); } OUString DragMethod_Base::getUndoDescription() const diff --git a/chart2/source/controller/main/DragMethod_Base.hxx b/chart2/source/controller/main/DragMethod_Base.hxx index b036da0e9fdf..497b31f6e88d 100644 --- a/chart2/source/controller/main/DragMethod_Base.hxx +++ b/chart2/source/controller/main/DragMethod_Base.hxx @@ -20,19 +20,20 @@ #include <svx/ActionDescriptionProvider.hxx> #include <svx/svddrgmt.hxx> -#include <cppuhelper/weakref.hxx> +#include <unotools/weakref.hxx> namespace chart { class DrawViewWrapper; } namespace com::sun::star::frame { class XModel; } namespace chart { +class ChartModel; class DragMethod_Base : public SdrDragMethod { public: DragMethod_Base( DrawViewWrapper& rDrawViewWrapper, const OUString& rObjectCID - , const css::uno::Reference< css::frame::XModel >& xChartModel + , const rtl::Reference<::chart::ChartModel>& xChartModel , ActionDescriptionProvider::ActionType eActionType = ActionDescriptionProvider::ActionType::Move ); virtual ~DragMethod_Base() override; @@ -42,7 +43,7 @@ public: virtual PointerStyle GetSdrDragPointer() const override; protected: - css::uno::Reference< css::frame::XModel > getChartModel() const; + rtl::Reference<::chart::ChartModel> getChartModel() const; protected: DrawViewWrapper& m_rDrawViewWrapper; @@ -50,7 +51,7 @@ protected: ActionDescriptionProvider::ActionType m_eActionType; private: - css::uno::WeakReference< css::frame::XModel > m_xChartModel; + unotools::WeakReference<::chart::ChartModel> m_xChartModel; }; } // namespace chart diff --git a/chart2/source/controller/main/DragMethod_PieSegment.cxx b/chart2/source/controller/main/DragMethod_PieSegment.cxx index 100846ba9357..3ba3e5a9f205 100644 --- a/chart2/source/controller/main/DragMethod_PieSegment.cxx +++ b/chart2/source/controller/main/DragMethod_PieSegment.cxx @@ -19,7 +19,7 @@ #include "DragMethod_PieSegment.hxx" #include <DrawViewWrapper.hxx> - +#include <ChartModel.hxx> #include <strings.hrc> #include <ResId.hxx> #include <ObjectIdentifier.hxx> @@ -38,7 +38,7 @@ using ::basegfx::B2DVector; DragMethod_PieSegment::DragMethod_PieSegment( DrawViewWrapper& rDrawViewWrapper , const OUString& rObjectCID - , const Reference< frame::XModel >& xChartModel ) + , const rtl::Reference<::chart::ChartModel>& xChartModel ) : DragMethod_Base( rDrawViewWrapper, rObjectCID, xChartModel ) , m_aStartVector(100.0,100.0) , m_fInitialOffset(0.0) @@ -112,11 +112,11 @@ bool DragMethod_PieSegment::EndSdrDrag(bool /*bCopy*/) try { - Reference< frame::XModel > xChartModel( getChartModel() ); + rtl::Reference<::chart::ChartModel> xChartModel( getChartModel() ); if( xChartModel.is() ) { Reference< beans::XPropertySet > xPointProperties( - ObjectIdentifier::getObjectPropertySet( m_aObjectCID, xChartModel ) ); + ObjectIdentifier::getObjectPropertySet( m_aObjectCID, uno::Reference<chart2::XChartDocument>(xChartModel) ) ); if( xPointProperties.is() ) xPointProperties->setPropertyValue( "Offset", uno::Any( m_fAdditionalOffset+m_fInitialOffset )); } diff --git a/chart2/source/controller/main/DragMethod_PieSegment.hxx b/chart2/source/controller/main/DragMethod_PieSegment.hxx index 14090203272f..8a36dbd4c876 100644 --- a/chart2/source/controller/main/DragMethod_PieSegment.hxx +++ b/chart2/source/controller/main/DragMethod_PieSegment.hxx @@ -28,7 +28,7 @@ class DragMethod_PieSegment : public DragMethod_Base { public: DragMethod_PieSegment( DrawViewWrapper& rDrawViewWrapper, const OUString& rObjectCID - , const css::uno::Reference< css::frame::XModel >& xChartModel ); + , const rtl::Reference<::chart::ChartModel>& xChartModel ); virtual ~DragMethod_PieSegment() override; virtual OUString GetSdrDragComment() const override; diff --git a/chart2/source/controller/main/DragMethod_RotateDiagram.cxx b/chart2/source/controller/main/DragMethod_RotateDiagram.cxx index b8a0b7d13fb5..63e111d84be7 100644 --- a/chart2/source/controller/main/DragMethod_RotateDiagram.cxx +++ b/chart2/source/controller/main/DragMethod_RotateDiagram.cxx @@ -22,6 +22,7 @@ #include <SelectionHelper.hxx> #include <ChartModelHelper.hxx> +#include <ChartModel.hxx> #include <DiagramHelper.hxx> #include <ChartTypeHelper.hxx> #include <ThreeDHelper.hxx> @@ -44,7 +45,7 @@ using ::com::sun::star::uno::Reference; DragMethod_RotateDiagram::DragMethod_RotateDiagram( DrawViewWrapper& rDrawViewWrapper , const OUString& rObjectCID - , const Reference< frame::XModel >& xChartModel + , const rtl::Reference<::chart::ChartModel>& xChartModel , RotationDirection eRotationDirection ) : DragMethod_Base( rDrawViewWrapper, rObjectCID, xChartModel, ActionDescriptionProvider::ActionType::Rotate ) , m_pScene(nullptr) @@ -72,7 +73,7 @@ DragMethod_RotateDiagram::DragMethod_RotateDiagram( DrawViewWrapper& rDrawViewWr m_aWireframePolyPolygon = m_pScene->CreateWireframe(); - uno::Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram(getChartModel()) ); + uno::Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram(uno::Reference<chart2::XChartDocument>(getChartModel())) ); uno::Reference< beans::XPropertySet > xDiagramProperties( xDiagram, uno::UNO_QUERY ); if( !xDiagramProperties.is() ) return; @@ -160,12 +161,12 @@ bool DragMethod_RotateDiagram::EndSdrDrag(bool /*bCopy*/) if(m_bRightAngledAxes) ThreeDHelper::adaptRadAnglesForRightAngledAxes( fResultX, fResultY ); - ThreeDHelper::setRotationAngleToDiagram( uno::Reference< beans::XPropertySet >( ChartModelHelper::findDiagram( getChartModel() ), uno::UNO_QUERY ) + ThreeDHelper::setRotationAngleToDiagram( uno::Reference< beans::XPropertySet >( ChartModelHelper::findDiagram( uno::Reference<chart2::XChartDocument>(getChartModel()) ), uno::UNO_QUERY ) , fResultX, fResultY, fResultZ ); } else { - ThreeDHelper::setRotationToDiagram( ( uno::Reference< beans::XPropertySet >( ChartModelHelper::findDiagram( getChartModel() ), uno::UNO_QUERY ) ) + ThreeDHelper::setRotationToDiagram( ( uno::Reference< beans::XPropertySet >( ChartModelHelper::findDiagram( uno::Reference<chart2::XChartDocument>(getChartModel()) ), uno::UNO_QUERY ) ) , m_nInitialHorizontalAngleDegree+m_nAdditionalHorizontalAngleDegree, m_nInitialVerticalAngleDegree+m_nAdditionalVerticalAngleDegree ); } diff --git a/chart2/source/controller/main/DragMethod_RotateDiagram.hxx b/chart2/source/controller/main/DragMethod_RotateDiagram.hxx index c4fe814b0e11..69e9050eeb4e 100644 --- a/chart2/source/controller/main/DragMethod_RotateDiagram.hxx +++ b/chart2/source/controller/main/DragMethod_RotateDiagram.hxx @@ -41,7 +41,7 @@ public: DragMethod_RotateDiagram( DrawViewWrapper& rDrawViewWrapper , const OUString& rObjectCID - , const css::uno::Reference< css::frame::XModel >& xChartModel + , const rtl::Reference<::chart::ChartModel>& xChartModel , RotationDirection eRotationDirection ); virtual ~DragMethod_RotateDiagram() override; diff --git a/chart2/source/controller/main/ElementSelector.cxx b/chart2/source/controller/main/ElementSelector.cxx index 8e448fa355fe..e56da4fc6173 100644 --- a/chart2/source/controller/main/ElementSelector.cxx +++ b/chart2/source/controller/main/ElementSelector.cxx @@ -25,6 +25,8 @@ #include <ResId.hxx> #include <strings.hrc> #include <ObjectIdentifier.hxx> +#include <ChartController.hxx> +#include <ChartModel.hxx> #include <cppuhelper/supportsservice.hxx> #include <o3tl/safeint.hxx> @@ -81,7 +83,7 @@ SelectorListBox::~SelectorListBox() } static void lcl_addObjectsToList( const ObjectHierarchy& rHierarchy, const ObjectIdentifier & rParent, std::vector< ListBoxEntryData >& rEntries - , const sal_Int32 nHierarchyDepth, const Reference< chart2::XChartDocument >& xChartDoc ) + , const sal_Int32 nHierarchyDepth, const rtl::Reference<::chart::ChartModel>& xChartDoc ) { ObjectHierarchy::tChildContainer aChildren( rHierarchy.getChildren(rParent) ); for (auto const& child : aChildren) @@ -95,9 +97,9 @@ static void lcl_addObjectsToList( const ObjectHierarchy& rHierarchy, const Obje } } -void SelectorListBox::SetChartController( const Reference< frame::XController >& xChartController ) +void SelectorListBox::SetChartController( const rtl::Reference< ::chart::ChartController >& xChartController ) { - m_xChartController = xChartController; + m_xChartController = xChartController.get(); } void SelectorListBox::UpdateChartElementsListAndSelection() @@ -105,19 +107,13 @@ void SelectorListBox::UpdateChartElementsListAndSelection() m_xWidget->clear(); m_aEntries.clear(); - Reference< frame::XController > xChartController( m_xChartController ); + rtl::Reference< ::chart::ChartController > xChartController = m_xChartController.get(); if( xChartController.is() ) { - Reference< view::XSelectionSupplier > xSelectionSupplier( xChartController, uno::UNO_QUERY); - ObjectIdentifier aSelectedOID; - OUString aSelectedCID; - if( xSelectionSupplier.is() ) - { - aSelectedOID = ObjectIdentifier( xSelectionSupplier->getSelection() ); - aSelectedCID = aSelectedOID.getObjectCID(); - } + ObjectIdentifier aSelectedOID( xChartController->getSelection() ); + OUString aSelectedCID = aSelectedOID.getObjectCID(); - Reference< chart2::XChartDocument > xChartDoc( xChartController->getModel(), uno::UNO_QUERY ); + rtl::Reference<::chart::ChartModel> xChartDoc = xChartController->getChartModel(); ObjectType eType( aSelectedOID.getObjectType() ); bool bAddSelectionToList = false; if ( eType == OBJECTTYPE_DATA_POINT || eType == OBJECTTYPE_DATA_LABEL || eType == OBJECTTYPE_SHAPE ) @@ -190,7 +186,7 @@ void SelectorListBox::ReleaseFocus_Impl() return; } - Reference< frame::XController > xController( m_xChartController ); + rtl::Reference< ::chart::ChartController > xController = m_xChartController.get(); Reference< frame::XFrame > xFrame( xController->getFrame() ); if ( xFrame.is() && xFrame->getContainerWindow().is() ) xFrame->getContainerWindow()->setFocus(); @@ -204,9 +200,9 @@ IMPL_LINK(SelectorListBox, SelectHdl, weld::ComboBox&, rComboBox, void) if (o3tl::make_unsigned(nPos) < m_aEntries.size()) { ObjectIdentifier aOID = m_aEntries[nPos].OID; - Reference< view::XSelectionSupplier > xSelectionSupplier( m_xChartController.get(), uno::UNO_QUERY ); - if( xSelectionSupplier.is() ) - xSelectionSupplier->select( aOID.getAny() ); + rtl::Reference< ::chart::ChartController > xController = m_xChartController.get(); + if( xController.is() ) + xController->select( aOID.getAny() ); } ReleaseFocus_Impl(); } @@ -291,7 +287,9 @@ void SAL_CALL ElementSelectorToolbarController::statusChanged( const frame::Feat { Reference< frame::XController > xChartController; rEvent.State >>= xChartController; - m_apSelectorListBox->SetChartController( xChartController ); + ::chart::ChartController* pController = dynamic_cast<::chart::ChartController*>(xChartController.get()); + assert(pController); + m_apSelectorListBox->SetChartController( pController ); m_apSelectorListBox->UpdateChartElementsListAndSelection(); } } diff --git a/chart2/source/controller/main/ElementSelector.hxx b/chart2/source/controller/main/ElementSelector.hxx index 67305fcf8266..5467dd161299 100644 --- a/chart2/source/controller/main/ElementSelector.hxx +++ b/chart2/source/controller/main/ElementSelector.hxx @@ -25,10 +25,11 @@ #include <svtools/toolboxcontroller.hxx> #include <vcl/InterimItemWindow.hxx> -#include <cppuhelper/weakref.hxx> +#include <unotools/weakref.hxx> namespace chart { +class ChartController; struct ListBoxEntryData { @@ -50,11 +51,11 @@ public: void ReleaseFocus_Impl(); - void SetChartController( const css::uno::Reference< css::frame::XController >& xChartController ); + void SetChartController( const rtl::Reference< ::chart::ChartController >& xChartController ); void UpdateChartElementsListAndSelection(); private: - css::uno::WeakReference<css::frame::XController> m_xChartController; + unotools::WeakReference<::chart::ChartController> m_xChartController; std::unique_ptr<weld::ComboBox> m_xWidget; std::vector<ListBoxEntryData> m_aEntries; diff --git a/chart2/source/controller/main/StatusBarCommandDispatch.cxx b/chart2/source/controller/main/StatusBarCommandDispatch.cxx index 1e6c06c35b6f..1b867cb562f8 100644 --- a/chart2/source/controller/main/StatusBarCommandDispatch.cxx +++ b/chart2/source/controller/main/StatusBarCommandDispatch.cxx @@ -22,6 +22,7 @@ #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> #include <com/sun/star/util/XModifiable.hpp> +#include <ChartModel.hxx> using namespace ::com::sun::star; @@ -33,10 +34,10 @@ namespace chart StatusBarCommandDispatch::StatusBarCommandDispatch( const Reference< uno::XComponentContext > & xContext, - const Reference< frame::XModel > & xModel, + const rtl::Reference<::chart::ChartModel> & xModel, const Reference< view::XSelectionSupplier > & xSelSupp ) : impl::StatusBarCommandDispatch_Base( xContext ), - m_xModifiable( xModel, uno::UNO_QUERY ), + m_xChartModel( xModel ), m_xSelectionSupplier( xSelSupp ), m_bIsModified( false ) {} @@ -46,9 +47,9 @@ StatusBarCommandDispatch::~StatusBarCommandDispatch() void StatusBarCommandDispatch::initialize() { - if( m_xModifiable.is()) + if( m_xChartModel.is()) { - m_xModifiable->addModifyListener( this ); + m_xChartModel->addModifyListener( this ); } if( m_xSelectionSupplier.is()) @@ -68,8 +69,7 @@ void StatusBarCommandDispatch::fireStatusEvent( if( bFireContext ) { uno::Any aArg; - Reference< chart2::XChartDocument > xDoc( m_xModifiable, uno::UNO_QUERY ); - aArg <<= ObjectNameProvider::getSelectedObjectText( m_aSelectedOID.getObjectCID(), xDoc ); + aArg <<= ObjectNameProvider::getSelectedObjectText( m_aSelectedOID.getObjectCID(), m_xChartModel ); fireStatusEventForURL( ".uno:Context", aArg, true, xSingleListener ); } if( bFireModified ) @@ -93,22 +93,22 @@ void SAL_CALL StatusBarCommandDispatch::dispatch( /// is called when this is disposed void SAL_CALL StatusBarCommandDispatch::disposing() { - m_xModifiable.clear(); + m_xChartModel.clear(); m_xSelectionSupplier.clear(); } // ____ XEventListener (base of XModifyListener) ____ void SAL_CALL StatusBarCommandDispatch::disposing( const lang::EventObject& /* Source */ ) { - m_xModifiable.clear(); + m_xChartModel.clear(); m_xSelectionSupplier.clear(); } // ____ XModifyListener ____ void SAL_CALL StatusBarCommandDispatch::modified( const lang::EventObject& aEvent ) { - if( m_xModifiable.is()) - m_bIsModified = m_xModifiable->isModified(); + if( m_xChartModel.is()) + m_bIsModified = m_xChartModel->isModified(); CommandDispatch::modified( aEvent ); } diff --git a/chart2/source/controller/main/StatusBarCommandDispatch.hxx b/chart2/source/controller/main/StatusBarCommandDispatch.hxx index 4551eb5a0c57..c123475c037f 100644 --- a/chart2/source/controller/main/StatusBarCommandDispatch.hxx +++ b/chart2/source/controller/main/StatusBarCommandDispatch.hxx @@ -22,6 +22,7 @@ #include <ObjectIdentifier.hxx> #include <cppuhelper/implbase.hxx> #include <com/sun/star/view/XSelectionChangeListener.hpp> +#include <rtl/ref.hxx> namespace com::sun::star::frame { class XModel; } namespace com::sun::star::util { class XModifiable; } @@ -48,7 +49,7 @@ class StatusBarCommandDispatch : public impl::StatusBarCommandDispatch_Base public: explicit StatusBarCommandDispatch( const css::uno::Reference< css::uno::XComponentContext > & xContext, - const css::uno::Reference< css::frame::XModel > & xModel, + const rtl::Reference<::chart::ChartModel> & xModel, const css::uno::Reference< css::view::XSelectionSupplier > & xSelSupp ); virtual ~StatusBarCommandDispatch() override; @@ -82,7 +83,7 @@ protected: const css::lang::EventObject& aEvent ) override; private: - css::uno::Reference< css::util::XModifiable > m_xModifiable; + rtl::Reference<::chart::ChartModel> m_xChartModel; css::uno::Reference< css::view::XSelectionSupplier > m_xSelectionSupplier; bool m_bIsModified; ObjectIdentifier m_aSelectedOID; diff --git a/chart2/source/controller/main/UndoActions.cxx b/chart2/source/controller/main/UndoActions.cxx index 48f156b4f730..6d043137d464 100644 --- a/chart2/source/controller/main/UndoActions.cxx +++ b/chart2/source/controller/main/UndoActions.cxx @@ -19,6 +19,7 @@ #include "UndoActions.hxx" #include "ChartModelClone.hxx" +#include <ChartModel.hxx> #include <com/sun/star/lang/DisposedException.hpp> @@ -34,7 +35,7 @@ namespace chart::impl using ::com::sun::star::frame::XModel; using ::com::sun::star::lang::DisposedException; -UndoElement::UndoElement( const OUString& i_actionString, const Reference< XModel >& i_documentModel, const std::shared_ptr< ChartModelClone >& i_modelClone ) +UndoElement::UndoElement( const OUString& i_actionString, const rtl::Reference<::chart::ChartModel>& i_documentModel, const std::shared_ptr< ChartModelClone >& i_modelClone ) :m_sActionString( i_actionString ) ,m_xDocumentModel( i_documentModel ) ,m_pModelClone( i_modelClone ) diff --git a/chart2/source/controller/main/UndoActions.hxx b/chart2/source/controller/main/UndoActions.hxx index 8c92440cd60e..3291a72be649 100644 --- a/chart2/source/controller/main/UndoActions.hxx +++ b/chart2/source/controller/main/UndoActions.hxx @@ -20,6 +20,7 @@ #include <com/sun/star/document/XUndoAction.hpp> +#include <rtl/ref.hxx> #include <rtl/ustring.hxx> #include <comphelper/compbase.hxx> @@ -31,6 +32,7 @@ class SdrUndoAction; namespace chart { +class ChartModel; class ChartModelClone; namespace impl @@ -52,7 +54,7 @@ public: Upon <member>invoking</member>, the clone model is applied to the document model. */ UndoElement( const OUString & i_actionString, - const css::uno::Reference< css::frame::XModel >& i_documentModel, + const rtl::Reference<::chart::ChartModel>& i_documentModel, const std::shared_ptr< ChartModelClone >& i_modelClone ); virtual ~UndoElement() override; @@ -73,7 +75,7 @@ private: private: OUString m_sActionString; - css::uno::Reference< css::frame::XModel > m_xDocumentModel; + rtl::Reference<::chart::ChartModel> m_xDocumentModel; std::shared_ptr< ChartModelClone > m_pModelClone; }; diff --git a/chart2/source/controller/main/UndoCommandDispatch.cxx b/chart2/source/controller/main/UndoCommandDispatch.cxx index e4bd85a3be34..3a05412d1670 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.cxx +++ b/chart2/source/controller/main/UndoCommandDispatch.cxx @@ -18,6 +18,7 @@ */ #include "UndoCommandDispatch.hxx" +#include <ChartModel.hxx> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/util/XModifyBroadcaster.hpp> @@ -40,12 +41,11 @@ namespace chart UndoCommandDispatch::UndoCommandDispatch( const Reference< uno::XComponentContext > & xContext, - const Reference< frame::XModel > & xModel ) : + const rtl::Reference<::chart::ChartModel> & xModel ) : CommandDispatch( xContext ), m_xModel( xModel ) { - uno::Reference< document::XUndoManagerSupplier > xSuppUndo( m_xModel, uno::UNO_QUERY_THROW ); - m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_SET_THROW ); + m_xUndoManager.set( m_xModel->getUndoManager(), uno::UNO_SET_THROW ); } UndoCommandDispatch::~UndoCommandDispatch() diff --git a/chart2/source/controller/main/UndoCommandDispatch.hxx b/chart2/source/controller/main/UndoCommandDispatch.hxx index cfb0e11078df..7be241a5fbc3 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.hxx +++ b/chart2/source/controller/main/UndoCommandDispatch.hxx @@ -19,12 +19,14 @@ #pragma once #include "CommandDispatch.hxx" +#include <rtl/ref.hxx> namespace com::sun::star::document { class XUndoManager; } namespace com::sun::star::frame { class XModel; } namespace chart { +class ChartModel; /** This is a CommandDispatch implementation for Undo and Redo. */ @@ -33,7 +35,7 @@ class UndoCommandDispatch : public CommandDispatch public: explicit UndoCommandDispatch( const css::uno::Reference< css::uno::XComponentContext > & xContext, - const css::uno::Reference< css::frame::XModel > & xModel ); + const rtl::Reference<::chart::ChartModel> & xModel ); virtual ~UndoCommandDispatch() override; // late initialisation, especially for adding as listener @@ -58,7 +60,7 @@ protected: const css::uno::Reference< css::frame::XStatusListener > & xSingleListener ) override; private: - css::uno::Reference< css::frame::XModel > m_xModel; + rtl::Reference<::chart::ChartModel> m_xModel; css::uno::Reference< css::document::XUndoManager > m_xUndoManager; }; diff --git a/chart2/source/controller/main/UndoGuard.cxx b/chart2/source/controller/main/UndoGuard.cxx index e10d9216137d..420347eb40d4 100644 --- a/chart2/source/controller/main/UndoGuard.cxx +++ b/chart2/source/controller/main/UndoGuard.cxx @@ -20,6 +20,7 @@ #include "UndoGuard.hxx" #include "ChartModelClone.hxx" #include "UndoActions.hxx" +#include <ChartModel.hxx> #include <com/sun/star/document/XUndoManager.hpp> #include <com/sun/star/frame/XModel.hpp> @@ -35,11 +36,12 @@ namespace chart UndoGuard::UndoGuard( const OUString& i_undoString, const uno::Reference< document::XUndoManager > & i_undoManager, const ModelFacet i_facet ) - :m_xChartModel( i_undoManager->getParent(), uno::UNO_QUERY_THROW ) - ,m_xUndoManager( i_undoManager ) + :m_xUndoManager( i_undoManager ) ,m_aUndoString( i_undoString ) ,m_bActionPosted( false ) { + m_xChartModel = dynamic_cast<::chart::ChartModel*>(i_undoManager->getParent().get()); + assert(m_xChartModel); m_pDocumentSnapshot = std::make_shared<ChartModelClone>( m_xChartModel, i_facet ); } diff --git a/chart2/source/controller/main/UndoGuard.hxx b/chart2/source/controller/main/UndoGuard.hxx index c983854e2fcd..9808da8bc1ad 100644 --- a/chart2/source/controller/main/UndoGuard.hxx +++ b/chart2/source/controller/main/UndoGuard.hxx @@ -53,7 +53,7 @@ private: void discardSnapshot(); private: - const css::uno::Reference< css::frame::XModel > m_xChartModel; + rtl::Reference<::chart::ChartModel> m_xChartModel; const css::uno::Reference< css::document::XUndoManager > m_xUndoManager; std::shared_ptr< ChartModelClone > m_pDocumentSnapshot; |