Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef SW_FLYFRM_HXX
21 : #define SW_FLYFRM_HXX
22 :
23 : #include "layfrm.hxx"
24 : #include <list>
25 : #include "frmfmt.hxx"
26 :
27 : class SwPageFrm;
28 : class SwFmtFrmSize;
29 : struct SwCrsrMoveState;
30 : class SwBorderAttrs;
31 : class SwVirtFlyDrawObj;
32 : class SwFrmFmts;
33 : class SwAttrSetChg;
34 : class PolyPolygon;
35 : class SwFlyDrawContact;
36 : class SwFmt;
37 :
38 : #include <anchoredobject.hxx>
39 :
40 : /** search an anchor for paragraph bound frames starting from pOldAnch
41 :
42 : needed for dragging of objects bound to a paragraph for showing an anchor
43 : indicator as well as for changing the anchor.
44 :
45 : implemented in layout/flycnt.cxx
46 : */
47 : const SwCntntFrm *FindAnchor( const SwFrm *pOldAnch, const Point &rNew,
48 : const sal_Bool bBody = sal_False );
49 :
50 : /** calculate rectangle in that the object can be moved or rather be resized */
51 : sal_Bool CalcClipRect( const SdrObject *pSdrObj, SwRect &rRect, sal_Bool bMove = sal_True );
52 :
53 : /** general base class for all free-flowing frames
54 :
55 : #i26791# - inherit also from <SwAnchoredFlyFrm>
56 : */
57 : class SwFlyFrm : public SwLayoutFrm, public SwAnchoredObject
58 : {
59 : // is allowed to lock, implemented in frmtool.cxx
60 : friend void AppendObjs ( const SwFrmFmts *, sal_uLong, SwFrm *, SwPageFrm * );
61 : friend void Notify( SwFlyFrm *, SwPageFrm *pOld, const SwRect &rOld,
62 : const SwRect* pOldPrt );
63 :
64 : void InitDrawObj( sal_Bool bNotify ); // these to methods are called in the
65 : void FinitDrawObj(); // constructors
66 :
67 : void _UpdateAttr( const SfxPoolItem*, const SfxPoolItem*, sal_uInt8 &,
68 : SwAttrSetChg *pa = 0, SwAttrSetChg *pb = 0 );
69 :
70 : using SwLayoutFrm::CalcRel;
71 :
72 : sal_uInt32 _GetOrdNumForNewRef( const SwFlyDrawContact* );
73 : SwVirtFlyDrawObj* CreateNewRef( SwFlyDrawContact* );
74 :
75 : protected:
76 : // Predecessor/Successor for chaining with text flow
77 : SwFlyFrm *pPrevLink, *pNextLink;
78 :
79 : private:
80 : // It must be possible to block Cntnt-bound flys so that they will be not
81 : // formatted; in this case MakeAll() returns immediately. This is necessary
82 : // for page changes during formattting. In addition, it is needed during
83 : // the constructor call of the root object since otherwise the anchor will
84 : // be formatted before the root is anchored correctly to a shell and
85 : // because too much would be formatted as a result.
86 : sal_Bool bLocked :1;
87 : // sal_True if the background of NotifyDTor needs to be notified at the end
88 : // of a MakeAll() call.
89 : sal_Bool bNotifyBack :1;
90 :
91 : protected:
92 : // Pos, PrtArea or SSize have been invalidated - they will be evaluated
93 : // again immediately because they have to be valid _at all time_.
94 : // The invalidation is tracked here so that LayAction knows about it and
95 : // can handle it properly. Exceptions prove the rule.
96 : sal_Bool bInvalid :1;
97 :
98 : // sal_True if the proposed height of an attribute is a minimal height
99 : // (this means that the frame can grow higher if needed)
100 : sal_Bool bMinHeight :1;
101 : // sal_True if the fly frame could not format position/size based on its
102 : // attributes, e.g. because there was not enough space.
103 : sal_Bool bHeightClipped :1;
104 : sal_Bool bWidthClipped :1;
105 : // If sal_True call only the format after adjusting the width (CheckClip);
106 : // but the width will not be re-evaluated based on the attributes.
107 : sal_Bool bFormatHeightOnly :1;
108 :
109 : sal_Bool bInCnt :1; ///< FLY_AS_CHAR, anchored as character
110 : sal_Bool bAtCnt :1; ///< FLY_AT_PARA, anchored at paragraph
111 : sal_Bool bLayout :1; ///< FLY_AT_PAGE, FLY_AT_FLY, at page or at frame
112 : sal_Bool bAutoPosition :1; ///< FLY_AT_CHAR, anchored at character
113 :
114 : sal_Bool bNoShrink :1; ///< temporary forbid shrinking to avoid loops
115 : // If sal_True, the content of the fly frame will not be deleted when it
116 : // is moved to an invisible layer.
117 : sal_Bool bLockDeleteContent :1;
118 :
119 : friend class SwNoTxtFrm; // is allowed to call NotifyBackground
120 :
121 : virtual void Format( const SwBorderAttrs *pAttrs = 0 );
122 : void MakePrtArea( const SwBorderAttrs &rAttrs );
123 :
124 600 : void Lock() { bLocked = sal_True; }
125 608 : void Unlock() { bLocked = sal_False; }
126 :
127 : void SetMinHeight() { bMinHeight = sal_True; }
128 : void ResetMinHeight(){ bMinHeight = sal_False; }
129 :
130 : Size CalcRel( const SwFmtFrmSize &rSz ) const;
131 : SwTwips CalcAutoWidth() const;
132 :
133 : SwFlyFrm( SwFlyFrmFmt*, SwFrm*, SwFrm *pAnchor );
134 :
135 : /** method to assure that anchored object is registered at the correct
136 : page frame
137 :
138 : #i28701#
139 : */
140 : virtual void RegisterAtCorrectPage();
141 :
142 : virtual bool _SetObjTop( const SwTwips _nTop );
143 : virtual bool _SetObjLeft( const SwTwips _nLeft );
144 :
145 : virtual const SwRect GetObjBoundRect() const;
146 : virtual void Modify( const SfxPoolItem*, const SfxPoolItem* );
147 :
148 : virtual const IDocumentDrawModelAccess* getIDocumentDrawModelAccess( );
149 :
150 : public:
151 : // #i26791#
152 : TYPEINFO();
153 :
154 : virtual ~SwFlyFrm();
155 : // get client information
156 : virtual bool GetInfo( SfxPoolItem& ) const;
157 : virtual void Paint( SwRect const&,
158 : SwPrintData const*const pPrintData = NULL ) const;
159 : virtual Size ChgSize( const Size& aNewSize );
160 : virtual sal_Bool GetCrsrOfst( SwPosition *, Point&,
161 : SwCrsrMoveState* = 0, bool bTestBackground = false ) const;
162 :
163 : virtual void CheckDirection( sal_Bool bVert );
164 : virtual void Cut();
165 : #ifdef DBG_UTIL
166 : virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 );
167 : #endif
168 :
169 : SwTwips _Shrink( SwTwips, sal_Bool bTst );
170 : SwTwips _Grow ( SwTwips, sal_Bool bTst );
171 : void _Invalidate( SwPageFrm *pPage = 0 );
172 :
173 : sal_Bool FrmSizeChg( const SwFmtFrmSize & );
174 :
175 274 : SwFlyFrm *GetPrevLink() const { return pPrevLink; }
176 2120 : SwFlyFrm *GetNextLink() const { return pNextLink; }
177 :
178 : static void ChainFrames( SwFlyFrm *pMaster, SwFlyFrm *pFollow );
179 : static void UnchainFrames( SwFlyFrm *pMaster, SwFlyFrm *pFollow );
180 :
181 : SwFlyFrm *FindChainNeighbour( SwFrmFmt &rFmt, SwFrm *pAnch = 0 );
182 :
183 : // #i26791#
184 : const SwVirtFlyDrawObj* GetVirtDrawObj() const;
185 : SwVirtFlyDrawObj *GetVirtDrawObj();
186 : void NotifyDrawObj();
187 :
188 : void ChgRelPos( const Point &rAbsPos );
189 27 : sal_Bool IsInvalid() const { return bInvalid; }
190 22 : void Invalidate() const { ((SwFlyFrm*)this)->bInvalid = sal_True; }
191 352 : void Validate() const { ((SwFlyFrm*)this)->bInvalid = sal_False; }
192 :
193 60 : sal_Bool IsMinHeight() const { return bMinHeight; }
194 2168 : sal_Bool IsLocked() const { return bLocked; }
195 475 : sal_Bool IsAutoPos() const { return bAutoPosition; }
196 2970 : sal_Bool IsFlyInCntFrm() const { return bInCnt; }
197 11 : sal_Bool IsFlyFreeFrm() const { return bAtCnt || bLayout; }
198 1261 : sal_Bool IsFlyLayFrm() const { return bLayout; }
199 542 : sal_Bool IsFlyAtCntFrm() const { return bAtCnt; }
200 :
201 831 : sal_Bool IsNotifyBack() const { return bNotifyBack; }
202 0 : void SetNotifyBack() { bNotifyBack = sal_True; }
203 343 : void ResetNotifyBack() { bNotifyBack = sal_False; }
204 0 : sal_Bool IsNoShrink() const { return bNoShrink; }
205 : void SetNoShrink( sal_Bool bNew ) { bNoShrink = bNew; }
206 0 : sal_Bool IsLockDeleteContent() const { return bLockDeleteContent; }
207 : void SetLockDeleteContent( sal_Bool bNew ) { bLockDeleteContent = bNew; }
208 :
209 :
210 589 : sal_Bool IsClipped() const { return bHeightClipped || bWidthClipped; }
211 0 : sal_Bool IsHeightClipped() const { return bHeightClipped; }
212 : sal_Bool IsWidthClipped() const { return bWidthClipped; }
213 :
214 : sal_Bool IsLowerOf( const SwLayoutFrm* pUpper ) const;
215 0 : inline sal_Bool IsUpperOf( const SwFlyFrm& _rLower ) const
216 : {
217 0 : return _rLower.IsLowerOf( this );
218 : }
219 :
220 : SwFrm *FindLastLower();
221 :
222 : // #i13147# - add parameter <_bForPaint> to avoid load of
223 : // the graphic during paint. Default value: sal_False
224 : sal_Bool GetContour( PolyPolygon& rContour,
225 : const sal_Bool _bForPaint = sal_False ) const;
226 :
227 :
228 : // Paint on this shell (consider PreView, print flag, etc. recursively)?
229 : static sal_Bool IsPaint( SdrObject *pObj, const ViewShell *pSh );
230 :
231 : /** SwFlyFrm::IsBackgroundTransparent
232 :
233 : determines if background of fly frame has to be drawn transparently
234 :
235 : definition found in /core/layout/paintfrm.cxx
236 :
237 : @return true, if background color is transparent or a existing background
238 : graphic is transparent.
239 : */
240 : sal_Bool IsBackgroundTransparent() const;
241 :
242 : /** SwFlyFrm::IsShadowTransparent
243 :
244 : determine if shadow color of fly frame has to be drawn transparently
245 :
246 : definition found in /core/layout/paintfrm.cxx
247 :
248 : @return true, if shadow color is transparent.
249 : */
250 : sal_Bool IsShadowTransparent() const;
251 :
252 : void Chain( SwFrm* _pAnchor );
253 : void Unchain();
254 : void InsertCnt();
255 : void DeleteCnt();
256 : void InsertColumns();
257 :
258 : // #i26791# - pure virtual methods of base class <SwAnchoredObject>
259 : virtual void MakeObjPos();
260 : virtual void InvalidateObjPos();
261 :
262 : virtual SwFrmFmt& GetFrmFmt();
263 : virtual const SwFrmFmt& GetFrmFmt() const;
264 :
265 : virtual const SwRect GetObjRect() const;
266 :
267 : /** method to determine if a format on the Writer fly frame is possible
268 :
269 : #i28701#
270 : refine 'IsFormatPossible'-conditions of method
271 : <SwAnchoredObject::IsFormatPossible()> by:
272 : format isn't possible, if Writer fly frame is locked resp. col-locked.
273 : */
274 : virtual bool IsFormatPossible() const;
275 : static void GetAnchoredObjects( std::list<SwAnchoredObject*>&, const SwFmt& rFmt );
276 :
277 : // overwriting "SwFrmFmt *SwLayoutFrm::GetFmt" to provide the correct derived return type.
278 : // (This is in order to skip on the otherwise necessary casting of the result to
279 : // 'SwFlyFrmFmt *' after calls to this function. The casting is now done in this function.)
280 : virtual const SwFlyFrmFmt *GetFmt() const;
281 : virtual SwFlyFrmFmt *GetFmt();
282 :
283 6 : virtual void dumpAsXml( xmlTextWriterPtr writer ) { SwLayoutFrm::dumpAsXml( writer ); };
284 : };
285 : #endif
286 :
287 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|