summaryrefslogtreecommitdiff
path: root/drawinglayer
diff options
context:
space:
mode:
authorArmin Weiss <aw@openoffice.org>2007-02-22 11:11:10 +0000
committerArmin Weiss <aw@openoffice.org>2007-02-22 11:11:10 +0000
commit8d83746f9f90b04f7e31dc931adc69cb0ce631da (patch)
tree6a0b0b8297fdd894b35392798b2a4edce2a8fbd1 /drawinglayer
parent345f244a3d2f78395a3dbe19db4111896cb384c7 (diff)
added stroke PolyPolygon and arrow PolyPolygon primitives as syntactical sugar. Decompositions are straightforward.
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx90
-rw-r--r--drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx162
2 files changed, 248 insertions, 4 deletions
diff --git a/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx
index 014816b23a94..960385b4b485 100644
--- a/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx
+++ b/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx
@@ -4,9 +4,9 @@
*
* $RCSfile: polypolygonprimitive2d.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: aw $ $Date: 2006-11-07 15:49:05 $
+ * last change: $Author: aw $ $Date: 2007-02-22 12:10:56 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -52,6 +52,92 @@
#include <basegfx/polygon/b2dpolypolygon.hxx>
#endif
+#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_STROKEATTRIBUTE_HXX
+#include <drawinglayer/attribute/strokeattribute.hxx>
+#endif
+
+#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_STROKEARROWATTRIBUTE_HXX
+#include <drawinglayer/attribute/strokearrowattribute.hxx>
+#endif
+
+//////////////////////////////////////////////////////////////////////////////
+// PolyPolygonStrokePrimitive2D class
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ class PolyPolygonStrokePrimitive2D : public BasePrimitive2D
+ {
+ private:
+ basegfx::B2DPolyPolygon maPolyPolygon;
+ attribute::StrokeAttribute maStrokeAttribute;
+
+ protected:
+ // local decomposition.
+ virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
+
+ public:
+ PolyPolygonStrokePrimitive2D(
+ const basegfx::B2DPolyPolygon& rPolyPolygon,
+ const attribute::StrokeAttribute& rStrokeAttribute);
+
+ // get data
+ basegfx::B2DPolyPolygon getB2DPolyPolygon() const { return maPolyPolygon; }
+ const attribute::StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; }
+
+ // compare operator
+ virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
+
+ // get range
+ virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
+
+ // provide unique ID
+ DeclPrimitrive2DIDBlock()
+ };
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// PolyPolygonStrokeArrowPrimitive2D class
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ class PolyPolygonStrokeArrowPrimitive2D : public PolyPolygonStrokePrimitive2D
+ {
+ private:
+ attribute::StrokeArrowAttribute maStart;
+ attribute::StrokeArrowAttribute maEnd;
+
+ protected:
+ // local decomposition.
+ virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
+
+ public:
+ PolyPolygonStrokeArrowPrimitive2D(
+ const basegfx::B2DPolyPolygon& rPolyPolygon,
+ const attribute::StrokeAttribute& rStrokeAttribute,
+ const attribute::StrokeArrowAttribute& rStart,
+ const attribute::StrokeArrowAttribute& rEnd);
+
+ // get data
+ const attribute::StrokeArrowAttribute& getStart() const { return maStart; }
+ const attribute::StrokeArrowAttribute& getEnd() const { return maEnd; }
+
+ // compare operator
+ virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
+
+ // get range
+ virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
+
+ // provide unique ID
+ DeclPrimitrive2DIDBlock()
+ };
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
//////////////////////////////////////////////////////////////////////////////
// PolyPolygonColorPrimitive2D class
diff --git a/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx b/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx
index 52054afef68b..1a9f1ab5cee4 100644
--- a/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: polypolygonprimitive2d.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: aw $ $Date: 2006-11-07 15:49:09 $
+ * last change: $Author: aw $ $Date: 2007-02-22 12:11:10 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -65,6 +65,10 @@
#include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx>
#endif
+#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYGONPRIMITIVE2D_HXX
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#endif
+
//////////////////////////////////////////////////////////////////////////////
using namespace com::sun::star;
@@ -75,6 +79,160 @@ namespace drawinglayer
{
namespace primitive2d
{
+ Primitive2DSequence PolyPolygonStrokePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
+ {
+ const basegfx::B2DPolyPolygon aPolyPolygon(getB2DPolyPolygon());
+ const sal_uInt32 nCount(aPolyPolygon.count());
+
+ if(nCount)
+ {
+ Primitive2DSequence aRetval(nCount);
+
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ aRetval[a] = Primitive2DReference(new PolygonStrokePrimitive2D(aPolyPolygon.getB2DPolygon(a), getStrokeAttribute()));
+ }
+
+ return aRetval;
+ }
+ else
+ {
+ return Primitive2DSequence();
+ }
+ }
+
+ PolyPolygonStrokePrimitive2D::PolyPolygonStrokePrimitive2D(
+ const basegfx::B2DPolyPolygon& rPolyPolygon,
+ const attribute::StrokeAttribute& rStrokeAttribute)
+ : BasePrimitive2D(),
+ maPolyPolygon(rPolyPolygon),
+ maStrokeAttribute(rStrokeAttribute)
+ {
+ }
+
+ bool PolyPolygonStrokePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BasePrimitive2D::operator==(rPrimitive))
+ {
+ const PolyPolygonStrokePrimitive2D& rCompare = (PolyPolygonStrokePrimitive2D&)rPrimitive;
+
+ return (getB2DPolyPolygon() == rCompare.getB2DPolyPolygon()
+ && getStrokeAttribute() == rCompare.getStrokeAttribute());
+ }
+
+ return false;
+ }
+
+ basegfx::B2DRange PolyPolygonStrokePrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const
+ {
+ // get range of it (subdivided)
+ basegfx::B2DRange aRetval(basegfx::tools::getRange(basegfx::tools::adaptiveSubdivideByAngle(getB2DPolyPolygon())));
+
+ // if width, grow by line width
+ if(getStrokeAttribute().getWidth())
+ {
+ aRetval.grow(getStrokeAttribute().getWidth() / 2.0);
+ }
+
+ return aRetval;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(PolyPolygonStrokePrimitive2D, '2','P','P','s')
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence PolyPolygonStrokeArrowPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
+ {
+ const basegfx::B2DPolyPolygon aPolyPolygon(getB2DPolyPolygon());
+ const sal_uInt32 nCount(aPolyPolygon.count());
+
+ if(nCount)
+ {
+ Primitive2DSequence aRetval(nCount);
+
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ const basegfx::B2DPolygon aPolygon(aPolyPolygon.getB2DPolygon(a));
+
+ if(aPolygon.isClosed())
+ {
+ // no need for PolygonStrokeArrowPrimitive2D when polygon is closed
+ aRetval[a] = Primitive2DReference(new PolygonStrokePrimitive2D(aPolygon, getStrokeAttribute()));
+ }
+ else
+ {
+ aRetval[a] = Primitive2DReference(new PolygonStrokeArrowPrimitive2D(aPolygon, getStrokeAttribute(), getStart(), getEnd()));
+ }
+ }
+
+ return aRetval;
+ }
+ else
+ {
+ return Primitive2DSequence();
+ }
+ }
+
+ PolyPolygonStrokeArrowPrimitive2D::PolyPolygonStrokeArrowPrimitive2D(
+ const basegfx::B2DPolyPolygon& rPolyPolygon,
+ const attribute::StrokeAttribute& rStrokeAttribute,
+ const attribute::StrokeArrowAttribute& rStart,
+ const attribute::StrokeArrowAttribute& rEnd)
+ : PolyPolygonStrokePrimitive2D(rPolyPolygon, rStrokeAttribute),
+ maStart(rStart),
+ maEnd(rEnd)
+ {
+ }
+
+ bool PolyPolygonStrokeArrowPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(PolyPolygonStrokePrimitive2D::operator==(rPrimitive))
+ {
+ const PolyPolygonStrokeArrowPrimitive2D& rCompare = (PolyPolygonStrokeArrowPrimitive2D&)rPrimitive;
+
+ return (getStart() == rCompare.getStart()
+ && getEnd() == rCompare.getEnd());
+ }
+
+ return false;
+ }
+
+ basegfx::B2DRange PolyPolygonStrokeArrowPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const
+ {
+ basegfx::B2DRange aRetval;
+
+ if(getStart().isActive() || getEnd().isActive())
+ {
+ // use decomposition when line start/end is used
+ return BasePrimitive2D::getB2DRange(rViewInformation);
+ }
+ else
+ {
+ // get range from parent
+ return PolyPolygonStrokePrimitive2D::getB2DRange(rViewInformation);
+ }
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(PolyPolygonStrokeArrowPrimitive2D, '2','P','P','A')
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
PolyPolygonColorPrimitive2D::PolyPolygonColorPrimitive2D(
const basegfx::B2DPolyPolygon& rPolyPolygon,
const basegfx::BColor& rBColor)