xref: /AOO41X/main/sw/source/core/layout/objectformattertxtfrm.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 _OBJECTFORMATTERTXTFRM_HXX
28 #define _OBJECTFORMATTERTXTFRM_HXX
29 
30 #include <objectformatter.hxx>
31 #include <sal/types.h>
32 
33 class SwTxtFrm;
34 
35 // -----------------------------------------------------------------------------
36 // OD 2004-07-01 #i28701#
37 // Format floating screen objects, which are anchored at a given anchor text frame
38 // and registered at the given page frame.
39 // -----------------------------------------------------------------------------
40 class SwObjectFormatterTxtFrm : public SwObjectFormatter
41 {
42     private:
43         // anchor text frame
44         SwTxtFrm& mrAnchorTxtFrm;
45 
46         // 'master' anchor text frame
47         SwTxtFrm* mpMasterAnchorTxtFrm;
48 
49         SwObjectFormatterTxtFrm( SwTxtFrm& _rAnchorTxtFrm,
50                                  const SwPageFrm& _rPageFrm,
51                                  SwTxtFrm* _pMasterAnchorTxtFrm,
52                                  SwLayAction* _pLayAction );
53 
54         /* method to invalidate objects, anchored previous to given object at
55            the anchor text frame
56 
57             @param _rAnchoredObj
58             reference to anchored object - objects, anchored previous to
59             this one will be invalidated.
60 
61             @author OD
62         */
63         void _InvalidatePrevObjs( SwAnchoredObject& _rAnchoredObj );
64 
65         /* method to invalidate objects, anchored after the given object at
66            the page frame
67 
68             @param _rAnchoredObj
69             reference to anchored object - objects, anchored after this one will
70             be invalidated.
71 
72             @param _bInclObj
73             boolean indicates, if given anchored object <_rAnchoredObj> also have
74             to be invalidated.
75 
76             @author OD
77         */
78         void _InvalidateFollowObjs( SwAnchoredObject& _rAnchoredObj,
79                                     const bool _bInclObj );
80 
81         /** method to determine first anchored object, whose 'anchor is moved
82             forward'.
83 
84             'anchor (of an object) is moved forward', if the anchor frame
85             respectively the anchor character of the object isn't on the
86             proposed page frame. Instead its on a following page
87             OD 2004-10-04 #i26945# - For at-character anchored objects,
88             it has also to be checked, if the anchor character is in a follow
89             text frame, which would move to the next page.
90             OD 2005-03-30 #i43913# - add output parameter <_boInFollow>
91 
92             @author OD
93 
94             @param _nWrapInfluenceOnPosition
95             input parameter - only object with this given wrapping style
96             influence are investigated.
97 
98             @param _nFromPageNum
99             input parameter - number of page frame, the 'anchor' should be
100 
101             @param _noToPageNum
102             output parameter - number of page frame, the 'anchor' of the returned
103             anchored object is.
104 
105             @param _boInFollow
106             output parameter - boolean, indicating that anchor text frame is
107             currently on the same page, but it's a follow of in a follow row,
108             which will move forward. value only relevant, if method returns
109             an anchored object
110 
111             @return SwAnchoredObject*
112             anchored object with a 'moved forward anchor'. If NULL, no such
113             anchored object is found.
114         */
115         SwAnchoredObject* _GetFirstObjWithMovedFwdAnchor(
116                                     const sal_Int16 _nWrapInfluenceOnPosition,
117                                     sal_uInt32& _noToPageNum,
118                                     bool& _boInFollow );
119 
120         /** method to format the anchor frame for checking of the move forward condition
121 
122             OD 2005-01-11 #i40141#
123 
124             @author OD
125         */
126         void _FormatAnchorFrmForCheckMoveFwd();
127 
128         /** method to determine if at least one anchored object has state
129             <temporarly consider wrapping style influence> set.
130 
131             OD 2006-07-24 #b6449874#
132 
133             @author OD
134         */
135         bool _AtLeastOneObjIsTmpConsiderWrapInfluence();
136 
137     protected:
138 
139         virtual SwFrm& GetAnchorFrm();
140 
141     public:
142         virtual ~SwObjectFormatterTxtFrm();
143 
144         // --> OD 2005-01-10 #i40147# - add parameter <_bCheckForMovedFwd>.
145         virtual bool DoFormatObj( SwAnchoredObject& _rAnchoredObj,
146                                   const bool _bCheckForMovedFwd = false );
147         // <--
148         virtual bool DoFormatObjs();
149 
150         /** method to create an instance of <SwObjectFormatterTxtFrm> is
151             necessary.
152 
153             @author OD
154         */
155         static SwObjectFormatterTxtFrm* CreateObjFormatter(
156                                                 SwTxtFrm& _rAnchorTxtFrm,
157                                                 const SwPageFrm& _rPageFrm,
158                                                 SwLayAction* _pLayAction );
159 
160         /** method to format given anchor text frame and its previous frames
161 
162             OD 2005-11-17 #i56300#
163             Usage: Needed to check, if the anchor text frame is moved forward
164             due to the positioning and wrapping of its anchored objects, and
165             to format the frames, which have become invalid due to the anchored
166             object formatting in the iterative object positioning algorithm
167 
168             @author OD
169 
170             @param _rAnchorTxtFrm
171             input parameter - reference to anchor text frame, which has to be
172             formatted including its previous frames of the page.
173         */
174         static void FormatAnchorFrmAndItsPrevs( SwTxtFrm& _rAnchorTxtFrm );
175 
176         /** method to check the conditions, if 'anchor is moved forward'
177 
178             OD 2004-10-11 #i26945#
179             OD 2005-03-30 #i43913# - add output parameter <_boInFollow>
180             OD 2006-01-27 #i58182# - replace method by a corresponding static
181             method, because it's needed for the iterative positioning algorithm.
182 
183             @author OD
184 
185             @param _rAnchoredObj
186             input parameter - anchored object, for which the condition has to checked.
187 
188             @param _nFromPageNum
189             input parameter - number of the page, on which the check is performed
190 
191             @param _bAnchoredAtMasterBeforeFormatAnchor
192             input parameter - boolean indicating, that the given anchored object
193             was anchored at the master frame before the anchor frame has been
194             formatted.
195 
196             @param _noToPageNum
197             output parameter - number of page frame, the 'anchor' of the returned
198             anchored object is.
199 
200             @param _boInFollow
201             output parameter - boolean, indicating that anchor text frame is
202             currently on the same page, but it's a follow of in a follow row,
203             which will move forward. value only relevant, if method return <true>.
204 
205             @return boolean
206             indicating, if 'anchor is moved forward'
207         */
208         static bool CheckMovedFwdCondition( SwAnchoredObject& _rAnchoredObj,
209                                             const sal_uInt32 _nFromPageNum,
210                                             const bool _bAnchoredAtMasterBeforeFormatAnchor,
211                                             sal_uInt32& _noToPageNum,
212                                             bool& _boInFollow );
213 };
214 
215 #endif
216