xref: /AOO41X/main/sw/source/ui/docvw/AnchorOverlayObject.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /************************************************************************* *
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2008 by Sun Microsystems, Inc.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * $RCSfile: postit.cxx,v $
10*cdf0e10cSrcweir  * $Revision: 1.8.42.11 $
11*cdf0e10cSrcweir  *
12*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
13*cdf0e10cSrcweir  *
14*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
15*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
16*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
17*cdf0e10cSrcweir  *
18*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
19*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
22*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
23*cdf0e10cSrcweir  *
24*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
25*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
26*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
27*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
28*cdf0e10cSrcweir  *
29*cdf0e10cSrcweir  ************************************************************************/
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include "precompiled_sw.hxx"
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <AnchorOverlayObject.hxx>
35*cdf0e10cSrcweir #include <SidebarWindowsConsts.hxx>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include <swrect.hxx>
38*cdf0e10cSrcweir #include <view.hxx>
39*cdf0e10cSrcweir #include <svx/sdrpaintwindow.hxx>
40*cdf0e10cSrcweir #include <svx/svdview.hxx>
41*cdf0e10cSrcweir #include <svx/sdr/overlay/overlaymanager.hxx>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #include <sw_primitivetypes2d.hxx>
44*cdf0e10cSrcweir #include <drawinglayer/primitive2d/primitivetools2d.hxx>
45*cdf0e10cSrcweir #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
46*cdf0e10cSrcweir #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
47*cdf0e10cSrcweir #include <drawinglayer/primitive2d/shadowprimitive2d.hxx>
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir namespace sw { namespace sidebarwindows {
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
52*cdf0e10cSrcweir // helper class: Primitive for discrete visualisation
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir class AnchorPrimitive : public drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D
55*cdf0e10cSrcweir {
56*cdf0e10cSrcweir private:
57*cdf0e10cSrcweir     basegfx::B2DPolygon             maTriangle;
58*cdf0e10cSrcweir     basegfx::B2DPolygon             maLine;
59*cdf0e10cSrcweir     basegfx::B2DPolygon             maLineTop;
60*cdf0e10cSrcweir     const AnchorState               maAnchorState;
61*cdf0e10cSrcweir     basegfx::BColor                 maColor;
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir     // discrete line width
64*cdf0e10cSrcweir     double                          mfLogicLineWidth;
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir     // bitfield
67*cdf0e10cSrcweir     bool                            mbShadow : 1;
68*cdf0e10cSrcweir     bool                            mbLineSolid : 1;
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir protected:
71*cdf0e10cSrcweir     virtual drawinglayer::primitive2d::Primitive2DSequence create2DDecomposition(
72*cdf0e10cSrcweir         const drawinglayer::geometry::ViewInformation2D& rViewInformation) const;
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir public:
75*cdf0e10cSrcweir     AnchorPrimitive( const basegfx::B2DPolygon& rTriangle,
76*cdf0e10cSrcweir                      const basegfx::B2DPolygon& rLine,
77*cdf0e10cSrcweir                      const basegfx::B2DPolygon& rLineTop,
78*cdf0e10cSrcweir                      AnchorState aAnchorState,
79*cdf0e10cSrcweir                      const basegfx::BColor& rColor,
80*cdf0e10cSrcweir                      double fLogicLineWidth,
81*cdf0e10cSrcweir                      bool bShadow,
82*cdf0e10cSrcweir                      bool bLineSolid )
83*cdf0e10cSrcweir     :   drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D(),
84*cdf0e10cSrcweir         maTriangle(rTriangle),
85*cdf0e10cSrcweir         maLine(rLine),
86*cdf0e10cSrcweir         maLineTop(rLineTop),
87*cdf0e10cSrcweir         maAnchorState(aAnchorState),
88*cdf0e10cSrcweir         maColor(rColor),
89*cdf0e10cSrcweir         mfLogicLineWidth(fLogicLineWidth),
90*cdf0e10cSrcweir         mbShadow(bShadow),
91*cdf0e10cSrcweir         mbLineSolid(bLineSolid)
92*cdf0e10cSrcweir     {}
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     // data access
95*cdf0e10cSrcweir     const basegfx::B2DPolygon& getTriangle() const { return maTriangle; }
96*cdf0e10cSrcweir     const basegfx::B2DPolygon& getLine() const { return maLine; }
97*cdf0e10cSrcweir     const basegfx::B2DPolygon& getLineTop() const { return maLineTop; }
98*cdf0e10cSrcweir     AnchorState getAnchorState() const { return maAnchorState; }
99*cdf0e10cSrcweir     const basegfx::BColor& getColor() const { return maColor; }
100*cdf0e10cSrcweir     double getLogicLineWidth() const { return mfLogicLineWidth; }
101*cdf0e10cSrcweir     bool getShadow() const { return mbShadow; }
102*cdf0e10cSrcweir     bool getLineSolid() const { return mbLineSolid; }
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir     virtual bool operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const;
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir     DeclPrimitrive2DIDBlock()
107*cdf0e10cSrcweir };
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence AnchorPrimitive::create2DDecomposition(
110*cdf0e10cSrcweir     const drawinglayer::geometry::ViewInformation2D& /*rViewInformation*/) const
111*cdf0e10cSrcweir {
112*cdf0e10cSrcweir     drawinglayer::primitive2d::Primitive2DSequence aRetval;
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir     if ( AS_TRI == maAnchorState ||
115*cdf0e10cSrcweir          AS_ALL == maAnchorState ||
116*cdf0e10cSrcweir          AS_START == maAnchorState )
117*cdf0e10cSrcweir     {
118*cdf0e10cSrcweir         // create triangle
119*cdf0e10cSrcweir         const drawinglayer::primitive2d::Primitive2DReference aTriangle(
120*cdf0e10cSrcweir             new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
121*cdf0e10cSrcweir                 basegfx::B2DPolyPolygon(getTriangle()),
122*cdf0e10cSrcweir                 getColor()));
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir         drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aTriangle);
125*cdf0e10cSrcweir     }
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir     if ( AS_ALL == maAnchorState ||
128*cdf0e10cSrcweir          AS_START == maAnchorState )
129*cdf0e10cSrcweir     {
130*cdf0e10cSrcweir         // create line start
131*cdf0e10cSrcweir         const drawinglayer::attribute::LineAttribute aLineAttribute(
132*cdf0e10cSrcweir             getColor(),
133*cdf0e10cSrcweir             getLogicLineWidth() / (basegfx::fTools::equalZero(getDiscreteUnit()) ? 1.0 : getDiscreteUnit()));
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir         if(getLineSolid())
136*cdf0e10cSrcweir         {
137*cdf0e10cSrcweir             const drawinglayer::primitive2d::Primitive2DReference aSolidLine(
138*cdf0e10cSrcweir                 new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
139*cdf0e10cSrcweir                     getLine(),
140*cdf0e10cSrcweir                     aLineAttribute));
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir             drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aSolidLine);
143*cdf0e10cSrcweir         }
144*cdf0e10cSrcweir         else
145*cdf0e10cSrcweir         {
146*cdf0e10cSrcweir             ::std::vector< double > aDotDashArray;
147*cdf0e10cSrcweir             const double fDistance(3.0 * 15.0);
148*cdf0e10cSrcweir             const double fDashLen(5.0 * 15.0);
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir             aDotDashArray.push_back(fDashLen);
151*cdf0e10cSrcweir             aDotDashArray.push_back(fDistance);
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir             const drawinglayer::attribute::StrokeAttribute aStrokeAttribute(
154*cdf0e10cSrcweir                 aDotDashArray,
155*cdf0e10cSrcweir                 fDistance + fDashLen);
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir             const drawinglayer::primitive2d::Primitive2DReference aStrokedLine(
158*cdf0e10cSrcweir                 new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
159*cdf0e10cSrcweir                     getLine(),
160*cdf0e10cSrcweir                     aLineAttribute,
161*cdf0e10cSrcweir                     aStrokeAttribute));
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir             drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aStrokedLine);
164*cdf0e10cSrcweir         }
165*cdf0e10cSrcweir     }
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir     if(aRetval.hasElements() && getShadow())
168*cdf0e10cSrcweir     {
169*cdf0e10cSrcweir         // shadow is only for triangle and line start, and in upper left
170*cdf0e10cSrcweir         // and lower right direction, in different colors
171*cdf0e10cSrcweir         const double fColorChange(20.0 / 255.0);
172*cdf0e10cSrcweir         const basegfx::B3DTuple aColorChange(fColorChange, fColorChange, fColorChange);
173*cdf0e10cSrcweir         basegfx::BColor aLighterColor(getColor() + aColorChange);
174*cdf0e10cSrcweir         basegfx::BColor aDarkerColor(getColor() - aColorChange);
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir         aLighterColor.clamp();
177*cdf0e10cSrcweir         aDarkerColor.clamp();
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir         // create shadow sequence
180*cdf0e10cSrcweir         drawinglayer::primitive2d::Primitive2DSequence aShadows(2);
181*cdf0e10cSrcweir         basegfx::B2DHomMatrix aTransform;
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir         aTransform.set(0, 2, -getDiscreteUnit());
184*cdf0e10cSrcweir         aTransform.set(1, 2, -getDiscreteUnit());
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir         aShadows[0] = drawinglayer::primitive2d::Primitive2DReference(
187*cdf0e10cSrcweir             new drawinglayer::primitive2d::ShadowPrimitive2D(
188*cdf0e10cSrcweir                 aTransform,
189*cdf0e10cSrcweir                 aLighterColor,
190*cdf0e10cSrcweir                 aRetval));
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir         aTransform.set(0, 2, getDiscreteUnit());
193*cdf0e10cSrcweir         aTransform.set(1, 2, getDiscreteUnit());
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir         aShadows[1] = drawinglayer::primitive2d::Primitive2DReference(
196*cdf0e10cSrcweir             new drawinglayer::primitive2d::ShadowPrimitive2D(
197*cdf0e10cSrcweir                 aTransform,
198*cdf0e10cSrcweir                 aDarkerColor,
199*cdf0e10cSrcweir                 aRetval));
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir         // add shadow before geometry to make it be proccessed first
202*cdf0e10cSrcweir         const drawinglayer::primitive2d::Primitive2DSequence aTemporary(aRetval);
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir         aRetval = aShadows;
205*cdf0e10cSrcweir         drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, aTemporary);
206*cdf0e10cSrcweir     }
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir     if ( AS_ALL == maAnchorState ||
209*cdf0e10cSrcweir          AS_END == maAnchorState )
210*cdf0e10cSrcweir     {
211*cdf0e10cSrcweir         // LineTop has to be created, too, but uses no shadow, so add after
212*cdf0e10cSrcweir         // the other parts are created
213*cdf0e10cSrcweir         const drawinglayer::attribute::LineAttribute aLineAttribute(
214*cdf0e10cSrcweir             getColor(),
215*cdf0e10cSrcweir             getLogicLineWidth() / (basegfx::fTools::equalZero(getDiscreteUnit()) ? 1.0 : getDiscreteUnit()));
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir         const drawinglayer::primitive2d::Primitive2DReference aLineTop(
218*cdf0e10cSrcweir             new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
219*cdf0e10cSrcweir                 getLineTop(),
220*cdf0e10cSrcweir                 aLineAttribute));
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir         drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aLineTop);
223*cdf0e10cSrcweir     }
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir     return aRetval;
226*cdf0e10cSrcweir }
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir bool AnchorPrimitive::operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const
229*cdf0e10cSrcweir {
230*cdf0e10cSrcweir     if(drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
231*cdf0e10cSrcweir     {
232*cdf0e10cSrcweir         const AnchorPrimitive& rCompare = static_cast< const AnchorPrimitive& >(rPrimitive);
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir         return (getTriangle() == rCompare.getTriangle()
235*cdf0e10cSrcweir             && getLine() == rCompare.getLine()
236*cdf0e10cSrcweir             && getLineTop() == rCompare.getLineTop()
237*cdf0e10cSrcweir             && getAnchorState() == rCompare.getAnchorState()
238*cdf0e10cSrcweir             && getColor() == rCompare.getColor()
239*cdf0e10cSrcweir             && getLogicLineWidth() == rCompare.getLogicLineWidth()
240*cdf0e10cSrcweir             && getShadow() == rCompare.getShadow()
241*cdf0e10cSrcweir             && getLineSolid() == rCompare.getLineSolid());
242*cdf0e10cSrcweir     }
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir     return false;
245*cdf0e10cSrcweir }
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir ImplPrimitrive2DIDBlock(AnchorPrimitive, PRIMITIVE2D_ID_SWSIDEBARANCHORPRIMITIVE)
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir /****** AnchorOverlayObject    ***********************************************************/
250*cdf0e10cSrcweir /*static*/ AnchorOverlayObject* AnchorOverlayObject::CreateAnchorOverlayObject(
251*cdf0e10cSrcweir                                                        SwView& rDocView,
252*cdf0e10cSrcweir                                                        const SwRect& aAnchorRect,
253*cdf0e10cSrcweir                                                        const long& aPageBorder,
254*cdf0e10cSrcweir                                                        const Point& aLineStart,
255*cdf0e10cSrcweir                                                        const Point& aLineEnd,
256*cdf0e10cSrcweir                                                        const Color& aColorAnchor )
257*cdf0e10cSrcweir {
258*cdf0e10cSrcweir     AnchorOverlayObject* pAnchorOverlayObject( 0 );
259*cdf0e10cSrcweir     if ( rDocView.GetDrawView() )
260*cdf0e10cSrcweir     {
261*cdf0e10cSrcweir         SdrPaintWindow* pPaintWindow = rDocView.GetDrawView()->GetPaintWindow(0);
262*cdf0e10cSrcweir         if( pPaintWindow )
263*cdf0e10cSrcweir         {
264*cdf0e10cSrcweir             sdr::overlay::OverlayManager* pOverlayManager = pPaintWindow->GetOverlayManager();
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir             if ( pOverlayManager )
267*cdf0e10cSrcweir             {
268*cdf0e10cSrcweir                 pAnchorOverlayObject = new AnchorOverlayObject(
269*cdf0e10cSrcweir                     basegfx::B2DPoint( aAnchorRect.Left() , aAnchorRect.Bottom()-5*15),
270*cdf0e10cSrcweir                     basegfx::B2DPoint( aAnchorRect.Left()-5*15 , aAnchorRect.Bottom()+5*15),
271*cdf0e10cSrcweir                     basegfx::B2DPoint( aAnchorRect.Left()+5*15 , aAnchorRect.Bottom()+5*15),
272*cdf0e10cSrcweir                     basegfx::B2DPoint( aAnchorRect.Left(), aAnchorRect.Bottom()+2*15),
273*cdf0e10cSrcweir                     basegfx::B2DPoint( aPageBorder ,aAnchorRect.Bottom()+2*15),
274*cdf0e10cSrcweir                     basegfx::B2DPoint( aLineStart.X(),aLineStart.Y()),
275*cdf0e10cSrcweir                     basegfx::B2DPoint( aLineEnd.X(),aLineEnd.Y()) ,
276*cdf0e10cSrcweir                     aColorAnchor,
277*cdf0e10cSrcweir                     false,
278*cdf0e10cSrcweir                     false);
279*cdf0e10cSrcweir                 pOverlayManager->add(*pAnchorOverlayObject);
280*cdf0e10cSrcweir             }
281*cdf0e10cSrcweir         }
282*cdf0e10cSrcweir     }
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir     return pAnchorOverlayObject;
285*cdf0e10cSrcweir }
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir /*static*/ void AnchorOverlayObject::DestroyAnchorOverlayObject( AnchorOverlayObject* pAnchor )
288*cdf0e10cSrcweir {
289*cdf0e10cSrcweir     if ( pAnchor )
290*cdf0e10cSrcweir     {
291*cdf0e10cSrcweir         if ( pAnchor->getOverlayManager() )
292*cdf0e10cSrcweir         {
293*cdf0e10cSrcweir             // remove this object from the chain
294*cdf0e10cSrcweir             pAnchor->getOverlayManager()->remove(*pAnchor);
295*cdf0e10cSrcweir         }
296*cdf0e10cSrcweir         delete pAnchor;
297*cdf0e10cSrcweir     }
298*cdf0e10cSrcweir }
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir AnchorOverlayObject::AnchorOverlayObject( const basegfx::B2DPoint& rBasePos,
301*cdf0e10cSrcweir                                           const basegfx::B2DPoint& rSecondPos,
302*cdf0e10cSrcweir                                           const basegfx::B2DPoint& rThirdPos,
303*cdf0e10cSrcweir                                           const basegfx::B2DPoint& rFourthPos,
304*cdf0e10cSrcweir                                           const basegfx::B2DPoint& rFifthPos,
305*cdf0e10cSrcweir                                           const basegfx::B2DPoint& rSixthPos,
306*cdf0e10cSrcweir                                           const basegfx::B2DPoint& rSeventhPos,
307*cdf0e10cSrcweir                                           const Color aBaseColor,
308*cdf0e10cSrcweir                                           const bool bShadowedEffect,
309*cdf0e10cSrcweir                                           const bool bLineSolid)
310*cdf0e10cSrcweir     : OverlayObjectWithBasePosition( rBasePos, aBaseColor )
311*cdf0e10cSrcweir     , maSecondPosition(rSecondPos)
312*cdf0e10cSrcweir     , maThirdPosition(rThirdPos)
313*cdf0e10cSrcweir     , maFourthPosition(rFourthPos)
314*cdf0e10cSrcweir     , maFifthPosition(rFifthPos)
315*cdf0e10cSrcweir     , maSixthPosition(rSixthPos)
316*cdf0e10cSrcweir     , maSeventhPosition(rSeventhPos)
317*cdf0e10cSrcweir     , maTriangle()
318*cdf0e10cSrcweir     , maLine()
319*cdf0e10cSrcweir     , maLineTop()
320*cdf0e10cSrcweir     , mHeight(0)
321*cdf0e10cSrcweir     , mAnchorState(AS_ALL)
322*cdf0e10cSrcweir     , mbShadowedEffect(bShadowedEffect)
323*cdf0e10cSrcweir     , mbLineSolid(bLineSolid)
324*cdf0e10cSrcweir {
325*cdf0e10cSrcweir }
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir AnchorOverlayObject::~AnchorOverlayObject()
328*cdf0e10cSrcweir {
329*cdf0e10cSrcweir }
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir void AnchorOverlayObject::implEnsureGeometry()
332*cdf0e10cSrcweir {
333*cdf0e10cSrcweir     if(!maTriangle.count())
334*cdf0e10cSrcweir     {
335*cdf0e10cSrcweir         maTriangle.append(getBasePosition());
336*cdf0e10cSrcweir         maTriangle.append(GetSecondPosition());
337*cdf0e10cSrcweir         maTriangle.append(GetThirdPosition());
338*cdf0e10cSrcweir         maTriangle.setClosed(true);
339*cdf0e10cSrcweir     }
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir     if(!maLine.count())
342*cdf0e10cSrcweir     {
343*cdf0e10cSrcweir         maLine.append(GetFourthPosition());
344*cdf0e10cSrcweir         maLine.append(GetFifthPosition());
345*cdf0e10cSrcweir         maLine.append(GetSixthPosition());
346*cdf0e10cSrcweir     }
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir   if(!maLineTop.count())
349*cdf0e10cSrcweir     {
350*cdf0e10cSrcweir         maLineTop.append(GetSixthPosition());
351*cdf0e10cSrcweir         maLineTop.append(GetSeventhPosition());
352*cdf0e10cSrcweir     }
353*cdf0e10cSrcweir }
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir void AnchorOverlayObject::implResetGeometry()
356*cdf0e10cSrcweir {
357*cdf0e10cSrcweir     maTriangle.clear();
358*cdf0e10cSrcweir     maLine.clear();
359*cdf0e10cSrcweir     maLineTop.clear();
360*cdf0e10cSrcweir }
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence AnchorOverlayObject::createOverlayObjectPrimitive2DSequence()
363*cdf0e10cSrcweir {
364*cdf0e10cSrcweir     implEnsureGeometry();
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir     const drawinglayer::primitive2d::Primitive2DReference aReference(
367*cdf0e10cSrcweir         new AnchorPrimitive( maTriangle,
368*cdf0e10cSrcweir                              maLine,
369*cdf0e10cSrcweir                              maLineTop,
370*cdf0e10cSrcweir                              GetAnchorState(),
371*cdf0e10cSrcweir                              getBaseColor().getBColor(),
372*cdf0e10cSrcweir                              ANCHORLINE_WIDTH * 15.0,
373*cdf0e10cSrcweir                              getShadowedEffect(),
374*cdf0e10cSrcweir                              getLineSolid()) );
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir     return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
377*cdf0e10cSrcweir }
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir void AnchorOverlayObject::SetAllPosition( const basegfx::B2DPoint& rPoint1,
380*cdf0e10cSrcweir                                           const basegfx::B2DPoint& rPoint2,
381*cdf0e10cSrcweir                                           const basegfx::B2DPoint& rPoint3,
382*cdf0e10cSrcweir                                           const basegfx::B2DPoint& rPoint4,
383*cdf0e10cSrcweir                                           const basegfx::B2DPoint& rPoint5,
384*cdf0e10cSrcweir                                           const basegfx::B2DPoint& rPoint6,
385*cdf0e10cSrcweir                                           const basegfx::B2DPoint& rPoint7)
386*cdf0e10cSrcweir {
387*cdf0e10cSrcweir     if ( rPoint1 != getBasePosition() ||
388*cdf0e10cSrcweir          rPoint2 != GetSecondPosition() ||
389*cdf0e10cSrcweir          rPoint3 != GetThirdPosition() ||
390*cdf0e10cSrcweir          rPoint4 != GetFourthPosition() ||
391*cdf0e10cSrcweir          rPoint5 != GetFifthPosition() ||
392*cdf0e10cSrcweir          rPoint6 != GetSixthPosition() ||
393*cdf0e10cSrcweir          rPoint7 != GetSeventhPosition() )
394*cdf0e10cSrcweir     {
395*cdf0e10cSrcweir         maBasePosition = rPoint1;
396*cdf0e10cSrcweir         maSecondPosition = rPoint2;
397*cdf0e10cSrcweir         maThirdPosition = rPoint3;
398*cdf0e10cSrcweir         maFourthPosition = rPoint4;
399*cdf0e10cSrcweir         maFifthPosition = rPoint5;
400*cdf0e10cSrcweir         maSixthPosition = rPoint6;
401*cdf0e10cSrcweir         maSeventhPosition = rPoint7;
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir         implResetGeometry();
404*cdf0e10cSrcweir         objectChange();
405*cdf0e10cSrcweir     }
406*cdf0e10cSrcweir }
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir void AnchorOverlayObject::SetSixthPosition(const basegfx::B2DPoint& rNew)
409*cdf0e10cSrcweir {
410*cdf0e10cSrcweir   if(rNew != maSixthPosition)
411*cdf0e10cSrcweir   {
412*cdf0e10cSrcweir       maSixthPosition = rNew;
413*cdf0e10cSrcweir         implResetGeometry();
414*cdf0e10cSrcweir       objectChange();
415*cdf0e10cSrcweir   }
416*cdf0e10cSrcweir }
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir void AnchorOverlayObject::SetSeventhPosition(const basegfx::B2DPoint& rNew)
419*cdf0e10cSrcweir {
420*cdf0e10cSrcweir   if(rNew != maSeventhPosition)
421*cdf0e10cSrcweir   {
422*cdf0e10cSrcweir       maSeventhPosition = rNew;
423*cdf0e10cSrcweir         implResetGeometry();
424*cdf0e10cSrcweir       objectChange();
425*cdf0e10cSrcweir   }
426*cdf0e10cSrcweir }
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir void AnchorOverlayObject::SetTriPosition(const basegfx::B2DPoint& rPoint1,const basegfx::B2DPoint& rPoint2,const basegfx::B2DPoint& rPoint3,
429*cdf0e10cSrcweir                                   const basegfx::B2DPoint& rPoint4,const basegfx::B2DPoint& rPoint5)
430*cdf0e10cSrcweir {
431*cdf0e10cSrcweir     if(rPoint1 != getBasePosition()
432*cdf0e10cSrcweir         || rPoint2 != GetSecondPosition()
433*cdf0e10cSrcweir         || rPoint3 != GetThirdPosition()
434*cdf0e10cSrcweir         || rPoint4 != GetFourthPosition()
435*cdf0e10cSrcweir         || rPoint5 != GetFifthPosition())
436*cdf0e10cSrcweir     {
437*cdf0e10cSrcweir       maBasePosition = rPoint1;
438*cdf0e10cSrcweir       maSecondPosition = rPoint2;
439*cdf0e10cSrcweir       maThirdPosition = rPoint3;
440*cdf0e10cSrcweir       maFourthPosition = rPoint4;
441*cdf0e10cSrcweir       maFifthPosition = rPoint5;
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir       implResetGeometry();
444*cdf0e10cSrcweir       objectChange();
445*cdf0e10cSrcweir     }
446*cdf0e10cSrcweir }
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir void AnchorOverlayObject::setLineSolid( const bool bNew )
449*cdf0e10cSrcweir {
450*cdf0e10cSrcweir   if ( bNew != getLineSolid() )
451*cdf0e10cSrcweir   {
452*cdf0e10cSrcweir       mbLineSolid = bNew;
453*cdf0e10cSrcweir       objectChange();
454*cdf0e10cSrcweir   }
455*cdf0e10cSrcweir }
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir void AnchorOverlayObject::SetAnchorState( const AnchorState aState)
458*cdf0e10cSrcweir {
459*cdf0e10cSrcweir   if ( mAnchorState != aState)
460*cdf0e10cSrcweir   {
461*cdf0e10cSrcweir       mAnchorState = aState;
462*cdf0e10cSrcweir       objectChange();
463*cdf0e10cSrcweir   }
464*cdf0e10cSrcweir }
465*cdf0e10cSrcweir 
466*cdf0e10cSrcweir } } // end of namespace sw::annotation
467*cdf0e10cSrcweir 
468