xref: /trunk/main/sw/source/core/inc/flyfrms.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 _FLYFRMS_HXX
28 #define _FLYFRMS_HXX
29 #include "flyfrm.hxx"
30 // --> OD 2004-06-23 #i28701#
31 class SwFlyAtCntFrm;
32 
33 //Basisklasse fuer diejenigen Flys, die sich relativ frei Bewegen koennen -
34 //also die nicht _im_ Inhalt gebundenen Flys.
35 class SwFlyFreeFrm : public SwFlyFrm
36 {
37     SwPageFrm *pPage;   //Bei dieser Seite ist der Fly angemeldet.
38 
39     // --> OD 2004-11-15 #i34753# - flag for at-page anchored Writer fly frames
40     // to prevent a positioning - call of method <MakeObjPos()> -, if Writer
41     // fly frame is already clipped during its format by the object formatter.
42     bool mbNoMakePos;
43     // <--
44     // --> OD 2004-11-12 #i37068# - flag to prevent move in method
45     // <CheckClip(..)>
46     bool mbNoMoveOnCheckClip;
47     // <--
48     void CheckClip( const SwFmtFrmSize &rSz );  //'Emergency' Clipping.
49 
50     /** determines, if direct environment of fly frame has 'auto' size
51 
52         OD 07.08.2003 #i17297#, #111066#, #111070#
53         start with anchor frame and search for a header, footer, row or fly frame
54         stopping at page frame.
55         return <true>, if such a frame is found and it has 'auto' size.
56         otherwise <false> is returned.
57 
58         @author OD
59 
60         @return boolean indicating, that direct environment has 'auto' size
61     */
62     bool HasEnvironmentAutoSize() const;
63 
64 protected:
65     // OD 2004-05-12 #i28701# - new friend class <SwFlyNotify> for access to
66     // method <NotifyBackground>
67     friend class SwFlyNotify;
68 	virtual void NotifyBackground( SwPageFrm *pPage,
69 								   const SwRect& rRect, PrepareHint eHint);
70 
71 	SwFlyFreeFrm( SwFlyFrmFmt*, SwFrm*, SwFrm *pAnchor );
72 
73 public:
74     // --> OD 2004-06-29 #i28701#
75     TYPEINFO();
76 
77 	virtual ~SwFlyFreeFrm();
78 
79 	virtual void MakeAll();
80 
81     // --> OD 2004-11-12 #i37068# - accessors for member <mbNoMoveOnCheckClip>
82     inline void SetNoMoveOnCheckClip( const bool _bNewNoMoveOnCheckClip )
83     {
84         mbNoMoveOnCheckClip = _bNewNoMoveOnCheckClip;
85     }
86     inline bool IsNoMoveOnCheckClip() const
87     {
88         return mbNoMoveOnCheckClip;
89     }
90     // <--
91     // --> OD 2004-11-15 #i34753# - accessors for member <mbNoMakePos>
92     inline void SetNoMakePos( const bool _bNoMakePos )
93     {
94         if ( IsFlyLayFrm() )
95         {
96             mbNoMakePos = _bNoMakePos;
97         }
98     }
99     inline bool IsNoMakePos() const
100     {
101         if ( IsFlyLayFrm() )
102         {
103             return mbNoMakePos;
104         }
105         else
106         {
107             return false;
108         }
109     }
110     // <--
111 
112     /** method to determine, if a format on the Writer fly frame is possible
113 
114         OD 2004-05-11 #i28701#
115         refine 'IsFormatPossible'-conditions of method
116         <SwFlyFrm::IsFormatPossible()> by:
117         format isn't possible, if Writer fly frame isn't registered at a page frame
118         and its anchor frame isn't inside another Writer fly frame.
119 
120         @author OD
121     */
122     virtual bool IsFormatPossible() const;
123 };
124 
125 
126 //Die Fly's, die an einem Layoutfrm haengen und nicht inhaltsgebunden sind
127 class SwFlyLayFrm : public SwFlyFreeFrm
128 {
129 public:
130     // --> OD 2004-06-29 #i28701#
131     TYPEINFO();
132 
133     SwFlyLayFrm( SwFlyFrmFmt*, SwFrm*, SwFrm *pAnchor );
134 	SwFlyLayFrm( SwFlyLayFrm& );
135 protected:
136 	virtual	void Modify( const SfxPoolItem*, const SfxPoolItem* );
137 };
138 
139 //Die Flys, die an einem Cntnt haengen nicht aber im Inhalt
140 class SwFlyAtCntFrm : public SwFlyFreeFrm
141 {
142 protected:
143     virtual void MakeAll();
144 
145     // OD 2004-05-12 #i28701#
146     virtual bool _InvalidationAllowed( const InvalidationType _nInvalid ) const;
147 
148     /** method to assure that anchored object is registered at the correct
149         page frame
150 
151         OD 2004-07-02 #i28701#
152 
153         @author OD
154     */
155     virtual void RegisterAtCorrectPage();
156 	virtual	void Modify( const SfxPoolItem*, const SfxPoolItem* );
157 
158 public:
159     // --> OD 2004-06-29 #i28701#
160     TYPEINFO();
161 
162     SwFlyAtCntFrm( SwFlyFrmFmt*, SwFrm*, SwFrm *pAnchor );
163 
164 	void SetAbsPos( const Point &rNew );
165 
166     // OD 2004-03-23 #i26791#
167     virtual void MakeObjPos();
168 
169     /** method to determine, if a format on the Writer fly frame is possible
170 
171         OD 2004-05-11 #i28701#
172         refine 'IsFormatPossible'-conditions of method
173         <SwFlyFreeFrm::IsFormatPossible()> by:
174         format isn't possible, if method <MakeAll()> is already in progress.
175 
176         @author OD
177     */
178     virtual bool IsFormatPossible() const;
179 };
180 
181 //Die Flys, die an einem Zeichen in einem Cntnt haengen.
182 class SwFlyInCntFrm : public SwFlyFrm
183 {
184     Point aRef;  //Relativ zu diesem Point wird die AbsPos berechnet.
185 	long  nLine; //Zeilenhoehe, Ref.Y() - nLine == Zeilenanfang.
186 
187 	sal_Bool bInvalidLayout :1;
188 	sal_Bool bInvalidCntnt	:1;
189 
190 protected:
191     virtual void NotifyBackground( SwPageFrm *pPage,
192 								   const SwRect& rRect, PrepareHint eHint);
193 	virtual void MakeAll();
194 	virtual	void  Modify( const SfxPoolItem*, const SfxPoolItem* );
195 
196 public:
197     // --> OD 2004-06-29 #i28701#
198     TYPEINFO();
199 
200 	SwFlyInCntFrm( SwFlyFrmFmt*, SwFrm*, SwFrm *pAnchor );
201 
202 	virtual ~SwFlyInCntFrm();
203 	virtual void  Format(  const SwBorderAttrs *pAttrs = 0 );
204 
205 	void SetRefPoint( const Point& rPoint, const Point &rRelAttr,
206 		const Point &rRelPos );
207 	const Point &GetRefPoint() const { return aRef; }
208     const Point GetRelPos() const;
209 		  long   GetLineHeight() const { return nLine; }
210 
211 	inline void InvalidateLayout() const;
212 	inline void InvalidateCntnt() const;
213 	inline void ValidateLayout() const;
214 	inline void ValidateCntnt() const;
215 	sal_Bool IsInvalid() const { return (bInvalidLayout || bInvalidCntnt); }
216 	sal_Bool IsInvalidLayout() const { return bInvalidLayout; }
217 	sal_Bool IsInvalidCntnt() const { return bInvalidCntnt; }
218 
219 
220 	//BP 26.11.93: vgl. tabfrm.hxx, gilt bestimmt aber fuer andere auch...
221 	//Zum Anmelden der Flys nachdem ein FlyCnt erzeugt _und_ eingefuegt wurde.
222 	//Muss vom Erzeuger gerufen werden, denn erst nach dem Konstruieren wird
223 	//Das Teil gepastet; mithin ist auch erst dann die Seite zum Anmelden der
224 	//Flys erreichbar.
225 	void RegistFlys();
226 
227 	//siehe layact.cxx
228 	void AddRefOfst( long nOfst ) { aRef.Y() += nOfst; }
229 
230     // OD 2004-03-23 #i26791#
231     virtual void MakeObjPos();
232 
233     // --> OD 2004-12-02 #115759# - invalidate anchor frame on invalidation
234     // of the position, because the position is calculated during the
235     // format of the anchor frame
236     virtual void _ActionOnInvalidation( const InvalidationType _nInvalid );
237     // <--
238 };
239 
240 inline void SwFlyInCntFrm::InvalidateLayout() const
241 {
242 	((SwFlyInCntFrm*)this)->bInvalidLayout = sal_True;
243 }
244 inline void SwFlyInCntFrm::InvalidateCntnt() const
245 {
246 	((SwFlyInCntFrm*)this)->bInvalidCntnt = sal_True;
247 }
248 inline void SwFlyInCntFrm::ValidateLayout() const
249 {
250 	((SwFlyInCntFrm*)this)->bInvalidLayout = sal_False;
251 }
252 inline void SwFlyInCntFrm::ValidateCntnt() const
253 {
254 	((SwFlyInCntFrm*)this)->bInvalidCntnt = sal_False;
255 }
256 
257 #endif
258