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