xref: /trunk/main/sw/source/core/layout/layact.cxx (revision 0c72d66f1a33589bfa5729d3fc3bdd5e807826ac)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <time.h>
30cdf0e10cSrcweir #include "rootfrm.hxx"
31cdf0e10cSrcweir #include "pagefrm.hxx"
32cdf0e10cSrcweir #include "cntfrm.hxx"
33cdf0e10cSrcweir #include "doc.hxx"
34cdf0e10cSrcweir #include "IDocumentDrawModelAccess.hxx"
35cdf0e10cSrcweir #include "IDocumentSettingAccess.hxx"
36cdf0e10cSrcweir #include "IDocumentLayoutAccess.hxx"
37cdf0e10cSrcweir #include "IDocumentStatistics.hxx"
38cdf0e10cSrcweir #include "IDocumentTimerAccess.hxx"
39cdf0e10cSrcweir #include "viewimp.hxx"
40cdf0e10cSrcweir #include "crsrsh.hxx"
41cdf0e10cSrcweir #include "dflyobj.hxx"
42cdf0e10cSrcweir #include "flyfrm.hxx"
43cdf0e10cSrcweir #include "frmtool.hxx"
44cdf0e10cSrcweir #include "dcontact.hxx"
45cdf0e10cSrcweir #include "ndtxt.hxx"    // OnlineSpelling
46cdf0e10cSrcweir #include "frmfmt.hxx"
47cdf0e10cSrcweir #include "swregion.hxx"
48cdf0e10cSrcweir #include "viewopt.hxx"  // OnlineSpelling ueber Internal-TabPage testen.
49cdf0e10cSrcweir #include "pam.hxx"      // OnlineSpelling wg. der aktuellen Cursorposition
50cdf0e10cSrcweir #include "dbg_lay.hxx"
51cdf0e10cSrcweir #include "layouter.hxx" // LoopControlling
52cdf0e10cSrcweir #include "docstat.hxx"
53cdf0e10cSrcweir #include "swevent.hxx"
54cdf0e10cSrcweir 
55cdf0e10cSrcweir #include <sfx2/event.hxx>
56cdf0e10cSrcweir 
57cdf0e10cSrcweir #include <ftnidx.hxx>
58cdf0e10cSrcweir #include <vcl/window.hxx>
59cdf0e10cSrcweir #include <vcl/svapp.hxx>
60cdf0e10cSrcweir #include <editeng/opaqitem.hxx>
61cdf0e10cSrcweir #include <editeng/brshitem.hxx>
62cdf0e10cSrcweir #include <SwSmartTagMgr.hxx>
63cdf0e10cSrcweir 
64cdf0e10cSrcweir #define _SVSTDARR_BOOLS
65cdf0e10cSrcweir #include <svl/svstdarr.hxx>
66cdf0e10cSrcweir 
67cdf0e10cSrcweir #define _LAYACT_CXX
68cdf0e10cSrcweir #include "layact.hxx"
69cdf0e10cSrcweir #include <swwait.hxx>
70cdf0e10cSrcweir #include <fmtsrnd.hxx>
71cdf0e10cSrcweir #include <fmtanchr.hxx>
72cdf0e10cSrcweir #include <tools/shl.hxx>
73cdf0e10cSrcweir #include <sfx2/progress.hxx>
74cdf0e10cSrcweir #ifndef _DOCSH_HXX
75cdf0e10cSrcweir #include <docsh.hxx>
76cdf0e10cSrcweir #endif
77cdf0e10cSrcweir 
78cdf0e10cSrcweir #include "swmodule.hxx"
79cdf0e10cSrcweir #include "fmtline.hxx"
80cdf0e10cSrcweir #include "tabfrm.hxx"
81cdf0e10cSrcweir #include "ftnfrm.hxx"
82cdf0e10cSrcweir #include "txtfrm.hxx"
83cdf0e10cSrcweir #include "notxtfrm.hxx"
84cdf0e10cSrcweir #include "flyfrms.hxx"
85cdf0e10cSrcweir #include "mdiexp.hxx"
86cdf0e10cSrcweir #include "fmtornt.hxx"
87cdf0e10cSrcweir #include "sectfrm.hxx"
88cdf0e10cSrcweir #include "lineinfo.hxx"
89cdf0e10cSrcweir #include <acmplwrd.hxx>
90cdf0e10cSrcweir // --> OD 2004-06-28 #i28701#
91cdf0e10cSrcweir #include <sortedobjs.hxx>
92cdf0e10cSrcweir #include <objectformatter.hxx>
93cdf0e10cSrcweir #include <PostItMgr.hxx>
94cdf0e10cSrcweir 
95cdf0e10cSrcweir // <--
96cdf0e10cSrcweir //#pragma optimize("ity",on)
97cdf0e10cSrcweir 
98cdf0e10cSrcweir /*************************************************************************
99cdf0e10cSrcweir |*
100cdf0e10cSrcweir |*  SwLayAction Statisches Geraffel
101cdf0e10cSrcweir |*
102cdf0e10cSrcweir |*  Ersterstellung      MA 22. Dec. 93
103cdf0e10cSrcweir |*  Letzte Aenderung    MA 22. Dec. 93
104cdf0e10cSrcweir |*
105cdf0e10cSrcweir |*************************************************************************/
106cdf0e10cSrcweir 
107cdf0e10cSrcweir #define IS_FLYS (pPage->GetSortedObjs())
108cdf0e10cSrcweir #define IS_INVAFLY (pPage->IsInvalidFly())
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 
111cdf0e10cSrcweir //Sparen von Schreibarbeit um den Zugriff auf zerstoerte Seiten zu vermeiden.
112cdf0e10cSrcweir #ifdef DBG_UTIL
113cdf0e10cSrcweir 
BreakPoint()114cdf0e10cSrcweir static void BreakPoint()
115cdf0e10cSrcweir {
116cdf0e10cSrcweir     return;
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir #define CHECKPAGE \
120cdf0e10cSrcweir             {   if ( IsAgain() ) \
121cdf0e10cSrcweir                 {   BreakPoint(); \
122cdf0e10cSrcweir                     return; \
123cdf0e10cSrcweir                 } \
124cdf0e10cSrcweir             }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir #define XCHECKPAGE \
127cdf0e10cSrcweir             {   if ( IsAgain() ) \
128cdf0e10cSrcweir                 {   BreakPoint(); \
129cdf0e10cSrcweir                     if( bNoLoop ) \
130cdf0e10cSrcweir                         pLayoutAccess->GetLayouter()->EndLoopControl(); \
131cdf0e10cSrcweir                     return; \
132cdf0e10cSrcweir                 } \
133cdf0e10cSrcweir             }
134cdf0e10cSrcweir #else
135cdf0e10cSrcweir #define CHECKPAGE \
136cdf0e10cSrcweir             {   if ( IsAgain() ) \
137cdf0e10cSrcweir                     return; \
138cdf0e10cSrcweir             }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir #define XCHECKPAGE \
141cdf0e10cSrcweir             {   if ( IsAgain() ) \
142cdf0e10cSrcweir                 { \
143cdf0e10cSrcweir                     if( bNoLoop ) \
144cdf0e10cSrcweir                         pLayoutAccess->GetLayouter()->EndLoopControl(); \
145cdf0e10cSrcweir                     return; \
146cdf0e10cSrcweir                 } \
147cdf0e10cSrcweir             }
148cdf0e10cSrcweir #endif
149cdf0e10cSrcweir 
150cdf0e10cSrcweir #define RESCHEDULE \
151cdf0e10cSrcweir     { \
152cdf0e10cSrcweir         if ( IsReschedule() ) \
153cdf0e10cSrcweir         { \
154cdf0e10cSrcweir             if (pProgress) pProgress->Reschedule(); \
155cdf0e10cSrcweir             ::RescheduleProgress( pImp->GetShell()->GetDoc()->GetDocShell() ); \
156cdf0e10cSrcweir         } \
157cdf0e10cSrcweir     }
158cdf0e10cSrcweir 
Ticks()159cdf0e10cSrcweir inline sal_uLong Ticks()
160cdf0e10cSrcweir {
161cdf0e10cSrcweir     return 1000 * clock() / CLOCKS_PER_SEC;
162cdf0e10cSrcweir }
163cdf0e10cSrcweir 
CheckWaitCrsr()164cdf0e10cSrcweir void SwLayAction::CheckWaitCrsr()
165cdf0e10cSrcweir {
166cdf0e10cSrcweir     RESCHEDULE
167cdf0e10cSrcweir     if ( !IsWait() && IsWaitAllowed() && IsPaint() &&
168cdf0e10cSrcweir          ((Ticks() - GetStartTicks()) >= CLOCKS_PER_SEC/2) )
169cdf0e10cSrcweir     {
1708ef2f12bSOliver-Rainer Wittmann         pWait = new SwWait( *pRoot->GetFmt()->GetDoc()->GetDocShell(), true );
171cdf0e10cSrcweir     }
172cdf0e10cSrcweir }
173cdf0e10cSrcweir 
174cdf0e10cSrcweir /*************************************************************************
175cdf0e10cSrcweir |*
176cdf0e10cSrcweir |*  SwLayAction::CheckIdleEnd()
177cdf0e10cSrcweir |*
178cdf0e10cSrcweir |*  Ersterstellung      MA 12. Aug. 94
179cdf0e10cSrcweir |*  Letzte Aenderung    MA 24. Jun. 96
180cdf0e10cSrcweir |*
181cdf0e10cSrcweir |*************************************************************************/
182cdf0e10cSrcweir //Ist es wirklich schon soweit...
CheckIdleEnd()183cdf0e10cSrcweir inline void SwLayAction::CheckIdleEnd()
184cdf0e10cSrcweir {
185cdf0e10cSrcweir     if ( !IsInput() )
186cdf0e10cSrcweir         bInput = GetInputType() && Application::AnyInput( GetInputType() );
187cdf0e10cSrcweir }
188cdf0e10cSrcweir 
189cdf0e10cSrcweir /*************************************************************************
190cdf0e10cSrcweir |*
191cdf0e10cSrcweir |*  SwLayAction::SetStatBar()
192cdf0e10cSrcweir |*
193cdf0e10cSrcweir |*  Ersterstellung      MA 10. Aug. 94
194cdf0e10cSrcweir |*  Letzte Aenderung    MA 06. Aug. 95
195cdf0e10cSrcweir |*
196cdf0e10cSrcweir |*************************************************************************/
SetStatBar(sal_Bool bNew)197cdf0e10cSrcweir void SwLayAction::SetStatBar( sal_Bool bNew )
198cdf0e10cSrcweir {
199cdf0e10cSrcweir     if ( bNew )
200cdf0e10cSrcweir     {
201cdf0e10cSrcweir         nEndPage = pRoot->GetPageNum();
202cdf0e10cSrcweir         nEndPage += nEndPage * 10 / 100;
203cdf0e10cSrcweir     }
204cdf0e10cSrcweir     else
205cdf0e10cSrcweir         nEndPage = USHRT_MAX;
206cdf0e10cSrcweir }
207cdf0e10cSrcweir 
208cdf0e10cSrcweir /*************************************************************************
209cdf0e10cSrcweir |*
210cdf0e10cSrcweir |*  SwLayAction::PaintCntnt()
211cdf0e10cSrcweir |*
212cdf0e10cSrcweir |*  Beschreibung        Je nach Typ wird der Cntnt entsprechend seinen
213cdf0e10cSrcweir |*      Veraenderungen ausgegeben bzw. wird die auszugebende Flaeche in der
214cdf0e10cSrcweir |*      Region eingetragen.
215cdf0e10cSrcweir |*      PaintCntnt:  fuellt die Region,
216cdf0e10cSrcweir |*  Ersterstellung      BP 19. Jan. 92
217cdf0e10cSrcweir |*  Letzte Aenderung    MA 10. Sep. 96
218cdf0e10cSrcweir |*
219cdf0e10cSrcweir |*************************************************************************/
PaintWithoutFlys(const SwRect & rRect,const SwCntntFrm * pCnt,const SwPageFrm * pPage)220cdf0e10cSrcweir sal_Bool SwLayAction::PaintWithoutFlys( const SwRect &rRect, const SwCntntFrm *pCnt,
221cdf0e10cSrcweir                                     const SwPageFrm *pPage )
222cdf0e10cSrcweir {
223cdf0e10cSrcweir     SwRegionRects aTmp( rRect );
224cdf0e10cSrcweir     const SwSortedObjs &rObjs = *pPage->GetSortedObjs();
225cdf0e10cSrcweir     const SwFlyFrm *pSelfFly = pCnt->FindFlyFrm();
226cdf0e10cSrcweir     sal_uInt16 i;
227cdf0e10cSrcweir 
228cdf0e10cSrcweir     for ( i = 0; i < rObjs.Count() && aTmp.Count(); ++i )
229cdf0e10cSrcweir     {
230cdf0e10cSrcweir         SdrObject *pO = rObjs[i]->DrawObj();
231cdf0e10cSrcweir         if ( !pO->ISA(SwVirtFlyDrawObj) )
232cdf0e10cSrcweir             continue;
233cdf0e10cSrcweir 
234cdf0e10cSrcweir         // OD 2004-01-15 #110582# - do not consider invisible objects
235cdf0e10cSrcweir         const IDocumentDrawModelAccess* pIDDMA = pPage->GetFmt()->getIDocumentDrawModelAccess();
236cdf0e10cSrcweir         if ( !pIDDMA->IsVisibleLayerId( pO->GetLayer() ) )
237cdf0e10cSrcweir         {
238cdf0e10cSrcweir             continue;
239cdf0e10cSrcweir         }
240cdf0e10cSrcweir 
241cdf0e10cSrcweir         SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pO)->GetFlyFrm();
242cdf0e10cSrcweir 
243cdf0e10cSrcweir         if ( pFly == pSelfFly || !rRect.IsOver( pFly->Frm() ) )
244cdf0e10cSrcweir             continue;
245cdf0e10cSrcweir 
246cdf0e10cSrcweir         if ( pSelfFly && pSelfFly->IsLowerOf( pFly ) )
247cdf0e10cSrcweir             continue;
248cdf0e10cSrcweir 
249cdf0e10cSrcweir         if ( pFly->GetVirtDrawObj()->GetLayer() == pIDDMA->GetHellId() )
250cdf0e10cSrcweir             continue;
251cdf0e10cSrcweir 
252cdf0e10cSrcweir         if ( pSelfFly )
253cdf0e10cSrcweir         {
254cdf0e10cSrcweir             const SdrObject *pTmp = pSelfFly->GetVirtDrawObj();
255cdf0e10cSrcweir             if ( pO->GetLayer() == pTmp->GetLayer() )
256cdf0e10cSrcweir             {
257cdf0e10cSrcweir                 if ( pO->GetOrdNumDirect() < pTmp->GetOrdNumDirect() )
258cdf0e10cSrcweir                     //Im gleichen Layer werden nur obenliegende beachtet.
259cdf0e10cSrcweir                     continue;
260cdf0e10cSrcweir             }
261cdf0e10cSrcweir             else
262cdf0e10cSrcweir             {
263cdf0e10cSrcweir                 const sal_Bool bLowerOfSelf = pFly->IsLowerOf( pSelfFly );
264cdf0e10cSrcweir                 if ( !bLowerOfSelf && !pFly->GetFmt()->GetOpaque().GetValue() )
265cdf0e10cSrcweir                     //Aus anderem Layer interessieren uns nur nicht transparente
266cdf0e10cSrcweir                     //oder innenliegende
267cdf0e10cSrcweir                     continue;
268cdf0e10cSrcweir             }
269cdf0e10cSrcweir         }
270cdf0e10cSrcweir 
271cdf0e10cSrcweir         /// OD 19.08.2002 #99657#
272cdf0e10cSrcweir         ///     Fly frame without a lower have to be subtracted from paint region.
273cdf0e10cSrcweir         ///     For checking, if fly frame contains transparent graphic or
274cdf0e10cSrcweir         ///     has surrounded contour, assure that fly frame has a lower
275cdf0e10cSrcweir         if ( pFly->Lower() &&
276cdf0e10cSrcweir              pFly->Lower()->IsNoTxtFrm() &&
277cdf0e10cSrcweir              ( ((SwNoTxtFrm*)pFly->Lower())->IsTransparent() ||
278cdf0e10cSrcweir                pFly->GetFmt()->GetSurround().IsContour() )
279cdf0e10cSrcweir            )
280cdf0e10cSrcweir         {
281cdf0e10cSrcweir             continue;
282cdf0e10cSrcweir         }
283cdf0e10cSrcweir 
284cdf0e10cSrcweir         /// OD 19.08.2002 #99657#
285cdf0e10cSrcweir         ///     Region of a fly frame with transparent background or a transparent
286cdf0e10cSrcweir         ///     shadow have not to be subtracted from paint region
287cdf0e10cSrcweir         if ( pFly->IsBackgroundTransparent() ||
288cdf0e10cSrcweir              pFly->IsShadowTransparent() )
289cdf0e10cSrcweir         {
290cdf0e10cSrcweir             continue;
291cdf0e10cSrcweir         }
292cdf0e10cSrcweir 
293cdf0e10cSrcweir         aTmp -= pFly->Frm();
294cdf0e10cSrcweir     }
295cdf0e10cSrcweir 
296cdf0e10cSrcweir     sal_Bool bRetPaint = sal_False;
297cdf0e10cSrcweir     const SwRect *pData = aTmp.GetData();
298cdf0e10cSrcweir     for ( i = 0; i < aTmp.Count(); ++pData, ++i )
299cdf0e10cSrcweir         bRetPaint |= pImp->GetShell()->AddPaintRect( *pData );
300cdf0e10cSrcweir     return bRetPaint;
301cdf0e10cSrcweir }
302cdf0e10cSrcweir 
_PaintCntnt(const SwCntntFrm * pCntnt,const SwPageFrm * pPage,const SwRect & rRect)303cdf0e10cSrcweir inline sal_Bool SwLayAction::_PaintCntnt( const SwCntntFrm *pCntnt,
304cdf0e10cSrcweir                                       const SwPageFrm *pPage,
305cdf0e10cSrcweir                                       const SwRect &rRect )
306cdf0e10cSrcweir {
307cdf0e10cSrcweir     if ( rRect.HasArea() )
308cdf0e10cSrcweir     {
309cdf0e10cSrcweir         if ( pPage->GetSortedObjs() )
310cdf0e10cSrcweir             return PaintWithoutFlys( rRect, pCntnt, pPage );
311cdf0e10cSrcweir         else
312cdf0e10cSrcweir             return pImp->GetShell()->AddPaintRect( rRect );
313cdf0e10cSrcweir     }
314cdf0e10cSrcweir     return sal_False;
315cdf0e10cSrcweir }
316cdf0e10cSrcweir 
PaintCntnt(const SwCntntFrm * pCnt,const SwPageFrm * pPage,const SwRect & rOldRect,long nOldBottom)317cdf0e10cSrcweir void SwLayAction::PaintCntnt( const SwCntntFrm *pCnt,
318cdf0e10cSrcweir                               const SwPageFrm *pPage,
319cdf0e10cSrcweir                               const SwRect &rOldRect,
320cdf0e10cSrcweir                               long nOldBottom )
321cdf0e10cSrcweir {
322cdf0e10cSrcweir     SWRECTFN( pCnt )
323cdf0e10cSrcweir 
324cdf0e10cSrcweir     if ( pCnt->IsCompletePaint() || !pCnt->IsTxtFrm() )
325cdf0e10cSrcweir     {
326cdf0e10cSrcweir         SwRect aPaint( pCnt->PaintArea() );
327cdf0e10cSrcweir         if ( !_PaintCntnt( pCnt, pPage, aPaint ) )
328cdf0e10cSrcweir             pCnt->ResetCompletePaint();
329cdf0e10cSrcweir     }
330cdf0e10cSrcweir     else
331cdf0e10cSrcweir     {
332cdf0e10cSrcweir         // paint the area between printing bottom and frame bottom and
333cdf0e10cSrcweir         // the area left and right beside the frame, if its height changed.
334cdf0e10cSrcweir         long nOldHeight = (rOldRect.*fnRect->fnGetHeight)();
335cdf0e10cSrcweir         long nNewHeight = (pCnt->Frm().*fnRect->fnGetHeight)();
336cdf0e10cSrcweir         const bool bHeightDiff = nOldHeight != nNewHeight;
337cdf0e10cSrcweir         if( bHeightDiff )
338cdf0e10cSrcweir         {
339cdf0e10cSrcweir             // OD 05.11.2002 #94454# - consider whole potential paint area.
340cdf0e10cSrcweir             //SwRect aDrawRect( pCnt->UnionFrm( sal_True ) );
341cdf0e10cSrcweir             SwRect aDrawRect( pCnt->PaintArea() );
342cdf0e10cSrcweir             if( nOldHeight > nNewHeight )
343cdf0e10cSrcweir                 nOldBottom = (pCnt->*fnRect->fnGetPrtBottom)();
344cdf0e10cSrcweir             (aDrawRect.*fnRect->fnSetTop)( nOldBottom );
345cdf0e10cSrcweir             _PaintCntnt( pCnt, pPage, aDrawRect );
346cdf0e10cSrcweir         }
347cdf0e10cSrcweir         // paint content area
348cdf0e10cSrcweir         SwRect aPaintRect = static_cast<SwTxtFrm*>(const_cast<SwCntntFrm*>(pCnt))->Paint();
349cdf0e10cSrcweir         _PaintCntnt( pCnt, pPage, aPaintRect );
350cdf0e10cSrcweir     }
351cdf0e10cSrcweir 
352cdf0e10cSrcweir     if ( pCnt->IsRetouche() && !pCnt->GetNext() )
353cdf0e10cSrcweir     {
354cdf0e10cSrcweir         const SwFrm *pTmp = pCnt;
355cdf0e10cSrcweir         if( pCnt->IsInSct() )
356cdf0e10cSrcweir         {
357cdf0e10cSrcweir             const SwSectionFrm* pSct = pCnt->FindSctFrm();
358cdf0e10cSrcweir             if( pSct->IsRetouche() && !pSct->GetNext() )
359cdf0e10cSrcweir                 pTmp = pSct;
360cdf0e10cSrcweir         }
361cdf0e10cSrcweir         SwRect aRect( pTmp->GetUpper()->PaintArea() );
362cdf0e10cSrcweir         (aRect.*fnRect->fnSetTop)( (pTmp->*fnRect->fnGetPrtBottom)() );
363cdf0e10cSrcweir         if ( !_PaintCntnt( pCnt, pPage, aRect ) )
364cdf0e10cSrcweir             pCnt->ResetRetouche();
365cdf0e10cSrcweir     }
366cdf0e10cSrcweir }
367cdf0e10cSrcweir 
368cdf0e10cSrcweir /*************************************************************************
369cdf0e10cSrcweir |*
370cdf0e10cSrcweir |*  SwLayAction::SwLayAction()
371cdf0e10cSrcweir |*
372cdf0e10cSrcweir |*  Ersterstellung      MA 30. Oct. 92
373cdf0e10cSrcweir |*  Letzte Aenderung    MA 09. Jun. 95
374cdf0e10cSrcweir |*
375cdf0e10cSrcweir |*************************************************************************/
SwLayAction(SwRootFrm * pRt,SwViewImp * pI)376cdf0e10cSrcweir SwLayAction::SwLayAction( SwRootFrm *pRt, SwViewImp *pI ) :
377cdf0e10cSrcweir     pRoot( pRt ),
378cdf0e10cSrcweir     pImp( pI ),
379cdf0e10cSrcweir     pOptTab( 0 ),
380cdf0e10cSrcweir     pWait( 0 ),
381cdf0e10cSrcweir     pProgress(NULL),
382cdf0e10cSrcweir     nPreInvaPage( USHRT_MAX ),
383cdf0e10cSrcweir     nStartTicks( Ticks() ),
384cdf0e10cSrcweir     nInputType( 0 ),
385cdf0e10cSrcweir     nEndPage( USHRT_MAX ),
386cdf0e10cSrcweir     nCheckPageNum( USHRT_MAX )
387cdf0e10cSrcweir {
388cdf0e10cSrcweir     bPaintExtraData = ::IsExtraData( pImp->GetShell()->GetDoc() );
389cdf0e10cSrcweir     bPaint = bComplete = bWaitAllowed = bCheckPages = sal_True;
390cdf0e10cSrcweir     bInput = bAgain = bNextCycle = bCalcLayout = bIdle = bReschedule =
391cdf0e10cSrcweir     bUpdateExpFlds = bBrowseActionStop = bActionInProgress = sal_False;
392cdf0e10cSrcweir     // OD 14.04.2003 #106346# - init new flag <mbFormatCntntOnInterrupt>.
393cdf0e10cSrcweir     mbFormatCntntOnInterrupt = sal_False;
394cdf0e10cSrcweir 
395cdf0e10cSrcweir     pImp->pLayAct = this;   //Anmelden
396cdf0e10cSrcweir }
397cdf0e10cSrcweir 
~SwLayAction()398cdf0e10cSrcweir SwLayAction::~SwLayAction()
399cdf0e10cSrcweir {
400cdf0e10cSrcweir     ASSERT( !pWait, "Wait object not destroyed" );
401cdf0e10cSrcweir     pImp->pLayAct = 0;      //Abmelden
402cdf0e10cSrcweir }
403cdf0e10cSrcweir 
404cdf0e10cSrcweir /*************************************************************************
405cdf0e10cSrcweir |*
406cdf0e10cSrcweir |*  SwLayAction::Reset()
407cdf0e10cSrcweir |*
408cdf0e10cSrcweir |*  Ersterstellung      MA 11. Aug. 94
409cdf0e10cSrcweir |*  Letzte Aenderung    MA 09. Jun. 95
410cdf0e10cSrcweir |*
411cdf0e10cSrcweir |*************************************************************************/
Reset()412cdf0e10cSrcweir void SwLayAction::Reset()
413cdf0e10cSrcweir {
414cdf0e10cSrcweir     pOptTab = 0;
415cdf0e10cSrcweir     nStartTicks = Ticks();
416cdf0e10cSrcweir     nInputType = 0;
417cdf0e10cSrcweir     nEndPage = nPreInvaPage = nCheckPageNum = USHRT_MAX;
418cdf0e10cSrcweir     bPaint = bComplete = bWaitAllowed = bCheckPages = sal_True;
419cdf0e10cSrcweir     bInput = bAgain = bNextCycle = bCalcLayout = bIdle = bReschedule =
420cdf0e10cSrcweir     bUpdateExpFlds = bBrowseActionStop = sal_False;
421cdf0e10cSrcweir }
422cdf0e10cSrcweir 
423cdf0e10cSrcweir /*************************************************************************
424cdf0e10cSrcweir |*
425cdf0e10cSrcweir |*  SwLayAction::RemoveEmptyBrowserPages()
426cdf0e10cSrcweir |*
427cdf0e10cSrcweir |*  Ersterstellung      MA 10. Sep. 97
428cdf0e10cSrcweir |*  Letzte Aenderung    MA 10. Sep. 97
429cdf0e10cSrcweir |*
430cdf0e10cSrcweir |*************************************************************************/
431cdf0e10cSrcweir 
RemoveEmptyBrowserPages()432cdf0e10cSrcweir sal_Bool SwLayAction::RemoveEmptyBrowserPages()
433cdf0e10cSrcweir {
434cdf0e10cSrcweir     //Beim umschalten vom normalen in den Browsermodus bleiben u.U. einige
435cdf0e10cSrcweir     //unangenehm lange stehen. Diese beseiten wir mal schnell.
436cdf0e10cSrcweir     sal_Bool bRet = sal_False;
437cdf0e10cSrcweir     const ViewShell *pSh = pRoot->GetCurrShell();
438cdf0e10cSrcweir     if( pSh && pSh->GetViewOptions()->getBrowseMode() )
439cdf0e10cSrcweir     {
440cdf0e10cSrcweir         SwPageFrm *pPage = (SwPageFrm*)pRoot->Lower();
441cdf0e10cSrcweir         do
442cdf0e10cSrcweir         {
443cdf0e10cSrcweir             if ( (pPage->GetSortedObjs() && pPage->GetSortedObjs()->Count()) ||
444cdf0e10cSrcweir                  pPage->ContainsCntnt() )
445cdf0e10cSrcweir                 pPage = (SwPageFrm*)pPage->GetNext();
446cdf0e10cSrcweir             else
447cdf0e10cSrcweir             {
448cdf0e10cSrcweir                 bRet = sal_True;
449cdf0e10cSrcweir                 SwPageFrm *pDel = pPage;
450cdf0e10cSrcweir                 pPage = (SwPageFrm*)pPage->GetNext();
451cdf0e10cSrcweir                 pDel->Cut();
452cdf0e10cSrcweir                 delete pDel;
453cdf0e10cSrcweir             }
454cdf0e10cSrcweir         } while ( pPage );
455cdf0e10cSrcweir     }
456cdf0e10cSrcweir     return bRet;
457cdf0e10cSrcweir }
458cdf0e10cSrcweir 
459cdf0e10cSrcweir 
460cdf0e10cSrcweir /*************************************************************************
461cdf0e10cSrcweir |*
462cdf0e10cSrcweir |*  SwLayAction::Action()
463cdf0e10cSrcweir |*
464cdf0e10cSrcweir |*  Ersterstellung      MA 10. Aug. 94
465cdf0e10cSrcweir |*  Letzte Aenderung    MA 06. Aug. 95
466cdf0e10cSrcweir |*
467cdf0e10cSrcweir |*************************************************************************/
Action()468cdf0e10cSrcweir void SwLayAction::Action()
469cdf0e10cSrcweir {
470cdf0e10cSrcweir     bActionInProgress = sal_True;
471cdf0e10cSrcweir 
472cdf0e10cSrcweir     //TurboMode? Disqualifiziert fuer Idle-Format.
473cdf0e10cSrcweir     if ( IsPaint() && !IsIdle() && TurboAction() )
474cdf0e10cSrcweir     {
475cdf0e10cSrcweir         delete pWait, pWait = 0;
476cdf0e10cSrcweir         pRoot->ResetTurboFlag();
477cdf0e10cSrcweir         bActionInProgress = sal_False;
478cdf0e10cSrcweir         pRoot->DeleteEmptySct();
479cdf0e10cSrcweir         return;
480cdf0e10cSrcweir     }
481cdf0e10cSrcweir     else if ( pRoot->GetTurbo() )
482cdf0e10cSrcweir     {
483cdf0e10cSrcweir         pRoot->DisallowTurbo();
484cdf0e10cSrcweir         const SwFrm *pFrm = pRoot->GetTurbo();
485cdf0e10cSrcweir         pRoot->ResetTurbo();
486cdf0e10cSrcweir         pFrm->InvalidatePage();
487cdf0e10cSrcweir     }
488cdf0e10cSrcweir     pRoot->DisallowTurbo();
489cdf0e10cSrcweir 
490cdf0e10cSrcweir     if ( IsCalcLayout() )
491cdf0e10cSrcweir         SetCheckPages( sal_False );
492cdf0e10cSrcweir 
493cdf0e10cSrcweir     InternalAction();
494cdf0e10cSrcweir     bAgain |= RemoveEmptyBrowserPages();
495cdf0e10cSrcweir     while ( IsAgain() )
496cdf0e10cSrcweir     {
497cdf0e10cSrcweir         bAgain = bNextCycle = sal_False;
498cdf0e10cSrcweir         InternalAction();
499cdf0e10cSrcweir         bAgain |= RemoveEmptyBrowserPages();
500cdf0e10cSrcweir     }
501cdf0e10cSrcweir     pRoot->DeleteEmptySct();
502cdf0e10cSrcweir 
503cdf0e10cSrcweir     delete pWait, pWait = 0;
504cdf0e10cSrcweir 
505cdf0e10cSrcweir     //Turbo-Action ist auf jedenfall wieder erlaubt.
506cdf0e10cSrcweir     pRoot->ResetTurboFlag();
507cdf0e10cSrcweir     pRoot->ResetTurbo();
508cdf0e10cSrcweir 
509cdf0e10cSrcweir     SetCheckPages( sal_True );
510cdf0e10cSrcweir 
511cdf0e10cSrcweir     bActionInProgress = sal_False;
512cdf0e10cSrcweir }
513cdf0e10cSrcweir 
CheckFirstVisPage(SwPageFrm * pPage)514cdf0e10cSrcweir SwPageFrm* SwLayAction::CheckFirstVisPage( SwPageFrm *pPage )
515cdf0e10cSrcweir {
516cdf0e10cSrcweir     SwCntntFrm *pCnt = pPage->FindFirstBodyCntnt();
517cdf0e10cSrcweir     SwCntntFrm *pChk = pCnt;
518cdf0e10cSrcweir     sal_Bool bPageChgd = sal_False;
519cdf0e10cSrcweir     while ( pCnt && pCnt->IsFollow() )
520cdf0e10cSrcweir         pCnt = static_cast<SwCntntFrm*>(pCnt)->FindMaster();
521cdf0e10cSrcweir     if ( pCnt && pChk != pCnt )
522cdf0e10cSrcweir     {   bPageChgd = sal_True;
523cdf0e10cSrcweir         pPage = pCnt->FindPageFrm();
524cdf0e10cSrcweir     }
525cdf0e10cSrcweir 
526cdf0e10cSrcweir     if ( pPage->GetFmt()->GetDoc()->GetFtnIdxs().Count() )
527cdf0e10cSrcweir     {
528cdf0e10cSrcweir         SwFtnContFrm *pCont = pPage->FindFtnCont();
529cdf0e10cSrcweir         if ( pCont )
530cdf0e10cSrcweir         {
531cdf0e10cSrcweir             pCnt = pCont->ContainsCntnt();
532cdf0e10cSrcweir             pChk = pCnt;
533cdf0e10cSrcweir             while ( pCnt && pCnt->IsFollow() )
534cdf0e10cSrcweir                 pCnt = (SwCntntFrm*)pCnt->FindPrev();
535cdf0e10cSrcweir             if ( pCnt && pCnt != pChk )
536cdf0e10cSrcweir             {
537cdf0e10cSrcweir                 if ( bPageChgd )
538cdf0e10cSrcweir                 {
539cdf0e10cSrcweir                     //Die 'oberste' Seite benutzten.
540cdf0e10cSrcweir                     SwPageFrm *pTmp = pCnt->FindPageFrm();
541cdf0e10cSrcweir                     if ( pPage->GetPhyPageNum() > pTmp->GetPhyPageNum() )
542cdf0e10cSrcweir                         pPage = pTmp;
543cdf0e10cSrcweir                 }
544cdf0e10cSrcweir                 else
545cdf0e10cSrcweir                     pPage = pCnt->FindPageFrm();
546cdf0e10cSrcweir             }
547cdf0e10cSrcweir         }
548cdf0e10cSrcweir     }
549cdf0e10cSrcweir     return pPage;
550cdf0e10cSrcweir }
551cdf0e10cSrcweir 
552cdf0e10cSrcweir // OD 2004-05-12 #i28701#
553cdf0e10cSrcweir // --> OD 2004-11-03 #i114798# - unlock position on start and end of page
554cdf0e10cSrcweir // layout process.
555cdf0e10cSrcweir class NotifyLayoutOfPageInProgress
556cdf0e10cSrcweir {
557cdf0e10cSrcweir     private:
558cdf0e10cSrcweir         SwPageFrm& mrPageFrm;
559cdf0e10cSrcweir 
_UnlockPositionOfObjs()560cdf0e10cSrcweir         void _UnlockPositionOfObjs()
561cdf0e10cSrcweir         {
562cdf0e10cSrcweir             SwSortedObjs* pObjs = mrPageFrm.GetSortedObjs();
563cdf0e10cSrcweir             if ( pObjs )
564cdf0e10cSrcweir             {
565cdf0e10cSrcweir                 sal_uInt32 i = 0;
566cdf0e10cSrcweir                 for ( ; i < pObjs->Count(); ++i )
567cdf0e10cSrcweir                 {
568cdf0e10cSrcweir                     SwAnchoredObject* pObj = (*pObjs)[i];
569cdf0e10cSrcweir                     pObj->UnlockPosition();
570cdf0e10cSrcweir                 }
571cdf0e10cSrcweir             }
572cdf0e10cSrcweir         }
573cdf0e10cSrcweir     public:
NotifyLayoutOfPageInProgress(SwPageFrm & _rPageFrm)574cdf0e10cSrcweir         NotifyLayoutOfPageInProgress( SwPageFrm& _rPageFrm )
575cdf0e10cSrcweir             : mrPageFrm( _rPageFrm )
576cdf0e10cSrcweir         {
577cdf0e10cSrcweir             _UnlockPositionOfObjs();
578cdf0e10cSrcweir             _rPageFrm.SetLayoutInProgress( true );
579cdf0e10cSrcweir         }
~NotifyLayoutOfPageInProgress()580cdf0e10cSrcweir         ~NotifyLayoutOfPageInProgress()
581cdf0e10cSrcweir         {
582cdf0e10cSrcweir             mrPageFrm.SetLayoutInProgress( false );
583cdf0e10cSrcweir             _UnlockPositionOfObjs();
584cdf0e10cSrcweir         }
585cdf0e10cSrcweir };
586cdf0e10cSrcweir // <--
587cdf0e10cSrcweir 
InternalAction()588cdf0e10cSrcweir void SwLayAction::InternalAction()
589cdf0e10cSrcweir {
590cdf0e10cSrcweir     ASSERT( pRoot->Lower()->IsPageFrm(), ":-( Keine Seite unterhalb der Root.");
591cdf0e10cSrcweir 
592cdf0e10cSrcweir     pRoot->Calc();
593cdf0e10cSrcweir 
594cdf0e10cSrcweir     //Die erste ungueltige bzw. zu formatierende Seite ermitteln.
595cdf0e10cSrcweir     //Bei einer Complete-Action ist es die erste ungueltige; mithin ist die
596cdf0e10cSrcweir     //erste zu formatierende Seite diejenige Seite mit der Numemr eins.
597cdf0e10cSrcweir     //Bei einer Luegen-Formatierung ist die Nummer der erste Seite die Nummer
598cdf0e10cSrcweir     //der ersten Sichtbaren Seite.
599cdf0e10cSrcweir     SwPageFrm *pPage = IsComplete() ? (SwPageFrm*)pRoot->Lower() :
600cdf0e10cSrcweir                 pImp->GetFirstVisPage();
601cdf0e10cSrcweir     if ( !pPage )
602cdf0e10cSrcweir         pPage = (SwPageFrm*)pRoot->Lower();
603cdf0e10cSrcweir 
604cdf0e10cSrcweir     //Wenn ein "Erster-Fliess-Cntnt" innerhalb der der ersten sichtbaren Seite
605cdf0e10cSrcweir     //ein Follow ist, so schalten wir die Seite zurueck auf den Ur-Master dieses
606cdf0e10cSrcweir     //Cntnt's
607cdf0e10cSrcweir     if ( !IsComplete() )
608cdf0e10cSrcweir         pPage = CheckFirstVisPage( pPage );
609cdf0e10cSrcweir     sal_uInt16 nFirstPageNum = pPage->GetPhyPageNum();
610cdf0e10cSrcweir 
611cdf0e10cSrcweir     while ( pPage && !pPage->IsInvalid() && !pPage->IsInvalidFly() )
612cdf0e10cSrcweir         pPage = (SwPageFrm*)pPage->GetNext();
613cdf0e10cSrcweir 
614cdf0e10cSrcweir     IDocumentLayoutAccess *pLayoutAccess = pRoot->GetFmt()->getIDocumentLayoutAccess();
615cdf0e10cSrcweir     sal_Bool bNoLoop = pPage ? SwLayouter::StartLoopControl( pRoot->GetFmt()->GetDoc(), pPage ) : sal_False;
616cdf0e10cSrcweir     sal_uInt16 nPercentPageNum = 0;
617cdf0e10cSrcweir     while ( (pPage && !IsInterrupt()) || nCheckPageNum != USHRT_MAX )
618cdf0e10cSrcweir     {
619cdf0e10cSrcweir         if ( !pPage && nCheckPageNum != USHRT_MAX &&
620cdf0e10cSrcweir              (!pPage || pPage->GetPhyPageNum() >= nCheckPageNum) )
621cdf0e10cSrcweir         {
622cdf0e10cSrcweir             if ( !pPage || pPage->GetPhyPageNum() > nCheckPageNum )
623cdf0e10cSrcweir             {
624cdf0e10cSrcweir                 SwPageFrm *pPg = (SwPageFrm*)pRoot->Lower();
625cdf0e10cSrcweir                 while ( pPg && pPg->GetPhyPageNum() < nCheckPageNum )
626cdf0e10cSrcweir                     pPg = (SwPageFrm*)pPg->GetNext();
627cdf0e10cSrcweir                 if ( pPg )
628cdf0e10cSrcweir                     pPage = pPg;
629cdf0e10cSrcweir                 if ( !pPage )
630cdf0e10cSrcweir                     break;
631cdf0e10cSrcweir             }
632cdf0e10cSrcweir             SwPageFrm *pTmp = pPage->GetPrev() ?
633cdf0e10cSrcweir                                         (SwPageFrm*)pPage->GetPrev() : pPage;
634cdf0e10cSrcweir             SetCheckPages( sal_True );
635cdf0e10cSrcweir             SwFrm::CheckPageDescs( pPage );
636cdf0e10cSrcweir             SetCheckPages( sal_False );
637cdf0e10cSrcweir             nCheckPageNum = USHRT_MAX;
638cdf0e10cSrcweir             pPage = pTmp;
639cdf0e10cSrcweir             continue;
640cdf0e10cSrcweir         }
641cdf0e10cSrcweir 
642cdf0e10cSrcweir         if ( nEndPage != USHRT_MAX && pPage->GetPhyPageNum() > nPercentPageNum )
643cdf0e10cSrcweir         {
644cdf0e10cSrcweir             nPercentPageNum = pPage->GetPhyPageNum();
645cdf0e10cSrcweir             ::SetProgressState( nPercentPageNum, pImp->GetShell()->GetDoc()->GetDocShell());
646cdf0e10cSrcweir         }
647cdf0e10cSrcweir         pOptTab = 0;
648cdf0e10cSrcweir              //Kein ShortCut fuer Idle oder CalcLayout
649cdf0e10cSrcweir         if ( !IsIdle() && !IsComplete() && IsShortCut( pPage ) )
650cdf0e10cSrcweir         {
651cdf0e10cSrcweir             pRoot->DeleteEmptySct();
652cdf0e10cSrcweir             XCHECKPAGE;
653cdf0e10cSrcweir             if ( !IsInterrupt() &&
654cdf0e10cSrcweir                  (pRoot->IsSuperfluous() || pRoot->IsAssertFlyPages()) )
655cdf0e10cSrcweir             {
656cdf0e10cSrcweir                 if ( pRoot->IsAssertFlyPages() )
657cdf0e10cSrcweir                     pRoot->AssertFlyPages();
658cdf0e10cSrcweir                 if ( pRoot->IsSuperfluous() )
659cdf0e10cSrcweir                 {
660cdf0e10cSrcweir                     sal_Bool bOld = IsAgain();
661cdf0e10cSrcweir                     pRoot->RemoveSuperfluous();
662cdf0e10cSrcweir                     bAgain = bOld;
663cdf0e10cSrcweir                 }
664cdf0e10cSrcweir                 if ( IsAgain() )
665cdf0e10cSrcweir                 {
666cdf0e10cSrcweir                     if( bNoLoop )
667cdf0e10cSrcweir                         pLayoutAccess->GetLayouter()->EndLoopControl();
668cdf0e10cSrcweir                     return;
669cdf0e10cSrcweir                 }
670cdf0e10cSrcweir                 pPage = (SwPageFrm*)pRoot->Lower();
671cdf0e10cSrcweir                 while ( pPage && !pPage->IsInvalid() && !pPage->IsInvalidFly() )
672cdf0e10cSrcweir                     pPage = (SwPageFrm*)pPage->GetNext();
673cdf0e10cSrcweir                 while ( pPage && pPage->GetNext() &&
674cdf0e10cSrcweir                         pPage->GetPhyPageNum() < nFirstPageNum )
675cdf0e10cSrcweir                     pPage = (SwPageFrm*)pPage->GetNext();
676cdf0e10cSrcweir                 continue;
677cdf0e10cSrcweir             }
678cdf0e10cSrcweir             break;
679cdf0e10cSrcweir         }
680cdf0e10cSrcweir         else
681cdf0e10cSrcweir         {
682cdf0e10cSrcweir             pRoot->DeleteEmptySct();
683cdf0e10cSrcweir             XCHECKPAGE;
684cdf0e10cSrcweir 
685cdf0e10cSrcweir             // OD 2004-05-12 #i28701# - scope for instance of class
686cdf0e10cSrcweir             // <NotifyLayoutOfPageInProgress>
687cdf0e10cSrcweir             {
688cdf0e10cSrcweir                 NotifyLayoutOfPageInProgress aLayoutOfPageInProgress( *pPage );
689cdf0e10cSrcweir 
690cdf0e10cSrcweir                 while ( !IsInterrupt() && !IsNextCycle() &&
691cdf0e10cSrcweir                         ((IS_FLYS && IS_INVAFLY) || pPage->IsInvalid()) )
692cdf0e10cSrcweir                 {
693cdf0e10cSrcweir                     // OD 2004-05-10 #i28701#
694cdf0e10cSrcweir                     SwObjectFormatter::FormatObjsAtFrm( *pPage, *pPage, this );
695cdf0e10cSrcweir                     if ( !IS_FLYS )
696cdf0e10cSrcweir                     {
697cdf0e10cSrcweir                         //Wenn keine Flys (mehr) da sind, sind die Flags
698cdf0e10cSrcweir                         //mehr als fluessig.
699cdf0e10cSrcweir                         pPage->ValidateFlyLayout();
700cdf0e10cSrcweir                         pPage->ValidateFlyCntnt();
701cdf0e10cSrcweir                     }
702cdf0e10cSrcweir                     // OD 2004-05-10 #i28701# - change condition
703cdf0e10cSrcweir                     while ( !IsInterrupt() && !IsNextCycle() &&
704cdf0e10cSrcweir                             ( pPage->IsInvalid() ||
705cdf0e10cSrcweir                               (IS_FLYS && IS_INVAFLY) ) )
706cdf0e10cSrcweir                     {
707cdf0e10cSrcweir                         PROTOCOL( pPage, PROT_FILE_INIT, 0, 0)
708cdf0e10cSrcweir                         XCHECKPAGE;
709cdf0e10cSrcweir 
710cdf0e10cSrcweir                         // FME 2007-08-30 #i81146# new loop control
711cdf0e10cSrcweir                         sal_uInt16 nLoopControlRuns_1 = 0;
712cdf0e10cSrcweir                         const sal_uInt16 nLoopControlMax = 20;
713cdf0e10cSrcweir 
714cdf0e10cSrcweir                         while ( !IsNextCycle() && pPage->IsInvalidLayout() )
715cdf0e10cSrcweir                         {
716cdf0e10cSrcweir                             pPage->ValidateLayout();
717cdf0e10cSrcweir 
718cdf0e10cSrcweir                             if ( ++nLoopControlRuns_1 > nLoopControlMax )
719cdf0e10cSrcweir                             {
720cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
721cdf0e10cSrcweir                                 ASSERT( false, "LoopControl_1 in SwLayAction::InternalAction" )
722cdf0e10cSrcweir #endif
723cdf0e10cSrcweir                                 break;
724cdf0e10cSrcweir                             }
725cdf0e10cSrcweir 
726cdf0e10cSrcweir                             FormatLayout( pPage );
727cdf0e10cSrcweir                             XCHECKPAGE;
728cdf0e10cSrcweir                         }
729cdf0e10cSrcweir                         // OD 2004-05-10 #i28701# - change condition
730cdf0e10cSrcweir                         if ( !IsNextCycle() &&
731cdf0e10cSrcweir                              ( pPage->IsInvalidCntnt() ||
732cdf0e10cSrcweir                                (IS_FLYS && IS_INVAFLY) ) )
733cdf0e10cSrcweir                         {
734cdf0e10cSrcweir                             pPage->ValidateFlyInCnt();
735cdf0e10cSrcweir                             pPage->ValidateCntnt();
736cdf0e10cSrcweir                             // --> OD 2004-05-10 #i28701#
737cdf0e10cSrcweir                             pPage->ValidateFlyLayout();
738cdf0e10cSrcweir                             pPage->ValidateFlyCntnt();
739cdf0e10cSrcweir                             // <--
740cdf0e10cSrcweir                             if ( !FormatCntnt( pPage ) )
741cdf0e10cSrcweir                             {
742cdf0e10cSrcweir                                 XCHECKPAGE;
743cdf0e10cSrcweir                                 pPage->InvalidateCntnt();
744cdf0e10cSrcweir                                 pPage->InvalidateFlyInCnt();
745cdf0e10cSrcweir                                 // --> OD 2004-05-10 #i28701#
746cdf0e10cSrcweir                                 pPage->InvalidateFlyLayout();
747cdf0e10cSrcweir                                 pPage->InvalidateFlyCntnt();
748cdf0e10cSrcweir                                 // <--
749cdf0e10cSrcweir                                 if ( IsBrowseActionStop() )
750cdf0e10cSrcweir                                     bInput = sal_True;
751cdf0e10cSrcweir                             }
752cdf0e10cSrcweir                         }
753cdf0e10cSrcweir                         if( bNoLoop )
754cdf0e10cSrcweir                             pLayoutAccess->GetLayouter()->LoopControl( pPage, LOOP_PAGE );
755cdf0e10cSrcweir                     }
756cdf0e10cSrcweir                 }
757cdf0e10cSrcweir             } // end of scope for instance of class <NotifyLayoutOfPageInProgress>
758cdf0e10cSrcweir 
759cdf0e10cSrcweir 
760cdf0e10cSrcweir             //Eine vorige Seite kann wieder invalid sein.
761cdf0e10cSrcweir             XCHECKPAGE;
762cdf0e10cSrcweir             if ( !IS_FLYS )
763cdf0e10cSrcweir             {
764cdf0e10cSrcweir                 //Wenn keine Flys (mehr) da sind, sind die Flags
765cdf0e10cSrcweir                 //mehr als fluessig.
766cdf0e10cSrcweir                 pPage->ValidateFlyLayout();
767cdf0e10cSrcweir                 pPage->ValidateFlyCntnt();
768cdf0e10cSrcweir             }
769cdf0e10cSrcweir             if ( !IsInterrupt() )
770cdf0e10cSrcweir             {
771cdf0e10cSrcweir                 SetNextCycle( sal_False );
772cdf0e10cSrcweir 
773cdf0e10cSrcweir                 if ( nPreInvaPage != USHRT_MAX )
774cdf0e10cSrcweir                 {
775cdf0e10cSrcweir                     if( !IsComplete() && nPreInvaPage + 2 < nFirstPageNum )
776cdf0e10cSrcweir                     {
777cdf0e10cSrcweir                         pImp->SetFirstVisPageInvalid();
778cdf0e10cSrcweir                         SwPageFrm *pTmpPage = pImp->GetFirstVisPage();
779cdf0e10cSrcweir                         nFirstPageNum = pTmpPage->GetPhyPageNum();
780cdf0e10cSrcweir                         if( nPreInvaPage < nFirstPageNum )
781cdf0e10cSrcweir                         {
782cdf0e10cSrcweir                             nPreInvaPage = nFirstPageNum;
783cdf0e10cSrcweir                             pPage = pTmpPage;
784cdf0e10cSrcweir                         }
785cdf0e10cSrcweir                     }
786cdf0e10cSrcweir                     while ( pPage->GetPrev() && pPage->GetPhyPageNum() > nPreInvaPage )
787cdf0e10cSrcweir                         pPage = (SwPageFrm*)pPage->GetPrev();
788cdf0e10cSrcweir                     nPreInvaPage = USHRT_MAX;
789cdf0e10cSrcweir                 }
790cdf0e10cSrcweir 
791cdf0e10cSrcweir                 while ( pPage->GetPrev() &&
792cdf0e10cSrcweir                         ( ((SwPageFrm*)pPage->GetPrev())->IsInvalid() ||
793cdf0e10cSrcweir                           ( ((SwPageFrm*)pPage->GetPrev())->GetSortedObjs() &&
794cdf0e10cSrcweir                             ((SwPageFrm*)pPage->GetPrev())->IsInvalidFly())) &&
795cdf0e10cSrcweir                         (((SwPageFrm*)pPage->GetPrev())->GetPhyPageNum() >=
796cdf0e10cSrcweir                             nFirstPageNum) )
797cdf0e10cSrcweir                 {
798cdf0e10cSrcweir                     pPage = (SwPageFrm*)pPage->GetPrev();
799cdf0e10cSrcweir                 }
800cdf0e10cSrcweir 
801cdf0e10cSrcweir                 //Weiter bis zur naechsten invaliden Seite.
802cdf0e10cSrcweir                 while ( pPage && !pPage->IsInvalid() &&
803cdf0e10cSrcweir                         (!IS_FLYS || !IS_INVAFLY) )
804cdf0e10cSrcweir                 {
805cdf0e10cSrcweir                     pPage = (SwPageFrm*)pPage->GetNext();
806cdf0e10cSrcweir                 }
807cdf0e10cSrcweir                 if( bNoLoop )
808cdf0e10cSrcweir                     pLayoutAccess->GetLayouter()->LoopControl( pPage, LOOP_PAGE );
809cdf0e10cSrcweir             }
810cdf0e10cSrcweir             CheckIdleEnd();
811cdf0e10cSrcweir         }
812cdf0e10cSrcweir         if ( !pPage && !IsInterrupt() &&
813cdf0e10cSrcweir              (pRoot->IsSuperfluous() || pRoot->IsAssertFlyPages()) )
814cdf0e10cSrcweir         {
815cdf0e10cSrcweir             if ( pRoot->IsAssertFlyPages() )
816cdf0e10cSrcweir                 pRoot->AssertFlyPages();
817cdf0e10cSrcweir             if ( pRoot->IsSuperfluous() )
818cdf0e10cSrcweir             {
819cdf0e10cSrcweir                 sal_Bool bOld = IsAgain();
820cdf0e10cSrcweir                 pRoot->RemoveSuperfluous();
821cdf0e10cSrcweir                 bAgain = bOld;
822cdf0e10cSrcweir             }
823cdf0e10cSrcweir             if ( IsAgain() )
824cdf0e10cSrcweir             {
825cdf0e10cSrcweir                 if( bNoLoop )
826cdf0e10cSrcweir                     pLayoutAccess->GetLayouter()->EndLoopControl();
827cdf0e10cSrcweir                 return;
828cdf0e10cSrcweir             }
829cdf0e10cSrcweir             pPage = (SwPageFrm*)pRoot->Lower();
830cdf0e10cSrcweir             while ( pPage && !pPage->IsInvalid() && !pPage->IsInvalidFly() )
831cdf0e10cSrcweir                 pPage = (SwPageFrm*)pPage->GetNext();
832cdf0e10cSrcweir             while ( pPage && pPage->GetNext() &&
833cdf0e10cSrcweir                     pPage->GetPhyPageNum() < nFirstPageNum )
834cdf0e10cSrcweir                 pPage = (SwPageFrm*)pPage->GetNext();
835cdf0e10cSrcweir         }
836cdf0e10cSrcweir     }
837cdf0e10cSrcweir     if ( IsInterrupt() && pPage )
838cdf0e10cSrcweir     {
839cdf0e10cSrcweir         //Wenn ein Input anliegt wollen wir keinen Inhalt mehr Formatieren,
840cdf0e10cSrcweir         //Das Layout muessen wir aber schon in Ordnung bringen.
841cdf0e10cSrcweir         //Andernfalls kann folgende Situation auftreten (Bug: 3244):
842e421cc8fSmseidel         //Am Ende des Absatz der letzten Seite wird Text eingegeben, so dass
843cdf0e10cSrcweir         //der Absatz einen Follow fuer die nachste Seite erzeugt, ausserdem
844cdf0e10cSrcweir         //wird gleich schnell weitergetippt - Es liegt waehrend der
845cdf0e10cSrcweir         //Verarbeitung ein Input an. Der Absatz auf der neuen Seite wurde
846cdf0e10cSrcweir         //bereits anformatiert, die neue Seite ist Formatiert und steht
847cdf0e10cSrcweir         //auf CompletePaint, hat sich aber noch nicht im Auszugebenden Bereich
848cdf0e10cSrcweir         //eingetragen. Es wird gepaintet, das CompletePaint der Seite wird
849cdf0e10cSrcweir         //zurueckgesetzt weil der neue Absatz sich bereits eingetragen hatte,
850cdf0e10cSrcweir         //aber die Raender der Seite werden nicht gepaintet. Naja, bei der
851cdf0e10cSrcweir         //zwangslaeufig auftretenden naechsten LayAction traegt sich die Seite
852cdf0e10cSrcweir         //nicht mehr ein, weil ihre (LayoutFrm-)Flags bereits zurueckgesetzt
853cdf0e10cSrcweir         //wurden -- Der Rand der Seite wird nie gepaintet.
854cdf0e10cSrcweir         SwPageFrm *pPg = pPage;
855cdf0e10cSrcweir         XCHECKPAGE;
856cdf0e10cSrcweir         const SwRect &rVis = pImp->GetShell()->VisArea();
857cdf0e10cSrcweir 
858cdf0e10cSrcweir         while( pPg && pPg->Frm().Bottom() < rVis.Top() )
859cdf0e10cSrcweir             pPg = (SwPageFrm*)pPg->GetNext();
860cdf0e10cSrcweir         if( pPg != pPage )
861cdf0e10cSrcweir             pPg = pPg ? (SwPageFrm*)pPg->GetPrev() : pPage;
862cdf0e10cSrcweir 
863cdf0e10cSrcweir         // OD 14.04.2003 #106346# - set flag for interrupt content formatting
864cdf0e10cSrcweir         mbFormatCntntOnInterrupt = IsInput() && !IsStopPrt();
865cdf0e10cSrcweir         long nBottom = rVis.Bottom();
866cdf0e10cSrcweir         // --> OD 2005-02-15 #i42586# - format current page, if idle action is active
867cdf0e10cSrcweir         // This is an optimization for the case that the interrupt is created by
868cdf0e10cSrcweir         // the move of a form control object, which is represented by a window.
869cdf0e10cSrcweir         while ( pPg && ( pPg->Frm().Top() < nBottom ||
870cdf0e10cSrcweir                          ( IsIdle() && pPg == pPage ) ) )
871cdf0e10cSrcweir         // <--
872cdf0e10cSrcweir         {
873cdf0e10cSrcweir             // --> OD 2004-10-11 #i26945# - follow-up of #i28701#
874cdf0e10cSrcweir             NotifyLayoutOfPageInProgress aLayoutOfPageInProgress( *pPg );
875cdf0e10cSrcweir 
876cdf0e10cSrcweir             XCHECKPAGE;
877cdf0e10cSrcweir 
878cdf0e10cSrcweir             // FME 2007-08-30 #i81146# new loop control
879cdf0e10cSrcweir             sal_uInt16 nLoopControlRuns_2 = 0;
880cdf0e10cSrcweir             const sal_uInt16 nLoopControlMax = 20;
881cdf0e10cSrcweir 
882cdf0e10cSrcweir             // OD 14.04.2003 #106346# - special case: interrupt content formatting
883cdf0e10cSrcweir             // --> OD 2004-07-08 #i28701# - conditions, introduced by #106346#,
884cdf0e10cSrcweir             // are incorrect (marcos IS_FLYS and IS_INVAFLY only works for <pPage>)
885cdf0e10cSrcweir             // and are too strict.
886cdf0e10cSrcweir             // --> OD 2005-06-09 #i50432# - adjust interrupt formatting to
887cdf0e10cSrcweir             // normal page formatting - see above.
888cdf0e10cSrcweir             while ( ( mbFormatCntntOnInterrupt &&
889cdf0e10cSrcweir                       ( pPg->IsInvalid() ||
890cdf0e10cSrcweir                         ( pPg->GetSortedObjs() && pPg->IsInvalidFly() ) ) ) ||
891cdf0e10cSrcweir                     ( !mbFormatCntntOnInterrupt && pPg->IsInvalidLayout() ) )
892cdf0e10cSrcweir             {
893cdf0e10cSrcweir                 XCHECKPAGE;
894cdf0e10cSrcweir                 // --> OD 2005-06-09 #i50432# - format also at-page anchored objects
895cdf0e10cSrcweir                 SwObjectFormatter::FormatObjsAtFrm( *pPg, *pPg, this );
896cdf0e10cSrcweir                 // <--
897cdf0e10cSrcweir                 // --> OD 2005-06-09 #i50432#
898cdf0e10cSrcweir                 if ( !pPg->GetSortedObjs() )
899cdf0e10cSrcweir                 {
900cdf0e10cSrcweir                     pPg->ValidateFlyLayout();
901cdf0e10cSrcweir                     pPg->ValidateFlyCntnt();
902cdf0e10cSrcweir                 }
903cdf0e10cSrcweir                 // <--
904cdf0e10cSrcweir 
905cdf0e10cSrcweir                 // FME 2007-08-30 #i81146# new loop control
906cdf0e10cSrcweir                 sal_uInt16 nLoopControlRuns_3 = 0;
907cdf0e10cSrcweir 
908cdf0e10cSrcweir                 while ( pPg->IsInvalidLayout() )
909cdf0e10cSrcweir                 {
910cdf0e10cSrcweir                     pPg->ValidateLayout();
911cdf0e10cSrcweir 
912cdf0e10cSrcweir                     if ( ++nLoopControlRuns_3 > nLoopControlMax )
913cdf0e10cSrcweir                     {
914cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
915cdf0e10cSrcweir                         ASSERT( false, "LoopControl_3 in Interrupt formatting in SwLayAction::InternalAction" )
916cdf0e10cSrcweir #endif
917cdf0e10cSrcweir                         break;
918cdf0e10cSrcweir                     }
919cdf0e10cSrcweir 
920cdf0e10cSrcweir                     FormatLayout( pPg );
921cdf0e10cSrcweir                     XCHECKPAGE;
922cdf0e10cSrcweir                 }
923cdf0e10cSrcweir 
924cdf0e10cSrcweir                 // --> OD 2005-06-09 #i50432#
925cdf0e10cSrcweir                 if ( mbFormatCntntOnInterrupt &&
926cdf0e10cSrcweir                      ( pPg->IsInvalidCntnt() ||
927cdf0e10cSrcweir                        ( pPg->GetSortedObjs() && pPg->IsInvalidFly() ) ) )
928cdf0e10cSrcweir                 // <--
929cdf0e10cSrcweir                 {
930cdf0e10cSrcweir                     pPg->ValidateFlyInCnt();
931cdf0e10cSrcweir                     pPg->ValidateCntnt();
932cdf0e10cSrcweir                     // --> OD 2004-05-10 #i26945# - follow-up of fix #117736#
933cdf0e10cSrcweir                     pPg->ValidateFlyLayout();
934cdf0e10cSrcweir                     pPg->ValidateFlyCntnt();
935cdf0e10cSrcweir                     // <--
936cdf0e10cSrcweir 
937cdf0e10cSrcweir                     if ( ++nLoopControlRuns_2 > nLoopControlMax )
938cdf0e10cSrcweir                     {
939cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
940cdf0e10cSrcweir                         ASSERT( false, "LoopControl_2 in Interrupt formatting in SwLayAction::InternalAction" )
941cdf0e10cSrcweir #endif
942cdf0e10cSrcweir                         break;
943cdf0e10cSrcweir                     }
944cdf0e10cSrcweir 
945cdf0e10cSrcweir                     if ( !FormatCntnt( pPg ) )
946cdf0e10cSrcweir                     {
947cdf0e10cSrcweir                         XCHECKPAGE;
948cdf0e10cSrcweir                         pPg->InvalidateCntnt();
949cdf0e10cSrcweir                         pPg->InvalidateFlyInCnt();
950cdf0e10cSrcweir                         // --> OD 2004-05-10 #i26945# - follow-up of fix #117736#
951cdf0e10cSrcweir                         pPg->InvalidateFlyLayout();
952cdf0e10cSrcweir                         pPg->InvalidateFlyCntnt();
953cdf0e10cSrcweir                         // <--
954cdf0e10cSrcweir                     }
955*0c72d66fSmseidel                     // --> OD 2005-04-06 #i46807# - we are satisfied, if the
956cdf0e10cSrcweir                     // content is formatted once complete.
957cdf0e10cSrcweir                     else
958cdf0e10cSrcweir                     {
959cdf0e10cSrcweir                         break;
960cdf0e10cSrcweir                     }
961cdf0e10cSrcweir                     // <--
962cdf0e10cSrcweir                 }
963cdf0e10cSrcweir             }
964cdf0e10cSrcweir             // <--
965cdf0e10cSrcweir             pPg = (SwPageFrm*)pPg->GetNext();
966cdf0e10cSrcweir         }
967cdf0e10cSrcweir         // OD 14.04.2003 #106346# - reset flag for special interrupt content formatting.
968cdf0e10cSrcweir         mbFormatCntntOnInterrupt = sal_False;
969cdf0e10cSrcweir     }
970cdf0e10cSrcweir     pOptTab = 0;
971cdf0e10cSrcweir     if( bNoLoop )
972cdf0e10cSrcweir         pLayoutAccess->GetLayouter()->EndLoopControl();
973cdf0e10cSrcweir }
974cdf0e10cSrcweir /*************************************************************************
975cdf0e10cSrcweir |*
976cdf0e10cSrcweir |*  SwLayAction::TurboAction(), _TurboAction()
977cdf0e10cSrcweir |*
978cdf0e10cSrcweir |*  Ersterstellung      MA 04. Dec. 92
979cdf0e10cSrcweir |*  Letzte Aenderung    MA 15. Aug. 93
980cdf0e10cSrcweir |*
981cdf0e10cSrcweir |*************************************************************************/
_TurboAction(const SwCntntFrm * pCnt)982cdf0e10cSrcweir sal_Bool SwLayAction::_TurboAction( const SwCntntFrm *pCnt )
983cdf0e10cSrcweir {
984cdf0e10cSrcweir 
985cdf0e10cSrcweir     const SwPageFrm *pPage = 0;
986cdf0e10cSrcweir     if ( !pCnt->IsValid() || pCnt->IsCompletePaint() || pCnt->IsRetouche() )
987cdf0e10cSrcweir     {
988cdf0e10cSrcweir         const SwRect aOldRect( pCnt->UnionFrm( sal_True ) );
989cdf0e10cSrcweir         const long   nOldBottom = pCnt->Frm().Top() + pCnt->Prt().Bottom();
990cdf0e10cSrcweir         pCnt->Calc();
991cdf0e10cSrcweir         if ( pCnt->Frm().Bottom() < aOldRect.Bottom() )
992cdf0e10cSrcweir             pCnt->SetRetouche();
993cdf0e10cSrcweir 
994cdf0e10cSrcweir         pPage = pCnt->FindPageFrm();
995cdf0e10cSrcweir         PaintCntnt( pCnt, pPage, aOldRect, nOldBottom );
996cdf0e10cSrcweir 
997cdf0e10cSrcweir         if ( !pCnt->GetValidLineNumFlag() && pCnt->IsTxtFrm() )
998cdf0e10cSrcweir         {
999cdf0e10cSrcweir             const sal_uLong nAllLines = ((SwTxtFrm*)pCnt)->GetAllLines();
1000cdf0e10cSrcweir             ((SwTxtFrm*)pCnt)->RecalcAllLines();
1001cdf0e10cSrcweir             if ( nAllLines != ((SwTxtFrm*)pCnt)->GetAllLines() )
1002cdf0e10cSrcweir             {
1003cdf0e10cSrcweir                 if ( IsPaintExtraData() )
1004cdf0e10cSrcweir                     pImp->GetShell()->AddPaintRect( pCnt->Frm() );
1005cdf0e10cSrcweir                 //Damit die restlichen LineNums auf der Seite bereichnet werden
1006cdf0e10cSrcweir                 //und nicht hier abgebrochen wird.
1007cdf0e10cSrcweir                 //Das im RecalcAllLines zu erledigen waere teuer, weil dort
1008cdf0e10cSrcweir                 //auch in unnoetigen Faellen (normale Action) auch immer die
1009cdf0e10cSrcweir                 //Seite benachrichtigt werden muesste.
1010cdf0e10cSrcweir                 const SwCntntFrm *pNxt = pCnt->GetNextCntntFrm();
1011cdf0e10cSrcweir                 while ( pNxt &&
1012cdf0e10cSrcweir                         (pNxt->IsInTab() || pNxt->IsInDocBody() != pCnt->IsInDocBody()) )
1013cdf0e10cSrcweir                     pNxt = pNxt->GetNextCntntFrm();
1014cdf0e10cSrcweir                 if ( pNxt )
1015cdf0e10cSrcweir                     pNxt->InvalidatePage();
1016cdf0e10cSrcweir             }
1017cdf0e10cSrcweir             return sal_False;
1018cdf0e10cSrcweir         }
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir         if ( pPage->IsInvalidLayout() || (IS_FLYS && IS_INVAFLY) )
1021cdf0e10cSrcweir             return sal_False;
1022cdf0e10cSrcweir     }
1023cdf0e10cSrcweir     if ( !pPage )
1024cdf0e10cSrcweir         pPage = pCnt->FindPageFrm();
1025cdf0e10cSrcweir 
1026cdf0e10cSrcweir     // OD 2004-05-10 #i28701# - format floating screen objects at content frame.
1027cdf0e10cSrcweir     if ( pCnt->IsTxtFrm() &&
1028cdf0e10cSrcweir          !SwObjectFormatter::FormatObjsAtFrm( *(const_cast<SwCntntFrm*>(pCnt)),
1029cdf0e10cSrcweir                                               *pPage, this ) )
1030cdf0e10cSrcweir     {
1031cdf0e10cSrcweir         return sal_False;
1032cdf0e10cSrcweir     }
1033cdf0e10cSrcweir 
1034cdf0e10cSrcweir     if ( pPage->IsInvalidCntnt() )
1035cdf0e10cSrcweir         return sal_False;
1036cdf0e10cSrcweir     return sal_True;
1037cdf0e10cSrcweir }
1038cdf0e10cSrcweir 
TurboAction()1039cdf0e10cSrcweir sal_Bool SwLayAction::TurboAction()
1040cdf0e10cSrcweir {
1041cdf0e10cSrcweir     sal_Bool bRet = sal_True;
1042cdf0e10cSrcweir 
1043cdf0e10cSrcweir     if ( pRoot->GetTurbo() )
1044cdf0e10cSrcweir     {
1045cdf0e10cSrcweir         if ( !_TurboAction( pRoot->GetTurbo() ) )
1046cdf0e10cSrcweir         {
1047cdf0e10cSrcweir             CheckIdleEnd();
1048cdf0e10cSrcweir             bRet = sal_False;
1049cdf0e10cSrcweir         }
1050cdf0e10cSrcweir         pRoot->ResetTurbo();
1051cdf0e10cSrcweir     }
1052cdf0e10cSrcweir     else
1053cdf0e10cSrcweir         bRet = sal_False;
1054cdf0e10cSrcweir     return bRet;
1055cdf0e10cSrcweir }
1056cdf0e10cSrcweir /*************************************************************************
1057cdf0e10cSrcweir |*
1058cdf0e10cSrcweir |*  SwLayAction::IsShortCut()
1059cdf0e10cSrcweir |*
1060cdf0e10cSrcweir |*  Beschreibung:       Liefert ein True, wenn die Seite vollstaendig unter
1061cdf0e10cSrcweir |*      oder rechts neben dem sichbaren Bereich liegt.
1062cdf0e10cSrcweir |*      Es kann passieren, dass sich die Verhaeltnisse derart aendern, dass
1063cdf0e10cSrcweir |*      die Verarbeitung (des Aufrufers!) mit der Vorgaengerseite der
1064*0c72d66fSmseidel |*      uebergebenen Seite weitergefuehrt werden muss. Der Parameter wird
1065*0c72d66fSmseidel |*      also ggf. veraendert!
1066cdf0e10cSrcweir |*      Fuer den BrowseMode kann auch dann der ShortCut aktiviert werden,
1067cdf0e10cSrcweir |*      wenn der ungueltige Inhalt der Seite unterhalb des sichbaren
1068cdf0e10cSrcweir |*      bereiches liegt.
1069cdf0e10cSrcweir |*  Ersterstellung      MA 30. Oct. 92
1070cdf0e10cSrcweir |*  Letzte Aenderung    MA 18. Jul. 96
1071cdf0e10cSrcweir |*
1072cdf0e10cSrcweir |*************************************************************************/
lcl_IsInvaLay(const SwFrm * pFrm,long nBottom)1073cdf0e10cSrcweir static bool lcl_IsInvaLay( const SwFrm *pFrm, long nBottom )
1074cdf0e10cSrcweir {
1075cdf0e10cSrcweir     if (
1076cdf0e10cSrcweir          !pFrm->IsValid() ||
1077cdf0e10cSrcweir          (pFrm->IsCompletePaint() && ( pFrm->Frm().Top() < nBottom ) )
1078cdf0e10cSrcweir        )
1079cdf0e10cSrcweir     {
1080cdf0e10cSrcweir         return true;
1081cdf0e10cSrcweir     }
1082cdf0e10cSrcweir     return false;
1083cdf0e10cSrcweir }
1084cdf0e10cSrcweir 
lcl_FindFirstInvaLay(const SwFrm * pFrm,long nBottom)1085cdf0e10cSrcweir static const SwFrm *lcl_FindFirstInvaLay( const SwFrm *pFrm, long nBottom )
1086cdf0e10cSrcweir {
1087cdf0e10cSrcweir     ASSERT( pFrm->IsLayoutFrm(), "FindFirstInvaLay, no LayFrm" );
1088cdf0e10cSrcweir 
1089cdf0e10cSrcweir     if (lcl_IsInvaLay(pFrm, nBottom))
1090cdf0e10cSrcweir         return pFrm;
1091cdf0e10cSrcweir     pFrm = ((SwLayoutFrm*)pFrm)->Lower();
1092cdf0e10cSrcweir     while ( pFrm )
1093cdf0e10cSrcweir     {
1094cdf0e10cSrcweir         if ( pFrm->IsLayoutFrm() )
1095cdf0e10cSrcweir         {
1096cdf0e10cSrcweir             if (lcl_IsInvaLay(pFrm, nBottom))
1097cdf0e10cSrcweir                 return pFrm;
1098cdf0e10cSrcweir             const SwFrm *pTmp;
1099cdf0e10cSrcweir             if ( 0 != (pTmp = lcl_FindFirstInvaLay( pFrm, nBottom )) )
1100cdf0e10cSrcweir                 return pTmp;
1101cdf0e10cSrcweir         }
1102cdf0e10cSrcweir         pFrm = pFrm->GetNext();
1103cdf0e10cSrcweir     }
1104cdf0e10cSrcweir     return 0;
1105cdf0e10cSrcweir }
1106cdf0e10cSrcweir 
lcl_FindFirstInvaCntnt(const SwLayoutFrm * pLay,long nBottom,const SwCntntFrm * pFirst)1107cdf0e10cSrcweir static const SwFrm *lcl_FindFirstInvaCntnt( const SwLayoutFrm *pLay, long nBottom,
1108cdf0e10cSrcweir                                      const SwCntntFrm *pFirst )
1109cdf0e10cSrcweir {
1110cdf0e10cSrcweir     const SwCntntFrm *pCnt = pFirst ? pFirst->GetNextCntntFrm() :
1111cdf0e10cSrcweir                                       pLay->ContainsCntnt();
1112cdf0e10cSrcweir     while ( pCnt )
1113cdf0e10cSrcweir     {
1114cdf0e10cSrcweir         if ( !pCnt->IsValid() || pCnt->IsCompletePaint() )
1115cdf0e10cSrcweir         {
1116cdf0e10cSrcweir             if ( pCnt->Frm().Top() <= nBottom )
1117cdf0e10cSrcweir                 return pCnt;
1118cdf0e10cSrcweir         }
1119cdf0e10cSrcweir 
1120cdf0e10cSrcweir         if ( pCnt->GetDrawObjs() )
1121cdf0e10cSrcweir         {
1122cdf0e10cSrcweir             const SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
1123cdf0e10cSrcweir             for ( sal_uInt16 i = 0; i < rObjs.Count(); ++i )
1124cdf0e10cSrcweir             {
1125cdf0e10cSrcweir                 const SwAnchoredObject* pObj = rObjs[i];
1126cdf0e10cSrcweir                 if ( pObj->ISA(SwFlyFrm) )
1127cdf0e10cSrcweir                 {
1128cdf0e10cSrcweir                     const SwFlyFrm* pFly = static_cast<const SwFlyFrm*>(pObj);
1129cdf0e10cSrcweir                     if ( pFly->IsFlyInCntFrm() )
1130cdf0e10cSrcweir                     {
1131cdf0e10cSrcweir                         if ( ((SwFlyInCntFrm*)pFly)->IsInvalid() ||
1132cdf0e10cSrcweir                              pFly->IsCompletePaint() )
1133cdf0e10cSrcweir                         {
1134cdf0e10cSrcweir                             if ( pFly->Frm().Top() <= nBottom )
1135cdf0e10cSrcweir                                 return pFly;
1136cdf0e10cSrcweir                         }
1137cdf0e10cSrcweir                         const SwFrm *pFrm = lcl_FindFirstInvaCntnt( pFly, nBottom, 0 );
1138cdf0e10cSrcweir                         if ( pFrm && pFrm->Frm().Bottom() <= nBottom )
1139cdf0e10cSrcweir                             return pFrm;
1140cdf0e10cSrcweir                     }
1141cdf0e10cSrcweir                 }
1142cdf0e10cSrcweir             }
1143cdf0e10cSrcweir         }
1144cdf0e10cSrcweir         if ( pCnt->Frm().Top() > nBottom && !pCnt->IsInTab() )
1145cdf0e10cSrcweir             return 0;
1146cdf0e10cSrcweir         pCnt = pCnt->GetNextCntntFrm();
1147cdf0e10cSrcweir         if ( !pLay->IsAnLower( pCnt ) )
1148cdf0e10cSrcweir             break;
1149cdf0e10cSrcweir     }
1150cdf0e10cSrcweir     return 0;
1151cdf0e10cSrcweir }
1152cdf0e10cSrcweir 
1153cdf0e10cSrcweir // --> OD 2005-02-21 #i37877# - consider drawing objects
lcl_FindFirstInvaObj(const SwPageFrm * _pPage,long _nBottom)1154cdf0e10cSrcweir static const SwAnchoredObject* lcl_FindFirstInvaObj( const SwPageFrm* _pPage,
1155cdf0e10cSrcweir                                               long _nBottom )
1156cdf0e10cSrcweir {
1157cdf0e10cSrcweir     ASSERT( _pPage->GetSortedObjs(), "FindFirstInvaObj, no Objs" )
1158cdf0e10cSrcweir 
1159cdf0e10cSrcweir     for ( sal_uInt16 i = 0; i < _pPage->GetSortedObjs()->Count(); ++i )
1160cdf0e10cSrcweir     {
1161cdf0e10cSrcweir         const SwAnchoredObject* pObj = (*_pPage->GetSortedObjs())[i];
1162cdf0e10cSrcweir         if ( pObj->ISA(SwFlyFrm) )
1163cdf0e10cSrcweir         {
1164cdf0e10cSrcweir             const SwFlyFrm* pFly = static_cast<const SwFlyFrm*>(pObj);
1165cdf0e10cSrcweir             if ( pFly->Frm().Top() <= _nBottom )
1166cdf0e10cSrcweir             {
1167cdf0e10cSrcweir                 if ( pFly->IsInvalid() || pFly->IsCompletePaint() )
1168cdf0e10cSrcweir                     return pFly;
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir                 const SwFrm* pTmp;
1171cdf0e10cSrcweir                 if ( 0 != (pTmp = lcl_FindFirstInvaCntnt( pFly, _nBottom, 0 )) &&
1172cdf0e10cSrcweir                      pTmp->Frm().Top() <= _nBottom )
1173cdf0e10cSrcweir                     return pFly;
1174cdf0e10cSrcweir             }
1175cdf0e10cSrcweir         }
1176cdf0e10cSrcweir         else if ( pObj->ISA(SwAnchoredDrawObject) )
1177cdf0e10cSrcweir         {
1178cdf0e10cSrcweir             if ( !static_cast<const SwAnchoredDrawObject*>(pObj)->IsValidPos() )
1179cdf0e10cSrcweir             {
1180cdf0e10cSrcweir                 return pObj;
1181cdf0e10cSrcweir             }
1182cdf0e10cSrcweir         }
1183cdf0e10cSrcweir     }
1184cdf0e10cSrcweir     return 0;
1185cdf0e10cSrcweir }
1186cdf0e10cSrcweir // <--
1187cdf0e10cSrcweir 
IsShortCut(SwPageFrm * & prPage)1188cdf0e10cSrcweir sal_Bool SwLayAction::IsShortCut( SwPageFrm *&prPage )
1189cdf0e10cSrcweir {
1190cdf0e10cSrcweir     sal_Bool bRet = sal_False;
1191cdf0e10cSrcweir     const ViewShell *pSh = pRoot->GetCurrShell();
1192cdf0e10cSrcweir     const sal_Bool bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode();
1193cdf0e10cSrcweir 
1194cdf0e10cSrcweir     //Wenn die Seite nicht Gueltig ist wird sie schnell formatiert, sonst
1195cdf0e10cSrcweir     //gibts nix als Aerger.
1196cdf0e10cSrcweir     if ( !prPage->IsValid() )
1197cdf0e10cSrcweir     {
1198cdf0e10cSrcweir         if ( bBrowse )
1199cdf0e10cSrcweir         {
1200cdf0e10cSrcweir             /// OD 15.10.2002 #103517# - format complete page
1201cdf0e10cSrcweir             /// Thus, loop on all lowers of the page <prPage>, instead of only
1202cdf0e10cSrcweir             /// format its first lower.
1203cdf0e10cSrcweir             /// NOTE: In online layout (bBrowse == sal_True) a page can contain
1204cdf0e10cSrcweir             ///     a header frame and/or a footer frame beside the body frame.
1205cdf0e10cSrcweir             prPage->Calc();
1206cdf0e10cSrcweir             SwFrm* pPageLowerFrm = prPage->Lower();
1207cdf0e10cSrcweir             while ( pPageLowerFrm )
1208cdf0e10cSrcweir             {
1209cdf0e10cSrcweir                 pPageLowerFrm->Calc();
1210cdf0e10cSrcweir                 pPageLowerFrm = pPageLowerFrm->GetNext();
1211cdf0e10cSrcweir             }
1212cdf0e10cSrcweir         }
1213cdf0e10cSrcweir         else
1214cdf0e10cSrcweir             FormatLayout( prPage );
1215cdf0e10cSrcweir         if ( IsAgain() )
1216cdf0e10cSrcweir             return sal_False;
1217cdf0e10cSrcweir     }
1218cdf0e10cSrcweir 
1219cdf0e10cSrcweir 
1220cdf0e10cSrcweir     const SwRect &rVis = pImp->GetShell()->VisArea();
1221cdf0e10cSrcweir     if ( (prPage->Frm().Top() >= rVis.Bottom()) ||
1222cdf0e10cSrcweir          (prPage->Frm().Left()>= rVis.Right()) )
1223cdf0e10cSrcweir     {
1224cdf0e10cSrcweir         bRet = sal_True;
1225cdf0e10cSrcweir 
1226e421cc8fSmseidel         //Jetzt wird es ein bisschen unangenehm: Der erste CntntFrm dieser Seite
1227e421cc8fSmseidel         //im Bodytext muss formatiert werden, wenn er dabei die Seite
1228cdf0e10cSrcweir         //wechselt, muss ich nochmal eine Seite zuvor anfangen, denn
1229cdf0e10cSrcweir         //es wurde ein PageBreak verarbeitet.
1230cdf0e10cSrcweir //Noch unangenehmer: Der naechste CntntFrm ueberhaupt muss
1231e421cc8fSmseidel         //formatiert werden, denn es kann passieren, dass kurzfristig
1232cdf0e10cSrcweir         //leere Seiten existieren (Bsp. Absatz ueber mehrere Seiten
1233cdf0e10cSrcweir         //wird geloescht oder verkleinert).
1234cdf0e10cSrcweir 
1235cdf0e10cSrcweir         //Ist fuer den Browser uninteressant, wenn der letzte Cnt davor bereits
1236e421cc8fSmseidel         //nicht mehr sichtbar ist.
1237cdf0e10cSrcweir 
1238cdf0e10cSrcweir         const SwPageFrm *p2ndPage = prPage;
1239cdf0e10cSrcweir         const SwCntntFrm *pCntnt;
1240cdf0e10cSrcweir         const SwLayoutFrm* pBody = p2ndPage->FindBodyCont();
1241cdf0e10cSrcweir         if( p2ndPage->IsFtnPage() && pBody )
1242cdf0e10cSrcweir             pBody = (SwLayoutFrm*)pBody->GetNext();
1243cdf0e10cSrcweir         pCntnt = pBody ? pBody->ContainsCntnt() : 0;
1244cdf0e10cSrcweir         while ( p2ndPage && !pCntnt )
1245cdf0e10cSrcweir         {
1246cdf0e10cSrcweir             p2ndPage = (SwPageFrm*)p2ndPage->GetNext();
1247cdf0e10cSrcweir             if( p2ndPage )
1248cdf0e10cSrcweir             {
1249cdf0e10cSrcweir                 pBody = p2ndPage->FindBodyCont();
1250cdf0e10cSrcweir                 if( p2ndPage->IsFtnPage() && pBody )
1251cdf0e10cSrcweir                     pBody = (SwLayoutFrm*)pBody->GetNext();
1252cdf0e10cSrcweir                 pCntnt = pBody ? pBody->ContainsCntnt() : 0;
1253cdf0e10cSrcweir             }
1254cdf0e10cSrcweir         }
1255cdf0e10cSrcweir         if ( pCntnt )
1256cdf0e10cSrcweir         {
1257cdf0e10cSrcweir             sal_Bool bTstCnt = sal_True;
1258cdf0e10cSrcweir             if ( bBrowse )
1259cdf0e10cSrcweir             {
1260cdf0e10cSrcweir                 //Der Cnt davor schon nicht mehr sichtbar?
1261cdf0e10cSrcweir                 const SwFrm *pLst = pCntnt;
1262cdf0e10cSrcweir                 if ( pLst->IsInTab() )
1263cdf0e10cSrcweir                     pLst = pCntnt->FindTabFrm();
1264cdf0e10cSrcweir                 if ( pLst->IsInSct() )
1265cdf0e10cSrcweir                     pLst = pCntnt->FindSctFrm();
1266cdf0e10cSrcweir                 pLst = pLst->FindPrev();
1267cdf0e10cSrcweir                 if ( pLst &&
1268cdf0e10cSrcweir                      (pLst->Frm().Top() >= rVis.Bottom() ||
1269cdf0e10cSrcweir                       pLst->Frm().Left()>= rVis.Right()) )
1270cdf0e10cSrcweir                 {
1271cdf0e10cSrcweir                     bTstCnt = sal_False;
1272cdf0e10cSrcweir                 }
1273cdf0e10cSrcweir             }
1274cdf0e10cSrcweir 
1275cdf0e10cSrcweir             if ( bTstCnt )
1276cdf0e10cSrcweir             {
1277cdf0e10cSrcweir                 // --> OD 2004-06-04 #i27756# - check after each frame calculation,
1278cdf0e10cSrcweir                 // if the content frame has changed the page. If yes, no other
1279cdf0e10cSrcweir                 // frame calculation is performed
1280cdf0e10cSrcweir                 bool bPageChg = false;
1281cdf0e10cSrcweir 
1282cdf0e10cSrcweir                 if ( pCntnt->IsInSct() )
1283cdf0e10cSrcweir                 {
1284cdf0e10cSrcweir                     const SwSectionFrm *pSct = ((SwFrm*)pCntnt)->ImplFindSctFrm();
1285cdf0e10cSrcweir                     if ( !pSct->IsValid() )
1286cdf0e10cSrcweir                     {
1287cdf0e10cSrcweir                         pSct->Calc();
1288cdf0e10cSrcweir                         pSct->SetCompletePaint();
1289cdf0e10cSrcweir                         if ( IsAgain() )
1290cdf0e10cSrcweir                             return sal_False;
1291cdf0e10cSrcweir                         // --> OD 2004-06-04 #i27756#
1292cdf0e10cSrcweir                         bPageChg = pCntnt->FindPageFrm() != p2ndPage &&
1293cdf0e10cSrcweir                                    prPage->GetPrev();
1294cdf0e10cSrcweir                     }
1295cdf0e10cSrcweir                 }
1296cdf0e10cSrcweir 
1297cdf0e10cSrcweir                 if ( !bPageChg && !pCntnt->IsValid() )
1298cdf0e10cSrcweir                 {
1299cdf0e10cSrcweir                     pCntnt->Calc();
1300cdf0e10cSrcweir                     pCntnt->SetCompletePaint();
1301cdf0e10cSrcweir                     if ( IsAgain() )
1302cdf0e10cSrcweir                         return sal_False;
1303cdf0e10cSrcweir                     // --> OD 2004-06-04 #i27756#
1304cdf0e10cSrcweir                     bPageChg = pCntnt->FindPageFrm() != p2ndPage &&
1305cdf0e10cSrcweir                                prPage->GetPrev();
1306cdf0e10cSrcweir                 }
1307cdf0e10cSrcweir 
1308cdf0e10cSrcweir                 if ( !bPageChg && pCntnt->IsInTab() )
1309cdf0e10cSrcweir                 {
1310cdf0e10cSrcweir                     const SwTabFrm *pTab = ((SwFrm*)pCntnt)->ImplFindTabFrm();
1311cdf0e10cSrcweir                     if ( !pTab->IsValid() )
1312cdf0e10cSrcweir                     {
1313cdf0e10cSrcweir                         pTab->Calc();
1314cdf0e10cSrcweir                         pTab->SetCompletePaint();
1315cdf0e10cSrcweir                         if ( IsAgain() )
1316cdf0e10cSrcweir                             return sal_False;
1317cdf0e10cSrcweir                         // --> OD 2004-06-04 #i27756#
1318cdf0e10cSrcweir                         bPageChg = pCntnt->FindPageFrm() != p2ndPage &&
1319cdf0e10cSrcweir                                    prPage->GetPrev();
1320cdf0e10cSrcweir                     }
1321cdf0e10cSrcweir                 }
1322cdf0e10cSrcweir 
1323cdf0e10cSrcweir                 if ( !bPageChg && pCntnt->IsInSct() )
1324cdf0e10cSrcweir                 {
1325cdf0e10cSrcweir                     const SwSectionFrm *pSct = ((SwFrm*)pCntnt)->ImplFindSctFrm();
1326cdf0e10cSrcweir                     if ( !pSct->IsValid() )
1327cdf0e10cSrcweir                     {
1328cdf0e10cSrcweir                         pSct->Calc();
1329cdf0e10cSrcweir                         pSct->SetCompletePaint();
1330cdf0e10cSrcweir                         if ( IsAgain() )
1331cdf0e10cSrcweir                             return sal_False;
1332cdf0e10cSrcweir                         // --> OD 2004-06-04 #i27756#
1333cdf0e10cSrcweir                         bPageChg = pCntnt->FindPageFrm() != p2ndPage &&
1334cdf0e10cSrcweir                                    prPage->GetPrev();
1335cdf0e10cSrcweir                     }
1336cdf0e10cSrcweir                 }
1337cdf0e10cSrcweir 
1338cdf0e10cSrcweir                 // --> OD 2004-06-04 #i27756#
1339cdf0e10cSrcweir                 if ( bPageChg )
1340cdf0e10cSrcweir                 {
1341cdf0e10cSrcweir                     bRet = sal_False;
1342cdf0e10cSrcweir                     const SwPageFrm* pTmp = pCntnt->FindPageFrm();
1343cdf0e10cSrcweir                     if ( pTmp->GetPhyPageNum() < prPage->GetPhyPageNum() &&
1344cdf0e10cSrcweir                          pTmp->IsInvalid() )
1345cdf0e10cSrcweir                     {
1346cdf0e10cSrcweir                         prPage = (SwPageFrm*)pTmp;
1347cdf0e10cSrcweir                     }
1348cdf0e10cSrcweir                     else
1349cdf0e10cSrcweir                     {
1350cdf0e10cSrcweir                         prPage = (SwPageFrm*)prPage->GetPrev();
1351cdf0e10cSrcweir                     }
1352cdf0e10cSrcweir                 }
1353cdf0e10cSrcweir                 // --> OD 2005-04-25 #121980# - no shortcut, if at previous page
1354cdf0e10cSrcweir                 // an anchored object is registered, whose anchor is <pCntnt>.
1355cdf0e10cSrcweir                 else if ( prPage->GetPrev() &&
1356cdf0e10cSrcweir                           static_cast<SwPageFrm*>(prPage->GetPrev())->GetSortedObjs() )
1357cdf0e10cSrcweir                 {
1358cdf0e10cSrcweir                     SwSortedObjs* pObjs =
1359cdf0e10cSrcweir                         static_cast<SwPageFrm*>(prPage->GetPrev())->GetSortedObjs();
1360cdf0e10cSrcweir                     if ( pObjs )
1361cdf0e10cSrcweir                     {
1362cdf0e10cSrcweir                         sal_uInt32 i = 0;
1363cdf0e10cSrcweir                         for ( ; i < pObjs->Count(); ++i )
1364cdf0e10cSrcweir                         {
1365cdf0e10cSrcweir                             SwAnchoredObject* pObj = (*pObjs)[i];
1366cdf0e10cSrcweir                             if ( pObj->GetAnchorFrmContainingAnchPos() == pCntnt )
1367cdf0e10cSrcweir                             {
1368cdf0e10cSrcweir                                 bRet = sal_False;
1369cdf0e10cSrcweir                                 break;
1370cdf0e10cSrcweir                             }
1371cdf0e10cSrcweir                         }
1372cdf0e10cSrcweir                     }
1373cdf0e10cSrcweir                 }
1374cdf0e10cSrcweir                 // <--
1375cdf0e10cSrcweir             }
1376cdf0e10cSrcweir         }
1377cdf0e10cSrcweir     }
1378cdf0e10cSrcweir 
1379cdf0e10cSrcweir     if ( !bRet && bBrowse )
1380cdf0e10cSrcweir     {
1381cdf0e10cSrcweir         const long nBottom = rVis.Bottom();
1382cdf0e10cSrcweir         const SwAnchoredObject* pObj( 0L );
1383cdf0e10cSrcweir         if ( prPage->GetSortedObjs() &&
1384cdf0e10cSrcweir              (prPage->IsInvalidFlyLayout() || prPage->IsInvalidFlyCntnt()) &&
1385cdf0e10cSrcweir              0 != (pObj = lcl_FindFirstInvaObj( prPage, nBottom )) &&
1386cdf0e10cSrcweir              pObj->GetObjRect().Top() <= nBottom )
1387cdf0e10cSrcweir         {
1388cdf0e10cSrcweir             return sal_False;
1389cdf0e10cSrcweir         }
1390cdf0e10cSrcweir         const SwFrm* pFrm( 0L );
1391cdf0e10cSrcweir         if ( prPage->IsInvalidLayout() &&
1392cdf0e10cSrcweir              0 != (pFrm = lcl_FindFirstInvaLay( prPage, nBottom )) &&
1393cdf0e10cSrcweir              pFrm->Frm().Top() <= nBottom )
1394cdf0e10cSrcweir         {
1395cdf0e10cSrcweir             return sal_False;
1396cdf0e10cSrcweir         }
1397cdf0e10cSrcweir         if ( (prPage->IsInvalidCntnt() || prPage->IsInvalidFlyInCnt()) &&
1398cdf0e10cSrcweir              0 != (pFrm = lcl_FindFirstInvaCntnt( prPage, nBottom, 0 )) &&
1399cdf0e10cSrcweir              pFrm->Frm().Top() <= nBottom )
1400cdf0e10cSrcweir         {
1401cdf0e10cSrcweir             return sal_False;
1402cdf0e10cSrcweir         }
1403cdf0e10cSrcweir         bRet = sal_True;
1404cdf0e10cSrcweir     }
1405cdf0e10cSrcweir     return bRet;
1406cdf0e10cSrcweir }
1407cdf0e10cSrcweir 
1408cdf0e10cSrcweir /*************************************************************************
1409cdf0e10cSrcweir |*
1410cdf0e10cSrcweir |*  SwLayAction::FormatLayout(), FormatLayoutFly, FormatLayoutTab()
1411cdf0e10cSrcweir |*
1412cdf0e10cSrcweir |*  Ersterstellung      MA 30. Oct. 92
1413cdf0e10cSrcweir |*  Letzte Aenderung    MA 18. May. 98
1414cdf0e10cSrcweir |*
1415cdf0e10cSrcweir |*************************************************************************/
1416cdf0e10cSrcweir // OD 15.11.2002 #105155# - introduce support for vertical layout
FormatLayout(SwLayoutFrm * pLay,sal_Bool bAddRect)1417cdf0e10cSrcweir sal_Bool SwLayAction::FormatLayout( SwLayoutFrm *pLay, sal_Bool bAddRect )
1418cdf0e10cSrcweir {
1419cdf0e10cSrcweir     ASSERT( !IsAgain(), "Ungueltige Seite beachten." );
1420cdf0e10cSrcweir     if ( IsAgain() )
1421cdf0e10cSrcweir         return sal_False;
1422cdf0e10cSrcweir 
1423cdf0e10cSrcweir     sal_Bool bChanged = sal_False;
1424cdf0e10cSrcweir     sal_Bool bAlreadyPainted = sal_False;
1425cdf0e10cSrcweir     // OD 11.11.2002 #104414# - remember frame at complete paint
1426cdf0e10cSrcweir     SwRect aFrmAtCompletePaint;
1427cdf0e10cSrcweir 
1428cdf0e10cSrcweir     if ( !pLay->IsValid() || pLay->IsCompletePaint() )
1429cdf0e10cSrcweir     {
1430cdf0e10cSrcweir         if ( pLay->GetPrev() && !pLay->GetPrev()->IsValid() )
1431cdf0e10cSrcweir             pLay->GetPrev()->SetCompletePaint();
1432cdf0e10cSrcweir 
1433cdf0e10cSrcweir         SwRect aOldRect( pLay->Frm() );
1434cdf0e10cSrcweir         pLay->Calc();
1435cdf0e10cSrcweir         if ( aOldRect != pLay->Frm() )
1436cdf0e10cSrcweir             bChanged = sal_True;
1437cdf0e10cSrcweir 
1438cdf0e10cSrcweir         sal_Bool bNoPaint = sal_False;
1439cdf0e10cSrcweir         if ( pLay->IsPageBodyFrm() &&
1440cdf0e10cSrcweir              pLay->Frm().Pos() == aOldRect.Pos() &&
1441cdf0e10cSrcweir              pLay->Lower() )
1442cdf0e10cSrcweir         {
1443cdf0e10cSrcweir             const ViewShell *pSh = pLay->getRootFrm()->GetCurrShell();
1444cdf0e10cSrcweir             //Einschraenkungen wegen Kopf-/Fusszeilen
1445cdf0e10cSrcweir             if( pSh && pSh->GetViewOptions()->getBrowseMode() &&
1446cdf0e10cSrcweir                 !( pLay->IsCompletePaint() && pLay->FindPageFrm()->FindFtnCont() ) )
1447cdf0e10cSrcweir                 bNoPaint = sal_True;
1448cdf0e10cSrcweir         }
1449cdf0e10cSrcweir 
1450cdf0e10cSrcweir         if ( !bNoPaint && IsPaint() && bAddRect && (pLay->IsCompletePaint() || bChanged) )
1451cdf0e10cSrcweir         {
1452cdf0e10cSrcweir             SwRect aPaint( pLay->Frm() );
1453e421cc8fSmseidel             // OD 13.02.2003 #i9719#, #105645# - consider border (shadow removed now) for
1454cdf0e10cSrcweir             // page frames -> enlarge paint rectangle correspondingly.
1455cdf0e10cSrcweir             if ( pLay->IsPageFrm() )
1456cdf0e10cSrcweir             {
1457cdf0e10cSrcweir                 SwPageFrm* pPageFrm = static_cast<SwPageFrm*>(pLay);
1458cdf0e10cSrcweir                 const int nBorderWidth =
1459cdf0e10cSrcweir                         pImp->GetShell()->GetOut()->PixelToLogic( Size( pPageFrm->BorderPxWidth(), 0 ) ).Width();
1460cdf0e10cSrcweir 
1461cdf0e10cSrcweir                 //mod #i6193# added sidebar width
1462cdf0e10cSrcweir                 const SwPostItMgr* pPostItMgr = pImp->GetShell()->GetPostItMgr();
1463cdf0e10cSrcweir                 const int nSidebarWidth = pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() ? pPostItMgr->GetSidebarWidth() + pPostItMgr->GetSidebarBorderWidth() : 0;
1464cdf0e10cSrcweir                 switch ( pPageFrm->SidebarPosition() )
1465cdf0e10cSrcweir                 {
1466cdf0e10cSrcweir                     case sw::sidebarwindows::SIDEBAR_LEFT:
1467cdf0e10cSrcweir                     {
1468cdf0e10cSrcweir                         aPaint.Left( aPaint.Left() - nBorderWidth - nSidebarWidth);
1469e421cc8fSmseidel                         aPaint.Right( aPaint.Right() + nBorderWidth );
1470cdf0e10cSrcweir                     }
1471cdf0e10cSrcweir                     break;
1472cdf0e10cSrcweir                     case sw::sidebarwindows::SIDEBAR_RIGHT:
1473cdf0e10cSrcweir                     {
1474cdf0e10cSrcweir                         aPaint.Left( aPaint.Left() - nBorderWidth );
1475e421cc8fSmseidel                         aPaint.Right( aPaint.Right() + nBorderWidth + nSidebarWidth);
1476cdf0e10cSrcweir                     }
1477cdf0e10cSrcweir                     break;
1478cdf0e10cSrcweir                     case sw::sidebarwindows::SIDEBAR_NONE:
1479cdf0e10cSrcweir                         // nothing to do
1480cdf0e10cSrcweir                     break;
1481cdf0e10cSrcweir                 }
1482cdf0e10cSrcweir                 aPaint.Top( aPaint.Top() - nBorderWidth );
1483e421cc8fSmseidel                 aPaint.Bottom( aPaint.Bottom() + nBorderWidth );
1484cdf0e10cSrcweir             }
1485cdf0e10cSrcweir 
1486cdf0e10cSrcweir             sal_Bool bPageInBrowseMode = pLay->IsPageFrm();
1487cdf0e10cSrcweir             if( bPageInBrowseMode )
1488cdf0e10cSrcweir             {
1489cdf0e10cSrcweir                 const ViewShell *pSh = pLay->getRootFrm()->GetCurrShell();
1490cdf0e10cSrcweir                 if( !pSh || !pSh->GetViewOptions()->getBrowseMode() )
1491cdf0e10cSrcweir                     bPageInBrowseMode = sal_False;
1492cdf0e10cSrcweir             }
1493cdf0e10cSrcweir             if( bPageInBrowseMode )
1494cdf0e10cSrcweir             {
1495cdf0e10cSrcweir                 // NOTE: no vertical layout in online layout
1496cdf0e10cSrcweir                 //Ist die Aenderung ueberhaupt sichtbar?
1497cdf0e10cSrcweir                 if ( pLay->IsCompletePaint() )
1498cdf0e10cSrcweir                 {
1499cdf0e10cSrcweir                     pImp->GetShell()->AddPaintRect( aPaint );
1500cdf0e10cSrcweir                     bAddRect = sal_False;
1501cdf0e10cSrcweir                 }
1502cdf0e10cSrcweir                 else
1503cdf0e10cSrcweir                 {
1504cdf0e10cSrcweir                     sal_uInt16 i;
1505cdf0e10cSrcweir 
1506cdf0e10cSrcweir                     SwRegionRects aRegion( aOldRect );
1507cdf0e10cSrcweir                     aRegion -= aPaint;
1508cdf0e10cSrcweir                     for ( i = 0; i < aRegion.Count(); ++i )
1509cdf0e10cSrcweir                         pImp->GetShell()->AddPaintRect( aRegion[i] );
1510cdf0e10cSrcweir                     aRegion.ChangeOrigin( aPaint );
1511cdf0e10cSrcweir                     aRegion.Remove( 0, aRegion.Count() );
1512cdf0e10cSrcweir                     aRegion.Insert( aPaint, 0 );
1513cdf0e10cSrcweir                     aRegion -= aOldRect;
1514cdf0e10cSrcweir                     for ( i = 0; i < aRegion.Count(); ++i )
1515cdf0e10cSrcweir                         pImp->GetShell()->AddPaintRect( aRegion[i] );
1516cdf0e10cSrcweir                 }
1517cdf0e10cSrcweir 
1518cdf0e10cSrcweir             }
1519cdf0e10cSrcweir             else
1520cdf0e10cSrcweir             {
1521cdf0e10cSrcweir                 pImp->GetShell()->AddPaintRect( aPaint );
1522cdf0e10cSrcweir                 bAlreadyPainted = sal_True;
1523cdf0e10cSrcweir                 // OD 11.11.2002 #104414# - remember frame at complete paint
1524cdf0e10cSrcweir                 aFrmAtCompletePaint = pLay->Frm();
1525cdf0e10cSrcweir             }
1526cdf0e10cSrcweir 
1527cdf0e10cSrcweir             // OD 13.02.2003 #i9719#, #105645# - provide paint of spacing
1528cdf0e10cSrcweir             // between pages (not only for in online mode).
1529cdf0e10cSrcweir             if ( pLay->IsPageFrm() )
1530cdf0e10cSrcweir             {
1531cdf0e10cSrcweir                 const SwTwips nHalfDocBorder = GAPBETWEENPAGES;
1532cdf0e10cSrcweir                 const bool bLeftToRightViewLayout = pRoot->IsLeftToRightViewLayout();
1533cdf0e10cSrcweir                 const bool bPrev = bLeftToRightViewLayout ? pLay->GetPrev() : pLay->GetNext();
1534cdf0e10cSrcweir                 const bool bNext = bLeftToRightViewLayout ? pLay->GetNext() : pLay->GetPrev();
1535cdf0e10cSrcweir 
1536cdf0e10cSrcweir                 if ( bPrev )
1537cdf0e10cSrcweir                 {
1538cdf0e10cSrcweir                     // top
1539cdf0e10cSrcweir                     SwRect aSpaceToPrevPage( pLay->Frm() );
1540cdf0e10cSrcweir                     const SwTwips nTop = aSpaceToPrevPage.Top() - nHalfDocBorder;
1541cdf0e10cSrcweir                     if ( nTop >= 0 )
1542cdf0e10cSrcweir                         aSpaceToPrevPage.Top( nTop );
1543cdf0e10cSrcweir                     aSpaceToPrevPage.Bottom( pLay->Frm().Top() );
1544cdf0e10cSrcweir                     pImp->GetShell()->AddPaintRect( aSpaceToPrevPage );
1545cdf0e10cSrcweir 
1546cdf0e10cSrcweir                     // left
1547cdf0e10cSrcweir                     aSpaceToPrevPage = pLay->Frm();
1548cdf0e10cSrcweir                     const SwTwips nLeft = aSpaceToPrevPage.Left() - nHalfDocBorder;
1549cdf0e10cSrcweir                     if ( nLeft >= 0 )
1550cdf0e10cSrcweir                         aSpaceToPrevPage.Left( nLeft );
1551cdf0e10cSrcweir                     aSpaceToPrevPage.Right( pLay->Frm().Left() );
1552cdf0e10cSrcweir                     pImp->GetShell()->AddPaintRect( aSpaceToPrevPage );
1553cdf0e10cSrcweir                 }
1554cdf0e10cSrcweir                 if ( bNext )
1555cdf0e10cSrcweir                 {
1556cdf0e10cSrcweir                     // bottom
1557cdf0e10cSrcweir                     SwRect aSpaceToNextPage( pLay->Frm() );
1558cdf0e10cSrcweir                     aSpaceToNextPage.Bottom( aSpaceToNextPage.Bottom() + nHalfDocBorder );
1559cdf0e10cSrcweir                     aSpaceToNextPage.Top( pLay->Frm().Bottom() );
1560cdf0e10cSrcweir                     pImp->GetShell()->AddPaintRect( aSpaceToNextPage );
1561cdf0e10cSrcweir 
1562cdf0e10cSrcweir                     // right
1563cdf0e10cSrcweir                     aSpaceToNextPage = pLay->Frm();
1564cdf0e10cSrcweir                     aSpaceToNextPage.Right( aSpaceToNextPage.Right() + nHalfDocBorder );
1565cdf0e10cSrcweir                     aSpaceToNextPage.Left( pLay->Frm().Right() );
1566cdf0e10cSrcweir                     pImp->GetShell()->AddPaintRect( aSpaceToNextPage );
1567cdf0e10cSrcweir                 }
1568cdf0e10cSrcweir             }
1569cdf0e10cSrcweir         }
1570cdf0e10cSrcweir         pLay->ResetCompletePaint();
1571cdf0e10cSrcweir     }
1572cdf0e10cSrcweir 
1573cdf0e10cSrcweir     if ( IsPaint() && bAddRect &&
1574cdf0e10cSrcweir          !pLay->GetNext() && pLay->IsRetoucheFrm() && pLay->IsRetouche() )
1575cdf0e10cSrcweir     {
1576cdf0e10cSrcweir         // OD 15.11.2002 #105155# - vertical layout support
1577cdf0e10cSrcweir         SWRECTFN( pLay );
1578cdf0e10cSrcweir         SwRect aRect( pLay->GetUpper()->PaintArea() );
1579cdf0e10cSrcweir         (aRect.*fnRect->fnSetTop)( (pLay->*fnRect->fnGetPrtBottom)() );
1580cdf0e10cSrcweir         if ( !pImp->GetShell()->AddPaintRect( aRect ) )
1581cdf0e10cSrcweir             pLay->ResetRetouche();
1582cdf0e10cSrcweir     }
1583cdf0e10cSrcweir 
1584cdf0e10cSrcweir     if( bAlreadyPainted )
1585cdf0e10cSrcweir         bAddRect = sal_False;
1586cdf0e10cSrcweir 
1587cdf0e10cSrcweir     CheckWaitCrsr();
1588cdf0e10cSrcweir 
1589cdf0e10cSrcweir     if ( IsAgain() )
1590cdf0e10cSrcweir         return sal_False;
1591cdf0e10cSrcweir 
1592cdf0e10cSrcweir     //Jetzt noch diejenigen Lowers versorgen die LayoutFrm's sind
1593cdf0e10cSrcweir 
1594cdf0e10cSrcweir     if ( pLay->IsFtnFrm() ) //Hat keine LayFrms als Lower.
1595cdf0e10cSrcweir         return bChanged;
1596cdf0e10cSrcweir 
1597cdf0e10cSrcweir     SwFrm *pLow = pLay->Lower();
1598cdf0e10cSrcweir     sal_Bool bTabChanged = sal_False;
1599cdf0e10cSrcweir     while ( pLow && pLow->GetUpper() == pLay )
1600cdf0e10cSrcweir     {
1601cdf0e10cSrcweir         if ( pLow->IsLayoutFrm() )
1602cdf0e10cSrcweir         {
1603cdf0e10cSrcweir             if ( pLow->IsTabFrm() )
1604cdf0e10cSrcweir                 bTabChanged |= FormatLayoutTab( (SwTabFrm*)pLow, bAddRect );
1605cdf0e10cSrcweir             // bereits zum Loeschen angemeldete Ueberspringen
1606cdf0e10cSrcweir             else if( !pLow->IsSctFrm() || ((SwSectionFrm*)pLow)->GetSection() )
1607cdf0e10cSrcweir                 bChanged |= FormatLayout( (SwLayoutFrm*)pLow, bAddRect );
1608cdf0e10cSrcweir         }
1609cdf0e10cSrcweir         else if ( pImp->GetShell()->IsPaintLocked() )
1610*0c72d66fSmseidel             //Abkuerzung um die Zyklen zu minimieren, bei Lock kommt das
1611cdf0e10cSrcweir             //Paint sowieso (Primaer fuer Browse)
1612cdf0e10cSrcweir             pLow->OptCalc();
1613cdf0e10cSrcweir 
1614cdf0e10cSrcweir         if ( IsAgain() )
1615cdf0e10cSrcweir             return sal_False;
1616cdf0e10cSrcweir         pLow = pLow->GetNext();
1617cdf0e10cSrcweir     }
1618cdf0e10cSrcweir     // OD 11.11.2002 #104414# - add complete frame area as paint area, if frame
1619*0c72d66fSmseidel     // area has been already added and after formatting its lower the frame area
1620cdf0e10cSrcweir     // is enlarged.
1621cdf0e10cSrcweir     if ( bAlreadyPainted &&
1622cdf0e10cSrcweir          ( pLay->Frm().Width() > aFrmAtCompletePaint.Width() ||
1623cdf0e10cSrcweir            pLay->Frm().Height() > aFrmAtCompletePaint.Height() )
1624cdf0e10cSrcweir        )
1625cdf0e10cSrcweir     {
1626cdf0e10cSrcweir         pImp->GetShell()->AddPaintRect( pLay->Frm() );
1627cdf0e10cSrcweir     }
1628cdf0e10cSrcweir     return bChanged || bTabChanged;
1629cdf0e10cSrcweir }
1630cdf0e10cSrcweir 
FormatLayoutFly(SwFlyFrm * pFly)1631cdf0e10cSrcweir sal_Bool SwLayAction::FormatLayoutFly( SwFlyFrm* pFly )
1632cdf0e10cSrcweir {
1633cdf0e10cSrcweir     ASSERT( !IsAgain(), "Ungueltige Seite beachten." );
1634cdf0e10cSrcweir     if ( IsAgain() )
1635cdf0e10cSrcweir         return sal_False;
1636cdf0e10cSrcweir 
1637cdf0e10cSrcweir     sal_Bool bChanged = false;
1638cdf0e10cSrcweir     sal_Bool bAddRect = true;
1639cdf0e10cSrcweir 
1640cdf0e10cSrcweir     if ( !pFly->IsValid() || pFly->IsCompletePaint() || pFly->IsInvalid() )
1641cdf0e10cSrcweir     {
1642cdf0e10cSrcweir         //Der Frame hat sich veraendert, er wird jetzt Formatiert
1643cdf0e10cSrcweir         const SwRect aOldRect( pFly->Frm() );
1644cdf0e10cSrcweir         pFly->Calc();
1645cdf0e10cSrcweir         bChanged = aOldRect != pFly->Frm();
1646cdf0e10cSrcweir 
1647cdf0e10cSrcweir         if ( IsPaint() && (pFly->IsCompletePaint() || bChanged) &&
1648cdf0e10cSrcweir                     pFly->Frm().Top() > 0 && pFly->Frm().Left() > 0 )
1649cdf0e10cSrcweir             pImp->GetShell()->AddPaintRect( pFly->Frm() );
1650cdf0e10cSrcweir 
1651cdf0e10cSrcweir         if ( bChanged )
1652cdf0e10cSrcweir             pFly->Invalidate();
1653cdf0e10cSrcweir         else
1654cdf0e10cSrcweir             pFly->Validate();
1655cdf0e10cSrcweir /*
1656cdf0e10cSrcweir         //mba: it's unclear why we should invalidate always, so I remove it
1657cdf0e10cSrcweir         //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
1658cdf0e10cSrcweir         if ( IsPaint() && bAddRect && pFly->Frm().Top() > 0 && pFly->Frm().Left() > 0 )
1659cdf0e10cSrcweir             pImp->GetShell()->AddPaintRect( pFly->Frm() );
1660cdf0e10cSrcweir 
1661cdf0e10cSrcweir         pFly->Invalidate();
1662cdf0e10cSrcweir */
1663cdf0e10cSrcweir         bAddRect = false;
1664cdf0e10cSrcweir         pFly->ResetCompletePaint();
1665cdf0e10cSrcweir     }
1666cdf0e10cSrcweir 
1667cdf0e10cSrcweir     if ( IsAgain() )
1668cdf0e10cSrcweir         return sal_False;
1669cdf0e10cSrcweir 
1670cdf0e10cSrcweir     //Jetzt noch diejenigen Lowers versorgen die LayoutFrm's sind
1671cdf0e10cSrcweir     sal_Bool bTabChanged = false;
1672cdf0e10cSrcweir     SwFrm *pLow = pFly->Lower();
1673cdf0e10cSrcweir     while ( pLow )
1674cdf0e10cSrcweir     {
1675cdf0e10cSrcweir         if ( pLow->IsLayoutFrm() )
1676cdf0e10cSrcweir         {
1677cdf0e10cSrcweir             if ( pLow->IsTabFrm() )
1678cdf0e10cSrcweir                 bTabChanged |= FormatLayoutTab( (SwTabFrm*)pLow, bAddRect );
1679cdf0e10cSrcweir             else
1680cdf0e10cSrcweir                 bChanged |= FormatLayout( (SwLayoutFrm*)pLow, bAddRect );
1681cdf0e10cSrcweir         }
1682cdf0e10cSrcweir         pLow = pLow->GetNext();
1683cdf0e10cSrcweir     }
1684cdf0e10cSrcweir     return bChanged || bTabChanged;
1685cdf0e10cSrcweir }
1686cdf0e10cSrcweir 
1687cdf0e10cSrcweir // OD 31.10.2002 #104100#
1688cdf0e10cSrcweir // Implement vertical layout support
FormatLayoutTab(SwTabFrm * pTab,sal_Bool bAddRect)1689cdf0e10cSrcweir sal_Bool SwLayAction::FormatLayoutTab( SwTabFrm *pTab, sal_Bool bAddRect )
1690cdf0e10cSrcweir {
1691cdf0e10cSrcweir     ASSERT( !IsAgain(), "8-) Ungueltige Seite beachten." );
1692cdf0e10cSrcweir     if ( IsAgain() || !pTab->Lower() )
1693cdf0e10cSrcweir         return sal_False;
1694cdf0e10cSrcweir 
1695cdf0e10cSrcweir     IDocumentTimerAccess *pTimerAccess = pRoot->GetFmt()->getIDocumentTimerAccess();
1696cdf0e10cSrcweir     pTimerAccess->BlockIdling();
1697cdf0e10cSrcweir 
1698cdf0e10cSrcweir     sal_Bool bChanged = sal_False;
1699cdf0e10cSrcweir     sal_Bool bPainted = sal_False;
1700cdf0e10cSrcweir 
1701cdf0e10cSrcweir     const SwPageFrm *pOldPage = pTab->FindPageFrm();
1702cdf0e10cSrcweir 
1703cdf0e10cSrcweir     // OD 31.10.2002 #104100# - vertical layout support
1704cdf0e10cSrcweir     // use macro to declare and init <sal_Bool bVert>, <sal_Bool bRev> and
1705cdf0e10cSrcweir     // <SwRectFn fnRect> for table frame <pTab>.
1706cdf0e10cSrcweir     SWRECTFN( pTab );
1707cdf0e10cSrcweir 
1708cdf0e10cSrcweir     if ( !pTab->IsValid() || pTab->IsCompletePaint() || pTab->IsComplete() )
1709cdf0e10cSrcweir     {
1710cdf0e10cSrcweir         if ( pTab->GetPrev() && !pTab->GetPrev()->IsValid() )
1711cdf0e10cSrcweir         {
1712cdf0e10cSrcweir             pTab->GetPrev()->SetCompletePaint();
1713cdf0e10cSrcweir         }
1714cdf0e10cSrcweir 
1715cdf0e10cSrcweir         const SwRect aOldRect( pTab->Frm() );
1716cdf0e10cSrcweir         pTab->SetLowersFormatted( sal_False );
1717cdf0e10cSrcweir         pTab->Calc();
1718cdf0e10cSrcweir         if ( aOldRect != pTab->Frm() )
1719cdf0e10cSrcweir         {
1720cdf0e10cSrcweir             bChanged = sal_True;
1721cdf0e10cSrcweir         }
1722cdf0e10cSrcweir         const SwRect aPaintFrm = pTab->PaintArea();
1723cdf0e10cSrcweir 
1724cdf0e10cSrcweir         if ( IsPaint() && bAddRect )
1725cdf0e10cSrcweir         {
1726cdf0e10cSrcweir             // OD 01.11.2002 #104100# - add condition <pTab->Frm().HasArea()>
1727cdf0e10cSrcweir             if ( !pTab->IsCompletePaint() &&
1728cdf0e10cSrcweir                  pTab->IsComplete() &&
1729cdf0e10cSrcweir                  ( pTab->Frm().SSize() != pTab->Prt().SSize() ||
1730cdf0e10cSrcweir                    // OD 31.10.2002 #104100# - vertical layout support
1731cdf0e10cSrcweir                    (pTab->*fnRect->fnGetLeftMargin)() ) &&
1732cdf0e10cSrcweir                  pTab->Frm().HasArea()
1733cdf0e10cSrcweir                )
1734cdf0e10cSrcweir             {
1735cdf0e10cSrcweir                 // OD 01.11.2002 #104100# - re-implement calculation of margin rectangles.
1736cdf0e10cSrcweir                 SwRect aMarginRect;
1737cdf0e10cSrcweir 
1738cdf0e10cSrcweir                 SwTwips nLeftMargin = (pTab->*fnRect->fnGetLeftMargin)();
1739cdf0e10cSrcweir                 if ( nLeftMargin > 0)
1740cdf0e10cSrcweir                 {
1741cdf0e10cSrcweir                     aMarginRect = pTab->Frm();
1742cdf0e10cSrcweir                     (aMarginRect.*fnRect->fnSetWidth)( nLeftMargin );
1743cdf0e10cSrcweir                     pImp->GetShell()->AddPaintRect( aMarginRect );
1744cdf0e10cSrcweir                 }
1745cdf0e10cSrcweir 
1746cdf0e10cSrcweir                 if ( (pTab->*fnRect->fnGetRightMargin)() > 0)
1747cdf0e10cSrcweir                 {
1748cdf0e10cSrcweir                     aMarginRect = pTab->Frm();
1749cdf0e10cSrcweir                     (aMarginRect.*fnRect->fnSetLeft)( (pTab->*fnRect->fnGetPrtRight)() );
1750cdf0e10cSrcweir                     pImp->GetShell()->AddPaintRect( aMarginRect );
1751cdf0e10cSrcweir                 }
1752cdf0e10cSrcweir 
1753cdf0e10cSrcweir                 SwTwips nTopMargin = (pTab->*fnRect->fnGetTopMargin)();
1754cdf0e10cSrcweir                 if ( nTopMargin > 0)
1755cdf0e10cSrcweir                 {
1756cdf0e10cSrcweir                     aMarginRect = pTab->Frm();
1757cdf0e10cSrcweir                     (aMarginRect.*fnRect->fnSetHeight)( nTopMargin );
1758cdf0e10cSrcweir                     pImp->GetShell()->AddPaintRect( aMarginRect );
1759cdf0e10cSrcweir                 }
1760cdf0e10cSrcweir 
1761cdf0e10cSrcweir                 if ( (pTab->*fnRect->fnGetBottomMargin)() > 0)
1762cdf0e10cSrcweir                 {
1763cdf0e10cSrcweir                     aMarginRect = pTab->Frm();
1764cdf0e10cSrcweir                     (aMarginRect.*fnRect->fnSetTop)( (pTab->*fnRect->fnGetPrtBottom)() );
1765cdf0e10cSrcweir                     pImp->GetShell()->AddPaintRect( aMarginRect );
1766cdf0e10cSrcweir                 }
1767cdf0e10cSrcweir             }
1768cdf0e10cSrcweir             else if ( pTab->IsCompletePaint() )
1769cdf0e10cSrcweir             {
1770cdf0e10cSrcweir                 pImp->GetShell()->AddPaintRect( aPaintFrm );
1771cdf0e10cSrcweir                 bAddRect = sal_False;
1772cdf0e10cSrcweir                 bPainted = sal_True;
1773cdf0e10cSrcweir             }
1774cdf0e10cSrcweir 
1775cdf0e10cSrcweir             if ( pTab->IsRetouche() && !pTab->GetNext() )
1776cdf0e10cSrcweir             {
1777cdf0e10cSrcweir                 SwRect aRect( pTab->GetUpper()->PaintArea() );
1778cdf0e10cSrcweir                 // OD 04.11.2002 #104100# - vertical layout support
1779cdf0e10cSrcweir                 (aRect.*fnRect->fnSetTop)( (pTab->*fnRect->fnGetPrtBottom)() );
1780cdf0e10cSrcweir                 if ( !pImp->GetShell()->AddPaintRect( aRect ) )
1781cdf0e10cSrcweir                     pTab->ResetRetouche();
1782cdf0e10cSrcweir             }
1783cdf0e10cSrcweir         }
1784cdf0e10cSrcweir         else
1785cdf0e10cSrcweir             bAddRect = sal_False;
1786cdf0e10cSrcweir 
1787cdf0e10cSrcweir         if ( pTab->IsCompletePaint() && !pOptTab )
1788cdf0e10cSrcweir             pOptTab = pTab;
1789cdf0e10cSrcweir         pTab->ResetCompletePaint();
1790cdf0e10cSrcweir     }
1791cdf0e10cSrcweir     if ( IsPaint() && bAddRect && pTab->IsRetouche() && !pTab->GetNext() )
1792cdf0e10cSrcweir     {
1793cdf0e10cSrcweir         // OD 04.10.2002 #102779#
1794cdf0e10cSrcweir         // set correct rectangle for retouche: area between bottom of table frame
1795cdf0e10cSrcweir         // and bottom of paint area of the upper frame.
1796cdf0e10cSrcweir         SwRect aRect( pTab->GetUpper()->PaintArea() );
1797cdf0e10cSrcweir         // OD 04.11.2002 #104100# - vertical layout support
1798cdf0e10cSrcweir         (aRect.*fnRect->fnSetTop)( (pTab->*fnRect->fnGetPrtBottom)() );
1799cdf0e10cSrcweir         if ( !pImp->GetShell()->AddPaintRect( aRect ) )
1800cdf0e10cSrcweir             pTab->ResetRetouche();
1801cdf0e10cSrcweir     }
1802cdf0e10cSrcweir 
1803cdf0e10cSrcweir     CheckWaitCrsr();
1804cdf0e10cSrcweir 
1805cdf0e10cSrcweir     pTimerAccess->UnblockIdling();
1806cdf0e10cSrcweir 
1807cdf0e10cSrcweir     //Heftige Abkuerzung!
1808cdf0e10cSrcweir     if ( pTab->IsLowersFormatted() &&
1809cdf0e10cSrcweir          (bPainted || !pImp->GetShell()->VisArea().IsOver( pTab->Frm())) )
1810cdf0e10cSrcweir         return sal_False;
1811cdf0e10cSrcweir 
1812cdf0e10cSrcweir     //Jetzt noch die Lowers versorgen
1813cdf0e10cSrcweir     if ( IsAgain() )
1814cdf0e10cSrcweir         return sal_False;
1815cdf0e10cSrcweir 
1816e421cc8fSmseidel     // OD 20.10.2003 #112464# - for safety reasons:
1817cdf0e10cSrcweir     // check page number before formatting lowers.
1818cdf0e10cSrcweir     if ( pOldPage->GetPhyPageNum() > (pTab->FindPageFrm()->GetPhyPageNum() + 1) )
1819cdf0e10cSrcweir         SetNextCycle( sal_True );
1820cdf0e10cSrcweir 
1821cdf0e10cSrcweir     // OD 20.10.2003 #112464# - format lowers, only if table frame is valid
1822cdf0e10cSrcweir     if ( pTab->IsValid() )
1823cdf0e10cSrcweir     {
1824cdf0e10cSrcweir         SwLayoutFrm *pLow = (SwLayoutFrm*)pTab->Lower();
1825cdf0e10cSrcweir         while ( pLow )
1826cdf0e10cSrcweir         {
1827cdf0e10cSrcweir             bChanged |= FormatLayout( (SwLayoutFrm*)pLow, bAddRect );
1828cdf0e10cSrcweir             if ( IsAgain() )
1829cdf0e10cSrcweir                 return sal_False;
1830cdf0e10cSrcweir             pLow = (SwLayoutFrm*)pLow->GetNext();
1831cdf0e10cSrcweir         }
1832cdf0e10cSrcweir     }
1833cdf0e10cSrcweir 
1834cdf0e10cSrcweir     return bChanged;
1835cdf0e10cSrcweir }
1836cdf0e10cSrcweir 
1837cdf0e10cSrcweir /*************************************************************************
1838cdf0e10cSrcweir |*
1839cdf0e10cSrcweir |*  SwLayAction::FormatCntnt()
1840cdf0e10cSrcweir |*
1841cdf0e10cSrcweir |*  Ersterstellung      MA 30. Oct. 92
1842cdf0e10cSrcweir |*  Letzte Aenderung    MA 16. Nov. 95
1843cdf0e10cSrcweir |*
1844cdf0e10cSrcweir |*************************************************************************/
FormatCntnt(const SwPageFrm * pPage)1845cdf0e10cSrcweir sal_Bool SwLayAction::FormatCntnt( const SwPageFrm *pPage )
1846cdf0e10cSrcweir {
1847cdf0e10cSrcweir     const SwCntntFrm *pCntnt = pPage->ContainsCntnt();
1848cdf0e10cSrcweir     const ViewShell *pSh = pRoot->GetCurrShell();
1849cdf0e10cSrcweir     const sal_Bool bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode();
1850cdf0e10cSrcweir 
1851cdf0e10cSrcweir     while ( pCntnt && pPage->IsAnLower( pCntnt ) )
1852cdf0e10cSrcweir     {
1853cdf0e10cSrcweir         //Wenn der Cntnt sich eh nicht veraendert koennen wir ein paar
1854cdf0e10cSrcweir         //Abkuerzungen nutzen.
1855cdf0e10cSrcweir         const sal_Bool bFull = !pCntnt->IsValid() || pCntnt->IsCompletePaint() ||
1856cdf0e10cSrcweir                            pCntnt->IsRetouche() || pCntnt->GetDrawObjs();
1857cdf0e10cSrcweir         if ( bFull )
1858cdf0e10cSrcweir         {
1859cdf0e10cSrcweir             //Damit wir nacher nicht suchen muessen.
1860cdf0e10cSrcweir             const sal_Bool bNxtCnt = IsCalcLayout() && !pCntnt->GetFollow();
1861cdf0e10cSrcweir             const SwCntntFrm *pCntntNext = bNxtCnt ? pCntnt->GetNextCntntFrm() : 0;
1862cdf0e10cSrcweir             const SwCntntFrm *pCntntPrev = pCntnt->GetPrev() ? pCntnt->GetPrevCntntFrm() : 0;
1863cdf0e10cSrcweir 
1864cdf0e10cSrcweir             const SwLayoutFrm*pOldUpper  = pCntnt->GetUpper();
1865cdf0e10cSrcweir             const SwTabFrm *pTab = pCntnt->FindTabFrm();
1866cdf0e10cSrcweir             const sal_Bool bInValid = !pCntnt->IsValid() || pCntnt->IsCompletePaint();
1867cdf0e10cSrcweir             const sal_Bool bOldPaint = IsPaint();
1868cdf0e10cSrcweir             bPaint = bOldPaint && !(pTab && pTab == pOptTab);
1869cdf0e10cSrcweir             _FormatCntnt( pCntnt, pPage );
1870cdf0e10cSrcweir             // --> OD 2004-11-05 #i26945# - reset <bPaint> before format objects
1871cdf0e10cSrcweir             bPaint = bOldPaint;
1872cdf0e10cSrcweir             // <--
1873cdf0e10cSrcweir 
1874cdf0e10cSrcweir             // OD 2004-05-10 #i28701# - format floating screen object at content frame.
1875cdf0e10cSrcweir             // No format, if action flag <bAgain> is set or action is interrupted.
1876cdf0e10cSrcweir             // OD 2004-08-30 #117736# - allow format on interruption of action, if
1877cdf0e10cSrcweir             // it's the format for this interrupt
1878cdf0e10cSrcweir             // --> OD 2004-11-01 #i23129#, #i36347# - pass correct page frame
1879cdf0e10cSrcweir             // to the object formatter.
1880cdf0e10cSrcweir             if ( !IsAgain() &&
1881cdf0e10cSrcweir                  ( !IsInterrupt() || mbFormatCntntOnInterrupt ) &&
1882cdf0e10cSrcweir                  pCntnt->IsTxtFrm() &&
1883cdf0e10cSrcweir                  !SwObjectFormatter::FormatObjsAtFrm( *(const_cast<SwCntntFrm*>(pCntnt)),
1884cdf0e10cSrcweir                                                       *(pCntnt->FindPageFrm()), this ) )
1885cdf0e10cSrcweir             // <--
1886cdf0e10cSrcweir             {
1887cdf0e10cSrcweir                 return sal_False;
1888cdf0e10cSrcweir             }
1889cdf0e10cSrcweir 
1890cdf0e10cSrcweir             if ( !pCntnt->GetValidLineNumFlag() && pCntnt->IsTxtFrm() )
1891cdf0e10cSrcweir             {
1892cdf0e10cSrcweir                 const sal_uLong nAllLines = ((SwTxtFrm*)pCntnt)->GetAllLines();
1893cdf0e10cSrcweir                 ((SwTxtFrm*)pCntnt)->RecalcAllLines();
1894cdf0e10cSrcweir                 if ( IsPaintExtraData() && IsPaint() &&
1895cdf0e10cSrcweir                      nAllLines != ((SwTxtFrm*)pCntnt)->GetAllLines() )
1896cdf0e10cSrcweir                     pImp->GetShell()->AddPaintRect( pCntnt->Frm() );
1897cdf0e10cSrcweir             }
1898cdf0e10cSrcweir 
1899cdf0e10cSrcweir             if ( IsAgain() )
1900cdf0e10cSrcweir                 return sal_False;
1901cdf0e10cSrcweir 
1902cdf0e10cSrcweir             //Wenn Layout oder Flys wieder Invalid sind breche ich die Verarbeitung
1903cdf0e10cSrcweir             //vorlaeufig ab - allerdings nicht fuer die BrowseView, denn dort wird
1904cdf0e10cSrcweir             //das Layout staendig ungueltig, weil die Seitenhoehe angepasst wird.
1905cdf0e10cSrcweir             //Desgleichen wenn der Benutzer weiterarbeiten will und mindestens ein
1906cdf0e10cSrcweir             //Absatz verarbeitet wurde.
1907cdf0e10cSrcweir             if ( (!pTab || (pTab && !bInValid)) )
1908cdf0e10cSrcweir             {
1909cdf0e10cSrcweir                 CheckIdleEnd();
1910cdf0e10cSrcweir                 // OD 14.04.2003 #106346# - consider interrupt formatting.
1911cdf0e10cSrcweir                 if ( ( IsInterrupt() && !mbFormatCntntOnInterrupt ) ||
1912cdf0e10cSrcweir                      ( !bBrowse && pPage->IsInvalidLayout() ) ||
1913cdf0e10cSrcweir                      // OD 07.05.2003 #109435# - consider interrupt formatting
1914cdf0e10cSrcweir                      ( IS_FLYS && IS_INVAFLY && !mbFormatCntntOnInterrupt )
1915cdf0e10cSrcweir                    )
1916cdf0e10cSrcweir                     return sal_False;
1917cdf0e10cSrcweir             }
1918cdf0e10cSrcweir             if ( pOldUpper != pCntnt->GetUpper() )
1919cdf0e10cSrcweir             {
1920cdf0e10cSrcweir                 const sal_uInt16 nCurNum = pCntnt->FindPageFrm()->GetPhyPageNum();
1921cdf0e10cSrcweir                 if ( nCurNum < pPage->GetPhyPageNum() )
1922cdf0e10cSrcweir                     nPreInvaPage = nCurNum;
1923cdf0e10cSrcweir 
1924cdf0e10cSrcweir                 //Wenn der Frm mehr als eine Seite rueckwaerts geflossen ist, so
1925cdf0e10cSrcweir                 //fangen wir nocheinmal von vorn an damit wir nichts auslassen.
1926cdf0e10cSrcweir                 if ( !IsCalcLayout() && pPage->GetPhyPageNum() > nCurNum+1 )
1927cdf0e10cSrcweir                 {
1928cdf0e10cSrcweir                     SetNextCycle( sal_True );
1929cdf0e10cSrcweir                     // OD 07.05.2003 #109435# - consider interrupt formatting
1930cdf0e10cSrcweir                     if ( !mbFormatCntntOnInterrupt )
1931cdf0e10cSrcweir                     {
1932cdf0e10cSrcweir                         return sal_False;
1933cdf0e10cSrcweir                     }
1934cdf0e10cSrcweir                 }
1935cdf0e10cSrcweir             }
1936cdf0e10cSrcweir             //Wenn der Frame die Seite vorwaerts gewechselt hat, so lassen wir
1937cdf0e10cSrcweir             //den Vorgaenger nocheinmal durchlaufen.
1938*0c72d66fSmseidel             //So werden einerseits Vorgaenger erwischt, die jetzt fuer Retouche
1939cdf0e10cSrcweir             //verantwortlich sind, andererseits werden die Fusszeilen
1940cdf0e10cSrcweir             //auch angefasst.
1941cdf0e10cSrcweir             sal_Bool bSetCntnt = sal_True;
1942cdf0e10cSrcweir             if ( pCntntPrev )
1943cdf0e10cSrcweir             {
1944cdf0e10cSrcweir                 if ( !pCntntPrev->IsValid() && pPage->IsAnLower( pCntntPrev ) )
1945cdf0e10cSrcweir                     pPage->InvalidateCntnt();
1946cdf0e10cSrcweir                 if ( pOldUpper != pCntnt->GetUpper() &&
1947cdf0e10cSrcweir                      pPage->GetPhyPageNum() < pCntnt->FindPageFrm()->GetPhyPageNum() )
1948cdf0e10cSrcweir                 {
1949cdf0e10cSrcweir                     pCntnt = pCntntPrev;
1950cdf0e10cSrcweir                     bSetCntnt = sal_False;
1951cdf0e10cSrcweir                 }
1952cdf0e10cSrcweir             }
1953cdf0e10cSrcweir             if ( bSetCntnt )
1954cdf0e10cSrcweir             {
1955cdf0e10cSrcweir                 if ( bBrowse && !IsIdle() && !IsCalcLayout() && !IsComplete() &&
1956cdf0e10cSrcweir                      pCntnt->Frm().Top() > pImp->GetShell()->VisArea().Bottom())
1957cdf0e10cSrcweir                 {
1958cdf0e10cSrcweir                     const long nBottom = pImp->GetShell()->VisArea().Bottom();
1959cdf0e10cSrcweir                     const SwFrm *pTmp = lcl_FindFirstInvaCntnt( pPage,
1960cdf0e10cSrcweir                                                             nBottom, pCntnt );
1961cdf0e10cSrcweir                     if ( !pTmp )
1962cdf0e10cSrcweir                     {
1963cdf0e10cSrcweir                         if ( (!(IS_FLYS && IS_INVAFLY) ||
1964cdf0e10cSrcweir                               !lcl_FindFirstInvaObj( pPage, nBottom )) &&
1965cdf0e10cSrcweir                               (!pPage->IsInvalidLayout() ||
1966cdf0e10cSrcweir                                !lcl_FindFirstInvaLay( pPage, nBottom )))
1967cdf0e10cSrcweir                             SetBrowseActionStop( sal_True );
1968cdf0e10cSrcweir                         // OD 14.04.2003 #106346# - consider interrupt formatting.
1969cdf0e10cSrcweir                         if ( !mbFormatCntntOnInterrupt )
1970cdf0e10cSrcweir                         {
1971cdf0e10cSrcweir                             return sal_False;
1972cdf0e10cSrcweir                         }
1973cdf0e10cSrcweir                     }
1974cdf0e10cSrcweir                 }
1975cdf0e10cSrcweir                 pCntnt = bNxtCnt ? pCntntNext : pCntnt->GetNextCntntFrm();
1976cdf0e10cSrcweir             }
1977cdf0e10cSrcweir 
1978cdf0e10cSrcweir             RESCHEDULE;
1979cdf0e10cSrcweir         }
1980cdf0e10cSrcweir         else
1981cdf0e10cSrcweir         {
1982cdf0e10cSrcweir             if ( !pCntnt->GetValidLineNumFlag() && pCntnt->IsTxtFrm() )
1983cdf0e10cSrcweir             {
1984cdf0e10cSrcweir                 const sal_uLong nAllLines = ((SwTxtFrm*)pCntnt)->GetAllLines();
1985cdf0e10cSrcweir                 ((SwTxtFrm*)pCntnt)->RecalcAllLines();
1986cdf0e10cSrcweir                 if ( IsPaintExtraData() && IsPaint() &&
1987cdf0e10cSrcweir                      nAllLines != ((SwTxtFrm*)pCntnt)->GetAllLines() )
1988cdf0e10cSrcweir                     pImp->GetShell()->AddPaintRect( pCntnt->Frm() );
1989cdf0e10cSrcweir             }
1990cdf0e10cSrcweir 
1991cdf0e10cSrcweir             //Falls der Frm schon vor der Abarbeitung hier formatiert wurde.
1992cdf0e10cSrcweir             if ( pCntnt->IsTxtFrm() && ((SwTxtFrm*)pCntnt)->HasRepaint() &&
1993cdf0e10cSrcweir                   IsPaint() )
1994cdf0e10cSrcweir                 PaintCntnt( pCntnt, pPage, pCntnt->Frm(), pCntnt->Frm().Bottom());
1995cdf0e10cSrcweir             if ( IsIdle() )
1996cdf0e10cSrcweir             {
1997cdf0e10cSrcweir                 CheckIdleEnd();
1998cdf0e10cSrcweir                 // OD 14.04.2003 #106346# - consider interrupt formatting.
1999cdf0e10cSrcweir                 if ( IsInterrupt() && !mbFormatCntntOnInterrupt )
2000cdf0e10cSrcweir                     return sal_False;
2001cdf0e10cSrcweir             }
2002cdf0e10cSrcweir             if ( bBrowse && !IsIdle() && !IsCalcLayout() && !IsComplete() &&
2003cdf0e10cSrcweir                  pCntnt->Frm().Top() > pImp->GetShell()->VisArea().Bottom())
2004cdf0e10cSrcweir             {
2005cdf0e10cSrcweir                 const long nBottom = pImp->GetShell()->VisArea().Bottom();
2006cdf0e10cSrcweir                 const SwFrm *pTmp = lcl_FindFirstInvaCntnt( pPage,
2007cdf0e10cSrcweir                                                     nBottom, pCntnt );
2008cdf0e10cSrcweir                 if ( !pTmp )
2009cdf0e10cSrcweir                 {
2010cdf0e10cSrcweir                     if ( (!(IS_FLYS && IS_INVAFLY) ||
2011cdf0e10cSrcweir                             !lcl_FindFirstInvaObj( pPage, nBottom )) &&
2012cdf0e10cSrcweir                             (!pPage->IsInvalidLayout() ||
2013cdf0e10cSrcweir                             !lcl_FindFirstInvaLay( pPage, nBottom )))
2014cdf0e10cSrcweir                         SetBrowseActionStop( sal_True );
2015cdf0e10cSrcweir                     // OD 14.04.2003 #106346# - consider interrupt formatting.
2016cdf0e10cSrcweir                     if ( !mbFormatCntntOnInterrupt )
2017cdf0e10cSrcweir                     {
2018cdf0e10cSrcweir                         return sal_False;
2019cdf0e10cSrcweir                     }
2020cdf0e10cSrcweir                 }
2021cdf0e10cSrcweir             }
2022cdf0e10cSrcweir             pCntnt = pCntnt->GetNextCntntFrm();
2023cdf0e10cSrcweir         }
2024cdf0e10cSrcweir     }
2025cdf0e10cSrcweir     CheckWaitCrsr();
2026cdf0e10cSrcweir     // OD 14.04.2003 #106346# - consider interrupt formatting.
2027cdf0e10cSrcweir     return !IsInterrupt() || mbFormatCntntOnInterrupt;
2028cdf0e10cSrcweir }
2029cdf0e10cSrcweir /*************************************************************************
2030cdf0e10cSrcweir |*
2031cdf0e10cSrcweir |*  SwLayAction::_FormatCntnt()
2032cdf0e10cSrcweir |*
2033cdf0e10cSrcweir |*  Beschreibung        Returnt sal_True wenn der Absatz verarbeitet wurde,
2034cdf0e10cSrcweir |*                      sal_False wenn es nichts zu verarbeiten gab.
2035cdf0e10cSrcweir |*  Ersterstellung      MA 07. Dec. 92
2036cdf0e10cSrcweir |*  Letzte Aenderung    MA 11. Mar. 98
2037cdf0e10cSrcweir |*
2038cdf0e10cSrcweir |*************************************************************************/
_FormatCntnt(const SwCntntFrm * pCntnt,const SwPageFrm * pPage)2039cdf0e10cSrcweir void SwLayAction::_FormatCntnt( const SwCntntFrm *pCntnt,
2040cdf0e10cSrcweir                                 const SwPageFrm  *pPage )
2041cdf0e10cSrcweir {
2042cdf0e10cSrcweir     //wird sind hier evtl. nur angekommen, weil der Cntnt DrawObjekte haelt.
2043cdf0e10cSrcweir     const sal_Bool bDrawObjsOnly = pCntnt->IsValid() && !pCntnt->IsCompletePaint() &&
2044cdf0e10cSrcweir                          !pCntnt->IsRetouche();
2045cdf0e10cSrcweir     SWRECTFN( pCntnt )
2046cdf0e10cSrcweir     if ( !bDrawObjsOnly && IsPaint() )
2047cdf0e10cSrcweir     {
2048cdf0e10cSrcweir         const SwRect aOldRect( pCntnt->UnionFrm() );
2049cdf0e10cSrcweir         const long nOldBottom = (pCntnt->*fnRect->fnGetPrtBottom)();
2050cdf0e10cSrcweir         pCntnt->OptCalc();
2051cdf0e10cSrcweir         if( IsAgain() )
2052cdf0e10cSrcweir             return;
2053cdf0e10cSrcweir         if( (*fnRect->fnYDiff)( (pCntnt->Frm().*fnRect->fnGetBottom)(),
2054cdf0e10cSrcweir                                 (aOldRect.*fnRect->fnGetBottom)() ) < 0 )
2055cdf0e10cSrcweir         {
2056cdf0e10cSrcweir             pCntnt->SetRetouche();
2057cdf0e10cSrcweir         }
2058cdf0e10cSrcweir         PaintCntnt( pCntnt, pCntnt->FindPageFrm(), aOldRect, nOldBottom);
2059cdf0e10cSrcweir     }
2060cdf0e10cSrcweir     else
2061cdf0e10cSrcweir     {
2062cdf0e10cSrcweir         if ( IsPaint() && pCntnt->IsTxtFrm() && ((SwTxtFrm*)pCntnt)->HasRepaint() )
2063cdf0e10cSrcweir             PaintCntnt( pCntnt, pPage, pCntnt->Frm(),
2064cdf0e10cSrcweir                         (pCntnt->Frm().*fnRect->fnGetBottom)() );
2065cdf0e10cSrcweir         pCntnt->OptCalc();
2066cdf0e10cSrcweir     }
2067cdf0e10cSrcweir }
2068cdf0e10cSrcweir 
2069cdf0e10cSrcweir /*************************************************************************
2070cdf0e10cSrcweir |*
2071cdf0e10cSrcweir |*  SwLayAction::_FormatFlyCntnt()
2072cdf0e10cSrcweir |*
2073cdf0e10cSrcweir |*  Beschreibung:
2074cdf0e10cSrcweir |*      - Returnt sal_True wenn alle Cntnts des Flys vollstaendig verarbeitet
2075cdf0e10cSrcweir |*        wurden. sal_False wenn vorzeitig unterbrochen wurde.
2076cdf0e10cSrcweir |*  Ersterstellung      MA 02. Dec. 92
2077cdf0e10cSrcweir |*  Letzte Aenderung    MA 24. Jun. 96
2078cdf0e10cSrcweir |*
2079cdf0e10cSrcweir |*************************************************************************/
_FormatFlyCntnt(const SwFlyFrm * pFly)2080cdf0e10cSrcweir sal_Bool SwLayAction::_FormatFlyCntnt( const SwFlyFrm *pFly )
2081cdf0e10cSrcweir {
2082cdf0e10cSrcweir     const SwCntntFrm *pCntnt = pFly->ContainsCntnt();
2083cdf0e10cSrcweir 
2084cdf0e10cSrcweir     while ( pCntnt )
2085cdf0e10cSrcweir     {
2086cdf0e10cSrcweir         // OD 2004-05-10 #i28701#
2087cdf0e10cSrcweir         _FormatCntnt( pCntnt, pCntnt->FindPageFrm() );
2088cdf0e10cSrcweir 
2089cdf0e10cSrcweir         // --> OD 2004-07-23 #i28701# - format floating screen objects
2090cdf0e10cSrcweir         // at content text frame
2091cdf0e10cSrcweir         // --> OD 2004-11-02 #i23129#, #i36347# - pass correct page frame
2092cdf0e10cSrcweir         // to the object formatter.
2093cdf0e10cSrcweir         if ( pCntnt->IsTxtFrm() &&
2094cdf0e10cSrcweir              !SwObjectFormatter::FormatObjsAtFrm(
2095cdf0e10cSrcweir                                             *(const_cast<SwCntntFrm*>(pCntnt)),
2096cdf0e10cSrcweir                                             *(pCntnt->FindPageFrm()), this ) )
2097cdf0e10cSrcweir         // <--
2098cdf0e10cSrcweir         {
2099cdf0e10cSrcweir             // restart format with first content
2100cdf0e10cSrcweir             pCntnt = pFly->ContainsCntnt();
2101cdf0e10cSrcweir             continue;
2102cdf0e10cSrcweir         }
2103cdf0e10cSrcweir         // <--
2104cdf0e10cSrcweir 
2105cdf0e10cSrcweir         if ( !pCntnt->GetValidLineNumFlag() && pCntnt->IsTxtFrm() )
2106cdf0e10cSrcweir         {
2107cdf0e10cSrcweir             const sal_uLong nAllLines = ((SwTxtFrm*)pCntnt)->GetAllLines();
2108cdf0e10cSrcweir             ((SwTxtFrm*)pCntnt)->RecalcAllLines();
2109cdf0e10cSrcweir             if ( IsPaintExtraData() && IsPaint() &&
2110cdf0e10cSrcweir                  nAllLines != ((SwTxtFrm*)pCntnt)->GetAllLines() )
2111cdf0e10cSrcweir                 pImp->GetShell()->AddPaintRect( pCntnt->Frm() );
2112cdf0e10cSrcweir         }
2113cdf0e10cSrcweir 
2114cdf0e10cSrcweir         if ( IsAgain() )
2115cdf0e10cSrcweir             return sal_False;
2116cdf0e10cSrcweir 
2117cdf0e10cSrcweir         //wenn eine Eingabe anliegt breche ich die Verarbeitung ab.
2118cdf0e10cSrcweir         if ( !pFly->IsFlyInCntFrm() )
2119cdf0e10cSrcweir         {
2120cdf0e10cSrcweir             CheckIdleEnd();
2121cdf0e10cSrcweir             // OD 14.04.2003 #106346# - consider interrupt formatting.
2122cdf0e10cSrcweir             if ( IsInterrupt() && !mbFormatCntntOnInterrupt )
2123cdf0e10cSrcweir                 return sal_False;
2124cdf0e10cSrcweir         }
2125cdf0e10cSrcweir         pCntnt = pCntnt->GetNextCntntFrm();
2126cdf0e10cSrcweir     }
2127cdf0e10cSrcweir     CheckWaitCrsr();
2128cdf0e10cSrcweir     // OD 14.04.2003 #106346# - consider interrupt formatting.
2129cdf0e10cSrcweir     return !(IsInterrupt() && !mbFormatCntntOnInterrupt);
2130cdf0e10cSrcweir }
2131cdf0e10cSrcweir 
IsStopPrt() const2132cdf0e10cSrcweir sal_Bool SwLayAction::IsStopPrt() const
2133cdf0e10cSrcweir {
2134cdf0e10cSrcweir     sal_Bool bResult = sal_False;
2135cdf0e10cSrcweir 
2136cdf0e10cSrcweir     if (pImp != NULL && pProgress != NULL)
2137cdf0e10cSrcweir         bResult = pImp->IsStopPrt();
2138cdf0e10cSrcweir 
2139cdf0e10cSrcweir     return bResult;
2140cdf0e10cSrcweir }
2141cdf0e10cSrcweir 
2142cdf0e10cSrcweir /*************************************************************************
2143cdf0e10cSrcweir |*
2144cdf0e10cSrcweir |*  SwLayAction::FormatSpelling(), _FormatSpelling()
2145cdf0e10cSrcweir |*
2146cdf0e10cSrcweir |*  Ersterstellung      AMA 01. Feb. 96
2147cdf0e10cSrcweir |*  Letzte Aenderung    AMA 01. Feb. 96
2148cdf0e10cSrcweir |*
2149cdf0e10cSrcweir |*************************************************************************/
_DoIdleJob(const SwCntntFrm * pCnt,IdleJobType eJob)2150cdf0e10cSrcweir sal_Bool SwLayIdle::_DoIdleJob( const SwCntntFrm *pCnt, IdleJobType eJob )
2151cdf0e10cSrcweir {
2152*0c72d66fSmseidel     ASSERT( pCnt->IsTxtFrm(), "NoTxt neighbor of Txt" );
2153cdf0e10cSrcweir     // robust against misuse by e.g. #i52542#
2154cdf0e10cSrcweir     if( !pCnt->IsTxtFrm() )
2155cdf0e10cSrcweir         return sal_False;
2156cdf0e10cSrcweir 
2157cdf0e10cSrcweir     const SwTxtNode* pTxtNode = pCnt->GetNode()->GetTxtNode();
2158cdf0e10cSrcweir 
2159cdf0e10cSrcweir     bool bProcess = false;
2160cdf0e10cSrcweir     switch ( eJob )
2161cdf0e10cSrcweir     {
2162cdf0e10cSrcweir         case ONLINE_SPELLING :
2163cdf0e10cSrcweir             bProcess = pTxtNode->IsWrongDirty(); break;
2164cdf0e10cSrcweir         case AUTOCOMPLETE_WORDS :
2165cdf0e10cSrcweir             bProcess = pTxtNode->IsAutoCompleteWordDirty(); break;
2166cdf0e10cSrcweir         case WORD_COUNT :
2167cdf0e10cSrcweir             bProcess = pTxtNode->IsWordCountDirty(); break;
2168cdf0e10cSrcweir         case SMART_TAGS :   // SMARTTAGS
2169cdf0e10cSrcweir             bProcess = pTxtNode->IsSmartTagDirty(); break;
2170cdf0e10cSrcweir     }
2171cdf0e10cSrcweir 
2172cdf0e10cSrcweir     if( bProcess )
2173cdf0e10cSrcweir     {
2174cdf0e10cSrcweir         ViewShell *pSh = pImp->GetShell();
2175cdf0e10cSrcweir         if( STRING_LEN == nTxtPos )
2176cdf0e10cSrcweir         {
2177cdf0e10cSrcweir             --nTxtPos;
2178cdf0e10cSrcweir             if( pSh->ISA(SwCrsrShell) && !((SwCrsrShell*)pSh)->IsTableMode() )
2179cdf0e10cSrcweir             {
2180cdf0e10cSrcweir                 SwPaM *pCrsr = ((SwCrsrShell*)pSh)->GetCrsr();
2181cdf0e10cSrcweir                 if( !pCrsr->HasMark() && pCrsr == pCrsr->GetNext() )
2182cdf0e10cSrcweir                 {
2183cdf0e10cSrcweir                     pCntntNode = pCrsr->GetCntntNode();
2184cdf0e10cSrcweir                     nTxtPos =  pCrsr->GetPoint()->nContent.GetIndex();
2185cdf0e10cSrcweir                 }
2186cdf0e10cSrcweir             }
2187cdf0e10cSrcweir         }
2188cdf0e10cSrcweir 
2189cdf0e10cSrcweir         switch ( eJob )
2190cdf0e10cSrcweir         {
2191cdf0e10cSrcweir             case ONLINE_SPELLING :
2192cdf0e10cSrcweir             {
2193cdf0e10cSrcweir                 SwRect aRepaint( ((SwTxtFrm*)pCnt)->_AutoSpell( pCntntNode,  *pSh->GetViewOptions(), nTxtPos ) );
2194cdf0e10cSrcweir                 bPageValid = bPageValid && !pTxtNode->IsWrongDirty();
2195cdf0e10cSrcweir                 if( !bPageValid )
2196cdf0e10cSrcweir                     bAllValid = sal_False;
2197cdf0e10cSrcweir                 if ( aRepaint.HasArea() )
2198cdf0e10cSrcweir                     pImp->GetShell()->InvalidateWindows( aRepaint );
2199cdf0e10cSrcweir                 if ( Application::AnyInput( INPUT_MOUSEANDKEYBOARD|INPUT_OTHER|INPUT_PAINT ) )
2200cdf0e10cSrcweir                     return sal_True;
2201cdf0e10cSrcweir                 break;
2202cdf0e10cSrcweir             }
2203cdf0e10cSrcweir             case AUTOCOMPLETE_WORDS :
2204cdf0e10cSrcweir                 ((SwTxtFrm*)pCnt)->CollectAutoCmplWrds( pCntntNode, nTxtPos );
2205cdf0e10cSrcweir                 if ( Application::AnyInput( INPUT_ANY ) )
2206cdf0e10cSrcweir                     return sal_True;
2207cdf0e10cSrcweir                 break;
2208cdf0e10cSrcweir             case WORD_COUNT :
2209cdf0e10cSrcweir             {
2210cdf0e10cSrcweir                 const xub_StrLen nEnd = pTxtNode->GetTxt().Len();
2211cdf0e10cSrcweir                 SwDocStat aStat;
2212cdf0e10cSrcweir                 pTxtNode->CountWords( aStat, 0, nEnd );
2213cdf0e10cSrcweir                 if ( Application::AnyInput( INPUT_ANY ) )
2214cdf0e10cSrcweir                     return sal_True;
2215cdf0e10cSrcweir                 break;
2216cdf0e10cSrcweir             }
2217cdf0e10cSrcweir             case SMART_TAGS : // SMARTTAGS
2218cdf0e10cSrcweir             {
22197a3d834cSHerbert Dürr                 try {
2220cdf0e10cSrcweir                     const SwRect aRepaint( ((SwTxtFrm*)pCnt)->SmartTagScan( pCntntNode, nTxtPos ) );
2221cdf0e10cSrcweir                     bPageValid = bPageValid && !pTxtNode->IsSmartTagDirty();
2222cdf0e10cSrcweir                     if( !bPageValid )
2223cdf0e10cSrcweir                         bAllValid = sal_False;
2224cdf0e10cSrcweir                     if ( aRepaint.HasArea() )
2225cdf0e10cSrcweir                         pImp->GetShell()->InvalidateWindows( aRepaint );
22267a3d834cSHerbert Dürr                 } catch( const ::com::sun::star::uno::RuntimeException& e) {
22277a3d834cSHerbert Dürr                     // #i122885# handle smarttag problems gracefully and provide diagnostics
222814b87244SHerbert Dürr                     DBG_WARNING( rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
22297a3d834cSHerbert Dürr                 }
2230cdf0e10cSrcweir                 if ( Application::AnyInput( INPUT_MOUSEANDKEYBOARD|INPUT_OTHER|INPUT_PAINT ) )
2231cdf0e10cSrcweir                     return sal_True;
2232cdf0e10cSrcweir                 break;
2233cdf0e10cSrcweir             }
2234cdf0e10cSrcweir         }
2235cdf0e10cSrcweir     }
2236cdf0e10cSrcweir 
2237cdf0e10cSrcweir     //Die im Absatz verankerten Flys wollen auch mitspielen.
2238cdf0e10cSrcweir     if ( pCnt->GetDrawObjs() )
2239cdf0e10cSrcweir     {
2240cdf0e10cSrcweir         const SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
2241cdf0e10cSrcweir         for ( sal_uInt16 i = 0; i < rObjs.Count(); ++i )
2242cdf0e10cSrcweir         {
2243cdf0e10cSrcweir             SwAnchoredObject* pObj = rObjs[i];
2244cdf0e10cSrcweir             if ( pObj->ISA(SwFlyFrm) )
2245cdf0e10cSrcweir             {
2246cdf0e10cSrcweir                 SwFlyFrm* pFly = static_cast<SwFlyFrm*>(pObj);
2247cdf0e10cSrcweir                 if ( pFly->IsFlyInCntFrm() )
2248cdf0e10cSrcweir                 {
2249cdf0e10cSrcweir                     const SwCntntFrm *pC = pFly->ContainsCntnt();
2250cdf0e10cSrcweir                     while( pC )
2251cdf0e10cSrcweir                     {
2252cdf0e10cSrcweir                         if ( pC->IsTxtFrm() )
2253cdf0e10cSrcweir                         {
2254cdf0e10cSrcweir                             if ( _DoIdleJob( pC, eJob ) )
2255cdf0e10cSrcweir                                 return sal_True;
2256cdf0e10cSrcweir                         }
2257cdf0e10cSrcweir                         pC = pC->GetNextCntntFrm();
2258cdf0e10cSrcweir                     }
2259cdf0e10cSrcweir                 }
2260cdf0e10cSrcweir             }
2261cdf0e10cSrcweir         }
2262cdf0e10cSrcweir     }
2263cdf0e10cSrcweir     return sal_False;
2264cdf0e10cSrcweir }
2265cdf0e10cSrcweir 
DoIdleJob(IdleJobType eJob,sal_Bool bVisAreaOnly)2266cdf0e10cSrcweir sal_Bool SwLayIdle::DoIdleJob( IdleJobType eJob, sal_Bool bVisAreaOnly )
2267cdf0e10cSrcweir {
2268cdf0e10cSrcweir     //Spellchecken aller Inhalte der Seiten. Entweder nur der sichtbaren
2269cdf0e10cSrcweir     //Seiten oder eben aller.
2270cdf0e10cSrcweir     const ViewShell* pViewShell = pImp->GetShell();
2271cdf0e10cSrcweir     const SwViewOption* pViewOptions = pViewShell->GetViewOptions();
2272cdf0e10cSrcweir     const SwDoc* pDoc = pViewShell->GetDoc();
2273cdf0e10cSrcweir 
2274cdf0e10cSrcweir     switch ( eJob )
2275cdf0e10cSrcweir     {
2276cdf0e10cSrcweir         case ONLINE_SPELLING :
2277cdf0e10cSrcweir             if( !pViewOptions->IsOnlineSpell() )
2278cdf0e10cSrcweir                 return sal_False;
2279cdf0e10cSrcweir             break;
2280cdf0e10cSrcweir         case AUTOCOMPLETE_WORDS :
2281cdf0e10cSrcweir             if( !pViewOptions->IsAutoCompleteWords() ||
2282cdf0e10cSrcweir                  pDoc->GetAutoCompleteWords().IsLockWordLstLocked())
2283cdf0e10cSrcweir                 return sal_False;
2284cdf0e10cSrcweir             break;
2285cdf0e10cSrcweir         case WORD_COUNT :
2286cdf0e10cSrcweir             if ( !pViewShell->getIDocumentStatistics()->GetDocStat().bModified )
2287cdf0e10cSrcweir                 return sal_False;
2288cdf0e10cSrcweir             break;
2289cdf0e10cSrcweir         case SMART_TAGS :
2290cdf0e10cSrcweir             if ( pDoc->GetDocShell()->IsHelpDocument() ||
2291cdf0e10cSrcweir                  pDoc->isXForms() ||
2292cdf0e10cSrcweir                 !SwSmartTagMgr::Get().IsSmartTagsEnabled() )
2293cdf0e10cSrcweir                 return sal_False;
2294cdf0e10cSrcweir             break;
2295cdf0e10cSrcweir         default: ASSERT( false, "Unknown idle job type" )
2296cdf0e10cSrcweir     }
2297cdf0e10cSrcweir 
2298cdf0e10cSrcweir     SwPageFrm *pPage;
2299cdf0e10cSrcweir     if ( bVisAreaOnly )
2300cdf0e10cSrcweir         pPage = pImp->GetFirstVisPage();
2301cdf0e10cSrcweir     else
2302cdf0e10cSrcweir         pPage = (SwPageFrm*)pRoot->Lower();
2303cdf0e10cSrcweir 
2304cdf0e10cSrcweir     pCntntNode = NULL;
2305cdf0e10cSrcweir     nTxtPos = STRING_LEN;
2306cdf0e10cSrcweir 
2307cdf0e10cSrcweir     while ( pPage )
2308cdf0e10cSrcweir     {
2309cdf0e10cSrcweir         bPageValid = sal_True;
2310cdf0e10cSrcweir         const SwCntntFrm *pCnt = pPage->ContainsCntnt();
2311cdf0e10cSrcweir         while( pCnt && pPage->IsAnLower( pCnt ) )
2312cdf0e10cSrcweir         {
2313cdf0e10cSrcweir             if ( _DoIdleJob( pCnt, eJob ) )
2314cdf0e10cSrcweir                 return sal_True;
2315cdf0e10cSrcweir             pCnt = pCnt->GetNextCntntFrm();
2316cdf0e10cSrcweir         }
2317cdf0e10cSrcweir         if ( pPage->GetSortedObjs() )
2318cdf0e10cSrcweir         {
2319cdf0e10cSrcweir             for ( sal_uInt16 i = 0; pPage->GetSortedObjs() &&
2320cdf0e10cSrcweir                                 i < pPage->GetSortedObjs()->Count(); ++i )
2321cdf0e10cSrcweir             {
2322cdf0e10cSrcweir                 const SwAnchoredObject* pObj = (*pPage->GetSortedObjs())[i];
2323cdf0e10cSrcweir                 if ( pObj->ISA(SwFlyFrm) )
2324cdf0e10cSrcweir                 {
2325cdf0e10cSrcweir                     const SwFlyFrm *pFly = static_cast<const SwFlyFrm*>(pObj);
2326cdf0e10cSrcweir                     const SwCntntFrm *pC = pFly->ContainsCntnt();
2327cdf0e10cSrcweir                     while( pC )
2328cdf0e10cSrcweir                     {
2329cdf0e10cSrcweir                         if ( pC->IsTxtFrm() )
2330cdf0e10cSrcweir                         {
2331cdf0e10cSrcweir                             if ( _DoIdleJob( pC, eJob ) )
2332cdf0e10cSrcweir                                 return sal_True;
2333cdf0e10cSrcweir                         }
2334cdf0e10cSrcweir                         pC = pC->GetNextCntntFrm();
2335cdf0e10cSrcweir                     }
2336cdf0e10cSrcweir                 }
2337cdf0e10cSrcweir             }
2338cdf0e10cSrcweir         }
2339cdf0e10cSrcweir 
2340cdf0e10cSrcweir         if( bPageValid )
2341cdf0e10cSrcweir         {
2342cdf0e10cSrcweir             switch ( eJob )
2343cdf0e10cSrcweir             {
2344cdf0e10cSrcweir                 case ONLINE_SPELLING : pPage->ValidateSpelling(); break;
2345cdf0e10cSrcweir                 case AUTOCOMPLETE_WORDS : pPage->ValidateAutoCompleteWords(); break;
2346cdf0e10cSrcweir                 case WORD_COUNT : pPage->ValidateWordCount(); break;
2347cdf0e10cSrcweir                 case SMART_TAGS : pPage->ValidateSmartTags(); break; // SMARTTAGS
2348cdf0e10cSrcweir             }
2349cdf0e10cSrcweir         }
2350cdf0e10cSrcweir 
2351cdf0e10cSrcweir         pPage = (SwPageFrm*)pPage->GetNext();
2352cdf0e10cSrcweir         if ( pPage && bVisAreaOnly &&
2353cdf0e10cSrcweir              !pPage->Frm().IsOver( pImp->GetShell()->VisArea()))
2354cdf0e10cSrcweir              break;
2355cdf0e10cSrcweir     }
2356cdf0e10cSrcweir     return sal_False;
2357cdf0e10cSrcweir }
2358cdf0e10cSrcweir 
2359cdf0e10cSrcweir 
2360cdf0e10cSrcweir #ifdef DBG_UTIL
2361cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
2362cdf0e10cSrcweir 
2363cdf0e10cSrcweir /*************************************************************************
2364cdf0e10cSrcweir |*
2365cdf0e10cSrcweir |*  void SwLayIdle::SwLayIdle()
2366cdf0e10cSrcweir |*
2367cdf0e10cSrcweir |*  Ersterstellung      MA ??
2368cdf0e10cSrcweir |*  Letzte Aenderung    MA 09. Jun. 94
2369cdf0e10cSrcweir |*
2370cdf0e10cSrcweir |*************************************************************************/
ShowIdle(ColorData eColorData)2371cdf0e10cSrcweir void SwLayIdle::ShowIdle( ColorData eColorData )
2372cdf0e10cSrcweir {
2373cdf0e10cSrcweir     if ( !bIndicator )
2374cdf0e10cSrcweir     {
2375cdf0e10cSrcweir         bIndicator = sal_True;
2376cdf0e10cSrcweir         Window *pWin = pImp->GetShell()->GetWin();
2377cdf0e10cSrcweir         if ( pWin )
2378cdf0e10cSrcweir         {
2379cdf0e10cSrcweir             Rectangle aRect( 0, 0, 5, 5 );
2380cdf0e10cSrcweir             aRect = pWin->PixelToLogic( aRect );
2381cdf0e10cSrcweir             // OD 2004-04-23 #116347#
2382cdf0e10cSrcweir             pWin->Push( PUSH_FILLCOLOR|PUSH_LINECOLOR );
2383cdf0e10cSrcweir             pWin->SetFillColor( eColorData );
2384cdf0e10cSrcweir             pWin->SetLineColor();
2385cdf0e10cSrcweir             pWin->DrawRect( aRect );
2386cdf0e10cSrcweir             pWin->Pop();
2387cdf0e10cSrcweir         }
2388cdf0e10cSrcweir     }
2389cdf0e10cSrcweir }
2390cdf0e10cSrcweir #define SHOW_IDLE( ColorData ) ShowIdle( ColorData )
2391cdf0e10cSrcweir #else
2392cdf0e10cSrcweir #define SHOW_IDLE( ColorData )
2393cdf0e10cSrcweir #endif
2394cdf0e10cSrcweir #else
2395cdf0e10cSrcweir #define SHOW_IDLE( ColorData )
2396cdf0e10cSrcweir #endif
2397cdf0e10cSrcweir 
2398cdf0e10cSrcweir /*************************************************************************
2399cdf0e10cSrcweir |*
2400cdf0e10cSrcweir |*  void SwLayIdle::SwLayIdle()
2401cdf0e10cSrcweir |*
2402cdf0e10cSrcweir |*  Ersterstellung      MA 30. Oct. 92
2403cdf0e10cSrcweir |*  Letzte Aenderung    MA 23. May. 95
2404cdf0e10cSrcweir |*
2405cdf0e10cSrcweir |*************************************************************************/
SwLayIdle(SwRootFrm * pRt,SwViewImp * pI)2406cdf0e10cSrcweir SwLayIdle::SwLayIdle( SwRootFrm *pRt, SwViewImp *pI ) :
2407cdf0e10cSrcweir     pRoot( pRt ),
2408cdf0e10cSrcweir     pImp( pI )
2409cdf0e10cSrcweir #ifdef DBG_UTIL
2410cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
2411cdf0e10cSrcweir     , bIndicator( sal_False )
2412cdf0e10cSrcweir #endif
2413cdf0e10cSrcweir #endif
2414cdf0e10cSrcweir {
2415cdf0e10cSrcweir     pImp->pIdleAct = this;
2416cdf0e10cSrcweir 
2417cdf0e10cSrcweir     SHOW_IDLE( COL_LIGHTRED );
2418cdf0e10cSrcweir 
2419cdf0e10cSrcweir     pImp->GetShell()->EnableSmooth( sal_False );
2420cdf0e10cSrcweir 
2421cdf0e10cSrcweir     //Zuerst den Sichtbaren Bereich Spellchecken, nur wenn dort nichts
2422cdf0e10cSrcweir     //zu tun war wird das IdleFormat angestossen.
2423cdf0e10cSrcweir     if ( !DoIdleJob( SMART_TAGS, sal_True ) &&
2424cdf0e10cSrcweir          !DoIdleJob( ONLINE_SPELLING, sal_True ) &&
2425cdf0e10cSrcweir          !DoIdleJob( AUTOCOMPLETE_WORDS, sal_True ) ) // SMARTTAGS
2426cdf0e10cSrcweir     {
2427cdf0e10cSrcweir         //Formatieren und ggf. Repaint-Rechtecke an der ViewShell vormerken.
2428cdf0e10cSrcweir         //Dabei muessen kuenstliche Actions laufen, damit es z.B. bei
2429cdf0e10cSrcweir         //Veraenderungen der Seitenzahl nicht zu unerwuenschten Effekten kommt.
2430cdf0e10cSrcweir         //Wir merken uns bei welchen Shells der Cursor sichtbar ist, damit
2431cdf0e10cSrcweir         //wir ihn bei Dokumentaenderung ggf. wieder sichbar machen koennen.
2432cdf0e10cSrcweir         SvBools aBools;
2433cdf0e10cSrcweir         ViewShell *pSh = pImp->GetShell();
2434cdf0e10cSrcweir         do
2435cdf0e10cSrcweir         {   ++pSh->nStartAction;
2436cdf0e10cSrcweir             sal_Bool bVis = sal_False;
2437cdf0e10cSrcweir             if ( pSh->ISA(SwCrsrShell) )
2438cdf0e10cSrcweir             {
2439cdf0e10cSrcweir #ifdef SW_CRSR_TIMER
2440cdf0e10cSrcweir                 ((SwCrsrShell*)pSh)->ChgCrsrTimerFlag( sal_False );
2441cdf0e10cSrcweir #endif
2442cdf0e10cSrcweir                 bVis = ((SwCrsrShell*)pSh)->GetCharRect().IsOver(pSh->VisArea());
2443cdf0e10cSrcweir             }
2444cdf0e10cSrcweir             aBools.push_back( bVis );
2445cdf0e10cSrcweir             pSh = (ViewShell*)pSh->GetNext();
2446cdf0e10cSrcweir         } while ( pSh != pImp->GetShell() );
2447cdf0e10cSrcweir 
2448cdf0e10cSrcweir         SwLayAction aAction( pRoot, pImp );
2449cdf0e10cSrcweir         aAction.SetInputType( INPUT_ANY );
2450cdf0e10cSrcweir         aAction.SetIdle( sal_True );
2451cdf0e10cSrcweir         aAction.SetWaitAllowed( sal_False );
2452cdf0e10cSrcweir         aAction.Action();
2453cdf0e10cSrcweir 
2454cdf0e10cSrcweir         //Weitere Start-/EndActions nur auf wenn irgendwo Paints aufgelaufen
2455cdf0e10cSrcweir         //sind oder wenn sich die Sichtbarkeit des CharRects veraendert hat.
2456cdf0e10cSrcweir         sal_Bool bActions = sal_False;
2457cdf0e10cSrcweir         sal_uInt16 nBoolIdx = 0;
2458cdf0e10cSrcweir         do
2459cdf0e10cSrcweir         {
2460cdf0e10cSrcweir             --pSh->nStartAction;
2461cdf0e10cSrcweir 
2462cdf0e10cSrcweir             if ( pSh->Imp()->GetRegion() )
2463cdf0e10cSrcweir                 bActions = sal_True;
2464cdf0e10cSrcweir             else
2465cdf0e10cSrcweir             {
2466cdf0e10cSrcweir                 SwRect aTmp( pSh->VisArea() );
2467cdf0e10cSrcweir                 pSh->UISizeNotify();
2468cdf0e10cSrcweir 
2469cdf0e10cSrcweir                 // --> FME 2006-08-03 #137134#
2470cdf0e10cSrcweir                 // Are we supposed to crash if pSh isn't a cursor shell?!
2471cdf0e10cSrcweir                 // bActions |= aTmp != pSh->VisArea() ||
2472cdf0e10cSrcweir                 //             aBools[nBoolIdx] != ((SwCrsrShell*)pSh)->GetCharRect().IsOver( pSh->VisArea() );
2473cdf0e10cSrcweir 
2474cdf0e10cSrcweir                 // aBools[ i ] is true, if the i-th shell is a cursor shell (!!!)
2475cdf0e10cSrcweir                 // and the cursor is visible.
2476cdf0e10cSrcweir                 bActions |= aTmp != pSh->VisArea();
2477cdf0e10cSrcweir                 if ( aTmp == pSh->VisArea() && pSh->ISA(SwCrsrShell) )
2478cdf0e10cSrcweir                 {
2479cdf0e10cSrcweir                     bActions |= aBools[nBoolIdx] !=
2480cdf0e10cSrcweir                                 static_cast<SwCrsrShell*>(pSh)->GetCharRect().IsOver( pSh->VisArea() );
2481cdf0e10cSrcweir                 }
2482cdf0e10cSrcweir             }
2483cdf0e10cSrcweir 
2484cdf0e10cSrcweir             pSh = (ViewShell*)pSh->GetNext();
2485cdf0e10cSrcweir             ++nBoolIdx;
2486cdf0e10cSrcweir         } while ( pSh != pImp->GetShell() );
2487cdf0e10cSrcweir 
2488cdf0e10cSrcweir         if ( bActions )
2489cdf0e10cSrcweir         {
2490cdf0e10cSrcweir             //Start- EndActions aufsetzen. ueber die CrsrShell, damit der
2491cdf0e10cSrcweir             //Cursor/Selektion und die VisArea korrekt gesetzt werden.
2492cdf0e10cSrcweir             nBoolIdx = 0;
2493cdf0e10cSrcweir             do
2494cdf0e10cSrcweir             {
2495cdf0e10cSrcweir                 sal_Bool bCrsrShell = pSh->IsA( TYPE(SwCrsrShell) );
2496cdf0e10cSrcweir 
2497cdf0e10cSrcweir                 if ( bCrsrShell )
2498cdf0e10cSrcweir                     ((SwCrsrShell*)pSh)->SttCrsrMove();
2499cdf0e10cSrcweir //              else
2500cdf0e10cSrcweir //                  pSh->StartAction();
2501cdf0e10cSrcweir 
2502cdf0e10cSrcweir                 //Wenn Paints aufgelaufen sind, ist es am sinnvollsten schlicht das
2503cdf0e10cSrcweir                 //gesamte Window zu invalidieren. Anderfalls gibt es Paintprobleme
2504cdf0e10cSrcweir                 //deren Loesung unverhaeltnissmaessig aufwendig waere.
2505cdf0e10cSrcweir                 //fix(18176):
2506cdf0e10cSrcweir                 SwViewImp *pViewImp = pSh->Imp();
2507cdf0e10cSrcweir                 sal_Bool bUnlock = sal_False;
2508cdf0e10cSrcweir                 if ( pViewImp->GetRegion() )
2509cdf0e10cSrcweir                 {
2510cdf0e10cSrcweir                     pViewImp->DelRegion();
2511cdf0e10cSrcweir 
2512cdf0e10cSrcweir                     //Fuer Repaint mit virtuellem Device sorgen.
2513cdf0e10cSrcweir                     pSh->LockPaint();
2514cdf0e10cSrcweir                     bUnlock = sal_True;
2515cdf0e10cSrcweir                 }
2516cdf0e10cSrcweir 
2517cdf0e10cSrcweir                 if ( bCrsrShell )
2518cdf0e10cSrcweir                     //Wenn der Crsr sichbar war wieder sichbar machen, sonst
2519cdf0e10cSrcweir                     //EndCrsrMove mit sal_True fuer IdleEnd.
2520cdf0e10cSrcweir                     ((SwCrsrShell*)pSh)->EndCrsrMove( sal_True^aBools[nBoolIdx] );
2521cdf0e10cSrcweir //              else
2522cdf0e10cSrcweir //                  pSh->EndAction();
2523cdf0e10cSrcweir                 if( bUnlock )
2524cdf0e10cSrcweir                 {
2525cdf0e10cSrcweir                     if( bCrsrShell )
2526cdf0e10cSrcweir                     {
2527cdf0e10cSrcweir                         // UnlockPaint overwrite the selection from the
2528cdf0e10cSrcweir                         // CrsrShell and calls the virtual method paint
2529cdf0e10cSrcweir                         // to fill the virtual device. This fill dont have
2530cdf0e10cSrcweir                         // paint the selection! -> Set the focus flag at
2531cdf0e10cSrcweir                         // CrsrShell and it dont paint the selection.
2532cdf0e10cSrcweir                         ((SwCrsrShell*)pSh)->ShLooseFcs();
2533cdf0e10cSrcweir                         pSh->UnlockPaint( sal_True );
2534cdf0e10cSrcweir                         ((SwCrsrShell*)pSh)->ShGetFcs( sal_False );
2535cdf0e10cSrcweir                     }
2536cdf0e10cSrcweir                     else
2537cdf0e10cSrcweir                         pSh->UnlockPaint( sal_True );
2538cdf0e10cSrcweir                 }
2539cdf0e10cSrcweir 
2540cdf0e10cSrcweir                 pSh = (ViewShell*)pSh->GetNext();
2541cdf0e10cSrcweir                 ++nBoolIdx;
2542cdf0e10cSrcweir 
2543cdf0e10cSrcweir             } while ( pSh != pImp->GetShell() );
2544cdf0e10cSrcweir         }
2545cdf0e10cSrcweir 
2546cdf0e10cSrcweir         if ( !aAction.IsInterrupt() )
2547cdf0e10cSrcweir         {
2548cdf0e10cSrcweir             if ( !DoIdleJob( WORD_COUNT, sal_False ) )
2549cdf0e10cSrcweir                 if ( !DoIdleJob( SMART_TAGS, sal_False ) )
2550cdf0e10cSrcweir                     if ( !DoIdleJob( ONLINE_SPELLING, sal_False ) )
2551cdf0e10cSrcweir                         DoIdleJob( AUTOCOMPLETE_WORDS, sal_False ); // SMARTTAGS
2552cdf0e10cSrcweir         }
2553cdf0e10cSrcweir 
2554cdf0e10cSrcweir         bool bInValid = false;
2555cdf0e10cSrcweir         const SwViewOption& rVOpt = *pImp->GetShell()->GetViewOptions();
2556cdf0e10cSrcweir         const ViewShell* pViewShell = pImp->GetShell();
2557cdf0e10cSrcweir         // See conditions in DoIdleJob()
2558cdf0e10cSrcweir         const sal_Bool bSpell     = rVOpt.IsOnlineSpell();
2559cdf0e10cSrcweir         const sal_Bool bACmplWrd  = rVOpt.IsAutoCompleteWords();
2560cdf0e10cSrcweir         const sal_Bool bWordCount = pViewShell->getIDocumentStatistics()->GetDocStat().bModified;
2561cdf0e10cSrcweir         const sal_Bool bSmartTags = !pViewShell->GetDoc()->GetDocShell()->IsHelpDocument() &&
2562cdf0e10cSrcweir                                 !pViewShell->GetDoc()->isXForms() &&
2563cdf0e10cSrcweir                                 SwSmartTagMgr::Get().IsSmartTagsEnabled(); // SMARTTAGS
2564cdf0e10cSrcweir 
2565cdf0e10cSrcweir         SwPageFrm *pPg = (SwPageFrm*)pRoot->Lower();
2566cdf0e10cSrcweir         do
2567cdf0e10cSrcweir         {
2568cdf0e10cSrcweir             bInValid = pPg->IsInvalidCntnt()    || pPg->IsInvalidLayout() ||
2569cdf0e10cSrcweir                        pPg->IsInvalidFlyCntnt() || pPg->IsInvalidFlyLayout() ||
2570cdf0e10cSrcweir                        pPg->IsInvalidFlyInCnt() ||
2571cdf0e10cSrcweir                        (bSpell && pPg->IsInvalidSpelling()) ||
2572cdf0e10cSrcweir                        (bACmplWrd && pPg->IsInvalidAutoCompleteWords()) ||
2573cdf0e10cSrcweir                        (bWordCount && pPg->IsInvalidWordCount()) ||
2574cdf0e10cSrcweir                        (bSmartTags && pPg->IsInvalidSmartTags()); // SMARTTAGS
2575cdf0e10cSrcweir 
2576cdf0e10cSrcweir             pPg = (SwPageFrm*)pPg->GetNext();
2577cdf0e10cSrcweir 
2578cdf0e10cSrcweir         } while ( pPg && !bInValid );
2579cdf0e10cSrcweir 
2580cdf0e10cSrcweir         if ( !bInValid )
2581cdf0e10cSrcweir         {
2582cdf0e10cSrcweir             pRoot->ResetIdleFormat();
2583cdf0e10cSrcweir             SfxObjectShell* pDocShell = pImp->GetShell()->GetDoc()->GetDocShell();
2584cdf0e10cSrcweir             pDocShell->Broadcast( SfxEventHint( SW_EVENT_LAYOUT_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_LAYOUT_FINISHED), pDocShell ) );
2585cdf0e10cSrcweir         }
2586cdf0e10cSrcweir     }
2587cdf0e10cSrcweir 
2588cdf0e10cSrcweir     pImp->GetShell()->EnableSmooth( sal_True );
2589cdf0e10cSrcweir 
2590cdf0e10cSrcweir     if( pImp->IsAccessible() )
2591cdf0e10cSrcweir         pImp->FireAccessibleEvents();
2592cdf0e10cSrcweir 
2593cdf0e10cSrcweir #ifdef DBG_UTIL
2594cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
2595cdf0e10cSrcweir     if ( bIndicator && pImp->GetShell()->GetWin() )
2596cdf0e10cSrcweir     {
2597cdf0e10cSrcweir         // #i75172# Do not invalidate indicator, this may cause a endless loop. Instead, just repaint it
2598cdf0e10cSrcweir         // This should be replaced by an overlay object in the future, anyways. Since it's only for debug
2599cdf0e10cSrcweir         // purposes, it is not urgent.
2600cdf0e10cSrcweir         static bool bCheckWithoutInvalidating(true);
2601cdf0e10cSrcweir         if(bCheckWithoutInvalidating)
2602cdf0e10cSrcweir         {
2603cdf0e10cSrcweir             bIndicator = false; SHOW_IDLE( COL_LIGHTGREEN );
2604cdf0e10cSrcweir         }
2605cdf0e10cSrcweir         else
2606cdf0e10cSrcweir         {
2607cdf0e10cSrcweir             Rectangle aRect( 0, 0, 5, 5 );
2608cdf0e10cSrcweir             aRect = pImp->GetShell()->GetWin()->PixelToLogic( aRect );
2609cdf0e10cSrcweir             pImp->GetShell()->GetWin()->Invalidate( aRect );
2610cdf0e10cSrcweir         }
2611cdf0e10cSrcweir     }
2612cdf0e10cSrcweir #endif
2613cdf0e10cSrcweir #endif
2614cdf0e10cSrcweir }
2615cdf0e10cSrcweir 
~SwLayIdle()2616cdf0e10cSrcweir SwLayIdle::~SwLayIdle()
2617cdf0e10cSrcweir {
2618cdf0e10cSrcweir     pImp->pIdleAct = 0;
2619cdf0e10cSrcweir }
2620*0c72d66fSmseidel 
2621*0c72d66fSmseidel /* vim: set noet sw=4 ts=4: */
2622