1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _ANCHOROVERLAYOBJECT_HXX
25 #define _ANCHOROVERLAYOBJECT_HXX
26 
27 #include <svx/sdr/overlay/overlayobject.hxx>
28 
29 #include <basegfx/polygon/b2dpolygon.hxx>
30 
31 class SwView;
32 class SwRect;
33 class Point;
34 
35 namespace sw { namespace sidebarwindows {
36 
37 enum AnchorState
38 {
39     AS_ALL,
40     AS_START,
41     AS_END,
42     AS_TRI
43 };
44 
45 class AnchorOverlayObject: public sdr::overlay::OverlayObjectWithBasePosition
46 {
47     public:
48         static AnchorOverlayObject* CreateAnchorOverlayObject( SwView& rDocView,
49                                                                const SwRect& aAnchorRect,
50                                                                const long& aPageBorder,
51                                                                const Point& aLineStart,
52                                                                const Point& aLineEnd,
53                                                                const Color& aColorAnchor );
54         static void DestroyAnchorOverlayObject( AnchorOverlayObject* pAnchor );
55 
GetSecondPosition() const56         inline const basegfx::B2DPoint& GetSecondPosition() const { return maSecondPosition; }
GetThirdPosition() const57         const basegfx::B2DPoint& GetThirdPosition() const { return maThirdPosition; }
GetFourthPosition() const58         const basegfx::B2DPoint& GetFourthPosition() const { return maFourthPosition; }
GetFifthPosition() const59         const basegfx::B2DPoint& GetFifthPosition() const { return maFifthPosition; }
GetSixthPosition() const60         const basegfx::B2DPoint& GetSixthPosition() const { return maSixthPosition; }
GetSeventhPosition() const61         const basegfx::B2DPoint& GetSeventhPosition() const { return maSeventhPosition; }
62 
63         void SetAllPosition( const basegfx::B2DPoint& rPoint1,
64                              const basegfx::B2DPoint& rPoint2,
65                              const basegfx::B2DPoint& rPoint3,
66                              const basegfx::B2DPoint& rPoint4,
67                              const basegfx::B2DPoint& rPoint5,
68                              const basegfx::B2DPoint& rPoint6,
69                              const basegfx::B2DPoint& rPoint7 );
70         void SetTriPosition( const basegfx::B2DPoint& rPoint1,
71                              const basegfx::B2DPoint& rPoint2,
72                              const basegfx::B2DPoint& rPoint3,
73                              const basegfx::B2DPoint& rPoint4,
74                              const basegfx::B2DPoint& rPoint5 );
75         void SetSixthPosition( const basegfx::B2DPoint& rNew );
76         void SetSeventhPosition( const basegfx::B2DPoint& rNew );
77 
78         void setLineSolid( const bool bNew );
getLineSolid() const79         inline bool getLineSolid() const { return mbLineSolid; }
80 
SetHeight(const unsigned long aHeight)81         inline void SetHeight( const unsigned long aHeight ) { mHeight = aHeight; };
82 
getShadowedEffect() const83         bool getShadowedEffect() const { return mbShadowedEffect; }
84 
85         void SetAnchorState( const AnchorState aState );
GetAnchorState() const86         inline AnchorState GetAnchorState() const { return mAnchorState; }
87 
88     protected:
89         /*                        6------------7
90              1                   /
91             /4\ ---------------5
92            2 - 3
93         */
94 
95         basegfx::B2DPoint maSecondPosition;
96         basegfx::B2DPoint maThirdPosition;
97         basegfx::B2DPoint maFourthPosition;
98         basegfx::B2DPoint maFifthPosition;
99         basegfx::B2DPoint maSixthPosition;
100         basegfx::B2DPoint maSeventhPosition;
101 
102         // helpers to fill and reset geometry
103         void implEnsureGeometry();
104         void implResetGeometry();
105 
106         // geometry creation for OverlayObject
107         virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence();
108 
109     private:
110         // object's geometry
111         basegfx::B2DPolygon maTriangle;
112         basegfx::B2DPolygon maLine;
113         basegfx::B2DPolygon maLineTop;
114         unsigned long mHeight;
115         AnchorState mAnchorState;
116 
117         bool mbShadowedEffect : 1;
118         bool mbLineSolid : 1;
119 
120         AnchorOverlayObject( const basegfx::B2DPoint& rBasePos,
121                              const basegfx::B2DPoint& rSecondPos,
122                              const basegfx::B2DPoint& rThirdPos,
123                              const basegfx::B2DPoint& rFourthPos,
124                              const basegfx::B2DPoint& rFifthPos,
125                              const basegfx::B2DPoint& rSixthPos,
126                              const basegfx::B2DPoint& rSeventhPos,
127                              const Color aBaseColor,
128                              const bool bShadowedEffect,
129                              const bool bLineSolid );
130         virtual ~AnchorOverlayObject();
131 };
132 
133 } } // end of namespace sw::annotation
134 
135 #endif
136