summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-12-31 13:39:33 +0100
committerTomaž Vajngerl <quikee@gmail.com>2020-01-01 20:58:56 +0100
commita3569c7b89a7ddee06149ece91ce608b1252fa82 (patch)
treee795912d84a4159ced8c3c77940c8a72def86fc0
parent4abb191916916c7003deedcfdcf46287faccaf01 (diff)
drawinglayer: clang-format BasePrimitive2D + remove from blacklist
No functional change was made, only formatting of the code. The code was formatted with clang-format and moves the files baseprimitve2d.{cxx,hxx} out of blacklist so it will be auto formatted with every change from now on. Change-Id: If49ec94f91e58825f7aa94dc54cff8374467aa30 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86078 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--drawinglayer/source/primitive2d/baseprimitive2d.cxx666
-rw-r--r--include/drawinglayer/primitive2d/baseprimitive2d.hxx540
-rw-r--r--solenv/clang-format/blacklist2
3 files changed, 664 insertions, 544 deletions
diff --git a/drawinglayer/source/primitive2d/baseprimitive2d.cxx b/drawinglayer/source/primitive2d/baseprimitive2d.cxx
index 4db80991dd93..72b0f33734ee 100644
--- a/drawinglayer/source/primitive2d/baseprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/baseprimitive2d.cxx
@@ -28,349 +28,433 @@
#include <basegfx/utils/canvastools.hxx>
#include <comphelper/sequence.hxx>
-
using namespace com::sun::star;
-
namespace drawinglayer
{
- namespace primitive2d
- {
- Primitive2DDecompositionVisitor::~Primitive2DDecompositionVisitor() {}
-
- BasePrimitive2D::BasePrimitive2D()
- : BasePrimitive2DImplBase(m_aMutex)
- {
- }
-
- BasePrimitive2D::~BasePrimitive2D()
- {
- }
-
- bool BasePrimitive2D::operator==( const BasePrimitive2D& rPrimitive ) const
- {
- return (getPrimitive2DID() == rPrimitive.getPrimitive2DID());
- }
+namespace primitive2d
+{
+Primitive2DDecompositionVisitor::~Primitive2DDecompositionVisitor() {}
- namespace {
-
- // Visitor class to get the B2D range from a tree of Primitive2DReference's
- //
- class B2DRangeVisitor : public Primitive2DDecompositionVisitor {
- public:
- const geometry::ViewInformation2D& mrViewInformation;
- basegfx::B2DRange maRetval;
- B2DRangeVisitor(const geometry::ViewInformation2D& rViewInformation) : mrViewInformation(rViewInformation) {}
- virtual void append(const Primitive2DReference& r) override {
- maRetval.expand(getB2DRangeFromPrimitive2DReference(r, mrViewInformation));
- }
- virtual void append(const Primitive2DContainer& r) override {
- maRetval.expand(r.getB2DRange(mrViewInformation));
- }
- virtual void append(Primitive2DContainer&& r) override {
- maRetval.expand(r.getB2DRange(mrViewInformation));
- }
- };
+BasePrimitive2D::BasePrimitive2D()
+ : BasePrimitive2DImplBase(m_aMutex)
+{
+}
- }
+BasePrimitive2D::~BasePrimitive2D() {}
- basegfx::B2DRange BasePrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const
- {
- B2DRangeVisitor aVisitor(rViewInformation);
- get2DDecomposition(aVisitor, rViewInformation);
- return aVisitor.maRetval;
- }
+bool BasePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+{
+ return (getPrimitive2DID() == rPrimitive.getPrimitive2DID());
+}
- void BasePrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& /*rVisitor*/, const geometry::ViewInformation2D& /*rViewInformation*/) const
- {
- }
+namespace
+{
+// Visitor class to get the B2D range from a tree of Primitive2DReference's
+//
+class B2DRangeVisitor : public Primitive2DDecompositionVisitor
+{
+public:
+ const geometry::ViewInformation2D& mrViewInformation;
+ basegfx::B2DRange maRetval;
+ B2DRangeVisitor(const geometry::ViewInformation2D& rViewInformation)
+ : mrViewInformation(rViewInformation)
+ {
+ }
+ virtual void append(const Primitive2DReference& r) override
+ {
+ maRetval.expand(getB2DRangeFromPrimitive2DReference(r, mrViewInformation));
+ }
+ virtual void append(const Primitive2DContainer& r) override
+ {
+ maRetval.expand(r.getB2DRange(mrViewInformation));
+ }
+ virtual void append(Primitive2DContainer&& r) override
+ {
+ maRetval.expand(r.getB2DRange(mrViewInformation));
+ }
+};
+}
- css::uno::Sequence< ::css::uno::Reference< ::css::graphic::XPrimitive2D > > SAL_CALL BasePrimitive2D::getDecomposition( const uno::Sequence< beans::PropertyValue >& rViewParameters )
- {
- const geometry::ViewInformation2D aViewInformation(rViewParameters);
- Primitive2DContainer aContainer;
- get2DDecomposition(aContainer, aViewInformation);
- return comphelper::containerToSequence(aContainer);
- }
+basegfx::B2DRange
+BasePrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const
+{
+ B2DRangeVisitor aVisitor(rViewInformation);
+ get2DDecomposition(aVisitor, rViewInformation);
+ return aVisitor.maRetval;
+}
+
+void BasePrimitive2D::get2DDecomposition(
+ Primitive2DDecompositionVisitor& /*rVisitor*/,
+ const geometry::ViewInformation2D& /*rViewInformation*/) const
+{
+}
- css::geometry::RealRectangle2D SAL_CALL BasePrimitive2D::getRange( const uno::Sequence< beans::PropertyValue >& rViewParameters )
- {
- const geometry::ViewInformation2D aViewInformation(rViewParameters);
- return basegfx::unotools::rectangle2DFromB2DRectangle(getB2DRange(aViewInformation));
- }
+css::uno::Sequence<::css::uno::Reference<::css::graphic::XPrimitive2D>> SAL_CALL
+BasePrimitive2D::getDecomposition(const uno::Sequence<beans::PropertyValue>& rViewParameters)
+{
+ const geometry::ViewInformation2D aViewInformation(rViewParameters);
+ Primitive2DContainer aContainer;
+ get2DDecomposition(aContainer, aViewInformation);
+ return comphelper::containerToSequence(aContainer);
+}
+
+css::geometry::RealRectangle2D SAL_CALL
+BasePrimitive2D::getRange(const uno::Sequence<beans::PropertyValue>& rViewParameters)
+{
+ const geometry::ViewInformation2D aViewInformation(rViewParameters);
+ return basegfx::unotools::rectangle2DFromB2DRectangle(getB2DRange(aViewInformation));
+}
- sal_Int64 SAL_CALL BasePrimitive2D::estimateUsage()
- {
- return 0; // for now ignore the objects themselves
- }
- } // end of namespace primitive2d
+sal_Int64 SAL_CALL BasePrimitive2D::estimateUsage()
+{
+ return 0; // for now ignore the objects themselves
+}
+} // end of namespace primitive2d
} // end of namespace drawinglayer
-
namespace drawinglayer
{
- namespace primitive2d
- {
- void BufferedDecompositionPrimitive2D::create2DDecomposition(Primitive2DContainer& /*rContainer*/, const geometry::ViewInformation2D& /*rViewInformation*/) const
- {
- }
-
- BufferedDecompositionPrimitive2D::BufferedDecompositionPrimitive2D()
- : BasePrimitive2D(),
- maBuffered2DDecomposition()
- {
- }
+namespace primitive2d
+{
+void BufferedDecompositionPrimitive2D::create2DDecomposition(
+ Primitive2DContainer& /*rContainer*/,
+ const geometry::ViewInformation2D& /*rViewInformation*/) const
+{
+}
- void BufferedDecompositionPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const
- {
- ::osl::MutexGuard aGuard( m_aMutex );
+BufferedDecompositionPrimitive2D::BufferedDecompositionPrimitive2D()
+ : BasePrimitive2D()
+ , maBuffered2DDecomposition()
+{
+}
- if(getBuffered2DDecomposition().empty())
- {
- Primitive2DContainer aNewSequence;
- create2DDecomposition(aNewSequence, rViewInformation);
- const_cast< BufferedDecompositionPrimitive2D* >(this)->setBuffered2DDecomposition(aNewSequence);
- }
+void BufferedDecompositionPrimitive2D::get2DDecomposition(
+ Primitive2DDecompositionVisitor& rVisitor,
+ const geometry::ViewInformation2D& rViewInformation) const
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
- rVisitor.append(getBuffered2DDecomposition());
- }
- } // end of namespace primitive2d
+ if (getBuffered2DDecomposition().empty())
+ {
+ Primitive2DContainer aNewSequence;
+ create2DDecomposition(aNewSequence, rViewInformation);
+ const_cast<BufferedDecompositionPrimitive2D*>(this)->setBuffered2DDecomposition(
+ aNewSequence);
+ }
+
+ rVisitor.append(getBuffered2DDecomposition());
+}
+} // end of namespace primitive2d
} // end of namespace drawinglayer
-
// tooling
namespace drawinglayer
{
- namespace primitive2d
+namespace primitive2d
+{
+Primitive2DContainer Primitive2DContainer::maybeInvert(bool bInvert) const
+{
+ const sal_uInt32 nSize(size());
+ Primitive2DContainer aRetval;
+
+ aRetval.resize(nSize);
+
+ for (sal_uInt32 a(0); a < nSize; a++)
{
- Primitive2DContainer Primitive2DContainer::maybeInvert(bool bInvert) const
- {
- const sal_uInt32 nSize(size());
- Primitive2DContainer aRetval;
+ aRetval[bInvert ? nSize - 1 - a : a] = (*this)[a];
+ }
- aRetval.resize(nSize);
+ // all entries taken over to Uno References as owners. To avoid
+ // errors with users of this mechanism to delete pointers to BasePrimitive2D
+ // itself, clear given vector
+ const_cast<Primitive2DContainer&>(*this).clear();
- for(sal_uInt32 a(0); a < nSize; a++)
- {
- aRetval[bInvert ? nSize - 1 - a : a] = (*this)[a];
- }
+ return aRetval;
+}
- // all entries taken over to Uno References as owners. To avoid
- // errors with users of this mechanism to delete pointers to BasePrimitive2D
- // itself, clear given vector
- const_cast< Primitive2DContainer& >(*this).clear();
+// get B2DRange from a given Primitive2DReference
+basegfx::B2DRange
+getB2DRangeFromPrimitive2DReference(const Primitive2DReference& rCandidate,
+ const geometry::ViewInformation2D& aViewInformation)
+{
+ basegfx::B2DRange aRetval;
- return aRetval;
- }
+ if (rCandidate.is())
+ {
+ // try to get C++ implementation base
+ const BasePrimitive2D* pCandidate(dynamic_cast<BasePrimitive2D*>(rCandidate.get()));
- // get B2DRange from a given Primitive2DReference
- basegfx::B2DRange getB2DRangeFromPrimitive2DReference(const Primitive2DReference& rCandidate, const geometry::ViewInformation2D& aViewInformation)
+ if (pCandidate)
{
- basegfx::B2DRange aRetval;
-
- if(rCandidate.is())
- {
- // try to get C++ implementation base
- const BasePrimitive2D* pCandidate(dynamic_cast< BasePrimitive2D* >(rCandidate.get()));
-
- if(pCandidate)
- {
- // use it if possible
- aRetval.expand(pCandidate->getB2DRange(aViewInformation));
- }
- else
- {
- // use UNO API call instead
- const uno::Sequence< beans::PropertyValue >& rViewParameters(aViewInformation.getViewInformationSequence());
- aRetval.expand(basegfx::unotools::b2DRectangleFromRealRectangle2D(rCandidate->getRange(rViewParameters)));
- }
- }
-
- return aRetval;
+ // use it if possible
+ aRetval.expand(pCandidate->getB2DRange(aViewInformation));
}
-
- // get B2DRange from a given Primitive2DSequence
- basegfx::B2DRange Primitive2DContainer::getB2DRange(const geometry::ViewInformation2D& aViewInformation) const
+ else
{
- basegfx::B2DRange aRetval;
+ // use UNO API call instead
+ const uno::Sequence<beans::PropertyValue>& rViewParameters(
+ aViewInformation.getViewInformationSequence());
+ aRetval.expand(basegfx::unotools::b2DRectangleFromRealRectangle2D(
+ rCandidate->getRange(rViewParameters)));
+ }
+ }
- if(!empty())
- {
- const sal_Int32 nCount(size());
+ return aRetval;
+}
- for(sal_Int32 a(0); a < nCount; a++)
- {
- aRetval.expand(getB2DRangeFromPrimitive2DReference((*this)[a], aViewInformation));
- }
- }
+// get B2DRange from a given Primitive2DSequence
+basegfx::B2DRange
+Primitive2DContainer::getB2DRange(const geometry::ViewInformation2D& aViewInformation) const
+{
+ basegfx::B2DRange aRetval;
- return aRetval;
- }
+ if (!empty())
+ {
+ const sal_Int32 nCount(size());
- bool arePrimitive2DReferencesEqual(const Primitive2DReference& rxA, const Primitive2DReference& rxB)
+ for (sal_Int32 a(0); a < nCount; a++)
{
- const bool bAIs(rxA.is());
+ aRetval.expand(getB2DRangeFromPrimitive2DReference((*this)[a], aViewInformation));
+ }
+ }
- if(bAIs != rxB.is())
- {
- return false;
- }
+ return aRetval;
+}
- if(!bAIs)
- {
- return true;
- }
+bool arePrimitive2DReferencesEqual(const Primitive2DReference& rxA, const Primitive2DReference& rxB)
+{
+ const bool bAIs(rxA.is());
- const BasePrimitive2D* pA(dynamic_cast< const BasePrimitive2D* >(rxA.get()));
- const BasePrimitive2D* pB(dynamic_cast< const BasePrimitive2D* >(rxB.get()));
+ if (bAIs != rxB.is())
+ {
+ return false;
+ }
- if (!pA || !pB)
- {
- return false;
- }
+ if (!bAIs)
+ {
+ return true;
+ }
- return pA->operator==(*pB);
- }
+ const BasePrimitive2D* pA(dynamic_cast<const BasePrimitive2D*>(rxA.get()));
+ const BasePrimitive2D* pB(dynamic_cast<const BasePrimitive2D*>(rxB.get()));
- bool Primitive2DContainer::operator==(const Primitive2DContainer& rB) const
- {
- const bool bAHasElements(!empty());
-
- if(bAHasElements != !rB.empty())
- {
- return false;
- }
-
- if(!bAHasElements)
- {
- return true;
- }
-
- const size_t nCount(size());
-
- if(nCount != rB.size())
- {
- return false;
- }
-
- for(size_t a(0); a < nCount; a++)
- {
- if(!arePrimitive2DReferencesEqual((*this)[a], rB[a]))
- {
- return false;
- }
- }
-
- return true;
- }
+ if (!pA || !pB)
+ {
+ return false;
+ }
- Primitive2DContainer::~Primitive2DContainer() {}
+ return pA->operator==(*pB);
+}
- void Primitive2DContainer::append(const Primitive2DReference& rSource)
- {
- push_back(rSource);
- }
+bool Primitive2DContainer::operator==(const Primitive2DContainer& rB) const
+{
+ const bool bAHasElements(!empty());
- void Primitive2DContainer::append(const Primitive2DContainer& rSource)
- {
- insert(end(), rSource.begin(), rSource.end());
- }
+ if (bAHasElements != !rB.empty())
+ {
+ return false;
+ }
- void Primitive2DContainer::append(Primitive2DContainer&& rSource)
- {
- size_t n = size();
- resize(n + rSource.size());
- for (size_t i = 0; i<rSource.size(); ++i)
- {
- (*this)[n + i] = std::move( rSource[i] );
- }
- }
+ if (!bAHasElements)
+ {
+ return true;
+ }
- void Primitive2DContainer::append(const Primitive2DSequence& rSource)
- {
- std::copy(rSource.begin(), rSource.end(), std::back_inserter(*this));
- }
+ const size_t nCount(size());
+
+ if (nCount != rB.size())
+ {
+ return false;
+ }
- OUString idToString(sal_uInt32 nId)
+ for (size_t a(0); a < nCount; a++)
+ {
+ if (!arePrimitive2DReferencesEqual((*this)[a], rB[a]))
{
- switch( nId )
- {
- case PRIMITIVE2D_ID_TRANSPARENCEPRIMITIVE2D: return "TRANSPARENCE";
- case PRIMITIVE2D_ID_ANIMATEDSWITCHPRIMITIVE2D: return "ANIMATEDSWITCH";
- case PRIMITIVE2D_ID_ANIMATEDBLINKPRIMITIVE2D: return "ANIMATEDBLINK";
- case PRIMITIVE2D_ID_ANIMATEDINTERPOLATEPRIMITIVE2D: return "ANIMATEDINTERPOLATE";
- case PRIMITIVE2D_ID_BACKGROUNDCOLORPRIMITIVE2D: return "BACKGROUNDCOLOR";
- case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D: return "BITMAP";
- case PRIMITIVE2D_ID_CONTROLPRIMITIVE2D: return "CONTROL";
- case PRIMITIVE2D_ID_EMBEDDED3DPRIMITIVE2D: return "EMBEDDED3D";
- case PRIMITIVE2D_ID_FILLGRAPHICPRIMITIVE2D: return "FILLGRAPHIC";
- case PRIMITIVE2D_ID_FILLGRADIENTPRIMITIVE2D: return "FILLGRADIENT";
- case PRIMITIVE2D_ID_FILLHATCHPRIMITIVE2D: return "FILLHATCH";
- case PRIMITIVE2D_ID_GRAPHICPRIMITIVE2D: return "GRAPHIC";
- case PRIMITIVE2D_ID_GRIDPRIMITIVE2D: return "GRID";
- case PRIMITIVE2D_ID_GROUPPRIMITIVE2D: return "GROUP";
- case PRIMITIVE2D_ID_HELPLINEPRIMITIVE2D: return "HELPLINE";
- case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D: return "MARKERARRAY";
- case PRIMITIVE2D_ID_MASKPRIMITIVE2D: return "MASK";
- case PRIMITIVE2D_ID_MEDIAPRIMITIVE2D: return "MEDIA";
- case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D: return "METAFILE";
- case PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D: return "MODIFIEDCOLOR";
- case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D: return "POLYGONHAIRLINE";
- case PRIMITIVE2D_ID_POLYGONMARKERPRIMITIVE2D: return "POLYGONMARKER";
- case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D: return "POLYGONSTROKE";
- case PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D: return "POLYGONSTROKEARROW";
- case PRIMITIVE2D_ID_POLYPOLYGONSTROKEPRIMITIVE2D: return "POLYPOLYGONSTROKE";
- case PRIMITIVE2D_ID_POLYPOLYGONSTROKEARROWPRIMITIVE2D: return "POLYPOLYGONSTROKEARROW";
- case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D: return "POLYPOLYGONCOLOR";
- case PRIMITIVE2D_ID_POLYPOLYGONGRADIENTPRIMITIVE2D: return "POLYPOLYGONGRADIENT";
- case PRIMITIVE2D_ID_POLYPOLYGONHATCHPRIMITIVE2D: return "POLYPOLYGONHATCH";
- case PRIMITIVE2D_ID_POLYPOLYGONGRAPHICPRIMITIVE2D: return "POLYPOLYGONGRAPHIC";
- case PRIMITIVE2D_ID_SCENEPRIMITIVE2D: return "SCENE";
- case PRIMITIVE2D_ID_SHADOWPRIMITIVE2D: return "SHADOW";
- case PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D: return "TEXTSIMPLEPORTION";
- case PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D: return "TEXTDECORATEDPORTION";
- case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D: return "TRANSFORM";
- case PRIMITIVE2D_ID_UNIFIEDTRANSPARENCEPRIMITIVE2D: return "UNIFIEDTRANSPARENCE";
- case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D: return "POINTARRAY";
- case PRIMITIVE2D_ID_TEXTHIERARCHYFIELDPRIMITIVE2D: return "TEXTHIERARCHYFIELD";
- case PRIMITIVE2D_ID_TEXTHIERARCHYLINEPRIMITIVE2D: return "TEXTHIERARCHYLINE";
- case PRIMITIVE2D_ID_TEXTHIERARCHYPARAGRAPHPRIMITIVE2D: return "TEXTHIERARCHYPARAGRAPH";
- case PRIMITIVE2D_ID_TEXTHIERARCHYBLOCKPRIMITIVE2D: return "TEXTHIERARCHYBLOCK";
- case PRIMITIVE2D_ID_TEXTHIERARCHYEDITPRIMITIVE2D: return "TEXTHIERARCHYEDIT";
- case PRIMITIVE2D_ID_POLYGONWAVEPRIMITIVE2D: return "POLYGONWAVE";
- case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D: return "WRONGSPELL";
- case PRIMITIVE2D_ID_TEXTEFFECTPRIMITIVE2D: return "TEXTEFFECT";
- case PRIMITIVE2D_ID_TEXTHIERARCHYBULLETPRIMITIVE2D: return "TEXTHIERARCHYBULLET";
- case PRIMITIVE2D_ID_POLYPOLYGONHAIRLINEPRIMITIVE2D: return "POLYPOLYGONHAIRLINE";
- case PRIMITIVE2D_ID_EXECUTEPRIMITIVE2D: return "EXECUTE";
- case PRIMITIVE2D_ID_PAGEPREVIEWPRIMITIVE2D: return "PAGEPREVIEW";
- case PRIMITIVE2D_ID_STRUCTURETAGPRIMITIVE2D: return "STRUCTURETAG";
- case PRIMITIVE2D_ID_BORDERLINEPRIMITIVE2D: return "BORDERLINE";
- case PRIMITIVE2D_ID_POLYPOLYGONMARKERPRIMITIVE2D: return "POLYPOLYGONMARKER";
- case PRIMITIVE2D_ID_HITTESTPRIMITIVE2D: return "HITTEST";
- case PRIMITIVE2D_ID_INVERTPRIMITIVE2D: return "INVERT";
- case PRIMITIVE2D_ID_DISCRETEBITMAPPRIMITIVE2D: return "DISCRETEBITMAP";
- case PRIMITIVE2D_ID_WALLPAPERBITMAPPRIMITIVE2D: return "WALLPAPERBITMAP";
- case PRIMITIVE2D_ID_TEXTLINEPRIMITIVE2D: return "TEXTLINE";
- case PRIMITIVE2D_ID_TEXTCHARACTERSTRIKEOUTPRIMITIVE2D: return "TEXTCHARACTERSTRIKEOUT";
- case PRIMITIVE2D_ID_TEXTGEOMETRYSTRIKEOUTPRIMITIVE2D: return "TEXTGEOMETRYSTRIKEOUT";
- case PRIMITIVE2D_ID_EPSPRIMITIVE2D: return "EPS";
- case PRIMITIVE2D_ID_DISCRETESHADOWPRIMITIVE2D: return "DISCRETESHADOW";
- case PRIMITIVE2D_ID_HIDDENGEOMETRYPRIMITIVE2D: return "HIDDENGEOMETRY";
- case PRIMITIVE2D_ID_SVGLINEARGRADIENTPRIMITIVE2D: return "SVGLINEARGRADIENT";
- case PRIMITIVE2D_ID_SVGRADIALGRADIENTPRIMITIVE2D: return "SVGRADIALGRADIENT";
- case PRIMITIVE2D_ID_SVGLINEARATOMPRIMITIVE2D: return "SVGLINEARATOM";
- case PRIMITIVE2D_ID_SVGRADIALATOMPRIMITIVE2D: return "SVGRADIALATOM";
- case PRIMITIVE2D_ID_CROPPRIMITIVE2D: return "CROP";
- case PRIMITIVE2D_ID_PATTERNFILLPRIMITIVE2D: return "PATTERNFILL";
- case PRIMITIVE2D_ID_OBJECTINFOPRIMITIVE2D: return "OBJECTINFO";
- case PRIMITIVE2D_ID_POLYPOLYGONSELECTIONPRIMITIVE2D: return "POLYPOLYGONSELECTION";
- case PRIMITIVE2D_ID_PAGEHIERARCHYPRIMITIVE2D: return "PAGEHIERARCHY";
- default: return OUString::number((nId >> 16) & 0xFF) + "|" + OUString::number(nId & 0xFF);
- }
+ return false;
}
- } // end of namespace primitive2d
+ }
+
+ return true;
+}
+
+Primitive2DContainer::~Primitive2DContainer() {}
+
+void Primitive2DContainer::append(const Primitive2DReference& rSource) { push_back(rSource); }
+
+void Primitive2DContainer::append(const Primitive2DContainer& rSource)
+{
+ insert(end(), rSource.begin(), rSource.end());
+}
+
+void Primitive2DContainer::append(Primitive2DContainer&& rSource)
+{
+ size_t n = size();
+ resize(n + rSource.size());
+ for (size_t i = 0; i < rSource.size(); ++i)
+ {
+ (*this)[n + i] = std::move(rSource[i]);
+ }
+}
+
+void Primitive2DContainer::append(const Primitive2DSequence& rSource)
+{
+ std::copy(rSource.begin(), rSource.end(), std::back_inserter(*this));
+}
+
+OUString idToString(sal_uInt32 nId)
+{
+ switch (nId)
+ {
+ case PRIMITIVE2D_ID_TRANSPARENCEPRIMITIVE2D:
+ return "TRANSPARENCE";
+ case PRIMITIVE2D_ID_ANIMATEDSWITCHPRIMITIVE2D:
+ return "ANIMATEDSWITCH";
+ case PRIMITIVE2D_ID_ANIMATEDBLINKPRIMITIVE2D:
+ return "ANIMATEDBLINK";
+ case PRIMITIVE2D_ID_ANIMATEDINTERPOLATEPRIMITIVE2D:
+ return "ANIMATEDINTERPOLATE";
+ case PRIMITIVE2D_ID_BACKGROUNDCOLORPRIMITIVE2D:
+ return "BACKGROUNDCOLOR";
+ case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D:
+ return "BITMAP";
+ case PRIMITIVE2D_ID_CONTROLPRIMITIVE2D:
+ return "CONTROL";
+ case PRIMITIVE2D_ID_EMBEDDED3DPRIMITIVE2D:
+ return "EMBEDDED3D";
+ case PRIMITIVE2D_ID_FILLGRAPHICPRIMITIVE2D:
+ return "FILLGRAPHIC";
+ case PRIMITIVE2D_ID_FILLGRADIENTPRIMITIVE2D:
+ return "FILLGRADIENT";
+ case PRIMITIVE2D_ID_FILLHATCHPRIMITIVE2D:
+ return "FILLHATCH";
+ case PRIMITIVE2D_ID_GRAPHICPRIMITIVE2D:
+ return "GRAPHIC";
+ case PRIMITIVE2D_ID_GRIDPRIMITIVE2D:
+ return "GRID";
+ case PRIMITIVE2D_ID_GROUPPRIMITIVE2D:
+ return "GROUP";
+ case PRIMITIVE2D_ID_HELPLINEPRIMITIVE2D:
+ return "HELPLINE";
+ case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D:
+ return "MARKERARRAY";
+ case PRIMITIVE2D_ID_MASKPRIMITIVE2D:
+ return "MASK";
+ case PRIMITIVE2D_ID_MEDIAPRIMITIVE2D:
+ return "MEDIA";
+ case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D:
+ return "METAFILE";
+ case PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D:
+ return "MODIFIEDCOLOR";
+ case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D:
+ return "POLYGONHAIRLINE";
+ case PRIMITIVE2D_ID_POLYGONMARKERPRIMITIVE2D:
+ return "POLYGONMARKER";
+ case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D:
+ return "POLYGONSTROKE";
+ case PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D:
+ return "POLYGONSTROKEARROW";
+ case PRIMITIVE2D_ID_POLYPOLYGONSTROKEPRIMITIVE2D:
+ return "POLYPOLYGONSTROKE";
+ case PRIMITIVE2D_ID_POLYPOLYGONSTROKEARROWPRIMITIVE2D:
+ return "POLYPOLYGONSTROKEARROW";
+ case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D:
+ return "POLYPOLYGONCOLOR";
+ case PRIMITIVE2D_ID_POLYPOLYGONGRADIENTPRIMITIVE2D:
+ return "POLYPOLYGONGRADIENT";
+ case PRIMITIVE2D_ID_POLYPOLYGONHATCHPRIMITIVE2D:
+ return "POLYPOLYGONHATCH";
+ case PRIMITIVE2D_ID_POLYPOLYGONGRAPHICPRIMITIVE2D:
+ return "POLYPOLYGONGRAPHIC";
+ case PRIMITIVE2D_ID_SCENEPRIMITIVE2D:
+ return "SCENE";
+ case PRIMITIVE2D_ID_SHADOWPRIMITIVE2D:
+ return "SHADOW";
+ case PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D:
+ return "TEXTSIMPLEPORTION";
+ case PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D:
+ return "TEXTDECORATEDPORTION";
+ case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D:
+ return "TRANSFORM";
+ case PRIMITIVE2D_ID_UNIFIEDTRANSPARENCEPRIMITIVE2D:
+ return "UNIFIEDTRANSPARENCE";
+ case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D:
+ return "POINTARRAY";
+ case PRIMITIVE2D_ID_TEXTHIERARCHYFIELDPRIMITIVE2D:
+ return "TEXTHIERARCHYFIELD";
+ case PRIMITIVE2D_ID_TEXTHIERARCHYLINEPRIMITIVE2D:
+ return "TEXTHIERARCHYLINE";
+ case PRIMITIVE2D_ID_TEXTHIERARCHYPARAGRAPHPRIMITIVE2D:
+ return "TEXTHIERARCHYPARAGRAPH";
+ case PRIMITIVE2D_ID_TEXTHIERARCHYBLOCKPRIMITIVE2D:
+ return "TEXTHIERARCHYBLOCK";
+ case PRIMITIVE2D_ID_TEXTHIERARCHYEDITPRIMITIVE2D:
+ return "TEXTHIERARCHYEDIT";
+ case PRIMITIVE2D_ID_POLYGONWAVEPRIMITIVE2D:
+ return "POLYGONWAVE";
+ case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D:
+ return "WRONGSPELL";
+ case PRIMITIVE2D_ID_TEXTEFFECTPRIMITIVE2D:
+ return "TEXTEFFECT";
+ case PRIMITIVE2D_ID_TEXTHIERARCHYBULLETPRIMITIVE2D:
+ return "TEXTHIERARCHYBULLET";
+ case PRIMITIVE2D_ID_POLYPOLYGONHAIRLINEPRIMITIVE2D:
+ return "POLYPOLYGONHAIRLINE";
+ case PRIMITIVE2D_ID_EXECUTEPRIMITIVE2D:
+ return "EXECUTE";
+ case PRIMITIVE2D_ID_PAGEPREVIEWPRIMITIVE2D:
+ return "PAGEPREVIEW";
+ case PRIMITIVE2D_ID_STRUCTURETAGPRIMITIVE2D:
+ return "STRUCTURETAG";
+ case PRIMITIVE2D_ID_BORDERLINEPRIMITIVE2D:
+ return "BORDERLINE";
+ case PRIMITIVE2D_ID_POLYPOLYGONMARKERPRIMITIVE2D:
+ return "POLYPOLYGONMARKER";
+ case PRIMITIVE2D_ID_HITTESTPRIMITIVE2D:
+ return "HITTEST";
+ case PRIMITIVE2D_ID_INVERTPRIMITIVE2D:
+ return "INVERT";
+ case PRIMITIVE2D_ID_DISCRETEBITMAPPRIMITIVE2D:
+ return "DISCRETEBITMAP";
+ case PRIMITIVE2D_ID_WALLPAPERBITMAPPRIMITIVE2D:
+ return "WALLPAPERBITMAP";
+ case PRIMITIVE2D_ID_TEXTLINEPRIMITIVE2D:
+ return "TEXTLINE";
+ case PRIMITIVE2D_ID_TEXTCHARACTERSTRIKEOUTPRIMITIVE2D:
+ return "TEXTCHARACTERSTRIKEOUT";
+ case PRIMITIVE2D_ID_TEXTGEOMETRYSTRIKEOUTPRIMITIVE2D:
+ return "TEXTGEOMETRYSTRIKEOUT";
+ case PRIMITIVE2D_ID_EPSPRIMITIVE2D:
+ return "EPS";
+ case PRIMITIVE2D_ID_DISCRETESHADOWPRIMITIVE2D:
+ return "DISCRETESHADOW";
+ case PRIMITIVE2D_ID_HIDDENGEOMETRYPRIMITIVE2D:
+ return "HIDDENGEOMETRY";
+ case PRIMITIVE2D_ID_SVGLINEARGRADIENTPRIMITIVE2D:
+ return "SVGLINEARGRADIENT";
+ case PRIMITIVE2D_ID_SVGRADIALGRADIENTPRIMITIVE2D:
+ return "SVGRADIALGRADIENT";
+ case PRIMITIVE2D_ID_SVGLINEARATOMPRIMITIVE2D:
+ return "SVGLINEARATOM";
+ case PRIMITIVE2D_ID_SVGRADIALATOMPRIMITIVE2D:
+ return "SVGRADIALATOM";
+ case PRIMITIVE2D_ID_CROPPRIMITIVE2D:
+ return "CROP";
+ case PRIMITIVE2D_ID_PATTERNFILLPRIMITIVE2D:
+ return "PATTERNFILL";
+ case PRIMITIVE2D_ID_OBJECTINFOPRIMITIVE2D:
+ return "OBJECTINFO";
+ case PRIMITIVE2D_ID_POLYPOLYGONSELECTIONPRIMITIVE2D:
+ return "POLYPOLYGONSELECTION";
+ case PRIMITIVE2D_ID_PAGEHIERARCHYPRIMITIVE2D:
+ return "PAGEHIERARCHY";
+ default:
+ return OUString::number((nId >> 16) & 0xFF) + "|" + OUString::number(nId & 0xFF);
+ }
+}
+} // end of namespace primitive2d
} // end of namespace drawinglayer
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/drawinglayer/primitive2d/baseprimitive2d.hxx b/include/drawinglayer/primitive2d/baseprimitive2d.hxx
index 0d0921850588..17b5d2f03a36 100644
--- a/include/drawinglayer/primitive2d/baseprimitive2d.hxx
+++ b/include/drawinglayer/primitive2d/baseprimitive2d.hxx
@@ -29,296 +29,334 @@
#include <basegfx/range/b2drange.hxx>
#include <deque>
-
/** defines for DeclPrimitive2DIDBlock and ImplPrimitive2DIDBlock
Added to be able to simply change identification stuff later, e.g. add
an identification string and/or ID to the interface and to the implementation
ATM used to delclare implement getPrimitive2DID()
*/
-#define DeclPrimitive2DIDBlock() \
- virtual sal_uInt32 getPrimitive2DID() const override;
+#define DeclPrimitive2DIDBlock() virtual sal_uInt32 getPrimitive2DID() const override;
-#define ImplPrimitive2DIDBlock(TheClass, TheID) \
+#define ImplPrimitive2DIDBlock(TheClass, TheID) \
sal_uInt32 TheClass::getPrimitive2DID() const { return TheID; }
-
// predefines
-namespace drawinglayer { namespace geometry {
- class ViewInformation2D;
-}}
-
-namespace drawinglayer { namespace primitive2d {
- /// typedefs for basePrimitive2DImplBase, Primitive2DSequence and Primitive2DReference
- typedef cppu::WeakComponentImplHelper<
- css::graphic::XPrimitive2D,
- css::util::XAccounting
- > BasePrimitive2DImplBase;
- typedef css::uno::Reference< css::graphic::XPrimitive2D > Primitive2DReference;
- typedef css::uno::Sequence< Primitive2DReference > Primitive2DSequence;
-
- class Primitive2DContainer;
- // Visitor class for walking a tree of Primitive2DReference in BasePrimitive2D::get2DDecomposition
- class DRAWINGLAYER_DLLPUBLIC Primitive2DDecompositionVisitor {
- public:
- virtual void append(const Primitive2DReference&) = 0;
- virtual void append(const Primitive2DContainer&) = 0;
- virtual void append(Primitive2DContainer&&) = 0;
- virtual ~Primitive2DDecompositionVisitor();
- };
-
- class SAL_WARN_UNUSED DRAWINGLAYER_DLLPUBLIC Primitive2DContainer : public std::deque< Primitive2DReference >,
- public Primitive2DDecompositionVisitor
- {
- public:
- explicit Primitive2DContainer() {}
- explicit Primitive2DContainer( size_type count ) : deque(count) {}
- virtual ~Primitive2DContainer() override;
- Primitive2DContainer( const Primitive2DContainer& other ) : deque(other) {}
- Primitive2DContainer( Primitive2DContainer&& other ) noexcept : deque(std::move(other)) {}
- Primitive2DContainer( const std::deque< Primitive2DReference >& other ) : deque(other) {}
- Primitive2DContainer( std::initializer_list<Primitive2DReference> init ) : deque(init) {}
- template <class Iter>
- Primitive2DContainer(Iter first, Iter last) : deque(first, last) {}
-
- virtual void append(const Primitive2DReference&) override;
- virtual void append(const Primitive2DContainer& rSource) override;
- virtual void append(Primitive2DContainer&& rSource) override;
- void append(const Primitive2DSequence& rSource);
- Primitive2DContainer& operator=(const Primitive2DContainer& r) { deque::operator=(r); return *this; }
- Primitive2DContainer& operator=(Primitive2DContainer&& r) noexcept { deque::operator=(std::move(r)); return *this; }
- bool operator==(const Primitive2DContainer& rB) const;
- bool operator!=(const Primitive2DContainer& rB) const { return !operator==(rB); }
- basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& aViewInformation) const;
- Primitive2DContainer maybeInvert(bool bInvert = false) const;
- };
-}}
-
-
-// basePrimitive2D class
+namespace drawinglayer
+{
+namespace geometry
+{
+class ViewInformation2D;
+}
+}
namespace drawinglayer
{
- namespace primitive2d
+namespace primitive2d
+{
+/// typedefs for basePrimitive2DImplBase, Primitive2DSequence and Primitive2DReference
+typedef cppu::WeakComponentImplHelper<css::graphic::XPrimitive2D, css::util::XAccounting>
+ BasePrimitive2DImplBase;
+typedef css::uno::Reference<css::graphic::XPrimitive2D> Primitive2DReference;
+typedef css::uno::Sequence<Primitive2DReference> Primitive2DSequence;
+
+class Primitive2DContainer;
+// Visitor class for walking a tree of Primitive2DReference in BasePrimitive2D::get2DDecomposition
+class DRAWINGLAYER_DLLPUBLIC Primitive2DDecompositionVisitor
+{
+public:
+ virtual void append(const Primitive2DReference&) = 0;
+ virtual void append(const Primitive2DContainer&) = 0;
+ virtual void append(Primitive2DContainer&&) = 0;
+ virtual ~Primitive2DDecompositionVisitor();
+};
+
+class SAL_WARN_UNUSED DRAWINGLAYER_DLLPUBLIC Primitive2DContainer
+ : public std::deque<Primitive2DReference>,
+ public Primitive2DDecompositionVisitor
+{
+public:
+ explicit Primitive2DContainer() {}
+ explicit Primitive2DContainer(size_type count)
+ : deque(count)
{
- /** BasePrimitive2D class
-
- Baseclass for all C++ implementations of css::graphic::XPrimitive2D
-
- This class is strongly virtual due to the lack of getPrimitiveID() implementation.
- This is by purpose, this base class shall not be incarnated and be used directly as
- a XPrimitive2D.
-
- It is noncopyable to make clear that a primitive is a read-only
- instance and copying or changing values is not intended. The idea is to hold all data
- needed for visualisation of this primitive in unchangeable form.
-
- It is derived from cppu::BaseMutex to have a Mutex at hand; in a base
- implementation this may not be needed, but e.g. when buffering at last decomposition
- in a local member, multiple threads may try to decompose at the same time, so locking
- is needed to avoid race conditions seen from the UNO object implementation.
-
- A method to get a simplified representation is provided by get2DDecomposition. The
- default implementation returns an empty sequence. The idea is that processors
- using this primitive and do not know it, may get the decomposition and process
- these instead. An example is e.g. a fat line, who's decomposition may contain
- the geometric representation of that line using filled polygon primitives. When
- the renderer knows how to handle fat lines, he may process this primitive directly;
- if not he can use the decomposition. With this functionality, renderers may operate by
- knowing only a small set of primitives.
-
- When a primitive does not implement get2DDecomposition, it is called a 'Basic Primitive' and
- belongs to the set of primitives which a processor should be able to handle. Practice
- will define this minimal sets of primitives. When defined and the concept is proved,
- unique UNO APIs may be defined/implemented for these set to allow more intense work
- with primitives using UNO.
-
- Current Basic 2D Primitives are:
-
- - BitmapPrimitive2D (bitmap data, evtl. with transparence)
- - PointArrayPrimitive2D (single points)
- - PolygonHairlinePrimitive2D (hairline curves/polygons)
- - PolyPolygonColorPrimitive2D (colored polygons)
-
- UPDATE: MetafilePrimitive2D (VCL Metafile) is taken off this list since
- it is implemented with the integration of CWS aw078 into DV300m69.
-
- All other implemented primitives have a defined decomposition and can thus be
- decomposed down to this small set.
-
- A renderer implementing support for this minimal set of primitives can completely
- render primitive-based visualisations. Of course, he also has to take states into account
- which are represented by GroupPrimitive2D derivations, see groupprimitive2d.hxx
-
- To support getting the geometric BoundRect, getB2DRange is used. The default
- implementation will use the get2DDecomposition result and merge a range from the
- entries. Thus, an implementation is only necessary for the Basic Primitives, but
- of course speedups are possible (and are used) by implementing the method at higher-level
- primitives.
-
- For primitive identification, getPrimitiveID is used currently in this implementations
- to allow a fast switch/case processing. This needs a unique identifier mechanism which
- currently uses defines (see drawinglayer_primitivetypes2d.hxx). For UNO primitive API
- it will be needed to add a unique descriptor (Name?) later to the API.
-
- This base implementation provides mappings from the methods from XPrimitive2D
- (getDecomposition/getRange) to the appropriate methods in the C++ implementations
- (get2DDecomposition/getB2DRange). The PropertyValue ViewParameters is converted to
- the appropriate C++ implementation class ViewInformation2D.
-
- This base class does not implement any buffering; e.g. buffering the decomposition
- and/or the range. These may be buffered anytime since the definition is that the primitive
- is read-only and thus unchangeable. This implies that the decomposition and/or getting
- the range will lead to the same result as last time, under the precondition that
- the parameter ViewInformation2D is the same as the last one. This is usually the case
- for view-independent primitives which are defined by not using ViewInformation2D
- in their get2DDecomposition/getB2DRange implementations.
- */
- class DRAWINGLAYER_DLLPUBLIC BasePrimitive2D
- : protected cppu::BaseMutex,
- public BasePrimitive2DImplBase
- {
- BasePrimitive2D(const BasePrimitive2D&) = delete;
- BasePrimitive2D& operator=( const BasePrimitive2D& ) = delete;
- public:
- // constructor/destructor
- BasePrimitive2D();
- virtual ~BasePrimitive2D() override;
-
- /** the ==operator is mainly needed to allow testing newly-created primitives against their last
- incarnation which buffers/holds the made decompositions. The default implementation
- uses getPrimitive2DID()-calls to test if it's the same ID at last.
- Overridden implementations are then based on this implementation
- */
- virtual bool operator==( const BasePrimitive2D& rPrimitive ) const;
- bool operator!=( const BasePrimitive2D& rPrimitive ) const { return !operator==(rPrimitive); }
-
- /// The default implementation will use getDecomposition results to create the range
- virtual 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.
- This method is normally defined using DeclPrimitive2DIDBlock()
- */
- virtual sal_uInt32 getPrimitive2DID() const = 0;
-
- /// The default implementation will return an empty sequence
- virtual 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
- */
- virtual css::uno::Sequence< ::css::uno::Reference< ::css::graphic::XPrimitive2D > > SAL_CALL getDecomposition( const css::uno::Sequence< css::beans::PropertyValue >& rViewParameters ) override;
+ }
+ virtual ~Primitive2DContainer() override;
+ Primitive2DContainer(const Primitive2DContainer& other)
+ : deque(other)
+ {
+ }
+ Primitive2DContainer(Primitive2DContainer&& other) noexcept
+ : deque(std::move(other))
+ {
+ }
+ Primitive2DContainer(const std::deque<Primitive2DReference>& other)
+ : deque(other)
+ {
+ }
+ Primitive2DContainer(std::initializer_list<Primitive2DReference> init)
+ : deque(init)
+ {
+ }
+ template <class Iter>
+ Primitive2DContainer(Iter first, Iter last)
+ : deque(first, last)
+ {
+ }
- /** 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 SAL_CALL getRange( const css::uno::Sequence< css::beans::PropertyValue >& rViewParameters ) override;
+ virtual void append(const Primitive2DReference&) override;
+ virtual void append(const Primitive2DContainer& rSource) override;
+ virtual void append(Primitive2DContainer&& rSource) override;
+ void append(const Primitive2DSequence& rSource);
+ Primitive2DContainer& operator=(const Primitive2DContainer& r)
+ {
+ deque::operator=(r);
+ return *this;
+ }
+ Primitive2DContainer& operator=(Primitive2DContainer&& r) noexcept
+ {
+ deque::operator=(std::move(r));
+ return *this;
+ }
+ bool operator==(const Primitive2DContainer& rB) const;
+ bool operator!=(const Primitive2DContainer& rB) const { return !operator==(rB); }
+ basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& aViewInformation) const;
+ Primitive2DContainer maybeInvert(bool bInvert = false) const;
+};
+}
+}
- // XAccounting
- virtual sal_Int64 SAL_CALL estimateUsage() override;
+// basePrimitive2D class
- };
- } // end of namespace primitive2d
+namespace drawinglayer
+{
+namespace primitive2d
+{
+/** BasePrimitive2D class
+
+ Baseclass for all C++ implementations of css::graphic::XPrimitive2D
+
+ This class is strongly virtual due to the lack of getPrimitiveID() implementation.
+ This is by purpose, this base class shall not be incarnated and be used directly as
+ a XPrimitive2D.
+
+ It is noncopyable to make clear that a primitive is a read-only
+ instance and copying or changing values is not intended. The idea is to hold all data
+ needed for visualisation of this primitive in unchangeable form.
+
+ It is derived from cppu::BaseMutex to have a Mutex at hand; in a base
+ implementation this may not be needed, but e.g. when buffering at last decomposition
+ in a local member, multiple threads may try to decompose at the same time, so locking
+ is needed to avoid race conditions seen from the UNO object implementation.
+
+ A method to get a simplified representation is provided by get2DDecomposition. The
+ default implementation returns an empty sequence. The idea is that processors
+ using this primitive and do not know it, may get the decomposition and process
+ these instead. An example is e.g. a fat line, who's decomposition may contain
+ the geometric representation of that line using filled polygon primitives. When
+ the renderer knows how to handle fat lines, he may process this primitive directly;
+ if not he can use the decomposition. With this functionality, renderers may operate by
+ knowing only a small set of primitives.
+
+ When a primitive does not implement get2DDecomposition, it is called a 'Basic Primitive' and
+ belongs to the set of primitives which a processor should be able to handle. Practice
+ will define this minimal sets of primitives. When defined and the concept is proved,
+ unique UNO APIs may be defined/implemented for these set to allow more intense work
+ with primitives using UNO.
+
+ Current Basic 2D Primitives are:
+
+ - BitmapPrimitive2D (bitmap data, evtl. with transparence)
+ - PointArrayPrimitive2D (single points)
+ - PolygonHairlinePrimitive2D (hairline curves/polygons)
+ - PolyPolygonColorPrimitive2D (colored polygons)
+
+ UPDATE: MetafilePrimitive2D (VCL Metafile) is taken off this list since
+ it is implemented with the integration of CWS aw078 into DV300m69.
+
+ All other implemented primitives have a defined decomposition and can thus be
+ decomposed down to this small set.
+
+ A renderer implementing support for this minimal set of primitives can completely
+ render primitive-based visualisations. Of course, he also has to take states into account
+ which are represented by GroupPrimitive2D derivations, see groupprimitive2d.hxx
+
+ To support getting the geometric BoundRect, getB2DRange is used. The default
+ implementation will use the get2DDecomposition result and merge a range from the
+ entries. Thus, an implementation is only necessary for the Basic Primitives, but
+ of course speedups are possible (and are used) by implementing the method at higher-level
+ primitives.
+
+ For primitive identification, getPrimitiveID is used currently in this implementations
+ to allow a fast switch/case processing. This needs a unique identifier mechanism which
+ currently uses defines (see drawinglayer_primitivetypes2d.hxx). For UNO primitive API
+ it will be needed to add a unique descriptor (Name?) later to the API.
+
+ This base implementation provides mappings from the methods from XPrimitive2D
+ (getDecomposition/getRange) to the appropriate methods in the C++ implementations
+ (get2DDecomposition/getB2DRange). The PropertyValue ViewParameters is converted to
+ the appropriate C++ implementation class ViewInformation2D.
+
+ This base class does not implement any buffering; e.g. buffering the decomposition
+ and/or the range. These may be buffered anytime since the definition is that the primitive
+ is read-only and thus unchangeable. This implies that the decomposition and/or getting
+ the range will lead to the same result as last time, under the precondition that
+ the parameter ViewInformation2D is the same as the last one. This is usually the case
+ for view-independent primitives which are defined by not using ViewInformation2D
+ in their get2DDecomposition/getB2DRange implementations.
+ */
+class DRAWINGLAYER_DLLPUBLIC BasePrimitive2D : protected cppu::BaseMutex,
+ public BasePrimitive2DImplBase
+{
+ BasePrimitive2D(const BasePrimitive2D&) = delete;
+ BasePrimitive2D& operator=(const BasePrimitive2D&) = delete;
+
+public:
+ // constructor/destructor
+ BasePrimitive2D();
+ virtual ~BasePrimitive2D() override;
+
+ /** the ==operator is mainly needed to allow testing newly-created primitives against their last
+ incarnation which buffers/holds the made decompositions. The default implementation
+ uses getPrimitive2DID()-calls to test if it's the same ID at last.
+ Overridden implementations are then based on this implementation
+ */
+ virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
+ bool operator!=(const BasePrimitive2D& rPrimitive) const { return !operator==(rPrimitive); }
+
+ /// The default implementation will use getDecomposition results to create the range
+ virtual 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.
+ This method is normally defined using DeclPrimitive2DIDBlock()
+ */
+ virtual sal_uInt32 getPrimitive2DID() const = 0;
+
+ /// The default implementation will return an empty sequence
+ virtual 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
+ */
+ virtual css::uno::Sequence<::css::uno::Reference<::css::graphic::XPrimitive2D>> SAL_CALL
+ getDecomposition(const css::uno::Sequence<css::beans::PropertyValue>& rViewParameters) override;
+
+ /** 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 SAL_CALL
+ getRange(const css::uno::Sequence<css::beans::PropertyValue>& rViewParameters) override;
+
+ // XAccounting
+ virtual sal_Int64 SAL_CALL estimateUsage() override;
+};
+} // end of namespace primitive2d
} // end of namespace drawinglayer
-
// BufferedDecompositionPrimitive2D class
namespace drawinglayer
{
- namespace primitive2d
+namespace primitive2d
+{
+/** BufferedDecompositionPrimitive2D class
+
+ Baseclass for all C++ implementations of css::graphic::XPrimitive2D
+ which want to buffer the decomposition result
+
+ Buffering the decomposition is the most-used buffering and is thus used my most
+ primitive implementations which support a decomposition as base class.
+
+ The buffering is done by holding the last decomposition in the local parameter
+ maBuffered2DDecomposition. The default implementation of get2DDecomposition checks
+ if maBuffered2DDecomposition is empty. If yes, it uses create2DDecomposition
+ to create the content. In all cases, maBuffered2DDecomposition is returned.
+
+ For view-dependent primitives derived from Primitive2DBufferDecomposition more needs
+ to be done when the decomposition depends on parts of the parameter ViewInformation2D.
+ This defines a standard method for processing these:
+
+ Implement a view-dependent get2DDecomposition doing the following steps:
+ (a) Locally extract needed parameters from ViewInformation2D to new, local parameters
+ (this may be a complete local copy of ViewInformation2D)
+ (b) If a buffered decomposition exists, ckeck if one of the new local parameters
+ differs from the corresponding locally remembered (as member) ones. If yes,
+ clear maBuffered2DDecomposition
+ (d) call baseclass::get2DDecomposition which will use create2DDecomposition
+ to fill maBuffered2DDecomposition if it's empty
+ (e) copy the new local parameters to the corresponding locally remembered ones
+ to identify if a new decomposition is needed at the next call
+ (f) return maBuffered2DDecomposition
+ */
+class DRAWINGLAYER_DLLPUBLIC BufferedDecompositionPrimitive2D : public BasePrimitive2D
+{
+private:
+ /// a sequence used for buffering the last create2DDecomposition() result
+ Primitive2DContainer maBuffered2DDecomposition;
+
+protected:
+ /** access methods to maBuffered2DDecomposition. The usage of this methods may allow
+ later thread-safe stuff to be added if needed. Only to be used by getDecomposition()
+ implementations for buffering the last decomposition.
+ */
+ const Primitive2DContainer& getBuffered2DDecomposition() const
{
- /** BufferedDecompositionPrimitive2D class
-
- Baseclass for all C++ implementations of css::graphic::XPrimitive2D
- which want to buffer the decomposition result
-
- Buffering the decomposition is the most-used buffering and is thus used my most
- primitive implementations which support a decomposition as base class.
-
- The buffering is done by holding the last decomposition in the local parameter
- maBuffered2DDecomposition. The default implementation of get2DDecomposition checks
- if maBuffered2DDecomposition is empty. If yes, it uses create2DDecomposition
- to create the content. In all cases, maBuffered2DDecomposition is returned.
-
- For view-dependent primitives derived from Primitive2DBufferDecomposition more needs
- to be done when the decomposition depends on parts of the parameter ViewInformation2D.
- This defines a standard method for processing these:
-
- Implement a view-dependent get2DDecomposition doing the following steps:
- (a) Locally extract needed parameters from ViewInformation2D to new, local parameters
- (this may be a complete local copy of ViewInformation2D)
- (b) If a buffered decomposition exists, ckeck if one of the new local parameters
- differs from the corresponding locally remembered (as member) ones. If yes,
- clear maBuffered2DDecomposition
- (d) call baseclass::get2DDecomposition which will use create2DDecomposition
- to fill maBuffered2DDecomposition if it's empty
- (e) copy the new local parameters to the corresponding locally remembered ones
- to identify if a new decomposition is needed at the next call
- (f) return maBuffered2DDecomposition
- */
- class DRAWINGLAYER_DLLPUBLIC BufferedDecompositionPrimitive2D
- : public BasePrimitive2D
- {
- private:
- /// a sequence used for buffering the last create2DDecomposition() result
- Primitive2DContainer maBuffered2DDecomposition;
-
- protected:
- /** access methods to maBuffered2DDecomposition. The usage of this methods may allow
- later thread-safe stuff to be added if needed. Only to be used by getDecomposition()
- implementations for buffering the last decomposition.
- */
- const Primitive2DContainer& getBuffered2DDecomposition() const { return maBuffered2DDecomposition; }
- void setBuffered2DDecomposition(const Primitive2DContainer& rNew) { maBuffered2DDecomposition = rNew; }
+ return maBuffered2DDecomposition;
+ }
+ void setBuffered2DDecomposition(const Primitive2DContainer& rNew)
+ {
+ maBuffered2DDecomposition = rNew;
+ }
- /** method which is to be used to implement the local decomposition of a 2D primitive. The default
+ /** method which is to be used to implement the local decomposition of a 2D primitive. The default
implementation will just return an empty decomposition
*/
- virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const;
-
- public:
- // constructor/destructor
- BufferedDecompositionPrimitive2D();
-
- /** The getDecomposition default implementation will on demand use create2DDecomposition() if
- maBuffered2DDecomposition is empty. It will set maBuffered2DDecomposition to this obtained decomposition
- to buffer it. If the decomposition is also ViewInformation2D-dependent, this method needs to be
- overridden and the ViewInformation2D for the last decomposition need to be remembered, too, and
- be used in the next call to decide if the buffered decomposition may be reused or not.
- */
- virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override;
- };
- } // end of namespace primitive2d
+ virtual void create2DDecomposition(Primitive2DContainer& rContainer,
+ const geometry::ViewInformation2D& rViewInformation) const;
+
+public:
+ // constructor/destructor
+ BufferedDecompositionPrimitive2D();
+
+ /** The getDecomposition default implementation will on demand use create2DDecomposition() if
+ maBuffered2DDecomposition is empty. It will set maBuffered2DDecomposition to this obtained decomposition
+ to buffer it. If the decomposition is also ViewInformation2D-dependent, this method needs to be
+ overridden and the ViewInformation2D for the last decomposition need to be remembered, too, and
+ be used in the next call to decide if the buffered decomposition may be reused or not.
+ */
+ virtual void
+ get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor,
+ const geometry::ViewInformation2D& rViewInformation) const override;
+};
+} // end of namespace primitive2d
} // end of namespace drawinglayer
-
// tooling
namespace drawinglayer
{
- namespace primitive2d
- {
- /// get B2DRange from a given Primitive2DReference
- basegfx::B2DRange DRAWINGLAYER_DLLPUBLIC getB2DRangeFromPrimitive2DReference(const Primitive2DReference& rCandidate, const geometry::ViewInformation2D& aViewInformation);
+namespace primitive2d
+{
+/// get B2DRange from a given Primitive2DReference
+basegfx::B2DRange DRAWINGLAYER_DLLPUBLIC getB2DRangeFromPrimitive2DReference(
+ const Primitive2DReference& rCandidate, const geometry::ViewInformation2D& aViewInformation);
- /** compare two Primitive2DReferences for equality, including trying to get implementations (BasePrimitive2D)
- and using compare operator
- */
- bool DRAWINGLAYER_DLLPUBLIC arePrimitive2DReferencesEqual(const Primitive2DReference& rA, const Primitive2DReference& rB);
+/** compare two Primitive2DReferences for equality, including trying to get implementations (BasePrimitive2D)
+ and using compare operator
+ */
+bool DRAWINGLAYER_DLLPUBLIC arePrimitive2DReferencesEqual(const Primitive2DReference& rA,
+ const Primitive2DReference& rB);
- OUString DRAWINGLAYER_DLLPUBLIC idToString(sal_uInt32 nId);
+OUString DRAWINGLAYER_DLLPUBLIC idToString(sal_uInt32 nId);
- } // end of namespace primitive2d
+} // end of namespace primitive2d
} // end of namespace drawinglayer
-
#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_BASEPRIMITIVE2D_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index f3334412c16d..84500af7c2ef 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -3758,7 +3758,6 @@ drawinglayer/source/geometry/viewinformation2d.cxx
drawinglayer/source/geometry/viewinformation3d.cxx
drawinglayer/source/primitive2d/animatedprimitive2d.cxx
drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx
-drawinglayer/source/primitive2d/baseprimitive2d.cxx
drawinglayer/source/primitive2d/bitmapprimitive2d.cxx
drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
drawinglayer/source/primitive2d/controlprimitive2d.cxx
@@ -6067,7 +6066,6 @@ include/drawinglayer/geometry/viewinformation2d.hxx
include/drawinglayer/geometry/viewinformation3d.hxx
include/drawinglayer/primitive2d/animatedprimitive2d.hxx
include/drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx
-include/drawinglayer/primitive2d/baseprimitive2d.hxx
include/drawinglayer/primitive2d/bitmapprimitive2d.hxx
include/drawinglayer/primitive2d/borderlineprimitive2d.hxx
include/drawinglayer/primitive2d/controlprimitive2d.hxx