From b0e0a74d72af09c01e0c6e1324b42fcc2ef55451 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 13 Jan 2023 19:18:46 +0200 Subject: use more concrete types in chart Change-Id: I87a7aed6f0168e92f3de7e188a1858b93b44a9cd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145489 Tested-by: Jenkins Reviewed-by: Noel Grandin --- .../controller/dialogs/dlg_InsertErrorBars.cxx | 5 ++-- chart2/source/controller/inc/ChartController.hxx | 5 ++-- .../source/controller/inc/dlg_InsertErrorBars.hxx | 10 ++++--- chart2/source/controller/main/ChartController.cxx | 24 +++++++--------- .../controller/main/ChartController_Insert.cxx | 1 + .../controller/main/ChartController_Position.cxx | 6 ++-- .../controller/main/ChartController_Properties.cxx | 3 +- .../controller/main/ChartController_TextEdit.cxx | 11 ++++---- .../controller/main/ChartController_Window.cxx | 32 ++++++++-------------- chart2/source/controller/uitest/uiobject.cxx | 8 +++--- 10 files changed, 48 insertions(+), 57 deletions(-) diff --git a/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx b/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx index 6d3aa87d20a0..7f00dcc976db 100644 --- a/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx +++ b/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -68,12 +69,12 @@ void InsertErrorBarsDialog::SetAxisMinorStepWidthForErrorBarDecimals( double fMi double InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( const rtl::Reference<::chart::ChartModel>& xChartModel, - const Reference< uno::XInterface >& xChartView, + const rtl::Reference<::chart::ChartView>& xChartView, std::u16string_view rSelectedObjectCID ) { double fStepWidth = 0.001; - ExplicitValueProvider* pExplicitValueProvider( comphelper::getFromUnoTunnel(xChartView) ); + ExplicitValueProvider* pExplicitValueProvider( xChartView.get() ); if( pExplicitValueProvider ) { rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); diff --git a/chart2/source/controller/inc/ChartController.hxx b/chart2/source/controller/inc/ChartController.hxx index f948e3bc6303..63fb4d4fc302 100644 --- a/chart2/source/controller/inc/ChartController.hxx +++ b/chart2/source/controller/inc/ChartController.hxx @@ -83,6 +83,7 @@ namespace chart { class UndoGuard; +class ChartView; class ChartWindow; class DrawModelWrapper; class DrawViewWrapper; @@ -341,7 +342,7 @@ public: void NotifyUndoActionHdl( std::unique_ptr ); - css::uno::Reference const & getChartView() const; + rtl::Reference<::chart::ChartView> const & getChartView() const { return m_xChartView; } rtl::Reference<::chart::ChartModel> getChartModel(); rtl::Reference<::chart::Diagram> getFirstDiagram(); @@ -395,7 +396,7 @@ private: //view css::uno::Reference m_xViewWindow; - css::uno::Reference m_xChartView; + rtl::Reference<::chart::ChartView> m_xChartView; std::shared_ptr< DrawModelWrapper > m_pDrawModelWrapper; std::unique_ptr m_pDrawViewWrapper; diff --git a/chart2/source/controller/inc/dlg_InsertErrorBars.hxx b/chart2/source/controller/inc/dlg_InsertErrorBars.hxx index 59911c2f5ed2..4f8e8d094a34 100644 --- a/chart2/source/controller/inc/dlg_InsertErrorBars.hxx +++ b/chart2/source/controller/inc/dlg_InsertErrorBars.hxx @@ -31,6 +31,8 @@ class XModel; namespace chart { +class ChartView; + class InsertErrorBarsDialog final : public weld::GenericDialogController { public: @@ -40,10 +42,10 @@ public: void SetAxisMinorStepWidthForErrorBarDecimals(double fMinorStepWidth); - static double getAxisMinorStepWidthForErrorBarDecimals( - const rtl::Reference<::chart::ChartModel>& xChartModel, - const css::uno::Reference& xChartView, - std::u16string_view rSelectedObjectCID); + static double + getAxisMinorStepWidthForErrorBarDecimals(const rtl::Reference<::chart::ChartModel>& xChartModel, + const rtl::Reference<::chart::ChartView>& xChartView, + std::u16string_view rSelectedObjectCID); void FillItemSet(SfxItemSet& rOutAttrs); diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 1a59bb161ec3..6007499248c1 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -543,9 +544,8 @@ sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XMo //--handle relations to the old model if any if( aOldModelRef.is() ) { - uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY ); - if( xViewBroadcaster.is() ) - xViewBroadcaster->removeModeChangeListener(this); + if( m_xChartView.is() ) + m_xChartView->removeModeChangeListener(this); m_pDrawModelWrapper.reset(); aOldModelRef->removeListener( this ); @@ -590,11 +590,9 @@ sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XMo rtl::Reference< ChartModel > xFact = getChartModel(); if( xFact.is()) { - m_xChartView = xFact->createInstance( CHART_VIEW_SERVICE_NAME ); + m_xChartView = dynamic_cast<::chart::ChartView*>(xFact->createInstance( CHART_VIEW_SERVICE_NAME ).get()); GetDrawModelWrapper(); - uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY ); - if( xViewBroadcaster.is() ) - xViewBroadcaster->addModeChangeListener(this); + m_xChartView->addModeChangeListener(this); } //the frameloader is responsible to call xModel->connectController @@ -799,9 +797,8 @@ void SAL_CALL ChartController::dispose() //--release all resources and references { - uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY ); - if( xViewBroadcaster.is() ) - xViewBroadcaster->removeModeChangeListener(this); + if( m_xChartView.is() ) + m_xChartView->removeModeChangeListener(this); impl_invalidateAccessible(); SolarMutexGuard aSolarGuard; @@ -1513,9 +1510,8 @@ DrawModelWrapper* ChartController::GetDrawModelWrapper() { if( !m_pDrawModelWrapper ) { - ExplicitValueProvider* pProvider = comphelper::getFromUnoTunnel( m_xChartView ); - if( pProvider ) - m_pDrawModelWrapper = pProvider->getDrawModelWrapper(); + if( m_xChartView ) + m_pDrawModelWrapper = m_xChartView->getDrawModelWrapper(); if ( m_pDrawModelWrapper ) { m_pDrawModelWrapper->getSdrModel().SetNotifyUndoActionHdl( @@ -1621,7 +1617,7 @@ void ChartController::impl_initializeAccessible( const uno::Reference< lang::XIn } uno::Sequence< uno::Any > aArguments{ uno::Any(uno::Reference(this)), uno::Any(getModel()), - uno::Any(m_xChartView), + uno::Any(uno::Reference(static_cast(m_xChartView.get()))), uno::Any(xParent), uno::Any(m_xViewWindow) }; diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index 40a0a86b1e95..7e8d0f4bd105 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -19,6 +19,7 @@ #include #include +#include #include #include diff --git a/chart2/source/controller/main/ChartController_Position.cxx b/chart2/source/controller/main/ChartController_Position.cxx index bc11bec5dff3..9e7194eca890 100644 --- a/chart2/source/controller/main/ChartController_Position.cxx +++ b/chart2/source/controller/main/ChartController_Position.cxx @@ -23,6 +23,7 @@ #include #include #include +#include #include "UndoGuard.hxx" #include #include @@ -170,9 +171,8 @@ void ChartController::executeDispatch_PositionAndSize(const ::css::uno::Sequence if(pOutItemSet || pArgs) { awt::Rectangle aOldObjectRect; - ExplicitValueProvider* pProvider(comphelper::getFromUnoTunnel( m_xChartView )); - if( pProvider ) - aOldObjectRect = pProvider->getRectangleOfObject(aCID); + if( m_xChartView ) + aOldObjectRect = m_xChartView->getRectangleOfObject(aCID); awt::Rectangle aNewObjectRect; lcl_getPositionAndSizeFromItemSet( aItemSet, aNewObjectRect, ToSize(aOldObjectRect) ); diff --git a/chart2/source/controller/main/ChartController_Properties.cxx b/chart2/source/controller/main/ChartController_Properties.cxx index 501870ecf2b2..427ea939bd58 100644 --- a/chart2/source/controller/main/ChartController_Properties.cxx +++ b/chart2/source/controller/main/ChartController_Properties.cxx @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -739,7 +740,7 @@ bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( std::unique_ptr pItemConverter( createItemConverter( rObjectCID, getChartModel(), m_xCC, m_pDrawModelWrapper->getSdrModel(), - comphelper::getFromUnoTunnel(m_xChartView), + m_xChartView.get(), pRefSizeProv.get())); if (!pItemConverter) diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx b/chart2/source/controller/main/ChartController_TextEdit.cxx index 8d56429e3855..07a35a533b0c 100644 --- a/chart2/source/controller/main/ChartController_TextEdit.cxx +++ b/chart2/source/controller/main/ChartController_TextEdit.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -72,9 +73,8 @@ void ChartController::StartTextEdit( const Point* pMousePixel ) SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner(); //#i77362 change notification for changes on additional shapes are missing - uno::Reference< beans::XPropertySet > xChartViewProps( m_xChartView, uno::UNO_QUERY ); - if( xChartViewProps.is() ) - xChartViewProps->setPropertyValue( "SdrViewIsInEditMode", uno::Any(true) ); + if( m_xChartView.is() ) + m_xChartView->setPropertyValue( "SdrViewIsInEditMode", uno::Any(true) ); auto pChartWindow(GetChartWindow()); @@ -117,9 +117,8 @@ bool ChartController::EndTextEdit() m_pDrawViewWrapper->SdrEndTextEdit(); //#i77362 change notification for changes on additional shapes are missing - uno::Reference< beans::XPropertySet > xChartViewProps( m_xChartView, uno::UNO_QUERY ); - if( xChartViewProps.is() ) - xChartViewProps->setPropertyValue( "SdrViewIsInEditMode", uno::Any(false) ); + if( m_xChartView.is() ) + m_xChartView->setPropertyValue( "SdrViewIsInEditMode", uno::Any(false) ); SdrObject* pTextObject = m_pDrawViewWrapper->getTextEditObject(); if(!pTextObject) diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 70ab5436e148..5a16f1ca96bb 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -266,8 +267,7 @@ void SAL_CALL ChartController::setPosSize( pChartWindow->setPosSizePixel( X, Y, Width, Height, static_cast(Flags) ); //#i75867# poor quality of ole's alternative view with 3D scenes and zoomfactors besides 100% - uno::Reference< beans::XPropertySet > xProp( m_xChartView, uno::UNO_QUERY ); - if( xProp.is() ) + if( m_xChartView.is() ) { auto aZoomFactors(::comphelper::InitPropertySequence({ { "ScaleXNumerator", uno::Any( nScaleXNumerator ) }, @@ -275,7 +275,7 @@ void SAL_CALL ChartController::setPosSize( { "ScaleYNumerator", uno::Any( nScaleYNumerator ) }, { "ScaleYDenominator", uno::Any( nScaleYDenominator ) } })); - xProp->setPropertyValue( "ZoomFactors", uno::Any( aZoomFactors )); + m_xChartView->setPropertyValue( "ZoomFactors", uno::Any( aZoomFactors )); } //a correct work area is at least necessary for correct values in the position and size dialog and for dragging area @@ -468,8 +468,7 @@ void ChartController::execute_Paint(vcl::RenderContext& rRenderContext, const to return; //better performance for big data - uno::Reference xProp(m_xChartView, uno::UNO_QUERY); - if (xProp.is()) + if (m_xChartView.is()) { awt::Size aResolution(1000, 1000); { @@ -481,12 +480,11 @@ void ChartController::execute_Paint(vcl::RenderContext& rRenderContext, const to aResolution.Height = pChartWindow->GetSizePixel().Height(); } } - xProp->setPropertyValue( "Resolution", uno::Any( aResolution )); + m_xChartView->setPropertyValue( "Resolution", uno::Any( aResolution )); } - uno::Reference< util::XUpdatable > xUpdatable( m_xChartView, uno::UNO_QUERY ); - if (xUpdatable.is()) - xUpdatable->update(); + if (m_xChartView.is()) + m_xChartView->update(); { SolarMutexGuard aGuard; @@ -1372,7 +1370,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) { // Navigation (Tab/F3/Home/End) rtl::Reference<::chart::ChartModel> xChartDoc( getChartModel() ); - ObjectKeyNavigation aObjNav( m_aSelection.getSelectedOID(), xChartDoc, comphelper::getFromUnoTunnel( m_xChartView )); + ObjectKeyNavigation aObjNav( m_aSelection.getSelectedOID(), xChartDoc, m_xChartView.get() ); awt::KeyEvent aKeyEvent( ::svt::AcceleratorExecute::st_VCLKey2AWTKey( aKeyCode )); bReturn = aObjNav.handleKeyEvent( aKeyEvent ); if( bReturn ) @@ -1638,10 +1636,8 @@ bool ChartController::requestQuickHelp( rOutQuickHelpText = ObjectNameProvider::getHelpText( aCID, xChartModel, bIsBalloonHelp /* bVerbose */ ); // set rectangle - ExplicitValueProvider * pValueProvider( - comphelper::getFromUnoTunnel( m_xChartView )); - if( pValueProvider ) - rOutEqualRect = pValueProvider->getRectangleOfObject( aCID, true ); + if( m_xChartView ) + rOutEqualRect = m_xChartView->getRectangleOfObject( aCID, true ); } return bResult; @@ -1793,8 +1789,7 @@ bool ChartController::impl_moveOrResizeObject( if( ( bDeterminePos || bDetermineSize ) && ( aRefSize.Width > 0 && aRefSize.Height > 0 ) ) { - ExplicitValueProvider * pValueProvider( - comphelper::getFromUnoTunnel( m_xChartView )); + ExplicitValueProvider * pValueProvider( m_xChartView.get() ); if( pValueProvider ) { awt::Rectangle aRect( pValueProvider->getRectangleOfObject( rCID )); @@ -2061,11 +2056,6 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent ) pChartWindow->SetPointer( PointerStyle::Arrow ); } -css::uno::Reference const & ChartController::getChartView() const -{ - return m_xChartView; -} - void ChartController::sendPopupRequest(std::u16string_view rCID, tools::Rectangle aRectangle) { ChartModel* pChartModel = m_aModel->getModel().get(); diff --git a/chart2/source/controller/uitest/uiobject.cxx b/chart2/source/controller/uitest/uiobject.cxx index 427976767425..531978db13d7 100644 --- a/chart2/source/controller/uitest/uiobject.cxx +++ b/chart2/source/controller/uitest/uiobject.cxx @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -173,10 +174,9 @@ std::set ChartWindowUIObject::get_children() const if (!pController) return aChildren; - rtl::Reference<::chart::ChartModel> xChartDoc( pController->getChartModel() ); - - css::uno::Reference xChartView = pController->getChartView(); - chart::ExplicitValueProvider* pValueProvider = comphelper::getFromUnoTunnel( xChartView ); + rtl::Reference<::chart::ChartModel> xChartDoc = pController->getChartModel(); + rtl::Reference<::chart::ChartView> xChartView = pController->getChartView(); + chart::ExplicitValueProvider* pValueProvider = xChartView.get(); chart::ObjectHierarchy aHierarchy(xChartDoc, pValueProvider); chart::ObjectIdentifier aIdentifier = chart::ObjectHierarchy::getRootNodeOID(); aChildren.insert(aIdentifier.getObjectCID()); -- cgit