update dev300-m57
[ooovba.git] / sw / inc / anchoredobject.hxx
blobea85b7fbf97528164613ce2de61435ca469a9b07
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: anchoredobject.hxx,v $
10 * $Revision: 1.22.214.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _ANCHOREDOBJECT_HXX
31 #define _ANCHOREDOBJECT_HXX
33 #include <tools/rtti.hxx>
34 #include <swtypes.hxx>
35 #include <swrect.hxx>
37 class SdrObject;
38 class SwFrm;
39 class SwLayoutFrm;
40 // --> OD 2004-07-14 #117380#
41 class SwTxtFrm;
42 // <--
43 // --> OD 2004-06-30 #i28701#
44 class SwPageFrm;
45 class SwObjPositioningInProgress;
46 // <--
47 class SwFrmFmt;
48 class SwFmtAnchor;
50 /** wrapper class for the positioning of Writer fly frames and drawing objects
52 OD 2004-03-22 #i26791#
53 Purpose of this class is to provide a unified interface for the positioning
54 of Writer fly frames (derived classes of <SwFlyFrm>) and of drawing objects
55 (derived classes of <SwDrawFrm>).
57 @author OD
59 class SW_DLLPUBLIC SwAnchoredObject
61 private:
62 // drawing object representing the anchored object in the drawing layer
63 SdrObject* mpDrawObj;
64 // frame the object is anchored at
65 SwFrm* mpAnchorFrm;
66 // --> OD 2004-06-30 #i28701# - page frame the object is registered at
67 // note: no page frame for as-character anchored objects
68 SwPageFrm* mpPageFrm;
69 // <--
70 // current relative position (relative to anchor position of anchor frame)
71 Point maRelPos;
73 // for to-character anchored objects:
74 // Last known anchor character retangle.
75 // Used to decide, if invalidation has to been performed, if anchor position
76 // has changed, and used to position object.
77 SwRect maLastCharRect;
79 // for to-character anchored objects:
80 // Last known top of line, in which the anchor character is in.
81 // Used to decide, if invalidation has to been performed, if anchor position
82 // has changed, and used to position object.
83 SwTwips mnLastTopOfLine;
85 // for to-paragraph and to-character anchored objects:
86 // Layout frame vertical position is orient at - typically its the upper
87 // of the anchor frame, but it could also by the upper of a follow or
88 // a following layout frame in the text flow.
89 const SwLayoutFrm* mpVertPosOrientFrm;
91 // --> OD 2004-06-30 #i28701# - boolean, indicating that the object
92 // positioning algorithm is in progress.
93 bool mbPositioningInProgress;
94 // <--
96 // --> OD 2004-06-29 #i28701# - Booleans needed for the layout process.
97 // Values only of relevance for to-paragraph and to-character anchored
98 // floating screen object, for whose the 'straight-forward positioning
99 // process are applied
100 // Otherwise value of <mbConsiderForTextWrap> is treated as <true>,
101 // value of <mbPositionLocked> is treated as <false> and
102 // value of <mbRestartLayoutProcess> is treated as <false>.
103 // --> OD 2004-10-22 #i35911# - add boolean <mbClearEnvironment>
104 // Indicates that due to its position and wrapping style its layout
105 // environment is cleared - all content is moved forward.
106 // Treated as <false>, if not the 'straight-forward positioning process"
107 // is applied.
108 bool mbConsiderForTextWrap;
109 bool mbPositionLocked;
110 // --> OD 2005-01-10 #i40147# - boolean needed to keep position of
111 // anchored object locked due to special object positioning for sections.
112 bool mbKeepPositionLockedForSection;
113 // <--
114 bool mbRestartLayoutProcess;
115 bool mbClearedEnvironment;
116 // <--
118 // --> OD 2004-08-25 #i3317# - boolean, indicating that temporarly
119 // the wrapping style influence of the anchored object has to be
120 // considered during its positioning.
121 // This boolean is used, if compatibility option 'Consider wrapping style
122 // influence on object positioning' is OFF and a positioning loop is
123 // detected in method <SwFlyAtCntFrm::MakeAll()> or method
124 // <SwAnchoredDrawObject::_MakeObjPosAnchoredAtPara()>.
125 // The boolean is reset to <false>, when the layout process for a
126 // page frame starts - see class <NotifyLayoutOfPageInProgress>.
127 bool mbTmpConsiderWrapInfluence;
128 // <--
130 // --> OD 2006-06-21 #i68520#
131 mutable SwRect maObjRectWithSpaces;
132 mutable bool mbObjRectWithSpacesValid;
133 mutable SwRect maLastObjRect;
134 // <--
136 /** method to indicate, that positioning of anchored object is in progress
138 note: method is implemented empty
140 @author OD
142 friend class SwObjPositioningInProgress;
143 inline void SetPositioningInProgress( const bool _bPosInProgress )
145 mbPositioningInProgress = _bPosInProgress;
149 /** check anchor character rectangle
151 OD 2004-03-25 #i26791#
152 helper method for method <CheckCharRectAndTopOfLine()>
153 For to-character anchored Writer fly frames the member <maLastCharRect>
154 is updated. This is checked for change and depending on the applied
155 positioning, it's decided, if the Writer fly frame has to be invalidated.
156 OD 2004-07-14 #117380#
157 improvement - add second parameter <_rAnchorCharFrm>
159 @author OD
161 @param _rAnch
162 input parameter - reference to anchor position
164 @param _rAnchorCharFrm
165 input parameter - reference to the text frame containing the anchor
166 character.
168 void _CheckCharRect( const SwFmtAnchor& _rAnch,
169 const SwTxtFrm& _rAnchorCharFrm );
171 /** check top of line
173 OD 2004-03-25 #i26791#
174 helper method for method <CheckCharRectAndTopOfLine()>
175 For to-character anchored Writer fly frames the member <mnLastTopOfLine>
176 is updated. This is checked for change and depending on the applied
177 positioning, it's decided, if the Writer fly frame has to be invalidated.
178 OD 2004-07-14 #117380#
179 improvement - add second parameter <_rAnchorCharFrm>
181 @author OD
183 @param _rAnch
184 input parameter - reference to anchor position
186 @param _rAnchorCharFrm
187 input parameter - reference to the text frame containing the anchor
188 character.
190 void _CheckTopOfLine( const SwFmtAnchor& _rAnch,
191 const SwTxtFrm& _rAnchorCharFrm );
193 // --> OD 2005-03-30 #120729# - needed for the hotfix
194 // method <lcl_HideObj(..)> sets needed data structure values for the
195 // object positioning
196 friend bool lcl_HideObj( const SwTxtFrm& _rFrm,
197 const RndStdIds _eAnchorType,
198 const xub_StrLen _nObjAnchorPos,
199 SwAnchoredObject* _pAnchoredObj );
200 // <--
201 protected:
202 SwAnchoredObject();
204 void SetVertPosOrientFrm( const SwLayoutFrm& _rVertPosOrientFrm );
206 /** method to assure that anchored object is registered at the correct
207 page frame
209 OD 2004-07-02 #i28701#
211 @author OD
213 virtual void RegisterAtCorrectPage() = 0;
215 /** method to indicate, that anchored object is attached to a anchor frame
217 @author OD
219 virtual void ObjectAttachedToAnchorFrame();
221 /** method to determine, if other anchored objects, also attached at
222 to the anchor frame, have to consider its wrap influence.
224 // --> OD 2005-02-22 #i43255#
226 @author OD
228 bool ConsiderObjWrapInfluenceOfOtherObjs() const;
230 /** method to apply temporary consideration of wrapping style influence
231 to the anchored objects, which are anchored at the same anchor frame
233 OD 2006-07-24 #b6449874#
235 @author OD
237 void SetTmpConsiderWrapInfluenceOfOtherObjs( const bool bTmpConsiderWrapInfluence );
239 // --> OD 2006-08-10 #i68520#
240 virtual bool _SetObjTop( const SwTwips _nTop) = 0;
241 virtual bool _SetObjLeft( const SwTwips _nLeft) = 0;
242 // <--
244 // --> OD 2006-10-05 #i70122#
245 virtual const SwRect GetObjBoundRect() const = 0;
246 // <--
247 public:
248 TYPEINFO();
250 virtual ~SwAnchoredObject();
252 // accessors to member <mpDrawObj>
253 void SetDrawObj( SdrObject& _rDrawObj );
254 const SdrObject* GetDrawObj() const;
255 SdrObject* DrawObj();
257 // accessors to member <mpAnchorFrm>
258 const SwFrm* GetAnchorFrm() const;
259 SwFrm* AnchorFrm();
260 void ChgAnchorFrm( SwFrm* _pNewAnchorFrm );
261 /** determine anchor frame containing the anchor position
263 OD 2004-10-08 #i26945#
264 the anchor frame, which is determined, is <mpAnchorFrm>
265 for an at-page, at-frame or at-paragraph anchored object
266 and the anchor character frame for an at-character and as-character
267 anchored object.
269 @author OD
271 SwFrm* GetAnchorFrmContainingAnchPos();
273 // --> OD 2004-06-30 #i28701# - accessors to member <mpPageFrm>
274 SwPageFrm* GetPageFrm();
275 const SwPageFrm* GetPageFrm() const;
276 void SetPageFrm( SwPageFrm* _pNewPageFrm );
277 // <--
279 /** method to determine the page frame, on which the 'anchor' of
280 the given anchored object is.
282 OD 2004-07-02 #i28701#
283 OD 2004-09-23 #i33751#, #i34060#
284 Adjust meaning of method and thus its name: If the anchored object
285 or its anchor isn't correctly inserted in the layout, no page frame
286 can be found. Thus, the return type changed to be a pointer and can
287 be NULL.
289 @author OD
291 @param _rAnchoredObj
292 input parameter - anchored object, for which the page frame of its
293 'anchor' has to be determined.
295 @return SwPageFrm&
296 page frame, the 'anchor' of the given anchored object is on
298 SwPageFrm* FindPageFrmOfAnchor();
300 /** get frame, which contains the anchor character, if the object
301 is anchored at-character or as-character.
303 OD 2004-10-04 #i26945#
305 @author OD
307 @return SwTxtFrm*
308 text frame containing the anchor character. It's NULL, if the object
309 isn't anchored at-character resp. as-character.
311 SwTxtFrm* FindAnchorCharFrm();
313 // accessors to data of position calculation:
314 // frame vertical position is orient at
315 inline const SwLayoutFrm* GetVertPosOrientFrm() const
317 return mpVertPosOrientFrm;
319 // --> OD 2004-11-29 #115759# - method to clear member <mpVertPosOrientFrm>
320 inline void ClearVertPosOrientFrm()
322 mpVertPosOrientFrm = 0L;
324 // <--
326 /** check anchor character rectangle and top of line
328 OD 2004-03-25 #i26791#
329 For to-character anchored Writer fly frames the members <maLastCharRect>
330 and <maLastTopOfLine> are updated. These are checked for change and
331 depending on the applied positioning, it's decided, if the Writer fly
332 frame has to be invalidated.
333 OD 2004-07-15 #117380#
334 add parameter <_bCheckForParaPorInf>, default value <true>
336 @author OD
338 @param _bCheckForParaPorInf
339 input parameter - boolean indicating, if check on paragraph portion
340 information has to be done.
342 void CheckCharRectAndTopOfLine( const bool _bCheckForParaPorInf = true );
344 // accessors to member <maLastCharRect>
345 const SwRect& GetLastCharRect() const;
346 SwTwips GetRelCharX( const SwFrm* pFrm ) const;
347 SwTwips GetRelCharY( const SwFrm* pFrm ) const;
348 void AddLastCharY( long nDiff );
349 void ResetLastCharRectHeight();
351 // accessor to member <nmLastTopOfLine>
352 SwTwips GetLastTopOfLine() const;
353 // OD 2004-05-18 #i28701# - follow-up of #i22341#
354 void AddLastTopOfLineY( SwTwips _nDiff );
356 /** reset members <maLastCharRect> and <mnLastTopOfLine>
358 OD 2004-06-29 #i27801#
360 @author OD
362 void ClearCharRectAndTopOfLine();
364 /** method to determine position for the object and set the position
365 at the object
367 @author OD
369 virtual void MakeObjPos() = 0;
371 /** is positioning of anchored object in progress
373 @author OD
375 inline bool IsPositioningInProgress() const
377 return mbPositioningInProgress;
380 /** method to determine, if invalidation of position is allowed
382 OD 2004-07-01 #i28701#
384 @author OD
386 bool InvalidationOfPosAllowed() const;
388 /** method to invalidate position of the anchored object
390 @author OD
392 virtual void InvalidateObjPos() = 0;
394 /** method to perform necessary invalidations for the positioning of
395 objects, for whose the wrapping style influence has to be considered
396 on the object positioning.
398 OD 2004-06-30 #i28701#
400 @author OD
402 void InvalidateObjPosForConsiderWrapInfluence( const bool _bNotifyBackgrd );
404 /** method to trigger notification of 'background'
406 OD 2004-07-01 #i28701#
408 @author OD
410 virtual void NotifyBackground( SwPageFrm* _pPageFrm,
411 const SwRect& _rRect,
412 PrepareHint _eHint ) = 0;
414 // accessors to the current relative position (relative to anchor
415 // position of anchor frame)
416 const Point GetCurrRelPos() const;
417 void SetCurrRelPos( Point _aRelPos );
419 // accessors to the format
420 virtual SwFrmFmt& GetFrmFmt() = 0;
421 virtual const SwFrmFmt& GetFrmFmt() const = 0;
423 // accessors to the object area and its position
424 virtual const SwRect GetObjRect() const = 0;
425 // --> OD 2006-08-10 #i68520#
426 void SetObjTop( const SwTwips _nTop);
427 void SetObjLeft( const SwTwips _nLeft);
428 // <--
430 /** method update layout direction the layout direction, the anchored
431 object is assigned to
433 OD 2004-07-27 #i31698#
434 method has typically to be called, if the anchored object gets its
435 anchor frame assigned and if the anchor frame changes its layout direction
436 OD 2006-03-17 #i62875#
437 made virtual, because it's needed to be overloaded by <SwAnchoredDrawObject>
439 @author OD
441 virtual void UpdateLayoutDir();
443 /** method to determine object area inclusive its spacing
445 OD 2004-06-30 #i28701#
446 OD 2006-08-10 #i68520# - return constant reference
448 @author OD
450 const SwRect& GetObjRectWithSpaces() const;
452 // --> OD 2006-08-10 #i68520#
453 inline void InvalidateObjRectWithSpaces() const
455 mbObjRectWithSpacesValid = false;
457 // <--
459 /** method to determine, if wrapping style influence of the anchored
460 object has to be considered on the object positioning
462 OD 2004-06-30 #i28701#
463 Note: result of this method also decides, if the boolean for the
464 layout process are of relevance.
466 @author OD
468 bool ConsiderObjWrapInfluenceOnObjPos() const;
470 // --> OD 2004-06-29 #i28701# - accessors to booleans for layout process
471 bool ConsiderForTextWrap() const;
472 void SetConsiderForTextWrap( const bool _bConsiderForTextWrap );
473 bool PositionLocked() const;
474 inline void LockPosition()
476 mbPositionLocked = true;
478 inline void UnlockPosition()
480 if ( !mbKeepPositionLockedForSection )
482 mbPositionLocked = false;
485 // --> OD 2005-01-10 #i40147#
486 inline void SetKeepPosLocked( const bool _bKeepPosLocked )
488 mbKeepPositionLockedForSection = _bKeepPosLocked;
490 // <--
491 bool RestartLayoutProcess() const;
492 void SetRestartLayoutProcess( const bool _bRestartLayoutProcess );
493 // --> OD 2004-10-22 #i35911# - accessors for <mbClearedEnvironment>
494 bool ClearedEnvironment() const;
495 void SetClearedEnvironment( const bool _bClearedEnvironment );
496 // <--
497 // --> OD 2005-03-03 #i43913# - reset booleans for layout process
498 inline void ResetLayoutProcessBools()
500 mbPositioningInProgress = false;
501 mbConsiderForTextWrap = false;
502 mbPositionLocked = false;
503 mbKeepPositionLockedForSection = false;
504 mbRestartLayoutProcess = false;
505 mbClearedEnvironment = false;
506 mbTmpConsiderWrapInfluence = false;
508 // <--
510 /** method to determine, if due to anchored object size and wrapping
511 style, its layout environment is cleared.
513 OD 2004-10-22 #i35911#
515 @author OD
517 bool HasClearedEnvironment() const;
519 /** method to update anchored object in the <SwSortedObjs> lists
521 OD 2004-07-01 #i28701#
522 Method is not proposed to be called during a layout process is
523 running. It has been used on the change of the anchored object
524 attributes, which belongs the sort criteria of <SwSortedObjs>.
525 If document compatibility option 'Consider wrapping style influence
526 on object positioning' is ON, additionally all anchored objects
527 at the anchor frame and all following anchored objects on the page
528 frame are invalidated.
530 @author OD
532 void UpdateObjInSortedList();
534 /** method to determine, if a format on the anchored object is possible
536 OD 2004-07-23 #i28701#
537 A format isn't possible, if anchored object is in an invisible layer.
538 Note: method is virtual to refine the conditions for the sub-classes.
540 @author OD
542 virtual bool IsFormatPossible() const;
544 // --> OD 2004-08-25 #i3317# - accessors to member <mbTmpConsiderWrapInfluence>
545 void SetTmpConsiderWrapInfluence( const bool _bTmpConsiderWrapInfluence );
546 bool IsTmpConsiderWrapInfluence() const;
547 // <--
549 /** method to determine, if the anchored object is overlapping with a
550 previous column
552 OD 2004-08-25 #i3317#
553 overlapping with a previous column means, that the object overlaps
554 with a column, which is a previous one of the column its anchor
555 frame is in.
556 Only applied for at-paragraph and at-character anchored objects.
558 @author OD
560 bool OverlapsPrevColumn() const;
562 /** method to determine position of anchored object relative to
563 anchor frame
565 OD 2005-01-06 #i30669#
566 Usage: Needed layout information for WW8 export
568 @author OD
570 @return Point - determined relative position
572 Point GetRelPosToAnchorFrm() const;
574 /** method to determine position of anchored object relative to
575 page frame
577 OD 2005-01-06 #i30669#
578 Usage: Needed layout information for WW8 export
579 OD 2005-01-27 #i33818# - add parameters <_bFollowTextFlow> and
580 <_obRelToTableCell>
581 If <_bFollowTextFlow> is set and object is anchored inside table,
582 the position relative to the table cell is determined. Output
583 parameter <_obRelToTableCell> reflects this situation
585 @author OD
587 @param _bFollowTextFlow
588 input parameter - boolean indicating, if the anchored object has to
589 follow the text flow.
591 @param _obRelToTableCell
592 output parameter - boolean indicating, the determine position is
593 relative to the table cell
595 @return Point - determined relative position
597 Point GetRelPosToPageFrm( const bool _bFollowTextFlow,
598 bool& _obRelToTableCell ) const;
600 /** method to determine position of anchored object relative to
601 anchor character
603 OD 2005-01-06 #i30669#
604 Usage: Needed layout information for WW8 export
606 @author OD
608 @return Point - determined relative position
610 Point GetRelPosToChar() const;
612 /** method to determine position of anchored object relative to
613 top of line
615 OD 2005-01-06 #i30669#
616 Usage: Needed layout information for WW8 export
618 @author OD
620 @return Point - determined relative position
622 Point GetRelPosToLine() const;
625 // ============================================================================
626 // OD 2004-04-13 #i26791#, #i28701#
627 // helper class for notify that positioning of an anchored object is in progress
628 // ============================================================================
629 class SwObjPositioningInProgress
631 private:
632 SwAnchoredObject* mpAnchoredObj;
633 // --> OD 2005-08-09 #i52904# - introduce boolean indicating old state
634 // of anchored object regarding positioning in progress in order to
635 // consider nested usage of class <SwObjPositioningInProgress>
636 bool mbOldObjPositioningInProgress;
637 // <--
639 public:
640 SwObjPositioningInProgress( SdrObject& _rSdrObj );
641 SwObjPositioningInProgress( SwAnchoredObject& _rAnchoredObj );
642 ~SwObjPositioningInProgress();
645 #endif