xref: /trunk/main/sw/inc/anchoreddrawobject.hxx (revision 1d2dbeb0)
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 #ifndef _ANCHOREDDRAWOBJECT_HXX
24 #define _ANCHOREDDRAWOBJECT_HXX
25 
26 #include <anchoredobject.hxx>
27 #include <tools/gen.hxx>
28 
29 /** class for the positioning of drawing objects
30 
31     OD 2004-03-25 #i26791#
32 
33     @author OD
34 */
35 class SW_DLLPUBLIC SwAnchoredDrawObject : public SwAnchoredObject
36 {
37     private:
38         // boolean, indicating that the object position has been invalidated
39         // and that a positioning has to be performed.
40         bool mbValidPos;
41 
42         // rectangle, keeping the last object rectangle after the postioning
43         // --> OD 2004-09-29 #i34748# - change <maLastObjRect> to a pointer
44         Rectangle* mpLastObjRect;
45 
46         // boolean, indicating that anchored drawing object hasn't been attached
47         // to a anchor frame yet. Once, it is attached to a anchor frame the
48         // boolean changes its state.
49         bool mbNotYetAttachedToAnchorFrame;
50 
51         // --> OD 2004-08-09 #i28749# - boolean, indicating that anchored
52         // drawing object hasn't been positioned yet. Once, it's positioned the
53         // boolean changes its state.
54         bool mbNotYetPositioned;
55 
56         // --> OD 2006-03-17 #i62875#
57         // boolean, indicating that after change of layout direction the
58         // anchored drawing object has to be captured on the page, if it exceeds
59         // the left or right page margin.
60         // Needed for compatibility option <DoNotCaptureDrawObjsOnPage>
61         bool mbCaptureAfterLayoutDirChange;
62         // <--
63 
64         /** method for the intrinsic positioning of a at-paragraph|at-character
65             anchored drawing object
66 
67             OD 2004-08-12 #i32795# - helper method for method <MakeObjPos>
68 
69             @author OD
70         */
71         void _MakeObjPosAnchoredAtPara();
72 
73         /** method for the intrinsic positioning of a at-page|at-frame anchored
74             drawing object
75 
76             OD 2004-08-12 #i32795# - helper method for method <MakeObjPos>
77 
78             @author OD
79         */
80         void _MakeObjPosAnchoredAtLayout();
81 
82             /** method to set positioning attributes (not for as-character anchored)
83 
84             OD 2004-10-20 #i35798#
85             During load the positioning attributes aren't set.
86             Thus, the positioning attributes are set by the current object geometry.
87             This method is also used for the conversion for drawing objects
88             (not anchored as-character) imported from OpenOffice.org file format
89             once and directly before the first positioning.
90 
91             @author OD
92         */
93         void _SetPositioningAttr();
94 
95         /** method to set internal anchor position of <SdrObject> instance
96             of the drawing object
97 
98             For drawing objects the internal anchor position of the <SdrObject>
99             instance has to be set.
100             Note: This adjustment is not be done for as-character anchored
101             drawing object - the positioning code takes care of this.
102             OD 2004-07-29 #i31698# - API for drawing objects in Writer has
103             been adjusted. Thus, this method will only set the internal anchor
104             position of the <SdrObject> instance to the anchor position given
105             by its anchor frame.
106 
107             @author OD
108         */
109         void _SetDrawObjAnchor();
110 
111         /** method to invalidate the given page frame
112 
113             OD 2004-07-02 #i28701#
114 
115             @author OD
116         */
117         void _InvalidatePage( SwPageFrm* _pPageFrm );
118 
119     protected:
120         virtual void ObjectAttachedToAnchorFrame();
121 
122         /** method to assure that anchored object is registered at the correct
123             page frame
124 
125             OD 2004-07-02 #i28701#
126 
127             @author OD
128         */
129         virtual void RegisterAtCorrectPage();
130 
131         // --> OD 2006-08-10 #i68520#
132         virtual bool _SetObjTop( const SwTwips _nTop);
133         virtual bool _SetObjLeft( const SwTwips _nLeft);
134         // <--
135 
136         // --> OD 2006-10-05 #i70122#
137         virtual const SwRect GetObjBoundRect() const;
138         // <--
139     public:
140         TYPEINFO();
141 
142         SwAnchoredDrawObject();
143         virtual ~SwAnchoredDrawObject();
144 
145         // declaration of pure virtual methods of base class <SwAnchoredObject>
146         virtual void MakeObjPos();
147         virtual void InvalidateObjPos();
148         inline bool IsValidPos() const
149         {
150             return mbValidPos;
151         }
152 
153         // accessors to the format
154         virtual SwFrmFmt& GetFrmFmt();
155         virtual const SwFrmFmt& GetFrmFmt() const;
156 
157         // accessors to the object area and its position
158         virtual const SwRect GetObjRect() const;
159         // --> OD 2004-09-29 #i34748# - change return type to a pointer.
160         // Return value can be NULL.
161         const Rectangle* GetLastObjRect() const;
162         // <--
163         // --> OD 2004-09-29 #i34748# - change method
164         void SetLastObjRect( const Rectangle& _rNewObjRect );
165         // <--
166 
167         /** adjust positioning and alignment attributes for new anchor frame
168 
169             OD 2004-04-21
170             Set horizontal and vertical position/alignment to manual position
171             relative to anchor frame area using the anchor position of the
172             new anchor frame and the current absolute drawing object position.
173             Note: For correct Undo/Redo method should only be called inside a
174             Undo-/Redo-action.
175             OD 2004-08-24 #i33313# - add second optional parameter <_pNewObjRect>
176 
177             @author OD
178 
179             @param <_pNewAnchorFrm>
180             input parameter - new anchor frame for the anchored object.
181 
182             @param <_pNewObjRect>
183             optional input parameter - proposed new object rectangle. If not
184             provided the current object rectangle is taken.
185         */
186         void AdjustPositioningAttr( const SwFrm* _pNewAnchorFrm,
187                                     const SwRect* _pNewObjRect = 0L );
188 
189         /** method to notify background of drawing object
190 
191             OD 2004-06-30 #i28701#
192 
193             @author OD
194         */
195         virtual void NotifyBackground( SwPageFrm* _pPageFrm,
196                                        const SwRect& _rRect,
197                                        PrepareHint _eHint );
198 
199         // --> OD 2005-08-16 #i53320#
200         inline bool NotYetPositioned() const
201         {
202             return mbNotYetPositioned;
203         }
204         // <--
205 
206         // --> OD 2006-03-17 #i62875#
207         // change of layout direction needs to be tracked
208         // for setting <mbCaptureAfterLayoutDirChange>.
209         virtual void UpdateLayoutDir();
210         // <--
211         // --> OD 2006-03-17 #i62875#
212         bool IsOutsidePage() const;
213         // <--
214 
215         // new Loop control
216         void ValidateThis() { mbValidPos = true; }
217 };
218 
219 #endif
220