chart2/inc/ChartView.hxx | 4 + chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx | 6 +- chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx | 5 + chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx | 4 - chart2/source/controller/inc/ChartDocumentWrapper.hxx | 5 + chart2/source/controller/main/ObjectHierarchy.cxx | 7 +- chart2/source/controller/main/ShapeController.cxx | 14 ++-- chart2/source/inc/chartview/DrawModelWrapper.hxx | 12 ++-- chart2/source/view/inc/ShapeFactory.hxx | 7 +- chart2/source/view/main/ChartView.cxx | 16 ++--- chart2/source/view/main/DrawModelWrapper.cxx | 29 ++++++---- chart2/source/view/main/ShapeFactory.cxx | 7 +- 12 files changed, 62 insertions(+), 54 deletions(-)
New commits: commit 610ebe90e15176a9106552790c896a8f29a3cbc7 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sat Jan 1 12:31:27 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sun Jan 2 11:38:29 2022 +0100 use concrete types in chart2, SvxDrawPage Change-Id: I0bdaa74595c0201a04490e293619c2c399ab03bd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127838 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/chart2/inc/ChartView.hxx b/chart2/inc/ChartView.hxx index 2830e89309f8..fb73f06a2d1f 100644 --- a/chart2/inc/ChartView.hxx +++ b/chart2/inc/ChartView.hxx @@ -34,6 +34,8 @@ #include <com/sun/star/util/XModeChangeBroadcaster.hpp> #include <com/sun/star/util/XModifyListener.hpp> #include <com/sun/star/util/XUpdatable2.hpp> +#include <rtl/ref.hxx> +#include <svx/unopage.hxx> #include <vector> #include <memory> @@ -213,7 +215,7 @@ private: //member css::uno::Reference< css::lang::XMultiServiceFactory> m_xShapeFactory; - css::uno::Reference< css::drawing::XDrawPage> + rtl::Reference<SvxDrawPage> m_xDrawPage; css::uno::Reference< css::drawing::XShapes > mxRootShape; diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx index 813b5b4339af..8f1f3ad23e9d 100644 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx @@ -117,13 +117,13 @@ ExplicitValueProvider* Chart2ModelContact::getExplicitValueProvider() const return comphelper::getFromUnoTunnel<ExplicitValueProvider>(m_xChartView); } -uno::Reference< drawing::XDrawPage > Chart2ModelContact::getDrawPage() const +rtl::Reference<SvxDrawPage> Chart2ModelContact::getDrawPage() const { - uno::Reference< drawing::XDrawPage > xResult; + rtl::Reference<SvxDrawPage> xResult; ExplicitValueProvider* pProvider( getExplicitValueProvider() ); if( pProvider ) { - xResult.set( pProvider->getDrawModelWrapper()->getMainDrawPage() ); + xResult = pProvider->getDrawModelWrapper()->getMainDrawPage(); } return xResult; } diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx index 594bd0d87f31..d101198a12d9 100644 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx @@ -22,7 +22,8 @@ #include <com/sun/star/awt/Size.hpp> #include <com/sun/star/awt/Point.hpp> #include <com/sun/star/awt/Rectangle.hpp> - +#include <rtl/ref.hxx> +#include <svx/unopage.hxx> #include <map> namespace chart { struct ExplicitIncrementData; } @@ -64,7 +65,7 @@ public: css::uno::Reference< css::chart2::XChartDocument > getChart2Document() const; css::uno::Reference< css::chart2::XDiagram > getChart2Diagram() const; - css::uno::Reference< css::drawing::XDrawPage > getDrawPage() const; + rtl::Reference<SvxDrawPage> getDrawPage() const; /** get the current values calculated for an axis in the current view in case properties are 'auto'. diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index 39ec746f3415..a4e494c9e5cb 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -976,7 +976,7 @@ Reference< drawing::XShapes > ChartDocumentWrapper::getAdditionalShapes() const { // get additional non-chart shapes for XML export uno::Reference< drawing::XShapes > xFoundShapes; - uno::Reference< drawing::XDrawPage > xDrawPage( impl_getDrawPage() ); + rtl::Reference<SvxDrawPage> xDrawPage( impl_getDrawPage() ); if( !xDrawPage.is() ) return xFoundShapes; @@ -1034,7 +1034,7 @@ uno::Reference< drawing::XDrawPage > SAL_CALL ChartDocumentWrapper::getDrawPage( return impl_getDrawPage(); } -uno::Reference< drawing::XDrawPage > ChartDocumentWrapper::impl_getDrawPage() const +rtl::Reference<SvxDrawPage> ChartDocumentWrapper::impl_getDrawPage() const { return m_spChart2ModelContact->getDrawPage(); } diff --git a/chart2/source/controller/inc/ChartDocumentWrapper.hxx b/chart2/source/controller/inc/ChartDocumentWrapper.hxx index 7eeb4646bfc7..563575a4b667 100644 --- a/chart2/source/controller/inc/ChartDocumentWrapper.hxx +++ b/chart2/source/controller/inc/ChartDocumentWrapper.hxx @@ -26,7 +26,8 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <cppuhelper/implbase.hxx> #include <unotools/eventlisteneradapter.hxx> - +#include <rtl/ref.hxx> +#include <svx/unopage.hxx> #include <memory> namespace com::sun::star::uno { class XComponentContext; } @@ -72,7 +73,7 @@ public: css::uno::Reference< css::drawing::XShapes > getAdditionalShapes() const; /// @throws css::uno::RuntimeException - css::uno::Reference< css::drawing::XDrawPage > impl_getDrawPage() const; + rtl::Reference<SvxDrawPage> impl_getDrawPage() const; protected: diff --git a/chart2/source/controller/main/ObjectHierarchy.cxx b/chart2/source/controller/main/ObjectHierarchy.cxx index 7934f58fc4d0..7ed950e05ebc 100644 --- a/chart2/source/controller/main/ObjectHierarchy.cxx +++ b/chart2/source/controller/main/ObjectHierarchy.cxx @@ -449,14 +449,13 @@ void ObjectHierarchy::createAdditionalShapesTree( ObjectHierarchy::tChildContain { if ( m_pExplicitValueProvider ) { - Reference< drawing::XDrawPage > xDrawPage( m_pExplicitValueProvider->getDrawModelWrapper()->getMainDrawPage() ); - Reference< drawing::XShapes > xDrawPageShapes( xDrawPage, uno::UNO_QUERY_THROW ); + rtl::Reference<SvxDrawPage> xDrawPage( m_pExplicitValueProvider->getDrawModelWrapper()->getMainDrawPage() ); Reference< drawing::XShapes > xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage ) ); - sal_Int32 nCount = xDrawPageShapes->getCount(); + sal_Int32 nCount = xDrawPage->getCount(); for ( sal_Int32 i = 0; i < nCount; ++i ) { Reference< drawing::XShape > xShape; - if ( xDrawPageShapes->getByIndex( i ) >>= xShape ) + if ( xDrawPage->getByIndex( i ) >>= xShape ) { if ( xShape.is() && xShape != xChartRoot ) { diff --git a/chart2/source/controller/main/ShapeController.cxx b/chart2/source/controller/main/ShapeController.cxx index a526abc60527..a85922dfa61d 100644 --- a/chart2/source/controller/main/ShapeController.cxx +++ b/chart2/source/controller/main/ShapeController.cxx @@ -561,14 +561,13 @@ SdrObject* ShapeController::getFirstAdditionalShape() if ( pDrawModelWrapper ) { Reference< drawing::XShape > xFirstShape; - Reference< drawing::XDrawPage > xDrawPage( pDrawModelWrapper->getMainDrawPage() ); - Reference< drawing::XShapes > xDrawPageShapes( xDrawPage, uno::UNO_QUERY_THROW ); + rtl::Reference<SvxDrawPage> xDrawPage( pDrawModelWrapper->getMainDrawPage() ); Reference< drawing::XShapes > xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage ) ); - sal_Int32 nCount = xDrawPageShapes->getCount(); + sal_Int32 nCount = xDrawPage->getCount(); for ( sal_Int32 i = 0; i < nCount; ++i ) { Reference< drawing::XShape > xShape; - if ( xDrawPageShapes->getByIndex( i ) >>= xShape ) + if ( xDrawPage->getByIndex( i ) >>= xShape ) { if ( xShape.is() && xShape != xChartRoot ) { @@ -601,14 +600,13 @@ SdrObject* ShapeController::getLastAdditionalShape() if ( pDrawModelWrapper ) { Reference< drawing::XShape > xLastShape; - Reference< drawing::XDrawPage > xDrawPage( pDrawModelWrapper->getMainDrawPage() ); - Reference< drawing::XShapes > xDrawPageShapes( xDrawPage, uno::UNO_QUERY_THROW ); + rtl::Reference<SvxDrawPage> xDrawPage( pDrawModelWrapper->getMainDrawPage() ); Reference< drawing::XShapes > xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage ) ); - sal_Int32 nCount = xDrawPageShapes->getCount(); + sal_Int32 nCount = xDrawPage->getCount(); for ( sal_Int32 i = nCount - 1; i >= 0; --i ) { Reference< drawing::XShape > xShape; - if ( xDrawPageShapes->getByIndex( i ) >>= xShape ) + if ( xDrawPage->getByIndex( i ) >>= xShape ) { if ( xShape.is() && xShape != xChartRoot ) { diff --git a/chart2/source/inc/chartview/DrawModelWrapper.hxx b/chart2/source/inc/chartview/DrawModelWrapper.hxx index 644501dcdace..72fad0e29eea 100644 --- a/chart2/source/inc/chartview/DrawModelWrapper.hxx +++ b/chart2/source/inc/chartview/DrawModelWrapper.hxx @@ -19,7 +19,7 @@ #pragma once #include <svx/svdmodel.hxx> - +#include <svx/unopage.hxx> #include <chartview/chartviewdllapi.hxx> namespace com::sun::star::lang { class XMultiServiceFactory; } @@ -37,8 +37,8 @@ namespace chart class OOO_DLLPUBLIC_CHARTVIEW DrawModelWrapper : private SdrModel { private: - css::uno::Reference< css::drawing::XDrawPage > m_xMainDrawPage; - css::uno::Reference< css::drawing::XDrawPage > m_xHiddenDrawPage; + rtl::Reference<SvxDrawPage> m_xMainDrawPage; + rtl::Reference<SvxDrawPage> m_xHiddenDrawPage; VclPtr<OutputDevice> m_pRefDevice; @@ -49,14 +49,14 @@ public: css::uno::Reference< css::lang::XMultiServiceFactory > getShapeFactory(); // the main page will contain the normal view objects - css::uno::Reference< css::drawing::XDrawPage > const & getMainDrawPage(); + const rtl::Reference<SvxDrawPage> & getMainDrawPage(); SAL_DLLPRIVATE void clearMainDrawPage(); // the extra page is not visible, but contains some extras like the symbols for data points - css::uno::Reference< css::drawing::XDrawPage > const & getHiddenDrawPage(); + const rtl::Reference<SvxDrawPage> & getHiddenDrawPage(); static css::uno::Reference< css::drawing::XShapes > - getChartRootShape( const css::uno::Reference< css::drawing::XDrawPage>& xPage ); + getChartRootShape( const rtl::Reference<SvxDrawPage>& xPage ); SAL_DLLPRIVATE void lockControllers(); SAL_DLLPRIVATE void unlockControllers(); diff --git a/chart2/source/view/inc/ShapeFactory.hxx b/chart2/source/view/inc/ShapeFactory.hxx index 74a8d5088518..7d5ce5091871 100644 --- a/chart2/source/view/inc/ShapeFactory.hxx +++ b/chart2/source/view/inc/ShapeFactory.hxx @@ -27,11 +27,11 @@ #include <rtl/ref.hxx> #include <rtl/ustring.hxx> #include <svx/unoshape.hxx> +#include <svx/unopage.hxx> namespace chart { struct VLineProperties; } namespace com::sun::star::beans { class XPropertySet; } namespace com::sun::star::chart2 { class XFormattedString; } -namespace com::sun::star::drawing { class XDrawPage; } namespace com::sun::star::drawing { class XShape; } namespace com::sun::star::drawing { class XShapes; } namespace com::sun::star::drawing { struct HomogenMatrix; } @@ -233,14 +233,13 @@ public: const css::uno::Reference< css::drawing::XShapes >& xTarget ); static css::uno::Reference< css::drawing::XShapes > - getOrCreateChartRootShape( const css::uno::Reference< - css::drawing::XDrawPage>& xPage ); + getOrCreateChartRootShape( const rtl::Reference<SvxDrawPage>& xPage ); static void setPageSize(const css::uno::Reference<css::drawing::XShapes>& xChartShapes, const css::awt::Size& rSize); static css::uno::Reference< css::drawing::XShapes > - getChartRootShape( const css::uno::Reference< css::drawing::XDrawPage>& xPage ); + getChartRootShape( const rtl::Reference<SvxDrawPage>& xPage ); static void makeShapeInvisible( const css::uno::Reference< css::drawing::XShape >& xShape ); diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 326a57a06fc0..a8948ca7c1b6 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -1129,7 +1129,7 @@ void ChartView::getMetaFile( const uno::Reference< io::XOutputStream >& xOutStre comphelper::makePropertyValue("ExportOnlyBackground", false), comphelper::makePropertyValue("HighContrast", bUseHighContrast), comphelper::makePropertyValue("Version", sal_Int32(SOFFICE_FILEFORMAT_50)), - comphelper::makePropertyValue("CurrentPage", uno::Reference< uno::XInterface >( m_xDrawPage, uno::UNO_QUERY )), + comphelper::makePropertyValue("CurrentPage", uno::Reference< uno::XInterface >( static_cast<cppu::OWeakObject*>(m_xDrawPage.get()), uno::UNO_QUERY )), //#i75867# poor quality of ole's alternative view with 3D scenes and zoomfactors besides 100% comphelper::makePropertyValue("ScaleXNumerator", m_nScaleXNumerator), comphelper::makePropertyValue("ScaleXDenominator", m_nScaleXDenominator), @@ -1143,7 +1143,7 @@ void ChartView::getMetaFile( const uno::Reference< io::XOutputStream >& xOutStre comphelper::makePropertyValue("FilterData", aFilterData) }; - xExporter->setSourceDocument( uno::Reference< lang::XComponent >( m_xDrawPage, uno::UNO_QUERY) ); + xExporter->setSourceDocument( m_xDrawPage ); if( xExporter->filter( aProps ) ) { xOutStream->flush(); @@ -1720,9 +1720,8 @@ bool ChartView::getExplicitValuesForAxis( SdrPage* ChartView::getSdrPage() { - auto pSvxDrawPage = comphelper::getFromUnoTunnel<SvxDrawPage>(m_xDrawPage); - if(pSvxDrawPage) - return pSvxDrawPage->GetSdrPage(); + if(m_xDrawPage) + return m_xDrawPage->GetSdrPage(); return nullptr; } @@ -2830,12 +2829,11 @@ OUString ChartView::dump() // Used for unit tests and in chartcontroller only, no need to drag in this when cross-compiling // for non-desktop impl_updateView(); - uno::Reference< drawing::XShapes > xShapes( m_xDrawPage, uno::UNO_QUERY_THROW ); - sal_Int32 n = xShapes->getCount(); + sal_Int32 n = m_xDrawPage->getCount(); OUStringBuffer aBuffer; for(sal_Int32 i = 0; i < n; ++i) { - uno::Reference< drawing::XShapes > xShape(xShapes->getByIndex(i), uno::UNO_QUERY); + uno::Reference< drawing::XShapes > xShape(m_xDrawPage->getByIndex(i), uno::UNO_QUERY); if(xShape.is()) { OUString aString = XShapeDumper::dump(mxRootShape); @@ -2843,7 +2841,7 @@ OUString ChartView::dump() } else { - uno::Reference< drawing::XShape > xSingleShape(xShapes->getByIndex(i), uno::UNO_QUERY); + uno::Reference< drawing::XShape > xSingleShape(m_xDrawPage->getByIndex(i), uno::UNO_QUERY); if(!xSingleShape.is()) continue; OUString aString = XShapeDumper::dump(xSingleShape); diff --git a/chart2/source/view/main/DrawModelWrapper.cxx b/chart2/source/view/main/DrawModelWrapper.cxx index 09daef1d6d54..d1aa44b21363 100644 --- a/chart2/source/view/main/DrawModelWrapper.cxx +++ b/chart2/source/view/main/DrawModelWrapper.cxx @@ -123,7 +123,7 @@ uno::Reference< lang::XMultiServiceFactory > DrawModelWrapper::getShapeFactory() return xShapeFactory; } -uno::Reference< drawing::XDrawPage > const & DrawModelWrapper::getMainDrawPage() +const rtl::Reference<SvxDrawPage> & DrawModelWrapper::getMainDrawPage() { if (m_xMainDrawPage.is()) return m_xMainDrawPage; @@ -138,12 +138,16 @@ uno::Reference< drawing::XDrawPage > const & DrawModelWrapper::getMainDrawPage() { // Take the first page in case of multiple pages. uno::Any aPage = xDrawPages->getByIndex(0); - aPage >>= m_xMainDrawPage; + uno::Reference<drawing::XDrawPage> xTmp; + aPage >>= xTmp; + m_xMainDrawPage = dynamic_cast<SvxDrawPage*>(xTmp.get()); + assert(m_xMainDrawPage); } if (!m_xMainDrawPage.is()) { - m_xMainDrawPage = xDrawPages->insertNewByIndex(0); + m_xMainDrawPage = dynamic_cast<SvxDrawPage*>(xDrawPages->insertNewByIndex(0).get()); + assert(m_xMainDrawPage); } //ensure that additional shapes are in front of the chart objects so create the chart root before @@ -152,7 +156,8 @@ uno::Reference< drawing::XDrawPage > const & DrawModelWrapper::getMainDrawPage() // ShapeFactory::getOrCreateShapeFactory(getShapeFactory())->getOrCreateChartRootShape( m_xMainDrawPage ); return m_xMainDrawPage; } -uno::Reference< drawing::XDrawPage > const & DrawModelWrapper::getHiddenDrawPage() + +const rtl::Reference<SvxDrawPage> & DrawModelWrapper::getHiddenDrawPage() { if( !m_xHiddenDrawPage.is() ) { @@ -163,14 +168,21 @@ uno::Reference< drawing::XDrawPage > const & DrawModelWrapper::getHiddenDrawPage if( xDrawPages->getCount()>1 ) { uno::Any aPage = xDrawPages->getByIndex( 1 ) ; - aPage >>= m_xHiddenDrawPage; + uno::Reference<drawing::XDrawPage> xTmp; + aPage >>= xTmp; + m_xHiddenDrawPage = dynamic_cast<SvxDrawPage*>(xTmp.get()); + assert(m_xHiddenDrawPage); } if(!m_xHiddenDrawPage.is()) { if( xDrawPages->getCount()==0 ) - m_xMainDrawPage = xDrawPages->insertNewByIndex( 0 ); - m_xHiddenDrawPage = xDrawPages->insertNewByIndex( 1 ); + { + m_xMainDrawPage = dynamic_cast<SvxDrawPage*>(xDrawPages->insertNewByIndex( 0 ).get()); + assert(m_xMainDrawPage); + } + m_xHiddenDrawPage = dynamic_cast<SvxDrawPage*>(xDrawPages->insertNewByIndex( 1 ).get()); + assert(m_xHiddenDrawPage); } } } @@ -192,8 +204,7 @@ void DrawModelWrapper::clearMainDrawPage() } } -uno::Reference< drawing::XShapes > DrawModelWrapper::getChartRootShape( - const uno::Reference< drawing::XDrawPage>& xDrawPage ) +uno::Reference< drawing::XShapes > DrawModelWrapper::getChartRootShape( const rtl::Reference<SvxDrawPage>& xDrawPage ) { return ShapeFactory::getChartRootShape( xDrawPage ); } diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx index eeb2f28611f8..28775a7ae880 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -84,7 +84,7 @@ void lcl_addProperty(uno::Sequence<OUString> & rPropertyNames, uno::Sequence<uno } // end anonymous namespace uno::Reference< drawing::XShapes > ShapeFactory::getOrCreateChartRootShape( - const uno::Reference< drawing::XDrawPage>& xDrawPage ) + const rtl::Reference<SvxDrawPage>& xDrawPage ) { uno::Reference<drawing::XShapes> xRet = ShapeFactory::getChartRootShape(xDrawPage); if (xRet.is()) @@ -95,8 +95,7 @@ uno::Reference< drawing::XShapes > ShapeFactory::getOrCreateChartRootShape( rtl::Reference<SvxShapeGroup> xShapeGroup = new SvxShapeGroup(nullptr, nullptr); xShapeGroup->setShapeKind(OBJ_GRUP); uno::Reference<drawing::XShape> xShape(static_cast<cppu::OWeakObject*>(xShapeGroup.get()), uno::UNO_QUERY); - uno::Reference<drawing::XShapes2> xShapes2(xDrawPage, uno::UNO_QUERY_THROW); - xShapes2->addBottom(xShape); + xDrawPage->addBottom(xShape); setShapeName(xShape, "com.sun.star.chart2.shapes"); xShape->setSize(awt::Size(0,0)); @@ -2313,7 +2312,7 @@ ShapeFactory* ShapeFactory::getOrCreateShapeFactory(const uno::Reference< lang:: } uno::Reference< drawing::XShapes > ShapeFactory::getChartRootShape( - const uno::Reference< drawing::XDrawPage>& xDrawPage ) + const rtl::Reference<SvxDrawPage>& xDrawPage ) { uno::Reference< drawing::XShapes > xRet; const uno::Reference< drawing::XShapes > xShapes = xDrawPage;