summaryrefslogtreecommitdiff
path: root/svx/source/sdr/primitive2d
diff options
context:
space:
mode:
Diffstat (limited to 'svx/source/sdr/primitive2d')
-rw-r--r--svx/source/sdr/primitive2d/makefile.mk57
-rw-r--r--svx/source/sdr/primitive2d/primitivefactory2d.cxx132
-rw-r--r--svx/source/sdr/primitive2d/sdrattributecreator.cxx1028
-rw-r--r--svx/source/sdr/primitive2d/sdrcaptionprimitive2d.cxx177
-rw-r--r--svx/source/sdr/primitive2d/sdrconnectorprimitive2d.cxx124
-rw-r--r--svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx130
-rw-r--r--svx/source/sdr/primitive2d/sdrdecompositiontools.cxx486
-rw-r--r--svx/source/sdr/primitive2d/sdrellipseprimitive2d.cxx278
-rw-r--r--svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx177
-rw-r--r--svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx510
-rw-r--r--svx/source/sdr/primitive2d/sdrole2primitive2d.cxx190
-rw-r--r--svx/source/sdr/primitive2d/sdrolecontentprimitive2d.cxx201
-rw-r--r--svx/source/sdr/primitive2d/sdrpathprimitive2d.cxx147
-rw-r--r--svx/source/sdr/primitive2d/sdrprimitivetools.cxx176
-rw-r--r--svx/source/sdr/primitive2d/sdrrectangleprimitive2d.cxx162
-rw-r--r--svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx497
16 files changed, 4472 insertions, 0 deletions
diff --git a/svx/source/sdr/primitive2d/makefile.mk b/svx/source/sdr/primitive2d/makefile.mk
new file mode 100644
index 000000000000..078bc4bc977e
--- /dev/null
+++ b/svx/source/sdr/primitive2d/makefile.mk
@@ -0,0 +1,57 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=svx
+TARGET=primitive2d
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=\
+ $(SLO)$/primitivefactory2d.obj \
+ $(SLO)$/sdrdecompositiontools.obj \
+ $(SLO)$/sdrattributecreator.obj \
+ $(SLO)$/sdrellipseprimitive2d.obj \
+ $(SLO)$/sdrrectangleprimitive2d.obj \
+ $(SLO)$/sdrcustomshapeprimitive2d.obj \
+ $(SLO)$/sdrcaptionprimitive2d.obj \
+ $(SLO)$/sdrgrafprimitive2d.obj \
+ $(SLO)$/sdrole2primitive2d.obj \
+ $(SLO)$/sdrolecontentprimitive2d.obj \
+ $(SLO)$/sdrpathprimitive2d.obj \
+ $(SLO)$/sdrprimitivetools.obj \
+ $(SLO)$/sdrmeasureprimitive2d.obj \
+ $(SLO)$/sdrconnectorprimitive2d.obj \
+ $(SLO)$/sdrtextprimitive2d.obj
+
+.INCLUDE : target.mk
diff --git a/svx/source/sdr/primitive2d/primitivefactory2d.cxx b/svx/source/sdr/primitive2d/primitivefactory2d.cxx
new file mode 100644
index 000000000000..d6a6867b819e
--- /dev/null
+++ b/svx/source/sdr/primitive2d/primitivefactory2d.cxx
@@ -0,0 +1,132 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/primitiveFactory2d.hxx>
+#include <drawinglayer/primitive2d/baseprimitive2d.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdpage.hxx>
+#include <unoapi.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+// UNO API helper methods
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ uno::Reference< uno::XInterface > SAL_CALL XPrimitiveFactory2DProvider_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory >& /*rSMgr*/) throw( uno::Exception )
+ {
+ return *(new PrimitiveFactory2D());
+ }
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// UNO API helper methods
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ PrimitiveFactory2D::PrimitiveFactory2D()
+ : PrimitiveFactory2DImplBase(m_aMutex)
+ {
+ }
+
+ Primitive2DSequence SAL_CALL PrimitiveFactory2D::createPrimitivesFromXShape(
+ const uno::Reference< drawing::XShape >& xShape,
+ const uno::Sequence< beans::PropertyValue >& /*aParms*/ ) throw (uno::RuntimeException)
+ {
+ Primitive2DSequence aRetval;
+
+ if(xShape.is())
+ {
+ SdrObject* pSource = GetSdrObjectFromXShape(xShape);
+
+ if(pSource)
+ {
+ const sdr::contact::ViewContact& rSource(pSource->GetViewContact());
+ aRetval = rSource.getViewIndependentPrimitive2DSequence();
+ }
+ }
+
+ return aRetval;
+ }
+
+ Primitive2DSequence SAL_CALL PrimitiveFactory2D::createPrimitivesFromXDrawPage(
+ const uno::Reference< drawing::XDrawPage >& xDrawPage,
+ const uno::Sequence< beans::PropertyValue >& /*aParms*/ ) throw (uno::RuntimeException)
+ {
+ Primitive2DSequence aRetval;
+
+ if(xDrawPage.is())
+ {
+ SdrPage* pSource = GetSdrPageFromXDrawPage(xDrawPage);
+
+ if(pSource)
+ {
+ const sdr::contact::ViewContact& rSource(pSource->GetViewContact());
+
+ aRetval = rSource.getViewIndependentPrimitive2DSequence();
+ }
+ }
+
+ return aRetval;
+ }
+
+ rtl::OUString PrimitiveFactory2D::getImplementationName_Static()
+ {
+ static rtl::OUString aRetval(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.graphic.PrimitiveFactory2D"));
+ return aRetval;
+ }
+
+ uno::Sequence< rtl::OUString > PrimitiveFactory2D::getSupportedServiceNames_Static()
+ {
+ static uno::Sequence< rtl::OUString > aSeq;
+ osl::Mutex aMutex;
+ osl::MutexGuard aGuard( aMutex );
+
+ if(!aSeq.getLength())
+ {
+ aSeq.realloc(1L);
+ aSeq.getArray()[0L] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.graphic.PrimitiveFactory2D"));
+ }
+
+ return aSeq;
+ }
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
diff --git a/svx/source/sdr/primitive2d/sdrattributecreator.cxx b/svx/source/sdr/primitive2d/sdrattributecreator.cxx
new file mode 100644
index 000000000000..4ff335a04125
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrattributecreator.cxx
@@ -0,0 +1,1028 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <svl/itemset.hxx>
+#include <svx/xdef.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <svx/xlineit0.hxx>
+#include <svx/xfillit0.hxx>
+#include <svx/xlntrit.hxx>
+#include <svx/xlnwtit.hxx>
+#include <svx/xlinjoit.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xlnstwit.hxx>
+#include <svx/xlnedwit.hxx>
+#include <svx/xlnstit.hxx>
+#include <svx/xlnstcit.hxx>
+#include <svx/xlnedit.hxx>
+#include <svx/xlnedcit.hxx>
+#include <svx/xdash.hxx>
+#include <svx/xlndsit.hxx>
+#include <svx/xfltrit.hxx>
+#include <svx/xflftrit.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/xgrscit.hxx>
+#include <svx/xflhtit.hxx>
+#include <svx/xflbckit.hxx>
+#include <svx/sdshitm.hxx>
+#include <svx/sdsxyitm.hxx>
+#include <svx/sdshcitm.hxx>
+#include <svx/sdshtitm.hxx>
+#include <drawinglayer/attribute/sdrfillbitmapattribute.hxx>
+#include <basegfx/polygon/b2dlinegeometry.hxx>
+#include <svx/svdotext.hxx>
+#include <drawinglayer/attribute/fillbitmapattribute.hxx>
+#include <svx/sdr/attribute/sdrtextattribute.hxx>
+#include <svx/xbtmpit.hxx>
+#include <svl/itempool.hxx>
+#include <vcl/svapp.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <svx/svx3ditems.hxx>
+#include <com/sun/star/drawing/ProjectionMode.hpp>
+#include <com/sun/star/drawing/ShadeMode.hpp>
+#include <drawinglayer/attribute/sdrallattribute3d.hxx>
+#include <svx/rectenum.hxx>
+#include <svx/sdtfchim.hxx>
+#include <svx/svdoutl.hxx>
+#include <svx/svdmodel.hxx>
+#include <editeng/editstat.hxx>
+#include <drawinglayer/attribute/fillhatchattribute.hxx>
+#include <drawinglayer/attribute/fillgradientattribute.hxx>
+#include <svx/sdr/attribute/sdrshadowtextattribute.hxx>
+#include <svx/sdr/attribute/sdrlineshadowtextattribute.hxx>
+#include <svx/sdr/attribute/sdrformtextattribute.hxx>
+#include <svx/sdr/attribute/sdrlinefillshadowtextattribute.hxx>
+#include <drawinglayer/attribute/sdrsceneattribute3d.hxx>
+#include <drawinglayer/attribute/sdrlightingattribute3d.hxx>
+#include <drawinglayer/attribute/sdrlightattribute3d.hxx>
+#include <svx/sdr/attribute/sdrfilltextattribute.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace
+ {
+ attribute::GradientStyle XGradientStyleToGradientStyle(XGradientStyle eStyle)
+ {
+ switch(eStyle)
+ {
+ case XGRAD_LINEAR :
+ {
+ return attribute::GRADIENTSTYLE_LINEAR;
+ }
+ case XGRAD_AXIAL :
+ {
+ return attribute::GRADIENTSTYLE_AXIAL;
+ }
+ case XGRAD_RADIAL :
+ {
+ return attribute::GRADIENTSTYLE_RADIAL;
+ }
+ case XGRAD_ELLIPTICAL :
+ {
+ return attribute::GRADIENTSTYLE_ELLIPTICAL;
+ }
+ case XGRAD_SQUARE :
+ {
+ return attribute::GRADIENTSTYLE_SQUARE;
+ }
+ default :
+ {
+ return attribute::GRADIENTSTYLE_RECT; // XGRAD_RECT
+ }
+ }
+ }
+
+ attribute::HatchStyle XHatchStyleToHatchStyle(XHatchStyle eStyle)
+ {
+ switch(eStyle)
+ {
+ case XHATCH_SINGLE :
+ {
+ return attribute::HATCHSTYLE_SINGLE;
+ }
+ case XHATCH_DOUBLE :
+ {
+ return attribute::HATCHSTYLE_DOUBLE;
+ }
+ default :
+ {
+ return attribute::HATCHSTYLE_TRIPLE; // XHATCH_TRIPLE
+ }
+ }
+ }
+
+ basegfx::B2DLineJoin XLineJointtoB2DLineJoin(XLineJoint eLineJoint)
+ {
+ switch(eLineJoint)
+ {
+ case XLINEJOINT_MIDDLE :
+ {
+ return basegfx::B2DLINEJOIN_MIDDLE;
+ }
+ case XLINEJOINT_BEVEL :
+ {
+ return basegfx::B2DLINEJOIN_BEVEL;
+ }
+ case XLINEJOINT_MITER :
+ {
+ return basegfx::B2DLINEJOIN_MITER;
+ }
+ case XLINEJOINT_ROUND :
+ {
+ return basegfx::B2DLINEJOIN_ROUND;
+ }
+ default :
+ {
+ return basegfx::B2DLINEJOIN_NONE; // XLINEJOINT_NONE
+ }
+ }
+ }
+
+ basegfx::B2DVector RectPointToB2DVector(RECT_POINT eRectPoint)
+ {
+ basegfx::B2DVector aRetval(0.0, 0.0);
+
+ // position changes X
+ switch(eRectPoint)
+ {
+ case RP_LT: case RP_LM: case RP_LB:
+ {
+ aRetval.setX(-1.0);
+ break;
+ }
+
+ case RP_RT: case RP_RM: case RP_RB:
+ {
+ aRetval.setX(1.0);
+ break;
+ }
+
+ default :
+ {
+ break;
+ }
+ }
+
+ // position changes Y
+ switch(eRectPoint)
+ {
+ case RP_LT: case RP_MT: case RP_RT:
+ {
+ aRetval.setY(-1.0);
+ break;
+ }
+
+ case RP_LB: case RP_MB: case RP_RB:
+ {
+ aRetval.setY(1.0);
+ break;
+ }
+
+ default :
+ {
+ break;
+ }
+ }
+
+ return aRetval;
+ }
+ } // end of anonymous namespace
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ attribute::SdrLineAttribute createNewSdrLineAttribute(const SfxItemSet& rSet)
+ {
+ const XLineStyle eStyle(((XLineStyleItem&)(rSet.Get(XATTR_LINESTYLE))).GetValue());
+
+ if(XLINE_NONE != eStyle)
+ {
+ sal_uInt16 nTransparence(((const XLineTransparenceItem&)(rSet.Get(XATTR_LINETRANSPARENCE))).GetValue());
+
+ if(nTransparence > 100)
+ {
+ nTransparence = 100;
+ }
+
+ if(100 != nTransparence)
+ {
+ const sal_uInt32 nWidth(((const XLineWidthItem&)(rSet.Get(XATTR_LINEWIDTH))).GetValue());
+ const Color aColor(((const XLineColorItem&)(rSet.Get(XATTR_LINECOLOR))).GetColorValue());
+ const XLineJoint eJoint(((const XLineJointItem&)(rSet.Get(XATTR_LINEJOINT))).GetValue());
+ ::std::vector< double > aDotDashArray;
+ double fFullDotDashLen(0.0);
+
+ if(XLINE_DASH == eStyle)
+ {
+ const XDash& rDash = ((const XLineDashItem&)(rSet.Get(XATTR_LINEDASH))).GetDashValue();
+
+ if(rDash.GetDots() || rDash.GetDashes())
+ {
+ fFullDotDashLen = rDash.CreateDotDashArray(aDotDashArray, (double)nWidth);
+ }
+ }
+
+ return attribute::SdrLineAttribute(
+ XLineJointtoB2DLineJoin(eJoint),
+ (double)nWidth,
+ (double)nTransparence * 0.01,
+ aColor.getBColor(),
+ aDotDashArray,
+ fFullDotDashLen);
+ }
+ }
+
+ return attribute::SdrLineAttribute();
+ }
+
+ attribute::SdrLineStartEndAttribute createNewSdrLineStartEndAttribute(
+ const SfxItemSet& rSet,
+ double fWidth)
+ {
+ const sal_Int32 nTempStartWidth(((const XLineStartWidthItem&)(rSet.Get(XATTR_LINESTARTWIDTH))).GetValue());
+ const sal_Int32 nTempEndWidth(((const XLineEndWidthItem&)(rSet.Get(XATTR_LINEENDWIDTH))).GetValue());
+ basegfx::B2DPolyPolygon aStartPolyPolygon;
+ basegfx::B2DPolyPolygon aEndPolyPolygon;
+ double fStartWidth(0.0);
+ double fEndWidth(0.0);
+ bool bStartActive(false);
+ bool bEndActive(false);
+ bool bStartCentered(true);
+ bool bEndCentered(true);
+
+ if(nTempStartWidth)
+ {
+ if(nTempStartWidth < 0L)
+ {
+ fStartWidth = ((double)(-nTempStartWidth) * fWidth) * 0.01;
+ }
+ else
+ {
+ fStartWidth = (double)nTempStartWidth;
+ }
+
+ if(0.0 != fStartWidth)
+ {
+ aStartPolyPolygon = basegfx::B2DPolyPolygon(((const XLineStartItem&)(rSet.Get(XATTR_LINESTART))).GetLineStartValue());
+
+ if(aStartPolyPolygon.count() && aStartPolyPolygon.getB2DPolygon(0L).count())
+ {
+ bStartActive = true;
+ bStartCentered = ((const XLineStartCenterItem&)(rSet.Get(XATTR_LINESTARTCENTER))).GetValue();
+ }
+ }
+ }
+
+ if(nTempEndWidth)
+ {
+ if(nTempEndWidth < 0L)
+ {
+ fEndWidth = ((double)(-nTempEndWidth) * fWidth) * 0.01;
+ }
+ else
+ {
+ fEndWidth = (double)nTempEndWidth;
+ }
+
+ if(0.0 != fEndWidth)
+ {
+ aEndPolyPolygon = basegfx::B2DPolyPolygon(((const XLineEndItem&)(rSet.Get(XATTR_LINEEND))).GetLineEndValue());
+
+ if(aEndPolyPolygon.count() && aEndPolyPolygon.getB2DPolygon(0L).count())
+ {
+ bEndActive = true;
+ bEndCentered = ((const XLineEndCenterItem&)(rSet.Get(XATTR_LINEENDCENTER))).GetValue();
+ }
+ }
+ }
+
+ if(bStartActive || bEndActive)
+ {
+ return attribute::SdrLineStartEndAttribute(
+ aStartPolyPolygon, aEndPolyPolygon, fStartWidth, fEndWidth,
+ bStartActive, bEndActive, bStartCentered, bEndCentered);
+ }
+
+ return attribute::SdrLineStartEndAttribute();
+ }
+
+ attribute::SdrShadowAttribute createNewSdrShadowAttribute(const SfxItemSet& rSet)
+ {
+ const bool bShadow(((SdrShadowItem&)rSet.Get(SDRATTR_SHADOW)).GetValue());
+
+ if(bShadow)
+ {
+ sal_uInt16 nTransparence(((SdrShadowTransparenceItem&)(rSet.Get(SDRATTR_SHADOWTRANSPARENCE))).GetValue());
+
+ if(nTransparence > 100)
+ {
+ nTransparence = 100;
+ }
+
+ if(nTransparence)
+ {
+ sal_uInt16 nFillTransparence(((const XFillTransparenceItem&)(rSet.Get(XATTR_FILLTRANSPARENCE))).GetValue());
+
+ if(nFillTransparence > 100)
+ {
+ nFillTransparence = 100;
+ }
+
+ if(nTransparence == nFillTransparence)
+ {
+ // shadow does not really have an own transparence, but the application
+ // sets the shadow transparence equal to the object transparence for
+ // convenience. This is not useful for primitive creation, so take
+ // this as no shadow transparence
+ nTransparence = 0;
+ }
+ }
+
+ if(100 != nTransparence)
+ {
+ const basegfx::B2DVector aOffset(
+ (double)((SdrShadowXDistItem&)(rSet.Get(SDRATTR_SHADOWXDIST))).GetValue(),
+ (double)((SdrShadowYDistItem&)(rSet.Get(SDRATTR_SHADOWYDIST))).GetValue());
+ const Color aColor(((SdrShadowColorItem&)(rSet.Get(SDRATTR_SHADOWCOLOR))).GetColorValue());
+
+ return attribute::SdrShadowAttribute(aOffset, (double)nTransparence * 0.01, aColor.getBColor());
+ }
+ }
+
+ return attribute::SdrShadowAttribute();
+ }
+
+ attribute::SdrFillAttribute createNewSdrFillAttribute(const SfxItemSet& rSet)
+ {
+ const XFillStyle eStyle(((XFillStyleItem&)(rSet.Get(XATTR_FILLSTYLE))).GetValue());
+
+ if(XFILL_NONE != eStyle)
+ {
+ sal_uInt16 nTransparence(((const XFillTransparenceItem&)(rSet.Get(XATTR_FILLTRANSPARENCE))).GetValue());
+
+ if(nTransparence > 100)
+ {
+ nTransparence = 100;
+ }
+
+ if(100 != nTransparence)
+ {
+ const Color aColor(((const XFillColorItem&)(rSet.Get(XATTR_FILLCOLOR))).GetColorValue());
+ attribute::FillGradientAttribute aGradient;
+ attribute::FillHatchAttribute aHatch;
+ attribute::SdrFillBitmapAttribute aBitmap;
+
+ switch(eStyle)
+ {
+ case XFILL_NONE : // for warnings
+ case XFILL_SOLID :
+ {
+ // nothing to do, color is defined
+ break;
+ }
+ case XFILL_GRADIENT :
+ {
+ XGradient aXGradient(((XFillGradientItem&)(rSet.Get(XATTR_FILLGRADIENT))).GetGradientValue());
+
+ const Color aStartColor(aXGradient.GetStartColor());
+ const sal_uInt16 nStartIntens(aXGradient.GetStartIntens());
+ basegfx::BColor aStart(aStartColor.getBColor());
+
+ if(nStartIntens != 100)
+ {
+ const basegfx::BColor aBlack;
+ aStart = interpolate(aBlack, aStart, (double)nStartIntens * 0.01);
+ }
+
+ const Color aEndColor(aXGradient.GetEndColor());
+ const sal_uInt16 nEndIntens(aXGradient.GetEndIntens());
+ basegfx::BColor aEnd(aEndColor.getBColor());
+
+ if(nEndIntens != 100)
+ {
+ const basegfx::BColor aBlack;
+ aEnd = interpolate(aBlack, aEnd, (double)nEndIntens * 0.01);
+ }
+
+ aGradient = attribute::FillGradientAttribute(
+ XGradientStyleToGradientStyle(aXGradient.GetGradientStyle()),
+ (double)aXGradient.GetBorder() * 0.01,
+ (double)aXGradient.GetXOffset() * 0.01,
+ (double)aXGradient.GetYOffset() * 0.01,
+ (double)aXGradient.GetAngle() * F_PI1800,
+ aStart,
+ aEnd,
+ ((const XGradientStepCountItem&)rSet.Get(XATTR_GRADIENTSTEPCOUNT)).GetValue());
+
+ break;
+ }
+ case XFILL_HATCH :
+ {
+ const XHatch& rHatch(((XFillHatchItem&)(rSet.Get(XATTR_FILLHATCH))).GetHatchValue());
+ const Color aColorB(rHatch.GetColor());
+
+ aHatch = attribute::FillHatchAttribute(
+ XHatchStyleToHatchStyle(rHatch.GetHatchStyle()),
+ (double)rHatch.GetDistance(),
+ (double)rHatch.GetAngle() * F_PI1800,
+ aColorB.getBColor(),
+ ((const XFillBackgroundItem&)(rSet.Get(XATTR_FILLBACKGROUND))).GetValue());
+
+ break;
+ }
+ case XFILL_BITMAP :
+ {
+ aBitmap = createNewSdrFillBitmapAttribute(rSet);
+ break;
+ }
+ }
+
+ return attribute::SdrFillAttribute(
+ (double)nTransparence * 0.01,
+ aColor.getBColor(),
+ aGradient,
+ aHatch,
+ aBitmap);
+ }
+ }
+
+ return attribute::SdrFillAttribute();
+ }
+
+ // #i101508# Support handing over given text-to-border distances
+ attribute::SdrTextAttribute createNewSdrTextAttribute(
+ const SfxItemSet& rSet,
+ const SdrText& rText,
+ const sal_Int32* pLeft,
+ const sal_Int32* pUpper,
+ const sal_Int32* pRight,
+ const sal_Int32* pLower)
+ {
+ const SdrTextObj& rTextObj = rText.GetObject();
+
+ if(rText.GetOutlinerParaObject() && rText.GetModel())
+ {
+ // added TextEdit text suppression
+ bool bInEditMode(false);
+
+ if(rText.GetObject().getTextCount() > 1)
+ {
+ bInEditMode = rTextObj.IsInEditMode() && rText.GetObject().getActiveText() == &rText;
+ }
+ else
+ {
+ bInEditMode = rTextObj.IsInEditMode();
+ }
+
+ OutlinerParaObject aOutlinerParaObject(*rText.GetOutlinerParaObject());
+
+ if(bInEditMode)
+ {
+ OutlinerParaObject* pTempObj = rTextObj.GetEditOutlinerParaObject();
+
+ if(pTempObj)
+ {
+ aOutlinerParaObject = *pTempObj;
+ delete pTempObj;
+ }
+ else
+ {
+ // #i100537#
+ // GetEditOutlinerParaObject() returning no object does not mean that
+ // text edit mode is not active. Do not reset the flag here
+ // bInEditMode = false;
+ }
+ }
+
+ const SdrFitToSizeType eFit(rTextObj.GetFitToSize());
+ const SdrTextAniKind eAniKind(rTextObj.GetTextAniKind());
+
+ // #i107346#
+ const SdrOutliner& rDrawTextOutliner = rText.GetModel()->GetDrawOutliner(&rTextObj);
+ const bool bWrongSpell(rDrawTextOutliner.GetControlWord() & EE_CNTRL_ONLINESPELLING);
+
+ return attribute::SdrTextAttribute(
+ rText,
+ aOutlinerParaObject,
+ ((const XFormTextStyleItem&)rSet.Get(XATTR_FORMTXTSTYLE)).GetValue(),
+ pLeft ? *pLeft : rTextObj.GetTextLeftDistance(),
+ pUpper ? *pUpper : rTextObj.GetTextUpperDistance(),
+ pRight ? *pRight : rTextObj.GetTextRightDistance(),
+ pLower ? *pLower : rTextObj.GetTextLowerDistance(),
+ rTextObj.GetTextHorizontalAdjust(rSet),
+ rTextObj.GetTextVerticalAdjust(rSet),
+ ((const SdrTextContourFrameItem&)rSet.Get(SDRATTR_TEXT_CONTOURFRAME)).GetValue(),
+ (SDRTEXTFIT_PROPORTIONAL == eFit || SDRTEXTFIT_ALLLINES == eFit),
+ ((const XFormTextHideFormItem&)rSet.Get(XATTR_FORMTXTHIDEFORM)).GetValue(),
+ SDRTEXTANI_BLINK == eAniKind,
+ SDRTEXTANI_SCROLL == eAniKind || SDRTEXTANI_ALTERNATE == eAniKind || SDRTEXTANI_SLIDE == eAniKind,
+ bInEditMode,
+ ((const SdrTextFixedCellHeightItem&)rSet.Get(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue(),
+ bWrongSpell);
+ }
+
+ return attribute::SdrTextAttribute();
+ }
+
+ attribute::FillGradientAttribute createNewTransparenceGradientAttribute(const SfxItemSet& rSet)
+ {
+ const SfxPoolItem* pGradientItem;
+
+ if(SFX_ITEM_SET == rSet.GetItemState(XATTR_FILLFLOATTRANSPARENCE, TRUE, &pGradientItem)
+ && ((XFillFloatTransparenceItem*)pGradientItem)->IsEnabled())
+ {
+ // test if float transparence is completely transparent
+ const XGradient& rGradient = ((XFillFloatTransparenceItem*)pGradientItem)->GetGradientValue();
+ const sal_uInt8 nStartLuminance(rGradient.GetStartColor().GetLuminance());
+ const sal_uInt8 nEndLuminance(rGradient.GetEndColor().GetLuminance());
+ const bool bCompletelyTransparent(0xff == nStartLuminance && 0xff == nEndLuminance);
+
+ if(!bCompletelyTransparent)
+ {
+ const double fStartLum(nStartLuminance / 255.0);
+ const double fEndLum(nEndLuminance / 255.0);
+
+ return attribute::FillGradientAttribute(
+ XGradientStyleToGradientStyle(rGradient.GetGradientStyle()),
+ (double)rGradient.GetBorder() * 0.01,
+ (double)rGradient.GetXOffset() * 0.01,
+ (double)rGradient.GetYOffset() * 0.01,
+ (double)rGradient.GetAngle() * F_PI1800,
+ basegfx::BColor(fStartLum, fStartLum, fStartLum),
+ basegfx::BColor(fEndLum, fEndLum, fEndLum),
+ 0);
+ }
+ }
+
+ return attribute::FillGradientAttribute();
+ }
+
+ attribute::SdrFillBitmapAttribute createNewSdrFillBitmapAttribute(const SfxItemSet& rSet)
+ {
+ Bitmap aBitmap((((const XFillBitmapItem&)(rSet.Get(XATTR_FILLBITMAP))).GetBitmapValue()).GetBitmap());
+
+ // make sure it's not empty, use default instead
+ if(aBitmap.IsEmpty())
+ {
+ aBitmap = Bitmap(Size(4,4), 8);
+ }
+
+ // if there is no logical size, create a size from pixel size and set MapMode accordingly
+ if(0L == aBitmap.GetPrefSize().Width() || 0L == aBitmap.GetPrefSize().Height())
+ {
+ aBitmap.SetPrefSize(aBitmap.GetSizePixel());
+ aBitmap.SetPrefMapMode(MAP_PIXEL);
+ }
+
+ // convert size and MapMode to destination logical size and MapMode. The created
+ // bitmap must have a valid logical size (PrefSize)
+ const MapUnit aDestinationMapUnit((MapUnit)rSet.GetPool()->GetMetric(0));
+
+ if(aBitmap.GetPrefMapMode() != aDestinationMapUnit)
+ {
+ // #i100360# for MAP_PIXEL, LogicToLogic will not work properly,
+ // so fallback to Application::GetDefaultDevice()
+ if(MAP_PIXEL == aBitmap.GetPrefMapMode().GetMapUnit())
+ {
+ aBitmap.SetPrefSize(Application::GetDefaultDevice()->PixelToLogic(
+ aBitmap.GetPrefSize(), aDestinationMapUnit));
+ }
+ else
+ {
+ aBitmap.SetPrefSize(OutputDevice::LogicToLogic(
+ aBitmap.GetPrefSize(), aBitmap.GetPrefMapMode(), aDestinationMapUnit));
+ }
+ }
+
+ // get size
+ const basegfx::B2DVector aSize(
+ (double)((const SfxMetricItem&)(rSet.Get(XATTR_FILLBMP_SIZEX))).GetValue(),
+ (double)((const SfxMetricItem&)(rSet.Get(XATTR_FILLBMP_SIZEY))).GetValue());
+ const basegfx::B2DVector aOffset(
+ (double)((const SfxUInt16Item&) (rSet.Get(XATTR_FILLBMP_TILEOFFSETX))).GetValue(),
+ (double)((const SfxUInt16Item&) (rSet.Get(XATTR_FILLBMP_TILEOFFSETY))).GetValue());
+ const basegfx::B2DVector aOffsetPosition(
+ (double)((const SfxUInt16Item&) (rSet.Get(XATTR_FILLBMP_POSOFFSETX))).GetValue(),
+ (double)((const SfxUInt16Item&) (rSet.Get(XATTR_FILLBMP_POSOFFSETY))).GetValue());
+
+ return attribute::SdrFillBitmapAttribute(
+ aBitmap,
+ aSize,
+ aOffset,
+ aOffsetPosition,
+ RectPointToB2DVector((RECT_POINT)((const SfxEnumItem&)(rSet.Get(XATTR_FILLBMP_POS))).GetValue()),
+ ((const SfxBoolItem&) (rSet.Get(XATTR_FILLBMP_TILE))).GetValue(),
+ ((const SfxBoolItem&) (rSet.Get(XATTR_FILLBMP_STRETCH))).GetValue(),
+ ((const SfxBoolItem&) (rSet.Get(XATTR_FILLBMP_SIZELOG))).GetValue());
+ }
+
+ attribute::SdrShadowTextAttribute createNewSdrShadowTextAttribute(
+ const SfxItemSet& rSet,
+ const SdrText* pText,
+ bool bSuppressText)
+ {
+ attribute::SdrTextAttribute aText;
+
+ // #i98072# added option to suppress text
+ // look for text first
+ if(!bSuppressText && pText)
+ {
+ aText = createNewSdrTextAttribute(rSet, *pText);
+ }
+
+ // try shadow
+ const attribute::SdrShadowAttribute aShadow(createNewSdrShadowAttribute(rSet));
+
+ return attribute::SdrShadowTextAttribute(aShadow, aText);
+ }
+
+ attribute::SdrLineShadowTextAttribute createNewSdrLineShadowTextAttribute(
+ const SfxItemSet& rSet,
+ const SdrText* pText)
+ {
+ attribute::SdrLineAttribute aLine;
+ attribute::SdrLineStartEndAttribute aLineStartEnd;
+ attribute::SdrTextAttribute aText;
+ bool bFontworkHideContour(false);
+
+ // look for text first
+ if(pText)
+ {
+ aText = createNewSdrTextAttribute(rSet, *pText);
+
+ // when object has text and text is fontwork and hide contour is set for fontwork, force
+ // line and fill style to empty
+ if(!aText.isDefault()
+ && !aText.getSdrFormTextAttribute().isDefault()
+ && aText.isHideContour())
+ {
+ bFontworkHideContour = true;
+ }
+ }
+
+ // try line style
+ if(!bFontworkHideContour)
+ {
+ aLine = createNewSdrLineAttribute(rSet);
+
+ if(!aLine.isDefault())
+ {
+ // try LineStartEnd
+ aLineStartEnd = createNewSdrLineStartEndAttribute(rSet, aLine.getWidth());
+ }
+ }
+
+ if(!aLine.isDefault() || !aText.isDefault())
+ {
+ // try shadow
+ const attribute::SdrShadowAttribute aShadow(createNewSdrShadowAttribute(rSet));
+
+ return attribute::SdrLineShadowTextAttribute(aLine, aLineStartEnd, aShadow, aText);
+ }
+
+ return attribute::SdrLineShadowTextAttribute();
+ }
+
+ attribute::SdrLineFillShadowTextAttribute createNewSdrLineFillShadowTextAttribute(
+ const SfxItemSet& rSet,
+ const SdrText* pText)
+ {
+ attribute::SdrLineAttribute aLine;
+ attribute::SdrFillAttribute aFill;
+ attribute::SdrLineStartEndAttribute aLineStartEnd;
+ attribute::SdrShadowAttribute aShadow;
+ attribute::FillGradientAttribute aFillFloatTransGradient;
+ attribute::SdrTextAttribute aText;
+ bool bFontworkHideContour(false);
+
+ // look for text first
+ if(pText)
+ {
+ aText = createNewSdrTextAttribute(rSet, *pText);
+
+ // when object has text and text is fontwork and hide contour is set for fontwork, force
+ // line and fill style to empty
+ if(!aText.getSdrFormTextAttribute().isDefault() && aText.isHideContour())
+ {
+ bFontworkHideContour = true;
+ }
+ }
+
+ if(!bFontworkHideContour)
+ {
+ // try line style
+ aLine = createNewSdrLineAttribute(rSet);
+
+ if(!aLine.isDefault())
+ {
+ // try LineStartEnd
+ aLineStartEnd = createNewSdrLineStartEndAttribute(rSet, aLine.getWidth());
+ }
+
+ // try fill style
+ aFill = createNewSdrFillAttribute(rSet);
+
+ if(!aFill.isDefault())
+ {
+ // try fillfloattransparence
+ aFillFloatTransGradient = createNewTransparenceGradientAttribute(rSet);
+ }
+ }
+
+ if(!aLine.isDefault() || !aFill.isDefault() || !aText.isDefault())
+ {
+ // try shadow
+ aShadow = createNewSdrShadowAttribute(rSet);
+
+ return attribute::SdrLineFillShadowTextAttribute(
+ aLine, aFill, aLineStartEnd, aShadow, aFillFloatTransGradient, aText);
+ }
+
+ return attribute::SdrLineFillShadowTextAttribute();
+ }
+
+ attribute::SdrLineFillShadowAttribute3D createNewSdrLineFillShadowAttribute(const SfxItemSet& rSet, bool bSuppressFill)
+ {
+ attribute::SdrFillAttribute aFill;
+ attribute::SdrLineStartEndAttribute aLineStartEnd;
+ attribute::SdrShadowAttribute aShadow;
+ attribute::FillGradientAttribute aFillFloatTransGradient;
+
+ // try line style
+ const attribute::SdrLineAttribute aLine(createNewSdrLineAttribute(rSet));
+
+ if(!aLine.isDefault())
+ {
+ // try LineStartEnd
+ aLineStartEnd = createNewSdrLineStartEndAttribute(rSet, aLine.getWidth());
+ }
+
+ // try fill style
+ if(!bSuppressFill)
+ {
+ aFill = createNewSdrFillAttribute(rSet);
+
+ if(!aFill.isDefault())
+ {
+ // try fillfloattransparence
+ aFillFloatTransGradient = createNewTransparenceGradientAttribute(rSet);
+ }
+ }
+
+ if(!aLine.isDefault() || !aFill.isDefault())
+ {
+ // try shadow
+ aShadow = createNewSdrShadowAttribute(rSet);
+
+ return attribute::SdrLineFillShadowAttribute3D(
+ aLine, aFill, aLineStartEnd, aShadow, aFillFloatTransGradient);
+ }
+
+ return attribute::SdrLineFillShadowAttribute3D();
+ }
+
+ attribute::SdrSceneAttribute createNewSdrSceneAttribute(const SfxItemSet& rSet)
+ {
+ // get perspective
+ ::com::sun::star::drawing::ProjectionMode aProjectionMode(::com::sun::star::drawing::ProjectionMode_PARALLEL);
+ const sal_uInt16 nProjectionValue(((const Svx3DPerspectiveItem&)rSet.Get(SDRATTR_3DSCENE_PERSPECTIVE)).GetValue());
+
+ if(1L == nProjectionValue)
+ {
+ aProjectionMode = ::com::sun::star::drawing::ProjectionMode_PERSPECTIVE;
+ }
+
+ // get distance
+ const double fDistance(((const Svx3DDistanceItem&)rSet.Get(SDRATTR_3DSCENE_DISTANCE)).GetValue());
+
+ // get shadow slant
+ const double fShadowSlant(F_PI180 * ((const Svx3DShadowSlantItem&)rSet.Get(SDRATTR_3DSCENE_SHADOW_SLANT)).GetValue());
+
+ // get shade mode
+ ::com::sun::star::drawing::ShadeMode aShadeMode(::com::sun::star::drawing::ShadeMode_FLAT);
+ const sal_uInt16 nShadeValue(((const Svx3DShadeModeItem&)rSet.Get(SDRATTR_3DSCENE_SHADE_MODE)).GetValue());
+
+ if(1L == nShadeValue)
+ {
+ aShadeMode = ::com::sun::star::drawing::ShadeMode_PHONG;
+ }
+ else if(2L == nShadeValue)
+ {
+ aShadeMode = ::com::sun::star::drawing::ShadeMode_SMOOTH;
+ }
+ else if(3L == nShadeValue)
+ {
+ aShadeMode = ::com::sun::star::drawing::ShadeMode_DRAFT;
+ }
+
+ // get two sided lighting
+ const bool bTwoSidedLighting(((const Svx3DTwoSidedLightingItem&)rSet.Get(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING)).GetValue());
+
+ return attribute::SdrSceneAttribute(fDistance, fShadowSlant, aProjectionMode, aShadeMode, bTwoSidedLighting);
+ }
+
+ attribute::SdrLightingAttribute createNewSdrLightingAttribute(const SfxItemSet& rSet)
+ {
+ // extract lights from given SfxItemSet (from scene)
+ ::std::vector< attribute::Sdr3DLightAttribute > aLightVector;
+
+ if(((const Svx3DLightOnOff1Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_1)).GetValue())
+ {
+ const basegfx::BColor aColor(((const Svx3DLightcolor1Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_1)).GetValue().getBColor());
+ const basegfx::B3DVector aDirection(((const Svx3DLightDirection1Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1)).GetValue());
+ aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, true));
+ }
+
+ if(((const Svx3DLightOnOff2Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_2)).GetValue())
+ {
+ const basegfx::BColor aColor(((const Svx3DLightcolor2Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_2)).GetValue().getBColor());
+ const basegfx::B3DVector aDirection(((const Svx3DLightDirection2Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2)).GetValue());
+ aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
+ }
+
+ if(((const Svx3DLightOnOff3Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_3)).GetValue())
+ {
+ const basegfx::BColor aColor(((const Svx3DLightcolor3Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_3)).GetValue().getBColor());
+ const basegfx::B3DVector aDirection(((const Svx3DLightDirection3Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3)).GetValue());
+ aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
+ }
+
+ if(((const Svx3DLightOnOff4Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_4)).GetValue())
+ {
+ const basegfx::BColor aColor(((const Svx3DLightcolor4Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_4)).GetValue().getBColor());
+ const basegfx::B3DVector aDirection(((const Svx3DLightDirection4Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4)).GetValue());
+ aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
+ }
+
+ if(((const Svx3DLightOnOff5Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_5)).GetValue())
+ {
+ const basegfx::BColor aColor(((const Svx3DLightcolor5Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_5)).GetValue().getBColor());
+ const basegfx::B3DVector aDirection(((const Svx3DLightDirection5Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5)).GetValue());
+ aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
+ }
+
+ if(((const Svx3DLightOnOff6Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_6)).GetValue())
+ {
+ const basegfx::BColor aColor(((const Svx3DLightcolor6Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_6)).GetValue().getBColor());
+ const basegfx::B3DVector aDirection(((const Svx3DLightDirection6Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6)).GetValue());
+ aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
+ }
+
+ if(((const Svx3DLightOnOff7Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_7)).GetValue())
+ {
+ const basegfx::BColor aColor(((const Svx3DLightcolor7Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_7)).GetValue().getBColor());
+ const basegfx::B3DVector aDirection(((const Svx3DLightDirection7Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7)).GetValue());
+ aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
+ }
+
+ if(((const Svx3DLightOnOff8Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_8)).GetValue())
+ {
+ const basegfx::BColor aColor(((const Svx3DLightcolor8Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_8)).GetValue().getBColor());
+ const basegfx::B3DVector aDirection(((const Svx3DLightDirection8Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8)).GetValue());
+ aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
+ }
+
+ // get ambient color
+ const Color aAmbientValue(((const Svx3DAmbientcolorItem&)rSet.Get(SDRATTR_3DSCENE_AMBIENTCOLOR)).GetValue());
+ const basegfx::BColor aAmbientLight(aAmbientValue.getBColor());
+
+ return attribute::SdrLightingAttribute(aAmbientLight, aLightVector);
+ }
+
+ void calculateRelativeCornerRadius(sal_Int32 nRadius, const basegfx::B2DRange& rObjectRange, double& rfCornerRadiusX, double& rfCornerRadiusY)
+ {
+ rfCornerRadiusX = rfCornerRadiusY = (double)nRadius;
+
+ if(0.0 != rfCornerRadiusX)
+ {
+ const double fHalfObjectWidth(rObjectRange.getWidth() * 0.5);
+
+ if(0.0 != fHalfObjectWidth)
+ {
+ if(rfCornerRadiusX < 0.0)
+ {
+ rfCornerRadiusX = 0.0;
+ }
+
+ if(rfCornerRadiusX > fHalfObjectWidth)
+ {
+ rfCornerRadiusX = fHalfObjectWidth;
+ }
+
+ rfCornerRadiusX /= fHalfObjectWidth;
+ }
+ else
+ {
+ rfCornerRadiusX = 0.0;
+ }
+ }
+
+ if(0.0 != rfCornerRadiusY)
+ {
+ const double fHalfObjectHeight(rObjectRange.getHeight() * 0.5);
+
+ if(0.0 != fHalfObjectHeight)
+ {
+ if(rfCornerRadiusY < 0.0)
+ {
+ rfCornerRadiusY = 0.0;
+ }
+
+ if(rfCornerRadiusY > fHalfObjectHeight)
+ {
+ rfCornerRadiusY = fHalfObjectHeight;
+ }
+
+ rfCornerRadiusY /= fHalfObjectHeight;
+ }
+ else
+ {
+ rfCornerRadiusY = 0.0;
+ }
+ }
+ }
+
+ // #i101508# Support handing over given text-to-border distances
+ attribute::SdrFillTextAttribute createNewSdrFillTextAttribute(
+ const SfxItemSet& rSet,
+ const SdrText* pText,
+ const sal_Int32* pLeft,
+ const sal_Int32* pUpper,
+ const sal_Int32* pRight,
+ const sal_Int32* pLower)
+ {
+ attribute::SdrFillAttribute aFill;
+ attribute::FillGradientAttribute aFillFloatTransGradient;
+ attribute::SdrTextAttribute aText;
+ bool bFontworkHideContour(false);
+
+ // look for text first
+ if(pText)
+ {
+ aText = createNewSdrTextAttribute(rSet, *pText, pLeft, pUpper, pRight, pLower);
+
+ // when object has text and text is fontwork and hide contour is set for fontwork, force
+ // fill style to empty
+ if(!aText.getSdrFormTextAttribute().isDefault() && aText.isHideContour())
+ {
+ bFontworkHideContour = true;
+ }
+ }
+
+ if(!bFontworkHideContour)
+ {
+ // try fill style
+ aFill = createNewSdrFillAttribute(rSet);
+
+ if(!aFill.isDefault())
+ {
+ // try fillfloattransparence
+ aFillFloatTransGradient = createNewTransparenceGradientAttribute(rSet);
+ }
+ }
+
+ if(!aFill.isDefault() || !aText.isDefault())
+ {
+ return attribute::SdrFillTextAttribute(aFill, aFillFloatTransGradient, aText);
+ }
+
+ return attribute::SdrFillTextAttribute();
+ }
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
diff --git a/svx/source/sdr/primitive2d/sdrcaptionprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrcaptionprimitive2d.cxx
new file mode 100644
index 000000000000..3757d60a3d27
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrcaptionprimitive2d.cxx
@@ -0,0 +1,177 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrcaptionprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrCaptionPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ Primitive2DSequence aRetval;
+
+ // create unit outline polygon
+ const basegfx::B2DPolygon aUnitOutline(basegfx::tools::createPolygonFromRect(
+ basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
+ getCornerRadiusX(),
+ getCornerRadiusY()));
+
+ // add fill
+ if(getSdrLFSTAttribute().getFill().isDefault())
+ {
+ // create invisible fill for HitTest
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ true,
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform()));
+ }
+ else
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolyPolygonFillPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getFill(),
+ getSdrLFSTAttribute().getFillFloatTransGradient()));
+ }
+
+ // add line
+ if(getSdrLFSTAttribute().getLine().isDefault())
+ {
+ // create invisible line for HitTest/BoundRect
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ false,
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform()));
+
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ false,
+ basegfx::B2DPolyPolygon(getTail()),
+ getTransform()));
+ }
+ else
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolygonLinePrimitive(
+ aUnitOutline,
+ getTransform(),
+ getSdrLFSTAttribute().getLine(),
+ attribute::SdrLineStartEndAttribute()));
+
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolygonLinePrimitive(
+ getTail(),
+ getTransform(),
+ getSdrLFSTAttribute().getLine(),
+ getSdrLFSTAttribute().getLineStartEnd()));
+ }
+
+ // add text
+ if(!getSdrLFSTAttribute().getText().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createTextPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getText(),
+ getSdrLFSTAttribute().getLine(),
+ false,
+ false,
+ false));
+ }
+
+ // add shadow
+ if(!getSdrLFSTAttribute().getShadow().isDefault())
+ {
+ aRetval = createEmbeddedShadowPrimitive(aRetval, getSdrLFSTAttribute().getShadow());
+ }
+
+ return aRetval;
+ }
+
+ SdrCaptionPrimitive2D::SdrCaptionPrimitive2D(
+ const basegfx::B2DHomMatrix& rTransform,
+ const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute,
+ const basegfx::B2DPolygon& rTail,
+ double fCornerRadiusX,
+ double fCornerRadiusY)
+ : BufferedDecompositionPrimitive2D(),
+ maTransform(rTransform),
+ maSdrLFSTAttribute(rSdrLFSTAttribute),
+ maTail(rTail),
+ mfCornerRadiusX(fCornerRadiusX),
+ mfCornerRadiusY(fCornerRadiusY)
+ {
+ // transform maTail to unit polygon
+ if(getTail().count())
+ {
+ basegfx::B2DHomMatrix aInverse(getTransform());
+ aInverse.invert();
+ maTail.transform(aInverse);
+ }
+ }
+
+ bool SdrCaptionPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrCaptionPrimitive2D& rCompare = (SdrCaptionPrimitive2D&)rPrimitive;
+
+ return (getCornerRadiusX() == rCompare.getCornerRadiusX()
+ && getCornerRadiusY() == rCompare.getCornerRadiusY()
+ && getTail() == rCompare.getTail()
+ && getTransform() == rCompare.getTransform()
+ && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute());
+ }
+
+ return false;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrCaptionPrimitive2D, PRIMITIVE2D_ID_SDRCAPTIONPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
diff --git a/svx/source/sdr/primitive2d/sdrconnectorprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrconnectorprimitive2d.cxx
new file mode 100644
index 000000000000..6b52837c3eca
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrconnectorprimitive2d.cxx
@@ -0,0 +1,124 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrconnectorprimitive2d.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrConnectorPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ Primitive2DSequence aRetval;
+
+ // add line
+ if(getSdrLSTAttribute().getLine().isDefault())
+ {
+ // create invisible line for HitTest/BoundRect
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ false,
+ basegfx::B2DPolyPolygon(getUnitPolygon())));
+ }
+ else
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolygonLinePrimitive(
+ getUnitPolygon(),
+ basegfx::B2DHomMatrix(),
+ getSdrLSTAttribute().getLine(),
+ getSdrLSTAttribute().getLineStartEnd()));
+ }
+
+ // add text
+ if(!getSdrLSTAttribute().getText().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createTextPrimitive(
+ basegfx::B2DPolyPolygon(getUnitPolygon()),
+ basegfx::B2DHomMatrix(),
+ getSdrLSTAttribute().getText(),
+ getSdrLSTAttribute().getLine(),
+ false,
+ false,
+ false));
+ }
+
+ // add shadow
+ if(!getSdrLSTAttribute().getShadow().isDefault())
+ {
+ aRetval = createEmbeddedShadowPrimitive(
+ aRetval,
+ getSdrLSTAttribute().getShadow());
+ }
+
+ return aRetval;
+ }
+
+ SdrConnectorPrimitive2D::SdrConnectorPrimitive2D(
+ const attribute::SdrLineShadowTextAttribute& rSdrLSTAttribute,
+ const ::basegfx::B2DPolygon& rUnitPolygon)
+ : BufferedDecompositionPrimitive2D(),
+ maSdrLSTAttribute(rSdrLSTAttribute),
+ maUnitPolygon(rUnitPolygon)
+ {
+ }
+
+ bool SdrConnectorPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrConnectorPrimitive2D& rCompare = (SdrConnectorPrimitive2D&)rPrimitive;
+
+ return (getUnitPolygon() == rCompare.getUnitPolygon()
+ && getSdrLSTAttribute() == rCompare.getSdrLSTAttribute());
+ }
+
+ return false;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrConnectorPrimitive2D, PRIMITIVE2D_ID_SDRCONNECTORPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
diff --git a/svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx
new file mode 100644
index 000000000000..710beeb444f2
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrcustomshapeprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <drawinglayer/attribute/sdrlineattribute.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrCustomShapePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ Primitive2DSequence aRetval(getSubPrimitives());
+
+ // add text
+ if(!getSdrSTAttribute().getText().isDefault())
+ {
+ const basegfx::B2DPolygon aUnitOutline(basegfx::tools::createUnitPolygon());
+
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createTextPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTextBox(),
+ getSdrSTAttribute().getText(),
+ attribute::SdrLineAttribute(),
+ false,
+ getWordWrap(),
+ isForceTextClipToTextRange()));
+ }
+
+ // add shadow
+ if(aRetval.hasElements() && !getSdrSTAttribute().getShadow().isDefault())
+ {
+ // #i105323# add generic shadow only for 2D shapes. For
+ // 3D shapes shadow will be set at the individual created
+ // visualisation objects and be visualized by the 3d renderer
+ // as a single shadow.
+ //
+ // The shadow for AutoShapes could be handled uniformely by not setting any
+ // shadow items at the helper model objects and only adding shadow here for
+ // 2D and 3D (and it works, too), but this would lead to two 3D scenes for
+ // the 3D object; one for the shadow aond one for the content. The one for the
+ // shadow will be correct (using ColorModifierStack), but expensive.
+ if(!get3DShape())
+ {
+ aRetval = createEmbeddedShadowPrimitive(aRetval, getSdrSTAttribute().getShadow());
+ }
+ }
+
+ return aRetval;
+ }
+
+ SdrCustomShapePrimitive2D::SdrCustomShapePrimitive2D(
+ const attribute::SdrShadowTextAttribute& rSdrSTAttribute,
+ const Primitive2DSequence& rSubPrimitives,
+ const basegfx::B2DHomMatrix& rTextBox,
+ bool bWordWrap,
+ bool b3DShape,
+ bool bForceTextClipToTextRange)
+ : BufferedDecompositionPrimitive2D(),
+ maSdrSTAttribute(rSdrSTAttribute),
+ maSubPrimitives(rSubPrimitives),
+ maTextBox(rTextBox),
+ mbWordWrap(bWordWrap),
+ mb3DShape(b3DShape),
+ mbForceTextClipToTextRange(bForceTextClipToTextRange)
+ {
+ }
+
+ bool SdrCustomShapePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrCustomShapePrimitive2D& rCompare = (SdrCustomShapePrimitive2D&)rPrimitive;
+
+ return (getSdrSTAttribute() == rCompare.getSdrSTAttribute()
+ && getSubPrimitives() == rCompare.getSubPrimitives()
+ && getTextBox() == rCompare.getTextBox()
+ && getWordWrap() == rCompare.getWordWrap()
+ && get3DShape() == rCompare.get3DShape()
+ && isForceTextClipToTextRange() == rCompare.isForceTextClipToTextRange());
+ }
+
+ return false;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrCustomShapePrimitive2D, PRIMITIVE2D_ID_SDRCUSTOMSHAPEPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
diff --git a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
new file mode 100644
index 000000000000..76e6d81bb252
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
@@ -0,0 +1,486 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <drawinglayer/primitive2d/baseprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
+#include <drawinglayer/primitive2d/transparenceprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
+#include <drawinglayer/attribute/strokeattribute.hxx>
+#include <drawinglayer/attribute/linestartendattribute.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <drawinglayer/attribute/sdrfillbitmapattribute.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <drawinglayer/primitive2d/shadowprimitive2d.hxx>
+#include <svx/sdr/attribute/sdrtextattribute.hxx>
+#include <svx/sdr/primitive2d/sdrtextprimitive2d.hxx>
+#include <svx/svdotext.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <drawinglayer/primitive2d/animatedprimitive2d.hxx>
+#include <drawinglayer/animation/animationtiming.hxx>
+#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
+#include <basegfx/tools/canvastools.hxx>
+#include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <drawinglayer/primitive2d/texthierarchyprimitive2d.hxx>
+#include <drawinglayer/attribute/sdrfillattribute.hxx>
+#include <drawinglayer/attribute/sdrlineattribute.hxx>
+#include <drawinglayer/attribute/sdrlinestartendattribute.hxx>
+#include <drawinglayer/attribute/sdrshadowattribute.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DReference createPolyPolygonFillPrimitive(
+ const basegfx::B2DPolyPolygon& rUnitPolyPolygon,
+ const basegfx::B2DHomMatrix& rObjectTransform,
+ const attribute::SdrFillAttribute& rFill,
+ const attribute::FillGradientAttribute& rFillGradient)
+ {
+ // prepare fully scaled polygon
+ basegfx::B2DPolyPolygon aScaledPolyPolygon(rUnitPolyPolygon);
+ aScaledPolyPolygon.transform(rObjectTransform);
+ BasePrimitive2D* pNewFillPrimitive = 0;
+
+ if(!rFill.getGradient().isDefault())
+ {
+ pNewFillPrimitive = new PolyPolygonGradientPrimitive2D(aScaledPolyPolygon, rFill.getGradient());
+ }
+ else if(!rFill.getHatch().isDefault())
+ {
+ pNewFillPrimitive = new PolyPolygonHatchPrimitive2D(aScaledPolyPolygon, rFill.getColor(), rFill.getHatch());
+ }
+ else if(!rFill.getBitmap().isDefault())
+ {
+ const basegfx::B2DRange aRange(basegfx::tools::getRange(aScaledPolyPolygon));
+ pNewFillPrimitive = new PolyPolygonBitmapPrimitive2D(aScaledPolyPolygon, rFill.getBitmap().getFillBitmapAttribute(aRange));
+ }
+ else
+ {
+ pNewFillPrimitive = new PolyPolygonColorPrimitive2D(aScaledPolyPolygon, rFill.getColor());
+ }
+
+ if(0.0 != rFill.getTransparence())
+ {
+ // create simpleTransparencePrimitive, add created fill primitive
+ const Primitive2DReference xRefA(pNewFillPrimitive);
+ const Primitive2DSequence aContent(&xRefA, 1L);
+ return Primitive2DReference(new UnifiedTransparencePrimitive2D(aContent, rFill.getTransparence()));
+ }
+ else if(!rFillGradient.isDefault())
+ {
+ // create sequence with created fill primitive
+ const Primitive2DReference xRefA(pNewFillPrimitive);
+ const Primitive2DSequence aContent(&xRefA, 1L);
+
+ // create FillGradientPrimitive2D for transparence and add to new sequence
+ // fillGradientPrimitive is enough here (compared to PolyPolygonGradientPrimitive2D) since float transparence will be masked anyways
+ const basegfx::B2DRange aRange(basegfx::tools::getRange(aScaledPolyPolygon));
+ const Primitive2DReference xRefB(new FillGradientPrimitive2D(aRange, rFillGradient));
+ const Primitive2DSequence aAlpha(&xRefB, 1L);
+
+ // create TransparencePrimitive2D using alpha and content
+ return Primitive2DReference(new TransparencePrimitive2D(aContent, aAlpha));
+ }
+ else
+ {
+ // add to decomposition
+ return Primitive2DReference(pNewFillPrimitive);
+ }
+ }
+
+ Primitive2DReference createPolygonLinePrimitive(
+ const basegfx::B2DPolygon& rUnitPolygon,
+ const basegfx::B2DHomMatrix& rObjectTransform,
+ const attribute::SdrLineAttribute& rLine,
+ const attribute::SdrLineStartEndAttribute& rStroke)
+ {
+ // prepare fully scaled polygon
+ basegfx::B2DPolygon aScaledPolygon(rUnitPolygon);
+ aScaledPolygon.transform(rObjectTransform);
+
+ // create line and stroke attribute
+ const attribute::LineAttribute aLineAttribute(rLine.getColor(), rLine.getWidth(), rLine.getJoin());
+ const attribute::StrokeAttribute aStrokeAttribute(rLine.getDotDashArray(), rLine.getFullDotDashLen());
+ BasePrimitive2D* pNewLinePrimitive = 0L;
+
+ if(!rUnitPolygon.isClosed() && !rStroke.isDefault())
+ {
+ attribute::LineStartEndAttribute aStart(rStroke.getStartWidth(), rStroke.getStartPolyPolygon(), rStroke.isStartCentered());
+ attribute::LineStartEndAttribute aEnd(rStroke.getEndWidth(), rStroke.getEndPolyPolygon(), rStroke.isEndCentered());
+
+ // create data
+ pNewLinePrimitive = new PolygonStrokeArrowPrimitive2D(aScaledPolygon, aLineAttribute, aStrokeAttribute, aStart, aEnd);
+ }
+ else
+ {
+ // create data
+ pNewLinePrimitive = new PolygonStrokePrimitive2D(aScaledPolygon, aLineAttribute, aStrokeAttribute);
+ }
+
+ if(0.0 != rLine.getTransparence())
+ {
+ // create simpleTransparencePrimitive, add created fill primitive
+ const Primitive2DReference xRefA(pNewLinePrimitive);
+ const Primitive2DSequence aContent(&xRefA, 1L);
+ return Primitive2DReference(new UnifiedTransparencePrimitive2D(aContent, rLine.getTransparence()));
+ }
+ else
+ {
+ // add to decomposition
+ return Primitive2DReference(pNewLinePrimitive);
+ }
+ }
+
+ Primitive2DReference createTextPrimitive(
+ const basegfx::B2DPolyPolygon& rUnitPolyPolygon,
+ const basegfx::B2DHomMatrix& rObjectTransform,
+ const attribute::SdrTextAttribute& rText,
+ const attribute::SdrLineAttribute& rStroke,
+ bool bCellText,
+ bool bWordWrap,
+ bool bClipOnBounds)
+ {
+ basegfx::B2DHomMatrix aAnchorTransform(rObjectTransform);
+ SdrTextPrimitive2D* pNew = 0;
+
+ if(rText.isContour())
+ {
+ // contour text
+ if(!rStroke.isDefault() && 0.0 != rStroke.getWidth())
+ {
+ // take line width into account and shrink contour polygon accordingly
+ // decompose to get scale
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ rObjectTransform.decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // scale outline to object's size to allow growing with value relative to that size
+ // and also to keep aspect ratio
+ basegfx::B2DPolyPolygon aScaledUnitPolyPolygon(rUnitPolyPolygon);
+ aScaledUnitPolyPolygon.transform(basegfx::tools::createScaleB2DHomMatrix(
+ fabs(aScale.getX()), fabs(aScale.getY())));
+
+ // grow the polygon. To shrink, use negative value (half width)
+ aScaledUnitPolyPolygon = basegfx::tools::growInNormalDirection(aScaledUnitPolyPolygon, -(rStroke.getWidth() * 0.5));
+
+ // scale back to unit polygon
+ aScaledUnitPolyPolygon.transform(basegfx::tools::createScaleB2DHomMatrix(
+ 0.0 != aScale.getX() ? 1.0 / aScale.getX() : 1.0,
+ 0.0 != aScale.getY() ? 1.0 / aScale.getY() : 1.0));
+
+ // create with unit polygon
+ pNew = new SdrContourTextPrimitive2D(
+ &rText.getSdrText(),
+ rText.getOutlinerParaObject(),
+ aScaledUnitPolyPolygon,
+ rObjectTransform);
+ }
+ else
+ {
+ // create with unit polygon
+ pNew = new SdrContourTextPrimitive2D(
+ &rText.getSdrText(),
+ rText.getOutlinerParaObject(),
+ rUnitPolyPolygon,
+ rObjectTransform);
+ }
+ }
+ else if(!rText.getSdrFormTextAttribute().isDefault())
+ {
+ // text on path, use scaled polygon
+ basegfx::B2DPolyPolygon aScaledPolyPolygon(rUnitPolyPolygon);
+ aScaledPolyPolygon.transform(rObjectTransform);
+ pNew = new SdrPathTextPrimitive2D(
+ &rText.getSdrText(),
+ rText.getOutlinerParaObject(),
+ aScaledPolyPolygon,
+ rText.getSdrFormTextAttribute());
+ }
+ else
+ {
+ // rObjectTransform is the whole SdrObject transformation from unit rectangle
+ // to it's size and position. Decompose to allow working with single values.
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ rObjectTransform.decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // extract mirroring
+ const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
+ const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0));
+ aScale = basegfx::absolute(aScale);
+
+ // Get the real size, since polygon ountline and scale
+ // from the object transformation may vary (e.g. ellipse segments)
+ basegfx::B2DHomMatrix aJustScaleTransform;
+ aJustScaleTransform.set(0, 0, aScale.getX());
+ aJustScaleTransform.set(1, 1, aScale.getY());
+ basegfx::B2DPolyPolygon aScaledUnitPolyPolygon(rUnitPolyPolygon);
+ aScaledUnitPolyPolygon.transform(aJustScaleTransform);
+ const basegfx::B2DRange aSnapRange(basegfx::tools::getRange(aScaledUnitPolyPolygon));
+
+ // create a range describing the wanted text position and size (aTextAnchorRange). This
+ // means to use the text distance values here
+ const basegfx::B2DPoint aTopLeft(aSnapRange.getMinX() + rText.getTextLeftDistance(), aSnapRange.getMinY() + rText.getTextUpperDistance());
+ const basegfx::B2DPoint aBottomRight(aSnapRange.getMaxX() - rText.getTextRightDistance(), aSnapRange.getMaxY() - rText.getTextLowerDistance());
+ basegfx::B2DRange aTextAnchorRange;
+ aTextAnchorRange.expand(aTopLeft);
+ aTextAnchorRange.expand(aBottomRight);
+
+ // now create a transformation from this basic range (aTextAnchorRange)
+ aAnchorTransform = basegfx::tools::createScaleTranslateB2DHomMatrix(
+ aTextAnchorRange.getWidth(), aTextAnchorRange.getHeight(),
+ aTextAnchorRange.getMinX(), aTextAnchorRange.getMinY());
+
+ // apply mirroring
+ aAnchorTransform.scale(bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0);
+
+ // apply object's other transforms
+ aAnchorTransform = basegfx::tools::createShearXRotateTranslateB2DHomMatrix(fShearX, fRotate, aTranslate)
+ * aAnchorTransform;
+
+ if(rText.isFitToSize())
+ {
+ // streched text in range
+ pNew = new SdrStretchTextPrimitive2D(
+ &rText.getSdrText(),
+ rText.getOutlinerParaObject(),
+ aAnchorTransform,
+ rText.isFixedCellHeight());
+ }
+ else // text in range
+ {
+ // build new primitive
+ pNew = new SdrBlockTextPrimitive2D(
+ &rText.getSdrText(),
+ rText.getOutlinerParaObject(),
+ aAnchorTransform,
+ rText.getSdrTextHorzAdjust(),
+ rText.getSdrTextVertAdjust(),
+ rText.isFixedCellHeight(),
+ rText.isScroll(),
+ bCellText,
+ bWordWrap,
+ bClipOnBounds);
+ }
+ }
+
+ OSL_ENSURE(pNew != 0, "createTextPrimitive: no text primitive created (!)");
+
+ if(rText.isBlink())
+ {
+ // prepare animation and primitive list
+ drawinglayer::animation::AnimationEntryList aAnimationList;
+ rText.getBlinkTextTiming(aAnimationList);
+
+ if(0.0 != aAnimationList.getDuration())
+ {
+ // create content sequence
+ const Primitive2DReference xRefA(pNew);
+ const Primitive2DSequence aContent(&xRefA, 1L);
+
+ // create and add animated switch primitive
+ return Primitive2DReference(new AnimatedBlinkPrimitive2D(aAnimationList, aContent, true));
+ }
+ else
+ {
+ // add to decomposition
+ return Primitive2DReference(pNew);
+ }
+ }
+
+ if(rText.isScroll())
+ {
+ // suppress scroll when FontWork
+ if(rText.getSdrFormTextAttribute().isDefault())
+ {
+ // get scroll direction
+ const SdrTextAniDirection eDirection(rText.getSdrText().GetObject().GetTextAniDirection());
+ const bool bHorizontal(SDRTEXTANI_LEFT == eDirection || SDRTEXTANI_RIGHT == eDirection);
+
+ // decompose to get separated values for the scroll box
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ aAnchorTransform.decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // build transform from scaled only to full AnchorTransform and inverse
+ const basegfx::B2DHomMatrix aSRT(basegfx::tools::createShearXRotateTranslateB2DHomMatrix(
+ fShearX, fRotate, aTranslate));
+ basegfx::B2DHomMatrix aISRT(aSRT);
+ aISRT.invert();
+
+ // bring the primitive back to scaled only and get scaled range, create new clone for this
+ SdrTextPrimitive2D* pNew2 = pNew->createTransformedClone(aISRT);
+ OSL_ENSURE(pNew2, "createTextPrimitive: Could not create transformed clone of text primitive (!)");
+ delete pNew;
+ pNew = pNew2;
+
+ // create neutral geometry::ViewInformation2D for local range and decompose calls. This is okay
+ // since the decompose is view-independent
+ const uno::Sequence< beans::PropertyValue > xViewParameters;
+ geometry::ViewInformation2D aViewInformation2D(xViewParameters);
+
+ // get range
+ const basegfx::B2DRange aScaledRange(pNew->getB2DRange(aViewInformation2D));
+
+ // create left outside and right outside transformations. Also take care
+ // of the clip rectangle
+ basegfx::B2DHomMatrix aLeft, aRight;
+ basegfx::B2DPoint aClipTopLeft(0.0, 0.0);
+ basegfx::B2DPoint aClipBottomRight(aScale.getX(), aScale.getY());
+
+ if(bHorizontal)
+ {
+ aClipTopLeft.setY(aScaledRange.getMinY());
+ aClipBottomRight.setY(aScaledRange.getMaxY());
+ aLeft.translate(-aScaledRange.getMaxX(), 0.0);
+ aRight.translate(aScale.getX() - aScaledRange.getMinX(), 0.0);
+ }
+ else
+ {
+ aClipTopLeft.setX(aScaledRange.getMinX());
+ aClipBottomRight.setX(aScaledRange.getMaxX());
+ aLeft.translate(0.0, -aScaledRange.getMaxY());
+ aRight.translate(0.0, aScale.getY() - aScaledRange.getMinY());
+ }
+
+ aLeft *= aSRT;
+ aRight *= aSRT;
+
+ // prepare animation list
+ drawinglayer::animation::AnimationEntryList aAnimationList;
+
+ if(bHorizontal)
+ {
+ rText.getScrollTextTiming(aAnimationList, aScale.getX(), aScaledRange.getWidth());
+ }
+ else
+ {
+ rText.getScrollTextTiming(aAnimationList, aScale.getY(), aScaledRange.getHeight());
+ }
+
+ if(0.0 != aAnimationList.getDuration())
+ {
+ // create a new Primitive2DSequence containing the animated text in it's scaled only state.
+ // use the decomposition to force to simple text primitives, those will no longer
+ // need the outliner for formatting (alternatively it is also possible to just add
+ // pNew to aNewPrimitiveSequence)
+ Primitive2DSequence aAnimSequence(pNew->get2DDecomposition(aViewInformation2D));
+ delete pNew;
+
+ // create a new animatedInterpolatePrimitive and add it
+ std::vector< basegfx::B2DHomMatrix > aMatrixStack;
+ aMatrixStack.push_back(aLeft);
+ aMatrixStack.push_back(aRight);
+ const Primitive2DReference xRefA(new AnimatedInterpolatePrimitive2D(aMatrixStack, aAnimationList, aAnimSequence, true));
+ const Primitive2DSequence aContent(&xRefA, 1L);
+
+ // scrolling needs an encapsulating clipping primitive
+ const basegfx::B2DRange aClipRange(aClipTopLeft, aClipBottomRight);
+ basegfx::B2DPolygon aClipPolygon(basegfx::tools::createPolygonFromRect(aClipRange));
+ aClipPolygon.transform(aSRT);
+ return Primitive2DReference(new MaskPrimitive2D(basegfx::B2DPolyPolygon(aClipPolygon), aContent));
+ }
+ else
+ {
+ // add to decomposition
+ return Primitive2DReference(pNew);
+ }
+ }
+ }
+
+ if(rText.isInEditMode())
+ {
+ // #i97628#
+ // encapsulate with TextHierarchyEditPrimitive2D to allow renderers
+ // to suppress actively edited content if needed
+ const Primitive2DReference xRefA(pNew);
+ const Primitive2DSequence aContent(&xRefA, 1L);
+
+ // create and add TextHierarchyEditPrimitive2D primitive
+ return Primitive2DReference(new TextHierarchyEditPrimitive2D(aContent));
+ }
+ else
+ {
+ // add to decomposition
+ return Primitive2DReference(pNew);
+ }
+ }
+
+ Primitive2DSequence createEmbeddedShadowPrimitive(
+ const Primitive2DSequence& rContent,
+ const attribute::SdrShadowAttribute& rShadow)
+ {
+ if(rContent.hasElements())
+ {
+ Primitive2DSequence aRetval(2);
+ basegfx::B2DHomMatrix aShadowOffset;
+
+ // prepare shadow offset
+ aShadowOffset.set(0, 2, rShadow.getOffset().getX());
+ aShadowOffset.set(1, 2, rShadow.getOffset().getY());
+
+ // create shadow primitive and add content
+ aRetval[0] = Primitive2DReference(
+ new ShadowPrimitive2D(
+ aShadowOffset,
+ rShadow.getColor(),
+ rContent));
+
+ if(0.0 != rShadow.getTransparence())
+ {
+ // create SimpleTransparencePrimitive2D
+ const Primitive2DSequence aTempContent(&aRetval[0], 1);
+
+ aRetval[0] = Primitive2DReference(
+ new UnifiedTransparencePrimitive2D(
+ aTempContent,
+ rShadow.getTransparence()));
+ }
+
+ aRetval[1] = Primitive2DReference(new GroupPrimitive2D(rContent));
+ return aRetval;
+ }
+ else
+ {
+ return rContent;
+ }
+ }
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
diff --git a/svx/source/sdr/primitive2d/sdrellipseprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrellipseprimitive2d.cxx
new file mode 100644
index 000000000000..02de307bee77
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrellipseprimitive2d.cxx
@@ -0,0 +1,278 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrellipseprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <basegfx/color/bcolor.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrEllipsePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ Primitive2DSequence aRetval;
+
+ // create unit outline polygon
+ // Do use createPolygonFromUnitCircle, but let create from first quadrant to mimic old geometry creation.
+ // This is needed to have the same look when stroke is used since the polygon start point defines the
+ // stroke start, too.
+ basegfx::B2DPolygon aUnitOutline(basegfx::tools::createPolygonFromUnitCircle(1));
+
+ // scale and move UnitEllipse to UnitObject (-1,-1 1,1) -> (0,0 1,1)
+ const basegfx::B2DHomMatrix aUnitCorrectionMatrix(
+ basegfx::tools::createScaleTranslateB2DHomMatrix(0.5, 0.5, 0.5, 0.5));
+
+ // apply to the geometry
+ aUnitOutline.transform(aUnitCorrectionMatrix);
+
+ // add fill
+ if(!getSdrLFSTAttribute().getFill().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolyPolygonFillPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getFill(),
+ getSdrLFSTAttribute().getFillFloatTransGradient()));
+ }
+
+ // add line
+ if(getSdrLFSTAttribute().getLine().isDefault())
+ {
+ // create invisible line for HitTest/BoundRect
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ false,
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform()));
+ }
+ else
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolygonLinePrimitive(
+ aUnitOutline,
+ getTransform(),
+ getSdrLFSTAttribute().getLine(),
+ attribute::SdrLineStartEndAttribute()));
+ }
+
+ // add text
+ if(!getSdrLFSTAttribute().getText().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createTextPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getText(),
+ getSdrLFSTAttribute().getLine(),
+ false,
+ false,
+ false));
+ }
+
+ // add shadow
+ if(!getSdrLFSTAttribute().getShadow().isDefault())
+ {
+ aRetval = createEmbeddedShadowPrimitive(
+ aRetval,
+ getSdrLFSTAttribute().getShadow());
+ }
+
+ return aRetval;
+ }
+
+ SdrEllipsePrimitive2D::SdrEllipsePrimitive2D(
+ const basegfx::B2DHomMatrix& rTransform,
+ const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute)
+ : BufferedDecompositionPrimitive2D(),
+ maTransform(rTransform),
+ maSdrLFSTAttribute(rSdrLFSTAttribute)
+ {
+ }
+
+ bool SdrEllipsePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrEllipsePrimitive2D& rCompare = (SdrEllipsePrimitive2D&)rPrimitive;
+
+ return (getTransform() == rCompare.getTransform()
+ && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute());
+ }
+
+ return false;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrEllipsePrimitive2D, PRIMITIVE2D_ID_SDRELLIPSEPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrEllipseSegmentPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ Primitive2DSequence aRetval;
+
+ // create unit outline polygon
+ basegfx::B2DPolygon aUnitOutline(basegfx::tools::createPolygonFromUnitEllipseSegment(mfStartAngle, mfEndAngle));
+
+ if(mbCloseSegment)
+ {
+ if(mbCloseUsingCenter)
+ {
+ // for compatibility, insert the center point at polygon start to get the same
+ // line stroking pattern as the old painting mechanisms.
+ aUnitOutline.insert(0L, basegfx::B2DPoint(0.0, 0.0));
+ }
+
+ aUnitOutline.setClosed(true);
+ }
+
+ // move and scale UnitEllipse to UnitObject (-1,-1 1,1) -> (0,0 1,1)
+ const basegfx::B2DHomMatrix aUnitCorrectionMatrix(
+ basegfx::tools::createScaleTranslateB2DHomMatrix(0.5, 0.5, 0.5, 0.5));
+
+ // apply to the geometry
+ aUnitOutline.transform(aUnitCorrectionMatrix);
+
+ // add fill
+ if(!getSdrLFSTAttribute().getFill().isDefault() && aUnitOutline.isClosed())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolyPolygonFillPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getFill(),
+ getSdrLFSTAttribute().getFillFloatTransGradient()));
+ }
+
+ // add line
+ if(getSdrLFSTAttribute().getLine().isDefault())
+ {
+ // create invisible line for HitTest/BoundRect
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ false,
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform()));
+ }
+ else
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolygonLinePrimitive(
+ aUnitOutline,
+ getTransform(),
+ getSdrLFSTAttribute().getLine(),
+ getSdrLFSTAttribute().getLineStartEnd()));
+ }
+
+ // add text
+ if(!getSdrLFSTAttribute().getText().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createTextPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getText(),
+ getSdrLFSTAttribute().getLine(),
+ false,
+ false,
+ false));
+ }
+
+ // add shadow
+ if(!getSdrLFSTAttribute().getShadow().isDefault())
+ {
+ aRetval = createEmbeddedShadowPrimitive(
+ aRetval,
+ getSdrLFSTAttribute().getShadow());
+ }
+
+ return aRetval;
+ }
+
+ SdrEllipseSegmentPrimitive2D::SdrEllipseSegmentPrimitive2D(
+ const basegfx::B2DHomMatrix& rTransform,
+ const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute,
+ double fStartAngle,
+ double fEndAngle,
+ bool bCloseSegment,
+ bool bCloseUsingCenter)
+ : SdrEllipsePrimitive2D(rTransform, rSdrLFSTAttribute),
+ mfStartAngle(fStartAngle),
+ mfEndAngle(fEndAngle),
+ mbCloseSegment(bCloseSegment),
+ mbCloseUsingCenter(bCloseUsingCenter)
+ {
+ }
+
+ bool SdrEllipseSegmentPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(SdrEllipsePrimitive2D::operator==(rPrimitive))
+ {
+ const SdrEllipseSegmentPrimitive2D& rCompare = (SdrEllipseSegmentPrimitive2D&)rPrimitive;
+
+ if( mfStartAngle == rCompare.mfStartAngle
+ && mfEndAngle == rCompare.mfEndAngle
+ && mbCloseSegment == rCompare.mbCloseSegment
+ && mbCloseUsingCenter == rCompare.mbCloseUsingCenter)
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrEllipseSegmentPrimitive2D, PRIMITIVE2D_ID_SDRELLIPSESEGMENTPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
diff --git a/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx
new file mode 100644
index 000000000000..e981af91896b
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx
@@ -0,0 +1,177 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrgrafprimitive2d.hxx>
+#include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrGrafPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ Primitive2DSequence aRetval;
+
+ // create unit outline polygon
+ basegfx::B2DPolygon aUnitOutline(basegfx::tools::createUnitPolygon());
+
+ // add fill, but only when graphic ist transparent
+ if(!getSdrLFSTAttribute().getFill().isDefault() && isTransparent())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolyPolygonFillPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getFill(),
+ getSdrLFSTAttribute().getFillFloatTransGradient()));
+ }
+
+ // add line
+ if(!getSdrLFSTAttribute().getLine().isDefault())
+ {
+ // if line width is given, polygon needs to be grown by half of it to make the
+ // outline to be outside of the bitmap
+ if(0.0 != getSdrLFSTAttribute().getLine().getWidth())
+ {
+ // decompose to get scale
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ getTransform().decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // create expanded range (add relative half line width to unit rectangle)
+ double fHalfLineWidth(getSdrLFSTAttribute().getLine().getWidth() * 0.5);
+ double fScaleX(0.0 != aScale.getX() ? fHalfLineWidth / fabs(aScale.getX()) : 1.0);
+ double fScaleY(0.0 != aScale.getY() ? fHalfLineWidth / fabs(aScale.getY()) : 1.0);
+ const basegfx::B2DRange aExpandedRange(-fScaleX, -fScaleY, 1.0 + fScaleX, 1.0 + fScaleY);
+ basegfx::B2DPolygon aExpandedUnitOutline(basegfx::tools::createPolygonFromRect(aExpandedRange));
+
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolygonLinePrimitive(
+ aExpandedUnitOutline,
+ getTransform(),
+ getSdrLFSTAttribute().getLine(),
+ attribute::SdrLineStartEndAttribute()));
+ }
+ else
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolygonLinePrimitive(
+ aUnitOutline, getTransform(),
+ getSdrLFSTAttribute().getLine(),
+ attribute::SdrLineStartEndAttribute()));
+ }
+ }
+
+ // add graphic content
+ if(255L != getGraphicAttr().GetTransparency())
+ {
+ const Primitive2DReference xGraphicContentPrimitive(
+ new GraphicPrimitive2D(
+ getTransform(),
+ getGraphicObject(),
+ getGraphicAttr()));
+
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, xGraphicContentPrimitive);
+ }
+
+ // add text
+ if(!getSdrLFSTAttribute().getText().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createTextPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getText(),
+ getSdrLFSTAttribute().getLine(),
+ false,
+ false,
+ false));
+ }
+
+ // add shadow
+ if(!getSdrLFSTAttribute().getShadow().isDefault())
+ {
+ aRetval = createEmbeddedShadowPrimitive(
+ aRetval,
+ getSdrLFSTAttribute().getShadow());
+ }
+
+ return aRetval;
+ }
+
+ SdrGrafPrimitive2D::SdrGrafPrimitive2D(
+ const basegfx::B2DHomMatrix& rTransform,
+ const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute,
+ const GraphicObject& rGraphicObject,
+ const GraphicAttr& rGraphicAttr)
+ : BufferedDecompositionPrimitive2D(),
+ maTransform(rTransform),
+ maSdrLFSTAttribute(rSdrLFSTAttribute),
+ maGraphicObject(rGraphicObject),
+ maGraphicAttr(rGraphicAttr)
+ {
+ // reset some values from GraphicAttr which are part of transformation already
+ maGraphicAttr.SetRotation(0L);
+ }
+
+ bool SdrGrafPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrGrafPrimitive2D& rCompare = (SdrGrafPrimitive2D&)rPrimitive;
+
+ return (getTransform() == rCompare.getTransform()
+ && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute()
+ && getGraphicObject() == rCompare.getGraphicObject()
+ && getGraphicAttr() == rCompare.getGraphicAttr());
+ }
+
+ return false;
+ }
+
+ bool SdrGrafPrimitive2D::isTransparent() const
+ {
+ return ((0L != getGraphicAttr().GetTransparency()) || (getGraphicObject().IsTransparent()));
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrGrafPrimitive2D, PRIMITIVE2D_ID_SDRGRAFPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
diff --git a/svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx
new file mode 100644
index 000000000000..e4403cd6df49
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx
@@ -0,0 +1,510 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrmeasureprimitive2d.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <svx/sdr/primitive2d/sdrtextprimitive2d.hxx>
+#include <svx/sdr/attribute/sdrtextattribute.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/tools/canvastools.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DReference SdrMeasurePrimitive2D::impCreatePart(
+ const attribute::SdrLineAttribute& rLineAttribute,
+ const basegfx::B2DHomMatrix& rObjectMatrix,
+ const basegfx::B2DPoint& rStart,
+ const basegfx::B2DPoint& rEnd,
+ bool bLeftActive,
+ bool bRightActive) const
+ {
+ const attribute::SdrLineStartEndAttribute& rLineStartEnd = getSdrLSTAttribute().getLineStartEnd();
+ basegfx::B2DPolygon aPolygon;
+
+ aPolygon.append(rStart);
+ aPolygon.append(rEnd);
+
+ if(rLineStartEnd.isDefault() || (!bLeftActive && !bRightActive))
+ {
+ return createPolygonLinePrimitive(
+ aPolygon,
+ rObjectMatrix,
+ rLineAttribute,
+ attribute::SdrLineStartEndAttribute());
+ }
+
+ if(bLeftActive && bRightActive)
+ {
+ return createPolygonLinePrimitive(
+ aPolygon,
+ rObjectMatrix,
+ rLineAttribute,
+ rLineStartEnd);
+ }
+
+ const basegfx::B2DPolyPolygon aEmpty;
+ const attribute::SdrLineStartEndAttribute aLineStartEnd(
+ bLeftActive ? rLineStartEnd.getStartPolyPolygon() : aEmpty, bRightActive ? rLineStartEnd.getEndPolyPolygon() : aEmpty,
+ bLeftActive ? rLineStartEnd.getStartWidth() : 0.0, bRightActive ? rLineStartEnd.getEndWidth() : 0.0,
+ bLeftActive ? rLineStartEnd.isStartActive() : false, bRightActive ? rLineStartEnd.isEndActive() : false,
+ bLeftActive ? rLineStartEnd.isStartCentered() : false, bRightActive? rLineStartEnd.isEndCentered() : false);
+
+ return createPolygonLinePrimitive(aPolygon, rObjectMatrix, rLineAttribute, aLineStartEnd);
+ }
+
+ Primitive2DSequence SdrMeasurePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const
+ {
+ Primitive2DSequence aRetval;
+ SdrBlockTextPrimitive2D* pBlockText = 0;
+ basegfx::B2DRange aTextRange;
+ double fTextX((getStart().getX() + getEnd().getX()) * 0.5);
+ double fTextY((getStart().getX() + getEnd().getX()) * 0.5);
+ const basegfx::B2DVector aLine(getEnd() - getStart());
+ const double fDistance(aLine.getLength());
+ const double fAngle(atan2(aLine.getY(), aLine.getX()));
+ bool bAutoUpsideDown(false);
+ const attribute::SdrTextAttribute rTextAttribute = getSdrLSTAttribute().getText();
+ const basegfx::B2DHomMatrix aObjectMatrix(
+ basegfx::tools::createShearXRotateTranslateB2DHomMatrix(0.0, fAngle, getStart()));
+
+ // preapare text, but do not add yet; it needs to be aligned to
+ // the line geometry
+ if(!rTextAttribute.isDefault())
+ {
+ basegfx::B2DHomMatrix aTextMatrix;
+ double fTestAngle(fAngle);
+
+ if(getTextRotation())
+ {
+ aTextMatrix.rotate(-90.0 * F_PI180);
+ fTestAngle -= (90.0 * F_PI180);
+
+ if(getTextAutoAngle() && fTestAngle < -F_PI)
+ {
+ fTestAngle += F_2PI;
+ }
+ }
+
+ if(getTextAutoAngle())
+ {
+ if(fTestAngle > (F_PI / 4.0) || fTestAngle < (-F_PI * (3.0 / 4.0)))
+ {
+ bAutoUpsideDown = true;
+ }
+ }
+
+ // create primitive and get text range
+ pBlockText = new SdrBlockTextPrimitive2D(
+ &rTextAttribute.getSdrText(),
+ rTextAttribute.getOutlinerParaObject(),
+ aTextMatrix,
+ SDRTEXTHORZADJUST_CENTER,
+ SDRTEXTVERTADJUST_CENTER,
+ rTextAttribute.isScroll(),
+ false,
+ false,
+ false,
+ false);
+
+ aTextRange = pBlockText->getB2DRange(aViewInformation);
+ }
+
+ // prepare line attribute and result
+ {
+ const attribute::SdrLineAttribute rLineAttribute(getSdrLSTAttribute().getLine());
+ bool bArrowsOutside(false);
+ bool bMainLineSplitted(false);
+ const attribute::SdrLineStartEndAttribute& rLineStartEnd = getSdrLSTAttribute().getLineStartEnd();
+ double fStartArrowW(0.0);
+ double fStartArrowH(0.0);
+ double fEndArrowW(0.0);
+ double fEndArrowH(0.0);
+
+ if(!rLineStartEnd.isDefault())
+ {
+ if(rLineStartEnd.isStartActive())
+ {
+ const basegfx::B2DRange aArrowRange(basegfx::tools::getRange(rLineStartEnd.getStartPolyPolygon()));
+ fStartArrowW = rLineStartEnd.getStartWidth();
+ fStartArrowH = aArrowRange.getHeight() * fStartArrowW / aArrowRange.getWidth();
+
+ if(rLineStartEnd.isStartCentered())
+ {
+ fStartArrowH *= 0.5;
+ }
+ }
+
+ if(rLineStartEnd.isEndActive())
+ {
+ const basegfx::B2DRange aArrowRange(basegfx::tools::getRange(rLineStartEnd.getEndPolyPolygon()));
+ fEndArrowW = rLineStartEnd.getEndWidth();
+ fEndArrowH = aArrowRange.getHeight() * fEndArrowW / aArrowRange.getWidth();
+
+ if(rLineStartEnd.isEndCentered())
+ {
+ fEndArrowH *= 0.5;
+ }
+ }
+ }
+
+ const double fSpaceNeededByArrows(fStartArrowH + fEndArrowH + ((fStartArrowW + fEndArrowW) * 0.5));
+ const double fArrowsOutsideLen((fStartArrowH + fEndArrowH + fStartArrowW + fEndArrowW) * 0.5);
+ const double fHalfLineWidth(rLineAttribute.getWidth() * 0.5);
+
+ if(fSpaceNeededByArrows > fDistance)
+ {
+ bArrowsOutside = true;
+ }
+
+ MeasureTextPosition eHorizontal(getHorizontal());
+ MeasureTextPosition eVertical(getVertical());
+
+ if(MEASURETEXTPOSITION_AUTOMATIC == eVertical)
+ {
+ eVertical = MEASURETEXTPOSITION_NEGATIVE;
+ }
+
+ if(MEASURETEXTPOSITION_CENTERED == eVertical)
+ {
+ bMainLineSplitted = true;
+ }
+
+ if(MEASURETEXTPOSITION_AUTOMATIC == eHorizontal)
+ {
+ if(aTextRange.getWidth() > fDistance)
+ {
+ eHorizontal = MEASURETEXTPOSITION_NEGATIVE;
+ }
+ else
+ {
+ eHorizontal = MEASURETEXTPOSITION_CENTERED;
+ }
+
+ if(bMainLineSplitted)
+ {
+ if(aTextRange.getWidth() + fSpaceNeededByArrows > fDistance)
+ {
+ bArrowsOutside = true;
+ }
+ }
+ else
+ {
+ const double fSmallArrowNeed(fStartArrowH + fEndArrowH + ((fStartArrowW + fEndArrowW) * 0.125));
+
+ if(aTextRange.getWidth() + fSmallArrowNeed > fDistance)
+ {
+ bArrowsOutside = true;
+ }
+ }
+ }
+
+ if(MEASURETEXTPOSITION_CENTERED != eHorizontal)
+ {
+ bArrowsOutside = true;
+ }
+
+ // switch text above/below?
+ if(getBelow() || (bAutoUpsideDown && !getTextRotation()))
+ {
+ if(MEASURETEXTPOSITION_NEGATIVE == eVertical)
+ {
+ eVertical = MEASURETEXTPOSITION_POSITIVE;
+ }
+ else if(MEASURETEXTPOSITION_POSITIVE == eVertical)
+ {
+ eVertical = MEASURETEXTPOSITION_NEGATIVE;
+ }
+ }
+
+ const double fMainLineOffset(getBelow() ? getDistance() : -getDistance());
+ const basegfx::B2DPoint aMainLeft(0.0, fMainLineOffset);
+ const basegfx::B2DPoint aMainRight(fDistance, fMainLineOffset);
+
+ // main line
+ if(bArrowsOutside)
+ {
+ double fLenLeft(fArrowsOutsideLen);
+ double fLenRight(fArrowsOutsideLen);
+
+ if(!bMainLineSplitted)
+ {
+ if(MEASURETEXTPOSITION_NEGATIVE == eHorizontal)
+ {
+ fLenLeft = fStartArrowH + aTextRange.getWidth();
+ }
+ else if(MEASURETEXTPOSITION_POSITIVE == eHorizontal)
+ {
+ fLenRight = fEndArrowH + aTextRange.getWidth();
+ }
+ }
+
+ const basegfx::B2DPoint aMainLeftLeft(aMainLeft.getX() - fLenLeft, aMainLeft.getY());
+ const basegfx::B2DPoint aMainRightRight(aMainRight.getX() + fLenRight, aMainRight.getY());
+
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aMainLeftLeft, aMainLeft, false, true));
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aMainRight, aMainRightRight, true, false));
+
+ if(!bMainLineSplitted || MEASURETEXTPOSITION_CENTERED != eHorizontal)
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aMainLeft, aMainRight, false, false));
+ }
+ }
+ else
+ {
+ if(bMainLineSplitted)
+ {
+ const double fHalfLength((fDistance - (aTextRange.getWidth() + (fStartArrowH + fEndArrowH) * 0.25)) * 0.5);
+ const basegfx::B2DPoint aMainInnerLeft(aMainLeft.getX() + fHalfLength, aMainLeft.getY());
+ const basegfx::B2DPoint aMainInnerRight(aMainRight.getX() - fHalfLength, aMainRight.getY());
+
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aMainLeft, aMainInnerLeft, true, false));
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aMainInnerRight, aMainRight, false, true));
+ }
+ else
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aMainLeft, aMainRight, true, true));
+ }
+ }
+
+ // left/right help line value preparation
+ const double fTopEdge(getBelow() ? getUpper() + getDistance() : -getUpper() - getDistance());
+ const double fBottomLeft(getBelow() ? getLower() - getLeftDelta() : getLeftDelta() - getLower());
+ const double fBottomRight(getBelow() ? getLower() - getRightDelta() : getRightDelta() - getLower());
+
+ // left help line
+ const basegfx::B2DPoint aLeftUp(0.0, fTopEdge);
+ const basegfx::B2DPoint aLeftDown(0.0, fBottomLeft);
+
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aLeftDown, aLeftUp, false, false));
+
+ // right help line
+ const basegfx::B2DPoint aRightUp(fDistance, fTopEdge);
+ const basegfx::B2DPoint aRightDown(fDistance, fBottomRight);
+
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aRightDown, aRightUp, false, false));
+
+ // text horizontal position
+ if(MEASURETEXTPOSITION_NEGATIVE == eHorizontal)
+ {
+ // left
+ const double fSmall(fArrowsOutsideLen * 0.18);
+ fTextX = aMainLeft.getX() - (fStartArrowH + aTextRange.getWidth() + fSmall + fHalfLineWidth);
+
+ if(bMainLineSplitted)
+ {
+ fTextX -= (fArrowsOutsideLen - fStartArrowH);
+ }
+
+ if(!rTextAttribute.isDefault())
+ {
+ fTextX -= rTextAttribute.getTextRightDistance();
+ }
+ }
+ else if(MEASURETEXTPOSITION_POSITIVE == eHorizontal)
+ {
+ // right
+ const double fSmall(fArrowsOutsideLen * 0.18);
+ fTextX = aMainRight.getX() + (fEndArrowH + fSmall + fHalfLineWidth);
+
+ if(bMainLineSplitted)
+ {
+ fTextX += (fArrowsOutsideLen - fEndArrowH);
+ }
+
+ if(!rTextAttribute.isDefault())
+ {
+ fTextX += rTextAttribute.getTextLeftDistance();
+ }
+ }
+ else // MEASURETEXTPOSITION_CENTERED
+ {
+ // centered
+ fTextX = aMainLeft.getX() + ((fDistance - aTextRange.getWidth()) * 0.5);
+
+ if(!rTextAttribute.isDefault())
+ {
+ fTextX += (rTextAttribute.getTextLeftDistance() - rTextAttribute.getTextRightDistance()) / 2L;
+ }
+ }
+
+ // text vertical position
+ if(MEASURETEXTPOSITION_NEGATIVE == eVertical)
+ {
+ // top
+ const double fSmall(fArrowsOutsideLen * 0.10);
+ fTextY = aMainLeft.getY() - (aTextRange.getHeight() + fSmall + fHalfLineWidth);
+
+ if(!rTextAttribute.isDefault())
+ {
+ fTextY -= rTextAttribute.getTextLowerDistance();
+ }
+ }
+ else if(MEASURETEXTPOSITION_POSITIVE == eVertical)
+ {
+ // bottom
+ const double fSmall(fArrowsOutsideLen * 0.10);
+ fTextY = aMainLeft.getY() + (fSmall + fHalfLineWidth);
+
+ if(!rTextAttribute.isDefault())
+ {
+ fTextY += rTextAttribute.getTextUpperDistance();
+ }
+ }
+ else // MEASURETEXTPOSITION_CENTERED
+ {
+ // centered
+ fTextY = aMainLeft.getY() - (aTextRange.getHeight() * 0.5);
+
+ if(!rTextAttribute.isDefault())
+ {
+ fTextY += (rTextAttribute.getTextUpperDistance() - rTextAttribute.getTextLowerDistance()) / 2L;
+ }
+ }
+ }
+
+ if(getSdrLSTAttribute().getLine().isDefault())
+ {
+ // embed line geometry to invisible (100% transparent) line group for HitTest
+ const Primitive2DReference xHiddenLines(new HiddenGeometryPrimitive2D(aRetval));
+
+ aRetval = Primitive2DSequence(&xHiddenLines, 1);
+ }
+
+ if(pBlockText)
+ {
+ // create transformation to text primitive end position
+ basegfx::B2DHomMatrix aChange;
+
+ // handle auto text rotation
+ if(bAutoUpsideDown)
+ {
+ aChange.rotate(F_PI);
+ }
+
+ // move from aTextRange.TopLeft to fTextX, fTextY
+ aChange.translate(fTextX - aTextRange.getMinX(), fTextY - aTextRange.getMinY());
+
+ // apply object matrix
+ aChange *= aObjectMatrix;
+
+ // apply to existing text primitive
+ SdrTextPrimitive2D* pNewBlockText = pBlockText->createTransformedClone(aChange);
+ OSL_ENSURE(pNewBlockText, "SdrMeasurePrimitive2D::create2DDecomposition: Could not create transformed clone of text primitive (!)");
+ delete pBlockText;
+
+ // add to local primitives
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, Primitive2DReference(pNewBlockText));
+ }
+
+ // add shadow
+ if(!getSdrLSTAttribute().getShadow().isDefault())
+ {
+ aRetval = createEmbeddedShadowPrimitive(
+ aRetval,
+ getSdrLSTAttribute().getShadow());
+ }
+
+ return aRetval;
+ }
+
+ SdrMeasurePrimitive2D::SdrMeasurePrimitive2D(
+ const attribute::SdrLineShadowTextAttribute& rSdrLSTAttribute,
+ const basegfx::B2DPoint& rStart,
+ const basegfx::B2DPoint& rEnd,
+ MeasureTextPosition eHorizontal,
+ MeasureTextPosition eVertical,
+ double fDistance,
+ double fUpper,
+ double fLower,
+ double fLeftDelta,
+ double fRightDelta,
+ bool bBelow,
+ bool bTextRotation,
+ bool bTextAutoAngle)
+ : BufferedDecompositionPrimitive2D(),
+ maSdrLSTAttribute(rSdrLSTAttribute),
+ maStart(rStart),
+ maEnd(rEnd),
+ meHorizontal(eHorizontal),
+ meVertical(eVertical),
+ mfDistance(fDistance),
+ mfUpper(fUpper),
+ mfLower(fLower),
+ mfLeftDelta(fLeftDelta),
+ mfRightDelta(fRightDelta),
+ mbBelow(bBelow),
+ mbTextRotation(bTextRotation),
+ mbTextAutoAngle(bTextAutoAngle)
+ {
+ }
+
+ bool SdrMeasurePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrMeasurePrimitive2D& rCompare = (SdrMeasurePrimitive2D&)rPrimitive;
+
+ return (getStart() == rCompare.getStart()
+ && getEnd() == rCompare.getEnd()
+ && getHorizontal() == rCompare.getHorizontal()
+ && getVertical() == rCompare.getVertical()
+ && getDistance() == rCompare.getDistance()
+ && getUpper() == rCompare.getUpper()
+ && getLower() == rCompare.getLower()
+ && getLeftDelta() == rCompare.getLeftDelta()
+ && getRightDelta() == rCompare.getRightDelta()
+ && getBelow() == rCompare.getBelow()
+ && getTextRotation() == rCompare.getTextRotation()
+ && getTextAutoAngle() == rCompare.getTextAutoAngle()
+ && getSdrLSTAttribute() == rCompare.getSdrLSTAttribute());
+ }
+
+ return false;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrMeasurePrimitive2D, PRIMITIVE2D_ID_SDRMEASUREPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
diff --git a/svx/source/sdr/primitive2d/sdrole2primitive2d.cxx b/svx/source/sdr/primitive2d/sdrole2primitive2d.cxx
new file mode 100644
index 000000000000..43e3cf72ffbb
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrole2primitive2d.cxx
@@ -0,0 +1,190 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrole2primitive2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ SdrOle2Primitive2D::SdrOle2Primitive2D(
+ const Primitive2DSequence& rOLEContent,
+ const basegfx::B2DHomMatrix& rTransform,
+ const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute)
+ : BasePrimitive2D(),
+ maOLEContent(rOLEContent),
+ maTransform(rTransform),
+ maSdrLFSTAttribute(rSdrLFSTAttribute)
+ {
+ }
+
+ bool SdrOle2Primitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BasePrimitive2D::operator==(rPrimitive))
+ {
+ const SdrOle2Primitive2D& rCompare = (SdrOle2Primitive2D&)rPrimitive;
+
+ // #i108636# The standard operator== on two UNO sequences did not work as i
+ // would have expected; it just checks the .is() states and the data type
+ // of the sequence. What i need here is detection of equality of the whole
+ // sequence content, thus i need to use the arePrimitive2DSequencesEqual helper
+ // here instead of the operator== which lead to always returning false and thus
+ // always re-decompositions of the subcontent.
+ if(arePrimitive2DSequencesEqual(getOLEContent(), rCompare.getOLEContent())
+ && getTransform() == rCompare.getTransform()
+ && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute())
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ Primitive2DSequence SdrOle2Primitive2D::get2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ // to take care of getSdrLFSTAttribute() later, the same as in SdrGrafPrimitive2D::create2DDecomposition
+ // should happen. For the moment we only need the OLE itself
+ // Added complete primitive preparation using getSdrLFSTAttribute() now. To not do stuff which is not needed now, it
+ // may be supressed by using a static bool. The paint version only supported text.
+ static bool bBehaveCompatibleToPaintVersion(true);
+ Primitive2DSequence aRetval;
+
+ // create unit outline polygon
+ const basegfx::B2DPolygon aUnitOutline(basegfx::tools::createUnitPolygon());
+
+ // add fill
+ if(!bBehaveCompatibleToPaintVersion
+ && !getSdrLFSTAttribute().getFill().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolyPolygonFillPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getFill(),
+ getSdrLFSTAttribute().getFillFloatTransGradient()));
+ }
+
+ // add line
+ // #i97981# condition was inverse to purpose. When being compatible to paint version,
+ // border needs to be suppressed
+ if(!bBehaveCompatibleToPaintVersion
+ && !getSdrLFSTAttribute().getLine().isDefault())
+ {
+ // if line width is given, polygon needs to be grown by half of it to make the
+ // outline to be outside of the bitmap
+ if(0.0 != getSdrLFSTAttribute().getLine().getWidth())
+ {
+ // decompose to get scale
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ getTransform().decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // create expanded range (add relative half line width to unit rectangle)
+ double fHalfLineWidth(getSdrLFSTAttribute().getLine().getWidth() * 0.5);
+ double fScaleX(0.0 != aScale.getX() ? fHalfLineWidth / fabs(aScale.getX()) : 1.0);
+ double fScaleY(0.0 != aScale.getY() ? fHalfLineWidth / fabs(aScale.getY()) : 1.0);
+ const basegfx::B2DRange aExpandedRange(-fScaleX, -fScaleY, 1.0 + fScaleX, 1.0 + fScaleY);
+ basegfx::B2DPolygon aExpandedUnitOutline(basegfx::tools::createPolygonFromRect(aExpandedRange));
+
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolygonLinePrimitive(
+ aExpandedUnitOutline,
+ getTransform(),
+ getSdrLFSTAttribute().getLine(),
+ attribute::SdrLineStartEndAttribute()));
+ }
+ else
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolygonLinePrimitive(
+ aUnitOutline,
+ getTransform(),
+ getSdrLFSTAttribute().getLine(),
+ attribute::SdrLineStartEndAttribute()));
+ }
+ }
+ else
+ {
+ // if initially no line is defined, create one for HitTest and BoundRect
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ false,
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform()));
+ }
+
+ // add graphic content
+ appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, getOLEContent());
+
+ // add text, no need to supress to stay compatible since text was
+ // always supported by the old paints, too
+ if(!getSdrLFSTAttribute().getText().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createTextPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getText(),
+ getSdrLFSTAttribute().getLine(),
+ false,
+ false,
+ false));
+ }
+
+ // add shadow
+ if(!bBehaveCompatibleToPaintVersion
+ && !getSdrLFSTAttribute().getShadow().isDefault())
+ {
+ aRetval = createEmbeddedShadowPrimitive(
+ aRetval,
+ getSdrLFSTAttribute().getShadow());
+ }
+
+ return aRetval;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrOle2Primitive2D, PRIMITIVE2D_ID_SDROLE2PRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
diff --git a/svx/source/sdr/primitive2d/sdrolecontentprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrolecontentprimitive2d.cxx
new file mode 100644
index 000000000000..70c1feda75a8
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrolecontentprimitive2d.cxx
@@ -0,0 +1,201 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrolecontentprimitive2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <svx/svdoole2.hxx>
+#include <vcl/svapp.hxx>
+#include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
+#include <svtools/colorcfg.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrOleContentPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ Primitive2DSequence aRetval;
+ const SdrOle2Obj* pSource = (mpSdrOle2Obj.is() ? static_cast< SdrOle2Obj* >(mpSdrOle2Obj.get()) : 0);
+ bool bScaleContent(false);
+ Graphic aGraphic;
+
+ if(pSource)
+ {
+ Graphic* pOLEGraphic = (getHighContrast())
+ ? pSource->getEmbeddedObjectRef().GetHCGraphic()
+ : pSource->GetGraphic();
+
+ if(pOLEGraphic)
+ {
+ aGraphic = *pOLEGraphic;
+ bScaleContent = pSource->IsEmptyPresObj();
+ }
+ }
+
+ if(GRAPHIC_NONE == aGraphic.GetType())
+ {
+ // no source, use fallback ressource emty OLE graphic
+ const Bitmap aEmptyOLEBitmap(SdrOle2Obj::GetEmtyOLEReplacementBitmap());
+ aGraphic = Graphic(aEmptyOLEBitmap);
+ bScaleContent = true;
+ }
+
+ if(GRAPHIC_NONE != aGraphic.GetType())
+ {
+ const GraphicObject aGraphicObject(aGraphic);
+ const GraphicAttr aGraphicAttr;
+ drawinglayer::primitive2d::Primitive2DSequence xOLEContent;
+
+ if(bScaleContent)
+ {
+ // get transformation atoms
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ getObjectTransform().decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // get PrefSize from the graphic in 100th mm
+ Size aPrefSize(aGraphic.GetPrefSize());
+
+ if(MAP_PIXEL == aGraphic.GetPrefMapMode().GetMapUnit())
+ {
+ aPrefSize = Application::GetDefaultDevice()->PixelToLogic(aPrefSize, MAP_100TH_MM);
+ }
+ else
+ {
+ aPrefSize = Application::GetDefaultDevice()->LogicToLogic(aPrefSize, aGraphic.GetPrefMapMode(), MAP_100TH_MM);
+ }
+
+ const double fOffsetX((aScale.getX() - aPrefSize.getWidth()) / 2.0);
+ const double fOffsetY((aScale.getY() - aPrefSize.getHeight()) / 2.0);
+
+ if(basegfx::fTools::moreOrEqual(fOffsetX, 0.0) && basegfx::fTools::moreOrEqual(fOffsetY, 0.0))
+ {
+ // if content fits into frame, create it
+ basegfx::B2DHomMatrix aInnerObjectMatrix(basegfx::tools::createScaleTranslateB2DHomMatrix(
+ aPrefSize.getWidth(), aPrefSize.getHeight(), fOffsetX, fOffsetY));
+ aInnerObjectMatrix = basegfx::tools::createShearXRotateTranslateB2DHomMatrix(fShearX, fRotate, aTranslate)
+ * aInnerObjectMatrix;
+
+ const drawinglayer::primitive2d::Primitive2DReference aGraphicPrimitive(
+ new drawinglayer::primitive2d::GraphicPrimitive2D(
+ aInnerObjectMatrix,
+ aGraphicObject,
+ aGraphicAttr));
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aGraphicPrimitive);
+ }
+ }
+ else
+ {
+ // create graphic primitive for content
+ const drawinglayer::primitive2d::Primitive2DReference aGraphicPrimitive(
+ new drawinglayer::primitive2d::GraphicPrimitive2D(
+ getObjectTransform(),
+ aGraphicObject,
+ aGraphicAttr));
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aGraphicPrimitive);
+ }
+
+ // a standard gray outline is created for scaled content
+ if(bScaleContent)
+ {
+ const svtools::ColorConfig aColorConfig;
+ const svtools::ColorConfigValue aColor(aColorConfig.GetColorValue(svtools::OBJECTBOUNDARIES));
+
+ if(aColor.bIsVisible)
+ {
+ basegfx::B2DPolygon aOutline(basegfx::tools::createUnitPolygon());
+ const Color aVclColor(aColor.nColor);
+ aOutline.transform(getObjectTransform());
+ const drawinglayer::primitive2d::Primitive2DReference xOutline(
+ new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aOutline, aVclColor.getBColor()));
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, xOutline);
+ }
+ }
+ }
+
+ // get graphic and check scale content state
+ return aRetval;
+ }
+
+ SdrOleContentPrimitive2D::SdrOleContentPrimitive2D(
+ const SdrOle2Obj& rSdrOle2Obj,
+ const basegfx::B2DHomMatrix& rObjectTransform,
+ sal_uInt32 nGraphicVersion,
+ bool bHighContrast)
+ : BufferedDecompositionPrimitive2D(),
+ mpSdrOle2Obj(const_cast< SdrOle2Obj* >(&rSdrOle2Obj)),
+ maObjectTransform(rObjectTransform),
+ mnGraphicVersion(nGraphicVersion),
+ mbHighContrast(bHighContrast)
+ {
+ }
+
+ bool SdrOleContentPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrOleContentPrimitive2D& rCompare = (SdrOleContentPrimitive2D&)rPrimitive;
+ const bool bBothNot(!mpSdrOle2Obj.is() && !rCompare.mpSdrOle2Obj.is());
+ const bool bBothAndEqual(mpSdrOle2Obj.is() && rCompare.mpSdrOle2Obj.is()
+ && mpSdrOle2Obj.get() == rCompare.mpSdrOle2Obj.get());
+
+ return ((bBothNot || bBothAndEqual)
+ && getObjectTransform() == rCompare.getObjectTransform()
+
+ // #i104867# to find out if the Graphic content of the
+ // OLE has changed, use GraphicVersion number
+ && getGraphicVersion() == rCompare.getGraphicVersion()
+
+ && getHighContrast() == rCompare.getHighContrast());
+ }
+
+ return false;
+ }
+
+ basegfx::B2DRange SdrOleContentPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const
+ {
+ basegfx::B2DRange aRange(0.0, 0.0, 1.0, 1.0);
+ aRange.transform(getObjectTransform());
+
+ return aRange;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrOleContentPrimitive2D, PRIMITIVE2D_ID_SDROLECONTENTPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
diff --git a/svx/source/sdr/primitive2d/sdrpathprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrpathprimitive2d.cxx
new file mode 100644
index 000000000000..2ceea2c69b7d
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrpathprimitive2d.cxx
@@ -0,0 +1,147 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrpathprimitive2d.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrPathPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ Primitive2DSequence aRetval;
+
+ // add fill
+ if(!getSdrLFSTAttribute().getFill().isDefault()
+ && getUnitPolyPolygon().isClosed())
+ {
+ // #i108255# no need to use correctOrientations here; target is
+ // straight visualisation
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolyPolygonFillPrimitive(
+ getUnitPolyPolygon(),
+ getTransform(),
+ getSdrLFSTAttribute().getFill(),
+ getSdrLFSTAttribute().getFillFloatTransGradient()));
+ }
+
+ // add line
+ if(getSdrLFSTAttribute().getLine().isDefault())
+ {
+ // if initially no line is defined, create one for HitTest and BoundRect
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ false,
+ getUnitPolyPolygon(),
+ getTransform()));
+ }
+ else
+ {
+ Primitive2DSequence aTemp(getUnitPolyPolygon().count());
+
+ for(sal_uInt32 a(0); a < getUnitPolyPolygon().count(); a++)
+ {
+ aTemp[a] = createPolygonLinePrimitive(
+ getUnitPolyPolygon().getB2DPolygon(a),
+ getTransform(),
+ getSdrLFSTAttribute().getLine(),
+ getSdrLFSTAttribute().getLineStartEnd());
+ }
+
+ appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, aTemp);
+ }
+
+ // add text
+ if(!getSdrLFSTAttribute().getText().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createTextPrimitive(
+ getUnitPolyPolygon(),
+ getTransform(),
+ getSdrLFSTAttribute().getText(),
+ getSdrLFSTAttribute().getLine(),
+ false,
+ false,
+ false));
+ }
+
+ // add shadow
+ if(!getSdrLFSTAttribute().getShadow().isDefault())
+ {
+ aRetval = createEmbeddedShadowPrimitive(
+ aRetval,
+ getSdrLFSTAttribute().getShadow());
+ }
+
+ return aRetval;
+ }
+
+ SdrPathPrimitive2D::SdrPathPrimitive2D(
+ const basegfx::B2DHomMatrix& rTransform,
+ const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute,
+ const basegfx::B2DPolyPolygon& rUnitPolyPolygon)
+ : BufferedDecompositionPrimitive2D(),
+ maTransform(rTransform),
+ maSdrLFSTAttribute(rSdrLFSTAttribute),
+ maUnitPolyPolygon(rUnitPolyPolygon)
+ {
+ }
+
+ bool SdrPathPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrPathPrimitive2D& rCompare = (SdrPathPrimitive2D&)rPrimitive;
+
+ return (getUnitPolyPolygon() == rCompare.getUnitPolyPolygon()
+ && getTransform() == rCompare.getTransform()
+ && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute());
+ }
+
+ return false;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrPathPrimitive2D, PRIMITIVE2D_ID_SDRPATHPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
diff --git a/svx/source/sdr/primitive2d/sdrprimitivetools.cxx b/svx/source/sdr/primitive2d/sdrprimitivetools.cxx
new file mode 100644
index 000000000000..8f188e9fcf6f
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrprimitivetools.cxx
@@ -0,0 +1,176 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrprimitivetools.hxx>
+#include <vcl/bmpacc.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/lazydelete.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+// helper methods
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ BitmapEx createDefaultCross_3x3(const basegfx::BColor& rBColor)
+ {
+ static vcl::DeleteOnDeinit< BitmapEx > aRetVal(0);
+ static basegfx::BColor aColor;
+ ::osl::Mutex m_mutex;
+
+ if(!aRetVal.get() || rBColor != aColor)
+ {
+ // copy values
+ aColor = rBColor;
+
+ // create bitmap
+ Bitmap aContent(Size(3, 3), 24);
+ Bitmap aMask(Size(3, 3), 1);
+ BitmapWriteAccess* pWContent = aContent.AcquireWriteAccess();
+ BitmapWriteAccess* pWMask = aMask.AcquireWriteAccess();
+ OSL_ENSURE(pWContent && pWMask, "No WriteAccess to bitmap (!)");
+ const Color aVCLColor(aColor);
+ const BitmapColor aPixColor(aVCLColor);
+ const BitmapColor aMaskColor(0x01);
+
+ // Y,X unusual order (!)
+ pWContent->SetPixel(0, 1, aPixColor);
+ pWContent->SetPixel(1, 0, aPixColor);
+ pWContent->SetPixel(1, 1, aPixColor);
+ pWContent->SetPixel(1, 2, aPixColor);
+ pWContent->SetPixel(2, 1, aPixColor);
+
+ pWMask->SetPixel(0, 0, aMaskColor);
+ pWMask->SetPixel(0, 2, aMaskColor);
+ pWMask->SetPixel(2, 0, aMaskColor);
+ pWMask->SetPixel(2, 2, aMaskColor);
+
+ aContent.ReleaseAccess(pWContent);
+ aMask.ReleaseAccess(pWMask);
+
+ // create and exchange at aRetVal
+ delete aRetVal.set(new BitmapEx(aContent, aMask));
+ }
+
+ return aRetVal.get() ? *aRetVal.get() : BitmapEx();
+ }
+
+ BitmapEx createDefaultGluepoint_7x7(const basegfx::BColor& rBColorA, const basegfx::BColor& rBColorB)
+ {
+ static vcl::DeleteOnDeinit< BitmapEx > aRetVal(0);
+ static basegfx::BColor aColorA;
+ static basegfx::BColor aColorB;
+ ::osl::Mutex m_mutex;
+
+ if(!aRetVal.get() || rBColorA != aColorA || rBColorB != aColorB)
+ {
+ // copy values
+ aColorA = rBColorA;
+ aColorB = rBColorB;
+
+ // create bitmap
+ Bitmap aContent(Size(7, 7), 24);
+ Bitmap aMask(Size(7, 7), 1);
+ BitmapWriteAccess* pWContent = aContent.AcquireWriteAccess();
+ BitmapWriteAccess* pWMask = aMask.AcquireWriteAccess();
+ OSL_ENSURE(pWContent && pWMask, "No WriteAccess to bitmap (!)");
+ const Color aColA(aColorA);
+ const Color aColB(aColorB);
+ const BitmapColor aPixColorA(aColA);
+ const BitmapColor aPixColorB(aColB);
+ const BitmapColor aMaskColor(0x01);
+
+ // Y,X unusual order (!)
+ pWContent->SetPixel(0, 1, aPixColorA);
+ pWContent->SetPixel(0, 5, aPixColorA);
+ pWContent->SetPixel(1, 0, aPixColorA);
+ pWContent->SetPixel(1, 2, aPixColorA);
+ pWContent->SetPixel(1, 4, aPixColorA);
+ pWContent->SetPixel(1, 6, aPixColorA);
+ pWContent->SetPixel(2, 1, aPixColorA);
+ pWContent->SetPixel(2, 3, aPixColorA);
+ pWContent->SetPixel(2, 5, aPixColorA);
+ pWContent->SetPixel(3, 2, aPixColorA);
+ pWContent->SetPixel(3, 4, aPixColorA);
+ pWContent->SetPixel(4, 1, aPixColorA);
+ pWContent->SetPixel(4, 3, aPixColorA);
+ pWContent->SetPixel(4, 5, aPixColorA);
+ pWContent->SetPixel(5, 0, aPixColorA);
+ pWContent->SetPixel(5, 2, aPixColorA);
+ pWContent->SetPixel(5, 4, aPixColorA);
+ pWContent->SetPixel(5, 6, aPixColorA);
+ pWContent->SetPixel(6, 1, aPixColorA);
+ pWContent->SetPixel(6, 5, aPixColorA);
+
+ pWContent->SetPixel(1, 1, aPixColorB);
+ pWContent->SetPixel(1, 5, aPixColorB);
+ pWContent->SetPixel(2, 2, aPixColorB);
+ pWContent->SetPixel(2, 4, aPixColorB);
+ pWContent->SetPixel(3, 3, aPixColorB);
+ pWContent->SetPixel(4, 2, aPixColorB);
+ pWContent->SetPixel(4, 4, aPixColorB);
+ pWContent->SetPixel(5, 1, aPixColorB);
+ pWContent->SetPixel(5, 5, aPixColorB);
+
+ pWMask->SetPixel(0, 0, aMaskColor);
+ pWMask->SetPixel(0, 2, aMaskColor);
+ pWMask->SetPixel(0, 3, aMaskColor);
+ pWMask->SetPixel(0, 4, aMaskColor);
+ pWMask->SetPixel(0, 6, aMaskColor);
+ pWMask->SetPixel(1, 3, aMaskColor);
+ pWMask->SetPixel(2, 0, aMaskColor);
+ pWMask->SetPixel(2, 6, aMaskColor);
+ pWMask->SetPixel(3, 0, aMaskColor);
+ pWMask->SetPixel(3, 1, aMaskColor);
+ pWMask->SetPixel(3, 5, aMaskColor);
+ pWMask->SetPixel(3, 6, aMaskColor);
+ pWMask->SetPixel(4, 0, aMaskColor);
+ pWMask->SetPixel(4, 6, aMaskColor);
+ pWMask->SetPixel(5, 3, aMaskColor);
+ pWMask->SetPixel(6, 0, aMaskColor);
+ pWMask->SetPixel(6, 2, aMaskColor);
+ pWMask->SetPixel(6, 3, aMaskColor);
+ pWMask->SetPixel(6, 4, aMaskColor);
+ pWMask->SetPixel(6, 6, aMaskColor);
+
+ aContent.ReleaseAccess(pWContent);
+ aMask.ReleaseAccess(pWMask);
+
+ // create and exchange at aRetVal
+ delete aRetVal.set(new BitmapEx(aContent, aMask));
+ }
+
+ return aRetVal.get() ? *aRetVal.get() : BitmapEx();
+ }
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
diff --git a/svx/source/sdr/primitive2d/sdrrectangleprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrrectangleprimitive2d.cxx
new file mode 100644
index 000000000000..60b8ca1c7817
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrrectangleprimitive2d.cxx
@@ -0,0 +1,162 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrrectangleprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrRectanglePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ Primitive2DSequence aRetval;
+
+ // create unit outline polygon
+ const basegfx::B2DPolygon aUnitOutline(basegfx::tools::createPolygonFromRect(
+ basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
+ getCornerRadiusX(),
+ getCornerRadiusY()));
+
+ // add fill
+ if(!getSdrLFSTAttribute().getFill().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolyPolygonFillPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getFill(),
+ getSdrLFSTAttribute().getFillFloatTransGradient()));
+ }
+ else if(getForceFillForHitTest())
+ {
+ // if no fill and it's a text frame, create a fill for HitTest and
+ // BoundRect fallback
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ true,
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform()));
+ }
+
+ // add line
+ if(!getSdrLFSTAttribute().getLine().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolygonLinePrimitive(
+ aUnitOutline,
+ getTransform(),
+ getSdrLFSTAttribute().getLine(),
+ attribute::SdrLineStartEndAttribute()));
+ }
+ else if(!getForceFillForHitTest())
+ {
+ // if initially no line is defined and it's not a text frame, create
+ // a line for HitTest and BoundRect
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ false,
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform()));
+ }
+
+ // add text
+ if(!getSdrLFSTAttribute().getText().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createTextPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getText(),
+ getSdrLFSTAttribute().getLine(),
+ false,
+ false,
+ false));
+ }
+
+ // add shadow
+ if(!getSdrLFSTAttribute().getShadow().isDefault())
+ {
+ aRetval = createEmbeddedShadowPrimitive(
+ aRetval,
+ getSdrLFSTAttribute().getShadow());
+ }
+
+ return aRetval;
+ }
+
+ SdrRectanglePrimitive2D::SdrRectanglePrimitive2D(
+ const basegfx::B2DHomMatrix& rTransform,
+ const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute,
+ double fCornerRadiusX,
+ double fCornerRadiusY,
+ bool bForceFillForHitTest)
+ : BufferedDecompositionPrimitive2D(),
+ maTransform(rTransform),
+ maSdrLFSTAttribute(rSdrLFSTAttribute),
+ mfCornerRadiusX(fCornerRadiusX),
+ mfCornerRadiusY(fCornerRadiusY),
+ mbForceFillForHitTest(bForceFillForHitTest)
+ {
+ }
+
+ bool SdrRectanglePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrRectanglePrimitive2D& rCompare = (SdrRectanglePrimitive2D&)rPrimitive;
+
+ return (getCornerRadiusX() == rCompare.getCornerRadiusX()
+ && getCornerRadiusY() == rCompare.getCornerRadiusY()
+ && getTransform() == rCompare.getTransform()
+ && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute()
+ && getForceFillForHitTest() == rCompare.getForceFillForHitTest());
+ }
+
+ return false;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrRectanglePrimitive2D, PRIMITIVE2D_ID_SDRRECTANGLEPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
diff --git a/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx
new file mode 100644
index 000000000000..089f75aa8ade
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx
@@ -0,0 +1,497 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrtextprimitive2d.hxx>
+#include <svx/svdotext.hxx>
+#include <basegfx/color/bcolor.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/texthierarchyprimitive2d.hxx>
+#include <editeng/outlobj.hxx>
+#include <editeng/editobj.hxx>
+#include <editeng/flditem.hxx>
+#include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <unoapi.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdoutl.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace
+{
+ sal_Int16 getPageNumber(const uno::Reference< drawing::XDrawPage >& rxDrawPage)
+ {
+ sal_Int16 nRetval(0);
+ uno::Reference< beans::XPropertySet > xSet(rxDrawPage, uno::UNO_QUERY);
+
+ if (xSet.is())
+ {
+ try
+ {
+ const uno::Any aNumber(xSet->getPropertyValue(::rtl::OUString::createFromAscii("Number")));
+ aNumber >>= nRetval;
+ }
+ catch(const uno::Exception&)
+ {
+ OSL_ASSERT(false);
+ }
+ }
+
+ return nRetval;
+ }
+
+ sal_Int16 getPageCount(const uno::Reference< drawing::XDrawPage >& rxDrawPage)
+ {
+ sal_Int16 nRetval(0);
+ SdrPage* pPage = GetSdrPageFromXDrawPage(rxDrawPage);
+
+ if(pPage && pPage->GetModel())
+ {
+ if( (pPage->GetPageNum() == 0) && !pPage->IsMasterPage() )
+ {
+ // handout page!
+ return pPage->GetModel()->getHandoutPageCount();
+ }
+ else
+ {
+ const sal_uInt16 nPageCount(pPage->GetModel()->GetPageCount());
+ nRetval = ((sal_Int16)nPageCount - 1) / 2;
+ }
+ }
+
+ return nRetval;
+ }
+} // end of anonymous namespace
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ // support for XTEXT_PAINTSHAPE_BEGIN/XTEXT_PAINTSHAPE_END Metafile comments
+ // for slideshow. This uses TextHierarchyBlockPrimitive2D to mark a text block.
+ // ATM there is only one text block per SdrObject, this may get more in the future
+ Primitive2DSequence SdrTextPrimitive2D::encapsulateWithTextHierarchyBlockPrimitive2D(const Primitive2DSequence& rCandidate) const
+ {
+ Primitive2DReference xReference(new TextHierarchyBlockPrimitive2D(rCandidate));
+ Primitive2DSequence xRetval(&xReference, 1);
+
+ return xRetval;
+ }
+
+ SdrTextPrimitive2D::SdrTextPrimitive2D(
+ const SdrText* pSdrText,
+ const OutlinerParaObject& rOutlinerParaObject)
+ : BufferedDecompositionPrimitive2D(),
+ mrSdrText(const_cast< SdrText* >(pSdrText)),
+ maOutlinerParaObject(rOutlinerParaObject),
+ mxLastVisualizingPage(),
+ mnLastPageNumber(0),
+ mnLastPageCount(0),
+ maLastTextBackgroundColor(),
+ mbContainsPageField(false),
+ mbContainsPageCountField(false),
+ mbContainsOtherFields(false)
+ {
+ const EditTextObject& rETO = maOutlinerParaObject.GetTextObject();
+
+ mbContainsPageField = rETO.HasField(SvxPageField::StaticType());
+ mbContainsPageCountField = rETO.HasField(SvxPagesField::StaticType());
+ mbContainsOtherFields = rETO.HasField(SvxHeaderField::StaticType())
+ || rETO.HasField(SvxFooterField::StaticType())
+ || rETO.HasField(SvxDateTimeField::StaticType())
+ || rETO.HasField(SvxAuthorField::StaticType());
+ }
+
+ bool SdrTextPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrTextPrimitive2D& rCompare = (SdrTextPrimitive2D&)rPrimitive;
+
+ return (
+
+ // compare OPO and content, but not WrongList
+ getOutlinerParaObject() == rCompare.getOutlinerParaObject()
+
+ // also compare WrongList (not-persistent data, but visualized)
+ && getOutlinerParaObject().isWrongListEqual(rCompare.getOutlinerParaObject()));
+ }
+
+ return false;
+ }
+
+ Primitive2DSequence SdrTextPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
+ {
+ uno::Reference< drawing::XDrawPage > xCurrentlyVisualizingPage;
+ bool bCurrentlyVisualizingPageIsSet(false);
+ Color aNewTextBackgroundColor;
+ bool bNewTextBackgroundColorIsSet(false);
+ sal_Int16 nCurrentlyValidPageNumber(0);
+ sal_Int16 nCurrentlyValidPageCount(0);
+
+ if(getBuffered2DDecomposition().hasElements())
+ {
+ bool bDoDelete(false);
+
+ // check visualized page
+ if(mbContainsPageField || mbContainsPageCountField || mbContainsOtherFields)
+ {
+ // get visualized page and remember
+ xCurrentlyVisualizingPage = rViewInformation.getVisualizedPage();
+ bCurrentlyVisualizingPageIsSet = true;
+
+ if(xCurrentlyVisualizingPage != mxLastVisualizingPage)
+ {
+ bDoDelete = true;
+ }
+
+ // #i98870# check visualized PageNumber
+ if(!bDoDelete && mbContainsPageField)
+ {
+ nCurrentlyValidPageNumber = getPageNumber(xCurrentlyVisualizingPage);
+
+ if(nCurrentlyValidPageNumber != mnLastPageNumber)
+ {
+ bDoDelete = true;
+ }
+ }
+
+ // #i98870# check visualized PageCount, too
+ if(!bDoDelete && mbContainsPageCountField)
+ {
+ nCurrentlyValidPageCount = getPageCount(xCurrentlyVisualizingPage);
+
+ if(nCurrentlyValidPageCount != mnLastPageCount)
+ {
+ bDoDelete = true;
+ }
+ }
+ }
+
+ // #i101443# check change of TextBackgroundolor
+ if(!bDoDelete && getSdrText() && getSdrText()->GetModel())
+ {
+ SdrOutliner& rDrawOutliner = getSdrText()->GetModel()->GetDrawOutliner(0);
+ aNewTextBackgroundColor = rDrawOutliner.GetBackgroundColor();
+ bNewTextBackgroundColorIsSet = true;
+
+ if(aNewTextBackgroundColor != maLastTextBackgroundColor)
+ {
+ bDoDelete = true;
+ }
+ }
+
+ if(bDoDelete)
+ {
+ const_cast< SdrTextPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence());
+ }
+ }
+
+ if(!getBuffered2DDecomposition().hasElements())
+ {
+ if(!bCurrentlyVisualizingPageIsSet && mbContainsPageField)
+ {
+ xCurrentlyVisualizingPage = rViewInformation.getVisualizedPage();
+ }
+
+ if(!nCurrentlyValidPageNumber && mbContainsPageField)
+ {
+ nCurrentlyValidPageNumber = getPageNumber(xCurrentlyVisualizingPage);
+ }
+
+ if(!nCurrentlyValidPageCount && mbContainsPageCountField)
+ {
+ nCurrentlyValidPageCount = getPageCount(xCurrentlyVisualizingPage);
+ }
+
+ if(!bNewTextBackgroundColorIsSet && getSdrText() && getSdrText()->GetModel())
+ {
+ SdrOutliner& rDrawOutliner = getSdrText()->GetModel()->GetDrawOutliner(0);
+ aNewTextBackgroundColor = rDrawOutliner.GetBackgroundColor();
+ }
+
+ const_cast< SdrTextPrimitive2D* >(this)->mxLastVisualizingPage = xCurrentlyVisualizingPage;
+ const_cast< SdrTextPrimitive2D* >(this)->mnLastPageNumber = nCurrentlyValidPageNumber;
+ const_cast< SdrTextPrimitive2D* >(this)->mnLastPageCount = nCurrentlyValidPageCount;
+ const_cast< SdrTextPrimitive2D* >(this)->maLastTextBackgroundColor = aNewTextBackgroundColor;
+ }
+
+ // call parent
+ return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
+ }
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrContourTextPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const
+ {
+ Primitive2DSequence aRetval;
+ getSdrText()->GetObject().impDecomposeContourTextPrimitive(aRetval, *this, aViewInformation);
+
+ return encapsulateWithTextHierarchyBlockPrimitive2D(aRetval);
+ }
+
+ SdrContourTextPrimitive2D::SdrContourTextPrimitive2D(
+ const SdrText* pSdrText,
+ const OutlinerParaObject& rOutlinerParaObject,
+ const basegfx::B2DPolyPolygon& rUnitPolyPolygon,
+ const basegfx::B2DHomMatrix& rObjectTransform)
+ : SdrTextPrimitive2D(pSdrText, rOutlinerParaObject),
+ maUnitPolyPolygon(rUnitPolyPolygon),
+ maObjectTransform(rObjectTransform)
+ {
+ }
+
+ bool SdrContourTextPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(SdrTextPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrContourTextPrimitive2D& rCompare = (SdrContourTextPrimitive2D&)rPrimitive;
+
+ return (getUnitPolyPolygon() == rCompare.getUnitPolyPolygon()
+ && getObjectTransform() == rCompare.getObjectTransform());
+ }
+
+ return false;
+ }
+
+ SdrTextPrimitive2D* SdrContourTextPrimitive2D::createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const
+ {
+ return new SdrContourTextPrimitive2D(
+ getSdrText(),
+ getOutlinerParaObject(),
+ getUnitPolyPolygon(),
+ rTransform * getObjectTransform());
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrContourTextPrimitive2D, PRIMITIVE2D_ID_SDRCONTOURTEXTPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrPathTextPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const
+ {
+ Primitive2DSequence aRetval;
+ getSdrText()->GetObject().impDecomposePathTextPrimitive(aRetval, *this, aViewInformation);
+
+ return encapsulateWithTextHierarchyBlockPrimitive2D(aRetval);
+ }
+
+ SdrPathTextPrimitive2D::SdrPathTextPrimitive2D(
+ const SdrText* pSdrText,
+ const OutlinerParaObject& rOutlinerParaObject,
+ const basegfx::B2DPolyPolygon& rPathPolyPolygon,
+ const attribute::SdrFormTextAttribute& rSdrFormTextAttribute)
+ : SdrTextPrimitive2D(pSdrText, rOutlinerParaObject),
+ maPathPolyPolygon(rPathPolyPolygon),
+ maSdrFormTextAttribute(rSdrFormTextAttribute)
+ {
+ }
+
+ bool SdrPathTextPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(SdrTextPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrPathTextPrimitive2D& rCompare = (SdrPathTextPrimitive2D&)rPrimitive;
+
+ return (getPathPolyPolygon() == rCompare.getPathPolyPolygon()
+ && getSdrFormTextAttribute() == rCompare.getSdrFormTextAttribute());
+ }
+
+ return false;
+ }
+
+ SdrTextPrimitive2D* SdrPathTextPrimitive2D::createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const
+ {
+ basegfx::B2DPolyPolygon aNewPolyPolygon(getPathPolyPolygon());
+ aNewPolyPolygon.transform(rTransform);
+
+ return new SdrPathTextPrimitive2D(
+ getSdrText(),
+ getOutlinerParaObject(),
+ aNewPolyPolygon,
+ getSdrFormTextAttribute());
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrPathTextPrimitive2D, PRIMITIVE2D_ID_SDRPATHTEXTPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrBlockTextPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const
+ {
+ Primitive2DSequence aRetval;
+ getSdrText()->GetObject().impDecomposeBlockTextPrimitive(aRetval, *this, aViewInformation);
+
+ return encapsulateWithTextHierarchyBlockPrimitive2D(aRetval);
+ }
+
+ SdrBlockTextPrimitive2D::SdrBlockTextPrimitive2D(
+ const SdrText* pSdrText,
+ const OutlinerParaObject& rOutlinerParaObject,
+ const basegfx::B2DHomMatrix& rTextRangeTransform,
+ SdrTextHorzAdjust aSdrTextHorzAdjust,
+ SdrTextVertAdjust aSdrTextVertAdjust,
+ bool bFixedCellHeight,
+ bool bUnlimitedPage,
+ bool bCellText,
+ bool bWordWrap,
+ bool bClipOnBounds)
+ : SdrTextPrimitive2D(pSdrText, rOutlinerParaObject),
+ maTextRangeTransform(rTextRangeTransform),
+ maSdrTextHorzAdjust(aSdrTextHorzAdjust),
+ maSdrTextVertAdjust(aSdrTextVertAdjust),
+ mbFixedCellHeight(bFixedCellHeight),
+ mbUnlimitedPage(bUnlimitedPage),
+ mbCellText(bCellText),
+ mbWordWrap(bWordWrap),
+ mbClipOnBounds(bClipOnBounds)
+ {
+ }
+
+ bool SdrBlockTextPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(SdrTextPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrBlockTextPrimitive2D& rCompare = (SdrBlockTextPrimitive2D&)rPrimitive;
+
+ return (getTextRangeTransform() == rCompare.getTextRangeTransform()
+ && getSdrTextHorzAdjust() == rCompare.getSdrTextHorzAdjust()
+ && getSdrTextVertAdjust() == rCompare.getSdrTextVertAdjust()
+ && isFixedCellHeight() == rCompare.isFixedCellHeight()
+ && getUnlimitedPage() == rCompare.getUnlimitedPage()
+ && getCellText() == rCompare.getCellText()
+ && getWordWrap() == rCompare.getWordWrap()
+ && getClipOnBounds() == rCompare.getClipOnBounds());
+ }
+
+ return false;
+ }
+
+ SdrTextPrimitive2D* SdrBlockTextPrimitive2D::createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const
+ {
+ return new SdrBlockTextPrimitive2D(
+ getSdrText(),
+ getOutlinerParaObject(),
+ rTransform * getTextRangeTransform(),
+ getSdrTextHorzAdjust(),
+ getSdrTextVertAdjust(),
+ isFixedCellHeight(),
+ getUnlimitedPage(),
+ getCellText(),
+ getWordWrap(),
+ getClipOnBounds());
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrBlockTextPrimitive2D, PRIMITIVE2D_ID_SDRBLOCKTEXTPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrStretchTextPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const
+ {
+ Primitive2DSequence aRetval;
+ getSdrText()->GetObject().impDecomposeStretchTextPrimitive(aRetval, *this, aViewInformation);
+
+ return encapsulateWithTextHierarchyBlockPrimitive2D(aRetval);
+ }
+
+ SdrStretchTextPrimitive2D::SdrStretchTextPrimitive2D(
+ const SdrText* pSdrText,
+ const OutlinerParaObject& rOutlinerParaObject,
+ const basegfx::B2DHomMatrix& rTextRangeTransform,
+ bool bFixedCellHeight)
+ : SdrTextPrimitive2D(pSdrText, rOutlinerParaObject),
+ maTextRangeTransform(rTextRangeTransform),
+ mbFixedCellHeight(bFixedCellHeight)
+ {
+ }
+
+ bool SdrStretchTextPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(SdrTextPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrStretchTextPrimitive2D& rCompare = (SdrStretchTextPrimitive2D&)rPrimitive;
+
+ return (getTextRangeTransform() == rCompare.getTextRangeTransform()
+ && isFixedCellHeight() == rCompare.isFixedCellHeight());
+ }
+
+ return false;
+ }
+
+ SdrTextPrimitive2D* SdrStretchTextPrimitive2D::createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const
+ {
+ return new SdrStretchTextPrimitive2D(
+ getSdrText(),
+ getOutlinerParaObject(),
+ rTransform * getTextRangeTransform(),
+ isFixedCellHeight());
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrStretchTextPrimitive2D, PRIMITIVE2D_ID_SDRSTRETCHTEXTPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof