From e3bd776e020723ad8caf0a02d8db0d19e0f0e650 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 7 Dec 2021 18:53:11 +0200 Subject: [PATCH] Split BasePrimitive2D UNO interface into separate object Rather than make all the BasePrimitive2D classes bear the cost of being an UNO object, we just wrap the top level BasePrimitive2D in this class when we need to pass them over UNO. This reduces the locking overhead when doing normal drawinglayer operations, and reduces the size of drawinglayer objects and the cost of initialising them, which shaves 5% off the load/display time of a large barchart. Add new drawinglayer::convertPrimitive2DContainerToBitmapEx utility method to avoid needing to convert to Sequence Change-Id: I553eaa4c16ba016b098cb21f6c55f5008f0d9b53 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126487 Tested-by: Noel Grandin Reviewed-by: Noel Grandin --- .../drawinglayeruno/xprimitive2drenderer.cxx | 2 +- .../BufferedDecompositionPrimitive2D.cxx | 2 - .../primitive2d/Primitive2DContainer.cxx | 69 ++++++++++++- drawinglayer/source/primitive2d/Tools.cxx | 28 ++++-- .../backgroundcolorprimitive2d.cxx | 3 - .../source/primitive2d/baseprimitive2d.cxx | 9 +- .../source/primitive2d/bitmapprimitive2d.cxx | 2 +- .../source/primitive2d/controlprimitive2d.cxx | 2 - .../primitive2d/embedded3dprimitive2d.cxx | 2 - .../primitive2d/fillhatchprimitive2d.cxx | 2 - .../primitive2d/graphicprimitivehelper2d.cxx | 2 +- .../source/primitive2d/gridprimitive2d.cxx | 3 - .../source/primitive2d/groupprimitive2d.cxx | 9 +- .../primitive2d/helplineprimitive2d.cxx | 3 - .../primitive2d/patternfillprimitive2d.cxx | 11 +-- .../source/primitive2d/polygonprimitive2d.cxx | 2 - .../source/primitive2d/primitivetools2d.cxx | 12 --- .../source/primitive2d/sceneprimitive2d.cxx | 5 - .../primitive2d/texteffectprimitive2d.cxx | 3 - .../source/processor2d/baseprocessor2d.cxx | 9 +- .../processor2d/vclpixelprocessor2d.cxx | 4 +- .../source/processor3d/defaultprocessor3d.cxx | 1 + drawinglayer/source/tools/converters.cxx | 97 +++++++++++++++++++ .../source/tools/primitive2dxmldump.cxx | 5 +- drawinglayer/source/tools/wmfemfhelper.cxx | 2 +- emfio/CppunitTest_emfio_wmf.mk | 9 +- emfio/qa/cppunit/emf/EmfImportTest.cxx | 91 ++++++----------- emfio/source/emfuno/xemfparser.cxx | 4 +- filter/Library_pdffilter.mk | 1 + filter/source/pdf/pdfdecomposer.cxx | 8 +- filter/source/svg/svgfilter.cxx | 12 +-- include/drawinglayer/converters.hxx | 8 ++ .../BufferedDecompositionPrimitive2D.hxx | 2 +- .../drawinglayer/primitive2d/CommonTypes.hxx | 6 +- .../primitive2d/Primitive2DContainer.hxx | 6 ++ include/drawinglayer/primitive2d/Tools.hxx | 13 ++- .../primitive2d/baseprimitive2d.hxx | 58 ++++++++++- .../primitive2d/bitmapprimitive2d.hxx | 2 +- .../primitive2d/groupprimitive2d.hxx | 2 +- .../primitive2d/patternfillprimitive2d.hxx | 2 +- .../primitive2d/textbreakuphelper.hxx | 4 +- .../processor2d/hittestprocessor2d.hxx | 2 +- sfx2/source/appl/appmisc.cxx | 4 +- sfx2/source/control/thumbnailview.cxx | 1 + sfx2/source/view/viewfrm.cxx | 1 + svgio/CppunitTest_svgio.mk | 1 + svgio/CppunitTest_svgio_tools.mk | 1 + svgio/Library_svgio.mk | 1 + svgio/qa/cppunit/SvgImportTest.cxx | 70 ++++++------- svgio/source/svguno/xsvgparser.cxx | 2 +- svx/source/dialog/frmsel.cxx | 1 + .../sdr/primitive2d/primitivefactory2d.cxx | 4 +- .../sdr/primitive2d/sdrdecompositiontools.cxx | 4 +- svx/source/svdraw/svdograf.cxx | 6 +- svx/source/svdraw/svdpntv.cxx | 3 +- svx/source/svdraw/svdview.cxx | 11 +-- svx/source/svdraw/svdxcgv.cxx | 5 +- svx/source/unodraw/unoshape.cxx | 5 +- vcl/Library_vcl.mk | 1 + vcl/source/bitmap/BitmapTools.cxx | 2 +- vcl/source/gdi/impgraph.cxx | 15 ++- 61 files changed, 421 insertions(+), 236 deletions(-) diff --git a/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx b/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx index abca8a310925..4c236606711e 100644 --- a/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx +++ b/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx @@ -133,7 +133,7 @@ namespace drawinglayer::unorenderer const primitive2d::Primitive2DReference xEmbedRef( new primitive2d::TransformPrimitive2D( aEmbedding, - comphelper::sequenceToContainer(aPrimitive2DSequence))); + aPrimitive2DSequence)); primitive2d::Primitive2DContainer xEmbedSeq { xEmbedRef }; BitmapEx aBitmapEx( diff --git a/drawinglayer/source/primitive2d/BufferedDecompositionPrimitive2D.cxx b/drawinglayer/source/primitive2d/BufferedDecompositionPrimitive2D.cxx index 769b23fb5b80..68ccc714c688 100644 --- a/drawinglayer/source/primitive2d/BufferedDecompositionPrimitive2D.cxx +++ b/drawinglayer/source/primitive2d/BufferedDecompositionPrimitive2D.cxx @@ -33,8 +33,6 @@ void BufferedDecompositionPrimitive2D::get2DDecomposition( Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const { - std::unique_lock aGuard(m_aMutex); - if (getBuffered2DDecomposition().empty()) { Primitive2DContainer aNewSequence; diff --git a/drawinglayer/source/primitive2d/Primitive2DContainer.cxx b/drawinglayer/source/primitive2d/Primitive2DContainer.cxx index 3ae4a9b3e3c4..b6c30a1c43bf 100644 --- a/drawinglayer/source/primitive2d/Primitive2DContainer.cxx +++ b/drawinglayer/source/primitive2d/Primitive2DContainer.cxx @@ -21,12 +21,39 @@ #include #include +#include #include using namespace css; namespace drawinglayer::primitive2d { +Primitive2DContainer::Primitive2DContainer( + const css::uno::Sequence>& rSource) +{ + for (const auto& rPrimitive : rSource) + append(static_cast(rPrimitive.get())->getBasePrimitive2D()); +} +Primitive2DContainer::Primitive2DContainer( + const std::deque>& rSource) +{ + for (const auto& rPrimitive : rSource) + append(static_cast(rPrimitive.get())->getBasePrimitive2D()); +} + +css::uno::Sequence> +Primitive2DContainer::toSequence() const +{ + css::uno::Sequence> aVal(size()); + auto p = aVal.getArray(); + for (const auto& rPrimitive : *this) + { + *p = new UnoPrimitive2D(rPrimitive); + ++p; + } + return aVal; +} + Primitive2DContainer Primitive2DContainer::maybeInvert(bool bInvert) const { const sal_uInt32 nSize(size()); @@ -115,7 +142,47 @@ void Primitive2DContainer::append(Primitive2DContainer&& rSource) void Primitive2DContainer::append(const Primitive2DSequence& rSource) { - this->insert(this->end(), rSource.begin(), rSource.end()); + for (const auto& rPrimitive : rSource) + append(static_cast(rPrimitive.get())->getBasePrimitive2D()); +} + +UnoPrimitive2D::~UnoPrimitive2D() {} + +basegfx::B2DRange +UnoPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const +{ + std::unique_lock aGuard(m_aMutex); + return mxPrimitive->getB2DRange(rViewInformation); +} + +sal_uInt32 UnoPrimitive2D::getPrimitive2DID() const { return mxPrimitive->getPrimitive2DID(); } + +void UnoPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, + const geometry::ViewInformation2D& rViewInformation) const +{ + std::unique_lock aGuard(m_aMutex); + mxPrimitive->get2DDecomposition(rVisitor, rViewInformation); +} + +css::uno::Sequence<::css::uno::Reference<::css::graphic::XPrimitive2D>> + SAL_CALL UnoPrimitive2D::getDecomposition( + const css::uno::Sequence& rViewParameters) +{ + std::unique_lock aGuard(m_aMutex); + return mxPrimitive->getDecomposition(rViewParameters).toSequence(); +} + +css::geometry::RealRectangle2D SAL_CALL +UnoPrimitive2D::getRange(const css::uno::Sequence& rViewParameters) +{ + std::unique_lock aGuard(m_aMutex); + return mxPrimitive->getRange(rViewParameters); +} + +sal_Int64 SAL_CALL UnoPrimitive2D::estimateUsage() +{ + std::unique_lock aGuard(m_aMutex); + return mxPrimitive->estimateUsage(); } } // end of namespace drawinglayer::primitive2d diff --git a/drawinglayer/source/primitive2d/Tools.cxx b/drawinglayer/source/primitive2d/Tools.cxx index 7be666a2cbd0..87272d9d1f9d 100644 --- a/drawinglayer/source/primitive2d/Tools.cxx +++ b/drawinglayer/source/primitive2d/Tools.cxx @@ -35,9 +35,7 @@ getB2DRangeFromPrimitive2DReference(const Primitive2DReference& rCandidate, if (!rCandidate) return basegfx::B2DRange(); - // get C++ implementation base - const BasePrimitive2D* pCandidate(static_cast(rCandidate.get())); - return pCandidate->getB2DRange(aViewInformation); + return rCandidate->getB2DRange(aViewInformation); } bool arePrimitive2DReferencesEqual(const Primitive2DReference& rxA, const Primitive2DReference& rxB) @@ -54,10 +52,28 @@ bool arePrimitive2DReferencesEqual(const Primitive2DReference& rxA, const Primit return true; } - const BasePrimitive2D* pA(static_cast(rxA.get())); - const BasePrimitive2D* pB(static_cast(rxB.get())); + return rxA->operator==(*rxB); +} - return pA->operator==(*pB); +bool arePrimitive2DReferencesEqual(const css::uno::Reference& rxA, + const css::uno::Reference& rxB) +{ + const bool bAIs(rxA.is()); + + if (bAIs != rxB.is()) + { + return false; + } + + if (!bAIs) + { + return true; + } + + auto pA = static_cast(rxA.get()); + auto pB = static_cast(rxB.get()); + + return (*pA->getBasePrimitive2D()) == (*pB->getBasePrimitive2D()); } OUString idToString(sal_uInt32 nId) diff --git a/drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx b/drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx index 68f31cb4c67a..8f68d9e73ba3 100644 --- a/drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx @@ -67,8 +67,6 @@ namespace drawinglayer::primitive2d void BackgroundColorPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const { - std::unique_lock aGuard( m_aMutex ); - if(!getBuffered2DDecomposition().empty() && (maLastViewport != rViewInformation.getViewport())) { // conditions of last local decomposition have changed, delete @@ -82,7 +80,6 @@ namespace drawinglayer::primitive2d } // use parent implementation - aGuard.unlock(); BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation); } diff --git a/drawinglayer/source/primitive2d/baseprimitive2d.cxx b/drawinglayer/source/primitive2d/baseprimitive2d.cxx index 86eaa37eb976..b5590bce082c 100644 --- a/drawinglayer/source/primitive2d/baseprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/baseprimitive2d.cxx @@ -19,6 +19,7 @@ #include +#include #include #include #include @@ -141,23 +142,23 @@ void BasePrimitive2D::get2DDecomposition( { } -css::uno::Sequence<::css::uno::Reference<::css::graphic::XPrimitive2D>> SAL_CALL +Primitive2DContainer BasePrimitive2D::getDecomposition(const uno::Sequence& rViewParameters) { const auto aViewInformation = geometry::createViewInformation2D(rViewParameters); Primitive2DContainer aContainer; get2DDecomposition(aContainer, aViewInformation); - return comphelper::containerToSequence(aContainer); + return aContainer; } -css::geometry::RealRectangle2D SAL_CALL +css::geometry::RealRectangle2D BasePrimitive2D::getRange(const uno::Sequence& rViewParameters) { const auto aViewInformation = geometry::createViewInformation2D(rViewParameters); return basegfx::unotools::rectangle2DFromB2DRectangle(getB2DRange(aViewInformation)); } -sal_Int64 SAL_CALL BasePrimitive2D::estimateUsage() +sal_Int64 BasePrimitive2D::estimateUsage() { return 0; // for now ignore the objects themselves } diff --git a/drawinglayer/source/primitive2d/bitmapprimitive2d.cxx b/drawinglayer/source/primitive2d/bitmapprimitive2d.cxx index 0a06010d31e2..6f256b6e1850 100644 --- a/drawinglayer/source/primitive2d/bitmapprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/bitmapprimitive2d.cxx @@ -52,7 +52,7 @@ BitmapPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInforma return aRetval; } -sal_Int64 SAL_CALL BitmapPrimitive2D::estimateUsage() +sal_Int64 BitmapPrimitive2D::estimateUsage() { if (!getXBitmap().is()) { diff --git a/drawinglayer/source/primitive2d/controlprimitive2d.cxx b/drawinglayer/source/primitive2d/controlprimitive2d.cxx index db27950df5d5..461400dafb84 100644 --- a/drawinglayer/source/primitive2d/controlprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/controlprimitive2d.cxx @@ -316,7 +316,6 @@ namespace drawinglayer::primitive2d { // this primitive is view-dependent related to the scaling. If scaling has changed, // destroy existing decomposition. To detect change, use size of unit size in view coordinates - std::unique_lock aGuard( m_aMutex ); const basegfx::B2DVector aNewScaling(rViewInformation.getObjectToViewTransformation() * basegfx::B2DVector(1.0, 1.0)); if(!getBuffered2DDecomposition().empty()) @@ -335,7 +334,6 @@ namespace drawinglayer::primitive2d } // use parent implementation - aGuard.unlock(); BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation); } diff --git a/drawinglayer/source/primitive2d/embedded3dprimitive2d.cxx b/drawinglayer/source/primitive2d/embedded3dprimitive2d.cxx index fe83b3850d8f..f072df0c33a7 100644 --- a/drawinglayer/source/primitive2d/embedded3dprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/embedded3dprimitive2d.cxx @@ -35,8 +35,6 @@ namespace drawinglayer::primitive2d { bool Embedded3DPrimitive2D::impGetShadow3D() const { - std::unique_lock aGuard( m_aMutex ); - // create on demand if(!mbShadow3DChecked && !getChildren3D().empty()) { diff --git a/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx b/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx index 07c48612d21d..09a82bdd89ca 100644 --- a/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx @@ -173,10 +173,8 @@ namespace drawinglayer::primitive2d void FillHatchPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const { - std::unique_lock aGuard( m_aMutex ); bool bAdaptDistance(0 != getFillHatch().getMinimalDiscreteDistance()); - aGuard.unlock(); if(bAdaptDistance) { // behave view-dependent diff --git a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx index c8a4da035455..9974117b5ae0 100644 --- a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx +++ b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx @@ -518,7 +518,7 @@ namespace drawinglayer::primitive2d aRetval.resize(1); aRetval[0] = new TransformPrimitive2D( aEmbedVectorGraphic, - rGraphic.getVectorGraphicData()->getPrimitive2DSequence()); + Primitive2DContainer(rGraphic.getVectorGraphicData()->getPrimitive2DSequence())); } } else diff --git a/drawinglayer/source/primitive2d/gridprimitive2d.cxx b/drawinglayer/source/primitive2d/gridprimitive2d.cxx index 515263e0d475..ddb468e9ad39 100644 --- a/drawinglayer/source/primitive2d/gridprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/gridprimitive2d.cxx @@ -305,8 +305,6 @@ namespace drawinglayer::primitive2d void GridPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const { - std::unique_lock aGuard( m_aMutex ); - if(!getBuffered2DDecomposition().empty()) { if(maLastViewport != rViewInformation.getViewport() || maLastObjectToViewTransformation != rViewInformation.getObjectToViewTransformation()) @@ -324,7 +322,6 @@ namespace drawinglayer::primitive2d } // use parent implementation - aGuard.unlock(); BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation); } diff --git a/drawinglayer/source/primitive2d/groupprimitive2d.cxx b/drawinglayer/source/primitive2d/groupprimitive2d.cxx index 8c16d848fdff..7a39bde2ccf4 100644 --- a/drawinglayer/source/primitive2d/groupprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/groupprimitive2d.cxx @@ -53,16 +53,13 @@ namespace drawinglayer::primitive2d getChildren(rVisitor); } - sal_Int64 SAL_CALL GroupPrimitive2D::estimateUsage() + sal_Int64 GroupPrimitive2D::estimateUsage() { size_t nRet(0); for (auto& it : getChildren()) { - uno::Reference const xAcc(it, uno::UNO_QUERY); - if (xAcc.is()) - { - nRet += xAcc->estimateUsage(); - } + if (it) + nRet += it->estimateUsage(); } return nRet; } diff --git a/drawinglayer/source/primitive2d/helplineprimitive2d.cxx b/drawinglayer/source/primitive2d/helplineprimitive2d.cxx index 612181bb7854..07d6a7f2236f 100644 --- a/drawinglayer/source/primitive2d/helplineprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/helplineprimitive2d.cxx @@ -155,8 +155,6 @@ namespace drawinglayer::primitive2d void HelplinePrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const { - std::unique_lock aGuard( m_aMutex ); - if(!getBuffered2DDecomposition().empty()) { if(maLastViewport != rViewInformation.getViewport() || maLastObjectToViewTransformation != rViewInformation.getObjectToViewTransformation()) @@ -174,7 +172,6 @@ namespace drawinglayer::primitive2d } // use parent implementation - aGuard.unlock(); BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation); } diff --git a/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx b/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx index cd4c58d11127..b667545b5347 100644 --- a/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx @@ -350,17 +350,12 @@ namespace drawinglayer::primitive2d BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation); } - sal_Int64 SAL_CALL PatternFillPrimitive2D::estimateUsage() + sal_Int64 PatternFillPrimitive2D::estimateUsage() { size_t nRet(0); for (auto& it : getChildren()) - { - uno::Reference const xAcc(it, uno::UNO_QUERY); - if (xAcc.is()) - { - nRet += xAcc->estimateUsage(); - } - } + if (it) + nRet += it->estimateUsage(); return nRet; } diff --git a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx index 0ed46fa68c81..1cbde11ae96b 100644 --- a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx @@ -167,7 +167,6 @@ void PolygonMarkerPrimitive2D::get2DDecomposition( Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const { - std::unique_lock aGuard(m_aMutex); bool bNeedNewDecomposition(false); if (!getBuffered2DDecomposition().empty()) @@ -195,7 +194,6 @@ void PolygonMarkerPrimitive2D::get2DDecomposition( } // use parent implementation - aGuard.unlock(); BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation); } diff --git a/drawinglayer/source/primitive2d/primitivetools2d.cxx b/drawinglayer/source/primitive2d/primitivetools2d.cxx index c4ab4f5c800b..7c6d426e95a2 100644 --- a/drawinglayer/source/primitive2d/primitivetools2d.cxx +++ b/drawinglayer/source/primitive2d/primitivetools2d.cxx @@ -26,8 +26,6 @@ namespace drawinglayer::primitive2d { void DiscreteMetricDependentPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const { - std::unique_lock aGuard( m_aMutex ); - // get the current DiscreteUnit, look at X and Y and use the maximum const basegfx::B2DVector aDiscreteVector(rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 1.0)); const double fDiscreteUnit(std::min(fabs(aDiscreteVector.getX()), fabs(aDiscreteVector.getY()))); @@ -45,7 +43,6 @@ namespace drawinglayer::primitive2d } // call base implementation - aGuard.unlock(); BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation); } @@ -54,8 +51,6 @@ namespace drawinglayer::primitive2d void ViewportDependentPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const { - std::unique_lock aGuard( m_aMutex ); - // get the current Viewport const basegfx::B2DRange& rViewport = rViewInformation.getViewport(); @@ -72,14 +67,11 @@ namespace drawinglayer::primitive2d } // call base implementation - aGuard.unlock(); BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation); } void ViewTransformationDependentPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const { - std::unique_lock aGuard( m_aMutex ); - // get the current ViewTransformation const basegfx::B2DHomMatrix& rViewTransformation = rViewInformation.getViewTransformation(); @@ -96,14 +88,11 @@ namespace drawinglayer::primitive2d } // call base implementation - aGuard.unlock(); BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation); } void ObjectAndViewTransformationDependentPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const { - std::unique_lock aGuard( m_aMutex ); - // get the current ViewTransformation const basegfx::B2DHomMatrix& rViewTransformation = rViewInformation.getViewTransformation(); @@ -130,7 +119,6 @@ namespace drawinglayer::primitive2d } // call base implementation - aGuard.unlock(); BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation); } diff --git a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx index 4f238cef4792..d371cdedcd5c 100644 --- a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx @@ -509,8 +509,6 @@ namespace drawinglayer::primitive2d Primitive2DContainer ScenePrimitive2D::getShadow2D() const { - std::unique_lock aGuard( m_aMutex ); - Primitive2DContainer aRetval; // create 2D shadows from contained 3D primitives @@ -624,8 +622,6 @@ namespace drawinglayer::primitive2d void ScenePrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const { - std::unique_lock aGuard( m_aMutex ); - // get the involved ranges (see helper method calculateDiscreteSizes for details) basegfx::B2DRange aDiscreteRange; basegfx::B2DRange aUnitVisibleRange; @@ -679,7 +675,6 @@ namespace drawinglayer::primitive2d } // use parent implementation - aGuard.unlock(); BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation); } diff --git a/drawinglayer/source/primitive2d/texteffectprimitive2d.cxx b/drawinglayer/source/primitive2d/texteffectprimitive2d.cxx index d05e727ce50c..dae397e1abd8 100644 --- a/drawinglayer/source/primitive2d/texteffectprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/texteffectprimitive2d.cxx @@ -213,8 +213,6 @@ void TextEffectPrimitive2D::get2DDecomposition( Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const { - std::unique_lock aGuard(m_aMutex); - if (!getBuffered2DDecomposition().empty()) { if (maLastObjectToViewTransformation != rViewInformation.getObjectToViewTransformation()) @@ -233,7 +231,6 @@ void TextEffectPrimitive2D::get2DDecomposition( } // use parent implementation - aGuard.unlock(); BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation); } diff --git a/drawinglayer/source/processor2d/baseprocessor2d.cxx b/drawinglayer/source/processor2d/baseprocessor2d.cxx index b4291dd4431c..e7a6a44932f7 100644 --- a/drawinglayer/source/processor2d/baseprocessor2d.cxx +++ b/drawinglayer/source/processor2d/baseprocessor2d.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include #include #include @@ -48,8 +49,7 @@ namespace drawinglayer::processor2d // Primitive2DDecompositionVisitor void BaseProcessor2D::visit(const primitive2d::Primitive2DReference& rCandidate) { - const primitive2d::BasePrimitive2D* pBasePrimitive = static_cast< const primitive2d::BasePrimitive2D* >(rCandidate.get()); - processBasePrimitive2D(*pBasePrimitive); + processBasePrimitive2D(*rCandidate); } void BaseProcessor2D::visit(const primitive2d::Primitive2DContainer& rContainer) { @@ -64,9 +64,8 @@ namespace drawinglayer::processor2d { for (const primitive2d::Primitive2DReference& rCandidate : rSource) { - const primitive2d::BasePrimitive2D* pBasePrimitive = static_cast< const primitive2d::BasePrimitive2D* >(rCandidate.get()); - if (pBasePrimitive) - processBasePrimitive2D(*pBasePrimitive); + if (rCandidate) + processBasePrimitive2D(*rCandidate); } } diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index c4ca011d30d1..73a3332af221 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -620,9 +620,7 @@ void VclPixelProcessor2D::processUnifiedTransparencePrimitive2D( if (1 == rContent.size()) { - const primitive2d::Primitive2DReference xReference(rContent[0]); - const primitive2d::BasePrimitive2D* pBasePrimitive - = static_cast(xReference.get()); + const primitive2d::BasePrimitive2D* pBasePrimitive = rContent[0].get(); switch (pBasePrimitive->getPrimitive2DID()) { diff --git a/drawinglayer/source/processor3d/defaultprocessor3d.cxx b/drawinglayer/source/processor3d/defaultprocessor3d.cxx index b9159c46c73f..2b61acd19762 100644 --- a/drawinglayer/source/processor3d/defaultprocessor3d.cxx +++ b/drawinglayer/source/processor3d/defaultprocessor3d.cxx @@ -34,6 +34,7 @@ #include #include #include +#include #include #include diff --git a/drawinglayer/source/tools/converters.cxx b/drawinglayer/source/tools/converters.cxx index 382b81197526..c0a92a8f479f 100644 --- a/drawinglayer/source/tools/converters.cxx +++ b/drawinglayer/source/tools/converters.cxx @@ -23,7 +23,10 @@ #include #include #include +#include #include +#include +#include #include @@ -170,6 +173,100 @@ namespace drawinglayer return aRetval; } + BitmapEx convertPrimitive2DContainerToBitmapEx( + primitive2d::Primitive2DContainer&& rSequence, + const basegfx::B2DRange& rTargetRange, + sal_uInt32 nMaximumQuadraticPixels, + const o3tl::Length eTargetUnit, + const std::optional& rTargetDPI) + { + if(rSequence.empty()) + return BitmapEx(); + + try + { + css::geometry::RealRectangle2D aRealRect; + aRealRect.X1 = rTargetRange.getMinX(); + aRealRect.Y1 = rTargetRange.getMinY(); + aRealRect.X2 = rTargetRange.getMaxX(); + aRealRect.Y2 = rTargetRange.getMaxY(); + + // get system DPI + Size aDPI(Application::GetDefaultDevice()->LogicToPixel(Size(1, 1), MapMode(MapUnit::MapInch))); + if (rTargetDPI.has_value()) + { + aDPI = *rTargetDPI; + } + + ::sal_uInt32 DPI_X = aDPI.getWidth(); + ::sal_uInt32 DPI_Y = aDPI.getHeight(); + const basegfx::B2DRange aRange(aRealRect.X1, aRealRect.Y1, aRealRect.X2, aRealRect.Y2); + const double fWidth(aRange.getWidth()); + const double fHeight(aRange.getHeight()); + + if(!(basegfx::fTools::more(fWidth, 0.0) && basegfx::fTools::more(fHeight, 0.0))) + return BitmapEx(); + + if(0 == DPI_X) + { + DPI_X = 75; + } + + if(0 == DPI_Y) + { + DPI_Y = 75; + } + + if(0 == nMaximumQuadraticPixels) + { + nMaximumQuadraticPixels = 500000; + } + + const auto aViewInformation2D = geometry::createViewInformation2D({}); + const sal_uInt32 nDiscreteWidth(basegfx::fround(o3tl::convert(fWidth, eTargetUnit, o3tl::Length::in) * DPI_X)); + const sal_uInt32 nDiscreteHeight(basegfx::fround(o3tl::convert(fHeight, eTargetUnit, o3tl::Length::in) * DPI_Y)); + + basegfx::B2DHomMatrix aEmbedding( + basegfx::utils::createTranslateB2DHomMatrix( + -aRange.getMinX(), + -aRange.getMinY())); + + aEmbedding.scale( + nDiscreteWidth / fWidth, + nDiscreteHeight / fHeight); + + const primitive2d::Primitive2DReference xEmbedRef( + new primitive2d::TransformPrimitive2D( + aEmbedding, + std::move(rSequence))); + primitive2d::Primitive2DContainer xEmbedSeq { xEmbedRef }; + + BitmapEx aBitmapEx( + convertToBitmapEx( + std::move(xEmbedSeq), + aViewInformation2D, + nDiscreteWidth, + nDiscreteHeight, + nMaximumQuadraticPixels)); + + if(aBitmapEx.IsEmpty()) + return BitmapEx(); + aBitmapEx.SetPrefMapMode(MapMode(MapUnit::Map100thMM)); + aBitmapEx.SetPrefSize(Size(basegfx::fround(fWidth), basegfx::fround(fHeight))); + + return aBitmapEx; + } + catch (const css::uno::Exception&) + { + TOOLS_WARN_EXCEPTION("vcl", "Got no graphic::XPrimitive2DRenderer!"); + } + catch (const std::exception& e) + { + SAL_WARN("vcl", "Got no graphic::XPrimitive2DRenderer! : " << e.what()); + } + + return BitmapEx(); + } } // end of namespace drawinglayer /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx b/drawinglayer/source/tools/primitive2dxmldump.cxx index 5f753039183c..5f303a627e0f 100644 --- a/drawinglayer/source/tools/primitive2dxmldump.cxx +++ b/drawinglayer/source/tools/primitive2dxmldump.cxx @@ -605,10 +605,7 @@ void Primitive2dXmlDump::decomposeAndWrite( { for (size_t i = 0; i < rPrimitive2DSequence.size(); i++) { - drawinglayer::primitive2d::Primitive2DReference xPrimitive2DReference - = rPrimitive2DSequence[i]; - const BasePrimitive2D* pBasePrimitive - = static_cast(xPrimitive2DReference.get()); + const BasePrimitive2D* pBasePrimitive = rPrimitive2DSequence[i].get(); sal_uInt32 nId = pBasePrimitive->getPrimitive2DID(); if (nId < maFilter.size() && maFilter[nId]) continue; diff --git a/drawinglayer/source/tools/wmfemfhelper.cxx b/drawinglayer/source/tools/wmfemfhelper.cxx index f8c562ce1a7a..307da099a774 100644 --- a/drawinglayer/source/tools/wmfemfhelper.cxx +++ b/drawinglayer/source/tools/wmfemfhelper.cxx @@ -1257,7 +1257,7 @@ namespace wmfemfhelper // prepare Primitive2DSequence, put text in foreground drawinglayer::primitive2d::Primitive2DContainer aSequence(2); - aSequence[1] = drawinglayer::primitive2d::Primitive2DReference(pResult); + aSequence[1] = pResult; // prepare filled polygon basegfx::B2DPolygon aOutline(basegfx::utils::createPolygonFromRect(aTextRange)); diff --git a/emfio/CppunitTest_emfio_wmf.mk b/emfio/CppunitTest_emfio_wmf.mk index ec67bff3a9b4..a127bdb0af1f 100644 --- a/emfio/CppunitTest_emfio_wmf.mk +++ b/emfio/CppunitTest_emfio_wmf.mk @@ -32,17 +32,10 @@ $(eval $(call gb_CppunitTest_use_libraries,emfio_wmf,\ vcl \ )) -$(eval $(call gb_CppunitTest_use_components,emfio_wmf,\ - configmgr/source/configmgr \ - emfio/emfio \ - i18npool/util/i18npool \ - ucb/source/core/ucb1 \ - unotools/util/utl \ -)) - $(eval $(call gb_CppunitTest_use_configuration,emfio_wmf)) $(eval $(call gb_CppunitTest_use_sdk_api,emfio_wmf)) $(eval $(call gb_CppunitTest_use_ure,emfio_wmf)) $(eval $(call gb_CppunitTest_use_vcl,emfio_wmf)) +$(eval $(call gb_CppunitTest_use_rdb,emfio_wmf,services)) # vim: set noet sw=4 ts=4: diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 6b16770d8d71..c9d5d17179ef 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -162,8 +163,7 @@ void Test::testPolyPolygon() Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/fdo79679-2.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); @@ -205,8 +205,7 @@ void Test::TestDrawImagePointsTypeBitmap() = parseEmf(u"/emfio/qa/cppunit/emf/data/TestDrawImagePointsTypeBitmap.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "polypolygoncolor", "color", "#0080ff"); @@ -237,8 +236,7 @@ void Test::TestDrawString() Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestDrawString.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); // check correct import of the DrawString: height, position, text, color and font @@ -259,8 +257,7 @@ void Test::TestDrawStringAlign() Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestDrawStringAlign.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "mask/transform", 9); @@ -330,8 +327,7 @@ void Test::TestDrawStringTransparent() = parseEmf(u"/emfio/qa/cppunit/emf/data/TestDrawStringTransparent.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "mask/transform/unifiedtransparence", "transparence", @@ -358,8 +354,7 @@ void Test::TestDrawStringWithBrush() = parseEmf(u"/emfio/qa/cppunit/emf/data/TestDrawStringWithBrush.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "transform/textdecoratedportion", "xy11", "20"); assertXPath(pDocument, aXPathPrefix + "transform/textdecoratedportion", "xy13", "16"); @@ -379,8 +374,7 @@ void Test::TestDrawLine() Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestDrawLine.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); // check correct import of the DrawLine: color and width of the line @@ -394,8 +388,7 @@ void Test::TestLinearGradient() Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestLinearGradient.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, "/primitive2D/metafile/transform", "xy11", "1"); @@ -433,8 +426,7 @@ void Test::TestTextMapMode() Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TextMapMode.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "polypolygoncolor", 2); @@ -471,8 +463,7 @@ void Test::TestEnglishMapMode() = parseEmf(u"/emfio/qa/cppunit/emf/data/test_mm_hienglish_ref.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "mask/polypolygon", 1); @@ -514,8 +505,7 @@ void Test::TestRectangleWithModifyWorldTransform() = parseEmf(u"/emfio/qa/cppunit/emf/data/TestRectangleWithModifyWorldTransform.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "polypolygoncolor", 1); @@ -535,8 +525,7 @@ void Test::TestChordWithModifyWorldTransform() = parseEmf(u"/emfio/qa/cppunit/emf/data/TestChordWithModifyWorldTransform.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "polypolygoncolor", "color", "#ffffff"); @@ -557,8 +546,7 @@ void Test::TestArcStartPointEqualEndPoint() = parseEmf(u"/emfio/qa/cppunit/emf/data/TestArcStartPointEqualEndPoint.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "mask/group/mask/polygonhairline", "color", "#000000"); @@ -607,8 +595,7 @@ void Test::TestArcInsideWronglyDefinedRectangle() = parseEmf(u"/emfio/qa/cppunit/emf/data/TestArcInsideWronglyDefinedRectangle.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "polygonhairline", "color", "#000000"); @@ -634,8 +621,7 @@ void Test::TestEllipseWithSelectClipPath() = parseEmf(u"/emfio/qa/cppunit/emf/data/TestEllipseWithSelectClipPath.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "group/mask/polypolygon", 1); @@ -666,8 +652,7 @@ void Test::TestEllipseXformIntersectClipRect() = parseEmf(u"/emfio/qa/cppunit/emf/data/TestEllipseXformIntersectClipRect.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "mask/polypolygon", "path", "m0 0h3000v2000h-3000z"); @@ -725,8 +710,7 @@ void Test::TestDrawPolyLine16WithClip() = parseEmf(u"/emfio/qa/cppunit/emf/data/TestDrawPolyLine16WithClip.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "mask/polypolygon", "path", "m0 0h3943v3939h-3943z"); @@ -754,8 +738,7 @@ void Test::TestFillRegion() Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestFillRegion.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "mask/polypolygon", "path", "m0 0h3943v3939h-3943z"); @@ -779,8 +762,7 @@ void Test::TestPolylinetoCloseStroke() = parseEmf(u"/emfio/qa/cppunit/emf/data/TestPolylinetoCloseStroke.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "polygonhairline", 2); @@ -807,8 +789,7 @@ void Test::TestExtTextOutOpaqueAndClipTransform() = parseEmf(u"/emfio/qa/cppunit/emf/data/TestExtTextOutOpaqueAndClipTransform.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "textsimpleportion", 2); @@ -862,8 +843,7 @@ void Test::TestBitBltStretchBltWMF() = parseEmf(u"/emfio/qa/cppunit/wmf/data/TestBitBltStretchBlt.wmf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "mask/bitmap", 2); @@ -913,8 +893,7 @@ void Test::TestExtTextOutOpaqueAndClipWMF() = parseEmf(u"/emfio/qa/cppunit/wmf/data/TestExtTextOutOpaqueAndClip.wmf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); #ifdef MACOSX @@ -964,8 +943,7 @@ void Test::TestPaletteWMF() Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/wmf/data/TestPalette.wmf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "mask/polypolygoncolor", 2); @@ -995,8 +973,7 @@ void Test::TestRestoreDCWMF() Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/wmf/data/TestRestoreDC.wmf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "polypolygoncolor", 3); @@ -1024,8 +1001,7 @@ void Test::TestRoundrectWMF() Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/wmf/data/TestRoundRect.wmf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "polypolygoncolor", "color", "#ffffff"); @@ -1066,8 +1042,7 @@ void Test::TestStretchDIBWMF() Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/wmf/data/TestStretchDIB.wmf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "mask/bitmap", "xy11", "12065"); @@ -1095,8 +1070,7 @@ void Test::TestPolyLineWidth() Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestPolyLineWidth.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "polypolygoncolor/polypolygon", "path", @@ -1115,8 +1089,7 @@ void Test::TestRestoreDC() Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestRestoreDC.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "polypolygoncolor", "color", "#ff0000"); @@ -1133,8 +1106,7 @@ void Test::TestRoundRect() Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestRoundRect.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "polypolygoncolor", 2); @@ -1186,8 +1158,7 @@ void Test::TestCreatePen() Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestCreatePen.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument - = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); CPPUNIT_ASSERT(pDocument); assertXPath(pDocument, aXPathPrefix + "mask/polypolygon", "path", "m0 0h31250v18192h-31250z"); diff --git a/emfio/source/emfuno/xemfparser.cxx b/emfio/source/emfuno/xemfparser.cxx index e5d27056332d..bd9ad4ac6eb3 100644 --- a/emfio/source/emfuno/xemfparser.cxx +++ b/emfio/source/emfuno/xemfparser.cxx @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include @@ -202,7 +202,7 @@ namespace emfio::emfreader SAL_WARN("emfio", "Invalid stream (!)"); } - return comphelper::containerToSequence(aRetval); + return aRetval.toSequence(); } void XEmfParser::setSizeHint(const geometry::RealPoint2D& rSize) diff --git a/filter/Library_pdffilter.mk b/filter/Library_pdffilter.mk index 6219c3a306aa..178a479d72ac 100644 --- a/filter/Library_pdffilter.mk +++ b/filter/Library_pdffilter.mk @@ -49,6 +49,7 @@ $(eval $(call gb_Library_use_libraries,pdffilter,\ cppuhelper \ cppu \ sal \ + salhelper \ drawinglayer \ drawinglayercore \ )) diff --git a/filter/source/pdf/pdfdecomposer.cxx b/filter/source/pdf/pdfdecomposer.cxx index 1118021a6377..f861b4eaf86e 100644 --- a/filter/source/pdf/pdfdecomposer.cxx +++ b/filter/source/pdf/pdfdecomposer.cxx @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -89,8 +90,11 @@ XPdfDecomposer::getDecomposition(const uno::Reference #include +#include #include #include "svgfilter.hxx" @@ -258,15 +259,10 @@ bool SVGFilter::filterImpressOrDraw( const Sequence< PropertyValue >& rDescripto for(const auto& rCandidate : aContainer) { - if(rCandidate.is()) + if(rCandidate && PRIMITIVE2D_ID_HIDDENGEOMETRYPRIMITIVE2D != rCandidate->getPrimitive2DID()) { - auto pBasePrimitive = static_cast< const drawinglayer::primitive2d::BasePrimitive2D* >(rCandidate.get()); - - if(PRIMITIVE2D_ID_HIDDENGEOMETRYPRIMITIVE2D != pBasePrimitive->getPrimitive2DID()) - { - bAllAreHiddenGeometry = false; - break; - } + bAllAreHiddenGeometry = false; + break; } } diff --git a/include/drawinglayer/converters.hxx b/include/drawinglayer/converters.hxx index a0b8c4c4be78..1fda7a2f8350 100644 --- a/include/drawinglayer/converters.hxx +++ b/include/drawinglayer/converters.hxx @@ -29,6 +29,14 @@ convertToBitmapEx(drawinglayer::primitive2d::Primitive2DContainer&& rSeq, const geometry::ViewInformation2D& rViewInformation2D, sal_uInt32 nDiscreteWidth, sal_uInt32 nDiscreteHeight, sal_uInt32 nMaxSquarePixels); +// helper to convert any Primitive2DSequence to a good quality BitmapEx, +// using default parameters +BitmapEx DRAWINGLAYER_DLLPUBLIC convertPrimitive2DContainerToBitmapEx( + drawinglayer::primitive2d::Primitive2DContainer&& rSeq, const basegfx::B2DRange& rTargetRange, + const sal_uInt32 nMaximumQuadraticPixels = 500000, + const o3tl::Length eTargetUnit = o3tl::Length::mm100, + const std::optional& rTargetDPI = std::nullopt); + } // end of namespace drawinglayer /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx b/include/drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx index e875709b440e..8087a6544dc0 100644 --- a/include/drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx +++ b/include/drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx @@ -20,7 +20,7 @@ #pragma once #include - +#include #include namespace drawinglayer::geometry diff --git a/include/drawinglayer/primitive2d/CommonTypes.hxx b/include/drawinglayer/primitive2d/CommonTypes.hxx index a7ef629fc98f..3e14b05daa30 100644 --- a/include/drawinglayer/primitive2d/CommonTypes.hxx +++ b/include/drawinglayer/primitive2d/CommonTypes.hxx @@ -20,11 +20,13 @@ #pragma once #include +#include namespace drawinglayer::primitive2d { -typedef css::uno::Reference Primitive2DReference; -typedef css::uno::Sequence Primitive2DSequence; +class BasePrimitive2D; +typedef rtl::Reference Primitive2DReference; +typedef css::uno::Sequence> Primitive2DSequence; } // end of namespace drawinglayer::primitive2d diff --git a/include/drawinglayer/primitive2d/Primitive2DContainer.hxx b/include/drawinglayer/primitive2d/Primitive2DContainer.hxx index 43268d0209dd..45688e504936 100644 --- a/include/drawinglayer/primitive2d/Primitive2DContainer.hxx +++ b/include/drawinglayer/primitive2d/Primitive2DContainer.hxx @@ -21,6 +21,7 @@ #include +#include #include #include @@ -70,6 +71,9 @@ public: : deque(first, last) { } + Primitive2DContainer( + const css::uno::Sequence>&); + Primitive2DContainer(const std::deque>&); virtual void visit(const Primitive2DReference& rSource) override { append(rSource); } virtual void visit(const Primitive2DContainer& rSource) override { append(rSource); } @@ -93,6 +97,8 @@ public: bool operator!=(const Primitive2DContainer& rB) const { return !operator==(rB); } basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& aViewInformation) const; Primitive2DContainer maybeInvert(bool bInvert = false) const; + + css::uno::Sequence> toSequence() const; }; } // end of namespace drawinglayer::primitive2d diff --git a/include/drawinglayer/primitive2d/Tools.hxx b/include/drawinglayer/primitive2d/Tools.hxx index fcb7ff48ce54..3eaa322d9a4f 100644 --- a/include/drawinglayer/primitive2d/Tools.hxx +++ b/include/drawinglayer/primitive2d/Tools.hxx @@ -22,13 +22,9 @@ #include #include #include +#include #include -namespace drawinglayer::geometry -{ -class ViewInformation2D; -} - namespace drawinglayer::primitive2d { /// get B2DRange from a given Primitive2DReference @@ -41,6 +37,13 @@ basegfx::B2DRange DRAWINGLAYERCORE_DLLPUBLIC getB2DRangeFromPrimitive2DReference bool DRAWINGLAYERCORE_DLLPUBLIC arePrimitive2DReferencesEqual(const Primitive2DReference& rA, const Primitive2DReference& rB); +/** compare two Primitive2DReferences for equality, including trying to get implementations (BasePrimitive2D) + and using compare operator + */ +bool DRAWINGLAYERCORE_DLLPUBLIC +arePrimitive2DReferencesEqual(const css::uno::Reference& rA, + const css::uno::Reference& rB); + OUString DRAWINGLAYERCORE_DLLPUBLIC idToString(sal_uInt32 nId); } // end of namespace drawinglayer::primitive2d diff --git a/include/drawinglayer/primitive2d/baseprimitive2d.hxx b/include/drawinglayer/primitive2d/baseprimitive2d.hxx index 444fec94c384..5fbcafc655db 100644 --- a/include/drawinglayer/primitive2d/baseprimitive2d.hxx +++ b/include/drawinglayer/primitive2d/baseprimitive2d.hxx @@ -31,6 +31,9 @@ #include #include #include +#include +#include +#include #include namespace drawinglayer::geometry @@ -147,7 +150,7 @@ namespace drawinglayer::primitive2d for view-independent primitives which are defined by not using ViewInformation2D in their get2DDecomposition/getB2DRange implementations. */ -class DRAWINGLAYERCORE_DLLPUBLIC BasePrimitive2D : public BasePrimitive2DImplBase +class DRAWINGLAYERCORE_DLLPUBLIC BasePrimitive2D : public salhelper::SimpleReferenceObject { BasePrimitive2D(const BasePrimitive2D&) = delete; BasePrimitive2D& operator=(const BasePrimitive2D&) = delete; @@ -180,6 +183,54 @@ public: // Methods from XPrimitive2D + /** The getDecomposition implementation for UNO API will use getDecomposition from this implementation. It + will construct a ViewInformation2D from the ViewParameters for that purpose + */ + virtual Primitive2DContainer + getDecomposition(const css::uno::Sequence& rViewParameters); + + /** The getRange implementation for UNO API will use getRange from this implementation. It + will construct a ViewInformation2D from the ViewParameters for that purpose + */ + virtual css::geometry::RealRectangle2D + getRange(const css::uno::Sequence& rViewParameters); + + // XAccounting + virtual sal_Int64 estimateUsage(); +}; + +/** + Rather than make all the BasePrimitive2D classes bear the cost of being an UNO + object, we just wrap the top level BasePrimitive2D in this class when we need + to pass them over UNO +*/ +class DRAWINGLAYERCORE_DLLPUBLIC UnoPrimitive2D final : public BasePrimitive2DImplBase +{ + UnoPrimitive2D(const UnoPrimitive2D&) = delete; + UnoPrimitive2D& operator=(const UnoPrimitive2D&) = delete; + +public: + // constructor/destructor + UnoPrimitive2D(const rtl::Reference& rPrimitive) + : mxPrimitive(rPrimitive) + { + } + virtual ~UnoPrimitive2D() override; + + /// The default implementation will use getDecomposition results to create the range + basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; + + /** provide unique ID for fast identifying of known primitive implementations in renderers. These use + the defines from drawinglayer_primitivetypes2d.hxx to define unique IDs. + */ + sal_uInt32 getPrimitive2DID() const; + + /// The default implementation will return an empty sequence + void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, + const geometry::ViewInformation2D& rViewInformation) const; + + // Methods from XPrimitive2D + /** The getDecomposition implementation for UNO API will use getDecomposition from this implementation. It will construct a ViewInformation2D from the ViewParameters for that purpose */ @@ -194,6 +245,11 @@ public: // XAccounting virtual sal_Int64 SAL_CALL estimateUsage() override; + + rtl::Reference const& getBasePrimitive2D() const { return mxPrimitive; } + +private: + rtl::Reference mxPrimitive; }; } // end of namespace drawinglayer::primitive2d diff --git a/include/drawinglayer/primitive2d/bitmapprimitive2d.hxx b/include/drawinglayer/primitive2d/bitmapprimitive2d.hxx index bef384eb47b2..46c0825af5e5 100644 --- a/include/drawinglayer/primitive2d/bitmapprimitive2d.hxx +++ b/include/drawinglayer/primitive2d/bitmapprimitive2d.hxx @@ -67,7 +67,7 @@ public: getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; // XAccounting - virtual sal_Int64 SAL_CALL estimateUsage() override; + virtual sal_Int64 estimateUsage() override; /// provide unique ID virtual sal_uInt32 getPrimitive2DID() const override; diff --git a/include/drawinglayer/primitive2d/groupprimitive2d.hxx b/include/drawinglayer/primitive2d/groupprimitive2d.hxx index 52d4fb4eb13b..b34bef834f03 100644 --- a/include/drawinglayer/primitive2d/groupprimitive2d.hxx +++ b/include/drawinglayer/primitive2d/groupprimitive2d.hxx @@ -85,7 +85,7 @@ namespace drawinglayer::primitive2d virtual sal_uInt32 getPrimitive2DID() const override; // XAccounting - virtual sal_Int64 SAL_CALL estimateUsage() override; + virtual sal_Int64 estimateUsage() override; }; } // end of namespace drawinglayer::primitive2d diff --git a/include/drawinglayer/primitive2d/patternfillprimitive2d.hxx b/include/drawinglayer/primitive2d/patternfillprimitive2d.hxx index 63a3e6d8d274..9da0e44e5414 100644 --- a/include/drawinglayer/primitive2d/patternfillprimitive2d.hxx +++ b/include/drawinglayer/primitive2d/patternfillprimitive2d.hxx @@ -85,7 +85,7 @@ namespace drawinglayer::primitive2d virtual sal_uInt32 getPrimitive2DID() const override; // XAccounting - virtual sal_Int64 SAL_CALL estimateUsage() override; + virtual sal_Int64 estimateUsage() override; /// helper which creates the content - checks if clipping is needed and eventually /// creates buffered content to speed up rendering diff --git a/include/drawinglayer/primitive2d/textbreakuphelper.hxx b/include/drawinglayer/primitive2d/textbreakuphelper.hxx index de233da8ea07..c007bb6afa1c 100644 --- a/include/drawinglayer/primitive2d/textbreakuphelper.hxx +++ b/include/drawinglayer/primitive2d/textbreakuphelper.hxx @@ -20,7 +20,7 @@ #pragma once #include -#include +#include #include #include @@ -39,7 +39,7 @@ namespace drawinglayer::primitive2d { private: const TextSimplePortionPrimitive2D& mrSource; - Primitive2DContainer mxResult; + Primitive2DContainer mxResult; TextLayouterDevice maTextLayouter; basegfx::utils::B2DHomMatrixBufferedOnDemandDecompose maDecTrans; diff --git a/include/drawinglayer/processor2d/hittestprocessor2d.hxx b/include/drawinglayer/processor2d/hittestprocessor2d.hxx index 9ba4ad55dcaa..5638f688964e 100644 --- a/include/drawinglayer/processor2d/hittestprocessor2d.hxx +++ b/include/drawinglayer/processor2d/hittestprocessor2d.hxx @@ -21,7 +21,7 @@ #define INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX #include - +#include #include namespace basegfx { class B2DPolygon; } diff --git a/sfx2/source/appl/appmisc.cxx b/sfx2/source/appl/appmisc.cxx index 51cde7cb8a7a..dc1f26a969b3 100644 --- a/sfx2/source/appl/appmisc.cxx +++ b/sfx2/source/appl/appmisc.cxx @@ -156,7 +156,7 @@ bool SfxApplication::loadBrandSvg(const char *pName, BitmapEx &rBitmap, int nWid const drawinglayer::primitive2d::Primitive2DReference xTransformRef( new drawinglayer::primitive2d::TransformPrimitive2D( aTransform, - aVectorGraphicData.getPrimitive2DSequence())); + drawinglayer::primitive2d::Primitive2DContainer(aVectorGraphicData.getPrimitive2DSequence()))); // UNO dance to render from drawinglayer @@ -178,7 +178,7 @@ bool SfxApplication::loadBrandSvg(const char *pName, BitmapEx &rBitmap, int nWid const uno::Reference< rendering::XBitmap > xBitmap( xPrimitive2DRenderer->rasterize( - drawinglayer::primitive2d::Primitive2DSequence(&xTransformRef, 1), + drawinglayer::primitive2d::Primitive2DContainer{xTransformRef}.toSequence(), uno::Sequence< beans::PropertyValue >(), fFakeDPI, fFakeDPI, diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 04de9a437550..37043f8767c0 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index b4924dc4474c..7050dee85964 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -80,6 +80,7 @@ #include #include #include +#include #include diff --git a/svgio/CppunitTest_svgio.mk b/svgio/CppunitTest_svgio.mk index e6708c916f34..3a828ad036e3 100644 --- a/svgio/CppunitTest_svgio.mk +++ b/svgio/CppunitTest_svgio.mk @@ -35,6 +35,7 @@ $(eval $(call gb_CppunitTest_use_libraries,svgio,\ cppuhelper \ comphelper \ sal \ + salhelper \ sax \ svt \ test \ diff --git a/svgio/CppunitTest_svgio_tools.mk b/svgio/CppunitTest_svgio_tools.mk index 09eb03f659fc..cb48c5eda09d 100644 --- a/svgio/CppunitTest_svgio_tools.mk +++ b/svgio/CppunitTest_svgio_tools.mk @@ -34,6 +34,7 @@ $(eval $(call gb_CppunitTest_use_libraries,svgio_tools,\ cppu \ cppuhelper \ sal \ + salhelper \ sax \ svt \ tk \ diff --git a/svgio/Library_svgio.mk b/svgio/Library_svgio.mk index e921ddaad939..c5a35405323f 100644 --- a/svgio/Library_svgio.mk +++ b/svgio/Library_svgio.mk @@ -39,6 +39,7 @@ $(eval $(call gb_Library_use_libraries,svgio,\ cppu \ cppuhelper \ sal \ + salhelper \ tk \ tl \ sax \ diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index 25baf76fdad8..a46285ee7f64 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -129,7 +130,7 @@ Primitive2DSequence Test::parseSvg(std::u16string_view aSource) void Test::checkRectPrimitive(Primitive2DSequence const & rPrimitive) { drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(rPrimitive)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(rPrimitive)); CPPUNIT_ASSERT (pDocument); @@ -149,8 +150,11 @@ void Test::checkRectPrimitive(Primitive2DSequence const & rPrimitive) bool arePrimitive2DSequencesEqual(const Primitive2DSequence& rA, const Primitive2DSequence& rB) { return std::equal(rA.begin(), rA.end(), rB.begin(), rB.end(), - [](const Primitive2DReference& a, const Primitive2DReference& b) { - return drawinglayer::primitive2d::arePrimitive2DReferencesEqual(a, b); }); + [](const css::uno::Reference& a, + const css::uno::Reference& b) + { + return drawinglayer::primitive2d::arePrimitive2DReferencesEqual(a, b); + }); } // Attributes for an object (like rect as in this case) can be defined @@ -185,7 +189,7 @@ void Test::testTdf87309() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf87309.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceTdf87309)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf87309); CPPUNIT_ASSERT (pDocument); @@ -204,7 +208,7 @@ void Test::testFontsizeKeywords() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceFontsizeKeywords.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceFontsizeKeywords)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceFontsizeKeywords); CPPUNIT_ASSERT (pDocument); @@ -267,7 +271,7 @@ void Test::testFontsizePercentage() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceFontsizePercentage.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceFontsizePercentage)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceFontsizePercentage); CPPUNIT_ASSERT (pDocument); @@ -284,7 +288,7 @@ void Test::testFontsizeRelative() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceFontsizeRelative.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceFontsizeRelative)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceFontsizeRelative); CPPUNIT_ASSERT (pDocument); @@ -306,7 +310,7 @@ void Test::testTdf45771() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf45771.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceTdf45771)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf45771); CPPUNIT_ASSERT (pDocument); @@ -323,7 +327,7 @@ void Test::testTdf97941() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf97941.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceTdf97941)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf97941); CPPUNIT_ASSERT (pDocument); @@ -339,7 +343,7 @@ void Test::testTdf104339() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf104339.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceTdf104339)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf104339); CPPUNIT_ASSERT (pDocument); assertXPath(pDocument, "/primitive2D/transform/transform/transform/transform/transform/polypolygoncolor", "color", "#000000"); @@ -351,7 +355,7 @@ void Test::testTdf85770() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf85770.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceTdf85770)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf85770)); CPPUNIT_ASSERT (pDocument); @@ -377,7 +381,7 @@ void Test::testTdf79163() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf79163.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceTdf79163)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf79163)); CPPUNIT_ASSERT (pDocument); @@ -390,7 +394,7 @@ void Test::testTdf97542_1() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf97542_1.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceTdf97542_1)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf97542_1)); CPPUNIT_ASSERT (pDocument); @@ -406,7 +410,7 @@ void Test::testTdf97542_2() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf97542_2.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceTdf97542_2)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf97542_2)); CPPUNIT_ASSERT (pDocument); @@ -422,7 +426,7 @@ void Test::testTdf97543() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf97543.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceTdf97543)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf97543)); CPPUNIT_ASSERT (pDocument); @@ -441,7 +445,7 @@ void Test::testRGBColor() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceRGBColor.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceRGBColor)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceRGBColor)); CPPUNIT_ASSERT (pDocument); @@ -460,7 +464,7 @@ void Test::testRGBAColor() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceRGBAColor.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceRGBAColor)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceRGBAColor)); CPPUNIT_ASSERT (pDocument); @@ -473,7 +477,7 @@ void Test::testNoneColor() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceRGBAColor.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceRGBAColor)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceRGBAColor)); CPPUNIT_ASSERT (pDocument); @@ -490,7 +494,7 @@ void Test::testTdf97936() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf97936.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceTdf97936)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf97936)); CPPUNIT_ASSERT (pDocument); @@ -518,7 +522,7 @@ void Test::testClipPathAndParentStyle() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceClipPathAndParentStyle.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceClipPathAndParentStyle)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceClipPathAndParentStyle)); CPPUNIT_ASSERT (pDocument); @@ -536,7 +540,7 @@ void Test::testClipPathAndStyle() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceClipPathAndStyle.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceClipPathAndStyle)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceClipPathAndStyle)); CPPUNIT_ASSERT (pDocument); @@ -553,7 +557,7 @@ void Test::testi125329() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequencei125329.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequencei125329)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequencei125329)); CPPUNIT_ASSERT (pDocument); @@ -576,7 +580,7 @@ void Test::testMaskingPath07b() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceMaskingPath07b.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceMaskingPath07b)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceMaskingPath07b)); CPPUNIT_ASSERT (pDocument); @@ -588,7 +592,7 @@ void Test::test123926() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence123926.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence123926)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence123926)); CPPUNIT_ASSERT (pDocument); @@ -602,7 +606,7 @@ void Test::test47446() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence47446.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence47446)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence47446)); CPPUNIT_ASSERT (pDocument); @@ -617,7 +621,7 @@ void Test::test47446b() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence47446b.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence47446b)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence47446b)); CPPUNIT_ASSERT (pDocument); @@ -632,7 +636,7 @@ void Test::testMaskText() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceMaskText.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceMaskText)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceMaskText)); CPPUNIT_ASSERT (pDocument); @@ -650,7 +654,7 @@ void Test::testTdf99994() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf99994.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceTdf99994)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf99994)); CPPUNIT_ASSERT (pDocument); @@ -667,7 +671,7 @@ void Test::testTdf99115() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf99115.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceTdf99115) ); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf99115) ); CPPUNIT_ASSERT (pDocument); @@ -716,7 +720,7 @@ void Test::testTdf101237() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf101237.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceTdf101237)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf101237)); CPPUNIT_ASSERT (pDocument); @@ -731,7 +735,7 @@ void Test::testTdf94765() CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf94765.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequenceTdf94765)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf94765)); CPPUNIT_ASSERT (pDocument); @@ -762,7 +766,7 @@ void Test::testBehaviourWhenWidthAndHeightIsOrIsNotSet() basegfx::B2DRange aRange; uno::Sequence aViewParameters; - for (Primitive2DReference const & xReference : aSequence) + for (css::uno::Reference const & xReference : aSequence) { if (xReference.is()) { @@ -787,7 +791,7 @@ void Test::testBehaviourWhenWidthAndHeightIsOrIsNotSet() basegfx::B2DRange aRange; uno::Sequence aViewParameters; - for (Primitive2DReference const & xReference : aSequence) + for (css::uno::Reference const & xReference : aSequence) { if (xReference.is()) { diff --git a/svgio/source/svguno/xsvgparser.cxx b/svgio/source/svguno/xsvgparser.cxx index 515c6910beb4..f6e85cdeb964 100644 --- a/svgio/source/svguno/xsvgparser.cxx +++ b/svgio/source/svguno/xsvgparser.cxx @@ -141,7 +141,7 @@ namespace svgio::svgreader OSL_ENSURE(false, "Invalid stream (!)"); } - return comphelper::containerToSequence(aRetval); + return aRetval.toSequence(); } uno::Any SAL_CALL XSvgParser::getDrawCommands( diff --git a/svx/source/dialog/frmsel.cxx b/svx/source/dialog/frmsel.cxx index e2be7400f89c..117bec6f6784 100644 --- a/svx/source/dialog/frmsel.cxx +++ b/svx/source/dialog/frmsel.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include diff --git a/svx/source/sdr/primitive2d/primitivefactory2d.cxx b/svx/source/sdr/primitive2d/primitivefactory2d.cxx index 9625c8bcd41e..620bc0e4f5a9 100644 --- a/svx/source/sdr/primitive2d/primitivefactory2d.cxx +++ b/svx/source/sdr/primitive2d/primitivefactory2d.cxx @@ -36,7 +36,7 @@ css::uno::Sequence< css::uno::Reference< css::graphic::XPrimitive2D > > SAL_CALL const sdr::contact::ViewContact& rSource(pSource->GetViewContact()); drawinglayer::primitive2d::Primitive2DContainer aSourceVal; rSource.getViewIndependentPrimitive2DContainer(aSourceVal); - aRetval = comphelper::containerToSequence(aSourceVal); + aRetval = aSourceVal.toSequence(); } } @@ -75,7 +75,7 @@ css::uno::Sequence< css::uno::Reference< css::graphic::XPrimitive2D > > SAL_CALL const sdr::contact::ViewContact& rSource(pSource->GetViewContact()); drawinglayer::primitive2d::Primitive2DContainer aSourceRetval; rSource.getViewIndependentPrimitive2DContainer(aSourceRetval); - aRetval = comphelper::containerToSequence(aSourceRetval); + aRetval = aSourceRetval.toSequence(); } } diff --git a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx index 017be7b4f5bb..18f1a0918fed 100644 --- a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx +++ b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx @@ -212,7 +212,7 @@ basegfx::B2DRange getTextAnchorRange(const attribute::SdrTextAttribute& rText, else { // add to decomposition - return Primitive2DReference(pNewFillPrimitive); + return pNewFillPrimitive; } } @@ -249,7 +249,7 @@ basegfx::B2DRange getTextAnchorRange(const attribute::SdrTextAttribute& rText, else { // add to decomposition - return Primitive2DReference(pNewLinePrimitive); + return pNewLinePrimitive; } } diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index 67bd14cc8622..2b95bb7207f3 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -145,15 +145,15 @@ void SdrGrafObj::onGraphicChanged() if (rVectorGraphicDataPtr->getType() == VectorGraphicDataType::Pdf) return; - const drawinglayer::primitive2d::Primitive2DContainer aSequence(rVectorGraphicDataPtr->getPrimitive2DSequence()); + const std::deque>& rContainer(rVectorGraphicDataPtr->getPrimitive2DSequence()); - if (aSequence.empty()) + if (rContainer.empty()) return; drawinglayer::geometry::ViewInformation2D aViewInformation2D; drawinglayer::processor2d::ObjectInfoPrimitiveExtractor2D aProcessor(aViewInformation2D); - aProcessor.process(aSequence); + aProcessor.process(rContainer); const drawinglayer::primitive2d::ObjectInfoPrimitive2D* pResult = aProcessor.getResult(); diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx index e8c42b4651d1..5ab5b150d175 100644 --- a/svx/source/svdraw/svdpntv.cxx +++ b/svx/source/svdraw/svdpntv.cxx @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -118,7 +119,7 @@ BitmapEx convertMetafileToBitmapEx( rTargetRange.getRange(), rTargetRange.getMinimum()), rMtf)); - aBitmapEx = convertPrimitive2DSequenceToBitmapEx( + aBitmapEx = drawinglayer::convertPrimitive2DContainerToBitmapEx( drawinglayer::primitive2d::Primitive2DContainer { aMtf }, rTargetRange, nMaximumQuadraticPixels); diff --git a/svx/source/svdraw/svdview.cxx b/svx/source/svdraw/svdview.cxx index 0dddaf873c3b..55731106abf8 100644 --- a/svx/source/svdraw/svdview.cxx +++ b/svx/source/svdraw/svdview.cxx @@ -456,14 +456,11 @@ SdrHitKind SdrView::PickAnything(const Point& rLogicPos, SdrViewEvent& rVEvt) co for (const drawinglayer::primitive2d::Primitive2DReference& xReference : aHitContainer) { - if (xReference.is()) + auto pBasePrimitive = xReference.get(); + if (pBasePrimitive && pBasePrimitive->getPrimitive2DID() == PRIMITIVE2D_ID_TEXTHIERARCHYFIELDPRIMITIVE2D) { - auto pBasePrimitive = static_cast(xReference.get()); - if (pBasePrimitive->getPrimitive2DID() == PRIMITIVE2D_ID_TEXTHIERARCHYFIELDPRIMITIVE2D) - { - pTextHierarchyFieldPrimitive2D = static_cast(xReference.get()); - break; - } + pTextHierarchyFieldPrimitive2D = static_cast(pBasePrimitive); + break; } } diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx index 8e84ff133626..c4725d899566 100644 --- a/svx/source/svdraw/svdxcgv.cxx +++ b/svx/source/svdraw/svdxcgv.cxx @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -502,8 +503,8 @@ BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked, const // if we have geometry and it has a range, convert to BitmapEx using // common tooling - aBmp = convertPrimitive2DSequenceToBitmapEx( - xPrimitives, + aBmp = drawinglayer::convertPrimitive2DContainerToBitmapEx( + std::move(xPrimitives), aRange, nMaximumQuadraticPixels, eRangeUnit, diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 86b3d875d64a..94a7b2540ec6 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -80,6 +80,7 @@ #include #include #include +#include #include #include @@ -748,8 +749,8 @@ uno::Any SvxShape::GetBitmap( bool bMetaFile /* = false */ ) const } const BitmapEx aBmp( - convertPrimitive2DSequenceToBitmapEx( - xPrimitives, + drawinglayer::convertPrimitive2DContainerToBitmapEx( + std::move(xPrimitives), aRange)); Graphic aGraph(aBmp); diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 63de3bd1571e..cd6826c6dbba 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -63,6 +63,7 @@ $(eval $(call gb_Library_use_libraries,vcl,\ cppu \ cppuhelper \ $(call gb_Helper_optional,BREAKPAD,crashreport) \ + drawinglayercore \ i18nlangtag \ i18nutil \ $(if $(ENABLE_JAVA),jvmaccess) \ diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx index 2a9dc870ddc1..b22661c628d7 100644 --- a/vcl/source/bitmap/BitmapTools.cxx +++ b/vcl/source/bitmap/BitmapTools.cxx @@ -91,7 +91,7 @@ void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx, geometry::RealRectangle2D aRealRect; basegfx::B2DRange aRange; - for (Primitive2DReference const & xReference : aPrimitiveSequence) + for (css::uno::Reference const & xReference : aPrimitiveSequence) { if (xReference.is()) { diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index a10844e1cada..b00eb31599fd 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -715,12 +716,16 @@ const GDIMetaFile& ImpGraphic::getGDIMetaFile() const { // try to cast to MetafileAccessor implementation const css::uno::Reference< css::graphic::XPrimitive2D > xReference(aSequence[0]); - const MetafileAccessor* pMetafileAccessor = dynamic_cast< const MetafileAccessor* >(xReference.get()); - - if (pMetafileAccessor) + auto pUnoPrimitive = static_cast< const drawinglayer::primitive2d::UnoPrimitive2D* >(xReference.get()); + if (pUnoPrimitive) { - // it is a MetafileAccessor implementation, get Metafile - pMetafileAccessor->accessMetafile(const_cast< ImpGraphic* >(this)->maMetaFile); + const MetafileAccessor* pMetafileAccessor = dynamic_cast< const MetafileAccessor* >(pUnoPrimitive->getBasePrimitive2D().get()); + + if (pMetafileAccessor) + { + // it is a MetafileAccessor implementation, get Metafile + pMetafileAccessor->accessMetafile(const_cast< ImpGraphic* >(this)->maMetaFile); + } } } }