1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_SOURCE_CORE_INC_LAYACT_HXX
20 #define INCLUDED_SW_SOURCE_CORE_INC_LAYACT_HXX
22 #include <sal/config.h>
24 #include <vcl/inputtypes.hxx>
25 #include <tools/color.hxx>
35 class SwFrameDeleteGuard
;
47 * The usage of LayAction is always the same:
49 * 1. Generation of the LayAction object.
50 * 2. Specifying the wanted behaviour via the Set-methods
52 * 4. Soon after that the destruction of the object
54 * The object registers at the SwViewShellImp in the ctor and deregisters not until
56 * It's a typical stack object.
61 SwViewShellImp
*m_pImp
; // here the action logs in and off
63 // For the sake of optimization, so that the tables stick a bit better to
64 // the Cursor when hitting return/backspace in front of one.
65 // The first TabFrame that paints itself (per page) adds itself to the pointer.
66 // The ContentFrames beneath the page do not need to deregister at the Shell for
68 const SwTabFrame
*m_pOptTab
;
70 std::unique_ptr
<SwWait
> m_pWait
;
72 std::vector
<SwFrame
*> m_aFrameStack
;
73 std::vector
<std::unique_ptr
<SwFrameDeleteGuard
>> m_aFrameDeleteGuards
;
75 // If a paragraph (or anything else) moved more than one page when
76 // formatting, it adds its new page number here.
77 // The InternalAction can then take the appropriate steps.
78 sal_uInt16 m_nPreInvaPage
;
80 std::clock_t m_nStartTicks
; // The Action's starting time; if too much time passes the
81 // WaitCursor can be enabled via CheckWaitCursor()
83 VclInputFlags m_nInputType
; // Which input should terminate processing
84 sal_uInt16 m_nEndPage
; // StatBar control
85 sal_uInt16 m_nCheckPageNum
; // CheckPageDesc() was delayed if != USHRT_MAX
86 // check from this page onwards
88 bool m_bPaint
; // painting or only formatting?
89 bool m_bComplete
; // Format everything or just the visible Area?
90 bool m_bCalcLayout
; // Complete reformatting?
91 bool m_bAgain
; // For the automatically repeated Action if Pages are deleted
92 bool m_bNextCycle
; // Reset on the first invalid Page
93 bool m_bInterrupt
; // For terminating processing on interrupt
94 bool m_bIdle
; // True if the LayAction was triggered by the Idler
95 bool m_bReschedule
; // Call Reschedule depending on Progress?
96 bool m_bCheckPages
; // Run CheckPageDescs() or delay it
97 bool m_bUpdateExpFields
; // Is set if, after Formatting, we need to do another round for ExpField
98 bool m_bBrowseActionStop
; // Terminate Action early (as per bInput) and leave the rest to the Idler
99 bool m_bWaitAllowed
; // Waitcursor allowed?
100 bool m_bPaintExtraData
; // Painting line numbers (or similar) enabled?
101 bool m_bActionInProgress
; // Is set in Action() at the beginning and deleted at the end
103 // OD 14.04.2003 #106346# - new flag for content formatting on interrupt.
104 bool mbFormatContentOnInterrupt
;
106 void PaintContent( const SwContentFrame
*, const SwPageFrame
*,
107 const SwRect
&rOldRect
, tools::Long nOldBottom
);
108 bool PaintWithoutFlys( const SwRect
&, const SwContentFrame
*,
109 const SwPageFrame
* );
110 inline bool PaintContent_( const SwContentFrame
*, const SwPageFrame
*,
113 bool FormatLayout( OutputDevice
* pRenderContext
, SwLayoutFrame
*, bool bAddRect
= true );
114 bool FormatLayoutTab( SwTabFrame
*, bool bAddRect
);
115 bool FormatContent(SwPageFrame
* pPage
);
116 void FormatContent_( const SwContentFrame
* pContent
,
117 const SwPageFrame
* pPage
);
118 bool IsShortCut( SwPageFrame
*& );
121 bool TurboAction_( const SwContentFrame
* );
122 void InternalAction(OutputDevice
* pRenderContext
);
124 static SwPageFrame
*CheckFirstVisPage( SwPageFrame
*pPage
);
126 bool RemoveEmptyBrowserPages();
128 void PushFormatLayout(SwFrame
* pLow
);
129 void PopFormatLayout();
131 inline void CheckIdleEnd();
134 SwLayAction( SwRootFrame
*pRt
, SwViewShellImp
*pImp
);
137 void SetIdle ( bool bNew
) { m_bIdle
= bNew
; }
138 void SetCheckPages ( bool bNew
) { m_bCheckPages
= bNew
; }
139 void SetBrowseActionStop( bool bNew
) { m_bBrowseActionStop
= bNew
; }
140 void SetNextCycle ( bool bNew
) { m_bNextCycle
= bNew
; }
142 bool IsWaitAllowed() const { return m_bWaitAllowed
; }
143 bool IsNextCycle() const { return m_bNextCycle
; }
144 bool IsPaint() const { return m_bPaint
; }
145 bool IsIdle() const { return m_bIdle
; }
146 bool IsReschedule() const { return m_bReschedule
; }
147 bool IsPaintExtraData() const { return m_bPaintExtraData
;}
148 bool IsInterrupt() const { return m_bInterrupt
; }
150 VclInputFlags
GetInputType() const { return m_nInputType
; }
152 // adjusting Action to the wanted behaviour
153 void SetPaint ( bool bNew
) { m_bPaint
= bNew
; }
154 void SetComplete ( bool bNew
) { m_bComplete
= bNew
; }
155 void SetStatBar ( bool bNew
);
156 void SetInputType ( VclInputFlags nNew
) { m_nInputType
= nNew
; }
157 void SetCalcLayout ( bool bNew
) { m_bCalcLayout
= bNew
; }
158 void SetReschedule ( bool bNew
) { m_bReschedule
= bNew
; }
159 void SetWaitAllowed ( bool bNew
) { m_bWaitAllowed
= bNew
; }
161 void SetAgain(bool bAgain
);
162 void SetUpdateExpFields() {m_bUpdateExpFields
= true; }
164 inline void SetCheckPageNum( sal_uInt16 nNew
);
165 void SetCheckPageNumDirect( sal_uInt16 nNew
) { m_nCheckPageNum
= nNew
; }
167 void Action(OutputDevice
* pRenderContext
); // here it begins
168 void Reset(); // back to CTor-defaults
170 bool IsAgain() const { return m_bAgain
; }
171 bool IsComplete() const { return m_bComplete
; }
172 bool IsExpFields() const { return m_bUpdateExpFields
; }
173 bool IsCalcLayout() const { return m_bCalcLayout
; }
174 bool IsCheckPages() const { return m_bCheckPages
; }
175 bool IsBrowseActionStop() const { return m_bBrowseActionStop
; }
176 bool IsActionInProgress() const { return m_bActionInProgress
; }
178 sal_uInt16
GetCheckPageNum() const { return m_nCheckPageNum
; }
180 // others should be able to activate the WaitCursor, too
181 void CheckWaitCursor();
183 // #i28701# - method is now public;
184 // delete 2nd parameter, because it's not used;
185 void FormatLayoutFly( SwFlyFrame
* );
186 // #i28701# - method is now public
187 void FormatFlyContent( const SwFlyFrame
* );
191 enum class IdleJobType
199 enum class IdleJobArea
207 SwRootFrame
*m_pRoot
;
208 SwViewShellImp
*m_pImp
; // The Idler registers and deregisters here
209 SwContentNode
*m_pContentNode
; // The current cursor position is saved here
210 sal_Int32 m_nTextPos
;
211 bool m_bPageValid
; // Were we able to evaluate everything on the whole page?
215 void ShowIdle( Color eName
);
218 bool DoIdleJob_( const SwContentFrame
*, IdleJobType
);
219 bool DoIdleJob(IdleJobType eJobType
, IdleJobArea eJobArea
);
221 static bool isJobEnabled(IdleJobType eJob
, const SwViewShell
* pViewShell
);
223 SwLayIdle( SwRootFrame
*pRt
, SwViewShellImp
*pImp
);
227 inline void SwLayAction::SetCheckPageNum( sal_uInt16 nNew
)
229 if ( nNew
< m_nCheckPageNum
)
230 m_nCheckPageNum
= nNew
;
233 #endif // INCLUDED_SW_SOURCE_CORE_INC_LAYACT_HXX
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */