merge the formfield patch from ooo-build
[ooovba.git] / svx / source / sdr / primitive2d / sdrcustomshapeprimitive2d.cxx
blob2a433ecaddb5c2bcc570dd5552b6f37a05782679
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sdrcustomshapeprimitive2d.cxx,v $
11 * $Revision: 1.2.18.1 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #include "precompiled_svx.hxx"
33 #include <svx/sdr/primitive2d/sdrcustomshapeprimitive2d.hxx>
34 #include <basegfx/polygon/b2dpolygon.hxx>
35 #include <basegfx/polygon/b2dpolygontools.hxx>
36 #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
37 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
38 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
40 //////////////////////////////////////////////////////////////////////////////
42 using namespace com::sun::star;
44 //////////////////////////////////////////////////////////////////////////////
46 namespace drawinglayer
48 namespace primitive2d
50 Primitive2DSequence SdrCustomShapePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
52 Primitive2DSequence aRetval(getSubPrimitives());
54 // add text
55 if(getSdrSTAttribute().getText())
57 const basegfx::B2DPolygon aUnitOutline(basegfx::tools::createPolygonFromRect(basegfx::B2DRange(0.0, 0.0, 1.0, 1.0)));
58 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, createTextPrimitive(
59 basegfx::B2DPolyPolygon(aUnitOutline),
60 getTextBox(),
61 *getSdrSTAttribute().getText(),
63 isForceTextClipToTextRange(), // #SJ# use CellText mode; text upper-left
64 getWordWrap()));
67 // add shadow
68 if(aRetval.hasElements() && getSdrSTAttribute().getShadow())
70 aRetval = createEmbeddedShadowPrimitive(aRetval, *getSdrSTAttribute().getShadow());
73 return aRetval;
76 SdrCustomShapePrimitive2D::SdrCustomShapePrimitive2D(
77 const attribute::SdrShadowTextAttribute& rSdrSTAttribute,
78 const Primitive2DSequence& rSubPrimitives,
79 const basegfx::B2DHomMatrix& rTextBox,
80 bool bWordWrap,
81 bool bForceTextClipToTextRange)
82 : BasePrimitive2D(),
83 maSdrSTAttribute(rSdrSTAttribute),
84 maSubPrimitives(rSubPrimitives),
85 maTextBox(rTextBox),
86 mbWordWrap(bWordWrap),
87 mbForceTextClipToTextRange(bForceTextClipToTextRange)
91 bool SdrCustomShapePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
93 if(BasePrimitive2D::operator==(rPrimitive))
95 const SdrCustomShapePrimitive2D& rCompare = (SdrCustomShapePrimitive2D&)rPrimitive;
97 return (getSdrSTAttribute() == rCompare.getSdrSTAttribute()
98 && getSubPrimitives() == rCompare.getSubPrimitives()
99 && getTextBox() == rCompare.getTextBox()
100 && getWordWrap() == rCompare.getWordWrap()
101 && isForceTextClipToTextRange() == rCompare.isForceTextClipToTextRange());
104 return false;
107 // provide unique ID
108 ImplPrimitrive2DIDBlock(SdrCustomShapePrimitive2D, PRIMITIVE2D_ID_SDRCUSTOMSHAPEPRIMITIVE2D)
110 } // end of namespace primitive2d
111 } // end of namespace drawinglayer
113 //////////////////////////////////////////////////////////////////////////////
114 // eof