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