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 
30 #include <swrect.hxx>
31 
32 class OutputDevice;
33 class SwRootFrame;
34 class SwLayoutFrame;
35 class SwPageFrame;
36 class SwFlyFrame;
37 class SwContentFrame;
38 class SwTabFrame;
39 class SwViewShellImp;
40 class SwContentNode;
41 class SwWait;
42 
56 {
58  SwViewShellImp *m_pImp; // here the action logs in and off
59 
60  // For the sake of optimization, so that the tables stick a bit better to
61  // the Cursor when hitting return/backspace in front of one.
62  // The first TabFrame that paints itself (per page) adds itself to the pointer.
63  // The ContentFrames beneath the page do not need to deregister at the Shell for
64  // painting.
66 
67  std::unique_ptr<SwWait> m_pWait;
68 
69  std::vector<SwFrame*> m_aFrameStack;
70  std::vector<std::unique_ptr<SwFrameDeleteGuard>> m_aFrameDeleteGuards;
71 
72  // If a paragraph (or anything else) moved more than one page when
73  // formatting, it adds its new page number here.
74  // The InternalAction can then take the appropriate steps.
75  sal_uInt16 m_nPreInvaPage;
76 
77  std::clock_t m_nStartTicks; // The Action's starting time; if too much time passes the
78  // WaitCursor can be enabled via CheckWaitCursor()
79 
80  VclInputFlags m_nInputType; // Which input should terminate processing
81  sal_uInt16 m_nEndPage; // StatBar control
82  sal_uInt16 m_nCheckPageNum; // CheckPageDesc() was delayed if != USHRT_MAX
83  // check from this page onwards
84 
85  bool m_bPaint; // painting or only formatting?
86  bool m_bComplete; // Format everything or just the visible Area?
87  bool m_bCalcLayout; // Complete reformatting?
88  bool m_bAgain; // For the automatically repeated Action if Pages are deleted
89  bool m_bNextCycle; // Reset on the first invalid Page
90  bool m_bInterrupt; // For terminating processing on interrupt
91  bool m_bIdle; // True if the LayAction was triggered by the Idler
92  bool m_bReschedule; // Call Reschedule depending on Progress?
93  bool m_bCheckPages; // Run CheckPageDescs() or delay it
94  bool m_bUpdateExpFields; // Is set if, after Formatting, we need to do another round for ExpField
95  bool m_bBrowseActionStop; // Terminate Action early (as per bInput) and leave the rest to the Idler
96  bool m_bWaitAllowed; // Waitcursor allowed?
97  bool m_bPaintExtraData; // Painting line numbers (or similar) enabled?
98  bool m_bActionInProgress; // Is set in Action() at the beginning and deleted at the end
99 
100  // OD 14.04.2003 #106346# - new flag for content formatting on interrupt.
102 
103  void PaintContent( const SwContentFrame *, const SwPageFrame *,
104  const SwRect &rOldRect, tools::Long nOldBottom );
105  bool PaintWithoutFlys( const SwRect &, const SwContentFrame *,
106  const SwPageFrame * );
107  inline bool PaintContent_( const SwContentFrame *, const SwPageFrame *,
108  const SwRect & );
109 
110  bool FormatLayout( OutputDevice* pRenderContext, SwLayoutFrame *, bool bAddRect = true );
111  bool FormatLayoutTab( SwTabFrame *, bool bAddRect );
112  bool FormatContent(SwPageFrame * pPage);
113  void FormatContent_( const SwContentFrame* pContent,
114  const SwPageFrame* pPage );
115  bool IsShortCut( SwPageFrame *& );
116 
117  bool TurboAction();
118  bool TurboAction_( const SwContentFrame * );
119  void InternalAction(OutputDevice* pRenderContext);
120 
121  static SwPageFrame *CheckFirstVisPage( SwPageFrame *pPage );
122 
124 
125  void PushFormatLayout(SwFrame* pLow);
126  void PopFormatLayout();
127 
128  inline void CheckIdleEnd();
129 
130 public:
131  SwLayAction( SwRootFrame *pRt, SwViewShellImp *pImp );
132  ~SwLayAction();
133 
134  void SetIdle ( bool bNew ) { m_bIdle = bNew; }
135  void SetCheckPages ( bool bNew ) { m_bCheckPages = bNew; }
136  void SetBrowseActionStop( bool bNew ) { m_bBrowseActionStop = bNew; }
137  void SetNextCycle ( bool bNew ) { m_bNextCycle = bNew; }
138 
139  bool IsWaitAllowed() const { return m_bWaitAllowed; }
140  bool IsNextCycle() const { return m_bNextCycle; }
141  bool IsPaint() const { return m_bPaint; }
142  bool IsIdle() const { return m_bIdle; }
143  bool IsReschedule() const { return m_bReschedule; }
144  bool IsPaintExtraData() const { return m_bPaintExtraData;}
145  bool IsInterrupt() const { return m_bInterrupt; }
146 
148 
149  // adjusting Action to the wanted behaviour
150  void SetPaint ( bool bNew ) { m_bPaint = bNew; }
151  void SetComplete ( bool bNew ) { m_bComplete = bNew; }
152  void SetStatBar ( bool bNew );
153  void SetInputType ( VclInputFlags nNew ) { m_nInputType = nNew; }
154  void SetCalcLayout ( bool bNew ) { m_bCalcLayout = bNew; }
155  void SetReschedule ( bool bNew ) { m_bReschedule = bNew; }
156  void SetWaitAllowed ( bool bNew ) { m_bWaitAllowed = bNew; }
157 
158  void SetAgain(bool bAgain);
159  void SetUpdateExpFields() {m_bUpdateExpFields = true; }
160 
161  inline void SetCheckPageNum( sal_uInt16 nNew );
162  void SetCheckPageNumDirect( sal_uInt16 nNew ) { m_nCheckPageNum = nNew; }
163 
164  void Action(OutputDevice* pRenderContext); // here it begins
165  void Reset(); // back to CTor-defaults
166 
167  bool IsAgain() const { return m_bAgain; }
168  bool IsComplete() const { return m_bComplete; }
169  bool IsExpFields() const { return m_bUpdateExpFields; }
170  bool IsCalcLayout() const { return m_bCalcLayout; }
171  bool IsCheckPages() const { return m_bCheckPages; }
172  bool IsBrowseActionStop() const { return m_bBrowseActionStop; }
173  bool IsActionInProgress() const { return m_bActionInProgress; }
174 
175  sal_uInt16 GetCheckPageNum() const { return m_nCheckPageNum; }
176 
177  // others should be able to activate the WaitCursor, too
178  void CheckWaitCursor();
179 
180  // #i28701# - method is now public;
181  // delete 2nd parameter, because it's not used;
182  void FormatLayoutFly( SwFlyFrame * );
183  // #i28701# - method is now public
184  void FormatFlyContent( const SwFlyFrame * );
185 
186 };
187 
189 {
191  SwViewShellImp *m_pImp; // The Idler registers and deregisters here
192  SwContentNode *m_pContentNode; // The current cursor position is saved here
193  sal_Int32 m_nTextPos;
194  bool m_bPageValid; // Were we able to evaluate everything on the whole page?
195 #ifdef DBG_UTIL
197 
198  void ShowIdle( Color eName );
199 #endif
200 
202  bool DoIdleJob_( const SwContentFrame*, IdleJobType );
203  bool DoIdleJob( IdleJobType, bool bVisAreaOnly );
204 
205 public:
206  SwLayIdle( SwRootFrame *pRt, SwViewShellImp *pImp );
207  ~SwLayIdle();
208 };
209 
210 inline void SwLayAction::SetCheckPageNum( sal_uInt16 nNew )
211 {
212  if ( nNew < m_nCheckPageNum )
213  m_nCheckPageNum = nNew;
214 }
215 
216 #endif // INCLUDED_SW_SOURCE_CORE_INC_LAYACT_HXX
217 
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void InternalAction(OutputDevice *pRenderContext)
Definition: layact.cxx:463
bool IsActionInProgress() const
Definition: layact.hxx:173
bool IsInterrupt() const
Definition: layact.hxx:145
Base class of the Writer layout elements.
Definition: frame.hxx:315
bool PaintWithoutFlys(const SwRect &, const SwContentFrame *, const SwPageFrame *)
Definition: layact.cxx:101
bool m_bBrowseActionStop
Definition: layact.hxx:95
bool m_bCalcLayout
Definition: layact.hxx:87
void SetNextCycle(bool bNew)
Definition: layact.hxx:137
bool FormatLayout(OutputDevice *pRenderContext, SwLayoutFrame *, bool bAddRect=true)
Definition: layact.cxx:1203
void ShowIdle(Color eName)
bool TurboAction_(const SwContentFrame *)
Definition: layact.cxx:802
bool FormatLayoutTab(SwTabFrame *, bool bAddRect)
Definition: layact.cxx:1488
void SetInputType(VclInputFlags nNew)
Definition: layact.hxx:153
bool m_bComplete
Definition: layact.hxx:86
void FormatFlyContent(const SwFlyFrame *)
Definition: layact.cxx:1891
bool IsWaitAllowed() const
Definition: layact.hxx:139
bool DoIdleJob(IdleJobType, bool bVisAreaOnly)
Definition: layact.cxx:2085
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:90
bool m_bReschedule
Definition: layact.hxx:92
bool IsComplete() const
Definition: layact.hxx:168
SwRootFrame * m_pRoot
Definition: layact.hxx:57
void PopFormatLayout()
Definition: layact.cxx:354
bool m_bPaintExtraData
Definition: layact.hxx:97
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
void SetIdle(bool bNew)
Definition: layact.hxx:134
bool IsCalcLayout() const
Definition: layact.hxx:170
bool m_bAgain
Definition: layact.hxx:88
void SetCalcLayout(bool bNew)
Definition: layact.hxx:154
VclInputFlags
bool IsReschedule() const
Definition: layact.hxx:143
bool RemoveEmptyBrowserPages()
Definition: layact.cxx:286
bool m_bWaitAllowed
Definition: layact.hxx:96
bool IsShortCut(SwPageFrame *&)
Definition: layact.cxx:988
void PushFormatLayout(SwFrame *pLow)
Definition: layact.cxx:340
std::vector< SwFrame * > m_aFrameStack
Definition: layact.hxx:69
sal_uInt16 GetCheckPageNum() const
Definition: layact.hxx:175
void Action(OutputDevice *pRenderContext)
Definition: layact.cxx:360
~SwLayIdle()
Definition: layact.cxx:2409
sal_uInt16 m_nEndPage
Definition: layact.hxx:81
bool IsNextCycle() const
Definition: layact.hxx:140
void SetBrowseActionStop(bool bNew)
Definition: layact.hxx:136
bool IsCheckPages() const
Definition: layact.hxx:171
bool m_bIndicator
Definition: layact.hxx:196
VclInputFlags m_nInputType
Definition: layact.hxx:80
void SetStatBar(bool bNew)
Definition: layact.cxx:90
void CheckWaitCursor()
Definition: layact.cxx:70
void Reset()
Definition: layact.cxx:274
void SetCheckPageNumDirect(sal_uInt16 nNew)
Definition: layact.hxx:162
sal_uInt16 m_nPreInvaPage
Definition: layact.hxx:75
static SwPageFrame * CheckFirstVisPage(SwPageFrame *pPage)
Definition: layact.cxx:409
SwViewShellImp * m_pImp
Definition: layact.hxx:191
bool m_bIdle
Definition: layact.hxx:91
std::unique_ptr< SwWait > m_pWait
Definition: layact.hxx:67
The usage of LayAction is always the same:
Definition: layact.hxx:55
void CheckIdleEnd()
Definition: layact.cxx:84
VclInputFlags GetInputType() const
Definition: layact.hxx:147
bool m_bUpdateExpFields
Definition: layact.hxx:94
void SetUpdateExpFields()
Definition: layact.hxx:159
bool IsExpFields() const
Definition: layact.hxx:169
bool mbFormatContentOnInterrupt
Definition: layact.hxx:101
SwLayAction(SwRootFrame *pRt, SwViewShellImp *pImp)
Definition: layact.cxx:247
A page of the document layout.
Definition: pagefrm.hxx:57
sal_uInt16 m_nCheckPageNum
Definition: layact.hxx:82
SwContentNode * m_pContentNode
Definition: layact.hxx:192
bool m_bActionInProgress
Definition: layact.hxx:98
~SwLayAction()
Definition: layact.cxx:268
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:197
void FormatContent_(const SwContentFrame *pContent, const SwPageFrame *pPage)
Definition: layact.cxx:1863
bool m_bPaint
Definition: layact.hxx:85
std::clock_t m_nStartTicks
Definition: layact.hxx:77
bool m_bCheckPages
Definition: layact.hxx:93
SwViewShellImp * m_pImp
Definition: layact.hxx:58
bool DoIdleJob_(const SwContentFrame *, IdleJobType)
Definition: layact.cxx:1936
const SwTabFrame * m_pOptTab
Definition: layact.hxx:65
general base class for all free-flowing frames
Definition: flyfrm.hxx:78
bool FormatContent(SwPageFrame *pPage)
Definition: layact.cxx:1636
SwRootFrame * m_pRoot
Definition: layact.hxx:190
bool IsBrowseActionStop() const
Definition: layact.hxx:172
bool IsPaintExtraData() const
Definition: layact.hxx:144
void SetComplete(bool bNew)
Definition: layact.hxx:151
void SetReschedule(bool bNew)
Definition: layact.hxx:155
bool IsAgain() const
Definition: layact.hxx:167
void SetWaitAllowed(bool bNew)
Definition: layact.hxx:156
bool PaintContent_(const SwContentFrame *, const SwPageFrame *, const SwRect &)
Definition: layact.cxx:179
bool IsPaint() const
Definition: layact.hxx:141
bool m_bPageValid
Definition: layact.hxx:194
void SetPaint(bool bNew)
Definition: layact.hxx:150
void FormatLayoutFly(SwFlyFrame *)
Definition: layact.cxx:1439
void SetCheckPages(bool bNew)
Definition: layact.hxx:135
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:142
sal_Int32 m_nTextPos
Definition: layact.hxx:193
std::vector< std::unique_ptr< SwFrameDeleteGuard > > m_aFrameDeleteGuards
Definition: layact.hxx:70
void SetCheckPageNum(sal_uInt16 nNew)
Definition: layact.hxx:210
void SetAgain(bool bAgain)
Definition: layact.cxx:313
SwLayIdle(SwRootFrame *pRt, SwViewShellImp *pImp)
Definition: layact.cxx:2208
bool m_bNextCycle
Definition: layact.hxx:89
bool TurboAction()
Definition: layact.cxx:858