xref: /trunk/main/sw/source/core/layout/pagechg.cxx (revision e9dc4413)
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
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
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.
19efeef26fSAndrew Rist  *
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 #include <com/sun/star/embed/EmbedStates.hpp>
28cdf0e10cSrcweir #include <ndole.hxx>
29cdf0e10cSrcweir #include <docary.hxx>
30cdf0e10cSrcweir #include <svl/itemiter.hxx>
31cdf0e10cSrcweir #include <fmtfsize.hxx>
32cdf0e10cSrcweir #include <fmthdft.hxx>
33cdf0e10cSrcweir #include <fmtclds.hxx>
34cdf0e10cSrcweir #include <fmtanchr.hxx>
35cdf0e10cSrcweir #include <fmtpdsc.hxx>
36cdf0e10cSrcweir #include <fmtfordr.hxx>
37cdf0e10cSrcweir #include <fmtfld.hxx>
38cdf0e10cSrcweir #include <fmtornt.hxx>
39*e9dc4413SOliver-Rainer Wittmann #include <fmtsrnd.hxx>
40cdf0e10cSrcweir #include <ftninfo.hxx>
41cdf0e10cSrcweir #include <tgrditem.hxx>
42cdf0e10cSrcweir #include <viewopt.hxx>
43cdf0e10cSrcweir #include <docsh.hxx>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include "viewimp.hxx"
46cdf0e10cSrcweir #include "viewopt.hxx"
47cdf0e10cSrcweir #include "pagefrm.hxx"
48cdf0e10cSrcweir #include "rootfrm.hxx"
49cdf0e10cSrcweir #include "cntfrm.hxx"
50cdf0e10cSrcweir #include "flyfrm.hxx"
51cdf0e10cSrcweir #include "doc.hxx"
52cdf0e10cSrcweir #include "fesh.hxx"
53cdf0e10cSrcweir #include "dview.hxx"
54cdf0e10cSrcweir #include "dflyobj.hxx"
55cdf0e10cSrcweir #include "dcontact.hxx"
56cdf0e10cSrcweir #include "frmtool.hxx"
57cdf0e10cSrcweir #include "fldbas.hxx"
58cdf0e10cSrcweir #include "hints.hxx"
59cdf0e10cSrcweir #include "errhdl.hxx"
60cdf0e10cSrcweir #include "swtable.hxx"
61cdf0e10cSrcweir 
62cdf0e10cSrcweir #include "ftnidx.hxx"
63cdf0e10cSrcweir #include "bodyfrm.hxx"
64cdf0e10cSrcweir #include "ftnfrm.hxx"
65cdf0e10cSrcweir #include "tabfrm.hxx"
66cdf0e10cSrcweir #include "txtfrm.hxx"
67cdf0e10cSrcweir #include "layact.hxx"
68cdf0e10cSrcweir #include "flyfrms.hxx"
69cdf0e10cSrcweir #include "htmltbl.hxx"
70cdf0e10cSrcweir #include "pagedesc.hxx"
71cdf0e10cSrcweir #include "poolfmt.hxx"
72cdf0e10cSrcweir #include <editeng/frmdiritem.hxx>
73cdf0e10cSrcweir #include <swfntcch.hxx>	// SwFontAccess
74cdf0e10cSrcweir #include <sortedobjs.hxx>
75cdf0e10cSrcweir #include <switerator.hxx>
76cdf0e10cSrcweir #include <vcl/svapp.hxx>
77cdf0e10cSrcweir 
78cdf0e10cSrcweir using namespace ::com::sun::star;
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 
81cdf0e10cSrcweir /*************************************************************************
82cdf0e10cSrcweir |*
83cdf0e10cSrcweir |*	SwBodyFrm::SwBodyFrm()
84cdf0e10cSrcweir |*
85cdf0e10cSrcweir |*	Ersterstellung		MA ??
86cdf0e10cSrcweir |*	Letzte Aenderung	MA 01. Aug. 93
87cdf0e10cSrcweir |*
88cdf0e10cSrcweir |*************************************************************************/
SwBodyFrm(SwFrmFmt * pFmt,SwFrm * pSib)89cdf0e10cSrcweir SwBodyFrm::SwBodyFrm( SwFrmFmt *pFmt, SwFrm* pSib ):
90cdf0e10cSrcweir 	SwLayoutFrm( pFmt, pSib )
91cdf0e10cSrcweir {
92cdf0e10cSrcweir     nType = FRMC_BODY;
93cdf0e10cSrcweir }
94cdf0e10cSrcweir 
95cdf0e10cSrcweir /*************************************************************************
96cdf0e10cSrcweir |*
97cdf0e10cSrcweir |*	SwBodyFrm::Format()
98cdf0e10cSrcweir |*
99cdf0e10cSrcweir |*	Ersterstellung		MA 30. May. 94
100cdf0e10cSrcweir |*	Letzte Aenderung	MA 20. Jan. 99
101cdf0e10cSrcweir |*
102cdf0e10cSrcweir |*************************************************************************/
Format(const SwBorderAttrs *)103cdf0e10cSrcweir void SwBodyFrm::Format( const SwBorderAttrs * )
104cdf0e10cSrcweir {
105cdf0e10cSrcweir 	//Formatieren des Body ist zu einfach, deshalb bekommt er ein eigenes
106cdf0e10cSrcweir 	//Format; Umrandungen und dergl. sind hier nicht zu beruecksichtigen.
107cdf0e10cSrcweir 	//Breite ist die der PrtArea des Uppers, Hoehe ist die Hoehe der PrtArea
108cdf0e10cSrcweir 	//des Uppers abzueglich der Nachbarn (Wird eigentlich eingestellt aber
109cdf0e10cSrcweir 	//Vorsicht ist die Mutter der Robustheit).
110cdf0e10cSrcweir 	//Die PrtArea ist stets so gross wie der Frm itself.
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 	if ( !bValidSize )
113cdf0e10cSrcweir 	{
114cdf0e10cSrcweir 		SwTwips nHeight = GetUpper()->Prt().Height();
115cdf0e10cSrcweir         SwTwips nWidth = GetUpper()->Prt().Width();
116cdf0e10cSrcweir 		const SwFrm *pFrm = GetUpper()->Lower();
117cdf0e10cSrcweir 		do
118cdf0e10cSrcweir         {
119cdf0e10cSrcweir             if ( pFrm != this )
120cdf0e10cSrcweir             {
121cdf0e10cSrcweir                 if( pFrm->IsVertical() )
122cdf0e10cSrcweir                     nWidth -= pFrm->Frm().Width();
123cdf0e10cSrcweir                 else
124cdf0e10cSrcweir                     nHeight -= pFrm->Frm().Height();
125cdf0e10cSrcweir             }
126cdf0e10cSrcweir 			pFrm = pFrm->GetNext();
127cdf0e10cSrcweir 		} while ( pFrm );
128cdf0e10cSrcweir 		if ( nHeight < 0 )
129cdf0e10cSrcweir 			nHeight = 0;
130cdf0e10cSrcweir 		Frm().Height( nHeight );
131cdf0e10cSrcweir         //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
132cdf0e10cSrcweir 		if( IsVertical() && !IsVertLR() && !IsReverse() && nWidth != Frm().Width() )
133cdf0e10cSrcweir             Frm().Pos().X() += Frm().Width() - nWidth;
134cdf0e10cSrcweir         Frm().Width( nWidth );
135cdf0e10cSrcweir 	}
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     sal_Bool bNoGrid = sal_True;
138cdf0e10cSrcweir     if( GetUpper()->IsPageFrm() && ((SwPageFrm*)GetUpper())->HasGrid() )
139cdf0e10cSrcweir     {
140cdf0e10cSrcweir         GETGRID( ((SwPageFrm*)GetUpper()) )
141cdf0e10cSrcweir         if( pGrid )
142cdf0e10cSrcweir         {
143cdf0e10cSrcweir             bNoGrid = sal_False;
144cdf0e10cSrcweir             long nSum = pGrid->GetBaseHeight() + pGrid->GetRubyHeight();
145cdf0e10cSrcweir             SWRECTFN( this )
146cdf0e10cSrcweir             long nSize = (Frm().*fnRect->fnGetWidth)();
147cdf0e10cSrcweir             long nBorder = 0;
148cdf0e10cSrcweir             if( GRID_LINES_CHARS == pGrid->GetGridType() )
149cdf0e10cSrcweir             {
150cdf0e10cSrcweir                 //for textgrid refactor
151cdf0e10cSrcweir 				SwDoc *pDoc = GetFmt()->GetDoc();
152cdf0e10cSrcweir                 nBorder = nSize % (GETGRIDWIDTH(pGrid, pDoc));
153cdf0e10cSrcweir                 nSize -= nBorder;
154cdf0e10cSrcweir                 nBorder /= 2;
155cdf0e10cSrcweir             }
156cdf0e10cSrcweir             (Prt().*fnRect->fnSetPosX)( nBorder );
157cdf0e10cSrcweir             (Prt().*fnRect->fnSetWidth)( nSize );
158cdf0e10cSrcweir 
159cdf0e10cSrcweir             // Height of body frame:
160cdf0e10cSrcweir             nBorder = (Frm().*fnRect->fnGetHeight)();
161cdf0e10cSrcweir 
162cdf0e10cSrcweir             // Number of possible lines in area of body frame:
163cdf0e10cSrcweir             long nNumberOfLines = nBorder / nSum;
164cdf0e10cSrcweir             if( nNumberOfLines > pGrid->GetLines() )
165cdf0e10cSrcweir                 nNumberOfLines = pGrid->GetLines();
166cdf0e10cSrcweir 
167cdf0e10cSrcweir             // Space required for nNumberOfLines lines:
168cdf0e10cSrcweir             nSize = nNumberOfLines * nSum;
169cdf0e10cSrcweir             nBorder -= nSize;
170cdf0e10cSrcweir             nBorder /= 2;
171cdf0e10cSrcweir 
172cdf0e10cSrcweir             // #i21774# Footnotes and centering the grid does not work together:
173cdf0e10cSrcweir             const bool bAdjust = 0 == ((SwPageFrm*)GetUpper())->GetFmt()->GetDoc()->
174cdf0e10cSrcweir                                         GetFtnIdxs().Count();
175cdf0e10cSrcweir 
176cdf0e10cSrcweir             (Prt().*fnRect->fnSetPosY)( bAdjust ? nBorder : 0 );
177cdf0e10cSrcweir             (Prt().*fnRect->fnSetHeight)( nSize );
178cdf0e10cSrcweir         }
179cdf0e10cSrcweir     }
180cdf0e10cSrcweir     if( bNoGrid )
181cdf0e10cSrcweir     {
182cdf0e10cSrcweir         Prt().Pos().X() = Prt().Pos().Y() = 0;
183cdf0e10cSrcweir         Prt().Height( Frm().Height() );
184cdf0e10cSrcweir         Prt().Width( Frm().Width() );
185cdf0e10cSrcweir     }
186cdf0e10cSrcweir 	bValidSize = bValidPrtArea = sal_True;
187cdf0e10cSrcweir }
188cdf0e10cSrcweir 
189cdf0e10cSrcweir /*************************************************************************
190cdf0e10cSrcweir |*
191cdf0e10cSrcweir |*	SwPageFrm::SwPageFrm(), ~SwPageFrm()
192cdf0e10cSrcweir |*
193cdf0e10cSrcweir |*	Ersterstellung		MA 20. Oct. 92
194cdf0e10cSrcweir |*	Letzte Aenderung	MA 08. Dec. 97
195cdf0e10cSrcweir |*
196cdf0e10cSrcweir |*************************************************************************/
SwPageFrm(SwFrmFmt * pFmt,SwFrm * pSib,SwPageDesc * pPgDsc)197cdf0e10cSrcweir SwPageFrm::SwPageFrm( SwFrmFmt *pFmt, SwFrm* pSib, SwPageDesc *pPgDsc ) :
198cdf0e10cSrcweir 	SwFtnBossFrm( pFmt, pSib ),
199cdf0e10cSrcweir 	pSortedObjs( 0 ),
200cdf0e10cSrcweir 	pDesc( pPgDsc ),
201cdf0e10cSrcweir     nPhyPageNum( 0 ),
202cdf0e10cSrcweir     // OD 2004-05-17 #i28701#
203cdf0e10cSrcweir     mbLayoutInProgress( false )
204cdf0e10cSrcweir {
205cdf0e10cSrcweir     SetDerivedVert( sal_False );
206cdf0e10cSrcweir     SetDerivedR2L( sal_False );
207cdf0e10cSrcweir     if( pDesc )
208cdf0e10cSrcweir     {
209cdf0e10cSrcweir         bHasGrid = sal_True;
210cdf0e10cSrcweir         GETGRID( this )
211cdf0e10cSrcweir         if( !pGrid )
212cdf0e10cSrcweir             bHasGrid = sal_False;
213cdf0e10cSrcweir     }
214cdf0e10cSrcweir     else
215cdf0e10cSrcweir         bHasGrid = sal_False;
216cdf0e10cSrcweir 	SetMaxFtnHeight( pPgDsc->GetFtnInfo().GetHeight() ?
217cdf0e10cSrcweir 					 pPgDsc->GetFtnInfo().GetHeight() : LONG_MAX ),
218cdf0e10cSrcweir     nType = FRMC_PAGE;
219cdf0e10cSrcweir     bInvalidLayout = bInvalidCntnt = bInvalidSpelling = bInvalidSmartTags = bInvalidAutoCmplWrds = bInvalidWordCount = sal_True;
220cdf0e10cSrcweir     bInvalidFlyLayout = bInvalidFlyCntnt = bInvalidFlyInCnt = bFtnPage = bEndNotePage = sal_False;
221cdf0e10cSrcweir 
222cdf0e10cSrcweir     ViewShell *pSh = getRootFrm()->GetCurrShell();
223cdf0e10cSrcweir     const bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
224cdf0e10cSrcweir     if ( bBrowseMode )
225cdf0e10cSrcweir 	{
226cdf0e10cSrcweir 		Frm().Height( 0 );
227cdf0e10cSrcweir 		long nWidth = pSh->VisArea().Width();
228cdf0e10cSrcweir 		if ( !nWidth )
229cdf0e10cSrcweir 			nWidth = 5000L;		//aendert sich sowieso
230cdf0e10cSrcweir 		Frm().Width ( nWidth );
231cdf0e10cSrcweir 	}
232cdf0e10cSrcweir 	else
233cdf0e10cSrcweir 		Frm().SSize( pFmt->GetFrmSize().GetSize() );
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 	//Body-Bereich erzeugen und einsetzen, aber nur wenn ich nicht gerade
236cdf0e10cSrcweir 	//eine Leerseite bin.
237cdf0e10cSrcweir     SwDoc *pDoc = pFmt->GetDoc();
238cdf0e10cSrcweir     if ( sal_False == (bEmptyPage = pFmt == pDoc->GetEmptyPageFmt()) )
239cdf0e10cSrcweir 	{
240cdf0e10cSrcweir 		bEmptyPage = sal_False;
241cdf0e10cSrcweir 		Calc();								//Damit die PrtArea stimmt.
242cdf0e10cSrcweir 		SwBodyFrm *pBodyFrm = new SwBodyFrm( pDoc->GetDfltFrmFmt(), this );
243cdf0e10cSrcweir 		pBodyFrm->ChgSize( Prt().SSize() );
244cdf0e10cSrcweir 		pBodyFrm->Paste( this );
245cdf0e10cSrcweir 		pBodyFrm->Calc();					//Damit die Spalten korrekt
246cdf0e10cSrcweir 											//eingesetzt werden koennen.
247cdf0e10cSrcweir 		pBodyFrm->InvalidatePos();
248cdf0e10cSrcweir 
249cdf0e10cSrcweir         if ( bBrowseMode )
250cdf0e10cSrcweir 			_InvalidateSize();		//Alles nur gelogen
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 		//Header/Footer einsetzen, nur rufen wenn aktiv.
253cdf0e10cSrcweir 		if ( pFmt->GetHeader().IsActive() )
254cdf0e10cSrcweir 			PrepareHeader();
255cdf0e10cSrcweir 		if ( pFmt->GetFooter().IsActive() )
256cdf0e10cSrcweir 			PrepareFooter();
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 		const SwFmtCol &rCol = pFmt->GetCol();
259cdf0e10cSrcweir 		if ( rCol.GetNumCols() > 1 )
260cdf0e10cSrcweir 		{
261cdf0e10cSrcweir 			const SwFmtCol aOld; //ChgColumns() verlaesst sich darauf, dass ein
262cdf0e10cSrcweir 								 //Old-Wert hereingereicht wird.
263cdf0e10cSrcweir 			pBodyFrm->ChgColumns( aOld, rCol );
264cdf0e10cSrcweir 		}
265cdf0e10cSrcweir 	}
266cdf0e10cSrcweir }
267cdf0e10cSrcweir 
~SwPageFrm()268cdf0e10cSrcweir SwPageFrm::~SwPageFrm()
269cdf0e10cSrcweir {
270cdf0e10cSrcweir 	//FlyContainer entleeren, delete der Flys uebernimmt der Anchor
271cdf0e10cSrcweir 	//(Basisklasse SwFrm)
272cdf0e10cSrcweir 	if ( pSortedObjs )
273cdf0e10cSrcweir 	{
274cdf0e10cSrcweir 		//Objekte koennen (warum auch immer) auch an Seiten verankert sein,
275cdf0e10cSrcweir 		//die vor Ihren Ankern stehen. Dann wuerde auf bereits freigegebenen
276cdf0e10cSrcweir 		//Speicher zugegriffen.
277cdf0e10cSrcweir 		for ( sal_uInt16 i = 0; i < pSortedObjs->Count(); ++i )
278cdf0e10cSrcweir 		{
279cdf0e10cSrcweir             SwAnchoredObject* pAnchoredObj = (*pSortedObjs)[i];
280cdf0e10cSrcweir             pAnchoredObj->SetPageFrm( 0L );
281cdf0e10cSrcweir 		}
282cdf0e10cSrcweir 		delete pSortedObjs;
283cdf0e10cSrcweir 		pSortedObjs = 0;		//Auf 0 setzen, sonst rauchts beim Abmdelden von Flys!
284cdf0e10cSrcweir 	}
285cdf0e10cSrcweir 
286cdf0e10cSrcweir 	//Damit der Zugriff auf zerstoerte Seiten verhindert werden kann.
287cdf0e10cSrcweir 	if ( !IsEmptyPage() ) //#59184# sollte fuer Leerseiten unnoetig sein.
288cdf0e10cSrcweir 	{
289cdf0e10cSrcweir 		SwDoc *pDoc = GetFmt()->GetDoc();
290cdf0e10cSrcweir 		if( pDoc && !pDoc->IsInDtor() )
291cdf0e10cSrcweir 		{
292cdf0e10cSrcweir 			ViewShell *pSh = getRootFrm()->GetCurrShell();
293cdf0e10cSrcweir 			if ( pSh )
294cdf0e10cSrcweir 			{
295cdf0e10cSrcweir 				SwViewImp *pImp = pSh->Imp();
296cdf0e10cSrcweir 				pImp->SetFirstVisPageInvalid();
297cdf0e10cSrcweir 				if ( pImp->IsAction() )
298cdf0e10cSrcweir 					pImp->GetLayAction().SetAgain();
299cdf0e10cSrcweir                 // OD 12.02.2003 #i9719#, #105645# - retouche area of page
300cdf0e10cSrcweir                 // including border and shadow area.
301cdf0e10cSrcweir                 const bool bRightSidebar = (SidebarPosition() == sw::sidebarwindows::SIDEBAR_RIGHT);
302cdf0e10cSrcweir                 SwRect aRetoucheRect;
303cdf0e10cSrcweir                 SwPageFrm::GetBorderAndShadowBoundRect( Frm(), pSh, aRetoucheRect, bRightSidebar );
304cdf0e10cSrcweir                 pSh->AddPaintRect( aRetoucheRect );
305cdf0e10cSrcweir             }
306cdf0e10cSrcweir 		}
307cdf0e10cSrcweir 	}
308cdf0e10cSrcweir }
309cdf0e10cSrcweir 
310cdf0e10cSrcweir 
CheckGrid(sal_Bool bInvalidate)311cdf0e10cSrcweir void SwPageFrm::CheckGrid( sal_Bool bInvalidate )
312cdf0e10cSrcweir {
313cdf0e10cSrcweir     sal_Bool bOld = bHasGrid;
314cdf0e10cSrcweir     bHasGrid = sal_True;
315cdf0e10cSrcweir     GETGRID( this )
316cdf0e10cSrcweir     bHasGrid = 0 != pGrid;
317cdf0e10cSrcweir     if( bInvalidate || bOld != bHasGrid )
318cdf0e10cSrcweir     {
319cdf0e10cSrcweir         SwLayoutFrm* pBody = FindBodyCont();
320cdf0e10cSrcweir         if( pBody )
321cdf0e10cSrcweir         {
322cdf0e10cSrcweir             pBody->InvalidatePrt();
323cdf0e10cSrcweir             SwCntntFrm* pFrm = pBody->ContainsCntnt();
324cdf0e10cSrcweir             while( pBody->IsAnLower( pFrm ) )
325cdf0e10cSrcweir             {
326cdf0e10cSrcweir                 ((SwTxtFrm*)pFrm)->Prepare( PREP_CLEAR );
327cdf0e10cSrcweir                 pFrm = pFrm->GetNextCntntFrm();
328cdf0e10cSrcweir             }
329cdf0e10cSrcweir         }
330cdf0e10cSrcweir         SetCompletePaint();
331cdf0e10cSrcweir     }
332cdf0e10cSrcweir }
333cdf0e10cSrcweir 
334cdf0e10cSrcweir 
CheckDirection(sal_Bool bVert)335cdf0e10cSrcweir void SwPageFrm::CheckDirection( sal_Bool bVert )
336cdf0e10cSrcweir {
337cdf0e10cSrcweir     sal_uInt16 nDir =
338cdf0e10cSrcweir             ((SvxFrameDirectionItem&)GetFmt()->GetFmtAttr( RES_FRAMEDIR )).GetValue();
339cdf0e10cSrcweir     if( bVert )
340cdf0e10cSrcweir     {
341cdf0e10cSrcweir         if( FRMDIR_HORI_LEFT_TOP == nDir || FRMDIR_HORI_RIGHT_TOP == nDir )
342cdf0e10cSrcweir         {
343cdf0e10cSrcweir             //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
344cdf0e10cSrcweir             bVertLR = 0;
345cdf0e10cSrcweir             bVertical = 0;
346cdf0e10cSrcweir         }
347cdf0e10cSrcweir         else
348cdf0e10cSrcweir         {
349cdf0e10cSrcweir             const ViewShell *pSh = getRootFrm()->GetCurrShell();
350cdf0e10cSrcweir             if( pSh && pSh->GetViewOptions()->getBrowseMode() )
351cdf0e10cSrcweir             {
352cdf0e10cSrcweir                 //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
353cdf0e10cSrcweir                 bVertLR = 0;
354cdf0e10cSrcweir                 bVertical = 0;
355cdf0e10cSrcweir 		    }
356cdf0e10cSrcweir             else
357cdf0e10cSrcweir             {
358cdf0e10cSrcweir 			    bVertical = 1;
359cdf0e10cSrcweir                 //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
360cdf0e10cSrcweir 			    if(FRMDIR_VERT_TOP_RIGHT == nDir)
361cdf0e10cSrcweir 				    bVertLR = 0;
362cdf0e10cSrcweir      	       	else if(FRMDIR_VERT_TOP_LEFT==nDir)
363cdf0e10cSrcweir 	           		bVertLR = 1;
364cdf0e10cSrcweir 		    }
365cdf0e10cSrcweir         }
366cdf0e10cSrcweir 
367cdf0e10cSrcweir         bReverse = 0;
368cdf0e10cSrcweir         bInvalidVert = 0;
369cdf0e10cSrcweir     }
370cdf0e10cSrcweir     else
371cdf0e10cSrcweir     {
372cdf0e10cSrcweir         if( FRMDIR_HORI_RIGHT_TOP == nDir )
373cdf0e10cSrcweir             bRightToLeft = 1;
374cdf0e10cSrcweir         else
375cdf0e10cSrcweir             bRightToLeft = 0;
376cdf0e10cSrcweir         bInvalidR2L = 0;
377cdf0e10cSrcweir     }
378cdf0e10cSrcweir }
379cdf0e10cSrcweir 
380cdf0e10cSrcweir /*************************************************************************
381cdf0e10cSrcweir |*
382cdf0e10cSrcweir |*	SwPageFrm::PreparePage()
383cdf0e10cSrcweir |*
384cdf0e10cSrcweir |*	Beschreibung		Erzeugt die Spezifischen Flys zur Seite und formatiert
385cdf0e10cSrcweir |* 		generischen Cntnt
386cdf0e10cSrcweir |*	Ersterstellung		MA 20. Oct. 92
387cdf0e10cSrcweir |*	Letzte Aenderung	MA 09. Nov. 95
388cdf0e10cSrcweir |*
389cdf0e10cSrcweir |*************************************************************************/
lcl_FormatLay(SwLayoutFrm * pLay)390cdf0e10cSrcweir void MA_FASTCALL lcl_FormatLay( SwLayoutFrm *pLay )
391cdf0e10cSrcweir {
392cdf0e10cSrcweir 	//Alle LayoutFrms - nicht aber Tables, Flys o.ae. - formatieren.
393cdf0e10cSrcweir 
394cdf0e10cSrcweir 	SwFrm *pTmp = pLay->Lower();
395cdf0e10cSrcweir 	//Erst die untergeordneten
396cdf0e10cSrcweir 	while ( pTmp )
397cdf0e10cSrcweir 	{
398cdf0e10cSrcweir 		if ( pTmp->GetType() & 0x00FF )
399cdf0e10cSrcweir 			::lcl_FormatLay( (SwLayoutFrm*)pTmp );
400cdf0e10cSrcweir 		pTmp = pTmp->GetNext();
401cdf0e10cSrcweir 	}
402cdf0e10cSrcweir 	pLay->Calc();
403cdf0e10cSrcweir }
404cdf0e10cSrcweir 
lcl_MakeObjs(const SwSpzFrmFmts & rTbl,SwPageFrm * pPage)405cdf0e10cSrcweir void MA_FASTCALL lcl_MakeObjs( const SwSpzFrmFmts &rTbl, SwPageFrm *pPage )
406cdf0e10cSrcweir {
407cdf0e10cSrcweir 	//Anlegen bzw. registrieren von Flys und Drawobjekten.
408cdf0e10cSrcweir 	//Die Formate stehen in der SpzTbl (vom Dokument).
409cdf0e10cSrcweir 	//Flys werden angelegt, DrawObjekte werden bei der Seite angemeldet.
410cdf0e10cSrcweir 
411cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < rTbl.Count(); ++i )
412cdf0e10cSrcweir 	{
413cdf0e10cSrcweir 		SdrObject *pSdrObj;
414cdf0e10cSrcweir 		SwFrmFmt *pFmt = rTbl[i];
415cdf0e10cSrcweir 		const SwFmtAnchor &rAnch = pFmt->GetAnchor();
416cdf0e10cSrcweir 		if ( rAnch.GetPageNum() == pPage->GetPhyPageNum() )
417cdf0e10cSrcweir 		{
418cdf0e10cSrcweir 			if( rAnch.GetCntntAnchor() )
419cdf0e10cSrcweir 			{
420cdf0e10cSrcweir                 if (FLY_AT_PAGE == rAnch.GetAnchorId())
421cdf0e10cSrcweir                 {
422cdf0e10cSrcweir 					SwFmtAnchor aAnch( rAnch );
423cdf0e10cSrcweir 					aAnch.SetAnchor( 0 );
424cdf0e10cSrcweir                     pFmt->SetFmtAttr( aAnch );
425cdf0e10cSrcweir 				}
426cdf0e10cSrcweir 				else
427cdf0e10cSrcweir 					continue;
428cdf0e10cSrcweir 			}
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 			//Wird ein Rahmen oder ein SdrObject beschrieben?
431cdf0e10cSrcweir 			sal_Bool bSdrObj = RES_DRAWFRMFMT == pFmt->Which();
432cdf0e10cSrcweir 			pSdrObj = 0;
433cdf0e10cSrcweir 			if ( bSdrObj  && 0 == (pSdrObj = pFmt->FindSdrObject()) )
434cdf0e10cSrcweir 			{
435cdf0e10cSrcweir 				ASSERT( sal_False, "DrawObject not found." );
436cdf0e10cSrcweir 				pFmt->GetDoc()->DelFrmFmt( pFmt );
437cdf0e10cSrcweir 				--i;
438cdf0e10cSrcweir 				continue;
439cdf0e10cSrcweir 			}
440cdf0e10cSrcweir 			//Das Objekt kann noch an einer anderen Seite verankert sein.
441cdf0e10cSrcweir 			//Z.B. beim Einfuegen einer neuen Seite aufgrund eines
442cdf0e10cSrcweir 			//Pagedescriptor-Wechsels. Das Objekt muss dann umgehaengt
443cdf0e10cSrcweir 			//werden.
444cdf0e10cSrcweir 			//Fuer bestimmte Faelle ist das Objekt bereits an der richtigen
445cdf0e10cSrcweir 			//Seite verankert. Das wird hier automatisch erledigt und braucht
446cdf0e10cSrcweir 			//- wenngleich performater machbar - nicht extra codiert werden.
447cdf0e10cSrcweir 			SwPageFrm *pPg = pPage->IsEmptyPage() ? (SwPageFrm*)pPage->GetNext() : pPage;
448cdf0e10cSrcweir 			if ( bSdrObj )
449cdf0e10cSrcweir 			{
450cdf0e10cSrcweir                 // OD 23.06.2003 #108784# - consider 'virtual' drawing objects
451cdf0e10cSrcweir                 SwDrawContact *pContact =
452cdf0e10cSrcweir                             static_cast<SwDrawContact*>(::GetUserCall(pSdrObj));
453cdf0e10cSrcweir                 if ( pSdrObj->ISA(SwDrawVirtObj) )
454cdf0e10cSrcweir                 {
455cdf0e10cSrcweir                     SwDrawVirtObj* pDrawVirtObj = static_cast<SwDrawVirtObj*>(pSdrObj);
456cdf0e10cSrcweir                     if ( pContact )
457cdf0e10cSrcweir                     {
458cdf0e10cSrcweir                         pDrawVirtObj->RemoveFromWriterLayout();
459cdf0e10cSrcweir                         pDrawVirtObj->RemoveFromDrawingPage();
460cdf0e10cSrcweir                         pPg->AppendDrawObj( *(pContact->GetAnchoredObj( pDrawVirtObj )) );
461cdf0e10cSrcweir                     }
462cdf0e10cSrcweir                 }
463cdf0e10cSrcweir                 else
464cdf0e10cSrcweir                 {
465cdf0e10cSrcweir                     if ( pContact->GetAnchorFrm() )
466cdf0e10cSrcweir                         pContact->DisconnectFromLayout( false );
467cdf0e10cSrcweir                     pPg->AppendDrawObj( *(pContact->GetAnchoredObj( pSdrObj )) );
468cdf0e10cSrcweir                 }
469cdf0e10cSrcweir 			}
470cdf0e10cSrcweir 			else
471cdf0e10cSrcweir 			{
472cdf0e10cSrcweir 				SwIterator<SwFlyFrm,SwFmt> aIter( *pFmt );
473cdf0e10cSrcweir 				SwFlyFrm *pFly = aIter.First();
474cdf0e10cSrcweir 				if ( pFly)
475cdf0e10cSrcweir 				{
476cdf0e10cSrcweir                     if( pFly->GetAnchorFrm() )
477cdf0e10cSrcweir                         pFly->AnchorFrm()->RemoveFly( pFly );
478cdf0e10cSrcweir 				}
479cdf0e10cSrcweir 				else
480cdf0e10cSrcweir 					pFly = new SwFlyLayFrm( (SwFlyFrmFmt*)pFmt, pPg, pPg );
481cdf0e10cSrcweir                 pPg->AppendFly( pFly );
482cdf0e10cSrcweir 				::RegistFlys( pPg, pFly );
483cdf0e10cSrcweir 			}
484cdf0e10cSrcweir 		}
485cdf0e10cSrcweir 	}
486cdf0e10cSrcweir }
487cdf0e10cSrcweir 
PreparePage(sal_Bool bFtn)488cdf0e10cSrcweir void SwPageFrm::PreparePage( sal_Bool bFtn )
489cdf0e10cSrcweir {
490cdf0e10cSrcweir 	SetFtnPage( bFtn );
491cdf0e10cSrcweir 
492cdf0e10cSrcweir     // --> OD 2008-01-30 #i82258#
493cdf0e10cSrcweir     // Due to made change on OOo 2.0 code line, method <::lcl_FormatLay(..)> has
494cdf0e10cSrcweir     // the side effect, that the content of page header and footer are formatted.
495cdf0e10cSrcweir     // For this formatting it is needed that the anchored objects are registered
496cdf0e10cSrcweir     // at the <SwPageFrm> instance.
497cdf0e10cSrcweir     // Thus, first calling <::RegistFlys(..)>, then call <::lcl_FormatLay(..)>
498cdf0e10cSrcweir     ::RegistFlys( this, this );
499cdf0e10cSrcweir 
500cdf0e10cSrcweir         if ( Lower() )
501cdf0e10cSrcweir     {
502cdf0e10cSrcweir                 ::lcl_FormatLay( this );
503cdf0e10cSrcweir     }
504cdf0e10cSrcweir     // <--
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 	//Flys und DrawObjekte die noch am Dokument bereitstehen.
507cdf0e10cSrcweir 	//Fussnotenseiten tragen keine Seitengebundenen Flys!
508cdf0e10cSrcweir 	//Es kann Flys und Objekte geben, die auf Leerseiten (Seitennummernmaessig)
509cdf0e10cSrcweir 	//stehen wollen, diese werden jedoch von den Leerseiten ignoriert;
510cdf0e10cSrcweir 	//sie werden von den Folgeseiten aufgenommen.
511cdf0e10cSrcweir 	if ( !bFtn && !IsEmptyPage() )
512cdf0e10cSrcweir 	{
513cdf0e10cSrcweir 		SwDoc *pDoc = GetFmt()->GetDoc();
514cdf0e10cSrcweir 
515cdf0e10cSrcweir 		if ( GetPrev() && ((SwPageFrm*)GetPrev())->IsEmptyPage() )
516cdf0e10cSrcweir 			lcl_MakeObjs( *pDoc->GetSpzFrmFmts(), (SwPageFrm*)GetPrev() );
517cdf0e10cSrcweir 		lcl_MakeObjs( *pDoc->GetSpzFrmFmts(), this );
518cdf0e10cSrcweir 
519cdf0e10cSrcweir 		//Kopf-/Fusszeilen) formatieren.
520cdf0e10cSrcweir 		SwLayoutFrm *pLow = (SwLayoutFrm*)Lower();
521cdf0e10cSrcweir 		while ( pLow )
522cdf0e10cSrcweir 		{
523cdf0e10cSrcweir 			if ( pLow->GetType() & (FRMTYPE_HEADER|FRMTYPE_FOOTER) )
524cdf0e10cSrcweir 			{
525cdf0e10cSrcweir 				SwCntntFrm *pCntnt = pLow->ContainsCntnt();
526cdf0e10cSrcweir 				while ( pCntnt && pLow->IsAnLower( pCntnt ) )
527cdf0e10cSrcweir 				{
528cdf0e10cSrcweir 					pCntnt->OptCalc();	//Nicht die Vorgaenger
529cdf0e10cSrcweir 					pCntnt = pCntnt->GetNextCntntFrm();
530cdf0e10cSrcweir 				}
531cdf0e10cSrcweir 			}
532cdf0e10cSrcweir 			pLow = (SwLayoutFrm*)pLow->GetNext();
533cdf0e10cSrcweir 		}
534cdf0e10cSrcweir 	}
535cdf0e10cSrcweir }
536cdf0e10cSrcweir 
537cdf0e10cSrcweir /*************************************************************************
538cdf0e10cSrcweir |*
539cdf0e10cSrcweir |*	SwPageFrm::Modify()
540cdf0e10cSrcweir |*
541cdf0e10cSrcweir |*	Ersterstellung		MA 20. Oct. 92
542cdf0e10cSrcweir |*	Letzte Aenderung	MA 03. Mar. 96
543cdf0e10cSrcweir |*
544cdf0e10cSrcweir |*************************************************************************/
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)545cdf0e10cSrcweir void SwPageFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
546cdf0e10cSrcweir {
547cdf0e10cSrcweir 	ViewShell *pSh = getRootFrm()->GetCurrShell();
548cdf0e10cSrcweir 	if ( pSh )
549cdf0e10cSrcweir 		pSh->SetFirstVisPageInvalid();
550cdf0e10cSrcweir 	sal_uInt8 nInvFlags = 0;
551cdf0e10cSrcweir 
552cdf0e10cSrcweir 	if( pNew && RES_ATTRSET_CHG == pNew->Which() )
553cdf0e10cSrcweir 	{
554cdf0e10cSrcweir 		SfxItemIter aNIter( *((SwAttrSetChg*)pNew)->GetChgSet() );
555cdf0e10cSrcweir 		SfxItemIter aOIter( *((SwAttrSetChg*)pOld)->GetChgSet() );
556cdf0e10cSrcweir 		SwAttrSetChg aOldSet( *(SwAttrSetChg*)pOld );
557cdf0e10cSrcweir 		SwAttrSetChg aNewSet( *(SwAttrSetChg*)pNew );
558cdf0e10cSrcweir 		while( sal_True )
559cdf0e10cSrcweir 		{
560cdf0e10cSrcweir 			_UpdateAttr( (SfxPoolItem*)aOIter.GetCurItem(),
561cdf0e10cSrcweir 						 (SfxPoolItem*)aNIter.GetCurItem(), nInvFlags,
562cdf0e10cSrcweir 						 &aOldSet, &aNewSet );
563cdf0e10cSrcweir 			if( aNIter.IsAtEnd() )
564cdf0e10cSrcweir 				break;
565cdf0e10cSrcweir 			aNIter.NextItem();
566cdf0e10cSrcweir 			aOIter.NextItem();
567cdf0e10cSrcweir 		}
568cdf0e10cSrcweir 		if ( aOldSet.Count() || aNewSet.Count() )
569cdf0e10cSrcweir 			SwLayoutFrm::Modify( &aOldSet, &aNewSet );
570cdf0e10cSrcweir 	}
571cdf0e10cSrcweir 	else
572cdf0e10cSrcweir 		_UpdateAttr( pOld, pNew, nInvFlags );
573cdf0e10cSrcweir 
574cdf0e10cSrcweir 	if ( nInvFlags != 0 )
575cdf0e10cSrcweir 	{
576cdf0e10cSrcweir 		InvalidatePage( this );
577cdf0e10cSrcweir 		if ( nInvFlags & 0x01 )
578cdf0e10cSrcweir 			_InvalidatePrt();
579cdf0e10cSrcweir 		if ( nInvFlags & 0x02 )
580cdf0e10cSrcweir 			SetCompletePaint();
581cdf0e10cSrcweir 		if ( nInvFlags & 0x04 && GetNext() )
582cdf0e10cSrcweir 			GetNext()->InvalidatePos();
583cdf0e10cSrcweir 		if ( nInvFlags & 0x08 )
584cdf0e10cSrcweir 			PrepareHeader();
585cdf0e10cSrcweir 		if ( nInvFlags & 0x10 )
586cdf0e10cSrcweir 			PrepareFooter();
587cdf0e10cSrcweir         if ( nInvFlags & 0x20 )
588cdf0e10cSrcweir             CheckGrid( nInvFlags & 0x40 );
589cdf0e10cSrcweir 	}
590cdf0e10cSrcweir }
591cdf0e10cSrcweir 
_UpdateAttr(const SfxPoolItem * pOld,const SfxPoolItem * pNew,sal_uInt8 & rInvFlags,SwAttrSetChg * pOldSet,SwAttrSetChg * pNewSet)592cdf0e10cSrcweir void SwPageFrm::_UpdateAttr( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
593cdf0e10cSrcweir 							 sal_uInt8 &rInvFlags,
594cdf0e10cSrcweir 							 SwAttrSetChg *pOldSet, SwAttrSetChg *pNewSet )
595cdf0e10cSrcweir {
596cdf0e10cSrcweir 	sal_Bool bClear = sal_True;
597cdf0e10cSrcweir 	const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
598cdf0e10cSrcweir 	switch( nWhich )
599cdf0e10cSrcweir 	{
600cdf0e10cSrcweir 		case RES_FMT_CHG:
601cdf0e10cSrcweir 		{
602cdf0e10cSrcweir 			//Wenn sich das FrmFmt aendert kann hier einiges passieren.
603cdf0e10cSrcweir 			//Abgesehen von den Grossenverhaeltnissen sind noch andere
604cdf0e10cSrcweir 			//Dinge betroffen.
605cdf0e10cSrcweir 			//1. Spaltigkeit.
606cdf0e10cSrcweir 			ASSERT( pOld && pNew, "FMT_CHG Missing Format." );
607cdf0e10cSrcweir 			const SwFmt* pOldFmt = ((SwFmtChg*)pOld)->pChangedFmt;
608cdf0e10cSrcweir 			const SwFmt* pNewFmt = ((SwFmtChg*)pNew)->pChangedFmt;
609cdf0e10cSrcweir 			ASSERT( pOldFmt && pNewFmt, "FMT_CHG Missing Format." );
610cdf0e10cSrcweir 
611cdf0e10cSrcweir 			const SwFmtCol &rOldCol = pOldFmt->GetCol();
612cdf0e10cSrcweir 			const SwFmtCol &rNewCol = pNewFmt->GetCol();
613cdf0e10cSrcweir 			if( rOldCol != rNewCol )
614cdf0e10cSrcweir 			{
615cdf0e10cSrcweir 				SwLayoutFrm *pB = FindBodyCont();
616cdf0e10cSrcweir 				ASSERT( pB, "Seite ohne Body." );
617cdf0e10cSrcweir 				pB->ChgColumns( rOldCol, rNewCol );
618cdf0e10cSrcweir                 rInvFlags |= 0x20;
619cdf0e10cSrcweir 			}
620cdf0e10cSrcweir 
621cdf0e10cSrcweir 			//2. Kopf- und Fusszeilen.
622cdf0e10cSrcweir 			const SwFmtHeader &rOldH = pOldFmt->GetHeader();
623cdf0e10cSrcweir 			const SwFmtHeader &rNewH = pNewFmt->GetHeader();
624cdf0e10cSrcweir 			if( rOldH != rNewH )
625cdf0e10cSrcweir 				rInvFlags |= 0x08;
626cdf0e10cSrcweir 
627cdf0e10cSrcweir 			const SwFmtFooter &rOldF = pOldFmt->GetFooter();
628cdf0e10cSrcweir 			const SwFmtFooter &rNewF = pNewFmt->GetFooter();
629cdf0e10cSrcweir 			if( rOldF != rNewF )
630cdf0e10cSrcweir 				rInvFlags |= 0x10;
631cdf0e10cSrcweir             CheckDirChange();
632cdf0e10cSrcweir 		}
633cdf0e10cSrcweir 			/* kein break hier */
634cdf0e10cSrcweir 		case RES_FRM_SIZE:
635cdf0e10cSrcweir 		{
636cdf0e10cSrcweir             const SwRect aOldPageFrmRect( Frm() );
637cdf0e10cSrcweir             ViewShell *pSh = getRootFrm()->GetCurrShell();
638cdf0e10cSrcweir             if( pSh && pSh->GetViewOptions()->getBrowseMode() )
639cdf0e10cSrcweir 			{
640cdf0e10cSrcweir                 bValidSize = sal_False;
641cdf0e10cSrcweir                 // OD 28.10.2002 #97265# - Don't call <SwPageFrm::MakeAll()>
642cdf0e10cSrcweir                 // Calculation of the page is not necessary, because its size is
643cdf0e10cSrcweir                 // is invalidated here and further invalidation is done in the
644cdf0e10cSrcweir                 // calling method <SwPageFrm::Modify(..)> and probably by calling
645cdf0e10cSrcweir                 // <SwLayoutFrm::Modify(..)> at the end.
646cdf0e10cSrcweir                 // It can also causes inconsistences, because the lowers are
647cdf0e10cSrcweir                 // adjusted, but not calculated, and a <SwPageFrm::MakeAll()> of
648cdf0e10cSrcweir                 // a next page is called. This is performed on the switch to the
649cdf0e10cSrcweir                 // online layout.
650cdf0e10cSrcweir                 //MakeAll();
651cdf0e10cSrcweir 			}
652cdf0e10cSrcweir 			else
653cdf0e10cSrcweir 			{
654cdf0e10cSrcweir 				const SwFmtFrmSize &rSz = nWhich == RES_FMT_CHG ?
655cdf0e10cSrcweir 						((SwFmtChg*)pNew)->pChangedFmt->GetFrmSize() :
656cdf0e10cSrcweir                         (const SwFmtFrmSize&)*pNew;
657cdf0e10cSrcweir 
658cdf0e10cSrcweir 				Frm().Height( Max( rSz.GetHeight(), long(MINLAY) ) );
659cdf0e10cSrcweir 				Frm().Width ( Max( rSz.GetWidth(),	long(MINLAY) ) );
660cdf0e10cSrcweir 
661cdf0e10cSrcweir                 // PAGES01
662cdf0e10cSrcweir                 if ( GetUpper() )
663cdf0e10cSrcweir                     static_cast<SwRootFrm*>(GetUpper())->CheckViewLayout( 0, 0 );
664cdf0e10cSrcweir             }
665cdf0e10cSrcweir 			//Window aufraeumen.
666cdf0e10cSrcweir             if( pSh && pSh->GetWin() && aOldPageFrmRect.HasArea() )
667cdf0e10cSrcweir             {
668cdf0e10cSrcweir                 // OD 12.02.2003 #i9719#, #105645# - consider border and shadow of
669cdf0e10cSrcweir                 // page frame for determine 'old' rectangle - it's used for invalidating.
670cdf0e10cSrcweir                 const bool bRightSidebar = (SidebarPosition() == sw::sidebarwindows::SIDEBAR_RIGHT);
671cdf0e10cSrcweir                 SwRect aOldRectWithBorderAndShadow;
672cdf0e10cSrcweir                 SwPageFrm::GetBorderAndShadowBoundRect( aOldPageFrmRect, pSh, aOldRectWithBorderAndShadow, bRightSidebar );
673cdf0e10cSrcweir                 pSh->InvalidateWindows( aOldRectWithBorderAndShadow );
674cdf0e10cSrcweir             }
675cdf0e10cSrcweir 			rInvFlags |= 0x03;
676cdf0e10cSrcweir             if ( aOldPageFrmRect.Height() != Frm().Height() )
677cdf0e10cSrcweir 				rInvFlags |= 0x04;
678cdf0e10cSrcweir 		}
679cdf0e10cSrcweir 		break;
680cdf0e10cSrcweir 
681cdf0e10cSrcweir 		case RES_COL:
682cdf0e10cSrcweir 		{
683cdf0e10cSrcweir 			SwLayoutFrm *pB = FindBodyCont();
684cdf0e10cSrcweir 			ASSERT( pB, "Seite ohne Body." );
685cdf0e10cSrcweir 			pB->ChgColumns( *(const SwFmtCol*)pOld, *(const SwFmtCol*)pNew );
686cdf0e10cSrcweir             rInvFlags |= 0x22;
687cdf0e10cSrcweir 		}
688cdf0e10cSrcweir 		break;
689cdf0e10cSrcweir 
690cdf0e10cSrcweir 		case RES_HEADER:
691cdf0e10cSrcweir 			rInvFlags |= 0x08;
692cdf0e10cSrcweir 			break;
693cdf0e10cSrcweir 
694cdf0e10cSrcweir 		case RES_FOOTER:
695cdf0e10cSrcweir 			rInvFlags |= 0x10;
696cdf0e10cSrcweir 			break;
697cdf0e10cSrcweir         case RES_TEXTGRID:
698cdf0e10cSrcweir             rInvFlags |= 0x60;
699cdf0e10cSrcweir             break;
700cdf0e10cSrcweir 
701cdf0e10cSrcweir 		case RES_PAGEDESC_FTNINFO:
702cdf0e10cSrcweir 			//Die derzeit einzig sichere Methode:
703cdf0e10cSrcweir 			((SwRootFrm*)GetUpper())->SetSuperfluous();
704cdf0e10cSrcweir 			SetMaxFtnHeight( pDesc->GetFtnInfo().GetHeight() );
705cdf0e10cSrcweir 			if ( !GetMaxFtnHeight() )
706cdf0e10cSrcweir 				SetMaxFtnHeight( LONG_MAX );
707cdf0e10cSrcweir 			SetColMaxFtnHeight();
708cdf0e10cSrcweir 			//Hier wird die Seite ggf. zerstoert!
709cdf0e10cSrcweir 			((SwRootFrm*)GetUpper())->RemoveFtns( 0, sal_False, sal_True );
710cdf0e10cSrcweir 			break;
711cdf0e10cSrcweir         case RES_FRAMEDIR :
712cdf0e10cSrcweir             CheckDirChange();
713cdf0e10cSrcweir             break;
714cdf0e10cSrcweir 
715cdf0e10cSrcweir 		default:
716cdf0e10cSrcweir 			bClear = sal_False;
717cdf0e10cSrcweir 	}
718cdf0e10cSrcweir 	if ( bClear )
719cdf0e10cSrcweir 	{
720cdf0e10cSrcweir 		if ( pOldSet || pNewSet )
721cdf0e10cSrcweir 		{
722cdf0e10cSrcweir 			if ( pOldSet )
723cdf0e10cSrcweir 				pOldSet->ClearItem( nWhich );
724cdf0e10cSrcweir 			if ( pNewSet )
725cdf0e10cSrcweir 				pNewSet->ClearItem( nWhich );
726cdf0e10cSrcweir 		}
727cdf0e10cSrcweir 		else
728cdf0e10cSrcweir 			SwLayoutFrm::Modify( pOld, pNew );
729cdf0e10cSrcweir 	}
730cdf0e10cSrcweir }
731cdf0e10cSrcweir 
732cdf0e10cSrcweir /*************************************************************************
733cdf0e10cSrcweir |*
734cdf0e10cSrcweir |*				  SwPageFrm::GetInfo()
735cdf0e10cSrcweir |*
736cdf0e10cSrcweir |*	  Beschreibung		erfragt Informationen
737cdf0e10cSrcweir |*	  Ersterstellung	JP 31.03.94
738cdf0e10cSrcweir |*	  Letzte Aenderung	JP 31.03.94
739cdf0e10cSrcweir |*
740cdf0e10cSrcweir *************************************************************************/
741cdf0e10cSrcweir 	// erfrage vom Modify Informationen
GetInfo(SfxPoolItem & rInfo) const742cdf0e10cSrcweir sal_Bool SwPageFrm::GetInfo( SfxPoolItem & rInfo ) const
743cdf0e10cSrcweir {
744cdf0e10cSrcweir 	if( RES_AUTOFMT_DOCNODE == rInfo.Which() )
745cdf0e10cSrcweir 	{
746cdf0e10cSrcweir 		// es gibt einen PageFrm also wird er benutzt
747cdf0e10cSrcweir 		return sal_False;
748cdf0e10cSrcweir 	}
749cdf0e10cSrcweir 	return sal_True;		// weiter suchen
750cdf0e10cSrcweir }
751cdf0e10cSrcweir 
752cdf0e10cSrcweir /*************************************************************************
753cdf0e10cSrcweir |*
754cdf0e10cSrcweir |*	SwPageFrm::SetPageDesc()
755cdf0e10cSrcweir |*
756cdf0e10cSrcweir |*	Ersterstellung		MA 02. Nov. 94
757cdf0e10cSrcweir |*	Letzte Aenderung	MA 02. Nov. 94
758cdf0e10cSrcweir |*
759cdf0e10cSrcweir |*************************************************************************/
SetPageDesc(SwPageDesc * pNew,SwFrmFmt * pFmt)760cdf0e10cSrcweir void  SwPageFrm::SetPageDesc( SwPageDesc *pNew, SwFrmFmt *pFmt )
761cdf0e10cSrcweir {
762cdf0e10cSrcweir 	pDesc = pNew;
763cdf0e10cSrcweir 	if ( pFmt )
764cdf0e10cSrcweir 		SetFrmFmt( pFmt );
765cdf0e10cSrcweir }
766cdf0e10cSrcweir 
767cdf0e10cSrcweir /*************************************************************************
768cdf0e10cSrcweir |*
769cdf0e10cSrcweir |*	SwPageFrm::FindPageDesc()
770cdf0e10cSrcweir |*
771cdf0e10cSrcweir |*	Beschreibung		Der richtige PageDesc wird bestimmt:
772cdf0e10cSrcweir |*		0.	Vom Dokument bei Fussnotenseiten und Endnotenseiten
773cdf0e10cSrcweir |* 		1.	vom ersten BodyCntnt unterhalb der Seite.
774cdf0e10cSrcweir |* 		2.	vom PageDesc der vorstehenden Seite.
775cdf0e10cSrcweir |* 		3.	bei Leerseiten vom PageDesc der vorigen Seite.
776cdf0e10cSrcweir |* 		3.1 vom PageDesc der folgenden Seite wenn es keinen Vorgaenger gibt.
777cdf0e10cSrcweir |* 		4.	es ist der Default-PageDesc sonst.
778cdf0e10cSrcweir |*		5.  Im BrowseMode ist der Pagedesc immer der vom ersten Absatz im
779cdf0e10cSrcweir |* 			Dokument oder Standard (der 0-te) wenn der erste Absatz keinen
780cdf0e10cSrcweir |* 			wuenscht.
781cdf0e10cSrcweir |*	   (6.  Im HTML-Mode ist der Pagedesc immer die HTML-Seitenvorlage.)
782cdf0e10cSrcweir |*	Ersterstellung		MA 15. Feb. 93
783cdf0e10cSrcweir |*	Letzte Aenderung	MA 17. Jun. 99
784cdf0e10cSrcweir |*
785cdf0e10cSrcweir |*************************************************************************/
FindPageDesc()786cdf0e10cSrcweir SwPageDesc *SwPageFrm::FindPageDesc()
787cdf0e10cSrcweir {
788cdf0e10cSrcweir 	//0.
789cdf0e10cSrcweir 	if ( IsFtnPage() )
790cdf0e10cSrcweir 	{
791cdf0e10cSrcweir 		SwDoc *pDoc = GetFmt()->GetDoc();
792cdf0e10cSrcweir 		if ( IsEndNotePage() )
793cdf0e10cSrcweir 			return pDoc->GetEndNoteInfo().GetPageDesc( *pDoc );
794cdf0e10cSrcweir 		else
795cdf0e10cSrcweir 			return pDoc->GetFtnInfo().GetPageDesc( *pDoc );
796cdf0e10cSrcweir 	}
797cdf0e10cSrcweir 
798cdf0e10cSrcweir 	//6.
799cdf0e10cSrcweir 	//if ( GetFmt()->GetDoc()->IsHTMLMode() )
800cdf0e10cSrcweir 	//	return GetFmt()->GetDoc()->GetPageDescFromPool( RES_POOLPAGE_HTML );
801cdf0e10cSrcweir 
802cdf0e10cSrcweir 	SwPageDesc *pRet = 0;
803cdf0e10cSrcweir 
804cdf0e10cSrcweir 	//5.
805cdf0e10cSrcweir     const ViewShell *pSh = getRootFrm()->GetCurrShell();
806cdf0e10cSrcweir     if( pSh && pSh->GetViewOptions()->getBrowseMode() )
807cdf0e10cSrcweir 	{
808cdf0e10cSrcweir 		SwCntntFrm *pFrm = GetUpper()->ContainsCntnt();
809cdf0e10cSrcweir 		while ( !pFrm->IsInDocBody() )
810cdf0e10cSrcweir 			pFrm = pFrm->GetNextCntntFrm();
811cdf0e10cSrcweir 		SwFrm *pFlow = pFrm;
812cdf0e10cSrcweir 		if ( pFlow->IsInTab() )
813cdf0e10cSrcweir 			pFlow = pFlow->FindTabFrm();
814cdf0e10cSrcweir 		pRet = (SwPageDesc*)pFlow->GetAttrSet()->GetPageDesc().GetPageDesc();
815cdf0e10cSrcweir 		if ( !pRet )
816cdf0e10cSrcweir 			pRet = &GetFmt()->GetDoc()->_GetPageDesc( 0 );
817cdf0e10cSrcweir 		return pRet;
818cdf0e10cSrcweir 	}
819cdf0e10cSrcweir 
820cdf0e10cSrcweir 	SwFrm *pFlow = FindFirstBodyCntnt();
821cdf0e10cSrcweir 	if ( pFlow && pFlow->IsInTab() )
822cdf0e10cSrcweir 		pFlow = pFlow->FindTabFrm();
823cdf0e10cSrcweir 
824cdf0e10cSrcweir 	//1.
825cdf0e10cSrcweir 	if ( pFlow )
826cdf0e10cSrcweir 	{
827cdf0e10cSrcweir 		SwFlowFrm *pTmp = SwFlowFrm::CastFlowFrm( pFlow );
828cdf0e10cSrcweir 		if ( !pTmp->IsFollow() )
829cdf0e10cSrcweir 			pRet = (SwPageDesc*)pFlow->GetAttrSet()->GetPageDesc().GetPageDesc();
830cdf0e10cSrcweir 	}
831cdf0e10cSrcweir 
832cdf0e10cSrcweir 	//3. und 3.1
833cdf0e10cSrcweir 	if ( !pRet && IsEmptyPage() )
834cdf0e10cSrcweir             // FME 2008-03-03 #i81544# lijian/fme: an empty page should have
835cdf0e10cSrcweir             // the same page description as its prev, just like after construction
836cdf0e10cSrcweir             // of the empty page.
837cdf0e10cSrcweir         pRet = GetPrev() ? ((SwPageFrm*)GetPrev())->GetPageDesc() :
838cdf0e10cSrcweir 			   GetNext() ? ((SwPageFrm*)GetNext())->GetPageDesc() : 0;
839cdf0e10cSrcweir 
840cdf0e10cSrcweir 	//2.
841cdf0e10cSrcweir 	if ( !pRet )
842cdf0e10cSrcweir 		pRet = GetPrev() ?
843cdf0e10cSrcweir 					((SwPageFrm*)GetPrev())->GetPageDesc()->GetFollow() : 0;
844cdf0e10cSrcweir 
845cdf0e10cSrcweir 	//4.
846cdf0e10cSrcweir 	if ( !pRet )
847cdf0e10cSrcweir 		pRet = (SwPageDesc*)&(const_cast<const SwDoc *>(GetFmt()->GetDoc())
848cdf0e10cSrcweir                               ->GetPageDesc( 0 ));
849cdf0e10cSrcweir 
850cdf0e10cSrcweir 
851cdf0e10cSrcweir 	ASSERT( pRet, "Kein Descriptor gefunden." );
852cdf0e10cSrcweir 	return pRet;
853cdf0e10cSrcweir }
854cdf0e10cSrcweir 
855cdf0e10cSrcweir //Wenn der RootFrm seine Groesse aendert muss benachrichtigt werden.
AdjustSizeChgNotify(SwRootFrm * pRoot)856cdf0e10cSrcweir void AdjustSizeChgNotify( SwRootFrm *pRoot )
857cdf0e10cSrcweir {
858cdf0e10cSrcweir 	const sal_Bool bOld = pRoot->IsSuperfluous();
859cdf0e10cSrcweir 	pRoot->bCheckSuperfluous = sal_False;
860cdf0e10cSrcweir 	ViewShell *pSh = pRoot->GetCurrShell();
861cdf0e10cSrcweir 	if ( pSh )
862cdf0e10cSrcweir 	{
863cdf0e10cSrcweir 		do
864cdf0e10cSrcweir         {
865cdf0e10cSrcweir             if( pRoot == pSh->GetLayout() )
866cdf0e10cSrcweir             {
867cdf0e10cSrcweir                 pSh->SizeChgNotify();
868cdf0e10cSrcweir                 pSh->Imp()->NotifySizeChg( pRoot->Frm().SSize() );
869cdf0e10cSrcweir             }
870cdf0e10cSrcweir 			pSh = (ViewShell*)pSh->GetNext();
871cdf0e10cSrcweir 		} while ( pSh != pRoot->GetCurrShell() );
872cdf0e10cSrcweir 	}
873cdf0e10cSrcweir 	pRoot->bCheckSuperfluous = bOld;
874cdf0e10cSrcweir }
875cdf0e10cSrcweir 
876cdf0e10cSrcweir 
SetLastPage(SwPageFrm * pPage)877cdf0e10cSrcweir inline void SetLastPage( SwPageFrm *pPage )
878cdf0e10cSrcweir {
879cdf0e10cSrcweir 	((SwRootFrm*)pPage->GetUpper())->pLastPage = pPage;
880cdf0e10cSrcweir }
881cdf0e10cSrcweir 
882cdf0e10cSrcweir /*************************************************************************
883cdf0e10cSrcweir |*
884cdf0e10cSrcweir |*	SwPageFrm::Cut()
885cdf0e10cSrcweir |*
886cdf0e10cSrcweir |*	Ersterstellung		MA 23. Feb. 94
887cdf0e10cSrcweir |*	Letzte Aenderung	MA 22. Jun. 95
888cdf0e10cSrcweir |*
889cdf0e10cSrcweir |*************************************************************************/
Cut()890cdf0e10cSrcweir void SwPageFrm::Cut()
891cdf0e10cSrcweir {
892cdf0e10cSrcweir     // PAGES01
893cdf0e10cSrcweir     //AdjustRootSize( CHG_CUTPAGE, 0 );
894cdf0e10cSrcweir 
895cdf0e10cSrcweir 	ViewShell *pSh = getRootFrm()->GetCurrShell();
896cdf0e10cSrcweir 	if ( !IsEmptyPage() )
897cdf0e10cSrcweir 	{
898cdf0e10cSrcweir 		if ( GetNext() )
899cdf0e10cSrcweir 			GetNext()->InvalidatePos();
900cdf0e10cSrcweir 
901cdf0e10cSrcweir 		//Flys deren Anker auf anderen Seiten stehen umhaengen.
902cdf0e10cSrcweir 		//DrawObjecte spielen hier keine Rolle.
903cdf0e10cSrcweir 		if ( GetSortedObjs() )
904cdf0e10cSrcweir 		{
905cdf0e10cSrcweir 			for ( int i = 0; GetSortedObjs() &&
906cdf0e10cSrcweir 							 (sal_uInt16)i < GetSortedObjs()->Count(); ++i )
907cdf0e10cSrcweir 			{
908cdf0e10cSrcweir                 // --> OD 2004-06-29 #i28701#
909cdf0e10cSrcweir                 SwAnchoredObject* pAnchoredObj = (*GetSortedObjs())[i];
910cdf0e10cSrcweir 
911cdf0e10cSrcweir                 if ( pAnchoredObj->ISA(SwFlyAtCntFrm) )
912cdf0e10cSrcweir                 {
913cdf0e10cSrcweir                     SwFlyFrm* pFly = static_cast<SwFlyAtCntFrm*>(pAnchoredObj);
914cdf0e10cSrcweir                     SwPageFrm *pAnchPage = pFly->GetAnchorFrm() ?
915cdf0e10cSrcweir                                 pFly->AnchorFrm()->FindPageFrm() : 0;
916cdf0e10cSrcweir                     if ( pAnchPage && (pAnchPage != this) )
917cdf0e10cSrcweir                     {
918cdf0e10cSrcweir                         MoveFly( pFly, pAnchPage );
919cdf0e10cSrcweir                         --i;
920cdf0e10cSrcweir                         pFly->InvalidateSize();
921cdf0e10cSrcweir                         pFly->_InvalidatePos();
922cdf0e10cSrcweir                     }
923cdf0e10cSrcweir                 }
924cdf0e10cSrcweir                 // <--
925cdf0e10cSrcweir 			}
926cdf0e10cSrcweir 		}
927cdf0e10cSrcweir 		//Window aufraeumen
928cdf0e10cSrcweir 		if ( pSh && pSh->GetWin() )
929cdf0e10cSrcweir 			pSh->InvalidateWindows( Frm() );
930cdf0e10cSrcweir 	}
931cdf0e10cSrcweir 
932cdf0e10cSrcweir 	// die Seitennummer der Root runterzaehlen.
933cdf0e10cSrcweir 	((SwRootFrm*)GetUpper())->DecrPhyPageNums();
934cdf0e10cSrcweir 	SwPageFrm *pPg = (SwPageFrm*)GetNext();
935cdf0e10cSrcweir 	if ( pPg )
936cdf0e10cSrcweir 	{
937cdf0e10cSrcweir 		while ( pPg )
938cdf0e10cSrcweir 		{
939cdf0e10cSrcweir 			pPg->DecrPhyPageNum();	//inline --nPhyPageNum
940cdf0e10cSrcweir 			pPg = (SwPageFrm*)pPg->GetNext();
941cdf0e10cSrcweir 		}
942cdf0e10cSrcweir 	}
943cdf0e10cSrcweir 	else
944cdf0e10cSrcweir 		::SetLastPage( (SwPageFrm*)GetPrev() );
945cdf0e10cSrcweir 
946cdf0e10cSrcweir     SwFrm* pRootFrm = GetUpper();
947cdf0e10cSrcweir 
948cdf0e10cSrcweir 	// Alle Verbindungen kappen.
949cdf0e10cSrcweir 	Remove();
950cdf0e10cSrcweir 
951cdf0e10cSrcweir     // PAGES01
952cdf0e10cSrcweir     if ( pRootFrm )
953cdf0e10cSrcweir         static_cast<SwRootFrm*>(pRootFrm)->CheckViewLayout( 0, 0 );
954cdf0e10cSrcweir }
955cdf0e10cSrcweir 
956cdf0e10cSrcweir /*************************************************************************
957cdf0e10cSrcweir |*
958cdf0e10cSrcweir |*	SwPageFrm::Paste()
959cdf0e10cSrcweir |*
960cdf0e10cSrcweir |*	Ersterstellung		MA 23. Feb. 94
961cdf0e10cSrcweir |*	Letzte Aenderung	MA 07. Dec. 94
962cdf0e10cSrcweir |*
963cdf0e10cSrcweir |*************************************************************************/
Paste(SwFrm * pParent,SwFrm * pSibling)964cdf0e10cSrcweir void SwPageFrm::Paste( SwFrm* pParent, SwFrm* pSibling )
965cdf0e10cSrcweir {
966cdf0e10cSrcweir 	ASSERT( pParent->IsRootFrm(), "Parent ist keine Root." );
967cdf0e10cSrcweir 	ASSERT( pParent, "Kein Parent fuer Paste." );
968cdf0e10cSrcweir 	ASSERT( pParent != this, "Bin selbst der Parent." );
969cdf0e10cSrcweir 	ASSERT( pSibling != this, "Bin mein eigener Nachbar." );
970cdf0e10cSrcweir 	ASSERT( !GetPrev() && !GetNext() && !GetUpper(),
971cdf0e10cSrcweir 			"Bin noch irgendwo angemeldet." );
972cdf0e10cSrcweir 
973cdf0e10cSrcweir 	//In den Baum einhaengen.
974cdf0e10cSrcweir 	InsertBefore( (SwLayoutFrm*)pParent, pSibling );
975cdf0e10cSrcweir 
976cdf0e10cSrcweir 	// die Seitennummer am Root hochzaehlen.
977cdf0e10cSrcweir 	((SwRootFrm*)GetUpper())->IncrPhyPageNums();
978cdf0e10cSrcweir 	if( GetPrev() )
979cdf0e10cSrcweir 		SetPhyPageNum( ((SwPageFrm*)GetPrev())->GetPhyPageNum() + 1 );
980cdf0e10cSrcweir 	else
981cdf0e10cSrcweir 		SetPhyPageNum( 1 );
982cdf0e10cSrcweir 	SwPageFrm *pPg = (SwPageFrm*)GetNext();
983cdf0e10cSrcweir 	if ( pPg )
984cdf0e10cSrcweir 	{
985cdf0e10cSrcweir 		while ( pPg )
986cdf0e10cSrcweir 		{
987cdf0e10cSrcweir 			pPg->IncrPhyPageNum();	//inline ++nPhyPageNum
988cdf0e10cSrcweir 			pPg->_InvalidatePos();
989cdf0e10cSrcweir 			pPg->InvalidateLayout();
990cdf0e10cSrcweir 			pPg = (SwPageFrm*)pPg->GetNext();
991cdf0e10cSrcweir 		}
992cdf0e10cSrcweir 	}
993cdf0e10cSrcweir 	else
994cdf0e10cSrcweir 		::SetLastPage( this );
995cdf0e10cSrcweir 
996cdf0e10cSrcweir     if( Frm().Width() != pParent->Prt().Width() )
997cdf0e10cSrcweir 		_InvalidateSize();
998cdf0e10cSrcweir 
999cdf0e10cSrcweir     InvalidatePos();
1000cdf0e10cSrcweir 
1001cdf0e10cSrcweir 	ViewShell *pSh = getRootFrm()->GetCurrShell();
1002cdf0e10cSrcweir 	if ( pSh )
1003cdf0e10cSrcweir 		pSh->SetFirstVisPageInvalid();
1004cdf0e10cSrcweir     // PAGES01
1005cdf0e10cSrcweir     getRootFrm()->CheckViewLayout( 0, 0 );
1006cdf0e10cSrcweir }
1007cdf0e10cSrcweir 
1008cdf0e10cSrcweir /*************************************************************************
1009cdf0e10cSrcweir |*
1010cdf0e10cSrcweir |*	SwPageFrm::PrepareRegisterChg()
1011cdf0e10cSrcweir |*
1012cdf0e10cSrcweir |*	Ersterstellung		AMA 22. Jul. 96
1013cdf0e10cSrcweir |*	Letzte Aenderung	AMA 22. Jul. 96
1014cdf0e10cSrcweir |*
1015cdf0e10cSrcweir |*************************************************************************/
lcl_PrepFlyInCntRegister(SwCntntFrm * pFrm)1016cdf0e10cSrcweir void lcl_PrepFlyInCntRegister( SwCntntFrm *pFrm )
1017cdf0e10cSrcweir {
1018cdf0e10cSrcweir 	pFrm->Prepare( PREP_REGISTER );
1019cdf0e10cSrcweir 	if( pFrm->GetDrawObjs() )
1020cdf0e10cSrcweir 	{
1021cdf0e10cSrcweir 		for( sal_uInt16 i = 0; i < pFrm->GetDrawObjs()->Count(); ++i )
1022cdf0e10cSrcweir 		{
1023cdf0e10cSrcweir             // --> OD 2004-06-29 #i28701#
1024cdf0e10cSrcweir             SwAnchoredObject* pAnchoredObj = (*pFrm->GetDrawObjs())[i];
1025cdf0e10cSrcweir             if ( pAnchoredObj->ISA(SwFlyInCntFrm) )
1026cdf0e10cSrcweir             {
1027cdf0e10cSrcweir                 SwFlyFrm* pFly = static_cast<SwFlyInCntFrm*>(pAnchoredObj);
1028cdf0e10cSrcweir                 SwCntntFrm *pCnt = pFly->ContainsCntnt();
1029cdf0e10cSrcweir                 while ( pCnt )
1030cdf0e10cSrcweir                 {
1031cdf0e10cSrcweir                     lcl_PrepFlyInCntRegister( pCnt );
1032cdf0e10cSrcweir                     pCnt = pCnt->GetNextCntntFrm();
1033cdf0e10cSrcweir                 }
1034cdf0e10cSrcweir             }
1035cdf0e10cSrcweir             // <--
1036cdf0e10cSrcweir 		}
1037cdf0e10cSrcweir 	}
1038cdf0e10cSrcweir }
1039cdf0e10cSrcweir 
PrepareRegisterChg()1040cdf0e10cSrcweir void SwPageFrm::PrepareRegisterChg()
1041cdf0e10cSrcweir {
1042cdf0e10cSrcweir 	SwCntntFrm *pFrm = FindFirstBodyCntnt();
1043cdf0e10cSrcweir 	while( pFrm )
1044cdf0e10cSrcweir 	{
1045cdf0e10cSrcweir 		lcl_PrepFlyInCntRegister( pFrm );
1046cdf0e10cSrcweir 		pFrm = pFrm->GetNextCntntFrm();
1047cdf0e10cSrcweir 		if( !IsAnLower( pFrm ) )
1048cdf0e10cSrcweir 			break;
1049cdf0e10cSrcweir 	}
1050cdf0e10cSrcweir 	if( GetSortedObjs() )
1051cdf0e10cSrcweir 	{
1052cdf0e10cSrcweir 		for( sal_uInt16 i = 0; i < GetSortedObjs()->Count(); ++i )
1053cdf0e10cSrcweir 		{
1054cdf0e10cSrcweir             // --> OD 2004-06-29 #i28701#
1055cdf0e10cSrcweir             SwAnchoredObject* pAnchoredObj = (*GetSortedObjs())[i];
1056cdf0e10cSrcweir             if ( pAnchoredObj->ISA(SwFlyFrm) )
1057cdf0e10cSrcweir 			{
1058cdf0e10cSrcweir                 SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
1059cdf0e10cSrcweir 				pFrm = pFly->ContainsCntnt();
1060cdf0e10cSrcweir 				while ( pFrm )
1061cdf0e10cSrcweir 				{
1062cdf0e10cSrcweir 					::lcl_PrepFlyInCntRegister( pFrm );
1063cdf0e10cSrcweir 					pFrm = pFrm->GetNextCntntFrm();
1064cdf0e10cSrcweir 				}
1065cdf0e10cSrcweir 			}
1066cdf0e10cSrcweir 		}
1067cdf0e10cSrcweir 	}
1068cdf0e10cSrcweir }
1069cdf0e10cSrcweir 
1070cdf0e10cSrcweir /*************************************************************************
1071cdf0e10cSrcweir |*
1072cdf0e10cSrcweir |*	SwFrm::CheckPageDescs()
1073cdf0e10cSrcweir |*
1074cdf0e10cSrcweir |*	Beschreibung		Prueft alle Seiten ab der uebergebenen, daraufhin,
1075cdf0e10cSrcweir |* 		ob sie das richtige FrmFmt verwenden. Wenn 'falsche' Seiten
1076cdf0e10cSrcweir |*		aufgespuehrt werden, so wird versucht die Situation moeglichst
1077cdf0e10cSrcweir |* 		einfache zu bereinigen.
1078cdf0e10cSrcweir |*
1079cdf0e10cSrcweir |*	Ersterstellung		MA 10. Feb. 93
1080cdf0e10cSrcweir |*	Letzte Aenderung	MA 18. Apr. 96
1081cdf0e10cSrcweir |*
1082cdf0e10cSrcweir |*************************************************************************/
CheckPageDescs(SwPageFrm * pStart,sal_Bool bNotifyFields)1083cdf0e10cSrcweir void SwFrm::CheckPageDescs( SwPageFrm *pStart, sal_Bool bNotifyFields )
1084cdf0e10cSrcweir {
1085cdf0e10cSrcweir 	ASSERT( pStart, "Keine Startpage." );
1086cdf0e10cSrcweir 
1087cdf0e10cSrcweir 	ViewShell *pSh	 = pStart->getRootFrm()->GetCurrShell();
1088cdf0e10cSrcweir 	SwViewImp *pImp  = pSh ? pSh->Imp() : 0;
1089cdf0e10cSrcweir 
1090cdf0e10cSrcweir 	if ( pImp && pImp->IsAction() && !pImp->GetLayAction().IsCheckPages() )
1091cdf0e10cSrcweir 	{
1092cdf0e10cSrcweir 		pImp->GetLayAction().SetCheckPageNum( pStart->GetPhyPageNum() );
1093cdf0e10cSrcweir 		return;
1094cdf0e10cSrcweir 	}
1095cdf0e10cSrcweir 
1096cdf0e10cSrcweir 	//Fuer das Aktualisieren der Seitennummern-Felder gibt nDocPos
1097cdf0e10cSrcweir 	//die Seitenposition an, _ab_ der invalidiert werden soll.
1098cdf0e10cSrcweir 	SwTwips nDocPos  = LONG_MAX;
1099cdf0e10cSrcweir 
1100cdf0e10cSrcweir 	SwRootFrm *pRoot = (SwRootFrm*)pStart->GetUpper();
1101cdf0e10cSrcweir 	SwDoc* pDoc		 = pStart->GetFmt()->GetDoc();
1102cdf0e10cSrcweir 	const sal_Bool bFtns = 0 != pDoc->GetFtnIdxs().Count();
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir 	SwPageFrm *pPage = pStart;
1105cdf0e10cSrcweir 	if( pPage->GetPrev() && ((SwPageFrm*)pPage->GetPrev())->IsEmptyPage() )
1106cdf0e10cSrcweir 		pPage = (SwPageFrm*)pPage->GetPrev();
1107cdf0e10cSrcweir 	while ( pPage )
1108cdf0e10cSrcweir 	{
1109cdf0e10cSrcweir 		//gewuenschten PageDesc und FrmFmt festellen.
1110cdf0e10cSrcweir 		SwPageDesc *pDesc = pPage->FindPageDesc();
1111cdf0e10cSrcweir 		sal_Bool bCheckEmpty = pPage->IsEmptyPage();
1112cdf0e10cSrcweir 		sal_Bool bActOdd = pPage->OnRightPage();
1113cdf0e10cSrcweir 		sal_Bool bOdd = pPage->WannaRightPage();
1114cdf0e10cSrcweir 		SwFrmFmt *pFmtWish = bOdd ? pDesc->GetRightFmt()
1115cdf0e10cSrcweir 								  : pDesc->GetLeftFmt();
1116cdf0e10cSrcweir 
1117cdf0e10cSrcweir 		if ( bActOdd != bOdd ||
1118cdf0e10cSrcweir 			 pDesc != pPage->GetPageDesc() ||		//falscher Desc
1119cdf0e10cSrcweir              ( pFmtWish != pPage->GetFmt()  &&      //falsches Format und
1120cdf0e10cSrcweir                ( !pPage->IsEmptyPage() || pFmtWish ) //nicht Leerseite
1121cdf0e10cSrcweir              )
1122cdf0e10cSrcweir            )
1123cdf0e10cSrcweir 		{
1124cdf0e10cSrcweir 			//Wenn wir schon ein Seite veraendern muessen kann das eine
1125cdf0e10cSrcweir 			//Weile dauern, deshalb hier den WaitCrsr pruefen.
1126cdf0e10cSrcweir 			if( pImp )
1127cdf0e10cSrcweir 				pImp->CheckWaitCrsr();
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir 			//Ab hier muessen die Felder invalidiert werden!
1130cdf0e10cSrcweir 			if ( nDocPos == LONG_MAX )
1131cdf0e10cSrcweir 				nDocPos = pPage->GetPrev() ?
1132cdf0e10cSrcweir 							pPage->GetPrev()->Frm().Top() :	pPage->Frm().Top();
1133cdf0e10cSrcweir 
1134cdf0e10cSrcweir 			//Faelle:
1135cdf0e10cSrcweir 			//1. Wir haben eine EmptyPage und wollen eine "Normalseite".
1136cdf0e10cSrcweir 			//		->EmptyPage wegwerfen und weiter mit der naechsten.
1137cdf0e10cSrcweir 			//2. Wir haben eine EmptyPage und wollen eine EmptyPage mit
1138cdf0e10cSrcweir 			//	 anderem Descriptor.
1139cdf0e10cSrcweir 			//		->Descriptor austauschen.
1140cdf0e10cSrcweir 			//3. Wir haben eine "Normalseite" und wollen eine EmptyPage.
1141cdf0e10cSrcweir 			//		->Emptypage einfuegen, nicht aber wenn die Vorseite
1142cdf0e10cSrcweir 			//							   bereits eine EmptyPage ist -> 6.
1143cdf0e10cSrcweir 			//4. Wir haben eine "Normalseite" und wollen eine "Normalseite"
1144cdf0e10cSrcweir 			//	 mit anderem Descriptor
1145cdf0e10cSrcweir 			//		->Descriptor und Format austauschen
1146cdf0e10cSrcweir 			//5. Wir haben eine "Normalseite" und wollen eine "Normalseite"
1147cdf0e10cSrcweir 			//	 mit anderem Format
1148cdf0e10cSrcweir 			//		->Format austauschen.
1149cdf0e10cSrcweir 			//6. Wir haben kein Wunschformat erhalten, also nehmen wir das
1150cdf0e10cSrcweir 			//	 'andere' Format (rechts/links) des PageDesc.
1151cdf0e10cSrcweir 
1152cdf0e10cSrcweir 			if ( pPage->IsEmptyPage() && ( pFmtWish ||			//1.
1153cdf0e10cSrcweir 				 ( !bOdd && !pPage->GetPrev() ) ) )
1154cdf0e10cSrcweir 			{
1155cdf0e10cSrcweir 				SwPageFrm *pTmp = (SwPageFrm*)pPage->GetNext();
1156cdf0e10cSrcweir 				pPage->Cut();
1157cdf0e10cSrcweir 				delete pPage;
1158cdf0e10cSrcweir 				if ( pStart == pPage )
1159cdf0e10cSrcweir 					pStart = pTmp;
1160cdf0e10cSrcweir 				pPage = pTmp;
1161cdf0e10cSrcweir 				continue;
1162cdf0e10cSrcweir 			}
1163cdf0e10cSrcweir 			else if ( pPage->IsEmptyPage() && !pFmtWish &&	//2.
1164cdf0e10cSrcweir 					  pDesc != pPage->GetPageDesc() )
1165cdf0e10cSrcweir 			{
1166cdf0e10cSrcweir 				pPage->SetPageDesc( pDesc, 0 );
1167cdf0e10cSrcweir 			}
1168cdf0e10cSrcweir             else if ( !pPage->IsEmptyPage() &&      //3.
1169cdf0e10cSrcweir                       bActOdd != bOdd &&
1170cdf0e10cSrcweir                       ( ( !pPage->GetPrev() && !bOdd ) ||
1171cdf0e10cSrcweir 						( pPage->GetPrev() &&
1172cdf0e10cSrcweir                           !((SwPageFrm*)pPage->GetPrev())->IsEmptyPage() )
1173cdf0e10cSrcweir                       )
1174cdf0e10cSrcweir                     )
1175cdf0e10cSrcweir 			{
1176cdf0e10cSrcweir 				if ( pPage->GetPrev() )
1177cdf0e10cSrcweir 					pDesc = ((SwPageFrm*)pPage->GetPrev())->GetPageDesc();
1178cdf0e10cSrcweir 				SwPageFrm *pTmp = new SwPageFrm( pDoc->GetEmptyPageFmt(),pRoot,pDesc);
1179cdf0e10cSrcweir 				pTmp->Paste( pRoot, pPage );
1180cdf0e10cSrcweir 				pTmp->PreparePage( sal_False );
1181cdf0e10cSrcweir 				pPage = pTmp;
1182cdf0e10cSrcweir 			}
1183cdf0e10cSrcweir 			else if ( pPage->GetPageDesc() != pDesc )			//4.
1184cdf0e10cSrcweir 			{
1185cdf0e10cSrcweir 				SwPageDesc *pOld = pPage->GetPageDesc();
1186cdf0e10cSrcweir 				pPage->SetPageDesc( pDesc, pFmtWish );
1187cdf0e10cSrcweir 				if ( bFtns )
1188cdf0e10cSrcweir 				{
1189cdf0e10cSrcweir 					//Wenn sich bestimmte Werte der FtnInfo veraendert haben
1190cdf0e10cSrcweir 					//muss etwas passieren. Wir versuchen den Schaden zu
1191cdf0e10cSrcweir 					//begrenzen.
1192cdf0e10cSrcweir 					//Wenn die Seiten keinen FtnCont hat, ist zwar theoretisches
1193cdf0e10cSrcweir 					//ein Problem denkbar, aber das ignorieren wir mit aller Kraft.
1194cdf0e10cSrcweir 					//Bei Aenderungen hoffen wir mal, dass eine Invalidierung
1195cdf0e10cSrcweir 					//ausreicht, denn alles andere wuerde viel Kraft kosten.
1196cdf0e10cSrcweir 					SwFtnContFrm *pCont = pPage->FindFtnCont();
1197cdf0e10cSrcweir 					if ( pCont && !(pOld->GetFtnInfo() == pDesc->GetFtnInfo()) )
1198cdf0e10cSrcweir 						pCont->_InvalidateAll();
1199cdf0e10cSrcweir 				}
1200cdf0e10cSrcweir 			}
1201cdf0e10cSrcweir 			else if ( pFmtWish && pPage->GetFmt() != pFmtWish )			//5.
1202cdf0e10cSrcweir 			{
1203cdf0e10cSrcweir 				pPage->SetFrmFmt( pFmtWish );
1204cdf0e10cSrcweir 			}
1205cdf0e10cSrcweir 			else if ( !pFmtWish )										//6.
1206cdf0e10cSrcweir 			{
1207cdf0e10cSrcweir 				//Format mit verdrehter Logic besorgen.
1208cdf0e10cSrcweir 				pFmtWish = bOdd ? pDesc->GetLeftFmt() : pDesc->GetRightFmt();
1209cdf0e10cSrcweir 				if ( pPage->GetFmt() != pFmtWish )
1210cdf0e10cSrcweir 					pPage->SetFrmFmt( pFmtWish );
1211cdf0e10cSrcweir 			}
1212cdf0e10cSrcweir #ifdef DBG_UTIL
1213cdf0e10cSrcweir 			else
1214cdf0e10cSrcweir 			{
1215cdf0e10cSrcweir 				ASSERT( sal_False, "CheckPageDescs, missing solution" );
1216cdf0e10cSrcweir 			}
1217cdf0e10cSrcweir #endif
1218cdf0e10cSrcweir 		}
1219cdf0e10cSrcweir 		if ( bCheckEmpty )
1220cdf0e10cSrcweir 		{
1221cdf0e10cSrcweir 			//Es kann noch sein, dass die Leerseite schlicht  ueberflussig ist.
1222cdf0e10cSrcweir 			//Obiger Algorithmus kann dies leider nicht feststellen.
1223cdf0e10cSrcweir 			//Eigentlich muesste die Leerseite einfach praeventiv entfernt
1224cdf0e10cSrcweir 			//werden; sie wuerde ja ggf. wieder eingefuegt.
1225cdf0e10cSrcweir 			//Die EmptyPage ist genau dann ueberfluessig, wenn die Folgeseite
1226cdf0e10cSrcweir 			//auch ohne sie auskommt. Dazu muessen wir uns die Verhaeltnisse
1227cdf0e10cSrcweir 			//genauer ansehen. Wir bestimmen den PageDesc und die virtuelle
1228cdf0e10cSrcweir 			//Seitennummer manuell.
1229cdf0e10cSrcweir 			SwPageFrm *pPg = (SwPageFrm*)pPage->GetNext();
1230cdf0e10cSrcweir 			if( !pPg || pPage->OnRightPage() == pPg->WannaRightPage() )
1231cdf0e10cSrcweir 			{
1232cdf0e10cSrcweir 				//Die Folgeseite hat kein Problem ein FrmFmt zu finden oder keinen
1233cdf0e10cSrcweir 				//Nachfolger, also ist die Leerseite ueberfluessig.
1234cdf0e10cSrcweir 				SwPageFrm *pTmp = (SwPageFrm*)pPage->GetNext();
1235cdf0e10cSrcweir 				pPage->Cut();
1236cdf0e10cSrcweir 				delete pPage;
1237cdf0e10cSrcweir 				if ( pStart == pPage )
1238cdf0e10cSrcweir 					pStart = pTmp;
1239cdf0e10cSrcweir 				pPage = pTmp;
1240cdf0e10cSrcweir 				continue;
1241cdf0e10cSrcweir 			}
1242cdf0e10cSrcweir 		}
1243cdf0e10cSrcweir 		pPage = (SwPageFrm*)pPage->GetNext();
1244cdf0e10cSrcweir 	}
1245cdf0e10cSrcweir 
1246cdf0e10cSrcweir 	pRoot->SetAssertFlyPages();
1247cdf0e10cSrcweir 	pRoot->AssertPageFlys( pStart );
1248cdf0e10cSrcweir 
1249cdf0e10cSrcweir 	if ( bNotifyFields && (!pImp || !pImp->IsUpdateExpFlds()) )
1250cdf0e10cSrcweir 	{
1251cdf0e10cSrcweir 		SwDocPosUpdate aMsgHnt( nDocPos );
1252cdf0e10cSrcweir 		pDoc->UpdatePageFlds( &aMsgHnt );
1253cdf0e10cSrcweir 	}
1254cdf0e10cSrcweir 
1255cdf0e10cSrcweir #ifdef DBG_UTIL
1256cdf0e10cSrcweir 	//Ein paar Pruefungen muessen schon erlaubt sein.
1257cdf0e10cSrcweir 
1258cdf0e10cSrcweir 	//1. Keine zwei EmptyPages hintereinander.
1259cdf0e10cSrcweir 	//2. Alle PageDescs richtig?
1260cdf0e10cSrcweir 	sal_Bool bEmpty = sal_False;
1261cdf0e10cSrcweir 	SwPageFrm *pPg = pStart;
1262cdf0e10cSrcweir 	while ( pPg )
1263cdf0e10cSrcweir 	{
1264cdf0e10cSrcweir 		if ( pPg->IsEmptyPage() )
1265cdf0e10cSrcweir 		{
1266cdf0e10cSrcweir 			if ( bEmpty )
1267cdf0e10cSrcweir 			{
1268cdf0e10cSrcweir 				ASSERT( sal_False, "Doppelte Leerseiten." );
1269cdf0e10cSrcweir 				break;	//Einmal reicht.
1270cdf0e10cSrcweir 			}
1271cdf0e10cSrcweir 			bEmpty = sal_True;
1272cdf0e10cSrcweir 		}
1273cdf0e10cSrcweir 		else
1274cdf0e10cSrcweir 			bEmpty = sal_False;
1275cdf0e10cSrcweir 
1276cdf0e10cSrcweir //MA 21. Jun. 95: Kann zu testzwecken 'rein, ist aber bei zyklen durchaus
1277cdf0e10cSrcweir //moeglich: Ein paar Seiten, auf der ersten 'erste Seite' anwenden,
1278cdf0e10cSrcweir //rechte als folge der ersten, linke als folge der rechten, rechte als
1279cdf0e10cSrcweir //folge der linken.
1280cdf0e10cSrcweir //		ASSERT( pPg->GetPageDesc() == pPg->FindPageDesc(),
1281cdf0e10cSrcweir //				"Seite mit falschem Descriptor." );
1282cdf0e10cSrcweir 
1283cdf0e10cSrcweir 		pPg = (SwPageFrm*)pPg->GetNext();
1284cdf0e10cSrcweir 	}
1285cdf0e10cSrcweir #endif
1286cdf0e10cSrcweir }
1287cdf0e10cSrcweir 
1288cdf0e10cSrcweir /*************************************************************************
1289cdf0e10cSrcweir |*
1290cdf0e10cSrcweir |*	SwFrm::InsertPage()
1291cdf0e10cSrcweir |*
1292cdf0e10cSrcweir |*	Beschreibung
1293cdf0e10cSrcweir |*	Ersterstellung		MA 10. Feb. 93
1294cdf0e10cSrcweir |*	Letzte Aenderung	MA 27. Jul. 93
1295cdf0e10cSrcweir |*
1296cdf0e10cSrcweir |*************************************************************************/
InsertPage(SwPageFrm * pPrevPage,sal_Bool bFtn)1297cdf0e10cSrcweir SwPageFrm *SwFrm::InsertPage( SwPageFrm *pPrevPage, sal_Bool bFtn )
1298cdf0e10cSrcweir {
1299cdf0e10cSrcweir 	SwRootFrm *pRoot = (SwRootFrm*)pPrevPage->GetUpper();
1300cdf0e10cSrcweir 	SwPageFrm *pSibling = (SwPageFrm*)pRoot->GetLower();
1301cdf0e10cSrcweir 	SwPageDesc *pDesc = pSibling->GetPageDesc();
1302cdf0e10cSrcweir 
1303cdf0e10cSrcweir 	pSibling = (SwPageFrm*)pPrevPage->GetNext();
1304cdf0e10cSrcweir 		//Rechte (ungerade) oder linke (gerade) Seite einfuegen?
1305cdf0e10cSrcweir 	sal_Bool bNextOdd = !pPrevPage->OnRightPage();
1306cdf0e10cSrcweir 	sal_Bool bWishedOdd = bNextOdd;
1307cdf0e10cSrcweir 
1308cdf0e10cSrcweir 	//Welcher PageDesc gilt?
1309cdf0e10cSrcweir 	//Bei CntntFrm der aus dem Format wenn einer angegeben ist,
1310cdf0e10cSrcweir 	//der Follow vom bereits in der PrevPage gueltigen sonst.
1311cdf0e10cSrcweir 	pDesc = 0;
1312cdf0e10cSrcweir 	if ( IsFlowFrm() && !SwFlowFrm::CastFlowFrm( this )->IsFollow() )
1313cdf0e10cSrcweir 	{	SwFmtPageDesc &rDesc = (SwFmtPageDesc&)GetAttrSet()->GetPageDesc();
1314cdf0e10cSrcweir 		pDesc = rDesc.GetPageDesc();
1315cdf0e10cSrcweir 		if ( rDesc.GetNumOffset() )
1316cdf0e10cSrcweir 		{
1317cdf0e10cSrcweir 			bWishedOdd = rDesc.GetNumOffset() % 2 ? sal_True : sal_False;
1318cdf0e10cSrcweir 			//Die Gelegenheit nutzen wir um das Flag an der Root zu pflegen.
1319cdf0e10cSrcweir 			pRoot->SetVirtPageNum( sal_True );
1320cdf0e10cSrcweir 		}
1321cdf0e10cSrcweir 	}
1322cdf0e10cSrcweir 	if ( !pDesc )
1323cdf0e10cSrcweir 		pDesc = pPrevPage->GetPageDesc()->GetFollow();
1324cdf0e10cSrcweir 
1325cdf0e10cSrcweir 	ASSERT( pDesc, "Missing PageDesc" );
1326cdf0e10cSrcweir 	if( !(bWishedOdd ? pDesc->GetRightFmt() : pDesc->GetLeftFmt()) )
1327cdf0e10cSrcweir 		bWishedOdd = !bWishedOdd;
1328cdf0e10cSrcweir 
1329cdf0e10cSrcweir 	SwDoc *pDoc = pPrevPage->GetFmt()->GetDoc();
1330cdf0e10cSrcweir 	SwFrmFmt *pFmt;
1331cdf0e10cSrcweir 	sal_Bool bCheckPages = sal_False;
1332cdf0e10cSrcweir 	//Wenn ich kein FrmFmt fuer die Seite gefunden habe, muss ich eben eine
1333cdf0e10cSrcweir 	//Leerseite einfuegen.
1334cdf0e10cSrcweir 	if( bWishedOdd != bNextOdd )
1335cdf0e10cSrcweir 	{	pFmt = pDoc->GetEmptyPageFmt();
1336cdf0e10cSrcweir 		SwPageDesc *pTmpDesc = pPrevPage->GetPageDesc();
1337cdf0e10cSrcweir 		SwPageFrm *pPage = new SwPageFrm( pFmt, pRoot, pTmpDesc );
1338cdf0e10cSrcweir 		pPage->Paste( pRoot, pSibling );
1339cdf0e10cSrcweir 		pPage->PreparePage( bFtn );
1340cdf0e10cSrcweir 		//Wenn der Sibling keinen Bodytext enthaelt kann ich ihn vernichten
1341cdf0e10cSrcweir 		//Es sei denn, es ist eine Fussnotenseite
1342cdf0e10cSrcweir 		if ( pSibling && !pSibling->IsFtnPage() &&
1343cdf0e10cSrcweir 			 !pSibling->FindFirstBodyCntnt() )
1344cdf0e10cSrcweir 		{
1345cdf0e10cSrcweir 			SwPageFrm *pDel = pSibling;
1346cdf0e10cSrcweir 			pSibling = (SwPageFrm*)pSibling->GetNext();
1347cdf0e10cSrcweir 			if ( pDoc->GetFtnIdxs().Count() )
1348cdf0e10cSrcweir 				pRoot->RemoveFtns( pDel, sal_True );
1349cdf0e10cSrcweir 			pDel->Cut();
1350cdf0e10cSrcweir 			delete pDel;
1351cdf0e10cSrcweir 		}
1352cdf0e10cSrcweir 		else
1353cdf0e10cSrcweir 			bCheckPages = sal_True;
1354cdf0e10cSrcweir 	}
1355cdf0e10cSrcweir 	pFmt = bWishedOdd ? pDesc->GetRightFmt() : pDesc->GetLeftFmt();
1356cdf0e10cSrcweir 	ASSERT( pFmt, "Descriptor without format." );
1357cdf0e10cSrcweir 	SwPageFrm *pPage = new SwPageFrm( pFmt, pRoot, pDesc );
1358cdf0e10cSrcweir 	pPage->Paste( pRoot, pSibling );
1359cdf0e10cSrcweir 	pPage->PreparePage( bFtn );
1360cdf0e10cSrcweir 	//Wenn der Sibling keinen Bodytext enthaelt kann ich ihn vernichten
1361cdf0e10cSrcweir 	//Es sei denn es ist eine Fussnotenseite.
1362cdf0e10cSrcweir 	if ( pSibling && !pSibling->IsFtnPage() &&
1363cdf0e10cSrcweir 		 !pSibling->FindFirstBodyCntnt() )
1364cdf0e10cSrcweir 	{
1365cdf0e10cSrcweir 		SwPageFrm *pDel = pSibling;
1366cdf0e10cSrcweir 		pSibling = (SwPageFrm*)pSibling->GetNext();
1367cdf0e10cSrcweir 		if ( pDoc->GetFtnIdxs().Count() )
1368cdf0e10cSrcweir 			pRoot->RemoveFtns( pDel, sal_True );
1369cdf0e10cSrcweir 		pDel->Cut();
1370cdf0e10cSrcweir 		delete pDel;
1371cdf0e10cSrcweir 	}
1372cdf0e10cSrcweir 	else
1373cdf0e10cSrcweir 		bCheckPages = sal_True;
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir 	if ( pSibling )
1376cdf0e10cSrcweir 	{
1377cdf0e10cSrcweir 		if ( bCheckPages )
1378cdf0e10cSrcweir 		{
1379cdf0e10cSrcweir 			CheckPageDescs( pSibling, sal_False );
1380cdf0e10cSrcweir 			ViewShell *pSh = getRootFrm()->GetCurrShell();
1381cdf0e10cSrcweir 			SwViewImp *pImp = pSh ? pSh->Imp() : 0;
1382cdf0e10cSrcweir 			if ( pImp && pImp->IsAction() && !pImp->GetLayAction().IsCheckPages() )
1383cdf0e10cSrcweir 			{
1384cdf0e10cSrcweir 				const sal_uInt16 nNum = pImp->GetLayAction().GetCheckPageNum();
1385cdf0e10cSrcweir 				if ( nNum == pPrevPage->GetPhyPageNum() + 1 )
1386cdf0e10cSrcweir 					pImp->GetLayAction().SetCheckPageNumDirect(
1387cdf0e10cSrcweir 													pSibling->GetPhyPageNum() );
1388cdf0e10cSrcweir 				return pPage;
1389cdf0e10cSrcweir 			}
1390cdf0e10cSrcweir 		}
1391cdf0e10cSrcweir 		else
1392cdf0e10cSrcweir 			pRoot->AssertPageFlys( pSibling );
1393cdf0e10cSrcweir 	}
1394cdf0e10cSrcweir 
1395cdf0e10cSrcweir 	//Fuer das Aktualisieren der Seitennummern-Felder gibt nDocPos
1396cdf0e10cSrcweir 	//die Seitenposition an, _ab_ der invalidiert werden soll.
1397cdf0e10cSrcweir 	ViewShell *pSh = getRootFrm()->GetCurrShell();
1398cdf0e10cSrcweir 	if ( !pSh || !pSh->Imp()->IsUpdateExpFlds() )
1399cdf0e10cSrcweir 	{
1400cdf0e10cSrcweir 		SwDocPosUpdate aMsgHnt( pPrevPage->Frm().Top() );
1401cdf0e10cSrcweir 		pDoc->UpdatePageFlds( &aMsgHnt );
1402cdf0e10cSrcweir 	}
1403cdf0e10cSrcweir 	return pPage;
1404cdf0e10cSrcweir }
1405cdf0e10cSrcweir 
SidebarPosition() const1406cdf0e10cSrcweir sw::sidebarwindows::SidebarPosition SwPageFrm::SidebarPosition() const
1407cdf0e10cSrcweir {
1408cdf0e10cSrcweir 	ViewShell *pSh = getRootFrm()->GetCurrShell();
1409cdf0e10cSrcweir 	if( !pSh || pSh->GetViewOptions()->getBrowseMode() )
1410cdf0e10cSrcweir     {
1411cdf0e10cSrcweir         return sw::sidebarwindows::SIDEBAR_RIGHT;
1412cdf0e10cSrcweir     }
1413cdf0e10cSrcweir 	else
1414cdf0e10cSrcweir 	{
1415cdf0e10cSrcweir         const bool bLTR = getRootFrm()->IsLeftToRightViewLayout();
1416cdf0e10cSrcweir         const bool bBookMode = pSh->GetViewOptions()->IsViewLayoutBookMode();
1417cdf0e10cSrcweir         const bool bRightSidebar = bLTR ? (!bBookMode || OnRightPage()) : (bBookMode && !OnRightPage());
1418cdf0e10cSrcweir 
1419cdf0e10cSrcweir         return bRightSidebar
1420cdf0e10cSrcweir                ? sw::sidebarwindows::SIDEBAR_RIGHT
1421cdf0e10cSrcweir                : sw::sidebarwindows::SIDEBAR_LEFT;
1422cdf0e10cSrcweir     }
1423cdf0e10cSrcweir }
1424cdf0e10cSrcweir 
1425cdf0e10cSrcweir /*************************************************************************
1426cdf0e10cSrcweir |*
1427cdf0e10cSrcweir |*	SwRootFrm::GrowFrm()
1428cdf0e10cSrcweir |*
1429cdf0e10cSrcweir |*	Ersterstellung		MA 30. Jul. 92
1430cdf0e10cSrcweir |*	Letzte Aenderung	MA 05. May. 94
1431cdf0e10cSrcweir |*
1432cdf0e10cSrcweir |*************************************************************************/
1433cdf0e10cSrcweir 
GrowFrm(SwTwips nDist,sal_Bool bTst,sal_Bool)1434cdf0e10cSrcweir SwTwips SwRootFrm::GrowFrm( SwTwips nDist, sal_Bool bTst, sal_Bool )
1435cdf0e10cSrcweir {
1436cdf0e10cSrcweir 	if ( !bTst )
1437cdf0e10cSrcweir         Frm().SSize().Height() += nDist;
1438cdf0e10cSrcweir 	return nDist;
1439cdf0e10cSrcweir }
1440cdf0e10cSrcweir /*************************************************************************
1441cdf0e10cSrcweir |*
1442cdf0e10cSrcweir |*	SwRootFrm::ShrinkFrm()
1443cdf0e10cSrcweir |*
1444cdf0e10cSrcweir |*	Ersterstellung		MA 30. Jul. 92
1445cdf0e10cSrcweir |*	Letzte Aenderung	MA 05. May. 94
1446cdf0e10cSrcweir |*
1447cdf0e10cSrcweir |*************************************************************************/
ShrinkFrm(SwTwips nDist,sal_Bool bTst,sal_Bool)1448cdf0e10cSrcweir SwTwips SwRootFrm::ShrinkFrm( SwTwips nDist, sal_Bool bTst, sal_Bool )
1449cdf0e10cSrcweir {
1450cdf0e10cSrcweir 	ASSERT( nDist >= 0, "nDist < 0." );
1451cdf0e10cSrcweir     ASSERT( nDist <= Frm().Height(), "nDist > als aktuelle Groesse." );
1452cdf0e10cSrcweir 
1453cdf0e10cSrcweir 	if ( !bTst )
1454cdf0e10cSrcweir         Frm().SSize().Height() -= nDist;
1455cdf0e10cSrcweir 	return nDist;
1456cdf0e10cSrcweir }
1457cdf0e10cSrcweir 
1458cdf0e10cSrcweir /*************************************************************************
1459cdf0e10cSrcweir |*
1460cdf0e10cSrcweir |*	SwRootFrm::RemoveSuperfluous()
1461cdf0e10cSrcweir |*
1462cdf0e10cSrcweir |*	Beschreibung:		Entfernung von ueberfluessigen Seiten.
1463cdf0e10cSrcweir |*			Arbeitet nur wenn das Flag bCheckSuperfluous gesetzt ist.
1464cdf0e10cSrcweir |*			Definition: Eine Seite ist genau dann leer, wenn der
1465cdf0e10cSrcweir |*			Body-Textbereich keinen CntntFrm enthaelt, aber nicht, wenn noch
1466cdf0e10cSrcweir |* 			mindestens ein Fly an der Seite klebt.
1467cdf0e10cSrcweir |* 			Die Seite ist auch dann nicht leer, wenn sie noch eine
1468cdf0e10cSrcweir |* 			Fussnote enthaelt.
1469cdf0e10cSrcweir |*			Es muss zweimal angesetzt werden um leeren Seiten aufzuspueren:
1470cdf0e10cSrcweir |* 				- einmal fuer die Endnotenseiten.
1471cdf0e10cSrcweir |* 				- und einmal fuer die Seiten des Bodytextes.
1472cdf0e10cSrcweir |*
1473cdf0e10cSrcweir |*	Ersterstellung		MA 20. May. 92
1474cdf0e10cSrcweir |*	Letzte Aenderung	MA 10. Jan. 95
1475cdf0e10cSrcweir |*
1476cdf0e10cSrcweir |*************************************************************************/
RemoveSuperfluous()1477cdf0e10cSrcweir void SwRootFrm::RemoveSuperfluous()
1478cdf0e10cSrcweir {
1479cdf0e10cSrcweir 	if ( !IsSuperfluous() )
1480cdf0e10cSrcweir 		return;
1481cdf0e10cSrcweir 	bCheckSuperfluous = sal_False;
1482cdf0e10cSrcweir 
1483cdf0e10cSrcweir 	SwPageFrm *pPage = GetLastPage();
1484cdf0e10cSrcweir 	long nDocPos = LONG_MAX;
1485cdf0e10cSrcweir 
1486cdf0e10cSrcweir 	//Jetzt wird fuer die jeweils letzte Seite geprueft ob sie leer ist
1487cdf0e10cSrcweir 	//bei der ersten nicht leeren Seite wird die Schleife beendet.
1488cdf0e10cSrcweir 	do
1489cdf0e10cSrcweir 	{
1490cdf0e10cSrcweir         bool bExistEssentialObjs = ( 0 != pPage->GetSortedObjs() );
1491cdf0e10cSrcweir         if ( bExistEssentialObjs )
1492cdf0e10cSrcweir 		{
1493cdf0e10cSrcweir 			//Nur weil die Seite Flys hat sind wir noch lange nicht fertig,
1494cdf0e10cSrcweir 			//denn wenn alle Flys an generischem Inhalt haengen, so ist sie
1495cdf0e10cSrcweir 			//trotzdem ueberfluessig (Ueberpruefung auf DocBody sollte reichen).
1496cdf0e10cSrcweir             // OD 19.06.2003 #108784# - consider that drawing objects in
1497cdf0e10cSrcweir             // header/footer are supported now.
1498cdf0e10cSrcweir             bool bOnlySuperfluosObjs = true;
1499cdf0e10cSrcweir             SwSortedObjs &rObjs = *pPage->GetSortedObjs();
1500cdf0e10cSrcweir             for ( sal_uInt16 i = 0; bOnlySuperfluosObjs && i < rObjs.Count(); ++i )
1501cdf0e10cSrcweir 			{
1502cdf0e10cSrcweir                 // --> OD 2004-06-29 #i28701#
1503cdf0e10cSrcweir                 SwAnchoredObject* pAnchoredObj = rObjs[i];
1504cdf0e10cSrcweir                 // OD 2004-01-19 #110582# - do not consider hidden objects
1505cdf0e10cSrcweir                 if ( pPage->GetFmt()->GetDoc()->IsVisibleLayerId(
1506cdf0e10cSrcweir                                     pAnchoredObj->GetDrawObj()->GetLayer() ) &&
1507cdf0e10cSrcweir                      !pAnchoredObj->GetAnchorFrm()->FindFooterOrHeader() )
1508cdf0e10cSrcweir                 {
1509cdf0e10cSrcweir                     bOnlySuperfluosObjs = false;
1510cdf0e10cSrcweir                 }
1511cdf0e10cSrcweir                 // <--
1512cdf0e10cSrcweir 			}
1513cdf0e10cSrcweir             bExistEssentialObjs = !bOnlySuperfluosObjs;
1514cdf0e10cSrcweir 		}
1515cdf0e10cSrcweir 
1516cdf0e10cSrcweir         // OD 19.06.2003 #108784# - optimization: check first, if essential objects
1517cdf0e10cSrcweir         // exists.
1518cdf0e10cSrcweir         const SwLayoutFrm* pBody = 0;
1519cdf0e10cSrcweir         if ( bExistEssentialObjs ||
1520cdf0e10cSrcweir              pPage->FindFtnCont() ||
1521cdf0e10cSrcweir              ( 0 != ( pBody = pPage->FindBodyCont() ) &&
1522cdf0e10cSrcweir                 ( pBody->ContainsCntnt() ||
1523cdf0e10cSrcweir                     // --> FME 2005-05-18 #i47580#
1524cdf0e10cSrcweir                     // Do not delete page if there's an empty tabframe
1525cdf0e10cSrcweir                     // left. I think it might be correct to use ContainsAny()
1526cdf0e10cSrcweir                     // instead of ContainsCntnt() to cover the empty-table-case,
1527cdf0e10cSrcweir                     // but I'm not fully sure, since ContainsAny() also returns
1528cdf0e10cSrcweir                     // SectionFrames. Therefore I prefer to do it the safe way:
1529cdf0e10cSrcweir                   ( pBody->Lower() && pBody->Lower()->IsTabFrm() ) ) ) )
1530cdf0e10cSrcweir                     // <--
1531cdf0e10cSrcweir 		{
1532cdf0e10cSrcweir 			if ( pPage->IsFtnPage() )
1533cdf0e10cSrcweir 			{
1534cdf0e10cSrcweir 				while ( pPage->IsFtnPage() )
1535cdf0e10cSrcweir 				{
1536cdf0e10cSrcweir 					pPage = (SwPageFrm*)pPage->GetPrev();
1537cdf0e10cSrcweir 					ASSERT( pPage, "Nur noch Endnotenseiten uebrig." );
1538cdf0e10cSrcweir 				}
1539cdf0e10cSrcweir 				continue;
1540cdf0e10cSrcweir 			}
1541cdf0e10cSrcweir 			else
1542cdf0e10cSrcweir 				pPage = 0;
1543cdf0e10cSrcweir 		}
1544cdf0e10cSrcweir 
1545cdf0e10cSrcweir 		if ( pPage )
1546cdf0e10cSrcweir 		{
1547cdf0e10cSrcweir 			SwPageFrm *pEmpty = pPage;
1548cdf0e10cSrcweir 			pPage = (SwPageFrm*)pPage->GetPrev();
1549cdf0e10cSrcweir 			if ( GetFmt()->GetDoc()->GetFtnIdxs().Count() )
1550cdf0e10cSrcweir 				RemoveFtns( pEmpty, sal_True );
1551cdf0e10cSrcweir 			pEmpty->Cut();
1552cdf0e10cSrcweir 			delete pEmpty;
1553cdf0e10cSrcweir 			nDocPos = pPage ? pPage->Frm().Top() : 0;
1554cdf0e10cSrcweir 		}
1555cdf0e10cSrcweir 	} while ( pPage );
1556cdf0e10cSrcweir 
1557cdf0e10cSrcweir 	ViewShell *pSh = getRootFrm()->GetCurrShell();
1558cdf0e10cSrcweir 	if ( nDocPos != LONG_MAX &&
1559cdf0e10cSrcweir 		 (!pSh || !pSh->Imp()->IsUpdateExpFlds()) )
1560cdf0e10cSrcweir 	{
1561cdf0e10cSrcweir 		SwDocPosUpdate aMsgHnt( nDocPos );
1562cdf0e10cSrcweir 		GetFmt()->GetDoc()->UpdatePageFlds( &aMsgHnt );
1563cdf0e10cSrcweir 	}
1564cdf0e10cSrcweir }
1565cdf0e10cSrcweir 
1566cdf0e10cSrcweir /*************************************************************************
1567cdf0e10cSrcweir |*
1568cdf0e10cSrcweir |*	SwRootFrm::AssertFlyPages()
1569cdf0e10cSrcweir |*
1570cdf0e10cSrcweir |*	Beschreibung		Stellt sicher, dass genuegend Seiten vorhanden
1571cdf0e10cSrcweir |* 		sind, damit alle Seitengebundenen Rahmen und DrawObject
1572cdf0e10cSrcweir |*		untergebracht sind.
1573cdf0e10cSrcweir |*
1574cdf0e10cSrcweir |*	Ersterstellung		MA 27. Jul. 93
1575cdf0e10cSrcweir |*	Letzte Aenderung	MA 24. Apr. 97
1576cdf0e10cSrcweir |*
1577cdf0e10cSrcweir |*************************************************************************/
AssertFlyPages()1578cdf0e10cSrcweir void SwRootFrm::AssertFlyPages()
1579cdf0e10cSrcweir {
1580cdf0e10cSrcweir 	if ( !IsAssertFlyPages() )
1581cdf0e10cSrcweir 		return;
1582cdf0e10cSrcweir 	bAssertFlyPages = sal_False;
1583cdf0e10cSrcweir 
1584cdf0e10cSrcweir 	SwDoc *pDoc = GetFmt()->GetDoc();
1585cdf0e10cSrcweir 	const SwSpzFrmFmts *pTbl = pDoc->GetSpzFrmFmts();
1586cdf0e10cSrcweir 
1587cdf0e10cSrcweir 	//Auf welche Seite will der 'letzte' Fly?
1588cdf0e10cSrcweir 	sal_uInt16 nMaxPg = 0;
1589cdf0e10cSrcweir 	sal_uInt16 i;
1590cdf0e10cSrcweir 
1591cdf0e10cSrcweir 	for ( i = 0; i < pTbl->Count(); ++i )
1592cdf0e10cSrcweir 	{
1593cdf0e10cSrcweir 		const SwFmtAnchor &rAnch = (*pTbl)[i]->GetAnchor();
1594cdf0e10cSrcweir 		if ( !rAnch.GetCntntAnchor() && nMaxPg < rAnch.GetPageNum() )
1595cdf0e10cSrcweir 			nMaxPg = rAnch.GetPageNum();
1596cdf0e10cSrcweir 	}
1597cdf0e10cSrcweir 	//Wieviele Seiten haben wir derzeit?
1598cdf0e10cSrcweir 	SwPageFrm *pPage = (SwPageFrm*)Lower();
1599cdf0e10cSrcweir 	while ( pPage && pPage->GetNext() &&
1600cdf0e10cSrcweir 			!((SwPageFrm*)pPage->GetNext())->IsFtnPage() )
1601cdf0e10cSrcweir 	{
1602cdf0e10cSrcweir 		pPage = (SwPageFrm*)pPage->GetNext();
1603cdf0e10cSrcweir 	}
1604cdf0e10cSrcweir 
1605cdf0e10cSrcweir 	if ( nMaxPg > pPage->GetPhyPageNum() )
1606cdf0e10cSrcweir 	{
1607cdf0e10cSrcweir 		//Die Seiten werden ausgehend von der letzten Seite konsequent
1608cdf0e10cSrcweir 		//nach den Regeln der PageDescs weitergefuehrt.
1609cdf0e10cSrcweir 		sal_Bool bOdd = pPage->GetPhyPageNum() % 2 ? sal_True : sal_False;
1610cdf0e10cSrcweir 		SwPageDesc *pDesc = pPage->GetPageDesc();
1611cdf0e10cSrcweir 		SwFrm *pSibling = pPage->GetNext();
1612cdf0e10cSrcweir 		for ( i = pPage->GetPhyPageNum(); i < nMaxPg; ++i  )
1613cdf0e10cSrcweir 		{
1614cdf0e10cSrcweir 			if ( !(bOdd ? pDesc->GetRightFmt() : pDesc->GetLeftFmt()) )
1615cdf0e10cSrcweir 			{
1616cdf0e10cSrcweir 				//Leerseite einfuegen, die Flys werden aber erst von
1617cdf0e10cSrcweir 				//der naechsten Seite aufgenommen!
1618cdf0e10cSrcweir 				pPage = new SwPageFrm( pDoc->GetEmptyPageFmt(), this, pDesc );
1619cdf0e10cSrcweir 				pPage->Paste( this, pSibling );
1620cdf0e10cSrcweir 				pPage->PreparePage( sal_False );
1621cdf0e10cSrcweir 				bOdd = bOdd ? sal_False : sal_True;
1622cdf0e10cSrcweir 				++i;
1623cdf0e10cSrcweir 			}
1624cdf0e10cSrcweir 			pPage = new
1625cdf0e10cSrcweir 					SwPageFrm( (bOdd ? pDesc->GetRightFmt() :
1626cdf0e10cSrcweir 									   pDesc->GetLeftFmt()), this, pDesc );
1627cdf0e10cSrcweir 			pPage->Paste( this, pSibling );
1628cdf0e10cSrcweir 			pPage->PreparePage( sal_False );
1629cdf0e10cSrcweir 			bOdd = bOdd ? sal_False : sal_True;
1630cdf0e10cSrcweir 			pDesc = pDesc->GetFollow();
1631cdf0e10cSrcweir 		}
1632cdf0e10cSrcweir 		//Jetzt koennen die Endnotenseiten natuerlich wieder krumm sein;
1633cdf0e10cSrcweir 		//in diesem Fall werden sie vernichtet.
1634cdf0e10cSrcweir 		if ( pDoc->GetFtnIdxs().Count() )
1635cdf0e10cSrcweir 		{
1636cdf0e10cSrcweir 			pPage = (SwPageFrm*)Lower();
1637cdf0e10cSrcweir 			while ( pPage && !pPage->IsFtnPage() )
1638cdf0e10cSrcweir 				pPage = (SwPageFrm*)pPage->GetNext();
1639cdf0e10cSrcweir 
1640cdf0e10cSrcweir 			if ( pPage )
1641cdf0e10cSrcweir 			{
1642cdf0e10cSrcweir                 SwPageDesc *pTmpDesc = pPage->FindPageDesc();
1643cdf0e10cSrcweir 				bOdd = pPage->OnRightPage();
1644cdf0e10cSrcweir 				if ( pPage->GetFmt() !=
1645cdf0e10cSrcweir                      (bOdd ? pTmpDesc->GetRightFmt() : pTmpDesc->GetLeftFmt()) )
1646cdf0e10cSrcweir 					RemoveFtns( pPage, sal_False, sal_True );
1647cdf0e10cSrcweir 			}
1648cdf0e10cSrcweir 		}
1649cdf0e10cSrcweir 	}
1650cdf0e10cSrcweir }
1651cdf0e10cSrcweir 
1652cdf0e10cSrcweir /*************************************************************************
1653cdf0e10cSrcweir |*
1654cdf0e10cSrcweir |*	SwRootFrm::AssertPageFlys()
1655cdf0e10cSrcweir |*
1656cdf0e10cSrcweir |*	Beschreibung		Stellt sicher, dass ab der uebergebenen Seite
1657cdf0e10cSrcweir |* 		auf allen Seiten die Seitengebunden Objecte auf der richtigen
1658cdf0e10cSrcweir |* 		Seite (Seitennummer stehen).
1659cdf0e10cSrcweir |*
1660cdf0e10cSrcweir |*	Ersterstellung		MA 02. Nov. 94
1661cdf0e10cSrcweir |*	Letzte Aenderung	MA 10. Aug. 95
1662cdf0e10cSrcweir |*
1663cdf0e10cSrcweir |*************************************************************************/
AssertPageFlys(SwPageFrm * pPage)1664cdf0e10cSrcweir void SwRootFrm::AssertPageFlys( SwPageFrm *pPage )
1665cdf0e10cSrcweir {
1666cdf0e10cSrcweir 	while ( pPage )
1667cdf0e10cSrcweir 	{
1668cdf0e10cSrcweir 		if ( pPage->GetSortedObjs() )
1669cdf0e10cSrcweir 		{
1670cdf0e10cSrcweir 			pPage->GetSortedObjs();
1671cdf0e10cSrcweir 			for ( int i = 0;
1672cdf0e10cSrcweir 				  pPage->GetSortedObjs() && sal_uInt16(i) < pPage->GetSortedObjs()->Count();
1673cdf0e10cSrcweir 				  ++i)
1674cdf0e10cSrcweir 			{
1675cdf0e10cSrcweir                 // --> OD 2004-06-29 #i28701#
1676cdf0e10cSrcweir                 SwFrmFmt& rFmt = (*pPage->GetSortedObjs())[i]->GetFrmFmt();
1677cdf0e10cSrcweir                 const SwFmtAnchor &rAnch = rFmt.GetAnchor();
1678cdf0e10cSrcweir 				const sal_uInt16 nPg = rAnch.GetPageNum();
1679cdf0e10cSrcweir                 if ((rAnch.GetAnchorId() == FLY_AT_PAGE) &&
1680cdf0e10cSrcweir 					 nPg != pPage->GetPhyPageNum() )
1681cdf0e10cSrcweir 				{
1682cdf0e10cSrcweir 					//Das er auf der falschen Seite steht muss noch nichts
1683cdf0e10cSrcweir 					//heissen, wenn er eigentlich auf der Vorseite
1684cdf0e10cSrcweir 					//stehen will und diese eine EmptyPage ist.
1685cdf0e10cSrcweir                     if( nPg && !(pPage->GetPhyPageNum()-1 == nPg &&
1686cdf0e10cSrcweir                         ((SwPageFrm*)pPage->GetPrev())->IsEmptyPage()) )
1687cdf0e10cSrcweir 					{
1688cdf0e10cSrcweir 						//Umhaengen kann er sich selbst, indem wir ihm
1689cdf0e10cSrcweir 						//einfach ein Modify mit seinem AnkerAttr schicken.
1690cdf0e10cSrcweir #ifndef DBG_UTIL
1691cdf0e10cSrcweir                         rFmt.NotifyClients( 0, (SwFmtAnchor*)&rAnch );
1692cdf0e10cSrcweir #else
1693cdf0e10cSrcweir                         const sal_uInt32 nCnt = pPage->GetSortedObjs()->Count();
1694cdf0e10cSrcweir                         rFmt.NotifyClients( 0, (SwFmtAnchor*)&rAnch );
1695cdf0e10cSrcweir 						ASSERT( !pPage->GetSortedObjs() ||
1696cdf0e10cSrcweir 								nCnt != pPage->GetSortedObjs()->Count(),
1697cdf0e10cSrcweir 								"Object couldn't be reattached!" );
1698cdf0e10cSrcweir #endif
1699cdf0e10cSrcweir 						--i;
1700cdf0e10cSrcweir 					}
1701cdf0e10cSrcweir 				}
1702cdf0e10cSrcweir 			}
1703cdf0e10cSrcweir 		}
1704cdf0e10cSrcweir 		pPage = (SwPageFrm*)pPage->GetNext();
1705cdf0e10cSrcweir 	}
1706cdf0e10cSrcweir }
1707cdf0e10cSrcweir 
1708cdf0e10cSrcweir /*************************************************************************
1709cdf0e10cSrcweir |*
1710cdf0e10cSrcweir |*	SwRootFrm::ChgSize()
1711cdf0e10cSrcweir |*
1712cdf0e10cSrcweir |*	Ersterstellung		MA 24. Jul. 92
1713cdf0e10cSrcweir |*	Letzte Aenderung	MA 13. Aug. 93
1714cdf0e10cSrcweir |*
1715cdf0e10cSrcweir |*************************************************************************/
ChgSize(const Size & aNewSize)1716cdf0e10cSrcweir Size SwRootFrm::ChgSize( const Size& aNewSize )
1717cdf0e10cSrcweir {
1718cdf0e10cSrcweir 	Frm().SSize() = aNewSize;
1719cdf0e10cSrcweir 	_InvalidatePrt();
1720cdf0e10cSrcweir     bFixSize = sal_False;
1721cdf0e10cSrcweir 	return Frm().SSize();
1722cdf0e10cSrcweir }
1723cdf0e10cSrcweir 
1724cdf0e10cSrcweir /*************************************************************************
1725cdf0e10cSrcweir |*
1726cdf0e10cSrcweir |*	SwRootFrm::MakeAll()
1727cdf0e10cSrcweir |*
1728cdf0e10cSrcweir |*	Ersterstellung		MA 17. Nov. 92
1729cdf0e10cSrcweir |*	Letzte Aenderung	MA 19. Apr. 93
1730cdf0e10cSrcweir |*
1731cdf0e10cSrcweir |*************************************************************************/
MakeAll()1732cdf0e10cSrcweir void SwRootFrm::MakeAll()
1733cdf0e10cSrcweir {
1734cdf0e10cSrcweir 	if ( !bValidPos )
1735cdf0e10cSrcweir 	{	bValidPos = sal_True;
1736cdf0e10cSrcweir 		aFrm.Pos().X() = aFrm.Pos().Y() = DOCUMENTBORDER;
1737cdf0e10cSrcweir 	}
1738cdf0e10cSrcweir 	if ( !bValidPrtArea )
1739cdf0e10cSrcweir 	{	bValidPrtArea = sal_True;
1740cdf0e10cSrcweir 		aPrt.Pos().X() = aPrt.Pos().Y() = 0;
1741cdf0e10cSrcweir 		aPrt.SSize( aFrm.SSize() );
1742cdf0e10cSrcweir 	}
1743cdf0e10cSrcweir 	if ( !bValidSize )
1744cdf0e10cSrcweir 		//SSize wird von den Seiten (Cut/Paste) eingestellt.
1745cdf0e10cSrcweir 		bValidSize = sal_True;
1746cdf0e10cSrcweir }
1747cdf0e10cSrcweir 
1748cdf0e10cSrcweir /*************************************************************************
1749cdf0e10cSrcweir |*
1750cdf0e10cSrcweir |*	SwRootFrm::ImplInvalidateBrowseWidth()
1751cdf0e10cSrcweir |*
1752cdf0e10cSrcweir |*	Ersterstellung		MA 08. Jun. 96
1753cdf0e10cSrcweir |*	Letzte Aenderung	MA 08. Jun. 96
1754cdf0e10cSrcweir |*
1755cdf0e10cSrcweir |*************************************************************************/
ImplInvalidateBrowseWidth()1756cdf0e10cSrcweir void SwRootFrm::ImplInvalidateBrowseWidth()
1757cdf0e10cSrcweir {
1758cdf0e10cSrcweir 	bBrowseWidthValid = sal_False;
1759cdf0e10cSrcweir 	SwFrm *pPg = Lower();
1760cdf0e10cSrcweir 	while ( pPg )
1761cdf0e10cSrcweir 	{
1762cdf0e10cSrcweir 		pPg->InvalidateSize();
1763cdf0e10cSrcweir 		pPg = pPg->GetNext();
1764cdf0e10cSrcweir 	}
1765cdf0e10cSrcweir }
1766cdf0e10cSrcweir 
1767cdf0e10cSrcweir /*************************************************************************
1768cdf0e10cSrcweir |*
1769cdf0e10cSrcweir |*	SwRootFrm::ImplCalcBrowseWidth()
1770cdf0e10cSrcweir |*
1771cdf0e10cSrcweir |*	Ersterstellung		MA 07. Jun. 96
1772cdf0e10cSrcweir |*	Letzte Aenderung	MA 13. Jun. 96
1773cdf0e10cSrcweir |*
1774cdf0e10cSrcweir |*************************************************************************/
ImplCalcBrowseWidth()1775cdf0e10cSrcweir void SwRootFrm::ImplCalcBrowseWidth()
1776cdf0e10cSrcweir {
1777cdf0e10cSrcweir     ASSERT( GetCurrShell() && GetCurrShell()->GetViewOptions()->getBrowseMode(),
1778cdf0e10cSrcweir 			"CalcBrowseWidth and not in BrowseView" )
1779cdf0e10cSrcweir 
1780cdf0e10cSrcweir 	//Die (minimale) Breite wird von Rahmen, Tabellen und Zeichenobjekten
1781cdf0e10cSrcweir 	//bestimmt. Die Breite wird nicht anhand ihrer aktuellen Groessen bestimmt,
1782cdf0e10cSrcweir 	//sondern anhand der Attribute. Es interessiert also nicht wie breit sie
1783cdf0e10cSrcweir 	//sind, sondern wie breit sie sein wollen.
1784cdf0e10cSrcweir 	//Rahmen und Zeichenobjekte innerhalb ander Objekte (Rahmen, Tabellen)
1785cdf0e10cSrcweir 	//Zaehlen nicht.
1786cdf0e10cSrcweir 	//Seitenraender und Spalten werden hier nicht beruecksichtigt.
1787cdf0e10cSrcweir 
1788cdf0e10cSrcweir 	SwFrm *pFrm = ContainsCntnt();
1789cdf0e10cSrcweir 	while ( pFrm && !pFrm->IsInDocBody() )
1790cdf0e10cSrcweir 		pFrm = ((SwCntntFrm*)pFrm)->GetNextCntntFrm();
1791cdf0e10cSrcweir 	if ( !pFrm )
1792cdf0e10cSrcweir 		return;
1793cdf0e10cSrcweir 
1794cdf0e10cSrcweir 	bBrowseWidthValid = sal_True;
1795cdf0e10cSrcweir 	ViewShell *pSh = getRootFrm()->GetCurrShell();
1796cdf0e10cSrcweir 	nBrowseWidth = pSh
1797cdf0e10cSrcweir 					? MINLAY + 2 * pSh->GetOut()->
1798cdf0e10cSrcweir 								PixelToLogic( pSh->GetBrowseBorder() ).Width()
1799cdf0e10cSrcweir 					: 5000;
1800cdf0e10cSrcweir 	do
1801cdf0e10cSrcweir 	{
1802cdf0e10cSrcweir 		if ( pFrm->IsInTab() )
1803cdf0e10cSrcweir 			pFrm = pFrm->FindTabFrm();
1804cdf0e10cSrcweir 
1805cdf0e10cSrcweir 		if ( pFrm->IsTabFrm() &&
1806cdf0e10cSrcweir 			 !((SwLayoutFrm*)pFrm)->GetFmt()->GetFrmSize().GetWidthPercent() )
1807cdf0e10cSrcweir 		{
1808cdf0e10cSrcweir 			SwBorderAttrAccess aAccess( SwFrm::GetCache(), pFrm );
1809cdf0e10cSrcweir 			const SwBorderAttrs &rAttrs = *aAccess.Get();
1810cdf0e10cSrcweir 			const SwFmtHoriOrient &rHori = rAttrs.GetAttrSet().GetHoriOrient();
1811cdf0e10cSrcweir 			long nWidth = rAttrs.GetSize().Width();
1812cdf0e10cSrcweir 			if ( nWidth < USHRT_MAX-2000 && //-2000, weil bei Randeinstellung per
1813cdf0e10cSrcweir 											//Zuppeln das USHRT_MAX verlorengeht!
1814cdf0e10cSrcweir                  text::HoriOrientation::FULL != rHori.GetHoriOrient() )
1815cdf0e10cSrcweir 			{
1816cdf0e10cSrcweir 				const SwHTMLTableLayout *pLayoutInfo =
1817cdf0e10cSrcweir 					((const SwTabFrm *)pFrm)->GetTable()
1818cdf0e10cSrcweir 											->GetHTMLTableLayout();
1819cdf0e10cSrcweir 				if ( pLayoutInfo )
1820cdf0e10cSrcweir 					nWidth = Min( nWidth, pLayoutInfo->GetBrowseWidthMin() );
1821cdf0e10cSrcweir 
1822cdf0e10cSrcweir 				switch ( rHori.GetHoriOrient() )
1823cdf0e10cSrcweir 				{
1824cdf0e10cSrcweir                     case text::HoriOrientation::NONE:
1825cdf0e10cSrcweir                         // OD 23.01.2003 #106895# - add 1st param to <SwBorderAttrs::CalcRight(..)>
1826cdf0e10cSrcweir                         nWidth += rAttrs.CalcLeft( pFrm ) + rAttrs.CalcRight( pFrm );
1827cdf0e10cSrcweir 						break;
1828cdf0e10cSrcweir                     case text::HoriOrientation::LEFT_AND_WIDTH:
1829cdf0e10cSrcweir 						nWidth += rAttrs.CalcLeft( pFrm );
1830cdf0e10cSrcweir                         break;
1831cdf0e10cSrcweir                     default:
1832cdf0e10cSrcweir                         break;
1833cdf0e10cSrcweir 
1834cdf0e10cSrcweir 				}
1835cdf0e10cSrcweir 				nBrowseWidth = Max( nBrowseWidth, nWidth );
1836cdf0e10cSrcweir 			}
1837cdf0e10cSrcweir 		}
1838cdf0e10cSrcweir 		else if ( pFrm->GetDrawObjs() )
1839cdf0e10cSrcweir 		{
1840cdf0e10cSrcweir 			for ( sal_uInt16 i = 0; i < pFrm->GetDrawObjs()->Count(); ++i )
1841cdf0e10cSrcweir 			{
1842cdf0e10cSrcweir                 // --> OD 2004-06-29 #i28701#
1843cdf0e10cSrcweir                 SwAnchoredObject* pAnchoredObj = (*pFrm->GetDrawObjs())[i];
1844cdf0e10cSrcweir                 const SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt();
1845cdf0e10cSrcweir                 const sal_Bool bFly = pAnchoredObj->ISA(SwFlyFrm);
1846cdf0e10cSrcweir                 if ((bFly && (WEIT_WECH == pAnchoredObj->GetObjRect().Width()))
1847cdf0e10cSrcweir                     || rFmt.GetFrmSize().GetWidthPercent())
1848cdf0e10cSrcweir                 {
1849cdf0e10cSrcweir 					continue;
1850cdf0e10cSrcweir                 }
1851cdf0e10cSrcweir 
1852cdf0e10cSrcweir 				long nWidth = 0;
1853cdf0e10cSrcweir                 switch ( rFmt.GetAnchor().GetAnchorId() )
1854cdf0e10cSrcweir 				{
1855cdf0e10cSrcweir                     case FLY_AS_CHAR:
1856cdf0e10cSrcweir                         nWidth = bFly ? rFmt.GetFrmSize().GetWidth() :
1857cdf0e10cSrcweir                                         pAnchoredObj->GetObjRect().Width();
1858cdf0e10cSrcweir                         break;
1859cdf0e10cSrcweir                     case FLY_AT_PARA:
1860cdf0e10cSrcweir                         {
1861cdf0e10cSrcweir                             // --> FME 2004-09-13 #i33170#
1862cdf0e10cSrcweir                             // Reactivated old code because
1863cdf0e10cSrcweir                             // nWidth = pAnchoredObj->GetObjRect().Right()
1864cdf0e10cSrcweir                             // gives wrong results for objects that are still
1865cdf0e10cSrcweir                             // at position WEIT_WECH.
1866cdf0e10cSrcweir                             if ( bFly )
1867cdf0e10cSrcweir                             {
1868cdf0e10cSrcweir                                 nWidth = rFmt.GetFrmSize().GetWidth();
1869cdf0e10cSrcweir                                 const SwFmtHoriOrient &rHori = rFmt.GetHoriOrient();
1870cdf0e10cSrcweir                                 switch ( rHori.GetHoriOrient() )
1871cdf0e10cSrcweir                                 {
1872cdf0e10cSrcweir                                     case text::HoriOrientation::NONE:
1873cdf0e10cSrcweir                                         nWidth += rHori.GetPos();
1874cdf0e10cSrcweir                                         break;
1875cdf0e10cSrcweir                                     case text::HoriOrientation::INSIDE:
1876cdf0e10cSrcweir                                     case text::HoriOrientation::LEFT:
1877cdf0e10cSrcweir                                         if ( text::RelOrientation::PRINT_AREA == rHori.GetRelationOrient() )
1878cdf0e10cSrcweir                                             nWidth += pFrm->Prt().Left();
1879cdf0e10cSrcweir                                         break;
1880cdf0e10cSrcweir                                     default:
1881cdf0e10cSrcweir                                         break;
1882cdf0e10cSrcweir                                 }
1883cdf0e10cSrcweir                             }
1884cdf0e10cSrcweir                             else
1885cdf0e10cSrcweir                                 //Fuer Zeichenobjekte ist die Auswahl sehr klein,
1886cdf0e10cSrcweir                                 //weil sie keine Attribute haben, also durch ihre
1887cdf0e10cSrcweir                                 //aktuelle Groesse bestimmt werden.
1888cdf0e10cSrcweir                                 nWidth = pAnchoredObj->GetObjRect().Right() -
1889cdf0e10cSrcweir                                          pAnchoredObj->GetDrawObj()->GetAnchorPos().X();
1890cdf0e10cSrcweir                             // <--
1891cdf0e10cSrcweir                         }
1892cdf0e10cSrcweir 						break;
1893cdf0e10cSrcweir 					default:	/* do nothing */;
1894cdf0e10cSrcweir 				}
1895cdf0e10cSrcweir 				nBrowseWidth = Max( nBrowseWidth, nWidth );
1896cdf0e10cSrcweir 			}
1897cdf0e10cSrcweir 		}
1898cdf0e10cSrcweir 		pFrm = pFrm->FindNextCnt();
1899cdf0e10cSrcweir 	} while ( pFrm );
1900cdf0e10cSrcweir }
1901cdf0e10cSrcweir 
1902cdf0e10cSrcweir /*************************************************************************
1903cdf0e10cSrcweir |*
1904cdf0e10cSrcweir |*	SwRootFrm::StartAllAction()
1905cdf0e10cSrcweir |*
1906cdf0e10cSrcweir |*	Ersterstellung		MA 08. Mar. 98
1907cdf0e10cSrcweir |*	Letzte Aenderung	MA 08. Mar. 98
1908cdf0e10cSrcweir |*
1909cdf0e10cSrcweir |*************************************************************************/
1910cdf0e10cSrcweir 
StartAllAction()1911cdf0e10cSrcweir void SwRootFrm::StartAllAction()
1912cdf0e10cSrcweir {
1913cdf0e10cSrcweir 	ViewShell *pSh = GetCurrShell();
1914cdf0e10cSrcweir 	if ( pSh )
1915cdf0e10cSrcweir 		do
1916cdf0e10cSrcweir 		{	if ( pSh->ISA( SwCrsrShell ) )
1917cdf0e10cSrcweir 				((SwCrsrShell*)pSh)->StartAction();
1918cdf0e10cSrcweir 			else
1919cdf0e10cSrcweir 				pSh->StartAction();
1920cdf0e10cSrcweir 			pSh = (ViewShell*)pSh->GetNext();
1921cdf0e10cSrcweir 
1922cdf0e10cSrcweir 		} while ( pSh != GetCurrShell() );
1923cdf0e10cSrcweir }
1924cdf0e10cSrcweir 
EndAllAction(sal_Bool bVirDev)1925cdf0e10cSrcweir void SwRootFrm::EndAllAction( sal_Bool bVirDev )
1926cdf0e10cSrcweir {
1927cdf0e10cSrcweir 	ViewShell *pSh = GetCurrShell();
1928cdf0e10cSrcweir 	if ( pSh )
1929cdf0e10cSrcweir 		do
1930cdf0e10cSrcweir 		{
1931cdf0e10cSrcweir 			const sal_Bool bOldEndActionByVirDev = pSh->IsEndActionByVirDev();
1932cdf0e10cSrcweir 			pSh->SetEndActionByVirDev( bVirDev );
1933cdf0e10cSrcweir 			if ( pSh->ISA( SwCrsrShell ) )
1934cdf0e10cSrcweir 			{
1935cdf0e10cSrcweir 				((SwCrsrShell*)pSh)->EndAction();
1936cdf0e10cSrcweir 				((SwCrsrShell*)pSh)->CallChgLnk();
1937cdf0e10cSrcweir 				if ( pSh->ISA( SwFEShell ) )
1938cdf0e10cSrcweir 					((SwFEShell*)pSh)->SetChainMarker();
1939cdf0e10cSrcweir 			}
1940cdf0e10cSrcweir 			else
1941cdf0e10cSrcweir 				pSh->EndAction();
1942cdf0e10cSrcweir 			pSh->SetEndActionByVirDev( bOldEndActionByVirDev );
1943cdf0e10cSrcweir 			pSh = (ViewShell*)pSh->GetNext();
1944cdf0e10cSrcweir 
1945cdf0e10cSrcweir 		} while ( pSh != GetCurrShell() );
1946cdf0e10cSrcweir }
1947cdf0e10cSrcweir 
UnoRemoveAllActions()1948cdf0e10cSrcweir void SwRootFrm::UnoRemoveAllActions()
1949cdf0e10cSrcweir {
1950cdf0e10cSrcweir     ViewShell *pSh = GetCurrShell();
1951cdf0e10cSrcweir 	if ( pSh )
1952cdf0e10cSrcweir 		do
1953cdf0e10cSrcweir 		{
1954cdf0e10cSrcweir             // --> OD 2008-05-16 #i84729#
1955cdf0e10cSrcweir             // No end action, if <ViewShell> instance is currently in its end action.
1956cdf0e10cSrcweir             // Recursives calls to <::EndAction()> are not allowed.
1957cdf0e10cSrcweir             if ( !pSh->IsInEndAction() )
1958cdf0e10cSrcweir             {
1959cdf0e10cSrcweir                 DBG_ASSERT(!pSh->GetRestoreActions(), "Restore action count is already set!");
1960cdf0e10cSrcweir                 sal_Bool bCrsr = pSh->ISA( SwCrsrShell );
1961cdf0e10cSrcweir                 sal_Bool bFE = pSh->ISA( SwFEShell );
1962cdf0e10cSrcweir                 sal_uInt16 nRestore = 0;
1963cdf0e10cSrcweir                 while( pSh->ActionCount() )
1964cdf0e10cSrcweir                 {
1965cdf0e10cSrcweir                     if( bCrsr )
1966cdf0e10cSrcweir                     {
1967cdf0e10cSrcweir                         ((SwCrsrShell*)pSh)->EndAction();
1968cdf0e10cSrcweir                         ((SwCrsrShell*)pSh)->CallChgLnk();
1969cdf0e10cSrcweir                         if ( bFE )
1970cdf0e10cSrcweir                             ((SwFEShell*)pSh)->SetChainMarker();
1971cdf0e10cSrcweir                     }
1972cdf0e10cSrcweir                     else
1973cdf0e10cSrcweir                         pSh->EndAction();
1974cdf0e10cSrcweir                     nRestore++;
1975cdf0e10cSrcweir                 }
1976cdf0e10cSrcweir                 pSh->SetRestoreActions(nRestore);
1977cdf0e10cSrcweir             }
1978cdf0e10cSrcweir             // <--
1979cdf0e10cSrcweir 			pSh->LockView(sal_True);
1980cdf0e10cSrcweir 			pSh = (ViewShell*)pSh->GetNext();
1981cdf0e10cSrcweir 
1982cdf0e10cSrcweir 		} while ( pSh != GetCurrShell() );
1983cdf0e10cSrcweir }
1984cdf0e10cSrcweir 
UnoRestoreAllActions()1985cdf0e10cSrcweir void SwRootFrm::UnoRestoreAllActions()
1986cdf0e10cSrcweir {
1987cdf0e10cSrcweir 	ViewShell *pSh = GetCurrShell();
1988cdf0e10cSrcweir 	if ( pSh )
1989cdf0e10cSrcweir 		do
1990cdf0e10cSrcweir 		{
1991cdf0e10cSrcweir 			sal_uInt16 nActions = pSh->GetRestoreActions();
1992cdf0e10cSrcweir 			while( nActions-- )
1993cdf0e10cSrcweir 			{
1994cdf0e10cSrcweir 				if ( pSh->ISA( SwCrsrShell ) )
1995cdf0e10cSrcweir 					((SwCrsrShell*)pSh)->StartAction();
1996cdf0e10cSrcweir 				else
1997cdf0e10cSrcweir 					pSh->StartAction();
1998cdf0e10cSrcweir 			}
1999cdf0e10cSrcweir 			pSh->SetRestoreActions(0);
2000cdf0e10cSrcweir 			pSh->LockView(sal_False);
2001cdf0e10cSrcweir 			pSh = (ViewShell*)pSh->GetNext();
2002cdf0e10cSrcweir 
2003cdf0e10cSrcweir 		} while ( pSh != GetCurrShell() );
2004cdf0e10cSrcweir }
2005cdf0e10cSrcweir 
2006cdf0e10cSrcweir // PAGES01: Helper functions for SwRootFrm::CheckViewLayout
2007cdf0e10cSrcweir void lcl_MoveAllLowers( SwFrm* pFrm, const Point& rOffset );
2008cdf0e10cSrcweir 
lcl_MoveAllLowerObjs(SwFrm * pFrm,const Point & rOffset)2009cdf0e10cSrcweir void lcl_MoveAllLowerObjs( SwFrm* pFrm, const Point& rOffset )
2010cdf0e10cSrcweir {
2011cdf0e10cSrcweir     SwSortedObjs* pSortedObj = 0;
2012cdf0e10cSrcweir     const bool bPage = pFrm->IsPageFrm();
2013cdf0e10cSrcweir 
2014cdf0e10cSrcweir     if ( bPage )
2015cdf0e10cSrcweir         pSortedObj = static_cast<SwPageFrm*>(pFrm)->GetSortedObjs();
2016cdf0e10cSrcweir     else
2017cdf0e10cSrcweir         pSortedObj = pFrm->GetDrawObjs();
2018cdf0e10cSrcweir 
2019cdf0e10cSrcweir     for ( sal_uInt16 i = 0; pSortedObj && i < pSortedObj->Count(); ++i)
2020cdf0e10cSrcweir     {
2021cdf0e10cSrcweir         SwAnchoredObject* pAnchoredObj = (*pSortedObj)[i];
2022cdf0e10cSrcweir 
2023cdf0e10cSrcweir         const SwFrmFmt& rObjFmt = pAnchoredObj->GetFrmFmt();
2024cdf0e10cSrcweir         const SwFmtAnchor& rAnchor = rObjFmt.GetAnchor();
2025cdf0e10cSrcweir 
2026cdf0e10cSrcweir         // all except from the as character anchored objects are moved
2027cdf0e10cSrcweir         // when processing the page frame:
2028cdf0e10cSrcweir         const bool bAsChar = (rAnchor.GetAnchorId() == FLY_AS_CHAR);
2029cdf0e10cSrcweir         if ( !bPage && !bAsChar )
2030cdf0e10cSrcweir             continue;
2031cdf0e10cSrcweir 
2032cdf0e10cSrcweir         SwObjPositioningInProgress aPosInProgress( *pAnchoredObj );
2033cdf0e10cSrcweir 
2034cdf0e10cSrcweir         if ( pAnchoredObj->ISA(SwFlyFrm) )
2035cdf0e10cSrcweir         {
2036cdf0e10cSrcweir             SwFlyFrm* pFlyFrm( static_cast<SwFlyFrm*>(pAnchoredObj) );
2037cdf0e10cSrcweir             lcl_MoveAllLowers( pFlyFrm, rOffset );
2038cdf0e10cSrcweir             pFlyFrm->NotifyDrawObj();
2039cdf0e10cSrcweir 			// --> let the active embedded object be moved
2040cdf0e10cSrcweir 			if ( pFlyFrm->Lower() )
2041cdf0e10cSrcweir             {
2042cdf0e10cSrcweir                 if ( pFlyFrm->Lower()->IsNoTxtFrm() )
2043cdf0e10cSrcweir                 {
2044cdf0e10cSrcweir 					SwCntntFrm* pCntntFrm = static_cast<SwCntntFrm*>(pFlyFrm->Lower());
2045cdf0e10cSrcweir                     SwRootFrm* pRoot = pFlyFrm->Lower()->getRootFrm();
2046cdf0e10cSrcweir                     ViewShell *pSh = pRoot ? pRoot->GetCurrShell() : 0;
2047cdf0e10cSrcweir                     if ( pSh )
2048cdf0e10cSrcweir                     {
2049cdf0e10cSrcweir                         SwOLENode* pNode = pCntntFrm->GetNode()->GetOLENode();
2050cdf0e10cSrcweir                         if ( pNode )
2051cdf0e10cSrcweir                         {
2052cdf0e10cSrcweir                             svt::EmbeddedObjectRef& xObj = pNode->GetOLEObj().GetObject();
2053cdf0e10cSrcweir                             if ( xObj.is() )
2054cdf0e10cSrcweir                             {
2055cdf0e10cSrcweir                                 ViewShell* pTmp = pSh;
2056cdf0e10cSrcweir                                 do
2057cdf0e10cSrcweir                                 {
2058cdf0e10cSrcweir                                     SwFEShell* pFEShell = dynamic_cast< SwFEShell* >( pTmp );
2059cdf0e10cSrcweir                                     if ( pFEShell )
2060cdf0e10cSrcweir                                         pFEShell->MoveObjectIfActive( xObj, rOffset );
2061cdf0e10cSrcweir                                     pTmp = static_cast<ViewShell*>( pTmp->GetNext() );
2062cdf0e10cSrcweir                                 } while( pTmp != pSh );
2063cdf0e10cSrcweir                             }
2064cdf0e10cSrcweir 						}
2065cdf0e10cSrcweir 					}
2066cdf0e10cSrcweir 				}
2067cdf0e10cSrcweir 			}
2068cdf0e10cSrcweir 			// <--
2069cdf0e10cSrcweir         }
2070cdf0e10cSrcweir         else if ( pAnchoredObj->ISA(SwAnchoredDrawObject) )
2071cdf0e10cSrcweir         {
2072cdf0e10cSrcweir             SwAnchoredDrawObject* pAnchoredDrawObj( static_cast<SwAnchoredDrawObject*>(pAnchoredObj) );
2073cdf0e10cSrcweir 
2074cdf0e10cSrcweir             // don't touch objects that are not yet positioned:
2075cdf0e10cSrcweir             const bool bNotYetPositioned = pAnchoredDrawObj->NotYetPositioned();
2076cdf0e10cSrcweir             if ( bNotYetPositioned )
2077cdf0e10cSrcweir                 continue;
2078cdf0e10cSrcweir 
2079cdf0e10cSrcweir             const Point aCurrAnchorPos = pAnchoredDrawObj->GetDrawObj()->GetAnchorPos();
2080cdf0e10cSrcweir             const Point aNewAnchorPos( ( aCurrAnchorPos + rOffset ) );
2081cdf0e10cSrcweir             pAnchoredDrawObj->DrawObj()->SetAnchorPos( aNewAnchorPos );
2082cdf0e10cSrcweir             pAnchoredDrawObj->SetLastObjRect( pAnchoredDrawObj->GetObjRect().SVRect() );
2083*e9dc4413SOliver-Rainer Wittmann 
2084*e9dc4413SOliver-Rainer Wittmann             // clear contour cache if contour wrapping is enabled #i100684#
2085*e9dc4413SOliver-Rainer Wittmann             if ( pAnchoredDrawObj->GetFrmFmt().GetSurround().IsContour() )
2086*e9dc4413SOliver-Rainer Wittmann                 ClrContourCache( pAnchoredDrawObj->GetDrawObj() );
2087cdf0e10cSrcweir         }
2088cdf0e10cSrcweir         // --> OD 2009-08-20 #i92511#
2089cdf0e10cSrcweir         // cache for object rectangle inclusive spaces has to be invalidated.
2090cdf0e10cSrcweir         pAnchoredObj->InvalidateObjRectWithSpaces();
2091cdf0e10cSrcweir         // <--
2092cdf0e10cSrcweir     }
2093cdf0e10cSrcweir }
2094cdf0e10cSrcweir 
lcl_MoveAllLowers(SwFrm * pFrm,const Point & rOffset)2095cdf0e10cSrcweir void lcl_MoveAllLowers( SwFrm* pFrm, const Point& rOffset )
2096cdf0e10cSrcweir {
2097cdf0e10cSrcweir     const SwRect aFrm( pFrm->Frm() );
2098cdf0e10cSrcweir 
2099cdf0e10cSrcweir     // first move the current frame
2100cdf0e10cSrcweir     pFrm->Frm().Pos() += rOffset;
2101cdf0e10cSrcweir 
2102cdf0e10cSrcweir     // Don't forget accessibility:
2103cdf0e10cSrcweir     if( pFrm->IsAccessibleFrm() )
2104cdf0e10cSrcweir     {
2105cdf0e10cSrcweir         SwRootFrm *pRootFrm = pFrm->getRootFrm();
2106cdf0e10cSrcweir         if( pRootFrm && pRootFrm->IsAnyShellAccessible() &&
2107cdf0e10cSrcweir             pRootFrm->GetCurrShell() )
2108cdf0e10cSrcweir         {
2109cdf0e10cSrcweir             pRootFrm->GetCurrShell()->Imp()->MoveAccessibleFrm( pFrm, aFrm );
2110cdf0e10cSrcweir         }
2111cdf0e10cSrcweir     }
2112cdf0e10cSrcweir 
2113cdf0e10cSrcweir     // the move any objects
2114cdf0e10cSrcweir     lcl_MoveAllLowerObjs( pFrm, rOffset );
2115cdf0e10cSrcweir 
2116cdf0e10cSrcweir     // finally, for layout frames we have to call this function recursively:
2117cdf0e10cSrcweir     if ( pFrm->ISA(SwLayoutFrm) )
2118cdf0e10cSrcweir     {
2119cdf0e10cSrcweir         SwFrm* pLowerFrm = pFrm->GetLower();
2120cdf0e10cSrcweir         while ( pLowerFrm )
2121cdf0e10cSrcweir         {
2122cdf0e10cSrcweir             lcl_MoveAllLowers( pLowerFrm, rOffset );
2123cdf0e10cSrcweir             pLowerFrm = pLowerFrm->GetNext();
2124cdf0e10cSrcweir         }
2125cdf0e10cSrcweir     }
2126cdf0e10cSrcweir }
2127cdf0e10cSrcweir 
2128cdf0e10cSrcweir // PAGES01: Calculate how the pages have to be positioned
CheckViewLayout(const SwViewOption * pViewOpt,const SwRect * pVisArea)2129cdf0e10cSrcweir void SwRootFrm::CheckViewLayout( const SwViewOption* pViewOpt, const SwRect* pVisArea )
2130cdf0e10cSrcweir {
2131cdf0e10cSrcweir     // --> OD 2008-07-07 #i91432#
2132cdf0e10cSrcweir     // No calculation of page positions, if only an empty page is present.
2133cdf0e10cSrcweir     // This situation occurs when <SwRootFrm> instance is in construction
2134cdf0e10cSrcweir     // and the document contains only left pages.
2135cdf0e10cSrcweir     if ( Lower()->GetNext() == 0 &&
2136cdf0e10cSrcweir          static_cast<SwPageFrm*>(Lower())->IsEmptyPage() )
2137cdf0e10cSrcweir     {
2138cdf0e10cSrcweir         return;
2139cdf0e10cSrcweir     }
2140cdf0e10cSrcweir     // <--
2141cdf0e10cSrcweir 
2142cdf0e10cSrcweir     if ( !pVisArea )
2143cdf0e10cSrcweir     {
2144cdf0e10cSrcweir         // no early return for bNewPage
2145cdf0e10cSrcweir         if ( mnViewWidth < 0 )
2146cdf0e10cSrcweir             mnViewWidth = 0;
2147cdf0e10cSrcweir     }
2148cdf0e10cSrcweir     else
2149cdf0e10cSrcweir     {
2150cdf0e10cSrcweir         ASSERT( pViewOpt, "CheckViewLayout required ViewOptions" )
2151cdf0e10cSrcweir 
2152cdf0e10cSrcweir         const sal_uInt16 nColumns =  pViewOpt->GetViewLayoutColumns();
2153cdf0e10cSrcweir         const bool   bBookMode = pViewOpt->IsViewLayoutBookMode();
2154cdf0e10cSrcweir 
2155cdf0e10cSrcweir         if ( nColumns == mnColumns && bBookMode == mbBookMode && pVisArea->Width() == mnViewWidth && !mbSidebarChanged )
2156cdf0e10cSrcweir             return;
2157cdf0e10cSrcweir 
2158cdf0e10cSrcweir         mnColumns = nColumns;
2159cdf0e10cSrcweir         mbBookMode = bBookMode;
2160cdf0e10cSrcweir         mnViewWidth = pVisArea->Width();
2161cdf0e10cSrcweir         mbSidebarChanged = false;
2162cdf0e10cSrcweir     }
2163cdf0e10cSrcweir 
2164cdf0e10cSrcweir     if( GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE ) )
2165cdf0e10cSrcweir     {
2166cdf0e10cSrcweir         mnColumns = 1;
2167cdf0e10cSrcweir         mbBookMode = false;
2168cdf0e10cSrcweir     }
2169cdf0e10cSrcweir 
2170cdf0e10cSrcweir     Calc();
2171cdf0e10cSrcweir 
2172cdf0e10cSrcweir     const sal_Bool bOldCallbackActionEnabled = IsCallbackActionEnabled();
2173cdf0e10cSrcweir     SetCallbackActionEnabled( sal_False );
2174cdf0e10cSrcweir 
2175cdf0e10cSrcweir     maPageRects.clear();
2176cdf0e10cSrcweir 
2177cdf0e10cSrcweir     const long nBorder = Frm().Pos().X();
2178cdf0e10cSrcweir     const long nVisWidth = mnViewWidth - 2 * nBorder;
2179cdf0e10cSrcweir     const long nGapBetweenPages = GAPBETWEENPAGES;
2180cdf0e10cSrcweir 
2181cdf0e10cSrcweir     // check how many pages fit into the first page layout row:
2182cdf0e10cSrcweir     SwPageFrm* pPageFrm = static_cast<SwPageFrm*>(Lower());
2183cdf0e10cSrcweir 
2184cdf0e10cSrcweir     // will contain the number of pages per row. 0 means that
2185cdf0e10cSrcweir     // the page does not fit.
2186cdf0e10cSrcweir     long nWidthRemain = nVisWidth;
2187cdf0e10cSrcweir 
2188cdf0e10cSrcweir     // after one row has been processed, these variables contain
2189cdf0e10cSrcweir     // the width of the row and the maxium of the page heights
2190cdf0e10cSrcweir     long nCurrentRowHeight = 0;
2191cdf0e10cSrcweir     long nCurrentRowWidth = 0;
2192cdf0e10cSrcweir 
2193cdf0e10cSrcweir     // these variables are used to finally set the size of the
2194cdf0e10cSrcweir     // root frame
2195cdf0e10cSrcweir     long nSumRowHeight = 0;
2196cdf0e10cSrcweir     SwTwips nMinPageLeft = TWIPS_MAX;
2197cdf0e10cSrcweir     SwTwips nMaxPageRight = 0;
2198cdf0e10cSrcweir     SwPageFrm* pStartOfRow = pPageFrm;
2199cdf0e10cSrcweir     sal_uInt16 nNumberOfPagesInRow = mbBookMode ? 1 : 0; // in book view, start with right page
2200cdf0e10cSrcweir     bool bFirstRow = true;
2201cdf0e10cSrcweir 
2202cdf0e10cSrcweir     bool bPageChanged = false;
2203cdf0e10cSrcweir     const bool bRTL = !IsLeftToRightViewLayout();
2204cdf0e10cSrcweir     const SwTwips nSidebarWidth = SwPageFrm::GetSidebarBorderWidth( GetCurrShell() );
2205cdf0e10cSrcweir 
2206cdf0e10cSrcweir     while ( pPageFrm )
2207cdf0e10cSrcweir     {
2208cdf0e10cSrcweir         // we consider the current page to be "start of row" if
2209cdf0e10cSrcweir         // 1. it is the first page in the current row or
2210cdf0e10cSrcweir         // 2. it is the second page in the row and the first page is an empty page in non-book view:
2211cdf0e10cSrcweir         const bool bStartOfRow = pPageFrm == pStartOfRow ||
2212cdf0e10cSrcweir                                              ( pStartOfRow->IsEmptyPage() && pPageFrm == pStartOfRow->GetNext() && !mbBookMode );
2213cdf0e10cSrcweir 
2214cdf0e10cSrcweir         const bool bEmptyPage = pPageFrm->IsEmptyPage() && !mbBookMode;
2215cdf0e10cSrcweir 
2216cdf0e10cSrcweir         // no half doc border space for first page in each row and
2217cdf0e10cSrcweir         long nPageWidth = 0;
2218cdf0e10cSrcweir         long nPageHeight = 0;
2219cdf0e10cSrcweir 
2220cdf0e10cSrcweir         if ( mbBookMode )
2221cdf0e10cSrcweir         {
2222cdf0e10cSrcweir             const SwFrm& rFormatPage = pPageFrm->GetFormatPage();
2223cdf0e10cSrcweir 
2224cdf0e10cSrcweir             nPageWidth  = rFormatPage.Frm().Width()  + nSidebarWidth + ((bStartOfRow || 1 == (pPageFrm->GetPhyPageNum()%2)) ? 0 : nGapBetweenPages);
2225cdf0e10cSrcweir             nPageHeight = rFormatPage.Frm().Height() + nGapBetweenPages;
2226cdf0e10cSrcweir         }
2227cdf0e10cSrcweir         else
2228cdf0e10cSrcweir         {
2229cdf0e10cSrcweir             SwRect aPageFrm;
2230cdf0e10cSrcweir             if ( !pPageFrm->IsEmptyPage() )
2231cdf0e10cSrcweir             {
2232cdf0e10cSrcweir                 nPageWidth  = pPageFrm->Frm().Width() + nSidebarWidth + (bStartOfRow ? 0 : nGapBetweenPages);
2233cdf0e10cSrcweir                 nPageHeight = pPageFrm->Frm().Height() + nGapBetweenPages;
2234cdf0e10cSrcweir             }
2235cdf0e10cSrcweir         }
2236cdf0e10cSrcweir 
2237cdf0e10cSrcweir         if ( !bEmptyPage )
2238cdf0e10cSrcweir             ++nNumberOfPagesInRow;
2239cdf0e10cSrcweir 
2240cdf0e10cSrcweir         // finish current row if
2241cdf0e10cSrcweir         // 1. in dynamic mode the current page does not fit anymore or
2242cdf0e10cSrcweir         // 2. the current page exceeds the maximum number of columns
2243cdf0e10cSrcweir         bool bRowFinished = (0 == mnColumns && nWidthRemain < nPageWidth ) ||
2244cdf0e10cSrcweir                             (0 != mnColumns && mnColumns < nNumberOfPagesInRow);
2245cdf0e10cSrcweir 
2246cdf0e10cSrcweir         // make sure that at least one page goes to the current row:
2247cdf0e10cSrcweir         if ( !bRowFinished || bStartOfRow )
2248cdf0e10cSrcweir         {
2249cdf0e10cSrcweir             // current page is allowed to be in current row
2250cdf0e10cSrcweir             nWidthRemain = nWidthRemain - nPageWidth;
2251cdf0e10cSrcweir 
2252cdf0e10cSrcweir             nCurrentRowWidth = nCurrentRowWidth + nPageWidth;
2253cdf0e10cSrcweir             nCurrentRowHeight = Max( nCurrentRowHeight, nPageHeight );
2254cdf0e10cSrcweir 
2255cdf0e10cSrcweir             pPageFrm = static_cast<SwPageFrm*>(pPageFrm->GetNext());
2256cdf0e10cSrcweir 
2257cdf0e10cSrcweir             if ( !pPageFrm )
2258cdf0e10cSrcweir                 bRowFinished = true;
2259cdf0e10cSrcweir         }
2260cdf0e10cSrcweir 
2261cdf0e10cSrcweir         if ( bRowFinished )
2262cdf0e10cSrcweir         {
2263cdf0e10cSrcweir             // pPageFrm now points to the first page in the new row or null
2264cdf0e10cSrcweir             // pStartOfRow points to the first page in the current row
2265cdf0e10cSrcweir 
2266cdf0e10cSrcweir             // special centering for last row. pretend to fill the last row with virtual copies of the last page before centering:
2267cdf0e10cSrcweir             if ( !pPageFrm && nWidthRemain > 0 )
2268cdf0e10cSrcweir             {
2269cdf0e10cSrcweir                 // find last page in current row:
2270cdf0e10cSrcweir                 const SwPageFrm* pLastPageInCurrentRow = pStartOfRow;
2271cdf0e10cSrcweir                 while( pLastPageInCurrentRow->GetNext() )
2272cdf0e10cSrcweir                     pLastPageInCurrentRow = static_cast<const SwPageFrm*>(pLastPageInCurrentRow->GetNext());
2273cdf0e10cSrcweir 
2274cdf0e10cSrcweir                 if ( pLastPageInCurrentRow->IsEmptyPage() )
2275cdf0e10cSrcweir                     pLastPageInCurrentRow = static_cast<const SwPageFrm*>(pLastPageInCurrentRow->GetPrev());
2276cdf0e10cSrcweir 
2277cdf0e10cSrcweir                 // check how many times the last page would still fit into the remaining space:
2278cdf0e10cSrcweir                 sal_uInt16 nNumberOfVirtualPages = 0;
2279cdf0e10cSrcweir                 const sal_uInt16 nMaxNumberOfVirtualPages = mnColumns > 0 ? mnColumns - nNumberOfPagesInRow : USHRT_MAX;
2280cdf0e10cSrcweir                 SwTwips nRemain = nWidthRemain;
2281cdf0e10cSrcweir                 SwTwips nVirtualPagesWidth = 0;
2282cdf0e10cSrcweir                 SwTwips nLastPageWidth = pLastPageInCurrentRow->Frm().Width() + nSidebarWidth;
2283cdf0e10cSrcweir 
2284cdf0e10cSrcweir                 while ( ( mnColumns > 0 || nRemain > 0 ) && nNumberOfVirtualPages < nMaxNumberOfVirtualPages )
2285cdf0e10cSrcweir                 {
2286cdf0e10cSrcweir                     SwTwips nLastPageWidthWithGap = nLastPageWidth;
2287cdf0e10cSrcweir                     if ( !mbBookMode || ( 0 == (nNumberOfVirtualPages + nNumberOfPagesInRow) %2) )
2288cdf0e10cSrcweir                         nLastPageWidthWithGap += nGapBetweenPages;
2289cdf0e10cSrcweir 
2290cdf0e10cSrcweir                     if ( mnColumns > 0 || nLastPageWidthWithGap < nRemain )
2291cdf0e10cSrcweir                     {
2292cdf0e10cSrcweir                         ++nNumberOfVirtualPages;
2293cdf0e10cSrcweir                         nVirtualPagesWidth += nLastPageWidthWithGap;
2294cdf0e10cSrcweir                     }
2295cdf0e10cSrcweir                     nRemain = nRemain - nLastPageWidthWithGap;
2296cdf0e10cSrcweir                 }
2297cdf0e10cSrcweir 
2298cdf0e10cSrcweir                 nCurrentRowWidth = nCurrentRowWidth + nVirtualPagesWidth;
2299cdf0e10cSrcweir             }
2300cdf0e10cSrcweir 
2301cdf0e10cSrcweir             // first page in book mode is always special:
2302cdf0e10cSrcweir             if ( bFirstRow && mbBookMode )
2303cdf0e10cSrcweir             {
2304cdf0e10cSrcweir                 // --> OD 2008-04-08 #i88036#
2305cdf0e10cSrcweir //                nCurrentRowWidth += pStartOfRow->Frm().Width() + nSidebarWidth;
2306cdf0e10cSrcweir                 nCurrentRowWidth +=
2307cdf0e10cSrcweir                     pStartOfRow->GetFormatPage().Frm().Width() + nSidebarWidth;
2308cdf0e10cSrcweir                 // <--
2309cdf0e10cSrcweir             }
2310cdf0e10cSrcweir 
2311cdf0e10cSrcweir             // center page if possible
2312cdf0e10cSrcweir             const long nSizeDiff = nVisWidth > nCurrentRowWidth ?
2313cdf0e10cSrcweir                                    ( nVisWidth - nCurrentRowWidth ) / 2 :
2314cdf0e10cSrcweir                                    0;
2315cdf0e10cSrcweir 
2316cdf0e10cSrcweir             // adjust positions of pages in current row
2317cdf0e10cSrcweir             long nX = nSizeDiff;
2318cdf0e10cSrcweir 
2319cdf0e10cSrcweir             const long nRowStart = nBorder + nSizeDiff;
2320cdf0e10cSrcweir             const long nRowEnd   = nRowStart + nCurrentRowWidth;
2321cdf0e10cSrcweir 
2322cdf0e10cSrcweir             if ( bFirstRow && mbBookMode )
2323cdf0e10cSrcweir             {
2324cdf0e10cSrcweir                 // --> OD 2008-04-08 #i88036#
2325cdf0e10cSrcweir //                nX += pStartOfRow->Frm().Width() + nSidebarWidth;
2326cdf0e10cSrcweir                 nX += pStartOfRow->GetFormatPage().Frm().Width() + nSidebarWidth;
2327cdf0e10cSrcweir                 // <--
2328cdf0e10cSrcweir             }
2329cdf0e10cSrcweir 
2330cdf0e10cSrcweir             SwPageFrm* pEndOfRow = pPageFrm;
2331cdf0e10cSrcweir             SwPageFrm* pPageToAdjust = pStartOfRow;
2332cdf0e10cSrcweir 
2333cdf0e10cSrcweir             do
2334cdf0e10cSrcweir             {
2335cdf0e10cSrcweir                 const SwPageFrm* pFormatPage = pPageToAdjust;
2336cdf0e10cSrcweir                 if ( mbBookMode )
2337cdf0e10cSrcweir                     pFormatPage = &pPageToAdjust->GetFormatPage();
2338cdf0e10cSrcweir 
2339cdf0e10cSrcweir                 const SwTwips nCurrentPageWidth = pFormatPage->Frm().Width() + (pFormatPage->IsEmptyPage() ? 0 : nSidebarWidth);
2340cdf0e10cSrcweir                 const Point aOldPagePos = pPageToAdjust->Frm().Pos();
2341cdf0e10cSrcweir                 const bool bLeftSidebar = pPageToAdjust->SidebarPosition() == sw::sidebarwindows::SIDEBAR_LEFT;
2342cdf0e10cSrcweir                 const SwTwips nLeftPageAddOffset = bLeftSidebar ?
2343cdf0e10cSrcweir                                                    nSidebarWidth :
2344cdf0e10cSrcweir                                                    0;
2345cdf0e10cSrcweir 
2346cdf0e10cSrcweir                 Point aNewPagePos( nBorder + nX, nBorder + nSumRowHeight );
2347cdf0e10cSrcweir                 Point aNewPagePosWithLeftOffset( nBorder + nX + nLeftPageAddOffset, nBorder + nSumRowHeight );
2348cdf0e10cSrcweir 
2349cdf0e10cSrcweir                 // RTL view layout: Calculate mirrored page position
2350cdf0e10cSrcweir                 if ( bRTL )
2351cdf0e10cSrcweir                 {
2352cdf0e10cSrcweir                     const long nXOffsetInRow = aNewPagePos.X() - nRowStart;
2353cdf0e10cSrcweir                     aNewPagePos.X() = nRowEnd - nXOffsetInRow - nCurrentPageWidth;
2354cdf0e10cSrcweir                     aNewPagePosWithLeftOffset = aNewPagePos;
2355cdf0e10cSrcweir                     aNewPagePosWithLeftOffset.X() += nLeftPageAddOffset;
2356cdf0e10cSrcweir                 }
2357cdf0e10cSrcweir 
2358cdf0e10cSrcweir                 if ( aNewPagePosWithLeftOffset != aOldPagePos )
2359cdf0e10cSrcweir                 {
2360cdf0e10cSrcweir                     lcl_MoveAllLowers( pPageToAdjust, aNewPagePosWithLeftOffset - aOldPagePos );
2361cdf0e10cSrcweir                     pPageToAdjust->SetCompletePaint();
2362cdf0e10cSrcweir                     bPageChanged = true;
2363cdf0e10cSrcweir                 }
2364cdf0e10cSrcweir 
2365cdf0e10cSrcweir                 // calculate area covered by the current page and store to
2366cdf0e10cSrcweir                 // maPageRects. This is used e.g., for cursor setting
2367cdf0e10cSrcweir                 const bool bFirstColumn = pPageToAdjust == pStartOfRow;
2368cdf0e10cSrcweir                 const bool bLastColumn = pPageToAdjust->GetNext() == pEndOfRow;
2369cdf0e10cSrcweir                 const bool bLastRow = !pEndOfRow;
2370cdf0e10cSrcweir 
2371cdf0e10cSrcweir                 nMinPageLeft  = Min( nMinPageLeft, aNewPagePos.X() );
2372cdf0e10cSrcweir                 nMaxPageRight = Max( nMaxPageRight, aNewPagePos.X() + nCurrentPageWidth);
2373cdf0e10cSrcweir 
2374cdf0e10cSrcweir                 // border of nGapBetweenPages around the current page:
2375cdf0e10cSrcweir                 SwRect aPageRectWithBorders( aNewPagePos.X() - nGapBetweenPages,
2376cdf0e10cSrcweir                                              aNewPagePos.Y(),
2377cdf0e10cSrcweir                                              pPageToAdjust->Frm().SSize().Width() + nGapBetweenPages + nSidebarWidth,
2378cdf0e10cSrcweir                                              nCurrentRowHeight );
2379cdf0e10cSrcweir 
2380cdf0e10cSrcweir                 static const long nOuterClickDiff = 1000000;
2381cdf0e10cSrcweir 
2382cdf0e10cSrcweir                 // adjust borders for these special cases:
2383cdf0e10cSrcweir                 if ( (bFirstColumn && !bRTL) || (bLastColumn && bRTL) )
2384cdf0e10cSrcweir                     aPageRectWithBorders.SubLeft( nOuterClickDiff );
2385cdf0e10cSrcweir                 if ( (bLastColumn && !bRTL) || (bFirstColumn && bRTL) )
2386cdf0e10cSrcweir                     aPageRectWithBorders.AddRight( nOuterClickDiff );
2387cdf0e10cSrcweir                 if ( bFirstRow )
2388cdf0e10cSrcweir                     aPageRectWithBorders.SubTop( nOuterClickDiff );
2389cdf0e10cSrcweir                 if ( bLastRow )
2390cdf0e10cSrcweir                     aPageRectWithBorders.AddBottom( nOuterClickDiff );
2391cdf0e10cSrcweir 
2392cdf0e10cSrcweir                 maPageRects.push_back( aPageRectWithBorders );
2393cdf0e10cSrcweir 
2394cdf0e10cSrcweir                 nX = nX + nCurrentPageWidth;
2395cdf0e10cSrcweir                 pPageToAdjust = static_cast<SwPageFrm*>(pPageToAdjust->GetNext());
2396cdf0e10cSrcweir 
2397cdf0e10cSrcweir                 // distance to next page
2398cdf0e10cSrcweir                 if ( pPageToAdjust && pPageToAdjust != pEndOfRow )
2399cdf0e10cSrcweir                 {
2400cdf0e10cSrcweir                     // in book view, we add the x gap before left (even) pages:
2401cdf0e10cSrcweir                     if ( mbBookMode )
2402cdf0e10cSrcweir                     {
2403cdf0e10cSrcweir                         if ( 0 == (pPageToAdjust->GetPhyPageNum()%2) )
2404cdf0e10cSrcweir                             nX = nX + nGapBetweenPages;
2405cdf0e10cSrcweir                     }
2406cdf0e10cSrcweir                     else
2407cdf0e10cSrcweir                     {
2408cdf0e10cSrcweir                         // in non-book view, dont add x gap before
2409cdf0e10cSrcweir                         // 1. the last empty page in a row
2410cdf0e10cSrcweir                         // 2. after an empty page
2411cdf0e10cSrcweir                         const bool bDontAddGap = ( pPageToAdjust->IsEmptyPage() && pPageToAdjust->GetNext() == pEndOfRow ) ||
2412cdf0e10cSrcweir                                                  ( static_cast<SwPageFrm*>(pPageToAdjust->GetPrev())->IsEmptyPage() );
2413cdf0e10cSrcweir 
2414cdf0e10cSrcweir                         if  ( !bDontAddGap )
2415cdf0e10cSrcweir                             nX = nX + nGapBetweenPages;
2416cdf0e10cSrcweir                     }
2417cdf0e10cSrcweir                 }
2418cdf0e10cSrcweir             }
2419cdf0e10cSrcweir             while ( pPageToAdjust != pEndOfRow );
2420cdf0e10cSrcweir 
2421cdf0e10cSrcweir             // adjust values for root frame size
2422cdf0e10cSrcweir             nSumRowHeight = nSumRowHeight + nCurrentRowHeight;
2423cdf0e10cSrcweir 
2424cdf0e10cSrcweir             // start new row:
2425cdf0e10cSrcweir             nCurrentRowHeight = 0;
2426cdf0e10cSrcweir             nCurrentRowWidth = 0;
2427cdf0e10cSrcweir             pStartOfRow = pEndOfRow;
2428cdf0e10cSrcweir             nWidthRemain = nVisWidth;
2429cdf0e10cSrcweir             nNumberOfPagesInRow = 0;
2430cdf0e10cSrcweir             bFirstRow = false;
2431cdf0e10cSrcweir         } // end row finished
2432cdf0e10cSrcweir     } // end while
2433cdf0e10cSrcweir 
2434cdf0e10cSrcweir     // set size of root frame:
2435cdf0e10cSrcweir     const Size aOldSize( Frm().SSize() );
2436cdf0e10cSrcweir     const Size aNewSize( nMaxPageRight - nBorder, nSumRowHeight - nGapBetweenPages );
2437cdf0e10cSrcweir 
2438cdf0e10cSrcweir     if ( bPageChanged || aNewSize != aOldSize )
2439cdf0e10cSrcweir     {
2440cdf0e10cSrcweir         ChgSize( aNewSize );
2441cdf0e10cSrcweir         ::AdjustSizeChgNotify( this );
2442cdf0e10cSrcweir         Calc();
2443cdf0e10cSrcweir 
2444cdf0e10cSrcweir         ViewShell* pSh = GetCurrShell();
2445cdf0e10cSrcweir 
2446cdf0e10cSrcweir         if ( pSh && pSh->GetDoc()->GetDocShell() )
2447cdf0e10cSrcweir         {
2448cdf0e10cSrcweir             pSh->SetFirstVisPageInvalid();
2449cdf0e10cSrcweir             if (bOldCallbackActionEnabled)
2450cdf0e10cSrcweir             {
2451cdf0e10cSrcweir                 pSh->InvalidateWindows( SwRect( 0, 0, LONG_MAX, LONG_MAX ) );
2452cdf0e10cSrcweir                 pSh->GetDoc()->GetDocShell()->Broadcast(SfxSimpleHint(SFX_HINT_DOCCHANGED));
2453cdf0e10cSrcweir             }
2454cdf0e10cSrcweir         }
2455cdf0e10cSrcweir     }
2456cdf0e10cSrcweir 
2457cdf0e10cSrcweir     maPagesArea.Pos( Frm().Pos() );
2458cdf0e10cSrcweir     maPagesArea.SSize( aNewSize );
2459cdf0e10cSrcweir     if ( TWIPS_MAX != nMinPageLeft )
2460cdf0e10cSrcweir         maPagesArea._Left( nMinPageLeft );
2461cdf0e10cSrcweir 
2462cdf0e10cSrcweir     SetCallbackActionEnabled( bOldCallbackActionEnabled );
2463cdf0e10cSrcweir }
2464cdf0e10cSrcweir 
IsLeftToRightViewLayout() const2465cdf0e10cSrcweir bool SwRootFrm::IsLeftToRightViewLayout() const
2466cdf0e10cSrcweir {
2467cdf0e10cSrcweir     // Layout direction determined by layout direction of the first page.
2468cdf0e10cSrcweir     // --> OD 2008-04-08 #i88036#
2469cdf0e10cSrcweir     // Only ask a non-empty page frame for its layout direction
2470cdf0e10cSrcweir //    const SwPageFrm* pPage = dynamic_cast<const SwPageFrm*>(Lower());
2471cdf0e10cSrcweir //    return !pPage->IsRightToLeft() && !pPage->IsVertical();
2472cdf0e10cSrcweir     const SwPageFrm& rPage =
2473cdf0e10cSrcweir                     dynamic_cast<const SwPageFrm*>(Lower())->GetFormatPage();
2474cdf0e10cSrcweir     return !rPage.IsRightToLeft() && !rPage.IsVertical();
2475cdf0e10cSrcweir     // <--
2476cdf0e10cSrcweir }
2477cdf0e10cSrcweir 
2478cdf0e10cSrcweir /*const SwRect SwRootFrm::GetExtendedPageArea( sal_uInt16 nPageNumber ) const
2479cdf0e10cSrcweir {
2480cdf0e10cSrcweir     SwRect aRet;
2481cdf0e10cSrcweir     ASSERT( nPageNumber < maPageRects.size(), "No extended page area available" )
2482cdf0e10cSrcweir     if ( nPageNumber < maPageRects.size() )
2483cdf0e10cSrcweir         aRet = maPageRects[ nPageNumber ];
2484cdf0e10cSrcweir     return aRet;
2485cdf0e10cSrcweir }*/
2486cdf0e10cSrcweir 
2487cdf0e10cSrcweir 
GetFormatPage() const2488cdf0e10cSrcweir const SwPageFrm& SwPageFrm::GetFormatPage() const
2489cdf0e10cSrcweir {
2490cdf0e10cSrcweir     const SwPageFrm* pRet = this;
2491cdf0e10cSrcweir     if ( IsEmptyPage() )
2492cdf0e10cSrcweir     {
2493cdf0e10cSrcweir         pRet = static_cast<const SwPageFrm*>( OnRightPage() ? GetNext() : GetPrev() );
2494cdf0e10cSrcweir         // --> OD 2008-04-08 #i88035#
2495cdf0e10cSrcweir         // Typically a right empty page frame has a next non-empty page frame and
2496cdf0e10cSrcweir         // a left empty page frame has a previous non-empty page frame.
2497cdf0e10cSrcweir         // But under certain cirsumstances this assumption is not true -
2498cdf0e10cSrcweir         // e.g. during insertion of a left page at the end of the document right
2499cdf0e10cSrcweir         // after a left page in an intermediate state a right empty page does not
2500cdf0e10cSrcweir         // have a next page frame.
2501cdf0e10cSrcweir         if ( pRet == 0 )
2502cdf0e10cSrcweir         {
2503cdf0e10cSrcweir             if ( OnRightPage() )
2504cdf0e10cSrcweir             {
2505cdf0e10cSrcweir                 pRet = static_cast<const SwPageFrm*>( GetPrev() );
2506cdf0e10cSrcweir             }
2507cdf0e10cSrcweir             else
2508cdf0e10cSrcweir             {
2509cdf0e10cSrcweir                 pRet = static_cast<const SwPageFrm*>( GetNext() );
2510cdf0e10cSrcweir             }
2511cdf0e10cSrcweir         }
2512cdf0e10cSrcweir         ASSERT( pRet,
2513cdf0e10cSrcweir                 "<SwPageFrm::GetFormatPage()> - inconsistent layout: empty page without previous and next page frame --> crash." );
2514cdf0e10cSrcweir         // <--
2515cdf0e10cSrcweir     }
2516cdf0e10cSrcweir     return *pRet;
2517cdf0e10cSrcweir }
2518cdf0e10cSrcweir 
2519