diff options
Diffstat (limited to 'drawinglayer/source/primitive2d')
18 files changed, 103 insertions, 66 deletions
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 <drawinglayer/primitive2d/Primitive2DContainer.hxx> #include <drawinglayer/primitive2d/Tools.hxx> +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> using namespace css; namespace drawinglayer::primitive2d { +Primitive2DContainer::Primitive2DContainer( + const css::uno::Sequence<css::uno::Reference<css::graphic::XPrimitive2D>>& rSource) +{ + for (const auto& rPrimitive : rSource) + append(static_cast<const UnoPrimitive2D*>(rPrimitive.get())->getBasePrimitive2D()); +} +Primitive2DContainer::Primitive2DContainer( + const std::deque<css::uno::Reference<css::graphic::XPrimitive2D>>& rSource) +{ + for (const auto& rPrimitive : rSource) + append(static_cast<const UnoPrimitive2D*>(rPrimitive.get())->getBasePrimitive2D()); +} + +css::uno::Sequence<css::uno::Reference<css::graphic::XPrimitive2D>> +Primitive2DContainer::toSequence() const +{ + css::uno::Sequence<css::uno::Reference<css::graphic::XPrimitive2D>> 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<const UnoPrimitive2D*>(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<css::beans::PropertyValue>& rViewParameters) +{ + std::unique_lock aGuard(m_aMutex); + return mxPrimitive->getDecomposition(rViewParameters).toSequence(); +} + +css::geometry::RealRectangle2D SAL_CALL +UnoPrimitive2D::getRange(const css::uno::Sequence<css::beans::PropertyValue>& 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<BasePrimitive2D*>(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<const BasePrimitive2D*>(rxA.get())); - const BasePrimitive2D* pB(static_cast<const BasePrimitive2D*>(rxB.get())); + return rxA->operator==(*rxB); +} + +bool arePrimitive2DReferencesEqual(const css::uno::Reference<css::graphic::XPrimitive2D>& rxA, + const css::uno::Reference<css::graphic::XPrimitive2D>& rxB) +{ + const bool bAIs(rxA.is()); + + if (bAIs != rxB.is()) + { + return false; + } + + if (!bAIs) + { + return true; + } + + auto pA = static_cast<const UnoPrimitive2D*>(rxA.get()); + auto pB = static_cast<const UnoPrimitive2D*>(rxB.get()); - return pA->operator==(*pB); + 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 <sal/config.h> +#include <drawinglayer/primitive2d/Primitive2DContainer.hxx> #include <drawinglayer/primitive2d/baseprimitive2d.hxx> #include <drawinglayer/primitive2d/Tools.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> @@ -141,23 +142,23 @@ void BasePrimitive2D::get2DDecomposition( { } -css::uno::Sequence<::css::uno::Reference<::css::graphic::XPrimitive2D>> SAL_CALL +Primitive2DContainer BasePrimitive2D::getDecomposition(const uno::Sequence<beans::PropertyValue>& 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<beans::PropertyValue>& 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<util::XAccounting> 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<util::XAccounting> 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); } |