LibreOffice Module sw (master)  1
layact.hxx
Go to the documentation of this file.
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_INC_LAYACT_HXX
20 #define INCLUDED_SW_SOURCE_CORE_INC_LAYACT_HXX
21 
22 #include <sal/config.h>
23 
24 #include <vcl/inputtypes.hxx>
25 #include <tools/color.hxx>
26 
27 #include <ctime>
28 #include <memory>
29 #include <vector>
30 
31 #include <swrect.hxx>
32 
33 class OutputDevice;
34 class SwFrame;
35 class SwFrameDeleteGuard;
36 class SwRootFrame;
37 class SwLayoutFrame;
38 class SwPageFrame;
39 class SwFlyFrame;
40 class SwContentFrame;
41 class SwTabFrame;
42 class SwViewShellImp;
43 class SwContentNode;
44 class SwWait;
45 
59 {
61  SwViewShellImp *m_pImp; // here the action logs in and off
62 
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
67  // painting.
69 
70  std::unique_ptr<SwWait> m_pWait;
71 
72  std::vector<SwFrame*> m_aFrameStack;
73  std::vector<std::unique_ptr<SwFrameDeleteGuard>> m_aFrameDeleteGuards;
74 
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;
79 
80  std::clock_t m_nStartTicks; // The Action's starting time; if too much time passes the
81  // WaitCursor can be enabled via CheckWaitCursor()
82 
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
87 
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
102 
103  // OD 14.04.2003 #106346# - new flag for content formatting on interrupt.
105 
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 *,
111  const SwRect & );
112 
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 *& );
119 
120  bool TurboAction();
121  bool TurboAction_( const SwContentFrame * );
122  void InternalAction(OutputDevice* pRenderContext);
123 
124  static SwPageFrame *CheckFirstVisPage( SwPageFrame *pPage );
125 
127 
128  void PushFormatLayout(SwFrame* pLow);
129  void PopFormatLayout();
130 
131  inline void CheckIdleEnd();
132 
133 public:
134  SwLayAction( SwRootFrame *pRt, SwViewShellImp *pImp );
135  ~SwLayAction();
136 
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; }
141 
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; }
149 
151 
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; }
160 
161  void SetAgain(bool bAgain);
162  void SetUpdateExpFields() {m_bUpdateExpFields = true; }
163 
164  inline void SetCheckPageNum( sal_uInt16 nNew );
165  void SetCheckPageNumDirect( sal_uInt16 nNew ) { m_nCheckPageNum = nNew; }
166 
167  void Action(OutputDevice* pRenderContext); // here it begins
168  void Reset(); // back to CTor-defaults
169 
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; }
177 
178  sal_uInt16 GetCheckPageNum() const { return m_nCheckPageNum; }
179 
180  // others should be able to activate the WaitCursor, too
181  void CheckWaitCursor();
182 
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 * );
188 
189 };
190 
192 {
194  SwViewShellImp *m_pImp; // The Idler registers and deregisters here
195  SwContentNode *m_pContentNode; // The current cursor position is saved here
196  sal_Int32 m_nTextPos;
197  bool m_bPageValid; // Were we able to evaluate everything on the whole page?
198 #ifdef DBG_UTIL
200 
201  void ShowIdle( Color eName );
202 #endif
203 
205  bool DoIdleJob_( const SwContentFrame*, IdleJobType );
206  bool DoIdleJob( IdleJobType, bool bVisAreaOnly );
207 
208 public:
209  SwLayIdle( SwRootFrame *pRt, SwViewShellImp *pImp );
210  ~SwLayIdle();
211 };
212 
213 inline void SwLayAction::SetCheckPageNum( sal_uInt16 nNew )
214 {
215  if ( nNew < m_nCheckPageNum )
216  m_nCheckPageNum = nNew;
217 }
218 
219 #endif // INCLUDED_SW_SOURCE_CORE_INC_LAYACT_HXX
220 
221 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void InternalAction(OutputDevice *pRenderContext)
Definition: layact.cxx:466
bool IsActionInProgress() const
Definition: layact.hxx:176
bool IsInterrupt() const
Definition: layact.hxx:148
Base class of the Writer layout elements.
Definition: frame.hxx:314
bool PaintWithoutFlys(const SwRect &, const SwContentFrame *, const SwPageFrame *)
Definition: layact.cxx:103
bool m_bBrowseActionStop
Definition: layact.hxx:98
bool m_bCalcLayout
Definition: layact.hxx:90
void SetNextCycle(bool bNew)
Definition: layact.hxx:140
bool FormatLayout(OutputDevice *pRenderContext, SwLayoutFrame *, bool bAddRect=true)
Definition: layact.cxx:1206
void ShowIdle(Color eName)
bool TurboAction_(const SwContentFrame *)
Definition: layact.cxx:805
bool FormatLayoutTab(SwTabFrame *, bool bAddRect)
Definition: layact.cxx:1491
void SetInputType(VclInputFlags nNew)
Definition: layact.hxx:156
bool m_bComplete
Definition: layact.hxx:89
void FormatFlyContent(const SwFlyFrame *)
Definition: layact.cxx:1906
bool IsWaitAllowed() const
Definition: layact.hxx:142
bool DoIdleJob(IdleJobType, bool bVisAreaOnly)
Definition: layact.cxx:2100
long Long
SwTabFrame is one table in the document layout, containing rows (which contain cells).
Definition: tabfrm.hxx:46
bool m_bInterrupt
Definition: layact.hxx:93
bool m_bReschedule
Definition: layact.hxx:95
bool IsComplete() const
Definition: layact.hxx:171
SwRootFrame * m_pRoot
Definition: layact.hxx:60
void PopFormatLayout()
Definition: layact.cxx:357
bool m_bPaintExtraData
Definition: layact.hxx:100
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
The root element of a Writer document layout.
Definition: rootfrm.hxx:81
void SetIdle(bool bNew)
Definition: layact.hxx:137
bool IsCalcLayout() const
Definition: layact.hxx:173
bool m_bAgain
Definition: layact.hxx:91
void SetCalcLayout(bool bNew)
Definition: layact.hxx:157
VclInputFlags
bool IsReschedule() const
Definition: layact.hxx:146
bool RemoveEmptyBrowserPages()
Definition: layact.cxx:288
bool m_bWaitAllowed
Definition: layact.hxx:99
bool IsShortCut(SwPageFrame *&)
Definition: layact.cxx:991
void PushFormatLayout(SwFrame *pLow)
Definition: layact.cxx:343
std::vector< SwFrame * > m_aFrameStack
Definition: layact.hxx:72
sal_uInt16 GetCheckPageNum() const
Definition: layact.hxx:178
void Action(OutputDevice *pRenderContext)
Definition: layact.cxx:363
~SwLayIdle()
Definition: layact.cxx:2423
sal_uInt16 m_nEndPage
Definition: layact.hxx:84
bool IsNextCycle() const
Definition: layact.hxx:143
void SetBrowseActionStop(bool bNew)
Definition: layact.hxx:139
bool IsCheckPages() const
Definition: layact.hxx:174
bool m_bIndicator
Definition: layact.hxx:199
VclInputFlags m_nInputType
Definition: layact.hxx:83
void SetStatBar(bool bNew)
Definition: layact.cxx:92
void CheckWaitCursor()
Definition: layact.cxx:72
void Reset()
Definition: layact.cxx:276
void SetCheckPageNumDirect(sal_uInt16 nNew)
Definition: layact.hxx:165
sal_uInt16 m_nPreInvaPage
Definition: layact.hxx:78
static SwPageFrame * CheckFirstVisPage(SwPageFrame *pPage)
Definition: layact.cxx:412
SwViewShellImp * m_pImp
Definition: layact.hxx:194
bool m_bIdle
Definition: layact.hxx:94
std::unique_ptr< SwWait > m_pWait
Definition: layact.hxx:70
The usage of LayAction is always the same:
Definition: layact.hxx:58
void CheckIdleEnd()
Definition: layact.cxx:86
VclInputFlags GetInputType() const
Definition: layact.hxx:150
bool m_bUpdateExpFields
Definition: layact.hxx:97
void SetUpdateExpFields()
Definition: layact.hxx:162
bool IsExpFields() const
Definition: layact.hxx:172
bool mbFormatContentOnInterrupt
Definition: layact.hxx:104
SwLayAction(SwRootFrame *pRt, SwViewShellImp *pImp)
Definition: layact.cxx:249
A page of the document layout.
Definition: pagefrm.hxx:57
sal_uInt16 m_nCheckPageNum
Definition: layact.hxx:85
SwContentNode * m_pContentNode
Definition: layact.hxx:195
bool m_bActionInProgress
Definition: layact.hxx:101
~SwLayAction()
Definition: layact.cxx:270
void PaintContent(const SwContentFrame *, const SwPageFrame *, const SwRect &rOldRect, tools::Long nOldBottom)
Depending of the type, the Content is output according to its changes, or the area to be outputted is...
Definition: layact.cxx:199
void FormatContent_(const SwContentFrame *pContent, const SwPageFrame *pPage)
Definition: layact.cxx:1878
bool m_bPaint
Definition: layact.hxx:88
std::clock_t m_nStartTicks
Definition: layact.hxx:80
bool m_bCheckPages
Definition: layact.hxx:96
SwViewShellImp * m_pImp
Definition: layact.hxx:61
bool DoIdleJob_(const SwContentFrame *, IdleJobType)
Definition: layact.cxx:1951
const SwTabFrame * m_pOptTab
Definition: layact.hxx:68
general base class for all free-flowing frames
Definition: flyfrm.hxx:78
bool FormatContent(SwPageFrame *pPage)
Definition: layact.cxx:1639
SwRootFrame * m_pRoot
Definition: layact.hxx:193
bool IsBrowseActionStop() const
Definition: layact.hxx:175
bool IsPaintExtraData() const
Definition: layact.hxx:147
void SetComplete(bool bNew)
Definition: layact.hxx:154
void SetReschedule(bool bNew)
Definition: layact.hxx:158
bool IsAgain() const
Definition: layact.hxx:170
void SetWaitAllowed(bool bNew)
Definition: layact.hxx:159
bool PaintContent_(const SwContentFrame *, const SwPageFrame *, const SwRect &)
Definition: layact.cxx:181
bool IsPaint() const
Definition: layact.hxx:144
bool m_bPageValid
Definition: layact.hxx:197
void SetPaint(bool bNew)
Definition: layact.hxx:153
void FormatLayoutFly(SwFlyFrame *)
Definition: layact.cxx:1442
void SetCheckPages(bool bNew)
Definition: layact.hxx:138
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
Definition: layfrm.hxx:35
bool IsIdle() const
Definition: layact.hxx:145
sal_Int32 m_nTextPos
Definition: layact.hxx:196
std::vector< std::unique_ptr< SwFrameDeleteGuard > > m_aFrameDeleteGuards
Definition: layact.hxx:73
void SetCheckPageNum(sal_uInt16 nNew)
Definition: layact.hxx:213
void SetAgain(bool bAgain)
Definition: layact.cxx:316
SwLayIdle(SwRootFrame *pRt, SwViewShellImp *pImp)
Definition: layact.cxx:2223
bool m_bNextCycle
Definition: layact.hxx:92
bool TurboAction()
Definition: layact.cxx:861