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