1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _OBJECTFORMATTERTXTFRM_HXX
24 #define _OBJECTFORMATTERTXTFRM_HXX
25 
26 #include <objectformatter.hxx>
27 #include <sal/types.h>
28 
29 class SwTxtFrm;
30 
31 // -----------------------------------------------------------------------------
32 // OD 2004-07-01 #i28701#
33 // Format floating screen objects, which are anchored at a given anchor text frame
34 // and registered at the given page frame.
35 // -----------------------------------------------------------------------------
36 class SwObjectFormatterTxtFrm : public SwObjectFormatter
37 {
38     private:
39         // anchor text frame
40         SwTxtFrm& mrAnchorTxtFrm;
41 
42         // 'master' anchor text frame
43         SwTxtFrm* mpMasterAnchorTxtFrm;
44 
45         SwObjectFormatterTxtFrm( SwTxtFrm& _rAnchorTxtFrm,
46                                  const SwPageFrm& _rPageFrm,
47                                  SwTxtFrm* _pMasterAnchorTxtFrm,
48                                  SwLayAction* _pLayAction );
49 
50         /* method to invalidate objects, anchored previous to given object at
51            the anchor text frame
52 
53             @param _rAnchoredObj
54             reference to anchored object - objects, anchored previous to
55             this one will be invalidated.
56 
57             @author OD
58         */
59         void _InvalidatePrevObjs( SwAnchoredObject& _rAnchoredObj );
60 
61         /* method to invalidate objects, anchored after the given object at
62            the page frame
63 
64             @param _rAnchoredObj
65             reference to anchored object - objects, anchored after this one will
66             be invalidated.
67 
68             @param _bInclObj
69             boolean indicates, if given anchored object <_rAnchoredObj> also have
70             to be invalidated.
71 
72             @author OD
73         */
74         void _InvalidateFollowObjs( SwAnchoredObject& _rAnchoredObj,
75                                     const bool _bInclObj );
76 
77         /** method to determine first anchored object, whose 'anchor is moved
78             forward'.
79 
80             'anchor (of an object) is moved forward', if the anchor frame
81             respectively the anchor character of the object isn't on the
82             proposed page frame. Instead its on a following page
83             OD 2004-10-04 #i26945# - For at-character anchored objects,
84             it has also to be checked, if the anchor character is in a follow
85             text frame, which would move to the next page.
86             OD 2005-03-30 #i43913# - add output parameter <_boInFollow>
87 
88             @author OD
89 
90             @param _nWrapInfluenceOnPosition
91             input parameter - only object with this given wrapping style
92             influence are investigated.
93 
94             @param _nFromPageNum
95             input parameter - number of page frame, the 'anchor' should be
96 
97             @param _noToPageNum
98             output parameter - number of page frame, the 'anchor' of the returned
99             anchored object is.
100 
101             @param _boInFollow
102             output parameter - boolean, indicating that anchor text frame is
103             currently on the same page, but it's a follow of in a follow row,
104             which will move forward. value only relevant, if method returns
105             an anchored object
106 
107             @return SwAnchoredObject*
108             anchored object with a 'moved forward anchor'. If NULL, no such
109             anchored object is found.
110         */
111         SwAnchoredObject* _GetFirstObjWithMovedFwdAnchor(
112                                     const sal_Int16 _nWrapInfluenceOnPosition,
113                                     sal_uInt32& _noToPageNum,
114                                     bool& _boInFollow );
115 
116         /** method to format the anchor frame for checking of the move forward condition
117 
118             OD 2005-01-11 #i40141#
119 
120             @author OD
121         */
122         void _FormatAnchorFrmForCheckMoveFwd();
123 
124         /** method to determine if at least one anchored object has state
125             <temporarly consider wrapping style influence> set.
126 
127             OD 2006-07-24 #b6449874#
128 
129             @author OD
130         */
131         bool _AtLeastOneObjIsTmpConsiderWrapInfluence();
132 
133     protected:
134 
135         virtual SwFrm& GetAnchorFrm();
136 
137     public:
138         virtual ~SwObjectFormatterTxtFrm();
139 
140         // --> OD 2005-01-10 #i40147# - add parameter <_bCheckForMovedFwd>.
141         virtual bool DoFormatObj( SwAnchoredObject& _rAnchoredObj,
142                                   const bool _bCheckForMovedFwd = false );
143         // <--
144         virtual bool DoFormatObjs();
145 
146         /** method to create an instance of <SwObjectFormatterTxtFrm> is
147             necessary.
148 
149             @author OD
150         */
151         static SwObjectFormatterTxtFrm* CreateObjFormatter(
152                                                 SwTxtFrm& _rAnchorTxtFrm,
153                                                 const SwPageFrm& _rPageFrm,
154                                                 SwLayAction* _pLayAction );
155 
156         /** method to format given anchor text frame and its previous frames
157 
158             OD 2005-11-17 #i56300#
159             Usage: Needed to check, if the anchor text frame is moved forward
160             due to the positioning and wrapping of its anchored objects, and
161             to format the frames, which have become invalid due to the anchored
162             object formatting in the iterative object positioning algorithm
163 
164             @author OD
165 
166             @param _rAnchorTxtFrm
167             input parameter - reference to anchor text frame, which has to be
168             formatted including its previous frames of the page.
169         */
170         static void FormatAnchorFrmAndItsPrevs( SwTxtFrm& _rAnchorTxtFrm );
171 
172         /** method to check the conditions, if 'anchor is moved forward'
173 
174             OD 2004-10-11 #i26945#
175             OD 2005-03-30 #i43913# - add output parameter <_boInFollow>
176             OD 2006-01-27 #i58182# - replace method by a corresponding static
177             method, because it's needed for the iterative positioning algorithm.
178 
179             @author OD
180 
181             @param _rAnchoredObj
182             input parameter - anchored object, for which the condition has to checked.
183 
184             @param _nFromPageNum
185             input parameter - number of the page, on which the check is performed
186 
187             @param _bAnchoredAtMasterBeforeFormatAnchor
188             input parameter - boolean indicating, that the given anchored object
189             was anchored at the master frame before the anchor frame has been
190             formatted.
191 
192             @param _noToPageNum
193             output parameter - number of page frame, the 'anchor' of the returned
194             anchored object is.
195 
196             @param _boInFollow
197             output parameter - boolean, indicating that anchor text frame is
198             currently on the same page, but it's a follow of in a follow row,
199             which will move forward. value only relevant, if method return <true>.
200 
201             @return boolean
202             indicating, if 'anchor is moved forward'
203         */
204         static bool CheckMovedFwdCondition( SwAnchoredObject& _rAnchoredObj,
205                                             const sal_uInt32 _nFromPageNum,
206                                             const bool _bAnchoredAtMasterBeforeFormatAnchor,
207                                             sal_uInt32& _noToPageNum,
208                                             bool& _boInFollow );
209 };
210 
211 #endif
212