Line data Source code
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 <ctime>
25 :
26 : #include "swtypes.hxx"
27 : #include "swrect.hxx"
28 :
29 : class SwRootFrm;
30 : class SwLayoutFrm;
31 : class SwPageFrm;
32 : class SwFlyFrm;
33 : class SwCntntFrm;
34 : class SwTabFrm;
35 : class SwViewImp;
36 : class SwCntntNode;
37 : class SwWait;
38 :
39 : /**
40 : * The usage of LayAction is always the same:
41 : *
42 : * 1. Generation of the LayAction object.
43 : * 2. Specifying the wanted behaviour via the Set-methods
44 : * 3. Calling Action()
45 : * 4. Soon after that the destruction of the object
46 : *
47 : * The object registers at the SwViewImp in the ctor and deregisters not until
48 : * the dtor!
49 : * It's a typical stack object.
50 : */
51 : class SwLayAction
52 : {
53 : SwRootFrm *pRoot;
54 : SwViewImp *pImp; // here the action logs in and off
55 :
56 : // For the sake of optimization, so that the tables stick a bit better to
57 : // the Crsr when hitting return/backspace in front of one.
58 : // The first TabFrm that paints itself (per page) adds itself to the pointer.
59 : // The CntntFrms beneath the page do not need to deregister at the Shell for
60 : // painting.
61 : const SwTabFrm *pOptTab;
62 :
63 : SwWait *pWait;
64 :
65 : // If a paragraph (or anything else) moved more than one page when
66 : // formatting, it adds its new page number here.
67 : // The InternalAction can then take the appropriate steps.
68 : sal_uInt16 nPreInvaPage;
69 :
70 : std::clock_t nStartTicks; // The Action's starting time; if too much time passes the
71 : // WaitCrsr can be enabled via CheckWaitCrsr()
72 :
73 : sal_uInt16 nInputType; // Which input should terminate processing
74 : sal_uInt16 nEndPage; // StatBar control
75 : sal_uInt16 nCheckPageNum; // CheckPageDesc() was delayed if != USHRT_MAX
76 : // check from this page onwards
77 :
78 : bool bPaint; // painting or only formatting?
79 : bool bComplete; // Format everything or just the visible Area?
80 : bool bCalcLayout; // Complete reformatting?
81 : bool bAgain; // For the automatically repeated Action if Pages are deleted
82 : bool bNextCycle; // Reset on the first invalid Page
83 : bool bInput; // For terminating processing on input
84 : bool bIdle; // True if the LayAction was triggered by the Idler
85 : bool bReschedule; // Call Reschedule depending on Progress?
86 : bool bCheckPages; // Run CheckPageDescs() or delay it
87 : bool bUpdateExpFlds; // Is set if, after Formatting, we need to do another round for ExpFld
88 : bool bBrowseActionStop; // Terminate Action early (as per bInput) and leave the rest to the Idler
89 : bool bWaitAllowed; // Waitcursor allowed?
90 : bool bPaintExtraData; // Painting line numbers (or similar) enabled?
91 : bool bActionInProgress; // Is set in Action() at the beginning and deleted at the end
92 :
93 : // OD 14.04.2003 #106346# - new flag for content formatting on interrupt.
94 : bool mbFormatCntntOnInterrupt;
95 :
96 : void PaintCntnt( const SwCntntFrm *, const SwPageFrm *,
97 : const SwRect &rOldRect, long nOldBottom );
98 : bool PaintWithoutFlys( const SwRect &, const SwCntntFrm *,
99 : const SwPageFrm * );
100 : inline bool _PaintCntnt( const SwCntntFrm *, const SwPageFrm *,
101 : const SwRect & );
102 :
103 : bool FormatLayout( SwLayoutFrm *, bool bAddRect = true );
104 : bool FormatLayoutTab( SwTabFrm *, bool bAddRect = true );
105 : bool FormatCntnt( const SwPageFrm* pPage );
106 : void _FormatCntnt( const SwCntntFrm* pCntnt,
107 : const SwPageFrm* pPage );
108 : bool IsShortCut( SwPageFrm *& );
109 :
110 : bool TurboAction();
111 : bool _TurboAction( const SwCntntFrm * );
112 : void InternalAction();
113 :
114 : SwPageFrm *CheckFirstVisPage( SwPageFrm *pPage );
115 :
116 : bool RemoveEmptyBrowserPages();
117 :
118 : inline void CheckIdleEnd();
119 20261 : inline std::clock_t GetStartTicks() { return nStartTicks; }
120 :
121 : public:
122 : SwLayAction( SwRootFrm *pRt, SwViewImp *pImp );
123 : ~SwLayAction();
124 :
125 637 : void SetIdle ( bool bNew ) { bIdle = bNew; }
126 72864 : void SetCheckPages ( bool bNew ) { bCheckPages = bNew; }
127 16 : void SetBrowseActionStop( bool bNew ) { bBrowseActionStop = bNew; }
128 12197 : void SetNextCycle ( bool bNew ) { bNextCycle = bNew; }
129 :
130 132525 : bool IsWaitAllowed() const { return bWaitAllowed; }
131 100253 : bool IsNextCycle() const { return bNextCycle; }
132 605263 : bool IsInput() const { return bInput; }
133 132525 : bool IsWait() const { return 0 != pWait; }
134 822353 : bool IsPaint() const { return bPaint; }
135 83078 : bool IsIdle() const { return bIdle; }
136 272511 : bool IsReschedule() const { return bReschedule; }
137 62162 : bool IsPaintExtraData() const { return bPaintExtraData;}
138 470207 : bool IsInterrupt() const { return IsInput(); }
139 :
140 208119 : sal_uInt16 GetInputType() const { return nInputType; }
141 :
142 : // adjusting Action to the wanted behaviour
143 28570 : void SetPaint ( bool bNew ) { bPaint = bNew; }
144 69471 : void SetComplete ( bool bNew ) { bComplete = bNew; }
145 : void SetStatBar ( bool bNew );
146 69460 : void SetInputType ( sal_uInt16 nNew ) { nInputType = nNew; }
147 4728 : void SetCalcLayout ( bool bNew ) { bCalcLayout = bNew; }
148 5502 : void SetReschedule ( bool bNew ) { bReschedule = bNew; }
149 637 : void SetWaitAllowed ( bool bNew ) { bWaitAllowed = bNew; }
150 :
151 322 : void SetAgain() { bAgain = true; }
152 11880 : void SetUpdateExpFlds() {bUpdateExpFlds = true; }
153 :
154 : inline void SetCheckPageNum( sal_uInt16 nNew );
155 0 : inline void SetCheckPageNumDirect( sal_uInt16 nNew ) { nCheckPageNum = nNew; }
156 :
157 : void Action(); // here it begins
158 : void Reset(); // back to CTor-defaults
159 :
160 990899 : bool IsAgain() const { return bAgain; }
161 165686 : bool IsComplete() const { return bComplete; }
162 4728 : bool IsExpFlds() const { return bUpdateExpFlds; }
163 258237 : bool IsCalcLayout() const { return bCalcLayout; }
164 596 : bool IsCheckPages() const { return bCheckPages; }
165 2854 : bool IsBrowseActionStop() const { return bBrowseActionStop; }
166 0 : bool IsActionInProgress() const { return bActionInProgress; }
167 :
168 4 : sal_uInt16 GetCheckPageNum() const { return nCheckPageNum; }
169 :
170 : // others should be able to activate the WaitCrsr, too
171 : void CheckWaitCrsr();
172 :
173 : // #i28701# - method is now public;
174 : // delete 2nd parameter, because its not used;
175 : bool FormatLayoutFly( SwFlyFrm * );
176 : // #i28701# - method is now public
177 : bool _FormatFlyCntnt( const SwFlyFrm * );
178 :
179 : };
180 :
181 : class SwLayIdle
182 : {
183 :
184 : SwRootFrm *pRoot;
185 : SwViewImp *pImp; // The Idler registers and deregisters here
186 : SwCntntNode *pCntntNode; // The current cursor position is saved here
187 : sal_Int32 nTxtPos;
188 : bool bPageValid; // Were we able to evaluate everything on the whole page?
189 : bool bAllValid; // Were we able to evaluate everything?
190 :
191 : #ifdef DBG_UTIL
192 : bool m_bIndicator;
193 : #endif
194 :
195 : #ifdef DBG_UTIL
196 : void ShowIdle( ColorData eName );
197 : #endif
198 :
199 : enum IdleJobType{ ONLINE_SPELLING, AUTOCOMPLETE_WORDS, WORD_COUNT, SMART_TAGS };
200 : bool _DoIdleJob( const SwCntntFrm*, IdleJobType );
201 : bool DoIdleJob( IdleJobType, bool bVisAreaOnly );
202 :
203 : public:
204 : SwLayIdle( SwRootFrm *pRt, SwViewImp *pImp );
205 : ~SwLayIdle();
206 : };
207 :
208 320 : inline void SwLayAction::SetCheckPageNum( sal_uInt16 nNew )
209 : {
210 320 : if ( nNew < nCheckPageNum )
211 42 : nCheckPageNum = nNew;
212 320 : }
213 :
214 : #endif // INCLUDED_SW_SOURCE_CORE_INC_LAYACT_HXX
215 :
216 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|