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 #ifndef INCLUDED_SW_SOURCE_CORE_LAYOUT_OBJECTFORMATTERTXTFRM_HXX
20 #define INCLUDED_SW_SOURCE_CORE_LAYOUT_OBJECTFORMATTERTXTFRM_HXX
21 
22 #include <objectformatter.hxx>
23 #include <sal/types.h>
24 
25 class SwTextFrame;
26 
27 // #i28701#
28 // Format floating screen objects, which are anchored at a given anchor text frame
29 // and registered at the given page frame.
30 class SwObjectFormatterTextFrame : public SwObjectFormatter
31 {
32     private:
33         // anchor text frame
34         SwTextFrame& mrAnchorTextFrame;
35 
36         // 'master' anchor text frame
37         SwTextFrame* mpMasterAnchorTextFrame;
38 
39         SwObjectFormatterTextFrame( SwTextFrame& _rAnchorTextFrame,
40                                  const SwPageFrame& _rPageFrame,
41                                  SwTextFrame* _pMasterAnchorTextFrame,
42                                  SwLayAction* _pLayAction );
43 
44         /** method to invalidate objects, anchored previous to given object at
45            the anchor text frame
46 
47             @param _rAnchoredObj
48             reference to anchored object - objects, anchored previous to
49             this one will be invalidated.
50         */
51         void InvalidatePrevObjs( SwAnchoredObject& _rAnchoredObj );
52 
53         /** method to invalidate objects, anchored after the given object at
54            the page frame
55 
56             @param _rAnchoredObj
57             reference to anchored object - objects, anchored after this one will
58             be invalidated.
59         */
60         void InvalidateFollowObjs( SwAnchoredObject& _rAnchoredObj );
61 
62         /** method to determine first anchored object, whose 'anchor is moved
63             forward'.
64 
65             'anchor (of an object) is moved forward', if the anchor frame
66             respectively the anchor character of the object isn't on the
67             proposed page frame. Instead its on a following page
68 
69             #i26945# - For at-character anchored objects,
70             it has also to be checked, if the anchor character is in a follow
71             text frame, which would move to the next page.
72 
73             #i43913# - add output parameter <_boInFollow>
74 
75             @param _nWrapInfluenceOnPosition
76             input parameter - only object with this given wrapping style
77             influence are investigated.
78 
79             @param _nFromPageNum
80             input parameter - number of page frame, the 'anchor' should be
81 
82             @param _noToPageNum
83             output parameter - number of page frame, the 'anchor' of the returned
84             anchored object is.
85 
86             @param _boInFollow
87             output parameter - boolean, indicating that anchor text frame is
88             currently on the same page, but it's a follow of in a follow row,
89             which will move forward. value only relevant, if method returns
90             an anchored object
91 
92             @return SwAnchoredObject*
93             anchored object with a 'moved forward anchor'. If NULL, no such
94             anchored object is found.
95         */
96         SwAnchoredObject* GetFirstObjWithMovedFwdAnchor(
97                                     const sal_Int16 _nWrapInfluenceOnPosition,
98                                     sal_uInt32& _noToPageNum,
99                                     bool& _boInFollow,
100                                     bool& o_rbPageHasFlysAnchoredBelowThis);
101 
102         /** method to format the anchor frame for checking of the move forward condition
103 
104             #i40141#
105         */
106         void FormatAnchorFrameForCheckMoveFwd();
107 
108         /** method to determine if at least one anchored object has state
109             <temporarily consider wrapping style influence> set.
110         */
111         bool AtLeastOneObjIsTmpConsiderWrapInfluence();
112 
113     protected:
114 
115         virtual SwFrame& GetAnchorFrame() override;
116 
117     public:
118         virtual ~SwObjectFormatterTextFrame() override;
119 
120         // #i40147# - add parameter <_bCheckForMovedFwd>.
121         virtual bool DoFormatObj( SwAnchoredObject& _rAnchoredObj,
122                                   const bool _bCheckForMovedFwd = false ) override;
123         virtual bool DoFormatObjs() override;
124 
125         /** method to create an instance of <SwObjectFormatterTextFrame> is
126             necessary.
127         */
128         static std::unique_ptr<SwObjectFormatterTextFrame> CreateObjFormatter(
129                                                 SwTextFrame& _rAnchorTextFrame,
130                                                 const SwPageFrame& _rPageFrame,
131                                                 SwLayAction* _pLayAction );
132 
133         /** method to format given anchor text frame and its previous frames
134 
135             #i56300#
136             Usage: Needed to check, if the anchor text frame is moved forward
137             due to the positioning and wrapping of its anchored objects, and
138             to format the frames, which have become invalid due to the anchored
139             object formatting in the iterative object positioning algorithm
140 
141             @param _rAnchorTextFrame
142             input parameter - reference to anchor text frame, which has to be
143             formatted including its previous frames of the page.
144         */
145         static void FormatAnchorFrameAndItsPrevs( SwTextFrame& _rAnchorTextFrame );
146 
147         /** method to check the conditions, if 'anchor is moved forward'
148 
149             #i26945#
150             #i43913# - add output parameter <_boInFollow>
151             #i58182# - replace method by a corresponding static
152             method, because it's needed for the iterative positioning algorithm.
153 
154             @param _rAnchoredObj
155             input parameter - anchored object, for which the condition has to checked.
156 
157             @param _nFromPageNum
158             input parameter - number of the page, on which the check is performed
159 
160             @param _bAnchoredAtMasterBeforeFormatAnchor
161             input parameter - boolean indicating, that the given anchored object
162             was anchored at the master frame before the anchor frame has been
163             formatted.
164 
165             @param _noToPageNum
166             output parameter - number of page frame, the 'anchor' of the returned
167             anchored object is.
168 
169             @param _boInFollow
170             output parameter - boolean, indicating that anchor text frame is
171             currently on the same page, but it's a follow of in a follow row,
172             which will move forward. value only relevant, if method return <true>.
173             @param o_rbPageHasFlysAnchoredBelowThis
174             output parameter - indicates that the page has flys anchored
175             somewhere below the anchor of the passed _rAnchoredObj
176 
177             @return boolean
178             indicating, if 'anchor is moved forward'
179         */
180         static bool CheckMovedFwdCondition( SwAnchoredObject& _rAnchoredObj,
181                                             SwPageFrame const& rFromPageFrame,
182                                             const bool _bAnchoredAtMasterBeforeFormatAnchor,
183                                             sal_uInt32& _noToPageNum,
184                                             bool& _boInFollow,
185                                             bool& o_rbPageHasFlysAnchoredBelowThis);
186 };
187 
188 #endif
189 
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
191