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