xref: /trunk/main/sw/source/core/layout/frmtool.cxx (revision 9204bf8294f34a46abdfeceee27c48e7b7b2ef12)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22*6e8337c1Smseidel 
23*6e8337c1Smseidel 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
2626ea3662SArmin Le Grand 
27cdf0e10cSrcweir #include <hintids.hxx>
28cdf0e10cSrcweir #include <tools/bigint.hxx>
29cdf0e10cSrcweir #include <svx/svdmodel.hxx>
30cdf0e10cSrcweir #include <svx/svdpage.hxx>
31cdf0e10cSrcweir #include <editeng/brshitem.hxx>
32cdf0e10cSrcweir #include <editeng/keepitem.hxx>
33cdf0e10cSrcweir #include <editeng/shaditem.hxx>
34cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
35cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
36cdf0e10cSrcweir #include <editeng/boxitem.hxx>
37cdf0e10cSrcweir #include <sfx2/printer.hxx>
38cdf0e10cSrcweir #include <editeng/lspcitem.hxx>
39cdf0e10cSrcweir #include <fmtornt.hxx>
40cdf0e10cSrcweir #include <fmtanchr.hxx>
41cdf0e10cSrcweir #include <fmthdft.hxx>
42cdf0e10cSrcweir #include <fmtcntnt.hxx>
43cdf0e10cSrcweir #include <fmtfsize.hxx>
44cdf0e10cSrcweir #include <fmtsrnd.hxx>
45cdf0e10cSrcweir #include <docary.hxx>
46cdf0e10cSrcweir #include <lineinfo.hxx>
47cdf0e10cSrcweir #include <swmodule.hxx>
48cdf0e10cSrcweir #include "pagefrm.hxx"
49cdf0e10cSrcweir #include "colfrm.hxx"
50cdf0e10cSrcweir #include "doc.hxx"
51cdf0e10cSrcweir #include "fesh.hxx"
52cdf0e10cSrcweir #include "viewimp.hxx"
53cdf0e10cSrcweir #include "viewopt.hxx"
54cdf0e10cSrcweir #include "pam.hxx"
55cdf0e10cSrcweir #include "dflyobj.hxx"
56cdf0e10cSrcweir #include "dcontact.hxx"
57cdf0e10cSrcweir #include "frmtool.hxx"
58cdf0e10cSrcweir #include "docsh.hxx"
59cdf0e10cSrcweir #include "tabfrm.hxx"
60cdf0e10cSrcweir #include "rowfrm.hxx"
61cdf0e10cSrcweir #include "ftnfrm.hxx"
62cdf0e10cSrcweir #include "txtfrm.hxx"
63cdf0e10cSrcweir #include "notxtfrm.hxx"
64cdf0e10cSrcweir #include "flyfrms.hxx"
65cdf0e10cSrcweir #include "layact.hxx"
66cdf0e10cSrcweir #include "pagedesc.hxx"
67cdf0e10cSrcweir #include "section.hxx"
68cdf0e10cSrcweir #include "sectfrm.hxx"
69cdf0e10cSrcweir #include "node2lay.hxx"
70cdf0e10cSrcweir #include "ndole.hxx"
71cdf0e10cSrcweir #include "ndtxt.hxx"
72cdf0e10cSrcweir #include "swtable.hxx"
73cdf0e10cSrcweir #include "hints.hxx"
74cdf0e10cSrcweir #include <layhelp.hxx>
75cdf0e10cSrcweir #include <laycache.hxx>
76cdf0e10cSrcweir #include <rootfrm.hxx>
77cdf0e10cSrcweir #include "mdiexp.hxx"
78cdf0e10cSrcweir #include "statstr.hrc"
79cdf0e10cSrcweir #include <paratr.hxx>
80cdf0e10cSrcweir #include <sortedobjs.hxx>
81cdf0e10cSrcweir #include <objectformatter.hxx>
82cdf0e10cSrcweir #include <switerator.hxx>
8356b35d86SArmin Le Grand #include <svx/sdr/attribute/sdrallfillattributeshelper.hxx>
8426ea3662SArmin Le Grand #include <drawdoc.hxx>
8556b35d86SArmin Le Grand 
86cdf0e10cSrcweir // ftnfrm.cxx:
87cdf0e10cSrcweir void lcl_RemoveFtns( SwFtnBossFrm* pBoss, sal_Bool bPageOnly, sal_Bool bEndNotes );
88cdf0e10cSrcweir 
89cdf0e10cSrcweir using namespace ::com::sun::star;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 
92cdf0e10cSrcweir sal_Bool bObjsDirect = sal_True;
93cdf0e10cSrcweir sal_Bool bDontCreateObjects = sal_False;
94cdf0e10cSrcweir sal_Bool bSetCompletePaintOnInvalidate = sal_False;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir sal_uInt8 StackHack::nCnt = 0;
97cdf0e10cSrcweir sal_Bool StackHack::bLocked = sal_False;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 
101cdf0e10cSrcweir /*************************************************************************/
102cdf0e10cSrcweir 
SwFrmNotify(SwFrm * pF)103cdf0e10cSrcweir SwFrmNotify::SwFrmNotify( SwFrm *pF ) :
104cdf0e10cSrcweir     pFrm( pF ),
105cdf0e10cSrcweir     aFrm( pF->Frm() ),
106cdf0e10cSrcweir     aPrt( pF->Prt() ),
107cdf0e10cSrcweir     bInvaKeep( sal_False ),
108cdf0e10cSrcweir     bValidSize( pF->GetValidSizeFlag() ),
109cdf0e10cSrcweir     mbFrmDeleted( false ) // #i49383#
110cdf0e10cSrcweir {
111cdf0e10cSrcweir     if ( pF->IsTxtFrm() )
112cdf0e10cSrcweir     {
113cdf0e10cSrcweir         mnFlyAnchorOfst = ((SwTxtFrm*)pF)->GetBaseOfstForFly( sal_True );
114cdf0e10cSrcweir         mnFlyAnchorOfstNoWrap = ((SwTxtFrm*)pF)->GetBaseOfstForFly( sal_False );
115cdf0e10cSrcweir     }
116cdf0e10cSrcweir     else
117cdf0e10cSrcweir     {
118cdf0e10cSrcweir         mnFlyAnchorOfst = 0;
119cdf0e10cSrcweir         mnFlyAnchorOfstNoWrap = 0;
120cdf0e10cSrcweir     }
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     bHadFollow = pF->IsCntntFrm() ?
123cdf0e10cSrcweir                     (((SwCntntFrm*)pF)->GetFollow() ? sal_True : sal_False) :
124cdf0e10cSrcweir                     sal_False;
125cdf0e10cSrcweir }
126cdf0e10cSrcweir 
127cdf0e10cSrcweir /*************************************************************************/
128cdf0e10cSrcweir 
~SwFrmNotify()129cdf0e10cSrcweir SwFrmNotify::~SwFrmNotify()
130cdf0e10cSrcweir {
131cdf0e10cSrcweir     // #i49383#
132cdf0e10cSrcweir     if ( mbFrmDeleted )
133cdf0e10cSrcweir     {
134cdf0e10cSrcweir         return;
135cdf0e10cSrcweir     }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     SWRECTFN( pFrm )
138cdf0e10cSrcweir     const sal_Bool bAbsP = POS_DIFF( aFrm, pFrm->Frm() );
139cdf0e10cSrcweir     const sal_Bool bChgWidth =
140cdf0e10cSrcweir             (aFrm.*fnRect->fnGetWidth)() != (pFrm->Frm().*fnRect->fnGetWidth)();
141cdf0e10cSrcweir     const sal_Bool bChgHeight =
142cdf0e10cSrcweir             (aFrm.*fnRect->fnGetHeight)()!=(pFrm->Frm().*fnRect->fnGetHeight)();
143cdf0e10cSrcweir     const sal_Bool bChgFlyBasePos = pFrm->IsTxtFrm() &&
144cdf0e10cSrcweir        ( ( mnFlyAnchorOfst != ((SwTxtFrm*)pFrm)->GetBaseOfstForFly( sal_True ) ) ||
145cdf0e10cSrcweir          ( mnFlyAnchorOfstNoWrap != ((SwTxtFrm*)pFrm)->GetBaseOfstForFly( sal_False ) ) );
146cdf0e10cSrcweir 
147cdf0e10cSrcweir     if ( pFrm->IsFlowFrm() && !pFrm->IsInFtn() )
148cdf0e10cSrcweir     {
149cdf0e10cSrcweir         SwFlowFrm *pFlow = SwFlowFrm::CastFlowFrm( pFrm );
150cdf0e10cSrcweir 
151cdf0e10cSrcweir         if ( !pFlow->IsFollow() )
152cdf0e10cSrcweir         {
153cdf0e10cSrcweir             if ( !pFrm->GetIndPrev() )
154cdf0e10cSrcweir             {
155cdf0e10cSrcweir                 if ( bInvaKeep )
156cdf0e10cSrcweir                 {
157cdf0e10cSrcweir                     SwFrm *pPre = pFrm->FindPrev();
158cdf0e10cSrcweir                     if ( pPre && pPre->IsFlowFrm() )
159cdf0e10cSrcweir                     {
160cdf0e10cSrcweir                         // 1. pPre wants to keep with me:
161cdf0e10cSrcweir                         bool bInvalidPrePos = SwFlowFrm::CastFlowFrm( pPre )->IsKeep( *pPre->GetAttrSet() ) && pPre->GetIndPrev();
162cdf0e10cSrcweir 
163cdf0e10cSrcweir                         // 2. pPre is a table and the last row wants to keep with me:
164cdf0e10cSrcweir                         if ( !bInvalidPrePos && pPre->IsTabFrm() )
165cdf0e10cSrcweir                         {
166cdf0e10cSrcweir                             SwTabFrm* pPreTab = static_cast<SwTabFrm*>(pPre);
167cdf0e10cSrcweir                             if ( pPreTab->GetFmt()->GetDoc()->get(IDocumentSettingAccess::TABLE_ROW_KEEP) )
168cdf0e10cSrcweir                             {
169cdf0e10cSrcweir                                 SwRowFrm* pLastRow = static_cast<SwRowFrm*>(pPreTab->GetLastLower());
170cdf0e10cSrcweir                                 if ( pLastRow && pLastRow->ShouldRowKeepWithNext() )
171cdf0e10cSrcweir                                     bInvalidPrePos = true;
172cdf0e10cSrcweir                             }
173cdf0e10cSrcweir                         }
174cdf0e10cSrcweir 
175cdf0e10cSrcweir                         if ( bInvalidPrePos )
176cdf0e10cSrcweir                             pPre->InvalidatePos();
177cdf0e10cSrcweir                     }
178cdf0e10cSrcweir                 }
179cdf0e10cSrcweir             }
180cdf0e10cSrcweir             else if ( !pFlow->HasFollow() )
181cdf0e10cSrcweir             {
182cdf0e10cSrcweir                 long nOldHeight = (aFrm.*fnRect->fnGetHeight)();
183cdf0e10cSrcweir                 long nNewHeight = (pFrm->Frm().*fnRect->fnGetHeight)();
184cdf0e10cSrcweir                 if( (nOldHeight > nNewHeight) || (!nOldHeight && nNewHeight) )
185cdf0e10cSrcweir                     pFlow->CheckKeep();
186cdf0e10cSrcweir             }
187cdf0e10cSrcweir         }
188cdf0e10cSrcweir     }
189cdf0e10cSrcweir 
190cdf0e10cSrcweir     if ( bAbsP )
191cdf0e10cSrcweir     {
192cdf0e10cSrcweir         pFrm->SetCompletePaint();
193cdf0e10cSrcweir 
194cdf0e10cSrcweir         SwFrm* pNxt = pFrm->GetIndNext();
195cdf0e10cSrcweir         // #121888# - skip empty section frames
196cdf0e10cSrcweir         while ( pNxt &&
197cdf0e10cSrcweir                 pNxt->IsSctFrm() && !static_cast<SwSectionFrm*>(pNxt)->GetSection() )
198cdf0e10cSrcweir         {
199cdf0e10cSrcweir             pNxt = pNxt->GetIndNext();
200cdf0e10cSrcweir         }
201cdf0e10cSrcweir 
202cdf0e10cSrcweir         if ( pNxt )
203cdf0e10cSrcweir             pNxt->InvalidatePos();
204cdf0e10cSrcweir         else
205cdf0e10cSrcweir         {
206cdf0e10cSrcweir             // #104100# - correct condition for setting retouche
207cdf0e10cSrcweir             // flag for vertical layout.
208cdf0e10cSrcweir             if( pFrm->IsRetoucheFrm() &&
209cdf0e10cSrcweir                 (aFrm.*fnRect->fnTopDist)( (pFrm->Frm().*fnRect->fnGetTop)() ) > 0 )
210cdf0e10cSrcweir             {
211cdf0e10cSrcweir                 pFrm->SetRetouche();
212cdf0e10cSrcweir             }
213cdf0e10cSrcweir 
214cdf0e10cSrcweir             // A fresh follow frame does not have to be invalidated, because
215cdf0e10cSrcweir             // it is already formatted:
216cdf0e10cSrcweir             if ( bHadFollow || !pFrm->IsCntntFrm() || !((SwCntntFrm*)pFrm)->GetFollow() )
217cdf0e10cSrcweir             {
218cdf0e10cSrcweir                 if ( !pFrm->IsTabFrm() || !((SwTabFrm*)pFrm)->GetFollow() )
219cdf0e10cSrcweir                     pFrm->InvalidateNextPos();
220cdf0e10cSrcweir             }
221cdf0e10cSrcweir         }
222cdf0e10cSrcweir     }
223cdf0e10cSrcweir 
224cdf0e10cSrcweir     //Fuer Hintergrundgrafiken muss bei Groessenaenderungen ein Repaint her.
225cdf0e10cSrcweir     const sal_Bool bPrtWidth =
226cdf0e10cSrcweir             (aPrt.*fnRect->fnGetWidth)() != (pFrm->Prt().*fnRect->fnGetWidth)();
227cdf0e10cSrcweir     const sal_Bool bPrtHeight =
228cdf0e10cSrcweir             (aPrt.*fnRect->fnGetHeight)()!=(pFrm->Prt().*fnRect->fnGetHeight)();
229cdf0e10cSrcweir     if ( bPrtWidth || bPrtHeight )
230cdf0e10cSrcweir     {
23156b35d86SArmin Le Grand         //UUUU
23256b35d86SArmin Le Grand         drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFillAttributes(pFrm->getSdrAllFillAttributesHelper());
23356b35d86SArmin Le Grand 
23456b35d86SArmin Le Grand         if(aFillAttributes.get() && aFillAttributes->isUsed())
23556b35d86SArmin Le Grand         {
23656b35d86SArmin Le Grand             //UUUU use SetCompletePaint if needed
23756b35d86SArmin Le Grand             if(aFillAttributes->needCompleteRepaint())
23856b35d86SArmin Le Grand             {
23956b35d86SArmin Le Grand                 pFrm->SetCompletePaint();
24056b35d86SArmin Le Grand             }
24156b35d86SArmin Le Grand         }
24256b35d86SArmin Le Grand         else
24356b35d86SArmin Le Grand         {
244cdf0e10cSrcweir             const SvxGraphicPosition ePos = pFrm->GetAttrSet()->GetBackground().GetGraphicPos();
245cdf0e10cSrcweir             if(GPOS_NONE != ePos && GPOS_TILED != ePos)
246cdf0e10cSrcweir                 pFrm->SetCompletePaint();
247cdf0e10cSrcweir         }
24856b35d86SArmin Le Grand     }
249cdf0e10cSrcweir     else
250cdf0e10cSrcweir     {
251cdf0e10cSrcweir         // #97597# - consider case that *only* margins between
252cdf0e10cSrcweir         // frame and printing area has changed. Then, frame has to be repainted,
253cdf0e10cSrcweir         // in order to force paint of the margin areas.
254cdf0e10cSrcweir         if ( !bAbsP && (bChgWidth || bChgHeight) )
255cdf0e10cSrcweir         {
256cdf0e10cSrcweir             pFrm->SetCompletePaint();
257cdf0e10cSrcweir         }
258cdf0e10cSrcweir     }
259cdf0e10cSrcweir 
260cdf0e10cSrcweir     const sal_Bool bPrtP = POS_DIFF( aPrt, pFrm->Prt() );
261cdf0e10cSrcweir     if ( bAbsP || bPrtP || bChgWidth || bChgHeight ||
262cdf0e10cSrcweir          bPrtWidth || bPrtHeight || bChgFlyBasePos )
263cdf0e10cSrcweir     {
264cdf0e10cSrcweir         if( pFrm->IsAccessibleFrm() )
265cdf0e10cSrcweir         {
266cdf0e10cSrcweir             SwRootFrm *pRootFrm = pFrm->getRootFrm();
267cdf0e10cSrcweir             if( pRootFrm && pRootFrm->IsAnyShellAccessible() &&
268cdf0e10cSrcweir                 pRootFrm->GetCurrShell() )
269cdf0e10cSrcweir             {
270cdf0e10cSrcweir                 pRootFrm->GetCurrShell()->Imp()->MoveAccessibleFrm( pFrm, aFrm );
271cdf0e10cSrcweir             }
272cdf0e10cSrcweir         }
273cdf0e10cSrcweir 
274cdf0e10cSrcweir         // Notification of anchored objects
275cdf0e10cSrcweir         if ( pFrm->GetDrawObjs() )
276cdf0e10cSrcweir         {
277cdf0e10cSrcweir             const SwSortedObjs &rObjs = *pFrm->GetDrawObjs();
278cdf0e10cSrcweir             SwPageFrm* pPageFrm = 0;
279cdf0e10cSrcweir             for ( sal_uInt32 i = 0; i < rObjs.Count(); ++i )
280cdf0e10cSrcweir             {
281cdf0e10cSrcweir                 // OD 2004-03-31 #i26791# - no general distinction between
282cdf0e10cSrcweir                 // Writer fly frames and drawing objects
283cdf0e10cSrcweir                 bool bNotify = false;
284cdf0e10cSrcweir                 bool bNotifySize = false;
285cdf0e10cSrcweir                 SwAnchoredObject* pObj = rObjs[i];
286cdf0e10cSrcweir                 SwContact* pContact = ::GetUserCall( pObj->GetDrawObj() );
287cdf0e10cSrcweir                 // --> OD 2004-12-08 #115759#
288cdf0e10cSrcweir                 const bool bAnchoredAsChar = pContact->ObjAnchoredAsChar();
289cdf0e10cSrcweir                 if ( !bAnchoredAsChar )
290cdf0e10cSrcweir                 // <--
291cdf0e10cSrcweir                 {
292cdf0e10cSrcweir                     // Notify object, which aren't anchored as-character:
293cdf0e10cSrcweir 
294cdf0e10cSrcweir                     // always notify objects, if frame position has changed
295cdf0e10cSrcweir                     // or if the object is to-page|to-fly anchored.
296cdf0e10cSrcweir                     if ( bAbsP ||
297cdf0e10cSrcweir                          pContact->ObjAnchoredAtPage() ||
298cdf0e10cSrcweir                          pContact->ObjAnchoredAtFly() )
299cdf0e10cSrcweir                     {
300cdf0e10cSrcweir                         bNotify = true;
301cdf0e10cSrcweir 
302cdf0e10cSrcweir                         // assure that to-fly anchored Writer fly frames are
303cdf0e10cSrcweir                         // registered at the correct page frame, if frame
304cdf0e10cSrcweir                         // position has changed.
305cdf0e10cSrcweir                         if ( bAbsP && pContact->ObjAnchoredAtFly() &&
306cdf0e10cSrcweir                              pObj->ISA(SwFlyFrm) )
307cdf0e10cSrcweir                         {
308cdf0e10cSrcweir                             // determine to-fly anchored Writer fly frame
309cdf0e10cSrcweir                             SwFlyFrm* pFlyFrm = static_cast<SwFlyFrm*>(pObj);
310cdf0e10cSrcweir                             // determine page frame of to-fly anchored
311cdf0e10cSrcweir                             // Writer fly frame
312cdf0e10cSrcweir                             SwPageFrm* pFlyPageFrm = pFlyFrm->FindPageFrm();
313cdf0e10cSrcweir                             // determine page frame, if needed.
314cdf0e10cSrcweir                             if ( !pPageFrm )
315cdf0e10cSrcweir                             {
316cdf0e10cSrcweir                                 pPageFrm = pFrm->FindPageFrm();
317cdf0e10cSrcweir                             }
318cdf0e10cSrcweir                             if ( pPageFrm != pFlyPageFrm )
319cdf0e10cSrcweir                             {
320cdf0e10cSrcweir                                 ASSERT( pFlyPageFrm, "~SwFrmNotify: Fly from Nowhere" );
321cdf0e10cSrcweir                                 if( pFlyPageFrm )
322cdf0e10cSrcweir                                     pFlyPageFrm->MoveFly( pFlyFrm, pPageFrm );
323cdf0e10cSrcweir                                 else
324cdf0e10cSrcweir                                     pPageFrm->AppendFlyToPage( pFlyFrm );
325cdf0e10cSrcweir                             }
326cdf0e10cSrcweir                         }
327cdf0e10cSrcweir                     }
328cdf0e10cSrcweir                     // otherwise the objects are notified in dependence to
329cdf0e10cSrcweir                     // its positioning and alignment
330cdf0e10cSrcweir                     else
331cdf0e10cSrcweir                     {
332cdf0e10cSrcweir                         const SwFmtVertOrient& rVert =
333cdf0e10cSrcweir                                         pContact->GetFmt()->GetVertOrient();
334cdf0e10cSrcweir                         if ( ( rVert.GetVertOrient() == text::VertOrientation::CENTER ||
335cdf0e10cSrcweir                                rVert.GetVertOrient() == text::VertOrientation::BOTTOM ||
336cdf0e10cSrcweir                                rVert.GetRelationOrient() == text::RelOrientation::PRINT_AREA ) &&
337cdf0e10cSrcweir                              ( bChgHeight || bPrtHeight ) )
338cdf0e10cSrcweir                         {
339cdf0e10cSrcweir                             bNotify = true;
340cdf0e10cSrcweir                         }
341cdf0e10cSrcweir                         if ( !bNotify )
342cdf0e10cSrcweir                         {
343cdf0e10cSrcweir                             const SwFmtHoriOrient& rHori =
344cdf0e10cSrcweir                                         pContact->GetFmt()->GetHoriOrient();
345cdf0e10cSrcweir                             if ( ( rHori.GetHoriOrient() != text::HoriOrientation::NONE ||
346cdf0e10cSrcweir                                    rHori.GetRelationOrient()== text::RelOrientation::PRINT_AREA ||
347cdf0e10cSrcweir                                    rHori.GetRelationOrient()== text::RelOrientation::FRAME ) &&
348cdf0e10cSrcweir                                  ( bChgWidth || bPrtWidth || bChgFlyBasePos ) )
349cdf0e10cSrcweir                             {
350cdf0e10cSrcweir                                 bNotify = true;
351cdf0e10cSrcweir                             }
352cdf0e10cSrcweir                         }
353cdf0e10cSrcweir                     }
354cdf0e10cSrcweir                 }
355cdf0e10cSrcweir                 else if ( bPrtWidth )
356cdf0e10cSrcweir                 {
357cdf0e10cSrcweir                     // Notify as-character anchored objects, if printing area
358cdf0e10cSrcweir                     // width has changed.
359cdf0e10cSrcweir                     bNotify = true;
360cdf0e10cSrcweir                     bNotifySize = true;
361cdf0e10cSrcweir                 }
362cdf0e10cSrcweir 
363cdf0e10cSrcweir                 // perform notification via the corresponding invalidations
364cdf0e10cSrcweir                 if ( bNotify )
365cdf0e10cSrcweir                 {
366cdf0e10cSrcweir                     if ( pObj->ISA(SwFlyFrm) )
367cdf0e10cSrcweir                     {
368cdf0e10cSrcweir                         SwFlyFrm* pFlyFrm = static_cast<SwFlyFrm*>(pObj);
369cdf0e10cSrcweir                         if ( bNotifySize )
370cdf0e10cSrcweir                             pFlyFrm->_InvalidateSize();
371cdf0e10cSrcweir                         // --> OD 2004-12-08 #115759# - no invalidation of
372cdf0e10cSrcweir                         // position for as-character anchored objects.
373cdf0e10cSrcweir                         if ( !bAnchoredAsChar )
374cdf0e10cSrcweir                         {
375cdf0e10cSrcweir                             pFlyFrm->_InvalidatePos();
376cdf0e10cSrcweir                         }
377cdf0e10cSrcweir                         // <--
378cdf0e10cSrcweir                         pFlyFrm->_Invalidate();
379cdf0e10cSrcweir                     }
380cdf0e10cSrcweir                     else if ( pObj->ISA(SwAnchoredDrawObject) )
381cdf0e10cSrcweir                     {
382cdf0e10cSrcweir                         // --> OD 2004-12-08 #115759# - no invalidation of
383cdf0e10cSrcweir                         // position for as-character anchored objects.
384cdf0e10cSrcweir                         if ( !bAnchoredAsChar )
385cdf0e10cSrcweir                         {
386cdf0e10cSrcweir                             pObj->InvalidateObjPos();
387cdf0e10cSrcweir                         }
388cdf0e10cSrcweir                         // <--
389cdf0e10cSrcweir                     }
390cdf0e10cSrcweir                     else
391cdf0e10cSrcweir                     {
392cdf0e10cSrcweir                         ASSERT( false,
393cdf0e10cSrcweir                                 "<SwCntntNotify::~SwCntntNotify()> - unknown anchored object type. Please inform OD." );
394cdf0e10cSrcweir                     }
395cdf0e10cSrcweir                 }
396cdf0e10cSrcweir             }
397cdf0e10cSrcweir         }
398cdf0e10cSrcweir     }
399cdf0e10cSrcweir     else if( pFrm->IsTxtFrm() && bValidSize != pFrm->GetValidSizeFlag() )
400cdf0e10cSrcweir     {
401cdf0e10cSrcweir         SwRootFrm *pRootFrm = pFrm->getRootFrm();
402cdf0e10cSrcweir         if( pRootFrm && pRootFrm->IsAnyShellAccessible() &&
403cdf0e10cSrcweir             pRootFrm->GetCurrShell() )
404cdf0e10cSrcweir         {
405cdf0e10cSrcweir             pRootFrm->GetCurrShell()->Imp()->InvalidateAccessibleFrmContent( pFrm );
406cdf0e10cSrcweir         }
407cdf0e10cSrcweir     }
408cdf0e10cSrcweir 
409cdf0e10cSrcweir     // #i9046# Automatic frame width
410cdf0e10cSrcweir     SwFlyFrm* pFly = 0;
411cdf0e10cSrcweir     // --> FME 2004-10-21 #i35879# Do not trust the inf flags. pFrm does not
412cdf0e10cSrcweir     // necessarily have to have an upper!
413cdf0e10cSrcweir     if ( !pFrm->IsFlyFrm() && 0 != ( pFly = pFrm->ImplFindFlyFrm() ) )
414cdf0e10cSrcweir     // <--
415cdf0e10cSrcweir     {
416cdf0e10cSrcweir         // --> OD 2006-05-08 #i61999#
417cdf0e10cSrcweir         // no invalidation of columned Writer fly frames, because automatic
418cdf0e10cSrcweir         // width doesn't make sense for such Writer fly frames.
419cdf0e10cSrcweir         if ( pFly->Lower() && !pFly->Lower()->IsColumnFrm() )
420cdf0e10cSrcweir         {
421cdf0e10cSrcweir             const SwFmtFrmSize &rFrmSz = pFly->GetFmt()->GetFrmSize();
422cdf0e10cSrcweir 
423cdf0e10cSrcweir             // This could be optimized. Basically the fly frame only has to
424cdf0e10cSrcweir             // be invalidated, if the first line of pFrm (if pFrm is a content
425cdf0e10cSrcweir             // frame, for other frame types its the print area) has changed its
426cdf0e10cSrcweir             // size and pFrm was responsible for the current width of pFly. On
427cdf0e10cSrcweir             // the other hand, this is only rarely used and re-calculation of
428cdf0e10cSrcweir             // the fly frame does not cause too much trouble. So we keep it this
429cdf0e10cSrcweir             // way:
430cdf0e10cSrcweir             if ( ATT_FIX_SIZE != rFrmSz.GetWidthSizeType() )
431cdf0e10cSrcweir             {
432cdf0e10cSrcweir                 // --> OD 2005-07-29 #i50668#, #i50998# - invalidation of position
433cdf0e10cSrcweir                 // of as-character anchored fly frames not needed and can cause
434cdf0e10cSrcweir                 // layout loops
435cdf0e10cSrcweir                 if ( !pFly->ISA(SwFlyInCntFrm) )
436cdf0e10cSrcweir                 {
437cdf0e10cSrcweir                     pFly->InvalidatePos();
438cdf0e10cSrcweir                 }
439cdf0e10cSrcweir                 // <--
440cdf0e10cSrcweir                 pFly->InvalidateSize();
441cdf0e10cSrcweir             }
442cdf0e10cSrcweir         }
443cdf0e10cSrcweir         // <--
444cdf0e10cSrcweir     }
445cdf0e10cSrcweir }
446cdf0e10cSrcweir 
447cdf0e10cSrcweir /*************************************************************************/
448cdf0e10cSrcweir 
SwLayNotify(SwLayoutFrm * pLayFrm)449cdf0e10cSrcweir SwLayNotify::SwLayNotify( SwLayoutFrm *pLayFrm ) :
450cdf0e10cSrcweir     SwFrmNotify( pLayFrm ),
451cdf0e10cSrcweir     bLowersComplete( sal_False )
452cdf0e10cSrcweir {
453cdf0e10cSrcweir }
454cdf0e10cSrcweir 
455cdf0e10cSrcweir /*************************************************************************/
456cdf0e10cSrcweir 
457cdf0e10cSrcweir // OD 2004-05-11 #i28701# - local method to invalidate the position of all
458cdf0e10cSrcweir // frames inclusive its floating screen objects, which are lowers of the given
459cdf0e10cSrcweir // layout frame
lcl_InvalidatePosOfLowers(SwLayoutFrm & _rLayoutFrm)460cdf0e10cSrcweir void lcl_InvalidatePosOfLowers( SwLayoutFrm& _rLayoutFrm )
461cdf0e10cSrcweir {
462cdf0e10cSrcweir     if( _rLayoutFrm.IsFlyFrm() && _rLayoutFrm.GetDrawObjs() )
463cdf0e10cSrcweir     {
464cdf0e10cSrcweir         _rLayoutFrm.InvalidateObjs( true, false );
465cdf0e10cSrcweir     }
466cdf0e10cSrcweir 
467cdf0e10cSrcweir     SwFrm* pLowerFrm = _rLayoutFrm.Lower();
468cdf0e10cSrcweir     while ( pLowerFrm )
469cdf0e10cSrcweir     {
470cdf0e10cSrcweir         pLowerFrm->InvalidatePos();
471cdf0e10cSrcweir         if ( pLowerFrm->IsTxtFrm() )
472cdf0e10cSrcweir         {
473cdf0e10cSrcweir             static_cast<SwTxtFrm*>(pLowerFrm)->Prepare( PREP_POS_CHGD );
474cdf0e10cSrcweir         }
475cdf0e10cSrcweir         else if ( pLowerFrm->IsTabFrm() )
476cdf0e10cSrcweir         {
477cdf0e10cSrcweir             pLowerFrm->InvalidatePrt();
478cdf0e10cSrcweir         }
479cdf0e10cSrcweir 
480cdf0e10cSrcweir         pLowerFrm->InvalidateObjs( true, false );
481cdf0e10cSrcweir 
482cdf0e10cSrcweir         pLowerFrm = pLowerFrm->GetNext();
483cdf0e10cSrcweir     };
484cdf0e10cSrcweir }
485cdf0e10cSrcweir 
~SwLayNotify()486cdf0e10cSrcweir SwLayNotify::~SwLayNotify()
487cdf0e10cSrcweir {
488cdf0e10cSrcweir     // --> OD 2005-07-29 #i49383#
489cdf0e10cSrcweir     if ( mbFrmDeleted )
490cdf0e10cSrcweir     {
491cdf0e10cSrcweir         return;
492cdf0e10cSrcweir     }
493cdf0e10cSrcweir     // <--
494cdf0e10cSrcweir 
495cdf0e10cSrcweir     SwLayoutFrm *pLay = GetLay();
496cdf0e10cSrcweir     SWRECTFN( pLay )
497cdf0e10cSrcweir     sal_Bool bNotify = sal_False;
498cdf0e10cSrcweir     if ( pLay->Prt().SSize() != aPrt.SSize() )
499cdf0e10cSrcweir     {
500cdf0e10cSrcweir         if ( !IsLowersComplete() )
501cdf0e10cSrcweir         {
502cdf0e10cSrcweir             sal_Bool bInvaPercent;
503cdf0e10cSrcweir 
504cdf0e10cSrcweir             if ( pLay->IsRowFrm() )
505cdf0e10cSrcweir             {
506cdf0e10cSrcweir                 bInvaPercent = sal_True;
507cdf0e10cSrcweir                 long nNew = (pLay->Prt().*fnRect->fnGetHeight)();
508cdf0e10cSrcweir                 if( nNew != (aPrt.*fnRect->fnGetHeight)() )
509cdf0e10cSrcweir                      ((SwRowFrm*)pLay)->AdjustCells( nNew, sal_True);
510cdf0e10cSrcweir                 if( (pLay->Prt().*fnRect->fnGetWidth)()
511cdf0e10cSrcweir                     != (aPrt.*fnRect->fnGetWidth)() )
512cdf0e10cSrcweir                      ((SwRowFrm*)pLay)->AdjustCells( 0, sal_False );
513cdf0e10cSrcweir             }
514cdf0e10cSrcweir             else
515cdf0e10cSrcweir             {
516cdf0e10cSrcweir                 //Proportionale Anpassung der innenliegenden.
517cdf0e10cSrcweir                 //1. Wenn der Formatierte kein Fly ist
518cdf0e10cSrcweir                 //2. Wenn er keine Spalten enthaelt
519cdf0e10cSrcweir                 //3. Wenn der Fly eine feste Hoehe hat und die Spalten in der
520cdf0e10cSrcweir                 //   Hoehe danebenliegen.
521cdf0e10cSrcweir                 //4. niemals bei SectionFrms.
522cdf0e10cSrcweir                 sal_Bool bLow;
523cdf0e10cSrcweir                 if( pLay->IsFlyFrm() )
524cdf0e10cSrcweir                 {
525cdf0e10cSrcweir                     if ( pLay->Lower() )
526cdf0e10cSrcweir                     {
527cdf0e10cSrcweir                         bLow = !pLay->Lower()->IsColumnFrm() ||
528cdf0e10cSrcweir                             (pLay->Lower()->Frm().*fnRect->fnGetHeight)()
529cdf0e10cSrcweir                              != (pLay->Prt().*fnRect->fnGetHeight)();
530cdf0e10cSrcweir                     }
531cdf0e10cSrcweir                     else
532cdf0e10cSrcweir                         bLow = sal_False;
533cdf0e10cSrcweir                 }
534cdf0e10cSrcweir                 else if( pLay->IsSctFrm() )
535cdf0e10cSrcweir                 {
536cdf0e10cSrcweir                     if ( pLay->Lower() )
537cdf0e10cSrcweir                     {
538cdf0e10cSrcweir                         if( pLay->Lower()->IsColumnFrm() && pLay->Lower()->GetNext() )
539cdf0e10cSrcweir                             bLow = pLay->Lower()->Frm().Height() != pLay->Prt().Height();
540cdf0e10cSrcweir                         else
541cdf0e10cSrcweir                             bLow = pLay->Prt().Width() != aPrt.Width();
542cdf0e10cSrcweir                     }
543cdf0e10cSrcweir                     else
544cdf0e10cSrcweir                         bLow = sal_False;
545cdf0e10cSrcweir                 }
546cdf0e10cSrcweir                 else if( pLay->IsFooterFrm() && !pLay->HasFixSize() )
547cdf0e10cSrcweir                     bLow = pLay->Prt().Width() != aPrt.Width();
548cdf0e10cSrcweir                 else
549cdf0e10cSrcweir                     bLow = sal_True;
550cdf0e10cSrcweir                 bInvaPercent = bLow;
551cdf0e10cSrcweir                 if ( bLow )
552cdf0e10cSrcweir                 {
553cdf0e10cSrcweir                     pLay->ChgLowersProp( aPrt.SSize() );
554cdf0e10cSrcweir                 }
555cdf0e10cSrcweir                 //Wenn die PrtArea gewachsen ist, so ist es moeglich, dass die
556cdf0e10cSrcweir                 //Kette der Untergeordneten einen weiteren Frm aufnehmen kann,
557cdf0e10cSrcweir                 //mithin muss also der 'moeglicherweise passende' Invalidiert werden.
558cdf0e10cSrcweir                 //Das invalidieren lohnt nur, wenn es sich beim mir bzw. meinen
559cdf0e10cSrcweir                 //Uppers um eine Moveable-Section handelt.
560cdf0e10cSrcweir                 //Die PrtArea ist gewachsen, wenn die Breite oder die Hoehe groesser
561cdf0e10cSrcweir                 //geworden ist.
562cdf0e10cSrcweir                 if ( (pLay->Prt().Height() > aPrt.Height() ||
563cdf0e10cSrcweir                       pLay->Prt().Width()  > aPrt.Width()) &&
564cdf0e10cSrcweir                      (pLay->IsMoveable() || pLay->IsFlyFrm()) )
565cdf0e10cSrcweir                 {
566cdf0e10cSrcweir                     SwFrm *pTmpFrm = pLay->Lower();
567cdf0e10cSrcweir                     if ( pTmpFrm && pTmpFrm->IsFlowFrm() )
568cdf0e10cSrcweir                     {
569cdf0e10cSrcweir                         while ( pTmpFrm->GetNext() )
570cdf0e10cSrcweir                             pTmpFrm = pTmpFrm->GetNext();
571cdf0e10cSrcweir                         pTmpFrm->InvalidateNextPos();
572cdf0e10cSrcweir                     }
573cdf0e10cSrcweir                 }
574cdf0e10cSrcweir             }
575cdf0e10cSrcweir             bNotify = sal_True;
576cdf0e10cSrcweir             //TEUER!! aber wie macht man es geschickter?
577cdf0e10cSrcweir             if( bInvaPercent )
578cdf0e10cSrcweir                 pLay->InvaPercentLowers( pLay->Prt().Height() - aPrt.Height() );
579cdf0e10cSrcweir         }
580cdf0e10cSrcweir         if ( pLay->IsTabFrm() )
581*6e8337c1Smseidel             //Damit _nur_ der Schatten bei Groessenaenderungen gemalt wird.
582cdf0e10cSrcweir             ((SwTabFrm*)pLay)->SetComplete();
583cdf0e10cSrcweir         else
584cdf0e10cSrcweir         {
585cdf0e10cSrcweir             const ViewShell *pSh = pLay->getRootFrm()->GetCurrShell();
586cdf0e10cSrcweir             if( !( pSh && pSh->GetViewOptions()->getBrowseMode() ) ||
587cdf0e10cSrcweir                   !(pLay->GetType() & (FRM_BODY | FRM_PAGE)) )
588cdf0e10cSrcweir             //Damit die untergeordneten sauber retouchiert werden.
589cdf0e10cSrcweir             //Problembsp: Flys an den Henkeln packen und verkleinern.
590cdf0e10cSrcweir             //Nicht fuer Body und Page, sonst flackerts beim HTML-Laden.
591cdf0e10cSrcweir             pLay->SetCompletePaint();
592cdf0e10cSrcweir         }
593cdf0e10cSrcweir     }
594cdf0e10cSrcweir     //Lower benachrichtigen wenn sich die Position veraendert hat.
595cdf0e10cSrcweir     const sal_Bool bPrtPos = POS_DIFF( aPrt, pLay->Prt() );
596cdf0e10cSrcweir     const sal_Bool bPos = bPrtPos || POS_DIFF( aFrm, pLay->Frm() );
597cdf0e10cSrcweir     const sal_Bool bSize = pLay->Frm().SSize() != aFrm.SSize();
598cdf0e10cSrcweir 
599cdf0e10cSrcweir     if ( bPos && pLay->Lower() && !IsLowersComplete() )
600cdf0e10cSrcweir         pLay->Lower()->InvalidatePos();
601cdf0e10cSrcweir 
602cdf0e10cSrcweir     if ( bPrtPos )
603cdf0e10cSrcweir         pLay->SetCompletePaint();
604cdf0e10cSrcweir 
605cdf0e10cSrcweir     //Nachfolger benachrichtigen wenn sich die SSize geaendert hat.
606cdf0e10cSrcweir     if ( bSize )
607cdf0e10cSrcweir     {
608cdf0e10cSrcweir         if( pLay->GetNext() )
609cdf0e10cSrcweir         {
610cdf0e10cSrcweir             if ( pLay->GetNext()->IsLayoutFrm() )
611cdf0e10cSrcweir                 pLay->GetNext()->_InvalidatePos();
612cdf0e10cSrcweir             else
613cdf0e10cSrcweir                 pLay->GetNext()->InvalidatePos();
614cdf0e10cSrcweir         }
615cdf0e10cSrcweir         else if( pLay->IsSctFrm() )
616cdf0e10cSrcweir             pLay->InvalidateNextPos();
617cdf0e10cSrcweir     }
618cdf0e10cSrcweir     if ( !IsLowersComplete() &&
619cdf0e10cSrcweir          !(pLay->GetType()&(FRM_FLY|FRM_SECTION) &&
620cdf0e10cSrcweir             pLay->Lower() && pLay->Lower()->IsColumnFrm()) &&
621cdf0e10cSrcweir          (bPos || bNotify) && !(pLay->GetType() & 0x1823) ) //Tab, Row, FtnCont, Root, Page
622cdf0e10cSrcweir     {
623cdf0e10cSrcweir         // --> OD 2005-03-11 #i44016# - force unlock of position of lower objects.
624cdf0e10cSrcweir         // --> OD 2005-03-30 #i43913# - no unlock of position of objects,
625cdf0e10cSrcweir         // if <pLay> is a cell frame, and its table frame resp. its parent table
626cdf0e10cSrcweir         // frame is locked.
627cdf0e10cSrcweir         // --> OD 2005-04-15 #i47458# - force unlock of position of lower objects,
628cdf0e10cSrcweir         // only if position of layout frame has changed.
629cdf0e10cSrcweir         bool bUnlockPosOfObjs( bPos );
630cdf0e10cSrcweir         if ( bUnlockPosOfObjs && pLay->IsCellFrm() )
631cdf0e10cSrcweir         {
632cdf0e10cSrcweir             SwTabFrm* pTabFrm( pLay->FindTabFrm() );
633cdf0e10cSrcweir             if ( pTabFrm &&
634cdf0e10cSrcweir                  ( pTabFrm->IsJoinLocked() ||
635cdf0e10cSrcweir                    ( pTabFrm->IsFollow() &&
636cdf0e10cSrcweir                      pTabFrm->FindMaster()->IsJoinLocked() ) ) )
637cdf0e10cSrcweir             {
638cdf0e10cSrcweir                 bUnlockPosOfObjs = false;
639cdf0e10cSrcweir             }
640cdf0e10cSrcweir         }
641cdf0e10cSrcweir         // --> OD 2005-05-18 #i49383# - check for footnote frame, if unlock
642cdf0e10cSrcweir         // of position of lower objects is allowed.
643cdf0e10cSrcweir         else if ( bUnlockPosOfObjs && pLay->IsFtnFrm() )
644cdf0e10cSrcweir         {
645cdf0e10cSrcweir             bUnlockPosOfObjs = static_cast<SwFtnFrm*>(pLay)->IsUnlockPosOfLowerObjs();
646cdf0e10cSrcweir         }
647cdf0e10cSrcweir         // <--
648cdf0e10cSrcweir         // --> OD 2005-07-29 #i51303# - no unlock of object positions for sections
649cdf0e10cSrcweir         else if ( bUnlockPosOfObjs && pLay->IsSctFrm() )
650cdf0e10cSrcweir         {
651cdf0e10cSrcweir             bUnlockPosOfObjs = false;
652cdf0e10cSrcweir         }
653cdf0e10cSrcweir         // <--
654cdf0e10cSrcweir         pLay->NotifyLowerObjs( bUnlockPosOfObjs );
655cdf0e10cSrcweir         // <--
656cdf0e10cSrcweir     }
657cdf0e10cSrcweir     if ( bPos && pLay->IsFtnFrm() && pLay->Lower() )
658cdf0e10cSrcweir     {
659cdf0e10cSrcweir         // OD 2004-05-11 #i28701#
660cdf0e10cSrcweir         ::lcl_InvalidatePosOfLowers( *pLay );
661cdf0e10cSrcweir     }
662cdf0e10cSrcweir     if( ( bPos || bSize ) && pLay->IsFlyFrm() && ((SwFlyFrm*)pLay)->GetAnchorFrm()
663cdf0e10cSrcweir           && ((SwFlyFrm*)pLay)->GetAnchorFrm()->IsFlyFrm() )
664cdf0e10cSrcweir         ((SwFlyFrm*)pLay)->AnchorFrm()->InvalidateSize();
665cdf0e10cSrcweir }
666cdf0e10cSrcweir 
667cdf0e10cSrcweir /*************************************************************************/
668cdf0e10cSrcweir 
SwFlyNotify(SwFlyFrm * pFlyFrm)669cdf0e10cSrcweir SwFlyNotify::SwFlyNotify( SwFlyFrm *pFlyFrm ) :
670cdf0e10cSrcweir     SwLayNotify( pFlyFrm ),
671cdf0e10cSrcweir     // --> OD 2004-11-24 #115759# - keep correct page frame - the page frame
672cdf0e10cSrcweir     // the Writer fly frame is currently registered at.
673cdf0e10cSrcweir     pOldPage( pFlyFrm->GetPageFrm() ),
674cdf0e10cSrcweir     // <--
675cdf0e10cSrcweir     aFrmAndSpace( pFlyFrm->GetObjRectWithSpaces() )
676cdf0e10cSrcweir {
677cdf0e10cSrcweir }
678cdf0e10cSrcweir 
679cdf0e10cSrcweir /*************************************************************************/
680cdf0e10cSrcweir 
~SwFlyNotify()681cdf0e10cSrcweir SwFlyNotify::~SwFlyNotify()
682cdf0e10cSrcweir {
683cdf0e10cSrcweir     // --> OD 2005-07-29 #i49383#
684cdf0e10cSrcweir     if ( mbFrmDeleted )
685cdf0e10cSrcweir     {
686cdf0e10cSrcweir         return;
687cdf0e10cSrcweir     }
688cdf0e10cSrcweir     // <--
689cdf0e10cSrcweir 
690cdf0e10cSrcweir     SwFlyFrm *pFly = GetFly();
691cdf0e10cSrcweir     if ( pFly->IsNotifyBack() )
692cdf0e10cSrcweir     {
693cdf0e10cSrcweir         ViewShell *pSh = pFly->getRootFrm()->GetCurrShell();
694cdf0e10cSrcweir         SwViewImp *pImp = pSh ? pSh->Imp() : 0;
695cdf0e10cSrcweir         if ( !pImp || !pImp->IsAction() || !pImp->GetLayAction().IsAgain() )
696cdf0e10cSrcweir         {
697cdf0e10cSrcweir             //Wenn in der LayAction das IsAgain gesetzt ist kann es sein,
698cdf0e10cSrcweir             //dass die alte Seite inzwischen vernichtet wurde!
699cdf0e10cSrcweir             ::Notify( pFly, pOldPage, aFrmAndSpace, &aPrt );
700cdf0e10cSrcweir             // --> OD 2004-10-20 #i35640# - additional notify anchor text frame,
701cdf0e10cSrcweir             // if Writer fly frame has changed its page
702cdf0e10cSrcweir             if ( pFly->GetAnchorFrm()->IsTxtFrm() &&
703cdf0e10cSrcweir                  pFly->GetPageFrm() != pOldPage )
704cdf0e10cSrcweir             {
705cdf0e10cSrcweir                 pFly->AnchorFrm()->Prepare( PREP_FLY_LEAVE );
706cdf0e10cSrcweir             }
707cdf0e10cSrcweir             // <--
708cdf0e10cSrcweir         }
709cdf0e10cSrcweir         pFly->ResetNotifyBack();
710cdf0e10cSrcweir     }
711cdf0e10cSrcweir 
712cdf0e10cSrcweir     //Haben sich Groesse oder Position geaendert, so sollte die View
713cdf0e10cSrcweir     //das wissen.
714cdf0e10cSrcweir     SWRECTFN( pFly )
715cdf0e10cSrcweir     const bool bPosChgd = POS_DIFF( aFrm, pFly->Frm() );
716cdf0e10cSrcweir     const bool bFrmChgd = pFly->Frm().SSize() != aFrm.SSize();
717cdf0e10cSrcweir     const bool bPrtChgd = aPrt != pFly->Prt();
718cdf0e10cSrcweir     if ( bPosChgd || bFrmChgd || bPrtChgd )
719cdf0e10cSrcweir     {
720cdf0e10cSrcweir         pFly->NotifyDrawObj();
721cdf0e10cSrcweir     }
722cdf0e10cSrcweir     if ( bPosChgd && aFrm.Pos().X() != WEIT_WECH )
723cdf0e10cSrcweir     {
724cdf0e10cSrcweir         // OD 2004-05-10 #i28701# - no direct move of lower Writer fly frames.
725cdf0e10cSrcweir         // reason: New positioning and alignment (e.g. to-paragraph anchored,
726cdf0e10cSrcweir         // but aligned at page) are introduced.
727cdf0e10cSrcweir         // <SwLayNotify::~SwLayNotify()> takes care of invalidation of lower
728cdf0e10cSrcweir         // floating screen objects by calling method <SwLayoutFrm::NotifyLowerObjs()>.
729cdf0e10cSrcweir 
730cdf0e10cSrcweir         if ( pFly->IsFlyAtCntFrm() )
731cdf0e10cSrcweir         {
732cdf0e10cSrcweir             SwFrm *pNxt = pFly->AnchorFrm()->FindNext();
733cdf0e10cSrcweir             if ( pNxt )
734cdf0e10cSrcweir             {
735cdf0e10cSrcweir                 pNxt->InvalidatePos();
736cdf0e10cSrcweir             }
737cdf0e10cSrcweir         }
738cdf0e10cSrcweir 
739cdf0e10cSrcweir         // --> OD 2004-11-05 #i26945# - notify anchor.
740cdf0e10cSrcweir         // Needed for negative positioned Writer fly frames
741cdf0e10cSrcweir         if ( pFly->GetAnchorFrm()->IsTxtFrm() )
742cdf0e10cSrcweir         {
743cdf0e10cSrcweir             pFly->AnchorFrm()->Prepare( PREP_FLY_LEAVE );
744cdf0e10cSrcweir         }
745cdf0e10cSrcweir         // <--
746cdf0e10cSrcweir     }
747cdf0e10cSrcweir 
748cdf0e10cSrcweir     // OD 2004-05-13 #i28701#
749cdf0e10cSrcweir     // --> OD 2005-03-21 #i45180# - no adjustment of layout process flags and
750cdf0e10cSrcweir     // further notifications/invalidations, if format is called by grow/shrink
751cdf0e10cSrcweir     if ( pFly->ConsiderObjWrapInfluenceOnObjPos() &&
752cdf0e10cSrcweir          ( !pFly->ISA(SwFlyFreeFrm) ||
753cdf0e10cSrcweir            !static_cast<SwFlyFreeFrm*>(pFly)->IsNoMoveOnCheckClip() ) )
754cdf0e10cSrcweir     // <--
755cdf0e10cSrcweir     {
756cdf0e10cSrcweir         // --> OD 2005-09-05 #i54138# - suppress restart of the layout process
757cdf0e10cSrcweir         // on changed frame height.
758cdf0e10cSrcweir         // Note: It doesn't seem to be necessary and can cause layout loops.
759cdf0e10cSrcweir         if ( bPosChgd )
760cdf0e10cSrcweir         // <--
761cdf0e10cSrcweir         {
762cdf0e10cSrcweir             // indicate a restart of the layout process
763cdf0e10cSrcweir             pFly->SetRestartLayoutProcess( true );
764cdf0e10cSrcweir         }
765cdf0e10cSrcweir         else
766cdf0e10cSrcweir         {
767cdf0e10cSrcweir             // lock position
768cdf0e10cSrcweir             pFly->LockPosition();
769cdf0e10cSrcweir 
770cdf0e10cSrcweir             if ( !pFly->ConsiderForTextWrap() )
771cdf0e10cSrcweir             {
772cdf0e10cSrcweir                 // indicate that object has to be considered for text wrap
773cdf0e10cSrcweir                 pFly->SetConsiderForTextWrap( true );
774cdf0e10cSrcweir                 // invalidate 'background' in order to allow its 'background'
775cdf0e10cSrcweir                 // to wrap around it.
776cdf0e10cSrcweir                 pFly->NotifyBackground( pFly->GetPageFrm(),
777cdf0e10cSrcweir                                         pFly->GetObjRectWithSpaces(),
778cdf0e10cSrcweir                                         PREP_FLY_ARRIVE );
779cdf0e10cSrcweir                 // invalidate position of anchor frame in order to force
780cdf0e10cSrcweir                 // a re-format of the anchor frame, which also causes a
781cdf0e10cSrcweir                 // re-format of the invalid previous frames of the anchor frame.
782cdf0e10cSrcweir                 pFly->AnchorFrm()->InvalidatePos();
783cdf0e10cSrcweir             }
784cdf0e10cSrcweir         }
785cdf0e10cSrcweir     }
786cdf0e10cSrcweir }
787cdf0e10cSrcweir 
788cdf0e10cSrcweir /*************************************************************************/
789cdf0e10cSrcweir 
SwCntntNotify(SwCntntFrm * pCntntFrm)790cdf0e10cSrcweir SwCntntNotify::SwCntntNotify( SwCntntFrm *pCntntFrm ) :
791cdf0e10cSrcweir     SwFrmNotify( pCntntFrm ),
792cdf0e10cSrcweir     // OD 08.01.2004 #i11859#
793cdf0e10cSrcweir     mbChkHeightOfLastLine( false ),
794cdf0e10cSrcweir     mnHeightOfLastLine( 0L ),
795cdf0e10cSrcweir     // OD 2004-02-26 #i25029#
796cdf0e10cSrcweir     mbInvalidatePrevPrtArea( false ),
797cdf0e10cSrcweir     mbBordersJoinedWithPrev( false )
798cdf0e10cSrcweir {
799cdf0e10cSrcweir     // OD 08.01.2004 #i11859#
800cdf0e10cSrcweir     if ( pCntntFrm->IsTxtFrm() )
801cdf0e10cSrcweir     {
802cdf0e10cSrcweir         SwTxtFrm* pTxtFrm = static_cast<SwTxtFrm*>(pCntntFrm);
803cdf0e10cSrcweir         if ( !pTxtFrm->GetTxtNode()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::OLD_LINE_SPACING) )
804cdf0e10cSrcweir         {
805cdf0e10cSrcweir             const SwAttrSet* pSet = pTxtFrm->GetAttrSet();
806cdf0e10cSrcweir             const SvxLineSpacingItem &rSpace = pSet->GetLineSpacing();
807cdf0e10cSrcweir             if ( rSpace.GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_PROP )
808cdf0e10cSrcweir             {
809cdf0e10cSrcweir                 mbChkHeightOfLastLine = true;
810cdf0e10cSrcweir                 mnHeightOfLastLine = pTxtFrm->GetHeightOfLastLine();
811cdf0e10cSrcweir             }
812cdf0e10cSrcweir         }
813cdf0e10cSrcweir     }
814cdf0e10cSrcweir }
815cdf0e10cSrcweir 
816cdf0e10cSrcweir /*************************************************************************/
817cdf0e10cSrcweir 
~SwCntntNotify()818cdf0e10cSrcweir SwCntntNotify::~SwCntntNotify()
819cdf0e10cSrcweir {
820cdf0e10cSrcweir     // --> OD 2005-07-29 #i49383#
821cdf0e10cSrcweir     if ( mbFrmDeleted )
822cdf0e10cSrcweir     {
823cdf0e10cSrcweir         return;
824cdf0e10cSrcweir     }
825cdf0e10cSrcweir     // <--
826cdf0e10cSrcweir 
827cdf0e10cSrcweir     SwCntntFrm *pCnt = GetCnt();
828cdf0e10cSrcweir     if ( bSetCompletePaintOnInvalidate )
829cdf0e10cSrcweir         pCnt->SetCompletePaint();
830cdf0e10cSrcweir 
831cdf0e10cSrcweir     SWRECTFN( pCnt )
832cdf0e10cSrcweir     if ( pCnt->IsInTab() && ( POS_DIFF( pCnt->Frm(), aFrm ) ||
833cdf0e10cSrcweir                              pCnt->Frm().SSize() != aFrm.SSize()))
834cdf0e10cSrcweir     {
835cdf0e10cSrcweir         SwLayoutFrm* pCell = pCnt->GetUpper();
836cdf0e10cSrcweir         while( !pCell->IsCellFrm() && pCell->GetUpper() )
837cdf0e10cSrcweir             pCell = pCell->GetUpper();
838cdf0e10cSrcweir         ASSERT( pCell->IsCellFrm(), "Where's my cell?" );
839cdf0e10cSrcweir         if ( text::VertOrientation::NONE != pCell->GetFmt()->GetVertOrient().GetVertOrient() )
840*6e8337c1Smseidel             pCell->InvalidatePrt(); // for vertical alignment
841cdf0e10cSrcweir     }
842cdf0e10cSrcweir 
843cdf0e10cSrcweir     // OD 2004-02-26 #i25029#
844cdf0e10cSrcweir     if ( mbInvalidatePrevPrtArea && mbBordersJoinedWithPrev &&
845cdf0e10cSrcweir          pCnt->IsTxtFrm() &&
846cdf0e10cSrcweir          !pCnt->IsFollow() && !pCnt->GetIndPrev() )
847cdf0e10cSrcweir     {
848cdf0e10cSrcweir         // determine previous frame
849cdf0e10cSrcweir         SwFrm* pPrevFrm = pCnt->FindPrev();
850cdf0e10cSrcweir         // skip empty section frames and hidden text frames
851cdf0e10cSrcweir         {
852cdf0e10cSrcweir             while ( pPrevFrm &&
853cdf0e10cSrcweir                     ( ( pPrevFrm->IsSctFrm() &&
854cdf0e10cSrcweir                         !static_cast<SwSectionFrm*>(pPrevFrm)->GetSection() ) ||
855cdf0e10cSrcweir                       ( pPrevFrm->IsTxtFrm() &&
856cdf0e10cSrcweir                         static_cast<SwTxtFrm*>(pPrevFrm)->IsHiddenNow() ) ) )
857cdf0e10cSrcweir             {
858cdf0e10cSrcweir                 pPrevFrm = pPrevFrm->FindPrev();
859cdf0e10cSrcweir             }
860cdf0e10cSrcweir         }
861cdf0e10cSrcweir 
862cdf0e10cSrcweir         // Invalidate printing area of found previous frame
863cdf0e10cSrcweir         if ( pPrevFrm )
864cdf0e10cSrcweir         {
865cdf0e10cSrcweir             if ( pPrevFrm->IsSctFrm() )
866cdf0e10cSrcweir             {
867cdf0e10cSrcweir                 if ( pCnt->IsInSct() )
868cdf0e10cSrcweir                 {
869cdf0e10cSrcweir                     // Note: found previous frame is a section frame and
870cdf0e10cSrcweir                     //       <pCnt> is also inside a section.
871cdf0e10cSrcweir                     //       Thus due to <mbBordersJoinedWithPrev>,
872cdf0e10cSrcweir                     //       <pCnt> had joined its borders/shadow with the
873cdf0e10cSrcweir                     //       last content of the found section.
874cdf0e10cSrcweir                     // Invalidate printing area of last content in found section.
875cdf0e10cSrcweir                     SwFrm* pLstCntntOfSctFrm =
876cdf0e10cSrcweir                             static_cast<SwSectionFrm*>(pPrevFrm)->FindLastCntnt();
877cdf0e10cSrcweir                     if ( pLstCntntOfSctFrm )
878cdf0e10cSrcweir                     {
879cdf0e10cSrcweir                         pLstCntntOfSctFrm->InvalidatePrt();
880cdf0e10cSrcweir                     }
881cdf0e10cSrcweir                 }
882cdf0e10cSrcweir             }
883cdf0e10cSrcweir             else
884cdf0e10cSrcweir             {
885cdf0e10cSrcweir                 pPrevFrm->InvalidatePrt();
886cdf0e10cSrcweir             }
887cdf0e10cSrcweir         }
888cdf0e10cSrcweir     }
889cdf0e10cSrcweir 
8906fddd742SOliver-Rainer Wittmann     const bool bFirst = (aFrm.*fnRect->fnGetWidth)() == 0;
891cdf0e10cSrcweir 
892cdf0e10cSrcweir     if ( pCnt->IsNoTxtFrm() )
893cdf0e10cSrcweir     {
894cdf0e10cSrcweir         //Aktive PlugIn's oder OLE-Objekte sollten etwas von der Veraenderung
895cdf0e10cSrcweir         //mitbekommen, damit sie Ihr Window entsprechend verschieben.
896cdf0e10cSrcweir         ViewShell *pSh = pCnt->getRootFrm()->GetCurrShell();
897cdf0e10cSrcweir         if ( pSh )
898cdf0e10cSrcweir         {
899cdf0e10cSrcweir             SwOLENode *pNd;
900cdf0e10cSrcweir             if ( 0 != (pNd = pCnt->GetNode()->GetOLENode()) &&
901cdf0e10cSrcweir                  (pNd->GetOLEObj().IsOleRef() ||
902cdf0e10cSrcweir                   pNd->IsOLESizeInvalid()) )
903cdf0e10cSrcweir             {
904b3b0b271SMichael Stahl                 // --> OD #i117189#
905b3b0b271SMichael Stahl                 const bool bNoTxtFrmPrtAreaChanged =
906b3b0b271SMichael Stahl                         ( aPrt.SSize().Width() != 0 &&
907b3b0b271SMichael Stahl                           aPrt.SSize().Height() != 0 ) &&
908b3b0b271SMichael Stahl                         aPrt.SSize() != pCnt->Prt().SSize();
909b3b0b271SMichael Stahl                 // <--
910cdf0e10cSrcweir                 ASSERT( pCnt->IsInFly(), "OLE not in FlyFrm" );
911cdf0e10cSrcweir                 SwFlyFrm *pFly = pCnt->FindFlyFrm();
912cdf0e10cSrcweir                 svt::EmbeddedObjectRef& xObj = pNd->GetOLEObj().GetObject();
913cdf0e10cSrcweir                 SwFEShell *pFESh = 0;
914cdf0e10cSrcweir                 ViewShell *pTmp = pSh;
915cdf0e10cSrcweir                 do
916cdf0e10cSrcweir                 {   if ( pTmp->ISA( SwCrsrShell ) )
917cdf0e10cSrcweir                     {
918cdf0e10cSrcweir                         pFESh = (SwFEShell*)pTmp;
919cdf0e10cSrcweir                         // #108369#: Here used to be the condition if (!bFirst).
920cdf0e10cSrcweir                         // I think this should mean "do not call CalcAndSetScale"
921cdf0e10cSrcweir                         // if the frame is formatted for the first time.
922cdf0e10cSrcweir                         // Unfortunately this is not valid anymore since the
923cdf0e10cSrcweir                         // SwNoTxtFrm already gets a width during CalcLowerPreps.
924*6e8337c1Smseidel                         // Nevertheless, the intention of !bFirst seemed to be
925cdf0e10cSrcweir                         // to assure that the OLE objects have already been notified
926cdf0e10cSrcweir                         // if necessary before calling CalcAndSetScale.
927cdf0e10cSrcweir                         // So I replaced !bFirst by !IsOLESizeInvalid. There is
928cdf0e10cSrcweir                         // one additional problem specific to the word import:
929cdf0e10cSrcweir                         // The layout is calculated _before_ calling PrtOLENotify,
930cdf0e10cSrcweir                         // and the OLE objects are not invalidated during import.
931cdf0e10cSrcweir                         // Therefore I added the condition !IsUpdateExpFld,
93286e1cf34SPedro Giffuni                         // have a look at the occurrence of CalcLayout in
933cdf0e10cSrcweir                         // uiview/view.cxx.
934cdf0e10cSrcweir                         if ( !pNd->IsOLESizeInvalid() &&
935cdf0e10cSrcweir                              !pSh->GetDoc()->IsUpdateExpFld() )
936b3b0b271SMichael Stahl                             pFESh->CalcAndSetScale( xObj,
937b3b0b271SMichael Stahl                                                     &pFly->Prt(), &pFly->Frm(),
938b3b0b271SMichael Stahl                                                     bNoTxtFrmPrtAreaChanged );
939cdf0e10cSrcweir                     }
940cdf0e10cSrcweir                     pTmp = (ViewShell*)pTmp->GetNext();
941cdf0e10cSrcweir                 } while ( pTmp != pSh );
942cdf0e10cSrcweir 
943cdf0e10cSrcweir                 if ( pFESh && pNd->IsOLESizeInvalid() )
944cdf0e10cSrcweir                 {
945cdf0e10cSrcweir                     pNd->SetOLESizeInvalid( sal_False );
946cdf0e10cSrcweir                     //TODO/LATER: needs OnDocumentPrinterChanged
947cdf0e10cSrcweir                     //xObj->OnDocumentPrinterChanged( pNd->GetDoc()->getPrinter( false ) );
948cdf0e10cSrcweir                     pFESh->CalcAndSetScale( xObj );//Client erzeugen lassen.
949cdf0e10cSrcweir                 }
950cdf0e10cSrcweir             }
951cdf0e10cSrcweir             //dito Animierte Grafiken
952cdf0e10cSrcweir             if ( Frm().HasArea() && ((SwNoTxtFrm*)pCnt)->HasAnimation() )
953cdf0e10cSrcweir             {
954cdf0e10cSrcweir                 ((SwNoTxtFrm*)pCnt)->StopAnimation();
955cdf0e10cSrcweir                 pSh->InvalidateWindows( Frm() );
956cdf0e10cSrcweir             }
957cdf0e10cSrcweir         }
958cdf0e10cSrcweir     }
959cdf0e10cSrcweir 
960cdf0e10cSrcweir     if ( bFirst )
961cdf0e10cSrcweir     {
962cdf0e10cSrcweir         pCnt->SetRetouche();    //fix(13870)
963cdf0e10cSrcweir 
964cdf0e10cSrcweir         SwDoc *pDoc = pCnt->GetNode()->GetDoc();
965cdf0e10cSrcweir         if ( pDoc->GetSpzFrmFmts()->Count() &&
9666fddd742SOliver-Rainer Wittmann              pDoc->DoesContainAtPageObjWithContentAnchor() && !pDoc->IsNewDoc() )
967cdf0e10cSrcweir         {
9686fddd742SOliver-Rainer Wittmann             // If certain import filters for foreign file format import
9696fddd742SOliver-Rainer Wittmann             // AT_PAGE anchored objects, the corresponding page number is
9706fddd742SOliver-Rainer Wittmann             // typically not known. In this case the content position is
9716fddd742SOliver-Rainer Wittmann             // stored at which the anchored object is found in the
9726fddd742SOliver-Rainer Wittmann             // imported document.
9736fddd742SOliver-Rainer Wittmann             // When this content is formatted it is the time at which
9746fddd742SOliver-Rainer Wittmann             // the page is known. Thus, this data can be corrected now.
975cdf0e10cSrcweir 
976cdf0e10cSrcweir             const SwPageFrm* pPage = 0;
977cdf0e10cSrcweir             SwNodeIndex *pIdx = 0;
978cdf0e10cSrcweir             SwSpzFrmFmts *pTbl = pDoc->GetSpzFrmFmts();
979cdf0e10cSrcweir             for ( sal_uInt16 i = 0; i < pTbl->Count(); ++i )
980cdf0e10cSrcweir             {
981cdf0e10cSrcweir                 SwFrmFmt *pFmt = (*pTbl)[i];
982cdf0e10cSrcweir                 const SwFmtAnchor &rAnch = pFmt->GetAnchor();
9836fddd742SOliver-Rainer Wittmann                 if ( FLY_AT_PAGE != rAnch.GetAnchorId() ||
9846fddd742SOliver-Rainer Wittmann                      rAnch.GetCntntAnchor() == 0 )
985cdf0e10cSrcweir                 {
9866fddd742SOliver-Rainer Wittmann                     continue;
987cdf0e10cSrcweir                 }
988cdf0e10cSrcweir 
989cdf0e10cSrcweir                 if ( !pIdx )
990cdf0e10cSrcweir                 {
991cdf0e10cSrcweir                     pIdx = new SwNodeIndex( *pCnt->GetNode() );
992cdf0e10cSrcweir                 }
993cdf0e10cSrcweir                 if ( rAnch.GetCntntAnchor()->nNode == *pIdx )
994cdf0e10cSrcweir                 {
995cdf0e10cSrcweir                     ASSERT( false, "<SwCntntNotify::~SwCntntNotify()> - to page anchored object with content position. Please inform OD." );
9966fddd742SOliver-Rainer Wittmann                     if ( !pPage )
9976fddd742SOliver-Rainer Wittmann                     {
9986fddd742SOliver-Rainer Wittmann                         pPage = pCnt->FindPageFrm();
9996fddd742SOliver-Rainer Wittmann                     }
1000cdf0e10cSrcweir                     SwFmtAnchor aAnch( rAnch );
1001cdf0e10cSrcweir                     aAnch.SetAnchor( 0 );
1002cdf0e10cSrcweir                     aAnch.SetPageNum( pPage->GetPhyPageNum() );
1003cdf0e10cSrcweir                     pFmt->SetFmtAttr( aAnch );
1004cdf0e10cSrcweir                     if ( RES_DRAWFRMFMT != pFmt->Which() )
10056fddd742SOliver-Rainer Wittmann                     {
1006cdf0e10cSrcweir                         pFmt->MakeFrms();
1007cdf0e10cSrcweir                     }
1008cdf0e10cSrcweir                 }
1009cdf0e10cSrcweir             }
1010cdf0e10cSrcweir             delete pIdx;
1011cdf0e10cSrcweir         }
1012cdf0e10cSrcweir     }
1013cdf0e10cSrcweir 
1014cdf0e10cSrcweir     // OD 12.01.2004 #i11859# - invalidate printing area of following frame,
1015cdf0e10cSrcweir     //  if height of last line has changed.
1016cdf0e10cSrcweir     if ( pCnt->IsTxtFrm() && mbChkHeightOfLastLine )
1017cdf0e10cSrcweir     {
1018cdf0e10cSrcweir         if ( mnHeightOfLastLine != static_cast<SwTxtFrm*>(pCnt)->GetHeightOfLastLine() )
1019cdf0e10cSrcweir         {
1020cdf0e10cSrcweir             pCnt->InvalidateNextPrtArea();
1021cdf0e10cSrcweir         }
1022cdf0e10cSrcweir     }
1023cdf0e10cSrcweir 
1024cdf0e10cSrcweir     // --> OD 2005-03-07 #i44049#
1025cdf0e10cSrcweir     if ( pCnt->IsTxtFrm() && POS_DIFF( aFrm, pCnt->Frm() ) )
1026cdf0e10cSrcweir     {
1027cdf0e10cSrcweir         pCnt->InvalidateObjs( true );
1028cdf0e10cSrcweir     }
1029cdf0e10cSrcweir     // <--
1030cdf0e10cSrcweir 
1031cdf0e10cSrcweir     // --> OD 2005-04-12 #i43255# - move code to invalidate at-character
1032cdf0e10cSrcweir     // anchored objects due to a change of its anchor character from
1033cdf0e10cSrcweir     // method <SwTxtFrm::Format(..)>.
1034cdf0e10cSrcweir     if ( pCnt->IsTxtFrm() )
1035cdf0e10cSrcweir     {
1036cdf0e10cSrcweir         SwTxtFrm* pMasterFrm = pCnt->IsFollow()
1037cdf0e10cSrcweir                                ? static_cast<SwTxtFrm*>(pCnt)->FindMaster()
1038cdf0e10cSrcweir                                : static_cast<SwTxtFrm*>(pCnt);
1039cdf0e10cSrcweir         if ( pMasterFrm && !pMasterFrm->IsFlyLock() &&
1040cdf0e10cSrcweir              pMasterFrm->GetDrawObjs() )
1041cdf0e10cSrcweir         {
1042cdf0e10cSrcweir             SwSortedObjs* pObjs = pMasterFrm->GetDrawObjs();
1043cdf0e10cSrcweir             for ( sal_uInt32 i = 0; i < pObjs->Count(); ++i )
1044cdf0e10cSrcweir             {
1045cdf0e10cSrcweir                 SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
1046cdf0e10cSrcweir                 if ( pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId()
1047cdf0e10cSrcweir                         == FLY_AT_CHAR )
1048cdf0e10cSrcweir                 {
1049cdf0e10cSrcweir                     pAnchoredObj->CheckCharRectAndTopOfLine( !pMasterFrm->IsEmpty() );
1050cdf0e10cSrcweir                 }
1051cdf0e10cSrcweir             }
1052cdf0e10cSrcweir         }
1053cdf0e10cSrcweir     }
1054cdf0e10cSrcweir     // <--
1055cdf0e10cSrcweir }
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir /*************************************************************************/
1058cdf0e10cSrcweir 
AppendObjs(const SwSpzFrmFmts * pTbl,sal_uLong nIndex,SwFrm * pFrm,SwPageFrm * pPage)1059cdf0e10cSrcweir void AppendObjs( const SwSpzFrmFmts *pTbl, sal_uLong nIndex,
1060cdf0e10cSrcweir                         SwFrm *pFrm, SwPageFrm *pPage )
1061cdf0e10cSrcweir {
1062cdf0e10cSrcweir     for ( sal_uInt16 i = 0; i < pTbl->Count(); ++i )
1063cdf0e10cSrcweir     {
1064cdf0e10cSrcweir         SwFrmFmt *pFmt = (SwFrmFmt*)(*pTbl)[i];
1065cdf0e10cSrcweir         const SwFmtAnchor &rAnch = pFmt->GetAnchor();
1066cdf0e10cSrcweir         if ( rAnch.GetCntntAnchor() &&
1067cdf0e10cSrcweir              (rAnch.GetCntntAnchor()->nNode.GetIndex() == nIndex) )
1068cdf0e10cSrcweir         {
1069cdf0e10cSrcweir             const bool bFlyAtFly = rAnch.GetAnchorId() == FLY_AT_FLY; // LAYER_IMPL
1070cdf0e10cSrcweir             //Wird ein Rahmen oder ein SdrObject beschrieben?
1071cdf0e10cSrcweir             const bool bSdrObj = RES_DRAWFRMFMT == pFmt->Which();
1072cdf0e10cSrcweir             // OD 23.06.2003 #108784# - append also drawing objects anchored
1073cdf0e10cSrcweir             // as character.
1074cdf0e10cSrcweir             const bool bDrawObjInCntnt = bSdrObj &&
1075cdf0e10cSrcweir                                          (rAnch.GetAnchorId() == FLY_AS_CHAR);
1076cdf0e10cSrcweir 
1077cdf0e10cSrcweir             if( bFlyAtFly ||
1078cdf0e10cSrcweir                 (rAnch.GetAnchorId() == FLY_AT_PARA) ||
1079cdf0e10cSrcweir                 (rAnch.GetAnchorId() == FLY_AT_CHAR) ||
1080cdf0e10cSrcweir                 bDrawObjInCntnt )
1081cdf0e10cSrcweir             {
1082cdf0e10cSrcweir                 SdrObject* pSdrObj = 0;
1083cdf0e10cSrcweir                 if ( bSdrObj && 0 == (pSdrObj = pFmt->FindSdrObject()) )
1084cdf0e10cSrcweir                 {
1085cdf0e10cSrcweir                     ASSERT( !bSdrObj, "DrawObject not found." );
1086cdf0e10cSrcweir                     pFmt->GetDoc()->DelFrmFmt( pFmt );
1087cdf0e10cSrcweir                     --i;
1088cdf0e10cSrcweir                     continue;
1089cdf0e10cSrcweir                 }
1090cdf0e10cSrcweir                 if ( pSdrObj )
1091cdf0e10cSrcweir                 {
1092cdf0e10cSrcweir                     if ( !pSdrObj->GetPage() )
1093cdf0e10cSrcweir                     {
1094cdf0e10cSrcweir                         pFmt->getIDocumentDrawModelAccess()->GetDrawModel()->GetPage(0)->
1095cdf0e10cSrcweir                                 InsertObject(pSdrObj, pSdrObj->GetOrdNumDirect());
1096cdf0e10cSrcweir                     }
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir                     SwDrawContact* pNew =
1099cdf0e10cSrcweir                         static_cast<SwDrawContact*>(GetUserCall( pSdrObj ));
1100cdf0e10cSrcweir                     if ( !pNew->GetAnchorFrm() )
1101cdf0e10cSrcweir                     {
1102cdf0e10cSrcweir                         pFrm->AppendDrawObj( *(pNew->GetAnchoredObj( 0L )) );
1103cdf0e10cSrcweir                     }
1104cdf0e10cSrcweir                     // OD 19.06.2003 #108784# - add 'virtual' drawing object,
1105cdf0e10cSrcweir                     // if necessary. But control objects have to be excluded.
1106cdf0e10cSrcweir                     else if ( !::CheckControlLayer( pSdrObj ) &&
1107cdf0e10cSrcweir                               pNew->GetAnchorFrm() != pFrm &&
1108cdf0e10cSrcweir                               !pNew->GetDrawObjectByAnchorFrm( *pFrm ) )
1109cdf0e10cSrcweir                     {
1110cdf0e10cSrcweir                         SwDrawVirtObj* pDrawVirtObj = pNew->AddVirtObj();
1111cdf0e10cSrcweir                         pFrm->AppendDrawObj( *(pNew->GetAnchoredObj( pDrawVirtObj )) );
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir                         // for repaint, use new ActionChanged()
1114cdf0e10cSrcweir                         // pDrawVirtObj->SendRepaintBroadcast();
1115cdf0e10cSrcweir                         pDrawVirtObj->ActionChanged();
1116cdf0e10cSrcweir                     }
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir                 }
1119cdf0e10cSrcweir                 else
1120cdf0e10cSrcweir                 {
1121cdf0e10cSrcweir                     SwFlyFrm *pFly;
1122cdf0e10cSrcweir                     if( bFlyAtFly )
1123cdf0e10cSrcweir                         pFly = new SwFlyLayFrm( (SwFlyFrmFmt*)pFmt, pFrm, pFrm );
1124cdf0e10cSrcweir                     else
1125cdf0e10cSrcweir                         pFly = new SwFlyAtCntFrm( (SwFlyFrmFmt*)pFmt, pFrm, pFrm );
1126cdf0e10cSrcweir                     pFly->Lock();
1127cdf0e10cSrcweir                     pFrm->AppendFly( pFly );
1128cdf0e10cSrcweir                     pFly->Unlock();
1129cdf0e10cSrcweir                     if ( pPage )
1130cdf0e10cSrcweir                         ::RegistFlys( pPage, pFly );
1131cdf0e10cSrcweir                 }
1132cdf0e10cSrcweir             }
1133cdf0e10cSrcweir         }
1134cdf0e10cSrcweir     }
1135cdf0e10cSrcweir }
1136cdf0e10cSrcweir 
lcl_ObjConnected(SwFrmFmt * pFmt,const SwFrm * pSib)1137cdf0e10cSrcweir bool lcl_ObjConnected( SwFrmFmt *pFmt, const SwFrm* pSib )
1138cdf0e10cSrcweir {
1139cdf0e10cSrcweir     SwIterator<SwFlyFrm,SwFmt> aIter( *pFmt );
1140cdf0e10cSrcweir     if ( RES_FLYFRMFMT == pFmt->Which() )
1141cdf0e10cSrcweir     {
1142cdf0e10cSrcweir         const SwRootFrm* pRoot = pSib ? pSib->getRootFrm() : 0;
1143cdf0e10cSrcweir         const SwFlyFrm* pTmpFrm;
1144cdf0e10cSrcweir         for( pTmpFrm = aIter.First(); pTmpFrm; pTmpFrm = aIter.Next() )
1145cdf0e10cSrcweir         {
1146cdf0e10cSrcweir             if(! pRoot || pRoot == pTmpFrm->getRootFrm() )
1147cdf0e10cSrcweir                 return true;
1148cdf0e10cSrcweir         }
1149cdf0e10cSrcweir     }
1150cdf0e10cSrcweir     else
1151cdf0e10cSrcweir     {
1152cdf0e10cSrcweir         SwDrawContact *pContact = SwIterator<SwDrawContact,SwFmt>::FirstElement(*pFmt);
1153cdf0e10cSrcweir         if ( pContact )
1154cdf0e10cSrcweir             return pContact->GetAnchorFrm() != 0;
1155cdf0e10cSrcweir     }
1156cdf0e10cSrcweir     return false;
1157cdf0e10cSrcweir }
1158cdf0e10cSrcweir 
1159cdf0e10cSrcweir /** helper method to determine, if a <SwFrmFmt>, which has an object connected,
1160cdf0e10cSrcweir     is located in header or footer.
1161cdf0e10cSrcweir 
1162cdf0e10cSrcweir     OD 23.06.2003 #108784#
1163cdf0e10cSrcweir 
1164cdf0e10cSrcweir     @author OD
1165cdf0e10cSrcweir */
lcl_InHeaderOrFooter(SwFrmFmt & _rFmt)1166cdf0e10cSrcweir bool lcl_InHeaderOrFooter( SwFrmFmt& _rFmt )
1167cdf0e10cSrcweir {
1168cdf0e10cSrcweir     bool bRetVal = false;
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir     const SwFmtAnchor& rAnch = _rFmt.GetAnchor();
1171cdf0e10cSrcweir 
1172cdf0e10cSrcweir     if (rAnch.GetAnchorId() != FLY_AT_PAGE)
1173cdf0e10cSrcweir     {
1174cdf0e10cSrcweir         bRetVal = _rFmt.GetDoc()->IsInHeaderFooter( rAnch.GetCntntAnchor()->nNode );
1175cdf0e10cSrcweir     }
1176cdf0e10cSrcweir 
1177cdf0e10cSrcweir     return bRetVal;
1178cdf0e10cSrcweir }
1179cdf0e10cSrcweir 
AppendAllObjs(const SwSpzFrmFmts * pTbl,const SwFrm * pSib)1180cdf0e10cSrcweir void AppendAllObjs( const SwSpzFrmFmts *pTbl, const SwFrm* pSib )
1181cdf0e10cSrcweir {
1182cdf0e10cSrcweir     //Verbinden aller Objekte, die in der SpzTbl beschrieben sind mit dem
1183cdf0e10cSrcweir     //Layout.
1184*6e8337c1Smseidel     //Wenn sich nichts mehr tut hoeren wir auf. Dann koennen noch Formate
1185*6e8337c1Smseidel     //uebrigbleiben, weil wir weder zeichengebundene Rahmen verbinden noch
1186*6e8337c1Smseidel     //Objekte die in zeichengebundenen verankert sind.
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir     SwSpzFrmFmts aCpy( 255, 255 );
1189cdf0e10cSrcweir     aCpy.Insert( pTbl, 0 );
1190cdf0e10cSrcweir 
1191cdf0e10cSrcweir     sal_uInt16 nOldCnt = USHRT_MAX;
1192cdf0e10cSrcweir 
1193cdf0e10cSrcweir     while ( aCpy.Count() && aCpy.Count() != nOldCnt )
1194cdf0e10cSrcweir     {
1195cdf0e10cSrcweir         nOldCnt = aCpy.Count();
1196cdf0e10cSrcweir         for ( int i = 0; i < int(aCpy.Count()); ++i )
1197cdf0e10cSrcweir         {
1198cdf0e10cSrcweir             SwFrmFmt *pFmt = (SwFrmFmt*)aCpy[ sal_uInt16(i) ];
1199cdf0e10cSrcweir             const SwFmtAnchor &rAnch = pFmt->GetAnchor();
1200cdf0e10cSrcweir             sal_Bool bRemove = sal_False;
1201cdf0e10cSrcweir             if ((rAnch.GetAnchorId() == FLY_AT_PAGE) ||
1202cdf0e10cSrcweir                 (rAnch.GetAnchorId() == FLY_AS_CHAR))
1203cdf0e10cSrcweir             {
1204cdf0e10cSrcweir                 //Seitengebunde sind bereits verankert, zeichengebundene
1205cdf0e10cSrcweir                 //will ich hier nicht.
1206cdf0e10cSrcweir                 bRemove = sal_True;
1207cdf0e10cSrcweir             }
1208cdf0e10cSrcweir             else if ( sal_False == (bRemove = ::lcl_ObjConnected( pFmt, pSib )) ||
1209cdf0e10cSrcweir                       ::lcl_InHeaderOrFooter( *pFmt ) )
1210cdf0e10cSrcweir             {
1211cdf0e10cSrcweir             // OD 23.06.2003 #108784# - correction: for objects in header
1212cdf0e10cSrcweir             // or footer create frames, in spite of the fact that an connected
1213cdf0e10cSrcweir             // objects already exists.
1214cdf0e10cSrcweir                 //Fuer Flys und DrawObjs nur dann ein MakeFrms rufen wenn noch
1215cdf0e10cSrcweir                 //keine abhaengigen Existieren, andernfalls, oder wenn das
1216cdf0e10cSrcweir                 //MakeFrms keine abhaengigen erzeugt, entfernen.
1217cdf0e10cSrcweir                 pFmt->MakeFrms();
1218cdf0e10cSrcweir                 bRemove = ::lcl_ObjConnected( pFmt, pSib );
1219cdf0e10cSrcweir             }
1220cdf0e10cSrcweir             if ( bRemove )
1221cdf0e10cSrcweir             {
1222cdf0e10cSrcweir                 aCpy.Remove( sal_uInt16(i) );
1223cdf0e10cSrcweir                 --i;
1224cdf0e10cSrcweir             }
1225cdf0e10cSrcweir         }
1226cdf0e10cSrcweir     }
1227cdf0e10cSrcweir     aCpy.Remove( 0, aCpy.Count() );
1228cdf0e10cSrcweir }
1229cdf0e10cSrcweir 
1230cdf0e10cSrcweir /** local method to set 'working' position for newly inserted frames
1231cdf0e10cSrcweir 
1232cdf0e10cSrcweir     OD 12.08.2003 #i17969#
1233cdf0e10cSrcweir 
1234cdf0e10cSrcweir     @author OD
1235cdf0e10cSrcweir */
lcl_SetPos(SwFrm & _rNewFrm,const SwLayoutFrm & _rLayFrm)1236cdf0e10cSrcweir void lcl_SetPos( SwFrm&             _rNewFrm,
1237cdf0e10cSrcweir                  const SwLayoutFrm& _rLayFrm )
1238cdf0e10cSrcweir {
1239cdf0e10cSrcweir     SWRECTFN( (&_rLayFrm) )
1240cdf0e10cSrcweir     (_rNewFrm.Frm().*fnRect->fnSetPos)( (_rLayFrm.Frm().*fnRect->fnGetPos)() );
1241cdf0e10cSrcweir     // move position by one SwTwip in text flow direction in order to get
1242cdf0e10cSrcweir     // notifications for a new calculated position after its formatting.
1243cdf0e10cSrcweir     if ( bVert )
1244cdf0e10cSrcweir         _rNewFrm.Frm().Pos().X() -= 1;
1245cdf0e10cSrcweir     else
1246cdf0e10cSrcweir         _rNewFrm.Frm().Pos().Y() += 1;
1247cdf0e10cSrcweir }
1248cdf0e10cSrcweir 
_InsertCnt(SwLayoutFrm * pLay,SwDoc * pDoc,sal_uLong nIndex,sal_Bool bPages,sal_uLong nEndIndex,SwFrm * pPrv)1249cdf0e10cSrcweir void MA_FASTCALL _InsertCnt( SwLayoutFrm *pLay, SwDoc *pDoc,
1250cdf0e10cSrcweir                              sal_uLong nIndex, sal_Bool bPages, sal_uLong nEndIndex,
1251cdf0e10cSrcweir                              SwFrm *pPrv )
1252cdf0e10cSrcweir {
1253cdf0e10cSrcweir     pDoc->BlockIdling();
1254cdf0e10cSrcweir     SwRootFrm* pLayout = pLay->getRootFrm();
1255cdf0e10cSrcweir     const sal_Bool bOldCallbackActionEnabled = pLayout ? pLayout->IsCallbackActionEnabled() : sal_False;
1256cdf0e10cSrcweir     if( bOldCallbackActionEnabled )
1257cdf0e10cSrcweir         pLayout->SetCallbackActionEnabled( sal_False );
1258cdf0e10cSrcweir 
1259cdf0e10cSrcweir     //Bei der Erzeugung des Layouts wird bPages mit sal_True uebergeben. Dann
1260cdf0e10cSrcweir     //werden schon mal alle x Absaetze neue Seiten angelegt. Bei umbruechen
1261cdf0e10cSrcweir     //und/oder Pagedescriptorwechseln werden gleich die entsprechenden Seiten
1262cdf0e10cSrcweir     //angelegt.
1263cdf0e10cSrcweir     //Vorteil ist, das einerseits schon eine annaehernd realistische Zahl von
1264cdf0e10cSrcweir     //Seiten angelegt wird, vor allem aber gibt es nicht mehr eine schier
1265cdf0e10cSrcweir     //lange Kette von Absaetzen teuer verschoben werden muss, bis sie sich auf
1266cdf0e10cSrcweir     //ertraegliches mass reduziert hat.
1267cdf0e10cSrcweir     //Wir gehen mal davon aus, da? 20 Absaetze auf eine Seite passen
1268*6e8337c1Smseidel     //Damit es in extremen Faellen nicht gar so heftig rechnen wir je nach
1269cdf0e10cSrcweir     //Node noch etwas drauf.
1270*6e8337c1Smseidel     //Wenn in der DocStatistik eine brauchbare Seitenzahl angegeben ist
1271cdf0e10cSrcweir     //(wird beim Schreiben gepflegt), so wird von dieser Seitenanzahl
1272cdf0e10cSrcweir     //ausgegengen.
1273cdf0e10cSrcweir     const sal_Bool bStartPercent = bPages && !nEndIndex;
1274cdf0e10cSrcweir 
1275cdf0e10cSrcweir     SwPageFrm *pPage = pLay->FindPageFrm();
1276cdf0e10cSrcweir     const SwSpzFrmFmts *pTbl = pDoc->GetSpzFrmFmts();
1277cdf0e10cSrcweir     SwFrm       *pFrm = 0;
1278cdf0e10cSrcweir     sal_Bool   bBreakAfter   = sal_False;
1279cdf0e10cSrcweir 
1280cdf0e10cSrcweir     SwActualSection *pActualSection = 0;
1281cdf0e10cSrcweir     SwLayHelper *pPageMaker;
1282cdf0e10cSrcweir 
1283cdf0e10cSrcweir     //Wenn das Layout erzeugt wird (bPages == sal_True) steuern wir den Progress
1284cdf0e10cSrcweir     //an. Flys und DrawObjekte werden dann nicht gleich verbunden, dies
1285cdf0e10cSrcweir     //passiert erst am Ende der Funktion.
1286cdf0e10cSrcweir     if ( bPages )
1287cdf0e10cSrcweir     {
1288cdf0e10cSrcweir         // Attention: the SwLayHelper class uses references to the content-,
1289cdf0e10cSrcweir         // page-, layout-frame etc. and may change them!
1290cdf0e10cSrcweir         pPageMaker = new SwLayHelper( pDoc, pFrm, pPrv, pPage, pLay,
1291cdf0e10cSrcweir                 pActualSection, bBreakAfter, nIndex, 0 == nEndIndex );
1292cdf0e10cSrcweir         if( bStartPercent )
1293cdf0e10cSrcweir         {
1294cdf0e10cSrcweir             const sal_uLong nPageCount = pPageMaker->CalcPageCount();
1295cdf0e10cSrcweir             if( nPageCount )
1296cdf0e10cSrcweir                 bObjsDirect = sal_False;
1297cdf0e10cSrcweir         }
1298cdf0e10cSrcweir     }
1299cdf0e10cSrcweir     else
1300cdf0e10cSrcweir         pPageMaker = NULL;
1301cdf0e10cSrcweir 
1302cdf0e10cSrcweir     if( pLay->IsInSct() &&
1303cdf0e10cSrcweir         ( pLay->IsSctFrm() || pLay->GetUpper() ) ) // Hierdurch werden Frischlinge
1304cdf0e10cSrcweir             // abgefangen, deren Flags noch nicht ermittelt werden koennen,
1305cdf0e10cSrcweir             // so z.B. beim Einfuegen einer Tabelle
1306cdf0e10cSrcweir     {
1307cdf0e10cSrcweir         SwSectionFrm* pSct = pLay->FindSctFrm();
1308cdf0e10cSrcweir         // Wenn Inhalt in eine Fussnote eingefuegt wird, die in einem spaltigen
1309cdf0e10cSrcweir         // Bereich liegt, so darf der spaltige Bereich nicht aufgebrochen werden.
1310cdf0e10cSrcweir         // Nur wenn im Innern der Fussnote ein Bereich liegt, ist dies ein
1311cdf0e10cSrcweir         // Kandidat fuer pActualSection.
1312cdf0e10cSrcweir         // Gleiches gilt fuer Bereiche in Tabellen, wenn innerhalb einer Tabelle
1313cdf0e10cSrcweir         // eingefuegt wird, duerfen nur Bereiche, die ebenfalls im Innern liegen,
1314cdf0e10cSrcweir         // aufgebrochen werden.
1315cdf0e10cSrcweir         if( ( !pLay->IsInFtn() || pSct->IsInFtn() ) &&
1316cdf0e10cSrcweir             ( !pLay->IsInTab() || pSct->IsInTab() ) )
1317cdf0e10cSrcweir         {
1318cdf0e10cSrcweir             pActualSection = new SwActualSection( 0, pSct, 0 );
1319cdf0e10cSrcweir             ASSERT( !pLay->Lower() || !pLay->Lower()->IsColumnFrm(),
1320cdf0e10cSrcweir                 "_InsertCnt: Wrong Call" );
1321cdf0e10cSrcweir         }
1322cdf0e10cSrcweir     }
1323cdf0e10cSrcweir 
1324cdf0e10cSrcweir     //If a section is "open", the pActualSection points to an SwActualSection.
1325cdf0e10cSrcweir     //If the page breaks, for "open" sections a follow will created.
1326cdf0e10cSrcweir     //For nested sections (which have, however, not a nested layout),
1327cdf0e10cSrcweir     //the SwActualSection class has a member, which points to an upper(section).
1328cdf0e10cSrcweir     //When the "inner" section finishs, the upper will used instead.
1329cdf0e10cSrcweir 
1330cdf0e10cSrcweir     while( sal_True )
1331cdf0e10cSrcweir     {
1332cdf0e10cSrcweir         SwNode *pNd = pDoc->GetNodes()[nIndex];
1333cdf0e10cSrcweir         if ( pNd->IsCntntNode() )
1334cdf0e10cSrcweir         {
1335cdf0e10cSrcweir             SwCntntNode* pNode = (SwCntntNode*)pNd;
1336cdf0e10cSrcweir             pFrm = pNode->IsTxtNode() ? new SwTxtFrm( (SwTxtNode*)pNode, pLay ) :
1337cdf0e10cSrcweir                                         pNode->MakeFrm( pLay );
1338cdf0e10cSrcweir             if( pPageMaker )
1339cdf0e10cSrcweir                 pPageMaker->CheckInsert( nIndex );
1340cdf0e10cSrcweir 
1341cdf0e10cSrcweir             pFrm->InsertBehind( pLay, pPrv );
1342cdf0e10cSrcweir             // --> OD 2005-12-01 #i27138#
1343cdf0e10cSrcweir             // notify accessibility paragraphs objects about changed
1344cdf0e10cSrcweir             // CONTENT_FLOWS_FROM/_TO relation.
1345cdf0e10cSrcweir             // Relation CONTENT_FLOWS_FROM for next paragraph will change
1346cdf0e10cSrcweir             // and relation CONTENT_FLOWS_TO for previous paragraph will change.
1347cdf0e10cSrcweir             if ( pFrm->IsTxtFrm() )
1348cdf0e10cSrcweir             {
1349cdf0e10cSrcweir                 ViewShell* pViewShell( pFrm->getRootFrm()->GetCurrShell() );
1350cdf0e10cSrcweir                 // no notification, if <ViewShell> is in construction
1351cdf0e10cSrcweir                 if ( pViewShell && !pViewShell->IsInConstructor() &&
1352cdf0e10cSrcweir                      pViewShell->GetLayout() &&
1353cdf0e10cSrcweir                      pViewShell->GetLayout()->IsAnyShellAccessible() )
1354cdf0e10cSrcweir                 {
1355cdf0e10cSrcweir                     pViewShell->InvalidateAccessibleParaFlowRelation(
1356cdf0e10cSrcweir                         dynamic_cast<SwTxtFrm*>(pFrm->FindNextCnt( true )),
1357cdf0e10cSrcweir                         dynamic_cast<SwTxtFrm*>(pFrm->FindPrevCnt( true )) );
1358cdf0e10cSrcweir                     // --> OD 2006-08-28 #i68958#
1359cdf0e10cSrcweir                     // The information flags of the text frame are validated
1360cdf0e10cSrcweir                     // in methods <FindNextCnt(..)> and <FindPrevCnt(..)>.
1361cdf0e10cSrcweir                     // The information flags have to be invalidated, because
1362cdf0e10cSrcweir                     // it is possible, that the one of its upper frames
1363cdf0e10cSrcweir                     // isn't inserted into the layout.
1364cdf0e10cSrcweir                     pFrm->InvalidateInfFlags();
1365cdf0e10cSrcweir                     // <--
1366cdf0e10cSrcweir                 }
1367cdf0e10cSrcweir             }
1368cdf0e10cSrcweir             // <--
1369cdf0e10cSrcweir             // OD 12.08.2003 #i17969# - consider horizontal/vertical layout
1370cdf0e10cSrcweir             // for setting position at newly inserted frame
1371cdf0e10cSrcweir             lcl_SetPos( *pFrm, *pLay );
1372cdf0e10cSrcweir             pPrv = pFrm;
1373cdf0e10cSrcweir 
1374cdf0e10cSrcweir             if ( pTbl->Count() && bObjsDirect && !bDontCreateObjects )
1375cdf0e10cSrcweir                 AppendObjs( pTbl, nIndex, pFrm, pPage );
1376cdf0e10cSrcweir         }
1377cdf0e10cSrcweir         else if ( pNd->IsTableNode() )
1378cdf0e10cSrcweir         {   //Sollten wir auf eine Tabelle gestossen sein?
1379cdf0e10cSrcweir             SwTableNode *pTblNode = (SwTableNode*)pNd;
1380cdf0e10cSrcweir 
1381cdf0e10cSrcweir             // #108116# loading may produce table structures that GCLines
1382cdf0e10cSrcweir             // needs to clean up. To keep table formulas correct, change
1383cdf0e10cSrcweir             // all table formulas to internal (BOXPTR) representation.
1384cdf0e10cSrcweir             SwTableFmlUpdate aMsgHnt( &pTblNode->GetTable() );
1385cdf0e10cSrcweir             aMsgHnt.eFlags = TBL_BOXPTR;
1386cdf0e10cSrcweir             pDoc->UpdateTblFlds( &aMsgHnt );
1387cdf0e10cSrcweir             pTblNode->GetTable().GCLines();
1388cdf0e10cSrcweir 
1389cdf0e10cSrcweir             pFrm = pTblNode->MakeFrm( pLay );
1390cdf0e10cSrcweir 
1391cdf0e10cSrcweir             if( pPageMaker )
1392cdf0e10cSrcweir                 pPageMaker->CheckInsert( nIndex );
1393cdf0e10cSrcweir 
1394cdf0e10cSrcweir             pFrm->InsertBehind( pLay, pPrv );
1395cdf0e10cSrcweir             // --> OD 2005-12-01 #i27138#
1396cdf0e10cSrcweir             // notify accessibility paragraphs objects about changed
1397cdf0e10cSrcweir             // CONTENT_FLOWS_FROM/_TO relation.
1398cdf0e10cSrcweir             // Relation CONTENT_FLOWS_FROM for next paragraph will change
1399cdf0e10cSrcweir             // and relation CONTENT_FLOWS_TO for previous paragraph will change.
1400cdf0e10cSrcweir             {
1401cdf0e10cSrcweir                 ViewShell* pViewShell( pFrm->getRootFrm()->GetCurrShell() );
1402cdf0e10cSrcweir                 // no notification, if <ViewShell> is in construction
1403cdf0e10cSrcweir                 if ( pViewShell && !pViewShell->IsInConstructor() &&
1404cdf0e10cSrcweir                      pViewShell->GetLayout() &&
1405cdf0e10cSrcweir                      pViewShell->GetLayout()->IsAnyShellAccessible() )
1406cdf0e10cSrcweir                 {
1407cdf0e10cSrcweir                     pViewShell->InvalidateAccessibleParaFlowRelation(
1408cdf0e10cSrcweir                             dynamic_cast<SwTxtFrm*>(pFrm->FindNextCnt( true )),
1409cdf0e10cSrcweir                             dynamic_cast<SwTxtFrm*>(pFrm->FindPrevCnt( true )) );
1410cdf0e10cSrcweir                 }
1411cdf0e10cSrcweir             }
1412cdf0e10cSrcweir             // <--
1413cdf0e10cSrcweir             if ( bObjsDirect && pTbl->Count() )
1414cdf0e10cSrcweir                 ((SwTabFrm*)pFrm)->RegistFlys();
1415cdf0e10cSrcweir             // OD 12.08.2003 #i17969# - consider horizontal/vertical layout
1416cdf0e10cSrcweir             // for setting position at newly inserted frame
1417cdf0e10cSrcweir             lcl_SetPos( *pFrm, *pLay );
1418cdf0e10cSrcweir 
1419cdf0e10cSrcweir             pPrv = pFrm;
1420cdf0e10cSrcweir             //Index auf den Endnode der Tabellensection setzen.
1421cdf0e10cSrcweir             nIndex = pTblNode->EndOfSectionIndex();
1422cdf0e10cSrcweir 
1423cdf0e10cSrcweir             SwTabFrm* pTmpFrm = (SwTabFrm*)pFrm;
1424cdf0e10cSrcweir             while ( pTmpFrm )
1425cdf0e10cSrcweir             {
1426cdf0e10cSrcweir                 pTmpFrm->CheckDirChange();
1427cdf0e10cSrcweir                 pTmpFrm = pTmpFrm->IsFollow() ? pTmpFrm->FindMaster() : NULL;
1428cdf0e10cSrcweir             }
1429cdf0e10cSrcweir 
1430cdf0e10cSrcweir         }
1431cdf0e10cSrcweir         else if ( pNd->IsSectionNode() )
1432cdf0e10cSrcweir         {
1433cdf0e10cSrcweir             SwSectionNode *pNode = (SwSectionNode*)pNd;
1434cdf0e10cSrcweir             if( pNode->GetSection().CalcHiddenFlag() )
1435cdf0e10cSrcweir                 // ist versteckt, ueberspringe den Bereich
1436cdf0e10cSrcweir                 nIndex = pNode->EndOfSectionIndex();
1437cdf0e10cSrcweir             else
1438cdf0e10cSrcweir             {
1439cdf0e10cSrcweir                 pFrm = pNode->MakeFrm( pLay );
1440cdf0e10cSrcweir                 pActualSection = new SwActualSection( pActualSection,
1441cdf0e10cSrcweir                                                 (SwSectionFrm*)pFrm, pNode );
1442cdf0e10cSrcweir                 if ( pActualSection->GetUpper() )
1443cdf0e10cSrcweir                 {
1444cdf0e10cSrcweir                     //Hinter den Upper einsetzen, beim EndNode wird der "Follow"
1445cdf0e10cSrcweir                     //des Uppers erzeugt.
1446cdf0e10cSrcweir                     SwSectionFrm *pTmp = pActualSection->GetUpper()->GetSectionFrm();
1447cdf0e10cSrcweir                     pFrm->InsertBehind( pTmp->GetUpper(), pTmp );
1448cdf0e10cSrcweir                     // OD 25.03.2003 #108339# - direct initialization of section
1449cdf0e10cSrcweir                     // after insertion in the layout
1450cdf0e10cSrcweir                     static_cast<SwSectionFrm*>(pFrm)->Init();
1451cdf0e10cSrcweir                 }
1452cdf0e10cSrcweir                 else
1453cdf0e10cSrcweir                 {
1454cdf0e10cSrcweir                     pFrm->InsertBehind( pLay, pPrv );
1455cdf0e10cSrcweir                     // OD 25.03.2003 #108339# - direct initialization of section
1456cdf0e10cSrcweir                     // after insertion in the layout
1457cdf0e10cSrcweir                     static_cast<SwSectionFrm*>(pFrm)->Init();
1458cdf0e10cSrcweir 
1459cdf0e10cSrcweir                     // --> FME 2004-09-08 #i33963#
1460cdf0e10cSrcweir                     // Do not trust the IsInFtn flag. If we are currently
1461cdf0e10cSrcweir                     // building up a table, the upper of pPrv may be a cell
1462cdf0e10cSrcweir                     // frame, but the cell frame does not have an upper yet.
1463cdf0e10cSrcweir                     if( pPrv && 0 != pPrv->ImplFindFtnFrm() )
1464cdf0e10cSrcweir                     // <--
1465cdf0e10cSrcweir                     {
1466cdf0e10cSrcweir                         if( pPrv->IsSctFrm() )
1467cdf0e10cSrcweir                             pPrv = ((SwSectionFrm*)pPrv)->ContainsCntnt();
1468cdf0e10cSrcweir                         if( pPrv && pPrv->IsTxtFrm() )
1469cdf0e10cSrcweir                             ((SwTxtFrm*)pPrv)->Prepare( PREP_QUOVADIS, 0, sal_False );
1470cdf0e10cSrcweir                     }
1471cdf0e10cSrcweir                 }
1472cdf0e10cSrcweir                 // --> OD 2005-12-01 #i27138#
1473cdf0e10cSrcweir                 // notify accessibility paragraphs objects about changed
1474cdf0e10cSrcweir                 // CONTENT_FLOWS_FROM/_TO relation.
1475cdf0e10cSrcweir                 // Relation CONTENT_FLOWS_FROM for next paragraph will change
1476cdf0e10cSrcweir                 // and relation CONTENT_FLOWS_TO for previous paragraph will change.
1477cdf0e10cSrcweir                 {
1478cdf0e10cSrcweir                     ViewShell* pViewShell( pFrm->getRootFrm()->GetCurrShell() );
1479cdf0e10cSrcweir                     // no notification, if <ViewShell> is in construction
1480cdf0e10cSrcweir                     if ( pViewShell && !pViewShell->IsInConstructor() &&
1481cdf0e10cSrcweir                          pViewShell->GetLayout() &&
1482cdf0e10cSrcweir                          pViewShell->GetLayout()->IsAnyShellAccessible() )
1483cdf0e10cSrcweir                     {
1484cdf0e10cSrcweir                         pViewShell->InvalidateAccessibleParaFlowRelation(
1485cdf0e10cSrcweir                             dynamic_cast<SwTxtFrm*>(pFrm->FindNextCnt( true )),
1486cdf0e10cSrcweir                             dynamic_cast<SwTxtFrm*>(pFrm->FindPrevCnt( true )) );
1487cdf0e10cSrcweir                     }
1488cdf0e10cSrcweir                 }
1489cdf0e10cSrcweir                 // <--
1490cdf0e10cSrcweir                 pFrm->CheckDirChange();
1491cdf0e10cSrcweir 
1492cdf0e10cSrcweir                 // OD 12.08.2003 #i17969# - consider horizontal/vertical layout
1493cdf0e10cSrcweir                 // for setting position at newly inserted frame
1494cdf0e10cSrcweir                 lcl_SetPos( *pFrm, *pLay );
1495cdf0e10cSrcweir 
1496cdf0e10cSrcweir                 // OD 20.11.2002 #105405# - no page, no invalidate.
1497cdf0e10cSrcweir                 if ( pPage )
1498cdf0e10cSrcweir                 {
1499cdf0e10cSrcweir                     // OD 18.09.2002 #100522#
1500cdf0e10cSrcweir                     // invalidate page in order to force format and paint of
1501cdf0e10cSrcweir                     // inserted section frame
1502cdf0e10cSrcweir                     pFrm->InvalidatePage( pPage );
1503cdf0e10cSrcweir 
1504cdf0e10cSrcweir                     // FME 10.11.2003 #112243#
1505cdf0e10cSrcweir                     // Invalidate fly content flag:
1506cdf0e10cSrcweir                     if ( pFrm->IsInFly() )
1507cdf0e10cSrcweir                         pPage->InvalidateFlyCntnt();
1508cdf0e10cSrcweir 
1509cdf0e10cSrcweir                     // OD 14.11.2002 #104684# - invalidate page content in order to
1510cdf0e10cSrcweir                     // force format and paint of section content.
1511cdf0e10cSrcweir                     pPage->InvalidateCntnt();
1512cdf0e10cSrcweir                 }
1513cdf0e10cSrcweir 
1514cdf0e10cSrcweir                 pLay = (SwLayoutFrm*)pFrm;
1515cdf0e10cSrcweir                 if ( pLay->Lower() && pLay->Lower()->IsLayoutFrm() )
1516cdf0e10cSrcweir                     pLay = pLay->GetNextLayoutLeaf();
1517cdf0e10cSrcweir                 pPrv = 0;
1518cdf0e10cSrcweir             }
1519cdf0e10cSrcweir         }
1520cdf0e10cSrcweir         else if ( pNd->IsEndNode() && pNd->StartOfSectionNode()->IsSectionNode() )
1521cdf0e10cSrcweir         {
1522cdf0e10cSrcweir             ASSERT( pActualSection, "Sectionende ohne Anfang?" );
1523cdf0e10cSrcweir             ASSERT( pActualSection->GetSectionNode() == pNd->StartOfSectionNode(),
1524cdf0e10cSrcweir                             "Sectionende mit falschen Start Node?" );
1525cdf0e10cSrcweir 
1526cdf0e10cSrcweir             //Section schliessen, ggf. die umgebende Section wieder
1527cdf0e10cSrcweir             //aktivieren.
1528cdf0e10cSrcweir             SwActualSection *pTmp = pActualSection->GetUpper();
1529cdf0e10cSrcweir             delete pActualSection;
1530cdf0e10cSrcweir             pLay = pLay->FindSctFrm();
1531cdf0e10cSrcweir             if ( 0 != (pActualSection = pTmp) )
1532cdf0e10cSrcweir             {
1533cdf0e10cSrcweir                 //Koennte noch sein, das der letzte SectionFrm leer geblieben
1534cdf0e10cSrcweir                 //ist. Dann ist es jetzt an der Zeit ihn zu entfernen.
1535cdf0e10cSrcweir                 if ( !pLay->ContainsCntnt() )
1536cdf0e10cSrcweir                 {
1537cdf0e10cSrcweir                     SwFrm *pTmpFrm = pLay;
1538cdf0e10cSrcweir                     pLay = pTmpFrm->GetUpper();
1539cdf0e10cSrcweir                     pPrv = pTmpFrm->GetPrev();
1540cdf0e10cSrcweir                     pTmpFrm->Remove();
1541cdf0e10cSrcweir                     delete pTmpFrm;
1542cdf0e10cSrcweir                 }
1543cdf0e10cSrcweir                 else
1544cdf0e10cSrcweir                 {
1545cdf0e10cSrcweir                     pPrv = pLay;
1546cdf0e10cSrcweir                     pLay = pLay->GetUpper();
1547cdf0e10cSrcweir                 }
1548cdf0e10cSrcweir 
1549cdf0e10cSrcweir                 // new section frame
1550cdf0e10cSrcweir                 pFrm = pActualSection->GetSectionNode()->MakeFrm( pLay );
1551cdf0e10cSrcweir                 pFrm->InsertBehind( pLay, pPrv );
1552cdf0e10cSrcweir                 static_cast<SwSectionFrm*>(pFrm)->Init();
1553cdf0e10cSrcweir 
1554cdf0e10cSrcweir                 // OD 12.08.2003 #i17969# - consider horizontal/vertical layout
1555cdf0e10cSrcweir                 // for setting position at newly inserted frame
1556cdf0e10cSrcweir                 lcl_SetPos( *pFrm, *pLay );
1557cdf0e10cSrcweir 
1558cdf0e10cSrcweir                 SwSectionFrm* pOuterSectionFrm = pActualSection->GetSectionFrm();
1559cdf0e10cSrcweir 
1560cdf0e10cSrcweir                 // a follow has to be appended to the new section frame
1561cdf0e10cSrcweir                 SwSectionFrm* pFollow = pOuterSectionFrm->GetFollow();
1562cdf0e10cSrcweir                 if ( pFollow )
1563cdf0e10cSrcweir                 {
1564cdf0e10cSrcweir                     pOuterSectionFrm->SetFollow( NULL );
1565cdf0e10cSrcweir                     pOuterSectionFrm->InvalidateSize();
1566cdf0e10cSrcweir                     ((SwSectionFrm*)pFrm)->SetFollow( pFollow );
1567cdf0e10cSrcweir                 }
1568cdf0e10cSrcweir 
1569cdf0e10cSrcweir                 // Wir wollen keine leeren Teile zuruecklassen
1570cdf0e10cSrcweir                 if( ! pOuterSectionFrm->IsColLocked() &&
1571cdf0e10cSrcweir                     ! pOuterSectionFrm->ContainsCntnt() )
1572cdf0e10cSrcweir                 {
1573cdf0e10cSrcweir                     pOuterSectionFrm->DelEmpty( sal_True );
1574cdf0e10cSrcweir                     delete pOuterSectionFrm;
1575cdf0e10cSrcweir                 }
1576cdf0e10cSrcweir                 pActualSection->SetSectionFrm( (SwSectionFrm*)pFrm );
1577cdf0e10cSrcweir 
1578cdf0e10cSrcweir                 pLay = (SwLayoutFrm*)pFrm;
1579cdf0e10cSrcweir                 if ( pLay->Lower() && pLay->Lower()->IsLayoutFrm() )
1580cdf0e10cSrcweir                     pLay = pLay->GetNextLayoutLeaf();
1581cdf0e10cSrcweir                 pPrv = 0;
1582cdf0e10cSrcweir             }
1583cdf0e10cSrcweir             else
1584cdf0e10cSrcweir             {
1585cdf0e10cSrcweir                 //Nix mehr mit Sections, es geht direkt hinter dem SectionFrame
1586cdf0e10cSrcweir                 //weiter.
1587cdf0e10cSrcweir                 pPrv = pLay;
1588cdf0e10cSrcweir                 pLay = pLay->GetUpper();
1589cdf0e10cSrcweir             }
1590cdf0e10cSrcweir         }
1591cdf0e10cSrcweir         else if( pNd->IsStartNode() &&
1592cdf0e10cSrcweir                  SwFlyStartNode == ((SwStartNode*)pNd)->GetStartNodeType() )
1593cdf0e10cSrcweir         {
1594cdf0e10cSrcweir             if ( pTbl->Count() && bObjsDirect && !bDontCreateObjects )
1595cdf0e10cSrcweir             {
1596cdf0e10cSrcweir                 SwFlyFrm* pFly = pLay->FindFlyFrm();
1597cdf0e10cSrcweir                 if( pFly )
1598cdf0e10cSrcweir                     AppendObjs( pTbl, nIndex, pFly, pPage );
1599cdf0e10cSrcweir             }
1600cdf0e10cSrcweir         }
1601cdf0e10cSrcweir         else
1602cdf0e10cSrcweir             // Weder Cntnt noch Tabelle noch Section,
1603cdf0e10cSrcweir             // also muessen wir fertig sein.
1604cdf0e10cSrcweir             break;
1605cdf0e10cSrcweir 
1606cdf0e10cSrcweir         ++nIndex;
1607cdf0e10cSrcweir         // Der Endnode wird nicht mehr mitgenommen, es muss vom
1608cdf0e10cSrcweir         // Aufrufenden (Section/MakeFrms()) sichergestellt sein, dass das Ende
1609cdf0e10cSrcweir         // des Bereichs vor dem EndIndex liegt!
1610cdf0e10cSrcweir         if ( nEndIndex && nIndex >= nEndIndex )
1611cdf0e10cSrcweir             break;
1612cdf0e10cSrcweir     }
1613cdf0e10cSrcweir 
1614cdf0e10cSrcweir     if ( pActualSection )
1615cdf0e10cSrcweir     {
1616cdf0e10cSrcweir         //Kann passieren, dass noch eine leere (Follow-)Section uebrig geblieben ist.
1617cdf0e10cSrcweir         if ( !(pLay = pActualSection->GetSectionFrm())->ContainsCntnt() )
1618cdf0e10cSrcweir         {
1619cdf0e10cSrcweir             pLay->Remove();
1620cdf0e10cSrcweir             delete pLay;
1621cdf0e10cSrcweir         }
1622cdf0e10cSrcweir         delete pActualSection;
1623cdf0e10cSrcweir     }
1624cdf0e10cSrcweir 
1625cdf0e10cSrcweir     if ( bPages )       //Jetzt noch die Flys verbinden lassen.
1626cdf0e10cSrcweir     {
1627cdf0e10cSrcweir         if ( !bDontCreateObjects )
1628cdf0e10cSrcweir             AppendAllObjs( pTbl, pLayout );
1629cdf0e10cSrcweir         bObjsDirect = sal_True;
1630cdf0e10cSrcweir     }
1631cdf0e10cSrcweir 
1632cdf0e10cSrcweir     if( pPageMaker )
1633cdf0e10cSrcweir     {
1634cdf0e10cSrcweir         pPageMaker->CheckFlyCache( pPage );
1635cdf0e10cSrcweir         delete pPageMaker;
1636cdf0e10cSrcweir         if( pDoc->GetLayoutCache() )
1637cdf0e10cSrcweir         {
1638cdf0e10cSrcweir #ifdef DBG_UTIL
1639cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1640cdf0e10cSrcweir             pDoc->GetLayoutCache()->CompareLayout( *pDoc );
1641cdf0e10cSrcweir #endif
1642cdf0e10cSrcweir #endif
1643cdf0e10cSrcweir             pDoc->GetLayoutCache()->ClearImpl();
1644cdf0e10cSrcweir         }
1645cdf0e10cSrcweir     }
1646cdf0e10cSrcweir 
1647cdf0e10cSrcweir     pDoc->UnblockIdling();
1648cdf0e10cSrcweir     if( bOldCallbackActionEnabled )
1649cdf0e10cSrcweir         pLayout->SetCallbackActionEnabled( bOldCallbackActionEnabled );
1650cdf0e10cSrcweir }
1651cdf0e10cSrcweir 
1652cdf0e10cSrcweir 
MakeFrms(SwDoc * pDoc,const SwNodeIndex & rSttIdx,const SwNodeIndex & rEndIdx)1653cdf0e10cSrcweir void MakeFrms( SwDoc *pDoc, const SwNodeIndex &rSttIdx,
1654cdf0e10cSrcweir                const SwNodeIndex &rEndIdx )
1655cdf0e10cSrcweir {
1656cdf0e10cSrcweir     bObjsDirect = sal_False;
1657cdf0e10cSrcweir 
1658cdf0e10cSrcweir     SwNodeIndex aTmp( rSttIdx );
1659cdf0e10cSrcweir     sal_uLong nEndIdx = rEndIdx.GetIndex();
1660cdf0e10cSrcweir     SwNode* pNd = pDoc->GetNodes().FindPrvNxtFrmNode( aTmp,
1661cdf0e10cSrcweir                                             pDoc->GetNodes()[ nEndIdx-1 ]);
1662cdf0e10cSrcweir     if ( pNd )
1663cdf0e10cSrcweir     {
1664cdf0e10cSrcweir         sal_Bool bApres = aTmp < rSttIdx;
1665cdf0e10cSrcweir         SwNode2Layout aNode2Layout( *pNd, rSttIdx.GetIndex() );
1666cdf0e10cSrcweir         SwFrm* pFrm;
1667cdf0e10cSrcweir         while( 0 != (pFrm = aNode2Layout.NextFrm()) )
1668cdf0e10cSrcweir         {
1669cdf0e10cSrcweir             SwLayoutFrm *pUpper = pFrm->GetUpper();
1670cdf0e10cSrcweir             SwFtnFrm* pFtnFrm = pUpper->FindFtnFrm();
1671cdf0e10cSrcweir             sal_Bool bOldLock, bOldFtn;
1672cdf0e10cSrcweir             if( pFtnFrm )
1673cdf0e10cSrcweir             {
1674cdf0e10cSrcweir                 bOldFtn = pFtnFrm->IsColLocked();
1675cdf0e10cSrcweir                 pFtnFrm->ColLock();
1676cdf0e10cSrcweir             }
1677cdf0e10cSrcweir             else
1678cdf0e10cSrcweir                 bOldFtn = sal_True;
1679cdf0e10cSrcweir             SwSectionFrm* pSct = pUpper->FindSctFrm();
1680cdf0e10cSrcweir             // Es sind innerhalb von Fussnoten nur die Bereiche interessant,
1681cdf0e10cSrcweir             // die in den Fussnoten liegen, nicht etwa die (spaltigen) Bereiche,
1682cdf0e10cSrcweir             // in denen die Fussnoten(Container) liegen.
1683cdf0e10cSrcweir             // #109767# Table frame is in section, insert section in cell frame.
1684cdf0e10cSrcweir             if( pSct && ((pFtnFrm && !pSct->IsInFtn()) || pUpper->IsCellFrm()) )
1685cdf0e10cSrcweir                 pSct = NULL;
1686cdf0e10cSrcweir             if( pSct )
1687cdf0e10cSrcweir             {   // damit der SectionFrm nicht zerstoert wird durch pTmp->MoveFwd()
1688cdf0e10cSrcweir                 bOldLock = pSct->IsColLocked();
1689cdf0e10cSrcweir                 pSct->ColLock();
1690cdf0e10cSrcweir             }
1691cdf0e10cSrcweir             else
1692cdf0e10cSrcweir                 bOldLock = sal_True;
1693cdf0e10cSrcweir 
1694cdf0e10cSrcweir             // Wenn pFrm sich nicht bewegen kann, koennen wir auch niemanden
1695cdf0e10cSrcweir             // auf die naechste Seite schieben. Innerhalb eines Rahmens auch
1696cdf0e10cSrcweir             // nicht ( in der 1. Spalte eines Rahmens waere pFrm Moveable()! )
1697cdf0e10cSrcweir             // Auch in spaltigen Bereichen in Tabellen waere pFrm Moveable.
1698cdf0e10cSrcweir             sal_Bool bMoveNext = nEndIdx - rSttIdx.GetIndex() > 120;
1699cdf0e10cSrcweir             sal_Bool bAllowMove = !pFrm->IsInFly() && pFrm->IsMoveable() &&
1700cdf0e10cSrcweir                  (!pFrm->IsInTab() || pFrm->IsTabFrm() );
1701cdf0e10cSrcweir             if ( bMoveNext && bAllowMove )
1702cdf0e10cSrcweir             {
1703cdf0e10cSrcweir                 SwFrm *pMove = pFrm;
1704cdf0e10cSrcweir                 SwFrm *pPrev = pFrm->GetPrev();
1705cdf0e10cSrcweir                 SwFlowFrm *pTmp = SwFlowFrm::CastFlowFrm( pMove );
1706cdf0e10cSrcweir                 ASSERT( pTmp, "Missing FlowFrm" );
1707cdf0e10cSrcweir 
1708cdf0e10cSrcweir                 if ( bApres )
1709cdf0e10cSrcweir                 {
1710cdf0e10cSrcweir                     // Wir wollen, dass der Rest der Seite leer ist, d.h.
1711cdf0e10cSrcweir                     // der naechste muss auf die naechste Seite wandern.
1712cdf0e10cSrcweir                     // Dieser kann auch in der naechsten Spalte stehen!
1713cdf0e10cSrcweir                     ASSERT( !pTmp->HasFollow(), "Follows forbidden" );
1714cdf0e10cSrcweir                     pPrev = pFrm;
1715cdf0e10cSrcweir                     // Wenn unser umgebender SectionFrm einen Next besitzt,
1716cdf0e10cSrcweir                     // so soll dieser ebenfalls gemoved werden!
1717cdf0e10cSrcweir                     pMove = pFrm->GetIndNext();
1718cdf0e10cSrcweir                     SwColumnFrm* pCol = (SwColumnFrm*)pFrm->FindColFrm();
1719cdf0e10cSrcweir                     if( pCol )
1720cdf0e10cSrcweir                         pCol = (SwColumnFrm*)pCol->GetNext();
1721cdf0e10cSrcweir                     do
1722cdf0e10cSrcweir                     {
1723cdf0e10cSrcweir                         if( pCol && !pMove )
1724cdf0e10cSrcweir                         {   // Bisher haben wir keinen Nachfolger gefunden
1725cdf0e10cSrcweir                             // jetzt gucken wir in die naechste Spalte
1726cdf0e10cSrcweir                             pMove = pCol->ContainsAny();
1727cdf0e10cSrcweir                             if( pCol->GetNext() )
1728cdf0e10cSrcweir                                 pCol = (SwColumnFrm*)pCol->GetNext();
1729cdf0e10cSrcweir                             else if( pCol->IsInSct() )
1730cdf0e10cSrcweir                             {   // Wenn es keine naechste Spalte gibt, wir aber
1731cdf0e10cSrcweir                                 // innerhalb eines spaltigen Bereichs sind,
1732cdf0e10cSrcweir                                 // koennte es noch ausserhalb des Bereich
1733cdf0e10cSrcweir                                 // (Seiten-)Spalten geben
1734cdf0e10cSrcweir                                 pCol = (SwColumnFrm*)pCol->FindSctFrm()->FindColFrm();
1735cdf0e10cSrcweir                                 if( pCol )
1736cdf0e10cSrcweir                                     pCol = (SwColumnFrm*)pCol->GetNext();
1737cdf0e10cSrcweir                             }
1738cdf0e10cSrcweir                             else
1739cdf0e10cSrcweir                                 pCol = NULL;
1740cdf0e10cSrcweir                         }
1741cdf0e10cSrcweir                         // Falls hier verschrottete SectionFrms herumgammeln,
1742cdf0e10cSrcweir                         // muessen diese uebersprungen werden.
1743cdf0e10cSrcweir                         while( pMove && pMove->IsSctFrm() &&
1744cdf0e10cSrcweir                                !((SwSectionFrm*)pMove)->GetSection() )
1745cdf0e10cSrcweir                             pMove = pMove->GetNext();
1746cdf0e10cSrcweir                     } while( !pMove && pCol );
1747cdf0e10cSrcweir 
1748cdf0e10cSrcweir                     if( pMove )
1749cdf0e10cSrcweir                     {
1750cdf0e10cSrcweir                         if ( pMove->IsCntntFrm() )
1751cdf0e10cSrcweir                             pTmp = (SwCntntFrm*)pMove;
1752cdf0e10cSrcweir                         else if ( pMove->IsTabFrm() )
1753cdf0e10cSrcweir                             pTmp = (SwTabFrm*)pMove;
1754cdf0e10cSrcweir                         else if ( pMove->IsSctFrm() )
1755cdf0e10cSrcweir                         {
1756cdf0e10cSrcweir                             pMove = ((SwSectionFrm*)pMove)->ContainsAny();
1757cdf0e10cSrcweir                             if( pMove )
1758cdf0e10cSrcweir                                 pTmp = SwFlowFrm::CastFlowFrm( pMove );
1759cdf0e10cSrcweir                             else
1760cdf0e10cSrcweir                                 pTmp = NULL;
1761cdf0e10cSrcweir                         }
1762cdf0e10cSrcweir                     }
1763cdf0e10cSrcweir                     else
1764cdf0e10cSrcweir                         pTmp = 0;
1765cdf0e10cSrcweir                 }
1766cdf0e10cSrcweir                 else
1767cdf0e10cSrcweir                 {
1768cdf0e10cSrcweir                     ASSERT( !pTmp->IsFollow(), "Follows really forbidden" );
1769cdf0e10cSrcweir                     // Bei Bereichen muss natuerlich der Inhalt auf die Reise
1770cdf0e10cSrcweir                     // geschickt werden.
1771cdf0e10cSrcweir                     if( pMove->IsSctFrm() )
1772cdf0e10cSrcweir                     {
1773cdf0e10cSrcweir                         while( pMove && pMove->IsSctFrm() &&
1774cdf0e10cSrcweir                                !((SwSectionFrm*)pMove)->GetSection() )
1775cdf0e10cSrcweir                             pMove = pMove->GetNext();
1776cdf0e10cSrcweir                         if( pMove && pMove->IsSctFrm() )
1777cdf0e10cSrcweir                             pMove = ((SwSectionFrm*)pMove)->ContainsAny();
1778cdf0e10cSrcweir                         if( pMove )
1779cdf0e10cSrcweir                             pTmp = SwFlowFrm::CastFlowFrm( pMove );
1780cdf0e10cSrcweir                         else
1781cdf0e10cSrcweir                             pTmp = NULL;
1782cdf0e10cSrcweir                     }
1783cdf0e10cSrcweir                 }
1784cdf0e10cSrcweir 
1785cdf0e10cSrcweir                 if( pTmp )
1786cdf0e10cSrcweir                 {
1787cdf0e10cSrcweir                     SwFrm* pOldUp = pTmp->GetFrm()->GetUpper();
1788cdf0e10cSrcweir                     // MoveFwd==sal_True bedeutet, dass wir auf der gleichen
1789cdf0e10cSrcweir                     // Seite geblieben sind, wir wollen aber die Seite wechseln,
1790cdf0e10cSrcweir                     // sofern dies moeglich ist
1791cdf0e10cSrcweir                     sal_Bool bTmpOldLock = pTmp->IsJoinLocked();
1792cdf0e10cSrcweir                     pTmp->LockJoin();
1793cdf0e10cSrcweir                     while( pTmp->MoveFwd( sal_True, sal_False, sal_True ) )
1794cdf0e10cSrcweir                     {
1795cdf0e10cSrcweir                         if( pOldUp == pTmp->GetFrm()->GetUpper() )
1796cdf0e10cSrcweir                             break;
1797cdf0e10cSrcweir                         pOldUp = pTmp->GetFrm()->GetUpper();
1798cdf0e10cSrcweir                     }
1799cdf0e10cSrcweir                     if( !bTmpOldLock )
1800cdf0e10cSrcweir                         pTmp->UnlockJoin();
1801cdf0e10cSrcweir                 }
1802cdf0e10cSrcweir                 ::_InsertCnt( pUpper, pDoc, rSttIdx.GetIndex(),
1803cdf0e10cSrcweir                               pFrm->IsInDocBody(), nEndIdx, pPrev );
1804cdf0e10cSrcweir             }
1805cdf0e10cSrcweir             else
1806cdf0e10cSrcweir             {
1807cdf0e10cSrcweir                 sal_Bool bSplit;
1808cdf0e10cSrcweir                 SwFrm* pPrv = bApres ? pFrm : pFrm->GetPrev();
1809cdf0e10cSrcweir                 // Wenn in einen SectionFrm ein anderer eingefuegt wird,
1810cdf0e10cSrcweir                 // muss dieser aufgebrochen werden
1811cdf0e10cSrcweir                 if( pSct && rSttIdx.GetNode().IsSectionNode() )
1812cdf0e10cSrcweir                 {
1813cdf0e10cSrcweir                     bSplit = pSct->SplitSect( pFrm, bApres );
1814cdf0e10cSrcweir                     // Wenn pSct nicht aufgespalten werden konnte
1815cdf0e10cSrcweir                     if( !bSplit && !bApres )
1816cdf0e10cSrcweir                     {
1817cdf0e10cSrcweir                         pUpper = pSct->GetUpper();
1818cdf0e10cSrcweir                         pPrv = pSct->GetPrev();
1819cdf0e10cSrcweir                     }
1820cdf0e10cSrcweir                 }
1821cdf0e10cSrcweir                 else
1822cdf0e10cSrcweir                     bSplit = sal_False;
1823cdf0e10cSrcweir                 ::_InsertCnt( pUpper, pDoc, rSttIdx.GetIndex(), sal_False,
1824cdf0e10cSrcweir                               nEndIdx, pPrv );
1825cdf0e10cSrcweir                 // OD 23.06.2003 #108784# - correction: append objects doesn't
1826cdf0e10cSrcweir                 // depend on value of <bAllowMove>
1827cdf0e10cSrcweir                 if( !bDontCreateObjects )
1828cdf0e10cSrcweir                 {
1829cdf0e10cSrcweir                     const SwSpzFrmFmts *pTbl = pDoc->GetSpzFrmFmts();
1830cdf0e10cSrcweir                     if( pTbl->Count() )
1831cdf0e10cSrcweir                         AppendAllObjs( pTbl, pUpper );
1832cdf0e10cSrcweir                 }
1833cdf0e10cSrcweir 
1834cdf0e10cSrcweir                 // Wenn nichts eingefuegt wurde, z.B. ein ausgeblendeter Bereich,
1835cdf0e10cSrcweir                 // muss das Splitten rueckgaengig gemacht werden
1836cdf0e10cSrcweir                 if( bSplit && pSct && pSct->GetNext()
1837cdf0e10cSrcweir                     && pSct->GetNext()->IsSctFrm() )
1838cdf0e10cSrcweir                     pSct->MergeNext( (SwSectionFrm*)pSct->GetNext() );
1839cdf0e10cSrcweir                 if( pFrm->IsInFly() )
1840cdf0e10cSrcweir                     pFrm->FindFlyFrm()->_Invalidate();
1841cdf0e10cSrcweir                 if( pFrm->IsInTab() )
1842cdf0e10cSrcweir                     pFrm->InvalidateSize();
1843cdf0e10cSrcweir             }
1844cdf0e10cSrcweir 
1845cdf0e10cSrcweir             SwPageFrm *pPage = pUpper->FindPageFrm();
1846cdf0e10cSrcweir             SwFrm::CheckPageDescs( pPage, sal_False );
1847cdf0e10cSrcweir             if( !bOldFtn )
1848cdf0e10cSrcweir                 pFtnFrm->ColUnlock();
1849cdf0e10cSrcweir             if( !bOldLock )
1850cdf0e10cSrcweir             {
1851cdf0e10cSrcweir                 pSct->ColUnlock();
1852cdf0e10cSrcweir                 // Zum Beispiel beim Einfuegen von gelinkten Bereichen,
1853cdf0e10cSrcweir                 // die wiederum Bereiche enthalten, kann pSct jetzt leer sein
1854cdf0e10cSrcweir                 // und damit ruhig zerstoert werden.
1855cdf0e10cSrcweir                 if( !pSct->ContainsCntnt() )
1856cdf0e10cSrcweir                 {
1857cdf0e10cSrcweir                     pSct->DelEmpty( sal_True );
1858cdf0e10cSrcweir                     pUpper->getRootFrm()->RemoveFromList( pSct );
1859cdf0e10cSrcweir                     delete pSct;
1860cdf0e10cSrcweir                 }
1861cdf0e10cSrcweir             }
1862cdf0e10cSrcweir         }
1863cdf0e10cSrcweir     }
1864cdf0e10cSrcweir 
1865cdf0e10cSrcweir     bObjsDirect = sal_True;
1866cdf0e10cSrcweir }
1867cdf0e10cSrcweir 
1868cdf0e10cSrcweir 
1869cdf0e10cSrcweir /*************************************************************************/
1870cdf0e10cSrcweir 
SwBorderAttrs(const SwModify * pMod,const SwFrm * pConstructor)1871cdf0e10cSrcweir SwBorderAttrs::SwBorderAttrs( const SwModify *pMod, const SwFrm *pConstructor ) :
1872cdf0e10cSrcweir     SwCacheObj( pMod ),
1873cdf0e10cSrcweir     rAttrSet( pConstructor->IsCntntFrm()
1874cdf0e10cSrcweir                     ? ((SwCntntFrm*)pConstructor)->GetNode()->GetSwAttrSet()
1875cdf0e10cSrcweir                     : ((SwLayoutFrm*)pConstructor)->GetFmt()->GetAttrSet() ),
1876cdf0e10cSrcweir     rUL     ( rAttrSet.GetULSpace() ),
1877cdf0e10cSrcweir     // --> OD 2008-12-04 #i96772#
1878cdf0e10cSrcweir     // LRSpaceItem is copied due to the possibility that it is adjusted - see below
1879cdf0e10cSrcweir     rLR     ( rAttrSet.GetLRSpace() ),
1880cdf0e10cSrcweir     // <--
1881cdf0e10cSrcweir     rBox    ( rAttrSet.GetBox()     ),
1882cdf0e10cSrcweir     rShadow ( rAttrSet.GetShadow()  ),
1883cdf0e10cSrcweir     aFrmSize( rAttrSet.GetFrmSize().GetSize() )
1884cdf0e10cSrcweir {
1885cdf0e10cSrcweir     // --> OD 2008-12-02 #i96772#
1886cdf0e10cSrcweir     const SwTxtFrm* pTxtFrm = dynamic_cast<const SwTxtFrm*>(pConstructor);
1887cdf0e10cSrcweir     if ( pTxtFrm )
1888cdf0e10cSrcweir     {
1889cdf0e10cSrcweir         pTxtFrm->GetTxtNode()->ClearLRSpaceItemDueToListLevelIndents( rLR );
1890cdf0e10cSrcweir     }
1891cdf0e10cSrcweir 
1892cdf0e10cSrcweir     //Achtung: Die USHORTs fuer die gecache'ten Werte werden absichtlich
1893cdf0e10cSrcweir     //nicht initialisiert!
1894cdf0e10cSrcweir 
1895cdf0e10cSrcweir     //Muessen alle einmal berechnet werden:
1896cdf0e10cSrcweir     bTopLine = bBottomLine = bLeftLine = bRightLine =
1897cdf0e10cSrcweir     bTop     = bBottom     = bLine   = sal_True;
1898cdf0e10cSrcweir 
1899cdf0e10cSrcweir     bCacheGetLine = bCachedGetTopLine = bCachedGetBottomLine = sal_False;
1900cdf0e10cSrcweir     // OD 21.05.2003 #108789# - init cache status for values <bJoinedWithPrev>
1901cdf0e10cSrcweir     // and <bJoinedWithNext>, which aren't initialized by default.
1902cdf0e10cSrcweir     bCachedJoinedWithPrev = sal_False;
1903cdf0e10cSrcweir     bCachedJoinedWithNext = sal_False;
1904cdf0e10cSrcweir 
1905cdf0e10cSrcweir     bBorderDist = 0 != (pConstructor->GetType() & (FRM_CELL));
1906cdf0e10cSrcweir }
1907cdf0e10cSrcweir 
~SwBorderAttrs()1908cdf0e10cSrcweir SwBorderAttrs::~SwBorderAttrs()
1909cdf0e10cSrcweir {
1910cdf0e10cSrcweir     ((SwModify*)pOwner)->SetInCache( sal_False );
1911cdf0e10cSrcweir }
1912cdf0e10cSrcweir 
1913cdf0e10cSrcweir /*************************************************************************
1914cdf0e10cSrcweir |*
1915cdf0e10cSrcweir |*  SwBorderAttrs::CalcTop(), CalcBottom(), CalcLeft(), CalcRight()
1916cdf0e10cSrcweir |*
1917cdf0e10cSrcweir |*  Beschreibung        Die Calc-Methoden errechnen zusaetzlich zu den
1918cdf0e10cSrcweir |*      von den Attributen vorgegebenen Groessen einen Sicherheitsabstand.
1919cdf0e10cSrcweir |*      der Sicherheitsabstand wird nur einkalkuliert, wenn Umrandung und/oder
1920cdf0e10cSrcweir |*      Schatten im Spiel sind; er soll vermeiden, dass aufgrund der
1921cdf0e10cSrcweir |*      groben physikalischen Gegebenheiten Raender usw. uebermalt werden.
1922cdf0e10cSrcweir |*
1923cdf0e10cSrcweir |*************************************************************************/
1924cdf0e10cSrcweir 
_CalcTop()1925cdf0e10cSrcweir void SwBorderAttrs::_CalcTop()
1926cdf0e10cSrcweir {
1927cdf0e10cSrcweir     nTop = CalcTopLine() + rUL.GetUpper();
1928cdf0e10cSrcweir     bTop = sal_False;
1929cdf0e10cSrcweir }
1930cdf0e10cSrcweir 
_CalcBottom()1931cdf0e10cSrcweir void SwBorderAttrs::_CalcBottom()
1932cdf0e10cSrcweir {
1933cdf0e10cSrcweir     nBottom = CalcBottomLine() + rUL.GetLower();
1934cdf0e10cSrcweir     bBottom = sal_False;
1935cdf0e10cSrcweir }
1936cdf0e10cSrcweir 
CalcRight(const SwFrm * pCaller) const1937cdf0e10cSrcweir long SwBorderAttrs::CalcRight( const SwFrm* pCaller ) const
1938cdf0e10cSrcweir {
1939cdf0e10cSrcweir     long nRight;
1940cdf0e10cSrcweir 
1941cdf0e10cSrcweir     // OD 23.01.2003 #106895# - for cell frame in R2L text direction the left
1942cdf0e10cSrcweir     // and right border are painted on the right respectively left.
1943cdf0e10cSrcweir     if ( pCaller->IsCellFrm() && pCaller->IsRightToLeft() )
1944cdf0e10cSrcweir         nRight = CalcLeftLine();
1945cdf0e10cSrcweir     else
1946cdf0e10cSrcweir         nRight = CalcRightLine();
1947cdf0e10cSrcweir 
1948cdf0e10cSrcweir     // for paragraphs, "left" is "before text" and "right" is "after text"
1949cdf0e10cSrcweir     if ( pCaller->IsTxtFrm() && pCaller->IsRightToLeft() )
1950cdf0e10cSrcweir         nRight += rLR.GetLeft();
1951cdf0e10cSrcweir     else
1952cdf0e10cSrcweir         nRight += rLR.GetRight();
1953cdf0e10cSrcweir 
1954cdf0e10cSrcweir     // --> OD 2008-01-21 #newlistlevelattrs#
1955cdf0e10cSrcweir     // correction: retrieve left margin for numbering in R2L-layout
1956cdf0e10cSrcweir     if ( pCaller->IsTxtFrm() && pCaller->IsRightToLeft() )
1957cdf0e10cSrcweir     {
1958cdf0e10cSrcweir         nRight += ((SwTxtFrm*)pCaller)->GetTxtNode()->GetLeftMarginWithNum();
1959cdf0e10cSrcweir     }
1960cdf0e10cSrcweir     // <--
1961cdf0e10cSrcweir 
1962cdf0e10cSrcweir     return nRight;
1963cdf0e10cSrcweir }
1964cdf0e10cSrcweir 
CalcLeft(const SwFrm * pCaller) const1965cdf0e10cSrcweir long SwBorderAttrs::CalcLeft( const SwFrm *pCaller ) const
1966cdf0e10cSrcweir {
1967cdf0e10cSrcweir     long nLeft;
1968cdf0e10cSrcweir 
1969cdf0e10cSrcweir     // OD 23.01.2003 #106895# - for cell frame in R2L text direction the left
1970cdf0e10cSrcweir     // and right border are painted on the right respectively left.
1971cdf0e10cSrcweir     if ( pCaller->IsCellFrm() && pCaller->IsRightToLeft() )
1972cdf0e10cSrcweir         nLeft = CalcRightLine();
1973cdf0e10cSrcweir     else
1974cdf0e10cSrcweir         nLeft = CalcLeftLine();
1975cdf0e10cSrcweir 
1976cdf0e10cSrcweir     // for paragraphs, "left" is "before text" and "right" is "after text"
1977cdf0e10cSrcweir     if ( pCaller->IsTxtFrm() && pCaller->IsRightToLeft() )
1978cdf0e10cSrcweir         nLeft += rLR.GetRight();
1979cdf0e10cSrcweir     else
1980cdf0e10cSrcweir         nLeft += rLR.GetLeft();
1981cdf0e10cSrcweir 
1982cdf0e10cSrcweir     // --> OD 2008-01-21 #newlistlevelattrs#
1983cdf0e10cSrcweir     // correction: do not retrieve left margin for numbering in R2L-layout
1984cdf0e10cSrcweir //    if ( pCaller->IsTxtFrm() )
1985cdf0e10cSrcweir     if ( pCaller->IsTxtFrm() && !pCaller->IsRightToLeft() )
1986cdf0e10cSrcweir     // <--
1987cdf0e10cSrcweir     {
1988cdf0e10cSrcweir         nLeft += ((SwTxtFrm*)pCaller)->GetTxtNode()->GetLeftMarginWithNum();
1989cdf0e10cSrcweir     }
1990cdf0e10cSrcweir 
1991cdf0e10cSrcweir     return nLeft;
1992cdf0e10cSrcweir }
1993cdf0e10cSrcweir 
1994cdf0e10cSrcweir /*************************************************************************
1995cdf0e10cSrcweir |*
1996cdf0e10cSrcweir |*  SwBorderAttrs::CalcTopLine(), CalcBottomLine(),
1997cdf0e10cSrcweir |*                 CalcLeftLine(), CalcRightLine()
1998cdf0e10cSrcweir |*
1999cdf0e10cSrcweir |*  Beschreibung        Berechnung der Groessen fuer Umrandung und Schatten.
2000cdf0e10cSrcweir |*                      Es kann auch ohne Linien ein Abstand erwuenscht sein,
2001cdf0e10cSrcweir |*                      dieser wird dann nicht vom Attribut sondern hier
2002cdf0e10cSrcweir |*                      beruecksichtigt (bBorderDist, z.B. fuer Zellen).
2003cdf0e10cSrcweir |*
2004cdf0e10cSrcweir |*************************************************************************/
2005cdf0e10cSrcweir 
_CalcTopLine()2006cdf0e10cSrcweir void SwBorderAttrs::_CalcTopLine()
2007cdf0e10cSrcweir {
2008cdf0e10cSrcweir     nTopLine = (bBorderDist && !rBox.GetTop())
2009cdf0e10cSrcweir                             ? rBox.GetDistance  (BOX_LINE_TOP)
2010cdf0e10cSrcweir                             : rBox.CalcLineSpace(BOX_LINE_TOP);
2011cdf0e10cSrcweir     nTopLine = nTopLine + rShadow.CalcShadowSpace(SHADOW_TOP);
2012cdf0e10cSrcweir     bTopLine = sal_False;
2013cdf0e10cSrcweir }
2014cdf0e10cSrcweir 
_CalcBottomLine()2015cdf0e10cSrcweir void SwBorderAttrs::_CalcBottomLine()
2016cdf0e10cSrcweir {
2017cdf0e10cSrcweir     nBottomLine = (bBorderDist && !rBox.GetBottom())
2018cdf0e10cSrcweir                             ? rBox.GetDistance  (BOX_LINE_BOTTOM)
2019cdf0e10cSrcweir                             : rBox.CalcLineSpace(BOX_LINE_BOTTOM);
2020cdf0e10cSrcweir     nBottomLine = nBottomLine + rShadow.CalcShadowSpace(SHADOW_BOTTOM);
2021cdf0e10cSrcweir     bBottomLine = sal_False;
2022cdf0e10cSrcweir }
2023cdf0e10cSrcweir 
_CalcLeftLine()2024cdf0e10cSrcweir void SwBorderAttrs::_CalcLeftLine()
2025cdf0e10cSrcweir {
2026cdf0e10cSrcweir     nLeftLine = (bBorderDist && !rBox.GetLeft())
2027cdf0e10cSrcweir                             ? rBox.GetDistance  (BOX_LINE_LEFT)
2028cdf0e10cSrcweir                             : rBox.CalcLineSpace(BOX_LINE_LEFT);
2029cdf0e10cSrcweir     nLeftLine = nLeftLine + rShadow.CalcShadowSpace(SHADOW_LEFT);
2030cdf0e10cSrcweir     bLeftLine = sal_False;
2031cdf0e10cSrcweir }
2032cdf0e10cSrcweir 
_CalcRightLine()2033cdf0e10cSrcweir void SwBorderAttrs::_CalcRightLine()
2034cdf0e10cSrcweir {
2035cdf0e10cSrcweir     nRightLine = (bBorderDist && !rBox.GetRight())
2036cdf0e10cSrcweir                             ? rBox.GetDistance  (BOX_LINE_RIGHT)
2037cdf0e10cSrcweir                             : rBox.CalcLineSpace(BOX_LINE_RIGHT);
2038cdf0e10cSrcweir     nRightLine = nRightLine + rShadow.CalcShadowSpace(SHADOW_RIGHT);
2039cdf0e10cSrcweir     bRightLine = sal_False;
2040cdf0e10cSrcweir }
2041cdf0e10cSrcweir 
2042cdf0e10cSrcweir /*************************************************************************/
2043cdf0e10cSrcweir 
_IsLine()2044cdf0e10cSrcweir void SwBorderAttrs::_IsLine()
2045cdf0e10cSrcweir {
2046cdf0e10cSrcweir     bIsLine = rBox.GetTop() || rBox.GetBottom() ||
2047cdf0e10cSrcweir               rBox.GetLeft()|| rBox.GetRight();
2048cdf0e10cSrcweir     bLine = sal_False;
2049cdf0e10cSrcweir }
2050cdf0e10cSrcweir 
2051cdf0e10cSrcweir /*************************************************************************
2052cdf0e10cSrcweir |*
2053cdf0e10cSrcweir |*  SwBorderAttrs::CmpLeftRightLine(), IsTopLine(), IsBottomLine()
2054cdf0e10cSrcweir |*
2055cdf0e10cSrcweir |*      Die Umrandungen benachbarter Absaetze werden nach folgendem
2056cdf0e10cSrcweir |*      Algorithmus zusammengefasst:
2057cdf0e10cSrcweir |*
2058cdf0e10cSrcweir |*      1. Die Umrandung oben faellt weg, wenn der Vorgaenger dieselbe
2059cdf0e10cSrcweir |*         Umrandung oben aufweist und 3. Zutrifft.
2060cdf0e10cSrcweir |*         Zusaetzlich muss der Absatz mindestens rechts oder links oder
2061cdf0e10cSrcweir |*         unten eine Umrandung haben.
2062cdf0e10cSrcweir |*      2. Die Umrandung unten faellt weg, wenn der Nachfolger dieselbe
2063*6e8337c1Smseidel |*         Umrandung unten aufweist und 3. zutrifft.
2064cdf0e10cSrcweir |*         Zusaetzlich muss der Absatz mindestens rechts oder links oder
2065cdf0e10cSrcweir |*         oben eine Umrandung haben.
2066cdf0e10cSrcweir |*      3. Die Umrandungen links und rechts vor Vorgaenger bzw. Nachfolger
2067cdf0e10cSrcweir |*         sind identisch.
2068cdf0e10cSrcweir |*
2069cdf0e10cSrcweir |*************************************************************************/
CmpLines(const SvxBorderLine * pL1,const SvxBorderLine * pL2)2070cdf0e10cSrcweir inline int CmpLines( const SvxBorderLine *pL1, const SvxBorderLine *pL2 )
2071cdf0e10cSrcweir {
2072cdf0e10cSrcweir     return ( ((pL1 && pL2) && (*pL1 == *pL2)) || (!pL1 && !pL2) );
2073cdf0e10cSrcweir }
2074cdf0e10cSrcweir 
2075cdf0e10cSrcweir // OD 21.05.2003 #108789# - change name of 1st parameter - "rAttrs" -> "rCmpAttrs"
2076cdf0e10cSrcweir // OD 21.05.2003 #108789# - compare <CalcRight()> and <rCmpAttrs.CalcRight()>
2077cdf0e10cSrcweir //          instead of only the right LR-spacing, because R2L-layout has to be
2078cdf0e10cSrcweir //          considered.
CmpLeftRight(const SwBorderAttrs & rCmpAttrs,const SwFrm * pCaller,const SwFrm * pCmp) const2079cdf0e10cSrcweir sal_Bool SwBorderAttrs::CmpLeftRight( const SwBorderAttrs &rCmpAttrs,
2080cdf0e10cSrcweir                                   const SwFrm *pCaller,
2081cdf0e10cSrcweir                                   const SwFrm *pCmp ) const
2082cdf0e10cSrcweir {
2083cdf0e10cSrcweir     return ( CmpLines( rCmpAttrs.GetBox().GetLeft(), GetBox().GetLeft()  ) &&
2084cdf0e10cSrcweir              CmpLines( rCmpAttrs.GetBox().GetRight(),GetBox().GetRight() ) &&
2085cdf0e10cSrcweir              CalcLeft( pCaller ) == rCmpAttrs.CalcLeft( pCmp ) &&
2086cdf0e10cSrcweir              // OD 21.05.2003 #108789# - compare <CalcRight> with <rCmpAttrs.CalcRight>.
2087cdf0e10cSrcweir              CalcRight( pCaller ) == rCmpAttrs.CalcRight( pCmp ) );
2088cdf0e10cSrcweir }
2089cdf0e10cSrcweir 
_JoinWithCmp(const SwFrm & _rCallerFrm,const SwFrm & _rCmpFrm) const2090cdf0e10cSrcweir sal_Bool SwBorderAttrs::_JoinWithCmp( const SwFrm& _rCallerFrm,
2091cdf0e10cSrcweir                                   const SwFrm& _rCmpFrm ) const
2092cdf0e10cSrcweir {
2093cdf0e10cSrcweir     sal_Bool bReturnVal = sal_False;
2094cdf0e10cSrcweir 
2095cdf0e10cSrcweir     SwBorderAttrAccess aCmpAccess( SwFrm::GetCache(), &_rCmpFrm );
2096cdf0e10cSrcweir     const SwBorderAttrs &rCmpAttrs = *aCmpAccess.Get();
2097cdf0e10cSrcweir     if ( rShadow == rCmpAttrs.GetShadow() &&
2098cdf0e10cSrcweir          CmpLines( rBox.GetTop(), rCmpAttrs.GetBox().GetTop() ) &&
2099cdf0e10cSrcweir          CmpLines( rBox.GetBottom(), rCmpAttrs.GetBox().GetBottom() ) &&
2100cdf0e10cSrcweir          CmpLeftRight( rCmpAttrs, &_rCallerFrm, &_rCmpFrm )
2101cdf0e10cSrcweir        )
2102cdf0e10cSrcweir     {
2103cdf0e10cSrcweir         bReturnVal = sal_True;
2104cdf0e10cSrcweir     }
2105cdf0e10cSrcweir 
2106cdf0e10cSrcweir     return bReturnVal;
2107cdf0e10cSrcweir }
2108cdf0e10cSrcweir 
2109cdf0e10cSrcweir // OD 21.05.2003 #108789# - method to determine, if borders are joined with
2110cdf0e10cSrcweir // previous frame. Calculated value saved in cached value <bJoinedWithPrev>
2111cdf0e10cSrcweir // OD 2004-02-26 #i25029# - add 2nd parameter <_pPrevFrm>
_CalcJoinedWithPrev(const SwFrm & _rFrm,const SwFrm * _pPrevFrm)2112cdf0e10cSrcweir void SwBorderAttrs::_CalcJoinedWithPrev( const SwFrm& _rFrm,
2113cdf0e10cSrcweir                                          const SwFrm* _pPrevFrm )
2114cdf0e10cSrcweir {
2115cdf0e10cSrcweir     // set default
2116cdf0e10cSrcweir     bJoinedWithPrev = sal_False;
2117cdf0e10cSrcweir 
2118cdf0e10cSrcweir     if ( _rFrm.IsTxtFrm() )
2119cdf0e10cSrcweir     {
2120cdf0e10cSrcweir         // text frame can potentially join with previous text frame, if
2121cdf0e10cSrcweir         // corresponding attribute set is set at previous text frame.
2122cdf0e10cSrcweir         // OD 2004-02-26 #i25029# - If parameter <_pPrevFrm> is set, take this
2123cdf0e10cSrcweir         // one as previous frame.
2124cdf0e10cSrcweir         const SwFrm* pPrevFrm = _pPrevFrm ? _pPrevFrm : _rFrm.GetPrev();
2125cdf0e10cSrcweir         // OD 2004-02-13 #i25029# - skip hidden text frames.
2126cdf0e10cSrcweir         while ( pPrevFrm && pPrevFrm->IsTxtFrm() &&
2127cdf0e10cSrcweir                 static_cast<const SwTxtFrm*>(pPrevFrm)->IsHiddenNow() )
2128cdf0e10cSrcweir         {
2129cdf0e10cSrcweir             pPrevFrm = pPrevFrm->GetPrev();
2130cdf0e10cSrcweir         }
2131cdf0e10cSrcweir         if ( pPrevFrm && pPrevFrm->IsTxtFrm() &&
2132cdf0e10cSrcweir              pPrevFrm->GetAttrSet()->GetParaConnectBorder().GetValue()
2133cdf0e10cSrcweir            )
2134cdf0e10cSrcweir         {
2135cdf0e10cSrcweir             bJoinedWithPrev = _JoinWithCmp( _rFrm, *(pPrevFrm) );
2136cdf0e10cSrcweir         }
2137cdf0e10cSrcweir     }
2138cdf0e10cSrcweir 
2139cdf0e10cSrcweir     // valid cache status, if demanded
2140cdf0e10cSrcweir     // OD 2004-02-26 #i25029# - Do not validate cache, if parameter <_pPrevFrm>
2141cdf0e10cSrcweir     // is set.
2142cdf0e10cSrcweir     bCachedJoinedWithPrev = bCacheGetLine && !_pPrevFrm;
2143cdf0e10cSrcweir }
2144cdf0e10cSrcweir 
2145cdf0e10cSrcweir // OD 21.05.2003 #108789# - method to determine, if borders are joined with
2146cdf0e10cSrcweir // next frame. Calculated value saved in cached value <bJoinedWithNext>
_CalcJoinedWithNext(const SwFrm & _rFrm)2147cdf0e10cSrcweir void SwBorderAttrs::_CalcJoinedWithNext( const SwFrm& _rFrm )
2148cdf0e10cSrcweir {
2149cdf0e10cSrcweir     // set default
2150cdf0e10cSrcweir     bJoinedWithNext = sal_False;
2151cdf0e10cSrcweir 
2152cdf0e10cSrcweir     if ( _rFrm.IsTxtFrm() )
2153cdf0e10cSrcweir     {
2154cdf0e10cSrcweir         // text frame can potentially join with next text frame, if
2155cdf0e10cSrcweir         // corresponding attribute set is set at current text frame.
2156cdf0e10cSrcweir         // OD 2004-02-13 #i25029# - get next frame, but skip hidden text frames.
2157cdf0e10cSrcweir         const SwFrm* pNextFrm = _rFrm.GetNext();
2158cdf0e10cSrcweir         while ( pNextFrm && pNextFrm->IsTxtFrm() &&
2159cdf0e10cSrcweir                 static_cast<const SwTxtFrm*>(pNextFrm)->IsHiddenNow() )
2160cdf0e10cSrcweir         {
2161cdf0e10cSrcweir             pNextFrm = pNextFrm->GetNext();
2162cdf0e10cSrcweir         }
2163cdf0e10cSrcweir         if ( pNextFrm && pNextFrm->IsTxtFrm() &&
2164cdf0e10cSrcweir              _rFrm.GetAttrSet()->GetParaConnectBorder().GetValue()
2165cdf0e10cSrcweir            )
2166cdf0e10cSrcweir         {
2167cdf0e10cSrcweir             bJoinedWithNext = _JoinWithCmp( _rFrm, *(pNextFrm) );
2168cdf0e10cSrcweir         }
2169cdf0e10cSrcweir     }
2170cdf0e10cSrcweir 
2171cdf0e10cSrcweir     // valid cache status, if demanded
2172cdf0e10cSrcweir     bCachedJoinedWithNext = bCacheGetLine;
2173cdf0e10cSrcweir }
2174cdf0e10cSrcweir 
2175cdf0e10cSrcweir // OD 21.05.2003 #108789# - accessor for cached values <bJoinedWithPrev>
2176cdf0e10cSrcweir // OD 2004-02-26 #i25029# - add 2nd parameter <_pPrevFrm>, which is passed to
2177cdf0e10cSrcweir // method <_CalcJoindWithPrev(..)>.
JoinedWithPrev(const SwFrm & _rFrm,const SwFrm * _pPrevFrm) const2178cdf0e10cSrcweir sal_Bool SwBorderAttrs::JoinedWithPrev( const SwFrm& _rFrm,
2179cdf0e10cSrcweir                                     const SwFrm* _pPrevFrm ) const
2180cdf0e10cSrcweir {
2181cdf0e10cSrcweir     if ( !bCachedJoinedWithPrev || _pPrevFrm )
2182cdf0e10cSrcweir     {
2183cdf0e10cSrcweir         // OD 2004-02-26 #i25029# - pass <_pPrevFrm> as 2nd parameter
2184cdf0e10cSrcweir         const_cast<SwBorderAttrs*>(this)->_CalcJoinedWithPrev( _rFrm, _pPrevFrm );
2185cdf0e10cSrcweir     }
2186cdf0e10cSrcweir 
2187cdf0e10cSrcweir     return bJoinedWithPrev;
2188cdf0e10cSrcweir }
2189cdf0e10cSrcweir 
JoinedWithNext(const SwFrm & _rFrm) const2190cdf0e10cSrcweir sal_Bool SwBorderAttrs::JoinedWithNext( const SwFrm& _rFrm ) const
2191cdf0e10cSrcweir {
2192cdf0e10cSrcweir     if ( !bCachedJoinedWithNext )
2193cdf0e10cSrcweir     {
2194cdf0e10cSrcweir         const_cast<SwBorderAttrs*>(this)->_CalcJoinedWithNext( _rFrm );
2195cdf0e10cSrcweir     }
2196cdf0e10cSrcweir 
2197cdf0e10cSrcweir     return bJoinedWithNext;
2198cdf0e10cSrcweir }
2199cdf0e10cSrcweir 
2200cdf0e10cSrcweir // OD 2004-02-26 #i25029# - added 2nd parameter <_pPrevFrm>, which is passed to
2201cdf0e10cSrcweir // method <JoinedWithPrev>
_GetTopLine(const SwFrm & _rFrm,const SwFrm * _pPrevFrm)2202cdf0e10cSrcweir void SwBorderAttrs::_GetTopLine( const SwFrm& _rFrm,
2203cdf0e10cSrcweir                                  const SwFrm* _pPrevFrm )
2204cdf0e10cSrcweir {
2205cdf0e10cSrcweir     sal_uInt16 nRet = CalcTopLine();
2206cdf0e10cSrcweir 
2207cdf0e10cSrcweir     // OD 21.05.2003 #108789# - use new method <JoinWithPrev()>
2208cdf0e10cSrcweir     // OD 2004-02-26 #i25029# - add 2nd parameter
2209cdf0e10cSrcweir     if ( JoinedWithPrev( _rFrm, _pPrevFrm ) )
2210cdf0e10cSrcweir     {
2211cdf0e10cSrcweir         nRet = 0;
2212cdf0e10cSrcweir     }
2213cdf0e10cSrcweir 
2214cdf0e10cSrcweir     bCachedGetTopLine = bCacheGetLine;
2215cdf0e10cSrcweir 
2216cdf0e10cSrcweir     nGetTopLine = nRet;
2217cdf0e10cSrcweir }
2218cdf0e10cSrcweir 
_GetBottomLine(const SwFrm & _rFrm)2219cdf0e10cSrcweir void SwBorderAttrs::_GetBottomLine( const SwFrm& _rFrm )
2220cdf0e10cSrcweir {
2221cdf0e10cSrcweir     sal_uInt16 nRet = CalcBottomLine();
2222cdf0e10cSrcweir 
2223cdf0e10cSrcweir     // OD 21.05.2003 #108789# - use new method <JoinWithPrev()>
2224cdf0e10cSrcweir     if ( JoinedWithNext( _rFrm ) )
2225cdf0e10cSrcweir     {
2226cdf0e10cSrcweir         nRet = 0;
2227cdf0e10cSrcweir     }
2228cdf0e10cSrcweir 
2229cdf0e10cSrcweir     bCachedGetBottomLine = bCacheGetLine;
2230cdf0e10cSrcweir 
2231cdf0e10cSrcweir     nGetBottomLine = nRet;
2232cdf0e10cSrcweir }
2233cdf0e10cSrcweir 
2234cdf0e10cSrcweir /*************************************************************************/
2235cdf0e10cSrcweir 
SwBorderAttrAccess(SwCache & rCach,const SwFrm * pFrm)2236cdf0e10cSrcweir SwBorderAttrAccess::SwBorderAttrAccess( SwCache &rCach, const SwFrm *pFrm ) :
2237cdf0e10cSrcweir     SwCacheAccess( rCach, (pFrm->IsCntntFrm() ?
2238cdf0e10cSrcweir                                 (void*)((SwCntntFrm*)pFrm)->GetNode() :
2239cdf0e10cSrcweir                                 (void*)((SwLayoutFrm*)pFrm)->GetFmt()),
2240cdf0e10cSrcweir                            (sal_Bool)(pFrm->IsCntntFrm() ?
2241cdf0e10cSrcweir                 ((SwModify*)((SwCntntFrm*)pFrm)->GetNode())->IsInCache() :
2242cdf0e10cSrcweir                 ((SwModify*)((SwLayoutFrm*)pFrm)->GetFmt())->IsInCache()) ),
2243cdf0e10cSrcweir     pConstructor( pFrm )
2244cdf0e10cSrcweir {
2245cdf0e10cSrcweir }
2246cdf0e10cSrcweir 
2247cdf0e10cSrcweir /*************************************************************************/
2248cdf0e10cSrcweir 
NewObj()2249cdf0e10cSrcweir SwCacheObj *SwBorderAttrAccess::NewObj()
2250cdf0e10cSrcweir {
2251cdf0e10cSrcweir     ((SwModify*)pOwner)->SetInCache( sal_True );
2252cdf0e10cSrcweir     return new SwBorderAttrs( (SwModify*)pOwner, pConstructor );
2253cdf0e10cSrcweir }
2254cdf0e10cSrcweir 
Get()2255cdf0e10cSrcweir SwBorderAttrs *SwBorderAttrAccess::Get()
2256cdf0e10cSrcweir {
2257cdf0e10cSrcweir     return (SwBorderAttrs*)SwCacheAccess::Get();
2258cdf0e10cSrcweir }
2259cdf0e10cSrcweir 
2260cdf0e10cSrcweir /*************************************************************************/
2261cdf0e10cSrcweir 
SwOrderIter(const SwPageFrm * pPg,sal_Bool bFlys)2262cdf0e10cSrcweir SwOrderIter::SwOrderIter( const SwPageFrm *pPg, sal_Bool bFlys ) :
2263cdf0e10cSrcweir     pPage( pPg ),
2264cdf0e10cSrcweir     pCurrent( 0 ),
2265cdf0e10cSrcweir     bFlysOnly( bFlys )
2266cdf0e10cSrcweir {
2267cdf0e10cSrcweir }
2268cdf0e10cSrcweir 
2269cdf0e10cSrcweir /*************************************************************************/
2270cdf0e10cSrcweir 
Top()2271cdf0e10cSrcweir const SdrObject *SwOrderIter::Top()
2272cdf0e10cSrcweir {
2273cdf0e10cSrcweir     pCurrent = 0;
2274cdf0e10cSrcweir     if ( pPage->GetSortedObjs() )
2275cdf0e10cSrcweir     {
2276cdf0e10cSrcweir         sal_uInt32 nTopOrd = 0;
2277cdf0e10cSrcweir         const SwSortedObjs *pObjs = pPage->GetSortedObjs();
2278cdf0e10cSrcweir         if ( pObjs->Count() )
2279cdf0e10cSrcweir         {
2280cdf0e10cSrcweir             (*pObjs)[0]->GetDrawObj()->GetOrdNum(); //Aktualisieren erzwingen!
2281cdf0e10cSrcweir             for ( sal_uInt16 i = 0; i < pObjs->Count(); ++i )
2282cdf0e10cSrcweir             {
2283cdf0e10cSrcweir                 const SdrObject* pObj = (*pObjs)[i]->GetDrawObj();
2284cdf0e10cSrcweir                 if ( bFlysOnly && !pObj->ISA(SwVirtFlyDrawObj) )
2285cdf0e10cSrcweir                     continue;
2286cdf0e10cSrcweir                 sal_uInt32 nTmp = pObj->GetOrdNumDirect();
2287cdf0e10cSrcweir                 if ( nTmp >= nTopOrd )
2288cdf0e10cSrcweir                 {
2289cdf0e10cSrcweir                     nTopOrd = nTmp;
2290cdf0e10cSrcweir                     pCurrent = pObj;
2291cdf0e10cSrcweir                 }
2292cdf0e10cSrcweir             }
2293cdf0e10cSrcweir         }
2294cdf0e10cSrcweir     }
2295cdf0e10cSrcweir     return pCurrent;
2296cdf0e10cSrcweir }
2297cdf0e10cSrcweir 
2298cdf0e10cSrcweir /*************************************************************************/
2299cdf0e10cSrcweir 
Bottom()2300cdf0e10cSrcweir const SdrObject *SwOrderIter::Bottom()
2301cdf0e10cSrcweir {
2302cdf0e10cSrcweir     pCurrent = 0;
2303cdf0e10cSrcweir     if ( pPage->GetSortedObjs() )
2304cdf0e10cSrcweir     {
2305cdf0e10cSrcweir         sal_uInt32 nBotOrd = USHRT_MAX;
2306cdf0e10cSrcweir         const SwSortedObjs *pObjs = pPage->GetSortedObjs();
2307cdf0e10cSrcweir         if ( pObjs->Count() )
2308cdf0e10cSrcweir         {
2309cdf0e10cSrcweir             (*pObjs)[0]->GetDrawObj()->GetOrdNum(); //Aktualisieren erzwingen!
2310cdf0e10cSrcweir             for ( sal_uInt16 i = 0; i < pObjs->Count(); ++i )
2311cdf0e10cSrcweir             {
2312cdf0e10cSrcweir                 const SdrObject* pObj = (*pObjs)[i]->GetDrawObj();
2313cdf0e10cSrcweir                 if ( bFlysOnly && !pObj->ISA(SwVirtFlyDrawObj) )
2314cdf0e10cSrcweir                     continue;
2315cdf0e10cSrcweir                 sal_uInt32 nTmp = pObj->GetOrdNumDirect();
2316cdf0e10cSrcweir                 if ( nTmp < nBotOrd )
2317cdf0e10cSrcweir                 {
2318cdf0e10cSrcweir                     nBotOrd = nTmp;
2319cdf0e10cSrcweir                     pCurrent = pObj;
2320cdf0e10cSrcweir                 }
2321cdf0e10cSrcweir             }
2322cdf0e10cSrcweir         }
2323cdf0e10cSrcweir     }
2324cdf0e10cSrcweir     return pCurrent;
2325cdf0e10cSrcweir }
2326cdf0e10cSrcweir 
2327cdf0e10cSrcweir /*************************************************************************/
2328cdf0e10cSrcweir 
Next()2329cdf0e10cSrcweir const SdrObject *SwOrderIter::Next()
2330cdf0e10cSrcweir {
2331cdf0e10cSrcweir     const sal_uInt32 nCurOrd = pCurrent ? pCurrent->GetOrdNumDirect() : 0;
2332cdf0e10cSrcweir     pCurrent = 0;
2333cdf0e10cSrcweir     if ( pPage->GetSortedObjs() )
2334cdf0e10cSrcweir     {
2335cdf0e10cSrcweir         sal_uInt32 nOrd = USHRT_MAX;
2336cdf0e10cSrcweir         const SwSortedObjs *pObjs = pPage->GetSortedObjs();
2337cdf0e10cSrcweir         if ( pObjs->Count() )
2338cdf0e10cSrcweir         {
2339cdf0e10cSrcweir             (*pObjs)[0]->GetDrawObj()->GetOrdNum(); //Aktualisieren erzwingen!
2340cdf0e10cSrcweir             for ( sal_uInt16 i = 0; i < pObjs->Count(); ++i )
2341cdf0e10cSrcweir             {
2342cdf0e10cSrcweir                 const SdrObject* pObj = (*pObjs)[i]->GetDrawObj();
2343cdf0e10cSrcweir                 if ( bFlysOnly && !pObj->ISA(SwVirtFlyDrawObj) )
2344cdf0e10cSrcweir                     continue;
2345cdf0e10cSrcweir                 sal_uInt32 nTmp = pObj->GetOrdNumDirect();
2346cdf0e10cSrcweir                 if ( nTmp > nCurOrd && nTmp < nOrd )
2347cdf0e10cSrcweir                 {
2348cdf0e10cSrcweir                     nOrd = nTmp;
2349cdf0e10cSrcweir                     pCurrent = pObj;
2350cdf0e10cSrcweir                 }
2351cdf0e10cSrcweir             }
2352cdf0e10cSrcweir         }
2353cdf0e10cSrcweir     }
2354cdf0e10cSrcweir     return pCurrent;
2355cdf0e10cSrcweir }
2356cdf0e10cSrcweir 
2357cdf0e10cSrcweir /*************************************************************************/
2358cdf0e10cSrcweir 
Prev()2359cdf0e10cSrcweir const SdrObject *SwOrderIter::Prev()
2360cdf0e10cSrcweir {
2361cdf0e10cSrcweir     const sal_uInt32 nCurOrd = pCurrent ? pCurrent->GetOrdNumDirect() : 0;
2362cdf0e10cSrcweir     pCurrent = 0;
2363cdf0e10cSrcweir     if ( pPage->GetSortedObjs() )
2364cdf0e10cSrcweir     {
2365cdf0e10cSrcweir         sal_uInt32 nOrd = 0;
2366cdf0e10cSrcweir         const SwSortedObjs *pObjs = pPage->GetSortedObjs();
2367cdf0e10cSrcweir         if ( pObjs->Count() )
2368cdf0e10cSrcweir         {
2369cdf0e10cSrcweir             (*pObjs)[0]->GetDrawObj()->GetOrdNum(); //Aktualisieren erzwingen!
2370cdf0e10cSrcweir             for ( sal_uInt16 i = 0; i < pObjs->Count(); ++i )
2371cdf0e10cSrcweir             {
2372cdf0e10cSrcweir                 const SdrObject* pObj = (*pObjs)[i]->GetDrawObj();
2373cdf0e10cSrcweir                 if ( bFlysOnly && !pObj->ISA(SwVirtFlyDrawObj) )
2374cdf0e10cSrcweir                     continue;
2375cdf0e10cSrcweir                 sal_uInt32 nTmp = pObj->GetOrdNumDirect();
2376cdf0e10cSrcweir                 if ( nTmp < nCurOrd && nTmp >= nOrd )
2377cdf0e10cSrcweir                 {
2378cdf0e10cSrcweir                     nOrd = nTmp;
2379cdf0e10cSrcweir                     pCurrent = pObj;
2380cdf0e10cSrcweir                 }
2381cdf0e10cSrcweir             }
2382cdf0e10cSrcweir         }
2383cdf0e10cSrcweir     }
2384cdf0e10cSrcweir     return pCurrent;
2385cdf0e10cSrcweir }
2386cdf0e10cSrcweir 
2387cdf0e10cSrcweir /*************************************************************************/
2388cdf0e10cSrcweir 
2389cdf0e10cSrcweir //Unterstruktur eines LayoutFrms fuer eine Aktion aufheben und wieder
2390cdf0e10cSrcweir //restaurieren.
2391cdf0e10cSrcweir //Neuer Algorithmus: Es ist unuetz jeden Nachbarn einzeln zu betrachten und
2392cdf0e10cSrcweir //die Pointer sauber zu setzen (Upper, Nachbarn, usw.)
2393cdf0e10cSrcweir //Es reicht vollkommen jeweils eine Einzelkette zu loesen, und mit dem
2394cdf0e10cSrcweir //Letzen der Einzelkette nachzuschauen ob noch eine weitere Kette
2395cdf0e10cSrcweir //angeheangt werden muss. Es brauchen nur die Pointer korrigiert werden,
2396cdf0e10cSrcweir //die zur Verkettung notwendig sind. So koennen Beipspielsweise die Pointer
2397cdf0e10cSrcweir //auf die Upper auf den alten Uppern stehenbleiben. Korrigiert werden die
2398cdf0e10cSrcweir //Pointer dann im RestoreCntnt. Zwischenzeitlich ist sowieso jeder Zugriff
2399cdf0e10cSrcweir //verboten.
2400cdf0e10cSrcweir //Unterwegs werden die Flys bei der Seite abgemeldet.
2401cdf0e10cSrcweir 
2402cdf0e10cSrcweir // --> OD 2004-11-29 #115759# - 'remove' also drawing object from page and
2403cdf0e10cSrcweir // at-fly anchored objects from page
lcl_RemoveObjsFromPage(SwFrm * _pFrm)2404cdf0e10cSrcweir void MA_FASTCALL lcl_RemoveObjsFromPage( SwFrm* _pFrm )
2405cdf0e10cSrcweir {
2406cdf0e10cSrcweir     ASSERT( _pFrm->GetDrawObjs(), "Keine DrawObjs fuer lcl_RemoveFlysFromPage." );
2407cdf0e10cSrcweir     SwSortedObjs &rObjs = *_pFrm->GetDrawObjs();
2408cdf0e10cSrcweir     for ( sal_uInt16 i = 0; i < rObjs.Count(); ++i )
2409cdf0e10cSrcweir     {
2410cdf0e10cSrcweir         SwAnchoredObject* pObj = rObjs[i];
2411cdf0e10cSrcweir         // --> OD 2004-11-29 #115759# - reset member, at which the anchored
2412cdf0e10cSrcweir         // object orients its vertical position
2413cdf0e10cSrcweir         pObj->ClearVertPosOrientFrm();
2414cdf0e10cSrcweir         // <--
2415cdf0e10cSrcweir         // --> OD 2005-03-03 #i43913#
2416cdf0e10cSrcweir         pObj->ResetLayoutProcessBools();
2417cdf0e10cSrcweir         // <--
2418cdf0e10cSrcweir         // --> OD 2004-11-29 #115759# - remove also lower objects of as-character
2419cdf0e10cSrcweir         // anchored Writer fly frames from page
2420cdf0e10cSrcweir         if ( pObj->ISA(SwFlyFrm) )
2421cdf0e10cSrcweir         {
2422cdf0e10cSrcweir             SwFlyFrm* pFlyFrm = static_cast<SwFlyFrm*>(pObj);
2423cdf0e10cSrcweir 
2424cdf0e10cSrcweir             // --> OD 2004-11-29 #115759# - remove also direct lowers of Writer
2425cdf0e10cSrcweir             // fly frame from page
2426cdf0e10cSrcweir             if ( pFlyFrm->GetDrawObjs() )
2427cdf0e10cSrcweir             {
2428cdf0e10cSrcweir                 ::lcl_RemoveObjsFromPage( pFlyFrm );
2429cdf0e10cSrcweir             }
2430cdf0e10cSrcweir             // <--
2431cdf0e10cSrcweir 
2432cdf0e10cSrcweir             SwCntntFrm* pCnt = pFlyFrm->ContainsCntnt();
2433cdf0e10cSrcweir             while ( pCnt )
2434cdf0e10cSrcweir             {
2435cdf0e10cSrcweir                 if ( pCnt->GetDrawObjs() )
2436cdf0e10cSrcweir                     ::lcl_RemoveObjsFromPage( pCnt );
2437cdf0e10cSrcweir                 pCnt = pCnt->GetNextCntntFrm();
2438cdf0e10cSrcweir             }
2439cdf0e10cSrcweir             if ( pFlyFrm->IsFlyFreeFrm() )
2440cdf0e10cSrcweir             {
2441cdf0e10cSrcweir                 // --> OD 2004-06-30 #i28701# - use new method <GetPageFrm()>
2442cdf0e10cSrcweir                 pFlyFrm->GetPageFrm()->RemoveFlyFromPage( pFlyFrm );
2443cdf0e10cSrcweir             }
2444cdf0e10cSrcweir         }
2445cdf0e10cSrcweir         // <--
2446cdf0e10cSrcweir         // --> OD 2004-11-29 #115759# - remove also drawing objects from page
2447cdf0e10cSrcweir         else if ( pObj->ISA(SwAnchoredDrawObject) )
2448cdf0e10cSrcweir         {
2449cdf0e10cSrcweir             if (pObj->GetFrmFmt().GetAnchor().GetAnchorId() != FLY_AS_CHAR)
2450cdf0e10cSrcweir             {
2451cdf0e10cSrcweir                 pObj->GetPageFrm()->RemoveDrawObjFromPage(
2452cdf0e10cSrcweir                                 *(static_cast<SwAnchoredDrawObject*>(pObj)) );
2453cdf0e10cSrcweir             }
2454cdf0e10cSrcweir         }
2455cdf0e10cSrcweir         // <--
2456cdf0e10cSrcweir     }
2457cdf0e10cSrcweir }
2458cdf0e10cSrcweir 
SaveCntnt(SwLayoutFrm * pLay,SwFrm * pStart)2459cdf0e10cSrcweir SwFrm *SaveCntnt( SwLayoutFrm *pLay, SwFrm *pStart )
2460cdf0e10cSrcweir {
2461cdf0e10cSrcweir     if( pLay->IsSctFrm() && pLay->Lower() && pLay->Lower()->IsColumnFrm() )
2462cdf0e10cSrcweir         lcl_RemoveFtns( (SwColumnFrm*)pLay->Lower(), sal_True, sal_True );
2463cdf0e10cSrcweir 
2464cdf0e10cSrcweir     SwFrm *pSav;
2465cdf0e10cSrcweir     if ( 0 == (pSav = pLay->ContainsAny()) )
2466cdf0e10cSrcweir         return 0;
2467cdf0e10cSrcweir 
2468cdf0e10cSrcweir     if( pSav->IsInFtn() && !pLay->IsInFtn() )
2469cdf0e10cSrcweir     {
2470cdf0e10cSrcweir         do
2471cdf0e10cSrcweir             pSav = pSav->FindNext();
2472cdf0e10cSrcweir         while( pSav && pSav->IsInFtn() );
2473cdf0e10cSrcweir         if( !pSav || !pLay->IsAnLower( pSav ) )
2474cdf0e10cSrcweir             return NULL;
2475cdf0e10cSrcweir     }
2476cdf0e10cSrcweir 
24772bf67293SMatthias Seidel     // Tables should be saved as a whole, exception:
2478cdf0e10cSrcweir     // The contents of a section or a cell inside a table should be saved
2479cdf0e10cSrcweir     if ( pSav->IsInTab() && !( ( pLay->IsSctFrm() || pLay->IsCellFrm() ) && pLay->IsInTab() ) )
2480cdf0e10cSrcweir         while ( !pSav->IsTabFrm() )
2481cdf0e10cSrcweir             pSav = pSav->GetUpper();
2482cdf0e10cSrcweir 
2483cdf0e10cSrcweir     if( pSav->IsInSct() )
2484cdf0e10cSrcweir     { // Jetzt wird der oberste Bereich gesucht, der innerhalb von pLay ist.
2485cdf0e10cSrcweir         SwFrm* pSect = pLay->FindSctFrm();
2486cdf0e10cSrcweir         SwFrm *pTmp = pSav;
2487cdf0e10cSrcweir         do
2488cdf0e10cSrcweir         {
2489cdf0e10cSrcweir             pSav = pTmp;
2490cdf0e10cSrcweir             pTmp = pSav->GetUpper() ? pSav->GetUpper()->FindSctFrm() : NULL;
2491cdf0e10cSrcweir         } while ( pTmp != pSect );
2492cdf0e10cSrcweir     }
2493cdf0e10cSrcweir 
2494cdf0e10cSrcweir     SwFrm *pFloat = pSav;
2495cdf0e10cSrcweir     if( !pStart )
2496cdf0e10cSrcweir         pStart = pSav;
2497cdf0e10cSrcweir     sal_Bool bGo = pStart == pSav;
2498cdf0e10cSrcweir     do
2499cdf0e10cSrcweir     {
2500cdf0e10cSrcweir         if( bGo )
2501cdf0e10cSrcweir             pFloat->GetUpper()->pLower = 0;     //Die Teilkette ausklinken.
2502cdf0e10cSrcweir 
2503cdf0e10cSrcweir         //Das Ende der Teilkette suchen, unterwegs die Flys abmelden.
2504cdf0e10cSrcweir         do
2505cdf0e10cSrcweir         {
2506cdf0e10cSrcweir             if( bGo )
2507cdf0e10cSrcweir             {
2508cdf0e10cSrcweir                 if ( pFloat->IsCntntFrm() )
2509cdf0e10cSrcweir                 {
2510cdf0e10cSrcweir                     if ( pFloat->GetDrawObjs() )
2511cdf0e10cSrcweir                         ::lcl_RemoveObjsFromPage( (SwCntntFrm*)pFloat );
2512cdf0e10cSrcweir                 }
2513cdf0e10cSrcweir                 else if ( pFloat->IsTabFrm() || pFloat->IsSctFrm() )
2514cdf0e10cSrcweir                 {
2515cdf0e10cSrcweir                     SwCntntFrm *pCnt = ((SwLayoutFrm*)pFloat)->ContainsCntnt();
2516cdf0e10cSrcweir                     if( pCnt )
2517cdf0e10cSrcweir                     {
2518cdf0e10cSrcweir                         do
2519cdf0e10cSrcweir                         {   if ( pCnt->GetDrawObjs() )
2520cdf0e10cSrcweir                                 ::lcl_RemoveObjsFromPage( pCnt );
2521cdf0e10cSrcweir                             pCnt = pCnt->GetNextCntntFrm();
2522cdf0e10cSrcweir                         } while ( pCnt && ((SwLayoutFrm*)pFloat)->IsAnLower( pCnt ) );
2523cdf0e10cSrcweir                     }
2524cdf0e10cSrcweir                 }
2525cdf0e10cSrcweir                 else {
2526cdf0e10cSrcweir                     ASSERT( !pFloat, "Neuer Float-Frame?" );
2527cdf0e10cSrcweir                 }
2528cdf0e10cSrcweir             }
2529cdf0e10cSrcweir             if ( pFloat->GetNext()  )
2530cdf0e10cSrcweir             {
2531cdf0e10cSrcweir                 if( bGo )
2532cdf0e10cSrcweir                     pFloat->pUpper = NULL;
2533cdf0e10cSrcweir                 pFloat = pFloat->GetNext();
2534cdf0e10cSrcweir                 if( !bGo && pFloat == pStart )
2535cdf0e10cSrcweir                 {
2536cdf0e10cSrcweir                     bGo = sal_True;
2537cdf0e10cSrcweir                     pFloat->pPrev->pNext = NULL;
2538cdf0e10cSrcweir                     pFloat->pPrev = NULL;
2539cdf0e10cSrcweir                 }
2540cdf0e10cSrcweir             }
2541cdf0e10cSrcweir             else
2542cdf0e10cSrcweir                 break;
2543cdf0e10cSrcweir 
2544cdf0e10cSrcweir         } while ( pFloat );
2545cdf0e10cSrcweir 
2546cdf0e10cSrcweir         //Die naechste Teilkette suchen und die Ketten miteinander verbinden.
2547cdf0e10cSrcweir         SwFrm *pTmp = pFloat->FindNext();
2548cdf0e10cSrcweir         if( bGo )
2549cdf0e10cSrcweir             pFloat->pUpper = NULL;
2550cdf0e10cSrcweir 
2551cdf0e10cSrcweir         if( !pLay->IsInFtn() )
2552cdf0e10cSrcweir             while( pTmp && pTmp->IsInFtn() )
2553cdf0e10cSrcweir                 pTmp = pTmp->FindNext();
2554cdf0e10cSrcweir 
2555cdf0e10cSrcweir         if ( !pLay->IsAnLower( pTmp ) )
2556cdf0e10cSrcweir             pTmp = 0;
2557cdf0e10cSrcweir 
2558cdf0e10cSrcweir         if ( pTmp && bGo )
2559cdf0e10cSrcweir         {
2560cdf0e10cSrcweir             pFloat->pNext = pTmp;           //Die beiden Ketten verbinden.
2561cdf0e10cSrcweir             pFloat->pNext->pPrev = pFloat;
2562cdf0e10cSrcweir         }
2563cdf0e10cSrcweir         pFloat = pTmp;
2564cdf0e10cSrcweir         bGo = bGo || ( pStart == pFloat );
2565cdf0e10cSrcweir     }  while ( pFloat );
2566cdf0e10cSrcweir 
2567cdf0e10cSrcweir     return bGo ? pStart : NULL;
2568cdf0e10cSrcweir }
2569cdf0e10cSrcweir 
2570cdf0e10cSrcweir // --> OD 2004-11-29 #115759# - add also drawing objects to page and at-fly
2571cdf0e10cSrcweir // anchored objects to page
lcl_AddObjsToPage(SwFrm * _pFrm,SwPageFrm * _pPage)2572cdf0e10cSrcweir void MA_FASTCALL lcl_AddObjsToPage( SwFrm* _pFrm, SwPageFrm* _pPage )
2573cdf0e10cSrcweir {
2574cdf0e10cSrcweir     ASSERT( _pFrm->GetDrawObjs(), "Keine DrawObjs fuer lcl_AddFlysToPage." );
2575cdf0e10cSrcweir     SwSortedObjs &rObjs = *_pFrm->GetDrawObjs();
2576cdf0e10cSrcweir     for ( sal_uInt16 i = 0; i < rObjs.Count(); ++i )
2577cdf0e10cSrcweir     {
2578cdf0e10cSrcweir         SwAnchoredObject* pObj = rObjs[i];
2579cdf0e10cSrcweir 
2580cdf0e10cSrcweir         // --> OD 2004-11-29 #115759# - unlock position of anchored object
2581cdf0e10cSrcweir         // in order to get the object's position calculated.
2582cdf0e10cSrcweir         pObj->UnlockPosition();
2583cdf0e10cSrcweir         // <--
2584cdf0e10cSrcweir         // --> OD 2004-11-29 #115759# - add also lower objects of as-character
2585cdf0e10cSrcweir         // anchored Writer fly frames from page
2586cdf0e10cSrcweir         if ( pObj->ISA(SwFlyFrm) )
2587cdf0e10cSrcweir         {
2588cdf0e10cSrcweir             SwFlyFrm* pFlyFrm = static_cast<SwFlyFrm*>(pObj);
2589cdf0e10cSrcweir             if ( pObj->ISA(SwFlyFreeFrm) )
2590cdf0e10cSrcweir             {
2591cdf0e10cSrcweir                 _pPage->AppendFlyToPage( pFlyFrm );
2592cdf0e10cSrcweir             }
2593cdf0e10cSrcweir             pFlyFrm->_InvalidatePos();
2594cdf0e10cSrcweir             pFlyFrm->_InvalidateSize();
2595cdf0e10cSrcweir             pFlyFrm->InvalidatePage( _pPage );
2596cdf0e10cSrcweir 
2597cdf0e10cSrcweir             // --> OD 2004-11-29 #115759# - add also at-fly anchored objects
2598cdf0e10cSrcweir             // to page
2599cdf0e10cSrcweir             if ( pFlyFrm->GetDrawObjs() )
2600cdf0e10cSrcweir             {
2601cdf0e10cSrcweir                 ::lcl_AddObjsToPage( pFlyFrm, _pPage );
2602cdf0e10cSrcweir             }
2603cdf0e10cSrcweir             // <--
2604cdf0e10cSrcweir 
2605cdf0e10cSrcweir             SwCntntFrm *pCnt = pFlyFrm->ContainsCntnt();
2606cdf0e10cSrcweir             while ( pCnt )
2607cdf0e10cSrcweir             {
2608cdf0e10cSrcweir                 if ( pCnt->GetDrawObjs() )
2609cdf0e10cSrcweir                     ::lcl_AddObjsToPage( pCnt, _pPage );
2610cdf0e10cSrcweir                 pCnt = pCnt->GetNextCntntFrm();
2611cdf0e10cSrcweir             }
2612cdf0e10cSrcweir         }
2613cdf0e10cSrcweir         // <--
2614cdf0e10cSrcweir         // --> OD 2004-11-29 #115759# - remove also drawing objects from page
2615cdf0e10cSrcweir         else if ( pObj->ISA(SwAnchoredDrawObject) )
2616cdf0e10cSrcweir         {
2617cdf0e10cSrcweir             if (pObj->GetFrmFmt().GetAnchor().GetAnchorId() != FLY_AS_CHAR)
2618cdf0e10cSrcweir             {
2619cdf0e10cSrcweir                 pObj->InvalidateObjPos();
2620cdf0e10cSrcweir                 _pPage->AppendDrawObjToPage(
2621cdf0e10cSrcweir                                 *(static_cast<SwAnchoredDrawObject*>(pObj)) );
2622cdf0e10cSrcweir             }
2623cdf0e10cSrcweir         }
2624cdf0e10cSrcweir         // <--
2625cdf0e10cSrcweir     }
2626cdf0e10cSrcweir }
2627cdf0e10cSrcweir 
RestoreCntnt(SwFrm * pSav,SwLayoutFrm * pParent,SwFrm * pSibling,bool bGrow)2628cdf0e10cSrcweir void RestoreCntnt( SwFrm *pSav, SwLayoutFrm *pParent, SwFrm *pSibling, bool bGrow )
2629cdf0e10cSrcweir {
2630cdf0e10cSrcweir     ASSERT( pSav && pParent, "Kein Save oder Parent fuer Restore." );
2631cdf0e10cSrcweir     SWRECTFN( pParent )
2632cdf0e10cSrcweir 
2633cdf0e10cSrcweir     //Wenn es bereits FlowFrms unterhalb des neuen Parent gibt, so wird die
2634cdf0e10cSrcweir     //Kette, beginnend mit pSav, hinter dem letzten angehaengt.
2635cdf0e10cSrcweir     //Die Teile werden kurzerhand insertet und geeignet invalidiert.
2636cdf0e10cSrcweir     //Unterwegs werden die Flys der CntntFrms bei der Seite angemeldet.
2637cdf0e10cSrcweir 
2638cdf0e10cSrcweir     SwPageFrm *pPage = pParent->FindPageFrm();
2639cdf0e10cSrcweir 
2640cdf0e10cSrcweir     if ( pPage )
2641cdf0e10cSrcweir         pPage->InvalidatePage( pPage ); //Invalides Layout anmelden.
2642cdf0e10cSrcweir 
2643*6e8337c1Smseidel     //Vorgaenger feststellen und die Verbindung herstellen bzw. initialisieren.
2644cdf0e10cSrcweir     pSav->pPrev = pSibling;
2645cdf0e10cSrcweir     SwFrm* pNxt;
2646cdf0e10cSrcweir     if ( pSibling )
2647cdf0e10cSrcweir     {
2648cdf0e10cSrcweir         pNxt = pSibling->pNext;
2649cdf0e10cSrcweir         pSibling->pNext = pSav;
2650cdf0e10cSrcweir         pSibling->_InvalidatePrt();
2651cdf0e10cSrcweir         ((SwCntntFrm*)pSibling)->InvalidatePage( pPage );//Invaliden Cntnt anmelden.
2652cdf0e10cSrcweir         if ( ((SwCntntFrm*)pSibling)->GetFollow() )
2653cdf0e10cSrcweir             pSibling->Prepare( PREP_CLEAR, 0, sal_False );
2654cdf0e10cSrcweir     }
2655cdf0e10cSrcweir     else
2656cdf0e10cSrcweir     {   pNxt = pParent->pLower;
2657cdf0e10cSrcweir         pParent->pLower = pSav;
2658cdf0e10cSrcweir         pSav->pUpper = pParent;     //Schon mal setzen, sonst ist fuer das
2659cdf0e10cSrcweir                                     //invalidate der Parent (z.B. ein Fly) nicht klar.
2660cdf0e10cSrcweir         //Invaliden Cntnt anmelden.
2661cdf0e10cSrcweir         if ( pSav->IsCntntFrm() )
2662cdf0e10cSrcweir             ((SwCntntFrm*)pSav)->InvalidatePage( pPage );
2663cdf0e10cSrcweir         else
2664cdf0e10cSrcweir         {   // pSav koennte auch ein leerer SectFrm sein
2665cdf0e10cSrcweir             SwCntntFrm* pCnt = pParent->ContainsCntnt();
2666cdf0e10cSrcweir             if( pCnt )
2667cdf0e10cSrcweir                 pCnt->InvalidatePage( pPage );
2668cdf0e10cSrcweir         }
2669cdf0e10cSrcweir     }
2670cdf0e10cSrcweir 
2671cdf0e10cSrcweir     //Der Parent muss entsprechend gegrow'ed werden.
2672cdf0e10cSrcweir     SwTwips nGrowVal = 0;
2673cdf0e10cSrcweir     SwFrm* pLast;
2674cdf0e10cSrcweir     do
2675cdf0e10cSrcweir     {   pSav->pUpper = pParent;
2676cdf0e10cSrcweir         nGrowVal += (pSav->Frm().*fnRect->fnGetHeight)();
2677cdf0e10cSrcweir         pSav->_InvalidateAll();
2678cdf0e10cSrcweir 
2679cdf0e10cSrcweir         //Jetzt die Flys anmelden, fuer TxtFrms gleich geeignet invalidieren.
2680cdf0e10cSrcweir         if ( pSav->IsCntntFrm() )
2681cdf0e10cSrcweir         {
2682cdf0e10cSrcweir             if ( pSav->IsTxtFrm() &&
2683cdf0e10cSrcweir                  ((SwTxtFrm*)pSav)->GetCacheIdx() != USHRT_MAX )
2684cdf0e10cSrcweir                 ((SwTxtFrm*)pSav)->Init();  //Ich bin sein Freund.
2685cdf0e10cSrcweir 
2686cdf0e10cSrcweir             if ( pPage && pSav->GetDrawObjs() )
2687cdf0e10cSrcweir                 ::lcl_AddObjsToPage( (SwCntntFrm*)pSav, pPage );
2688cdf0e10cSrcweir         }
2689cdf0e10cSrcweir         else
2690cdf0e10cSrcweir         {   SwCntntFrm *pBlub = ((SwLayoutFrm*)pSav)->ContainsCntnt();
2691cdf0e10cSrcweir             if( pBlub )
2692cdf0e10cSrcweir             {
2693cdf0e10cSrcweir                 do
2694cdf0e10cSrcweir                 {   if ( pPage && pBlub->GetDrawObjs() )
2695cdf0e10cSrcweir                         ::lcl_AddObjsToPage( pBlub, pPage );
2696cdf0e10cSrcweir                     if( pBlub->IsTxtFrm() && ((SwTxtFrm*)pBlub)->HasFtn() &&
2697cdf0e10cSrcweir                         ((SwTxtFrm*)pBlub)->GetCacheIdx() != USHRT_MAX )
2698cdf0e10cSrcweir                         ((SwTxtFrm*)pBlub)->Init(); //Ich bin sein Freund.
2699cdf0e10cSrcweir                     pBlub = pBlub->GetNextCntntFrm();
2700cdf0e10cSrcweir                 } while ( pBlub && ((SwLayoutFrm*)pSav)->IsAnLower( pBlub ));
2701cdf0e10cSrcweir             }
2702cdf0e10cSrcweir         }
2703cdf0e10cSrcweir         pLast = pSav;
2704cdf0e10cSrcweir         pSav = pSav->GetNext();
2705cdf0e10cSrcweir 
2706cdf0e10cSrcweir     } while ( pSav );
2707cdf0e10cSrcweir 
2708cdf0e10cSrcweir     if( pNxt )
2709cdf0e10cSrcweir     {
2710cdf0e10cSrcweir         pLast->pNext = pNxt;
2711cdf0e10cSrcweir         pNxt->pPrev = pLast;
2712cdf0e10cSrcweir     }
2713cdf0e10cSrcweir 
2714cdf0e10cSrcweir     if ( bGrow )
2715cdf0e10cSrcweir         pParent->Grow( nGrowVal );
2716cdf0e10cSrcweir }
2717cdf0e10cSrcweir 
2718cdf0e10cSrcweir /*************************************************************************
2719cdf0e10cSrcweir |*
2720cdf0e10cSrcweir |*  SqRt()              Berechnung der Quadratwurzel, damit die math.lib
2721cdf0e10cSrcweir |*      nicht auch noch dazugelinkt werden muss.
2722cdf0e10cSrcweir |*
2723cdf0e10cSrcweir |*************************************************************************/
2724cdf0e10cSrcweir 
SqRt(BigInt nX)2725cdf0e10cSrcweir sal_uLong MA_FASTCALL SqRt( BigInt nX )
2726cdf0e10cSrcweir {
2727cdf0e10cSrcweir     BigInt nErg = 1;
2728cdf0e10cSrcweir 
2729cdf0e10cSrcweir     if ( !nX.IsNeg() )
2730cdf0e10cSrcweir     {
2731cdf0e10cSrcweir         BigInt nOldErg = 1;
2732cdf0e10cSrcweir         for ( int i = 0; i <= 5; i++ )
2733cdf0e10cSrcweir         {
2734cdf0e10cSrcweir             nErg = (nOldErg + (nX / nOldErg)) / BigInt(2);
2735cdf0e10cSrcweir             nOldErg = nErg;
2736cdf0e10cSrcweir         }
2737cdf0e10cSrcweir     }
2738cdf0e10cSrcweir     return nErg >= BigInt(SAL_MAX_UINT32) ? ULONG_MAX : (sal_uLong)nErg;
2739cdf0e10cSrcweir }
2740cdf0e10cSrcweir 
2741cdf0e10cSrcweir /*************************************************************************/
2742cdf0e10cSrcweir 
InsertNewPage(SwPageDesc & rDesc,SwFrm * pUpper,sal_Bool bOdd,sal_Bool bInsertEmpty,sal_Bool bFtn,SwFrm * pSibling)2743cdf0e10cSrcweir SwPageFrm * MA_FASTCALL InsertNewPage( SwPageDesc &rDesc, SwFrm *pUpper,
2744cdf0e10cSrcweir                           sal_Bool bOdd, sal_Bool bInsertEmpty, sal_Bool bFtn,
2745cdf0e10cSrcweir                           SwFrm *pSibling )
2746cdf0e10cSrcweir {
2747cdf0e10cSrcweir     SwPageFrm *pRet;
2748cdf0e10cSrcweir     SwDoc *pDoc = ((SwLayoutFrm*)pUpper)->GetFmt()->GetDoc();
2749cdf0e10cSrcweir     SwFrmFmt *pFmt = bOdd ? rDesc.GetRightFmt() : rDesc.GetLeftFmt();
2750cdf0e10cSrcweir     //Wenn ich kein FrmFmt fuer die Seite gefunden habe, muss ich eben
2751cdf0e10cSrcweir     //eine Leerseite einfuegen.
2752cdf0e10cSrcweir     if ( !pFmt )
2753cdf0e10cSrcweir     {
2754cdf0e10cSrcweir         pFmt = bOdd ? rDesc.GetLeftFmt() : rDesc.GetRightFmt();
2755cdf0e10cSrcweir         ASSERT( pFmt, "Descriptor without any format?!" );
2756cdf0e10cSrcweir         bInsertEmpty = !bInsertEmpty;
2757cdf0e10cSrcweir     }
2758cdf0e10cSrcweir     if( bInsertEmpty )
2759cdf0e10cSrcweir     {
2760cdf0e10cSrcweir         SwPageDesc *pTmpDesc = pSibling && pSibling->GetPrev() ?
2761cdf0e10cSrcweir                 ((SwPageFrm*)pSibling->GetPrev())->GetPageDesc() : &rDesc;
2762cdf0e10cSrcweir         pRet = new SwPageFrm( pDoc->GetEmptyPageFmt(), pUpper, pTmpDesc );
2763cdf0e10cSrcweir         pRet->Paste( pUpper, pSibling );
2764cdf0e10cSrcweir         pRet->PreparePage( bFtn );
2765cdf0e10cSrcweir     }
2766cdf0e10cSrcweir     pRet = new SwPageFrm( pFmt, pUpper, &rDesc );
2767cdf0e10cSrcweir     pRet->Paste( pUpper, pSibling );
2768cdf0e10cSrcweir     pRet->PreparePage( bFtn );
2769cdf0e10cSrcweir     if ( pRet->GetNext() )
2770cdf0e10cSrcweir         ((SwRootFrm*)pRet->GetUpper())->AssertPageFlys( pRet );
2771cdf0e10cSrcweir     return pRet;
2772cdf0e10cSrcweir }
2773cdf0e10cSrcweir 
2774cdf0e10cSrcweir 
2775cdf0e10cSrcweir /*************************************************************************
2776cdf0e10cSrcweir |*
2777cdf0e10cSrcweir |*  RegistFlys(), Regist()  Die beiden folgenden Methoden durchsuchen rekursiv
2778cdf0e10cSrcweir |*      eine Layoutstruktur und melden alle FlyFrms, die einen beliebigen Frm
2779cdf0e10cSrcweir |*      innerhalb der Struktur als Anker haben bei der Seite an.
2780cdf0e10cSrcweir |*
2781cdf0e10cSrcweir |*************************************************************************/
2782cdf0e10cSrcweir 
lcl_Regist(SwPageFrm * pPage,const SwFrm * pAnch)2783cdf0e10cSrcweir void MA_FASTCALL lcl_Regist( SwPageFrm *pPage, const SwFrm *pAnch )
2784cdf0e10cSrcweir {
2785cdf0e10cSrcweir     SwSortedObjs *pObjs = (SwSortedObjs*)pAnch->GetDrawObjs();
2786cdf0e10cSrcweir     for ( sal_uInt16 i = 0; i < pObjs->Count(); ++i )
2787cdf0e10cSrcweir     {
2788cdf0e10cSrcweir         SwAnchoredObject* pObj = (*pObjs)[i];
2789cdf0e10cSrcweir         if ( pObj->ISA(SwFlyFrm) )
2790cdf0e10cSrcweir         {
2791cdf0e10cSrcweir             SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pObj);
2792cdf0e10cSrcweir             //Ggf. ummelden, nicht anmelden wenn bereits bekannt.
2793cdf0e10cSrcweir             // --> OD 2004-06-30 #i28701# - use new method <GetPageFrm()>
2794cdf0e10cSrcweir             SwPageFrm *pPg = pFly->IsFlyFreeFrm()
2795cdf0e10cSrcweir                              ? pFly->GetPageFrm() : pFly->FindPageFrm();
2796cdf0e10cSrcweir             if ( pPg != pPage )
2797cdf0e10cSrcweir             {
2798cdf0e10cSrcweir                 if ( pPg )
2799cdf0e10cSrcweir                     pPg->RemoveFlyFromPage( pFly );
2800cdf0e10cSrcweir                 pPage->AppendFlyToPage( pFly );
2801cdf0e10cSrcweir             }
2802cdf0e10cSrcweir             ::RegistFlys( pPage, pFly );
2803cdf0e10cSrcweir         }
2804cdf0e10cSrcweir         else
2805cdf0e10cSrcweir         {
2806cdf0e10cSrcweir             // --> OD 2008-04-22 #i87493#
2807cdf0e10cSrcweir             if ( pPage != pObj->GetPageFrm() )
2808cdf0e10cSrcweir             {
2809cdf0e10cSrcweir                 // --> OD 2004-07-02 #i28701#
2810cdf0e10cSrcweir                 if ( pObj->GetPageFrm() )
2811cdf0e10cSrcweir                     pObj->GetPageFrm()->RemoveDrawObjFromPage( *pObj );
2812cdf0e10cSrcweir                 pPage->AppendDrawObjToPage( *pObj );
2813cdf0e10cSrcweir                 // <--
2814cdf0e10cSrcweir             }
2815cdf0e10cSrcweir             // <--
2816cdf0e10cSrcweir         }
2817cdf0e10cSrcweir 
2818cdf0e10cSrcweir         const SwFlyFrm* pFly = pAnch->FindFlyFrm();
2819cdf0e10cSrcweir         if ( pFly &&
2820cdf0e10cSrcweir              pObj->GetDrawObj()->GetOrdNum() < pFly->GetVirtDrawObj()->GetOrdNum() &&
2821cdf0e10cSrcweir              pObj->GetDrawObj()->GetPage() )
2822cdf0e10cSrcweir         {
282343e393b3SOliver-Rainer Wittmann             //#i119945# set pFly's OrdNum to pObj's. So when pFly is removed by Undo, the original OrdNum will not be changed.
282443e393b3SOliver-Rainer Wittmann             pObj->DrawObj()->GetPage()->SetObjectOrdNum( pFly->GetVirtDrawObj()->GetOrdNumDirect(),
282543e393b3SOliver-Rainer Wittmann                                                          pObj->GetDrawObj()->GetOrdNumDirect() );
2826cdf0e10cSrcweir         }
2827cdf0e10cSrcweir     }
2828cdf0e10cSrcweir }
2829cdf0e10cSrcweir 
RegistFlys(SwPageFrm * pPage,const SwLayoutFrm * pLay)2830cdf0e10cSrcweir void RegistFlys( SwPageFrm *pPage, const SwLayoutFrm *pLay )
2831cdf0e10cSrcweir {
2832cdf0e10cSrcweir     if ( pLay->GetDrawObjs() )
2833cdf0e10cSrcweir         ::lcl_Regist( pPage, pLay );
2834cdf0e10cSrcweir     const SwFrm *pFrm = pLay->Lower();
2835cdf0e10cSrcweir     while ( pFrm )
2836cdf0e10cSrcweir     {
2837cdf0e10cSrcweir         if ( pFrm->IsLayoutFrm() )
2838cdf0e10cSrcweir             ::RegistFlys( pPage, (const SwLayoutFrm*)pFrm );
2839cdf0e10cSrcweir         else if ( pFrm->GetDrawObjs() )
2840cdf0e10cSrcweir             ::lcl_Regist( pPage, pFrm );
2841cdf0e10cSrcweir         pFrm = pFrm->GetNext();
2842cdf0e10cSrcweir     }
2843cdf0e10cSrcweir }
2844cdf0e10cSrcweir 
2845cdf0e10cSrcweir /*************************************************************************
2846cdf0e10cSrcweir |*
2847cdf0e10cSrcweir |*  void Notify()
2848cdf0e10cSrcweir |*
2849cdf0e10cSrcweir |*  Beschreibung        Benachrichtigt den Hintergrund je nach der
2850*6e8337c1Smseidel |*      Veraenderung zwischen altem und neuem Rechteck.
2851cdf0e10cSrcweir |*
2852cdf0e10cSrcweir |*************************************************************************/
2853cdf0e10cSrcweir 
Notify(SwFlyFrm * pFly,SwPageFrm * pOld,const SwRect & rOld,const SwRect * pOldPrt)2854cdf0e10cSrcweir void Notify( SwFlyFrm *pFly, SwPageFrm *pOld, const SwRect &rOld,
2855cdf0e10cSrcweir              const SwRect* pOldPrt )
2856cdf0e10cSrcweir {
2857cdf0e10cSrcweir     const SwRect aFrm( pFly->GetObjRectWithSpaces() );
2858cdf0e10cSrcweir     if ( rOld.Pos() != aFrm.Pos() )
2859cdf0e10cSrcweir     {   //Positionsaenderung, alten und neuen Bereich invalidieren
2860cdf0e10cSrcweir         if ( rOld.HasArea() &&
2861cdf0e10cSrcweir              rOld.Left()+pFly->GetFmt()->GetLRSpace().GetLeft() < WEIT_WECH )
2862cdf0e10cSrcweir         {
2863cdf0e10cSrcweir             pFly->NotifyBackground( pOld, rOld, PREP_FLY_LEAVE );
2864cdf0e10cSrcweir         }
2865cdf0e10cSrcweir         pFly->NotifyBackground( pFly->FindPageFrm(), aFrm, PREP_FLY_ARRIVE );
2866cdf0e10cSrcweir     }
2867cdf0e10cSrcweir     else if ( rOld.SSize() != aFrm.SSize() )
2868cdf0e10cSrcweir     {   //Groessenaenderung, den Bereich der Verlassen wurde bzw. jetzt
2869cdf0e10cSrcweir         //ueberdeckt wird invalidieren.
2870cdf0e10cSrcweir         //Der Einfachheit halber wird hier bewusst jeweils ein Twip
2871cdf0e10cSrcweir         //unnoetig invalidiert.
2872cdf0e10cSrcweir 
2873cdf0e10cSrcweir         ViewShell *pSh = pFly->getRootFrm()->GetCurrShell();
2874cdf0e10cSrcweir         if( pSh && rOld.HasArea() )
2875cdf0e10cSrcweir             pSh->InvalidateWindows( rOld );
2876cdf0e10cSrcweir 
2877cdf0e10cSrcweir         // --> OD 2005-08-19 #i51941# - consider case that fly frame isn't
2878cdf0e10cSrcweir         // registered at the old page <pOld>
2879cdf0e10cSrcweir         SwPageFrm* pPageFrm = pFly->FindPageFrm();
2880cdf0e10cSrcweir         if ( pOld != pPageFrm )
2881cdf0e10cSrcweir         {
2882cdf0e10cSrcweir             pFly->NotifyBackground( pPageFrm, aFrm, PREP_FLY_ARRIVE );
2883cdf0e10cSrcweir         }
2884cdf0e10cSrcweir         // <--
2885cdf0e10cSrcweir 
2886cdf0e10cSrcweir         if ( rOld.Left() != aFrm.Left() )
2887cdf0e10cSrcweir         {
2888cdf0e10cSrcweir             SwRect aTmp( rOld );
2889cdf0e10cSrcweir             aTmp.Union( aFrm );
2890cdf0e10cSrcweir             aTmp.Left(  Min(aFrm.Left(), rOld.Left()) );
2891cdf0e10cSrcweir             aTmp.Right( Max(aFrm.Left(), rOld.Left()) );
2892cdf0e10cSrcweir             pFly->NotifyBackground( pOld, aTmp, PREP_FLY_CHGD );
2893cdf0e10cSrcweir         }
2894cdf0e10cSrcweir         SwTwips nOld = rOld.Right();
2895cdf0e10cSrcweir         SwTwips nNew = aFrm.Right();
2896cdf0e10cSrcweir         if ( nOld != nNew )
2897cdf0e10cSrcweir         {
2898cdf0e10cSrcweir             SwRect aTmp( rOld );
2899cdf0e10cSrcweir             aTmp.Union( aFrm );
2900cdf0e10cSrcweir             aTmp.Left(  Min(nNew, nOld) );
2901cdf0e10cSrcweir             aTmp.Right( Max(nNew, nOld) );
2902cdf0e10cSrcweir             pFly->NotifyBackground( pOld, aTmp, PREP_FLY_CHGD );
2903cdf0e10cSrcweir         }
2904cdf0e10cSrcweir         if ( rOld.Top() != aFrm.Top() )
2905cdf0e10cSrcweir         {
2906cdf0e10cSrcweir             SwRect aTmp( rOld );
2907cdf0e10cSrcweir             aTmp.Union( aFrm );
2908cdf0e10cSrcweir             aTmp.Top(    Min(aFrm.Top(), rOld.Top()) );
2909cdf0e10cSrcweir             aTmp.Bottom( Max(aFrm.Top(), rOld.Top()) );
2910cdf0e10cSrcweir             pFly->NotifyBackground( pOld, aTmp, PREP_FLY_CHGD );
2911cdf0e10cSrcweir         }
2912cdf0e10cSrcweir         nOld = rOld.Bottom();
2913cdf0e10cSrcweir         nNew = aFrm.Bottom();
2914cdf0e10cSrcweir         if ( nOld != nNew )
2915cdf0e10cSrcweir         {
2916cdf0e10cSrcweir             SwRect aTmp( rOld );
2917cdf0e10cSrcweir             aTmp.Union( aFrm );
2918cdf0e10cSrcweir             aTmp.Top(    Min(nNew, nOld) );
2919cdf0e10cSrcweir             aTmp.Bottom( Max(nNew, nOld) );
2920cdf0e10cSrcweir             pFly->NotifyBackground( pOld, aTmp, PREP_FLY_CHGD );
2921cdf0e10cSrcweir         }
2922cdf0e10cSrcweir     }
2923cdf0e10cSrcweir     else if ( pOldPrt && *pOldPrt != pFly->Prt() &&
2924cdf0e10cSrcweir               pFly->GetFmt()->GetSurround().IsContour() )
2925cdf0e10cSrcweir     {
2926cdf0e10cSrcweir         // #i24097#
2927cdf0e10cSrcweir         pFly->NotifyBackground( pFly->FindPageFrm(), aFrm, PREP_FLY_ARRIVE );
2928cdf0e10cSrcweir     }
2929cdf0e10cSrcweir }
2930cdf0e10cSrcweir 
2931cdf0e10cSrcweir /*************************************************************************/
2932cdf0e10cSrcweir 
lcl_CheckFlowBack(SwFrm * pFrm,const SwRect & rRect)2933cdf0e10cSrcweir void lcl_CheckFlowBack( SwFrm* pFrm, const SwRect &rRect )
2934cdf0e10cSrcweir {
2935cdf0e10cSrcweir     SwTwips nBottom = rRect.Bottom();
2936cdf0e10cSrcweir     while( pFrm )
2937cdf0e10cSrcweir     {
2938cdf0e10cSrcweir         if( pFrm->IsLayoutFrm() )
2939cdf0e10cSrcweir         {
2940cdf0e10cSrcweir             if( rRect.IsOver( pFrm->Frm() ) )
2941cdf0e10cSrcweir                 lcl_CheckFlowBack( ((SwLayoutFrm*)pFrm)->Lower(), rRect );
2942cdf0e10cSrcweir         }
2943cdf0e10cSrcweir         else if( !pFrm->GetNext() && nBottom > pFrm->Frm().Bottom() )
2944cdf0e10cSrcweir         {
2945cdf0e10cSrcweir             if( pFrm->IsCntntFrm() && ((SwCntntFrm*)pFrm)->HasFollow() )
2946cdf0e10cSrcweir                 pFrm->InvalidateSize();
2947cdf0e10cSrcweir             else
2948cdf0e10cSrcweir                 pFrm->InvalidateNextPos();
2949cdf0e10cSrcweir         }
2950cdf0e10cSrcweir         pFrm = pFrm->GetNext();
2951cdf0e10cSrcweir     }
2952cdf0e10cSrcweir }
2953cdf0e10cSrcweir 
lcl_NotifyCntnt(const SdrObject * pThis,SwCntntFrm * pCnt,const SwRect & rRect,const PrepareHint eHint)2954cdf0e10cSrcweir void MA_FASTCALL lcl_NotifyCntnt( const SdrObject *pThis, SwCntntFrm *pCnt,
2955cdf0e10cSrcweir     const SwRect &rRect, const PrepareHint eHint )
2956cdf0e10cSrcweir {
2957cdf0e10cSrcweir     if ( pCnt->IsTxtFrm() )
2958cdf0e10cSrcweir     {
2959cdf0e10cSrcweir         SwRect aCntPrt( pCnt->Prt() );
2960cdf0e10cSrcweir         aCntPrt.Pos() += pCnt->Frm().Pos();
2961cdf0e10cSrcweir         if ( eHint == PREP_FLY_ATTR_CHG )
2962cdf0e10cSrcweir         {
2963cdf0e10cSrcweir             // --> OD 2004-10-20 #i35640# - use given rectangle <rRect> instead
2964cdf0e10cSrcweir             // of current bound rectangle
2965cdf0e10cSrcweir             if ( aCntPrt.IsOver( rRect ) )
2966cdf0e10cSrcweir             // <--
2967cdf0e10cSrcweir                 pCnt->Prepare( PREP_FLY_ATTR_CHG );
2968cdf0e10cSrcweir         }
2969cdf0e10cSrcweir         // --> OD 2004-11-01 #i23129# - only invalidate, if the text frame
2970cdf0e10cSrcweir         // printing area overlaps with the given rectangle.
2971cdf0e10cSrcweir         else if ( aCntPrt.IsOver( rRect ) )
2972cdf0e10cSrcweir         // <--
2973cdf0e10cSrcweir             pCnt->Prepare( eHint, (void*)&aCntPrt._Intersection( rRect ) );
2974cdf0e10cSrcweir         if ( pCnt->GetDrawObjs() )
2975cdf0e10cSrcweir         {
2976cdf0e10cSrcweir             const SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
2977cdf0e10cSrcweir             for ( sal_uInt16 i = 0; i < rObjs.Count(); ++i )
2978cdf0e10cSrcweir             {
2979cdf0e10cSrcweir                 SwAnchoredObject* pObj = rObjs[i];
2980cdf0e10cSrcweir                 if ( pObj->ISA(SwFlyFrm) )
2981cdf0e10cSrcweir                 {
2982cdf0e10cSrcweir                     SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pObj);
2983cdf0e10cSrcweir                     if ( pFly->IsFlyInCntFrm() )
2984cdf0e10cSrcweir                     {
2985cdf0e10cSrcweir                         SwCntntFrm *pCntnt = pFly->ContainsCntnt();
2986cdf0e10cSrcweir                         while ( pCntnt )
2987cdf0e10cSrcweir                         {
2988cdf0e10cSrcweir                             ::lcl_NotifyCntnt( pThis, pCntnt, rRect, eHint );
2989cdf0e10cSrcweir                             pCntnt = pCntnt->GetNextCntntFrm();
2990cdf0e10cSrcweir                         }
2991cdf0e10cSrcweir                     }
2992cdf0e10cSrcweir                 }
2993cdf0e10cSrcweir             }
2994cdf0e10cSrcweir         }
2995cdf0e10cSrcweir     }
2996cdf0e10cSrcweir }
2997cdf0e10cSrcweir 
Notify_Background(const SdrObject * pObj,SwPageFrm * pPage,const SwRect & rRect,const PrepareHint eHint,const sal_Bool bInva)2998cdf0e10cSrcweir void Notify_Background( const SdrObject* pObj,
2999cdf0e10cSrcweir                         SwPageFrm* pPage,
3000cdf0e10cSrcweir                         const SwRect& rRect,
3001cdf0e10cSrcweir                         const PrepareHint eHint,
3002cdf0e10cSrcweir                         const sal_Bool bInva )
3003cdf0e10cSrcweir {
3004cdf0e10cSrcweir 
3005cdf0e10cSrcweir     //Wenn der Frm gerade erstmalig sinnvoll positioniert wurde, braucht der
3006cdf0e10cSrcweir     //alte Bereich nicht benachrichtigt werden.
3007cdf0e10cSrcweir     if ( eHint == PREP_FLY_LEAVE && rRect.Top() == WEIT_WECH )
3008cdf0e10cSrcweir          return;
3009cdf0e10cSrcweir 
3010cdf0e10cSrcweir     SwLayoutFrm* pArea;
3011cdf0e10cSrcweir     SwFlyFrm *pFlyFrm = 0;
3012cdf0e10cSrcweir     SwFrm* pAnchor;
3013cdf0e10cSrcweir     if( pObj->ISA(SwVirtFlyDrawObj) )
3014cdf0e10cSrcweir     {
3015cdf0e10cSrcweir         pFlyFrm = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
3016cdf0e10cSrcweir         pAnchor = pFlyFrm->AnchorFrm();
3017cdf0e10cSrcweir     }
3018cdf0e10cSrcweir     else
3019cdf0e10cSrcweir     {
3020cdf0e10cSrcweir         pFlyFrm = NULL;
3021cdf0e10cSrcweir         pAnchor = const_cast<SwFrm*>(
3022cdf0e10cSrcweir                     GetUserCall(pObj)->GetAnchoredObj( pObj )->GetAnchorFrm() );
3023cdf0e10cSrcweir     }
3024cdf0e10cSrcweir     if( PREP_FLY_LEAVE != eHint && pAnchor->IsInFly() )
3025cdf0e10cSrcweir         pArea = pAnchor->FindFlyFrm();
3026cdf0e10cSrcweir     else
3027cdf0e10cSrcweir         pArea = pPage;
3028cdf0e10cSrcweir     SwCntntFrm *pCnt = 0;
3029cdf0e10cSrcweir     if ( pArea )
3030cdf0e10cSrcweir     {
3031cdf0e10cSrcweir         if( PREP_FLY_ARRIVE != eHint )
3032cdf0e10cSrcweir             lcl_CheckFlowBack( pArea, rRect );
3033cdf0e10cSrcweir 
3034cdf0e10cSrcweir         //Es reagieren sowieso nur die auf den Anker folgenden auf den Fly, also
3035cdf0e10cSrcweir         //brauchen diese nicht abgeklappert werden.
3036cdf0e10cSrcweir         //Ausnahme sind ist natuerlich das LEAVE, denn der Fly koennte ja von
3037cdf0e10cSrcweir         //"oben" kommen.
3038cdf0e10cSrcweir         // Wenn der Anker auf der vorhergehenden Seite liegt, muss ebenfalls
3039cdf0e10cSrcweir         // die gesamte Seite abgearbeitet werden. (47722)
3040cdf0e10cSrcweir         // OD 2004-05-13 #i28701# - If the wrapping style has to be considered
3041cdf0e10cSrcweir         // on the object positioning, the complete area has to be processed,
3042cdf0e10cSrcweir         // because content frames before the anchor frame also have to consider
3043cdf0e10cSrcweir         // the object for the text wrapping.
3044cdf0e10cSrcweir         // --> OD 2004-08-25 #i3317# - The complete area has always been
3045cdf0e10cSrcweir         // processed.
3046cdf0e10cSrcweir         {
3047cdf0e10cSrcweir             pCnt = pArea->ContainsCntnt();
3048cdf0e10cSrcweir         }
3049cdf0e10cSrcweir         // <--
3050cdf0e10cSrcweir     }
3051cdf0e10cSrcweir     SwFrm *pLastTab = 0;
3052cdf0e10cSrcweir 
3053cdf0e10cSrcweir     while ( pCnt && pArea && pArea->IsAnLower( pCnt ) )
3054cdf0e10cSrcweir     {
3055cdf0e10cSrcweir         ::lcl_NotifyCntnt( pObj, pCnt, rRect, eHint );
3056cdf0e10cSrcweir         if ( pCnt->IsInTab() )
3057cdf0e10cSrcweir         {
3058cdf0e10cSrcweir             SwLayoutFrm* pCell = pCnt->GetUpper();
3059cdf0e10cSrcweir             // --> OD 2005-01-14 #i40606# - use <GetLastBoundRect()>
3060cdf0e10cSrcweir             // instead of <GetCurrentBoundRect()>, because a recalculation
3061cdf0e10cSrcweir             // of the bounding rectangle isn't intended here.
3062cdf0e10cSrcweir             if ( pCell->IsCellFrm() &&
3063cdf0e10cSrcweir                  ( pCell->Frm().IsOver( pObj->GetLastBoundRect() ) ||
3064cdf0e10cSrcweir                    pCell->Frm().IsOver( rRect ) ) )
3065cdf0e10cSrcweir             // <--
3066cdf0e10cSrcweir             {
3067cdf0e10cSrcweir                 const SwFmtVertOrient &rOri = pCell->GetFmt()->GetVertOrient();
3068cdf0e10cSrcweir                 if ( text::VertOrientation::NONE != rOri.GetVertOrient() )
3069cdf0e10cSrcweir                     pCell->InvalidatePrt();
3070cdf0e10cSrcweir             }
3071cdf0e10cSrcweir             SwTabFrm *pTab = pCnt->FindTabFrm();
3072cdf0e10cSrcweir             if ( pTab != pLastTab )
3073cdf0e10cSrcweir             {
3074cdf0e10cSrcweir                 pLastTab = pTab;
3075cdf0e10cSrcweir                 // --> OD 2005-01-14 #i40606# - use <GetLastBoundRect()>
3076cdf0e10cSrcweir                 // instead of <GetCurrentBoundRect()>, because a recalculation
3077cdf0e10cSrcweir                 // of the bounding rectangle isn't intended here.
3078cdf0e10cSrcweir                 if ( pTab->Frm().IsOver( pObj->GetLastBoundRect() ) ||
3079cdf0e10cSrcweir                      pTab->Frm().IsOver( rRect ) )
3080cdf0e10cSrcweir                 // <--
3081cdf0e10cSrcweir                 {
3082cdf0e10cSrcweir                     if ( !pFlyFrm || !pFlyFrm->IsLowerOf( pTab ) )
3083cdf0e10cSrcweir                         pTab->InvalidatePrt();
3084cdf0e10cSrcweir                 }
3085cdf0e10cSrcweir             }
3086cdf0e10cSrcweir         }
3087cdf0e10cSrcweir         pCnt = pCnt->GetNextCntntFrm();
3088cdf0e10cSrcweir     }
3089cdf0e10cSrcweir // #108745# Sorry, but this causes nothing but trouble. I remove these lines
3090cdf0e10cSrcweir // taking the risk that the footer frame will have a wrong height
3091cdf0e10cSrcweir //  if( pPage->Lower() )
3092cdf0e10cSrcweir //  {
3093cdf0e10cSrcweir //      SwFrm* pFrm = pPage->Lower();
3094cdf0e10cSrcweir //      while( pFrm->GetNext() )
3095cdf0e10cSrcweir //          pFrm = pFrm->GetNext();
3096cdf0e10cSrcweir //      if( pFrm->IsFooterFrm() &&
3097cdf0e10cSrcweir //          ( ( pFrm->Frm().IsOver( pObj->GetBoundRect() ) ||
3098cdf0e10cSrcweir //              pFrm->Frm().IsOver( rRect ) ) ) )
3099cdf0e10cSrcweir //           pFrm->InvalidateSize();
3100cdf0e10cSrcweir //  }
3101cdf0e10cSrcweir     // --> OD 2007-07-24 #128702# - make code robust
3102cdf0e10cSrcweir     if ( pPage && pPage->GetSortedObjs() )
3103cdf0e10cSrcweir     // <--
3104cdf0e10cSrcweir     {
3105cdf0e10cSrcweir         pObj->GetOrdNum();
3106cdf0e10cSrcweir         const SwSortedObjs &rObjs = *pPage->GetSortedObjs();
3107cdf0e10cSrcweir         for ( sal_uInt16 i = 0; i < rObjs.Count(); ++i )
3108cdf0e10cSrcweir         {
3109cdf0e10cSrcweir             SwAnchoredObject* pAnchoredObj = rObjs[i];
3110cdf0e10cSrcweir             if ( pAnchoredObj->ISA(SwFlyFrm) )
3111cdf0e10cSrcweir             {
3112cdf0e10cSrcweir                 if( pAnchoredObj->GetDrawObj() == pObj )
3113cdf0e10cSrcweir                     continue;
3114cdf0e10cSrcweir                 SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
3115cdf0e10cSrcweir                 if ( pFly->Frm().Top() == WEIT_WECH )
3116cdf0e10cSrcweir                     continue;
3117cdf0e10cSrcweir 
3118cdf0e10cSrcweir                 if ( !pFlyFrm ||
3119cdf0e10cSrcweir                         (!pFly->IsLowerOf( pFlyFrm ) &&
3120cdf0e10cSrcweir                         pFly->GetVirtDrawObj()->GetOrdNumDirect() < pObj->GetOrdNumDirect()))
3121cdf0e10cSrcweir                 {
3122cdf0e10cSrcweir                     pCnt = pFly->ContainsCntnt();
3123cdf0e10cSrcweir                     while ( pCnt )
3124cdf0e10cSrcweir                     {
3125cdf0e10cSrcweir                         ::lcl_NotifyCntnt( pObj, pCnt, rRect, eHint );
3126cdf0e10cSrcweir                         pCnt = pCnt->GetNextCntntFrm();
3127cdf0e10cSrcweir                     }
3128cdf0e10cSrcweir                 }
3129cdf0e10cSrcweir                 if( pFly->IsFlyLayFrm() )
3130cdf0e10cSrcweir                 {
3131cdf0e10cSrcweir                     if( pFly->Lower() && pFly->Lower()->IsColumnFrm() &&
3132cdf0e10cSrcweir                         pFly->Frm().Bottom() >= rRect.Top() &&
3133cdf0e10cSrcweir                         pFly->Frm().Top() <= rRect.Bottom() &&
3134cdf0e10cSrcweir                         pFly->Frm().Right() >= rRect.Left() &&
3135cdf0e10cSrcweir                         pFly->Frm().Left() <= rRect.Right() )
3136cdf0e10cSrcweir                      {
3137cdf0e10cSrcweir                         pFly->InvalidateSize();
3138cdf0e10cSrcweir                      }
3139cdf0e10cSrcweir                 }
3140cdf0e10cSrcweir                 //Flys, die ueber mir liegen muessen/mussten evtl.
3141cdf0e10cSrcweir                 //ausweichen, wenn sie eine automatische Ausrichtung haben.
3142cdf0e10cSrcweir                 //das ist unabhaengig von meinem Attribut, weil dies sich
3143cdf0e10cSrcweir                 //gerade geaendert haben kann und eben deshalb
3144cdf0e10cSrcweir                 //umformatiert wurde.
3145cdf0e10cSrcweir                 else if ( pFly->IsFlyAtCntFrm() &&
3146cdf0e10cSrcweir                         pObj->GetOrdNumDirect() <
3147cdf0e10cSrcweir                         pFly->GetVirtDrawObj()->GetOrdNumDirect() &&
3148cdf0e10cSrcweir                         pFlyFrm && !pFly->IsLowerOf( pFlyFrm ) )
3149cdf0e10cSrcweir                 {
3150cdf0e10cSrcweir                     const SwFmtHoriOrient &rH = pFly->GetFmt()->GetHoriOrient();
3151cdf0e10cSrcweir                     if ( text::HoriOrientation::NONE != rH.GetHoriOrient() &&
3152cdf0e10cSrcweir                             text::HoriOrientation::CENTER != rH.GetHoriOrient() &&
3153cdf0e10cSrcweir                             ( !pFly->IsAutoPos() || text::RelOrientation::CHAR != rH.GetRelationOrient() ) &&
3154cdf0e10cSrcweir                             (pFly->Frm().Bottom() >= rRect.Top() &&
3155cdf0e10cSrcweir                             pFly->Frm().Top() <= rRect.Bottom()) )
3156cdf0e10cSrcweir                         pFly->InvalidatePos();
3157cdf0e10cSrcweir                 }
3158cdf0e10cSrcweir             }
3159cdf0e10cSrcweir         }
3160cdf0e10cSrcweir     }
3161cdf0e10cSrcweir     if ( pFlyFrm && pAnchor->GetUpper() && pAnchor->IsInTab() )//MA_FLY_HEIGHT
3162cdf0e10cSrcweir         pAnchor->GetUpper()->InvalidateSize();
3163cdf0e10cSrcweir 
3164cdf0e10cSrcweir     // --> OD 2008-01-30 #i82258# - make code robust
3165cdf0e10cSrcweir     ViewShell* pSh = 0;
3166cdf0e10cSrcweir     if ( bInva && pPage &&
3167cdf0e10cSrcweir         0 != (pSh = pPage->getRootFrm()->GetCurrShell()) )
3168cdf0e10cSrcweir     {
3169cdf0e10cSrcweir         pSh->InvalidateWindows( rRect );
3170cdf0e10cSrcweir     }
3171cdf0e10cSrcweir     // <--
3172cdf0e10cSrcweir }
3173cdf0e10cSrcweir 
3174cdf0e10cSrcweir /*************************************************************************
3175cdf0e10cSrcweir |*
3176cdf0e10cSrcweir |*  GetVirtualUpper() liefert bei absatzgebundenen Objekten den Upper
3177cdf0e10cSrcweir |*  des Ankers. Falls es sich dabei um verkettete Rahmen oder
3178cdf0e10cSrcweir |*  Fussnoten handelt, wird ggf. der "virtuelle" Upper ermittelt.
3179cdf0e10cSrcweir |*
3180cdf0e10cSrcweir |*************************************************************************/
3181cdf0e10cSrcweir 
GetVirtualUpper(const SwFrm * pFrm,const Point & rPos)3182cdf0e10cSrcweir const SwFrm* GetVirtualUpper( const SwFrm* pFrm, const Point& rPos )
3183cdf0e10cSrcweir {
3184cdf0e10cSrcweir     if( pFrm->IsTxtFrm() )
3185cdf0e10cSrcweir     {
3186cdf0e10cSrcweir         pFrm = pFrm->GetUpper();
3187cdf0e10cSrcweir         if( !pFrm->Frm().IsInside( rPos ) )
3188cdf0e10cSrcweir         {
3189cdf0e10cSrcweir             if( pFrm->IsFtnFrm() )
3190cdf0e10cSrcweir             {
3191cdf0e10cSrcweir                 const SwFtnFrm* pTmp = ((SwFtnFrm*)pFrm)->GetFollow();
3192cdf0e10cSrcweir                 while( pTmp )
3193cdf0e10cSrcweir                 {
3194cdf0e10cSrcweir                     if( pTmp->Frm().IsInside( rPos ) )
3195cdf0e10cSrcweir                         return pTmp;
3196cdf0e10cSrcweir                     pTmp = pTmp->GetFollow();
3197cdf0e10cSrcweir                 }
3198cdf0e10cSrcweir             }
3199cdf0e10cSrcweir             else
3200cdf0e10cSrcweir             {
3201cdf0e10cSrcweir                 SwFlyFrm* pTmp = (SwFlyFrm*)pFrm->FindFlyFrm();
3202cdf0e10cSrcweir                 while( pTmp )
3203cdf0e10cSrcweir                 {
3204cdf0e10cSrcweir                     if( pTmp->Frm().IsInside( rPos ) )
3205cdf0e10cSrcweir                         return pTmp;
3206cdf0e10cSrcweir                     pTmp = pTmp->GetNextLink();
3207cdf0e10cSrcweir                 }
3208cdf0e10cSrcweir             }
3209cdf0e10cSrcweir         }
3210cdf0e10cSrcweir     }
3211cdf0e10cSrcweir     return pFrm;
3212cdf0e10cSrcweir }
3213cdf0e10cSrcweir 
3214cdf0e10cSrcweir /*************************************************************************/
3215cdf0e10cSrcweir 
Is_Lower_Of(const SwFrm * pCurrFrm,const SdrObject * pObj)3216cdf0e10cSrcweir sal_Bool Is_Lower_Of( const SwFrm *pCurrFrm, const SdrObject* pObj )
3217cdf0e10cSrcweir {
3218cdf0e10cSrcweir     Point aPos;
3219cdf0e10cSrcweir     const SwFrm* pFrm;
3220cdf0e10cSrcweir     if( pObj->ISA(SwVirtFlyDrawObj) )
3221cdf0e10cSrcweir     {
3222cdf0e10cSrcweir         const SwFlyFrm* pFly = ( (SwVirtFlyDrawObj*)pObj )->GetFlyFrm();
3223cdf0e10cSrcweir         pFrm = pFly->GetAnchorFrm();
3224cdf0e10cSrcweir         aPos = pFly->Frm().Pos();
3225cdf0e10cSrcweir     }
3226cdf0e10cSrcweir     else
3227cdf0e10cSrcweir     {
3228cdf0e10cSrcweir         pFrm = ( (SwDrawContact*)GetUserCall(pObj) )->GetAnchorFrm(pObj);
3229cdf0e10cSrcweir         aPos = pObj->GetCurrentBoundRect().TopLeft();
3230cdf0e10cSrcweir     }
3231cdf0e10cSrcweir     ASSERT( pFrm, "8-( Fly is lost in Space." );
3232cdf0e10cSrcweir     pFrm = GetVirtualUpper( pFrm, aPos );
3233cdf0e10cSrcweir     do
3234cdf0e10cSrcweir     {   if ( pFrm == pCurrFrm )
3235cdf0e10cSrcweir             return sal_True;
3236cdf0e10cSrcweir         if( pFrm->IsFlyFrm() )
3237cdf0e10cSrcweir         {
3238cdf0e10cSrcweir             aPos = pFrm->Frm().Pos();
3239cdf0e10cSrcweir             pFrm = GetVirtualUpper( ((const SwFlyFrm*)pFrm)->GetAnchorFrm(), aPos );
3240cdf0e10cSrcweir         }
3241cdf0e10cSrcweir         else
3242cdf0e10cSrcweir             pFrm = pFrm->GetUpper();
3243cdf0e10cSrcweir     } while ( pFrm );
3244cdf0e10cSrcweir     return sal_False;
3245cdf0e10cSrcweir }
3246cdf0e10cSrcweir 
FindKontext(const SwFrm * pFrm,sal_uInt16 nAdditionalKontextTyp)3247cdf0e10cSrcweir const SwFrm *FindKontext( const SwFrm *pFrm, sal_uInt16 nAdditionalKontextTyp )
3248cdf0e10cSrcweir {
3249cdf0e10cSrcweir     //Liefert die Umgebung des Frm in die kein Fly aus einer anderen
3250cdf0e10cSrcweir     //Umgebung hineinragen kann.
3251cdf0e10cSrcweir     const sal_uInt16 nTyp = FRM_ROOT | FRM_HEADER   | FRM_FOOTER | FRM_FTNCONT  |
3252cdf0e10cSrcweir                         FRM_FTN  | FRM_FLY      |
3253cdf0e10cSrcweir                         FRM_TAB  | FRM_ROW      | FRM_CELL |
3254cdf0e10cSrcweir                         nAdditionalKontextTyp;
3255cdf0e10cSrcweir     do
3256cdf0e10cSrcweir     {   if ( pFrm->GetType() & nTyp )
3257cdf0e10cSrcweir             break;
3258cdf0e10cSrcweir         pFrm = pFrm->GetUpper();
3259cdf0e10cSrcweir     } while( pFrm );
3260cdf0e10cSrcweir     return pFrm;
3261cdf0e10cSrcweir }
3262cdf0e10cSrcweir 
IsFrmInSameKontext(const SwFrm * pInnerFrm,const SwFrm * pFrm)3263cdf0e10cSrcweir sal_Bool IsFrmInSameKontext( const SwFrm *pInnerFrm, const SwFrm *pFrm )
3264cdf0e10cSrcweir {
3265cdf0e10cSrcweir     const SwFrm *pKontext = FindKontext( pInnerFrm, 0 );
3266cdf0e10cSrcweir 
3267cdf0e10cSrcweir     const sal_uInt16 nTyp = FRM_ROOT | FRM_HEADER   | FRM_FOOTER | FRM_FTNCONT  |
3268cdf0e10cSrcweir                         FRM_FTN  | FRM_FLY      |
3269cdf0e10cSrcweir                         FRM_TAB  | FRM_ROW      | FRM_CELL;
3270cdf0e10cSrcweir     do
3271cdf0e10cSrcweir     {   if ( pFrm->GetType() & nTyp )
3272cdf0e10cSrcweir         {
3273cdf0e10cSrcweir             if( pFrm == pKontext )
3274cdf0e10cSrcweir                 return sal_True;
3275cdf0e10cSrcweir             if( pFrm->IsCellFrm() )
3276cdf0e10cSrcweir                 return sal_False;
3277cdf0e10cSrcweir         }
3278cdf0e10cSrcweir         if( pFrm->IsFlyFrm() )
3279cdf0e10cSrcweir         {
3280cdf0e10cSrcweir             Point aPos( pFrm->Frm().Pos() );
3281cdf0e10cSrcweir             pFrm = GetVirtualUpper( ((const SwFlyFrm*)pFrm)->GetAnchorFrm(), aPos );
3282cdf0e10cSrcweir         }
3283cdf0e10cSrcweir         else
3284cdf0e10cSrcweir             pFrm = pFrm->GetUpper();
3285cdf0e10cSrcweir     } while( pFrm );
3286cdf0e10cSrcweir 
3287cdf0e10cSrcweir     return sal_False;
3288cdf0e10cSrcweir }
3289cdf0e10cSrcweir 
3290cdf0e10cSrcweir 
3291cdf0e10cSrcweir //---------------------------------
3292cdf0e10cSrcweir 
lcl_CalcCellRstHeight(SwLayoutFrm * pCell)3293cdf0e10cSrcweir SwTwips MA_FASTCALL lcl_CalcCellRstHeight( SwLayoutFrm *pCell )
3294cdf0e10cSrcweir {
3295cdf0e10cSrcweir     if ( pCell->Lower()->IsCntntFrm() || pCell->Lower()->IsSctFrm() )
3296cdf0e10cSrcweir     {
3297cdf0e10cSrcweir         SwFrm *pLow = pCell->Lower();
3298cdf0e10cSrcweir         long nHeight = 0, nFlyAdd = 0;
3299cdf0e10cSrcweir         do
3300cdf0e10cSrcweir         {
3301cdf0e10cSrcweir             long nLow = pLow->Frm().Height();
3302cdf0e10cSrcweir             if( pLow->IsTxtFrm() && ((SwTxtFrm*)pLow)->IsUndersized() )
3303cdf0e10cSrcweir                 nLow += ((SwTxtFrm*)pLow)->GetParHeight()-pLow->Prt().Height();
3304cdf0e10cSrcweir             else if( pLow->IsSctFrm() && ((SwSectionFrm*)pLow)->IsUndersized() )
3305cdf0e10cSrcweir                 nLow += ((SwSectionFrm*)pLow)->Undersize();
3306cdf0e10cSrcweir             nFlyAdd = Max( 0L, nFlyAdd - nLow );
3307cdf0e10cSrcweir             nFlyAdd = Max( nFlyAdd, ::CalcHeightWidthFlys( pLow ) );
3308cdf0e10cSrcweir             nHeight += nLow;
3309cdf0e10cSrcweir             pLow = pLow->GetNext();
3310cdf0e10cSrcweir         } while ( pLow );
3311cdf0e10cSrcweir         if ( nFlyAdd )
3312cdf0e10cSrcweir             nHeight += nFlyAdd;
3313cdf0e10cSrcweir 
3314cdf0e10cSrcweir         //Der Border will natuerlich auch mitspielen, er kann leider nicht
3315cdf0e10cSrcweir         //aus PrtArea und Frm errechnet werden, da diese in beliebiger
3316cdf0e10cSrcweir         //Kombination ungueltig sein koennen.
3317cdf0e10cSrcweir         SwBorderAttrAccess aAccess( SwFrm::GetCache(), pCell );
3318cdf0e10cSrcweir         const SwBorderAttrs &rAttrs = *aAccess.Get();
3319cdf0e10cSrcweir         nHeight += rAttrs.CalcTop() + rAttrs.CalcBottom();
3320cdf0e10cSrcweir 
3321cdf0e10cSrcweir         return pCell->Frm().Height() - nHeight;
3322cdf0e10cSrcweir     }
3323cdf0e10cSrcweir     else
3324cdf0e10cSrcweir     {
3325cdf0e10cSrcweir         long nRstHeight = 0;
3326cdf0e10cSrcweir         SwFrm *pLow = pCell->Lower();
3327cdf0e10cSrcweir         do
3328cdf0e10cSrcweir         {   nRstHeight += ::CalcRowRstHeight( (SwLayoutFrm*)pLow );
3329cdf0e10cSrcweir             pLow = pLow->GetNext();
3330cdf0e10cSrcweir 
3331cdf0e10cSrcweir         } while ( pLow );
3332cdf0e10cSrcweir 
3333cdf0e10cSrcweir         return nRstHeight;
3334cdf0e10cSrcweir     }
3335cdf0e10cSrcweir }
3336cdf0e10cSrcweir 
CalcRowRstHeight(SwLayoutFrm * pRow)3337cdf0e10cSrcweir SwTwips MA_FASTCALL CalcRowRstHeight( SwLayoutFrm *pRow )
3338cdf0e10cSrcweir {
3339cdf0e10cSrcweir     SwTwips nRstHeight = LONG_MAX;
3340cdf0e10cSrcweir     SwLayoutFrm *pLow = (SwLayoutFrm*)pRow->Lower();
3341cdf0e10cSrcweir     while ( pLow )
3342cdf0e10cSrcweir     {
3343cdf0e10cSrcweir         nRstHeight = Min( nRstHeight, ::lcl_CalcCellRstHeight( pLow ) );
3344cdf0e10cSrcweir         pLow = (SwLayoutFrm*)pLow->GetNext();
3345cdf0e10cSrcweir     }
3346cdf0e10cSrcweir     return nRstHeight;
3347cdf0e10cSrcweir }
3348cdf0e10cSrcweir 
FindPage(const SwRect & rRect,const SwFrm * pPage)3349cdf0e10cSrcweir const SwFrm* MA_FASTCALL FindPage( const SwRect &rRect, const SwFrm *pPage )
3350cdf0e10cSrcweir {
3351cdf0e10cSrcweir     if ( !rRect.IsOver( pPage->Frm() ) )
3352cdf0e10cSrcweir     {
3353cdf0e10cSrcweir         const SwRootFrm* pRootFrm = static_cast<const SwRootFrm*>(pPage->GetUpper());
3354cdf0e10cSrcweir         const SwFrm* pTmpPage = pRootFrm ? pRootFrm->GetPageAtPos( rRect.TopLeft(), &rRect.SSize(), true ) : 0;
3355cdf0e10cSrcweir         if ( pTmpPage )
3356cdf0e10cSrcweir             pPage = pTmpPage;
3357cdf0e10cSrcweir     }
3358cdf0e10cSrcweir 
3359cdf0e10cSrcweir     return pPage;
3360cdf0e10cSrcweir }
3361cdf0e10cSrcweir 
3362cdf0e10cSrcweir #include <svl/smplhint.hxx>
3363cdf0e10cSrcweir class SwFrmHolder : private SfxListener
3364cdf0e10cSrcweir {
3365cdf0e10cSrcweir     SwFrm* pFrm;
3366cdf0e10cSrcweir     bool bSet;
3367cdf0e10cSrcweir     virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
3368cdf0e10cSrcweir public:
SwFrmHolder()3369cdf0e10cSrcweir     SwFrmHolder() : pFrm(0), bSet(false) {}
3370cdf0e10cSrcweir     void SetFrm( SwFrm* pHold );
GetFrm()3371cdf0e10cSrcweir     SwFrm* GetFrm() { return pFrm; }
3372cdf0e10cSrcweir     void Reset();
IsSet()3373cdf0e10cSrcweir     bool IsSet() { return bSet; }
3374cdf0e10cSrcweir };
3375cdf0e10cSrcweir 
SetFrm(SwFrm * pHold)3376cdf0e10cSrcweir void SwFrmHolder::SetFrm( SwFrm* pHold )
3377cdf0e10cSrcweir {
3378cdf0e10cSrcweir     bSet = true;
3379cdf0e10cSrcweir     pFrm = pHold;
3380cdf0e10cSrcweir     StartListening(*pHold);
3381cdf0e10cSrcweir }
3382cdf0e10cSrcweir 
Reset()3383cdf0e10cSrcweir void SwFrmHolder::Reset()
3384cdf0e10cSrcweir {
3385cdf0e10cSrcweir     if (pFrm)
3386cdf0e10cSrcweir         EndListening(*pFrm);
3387cdf0e10cSrcweir     bSet = false;
3388cdf0e10cSrcweir     pFrm = 0;
3389cdf0e10cSrcweir }
3390cdf0e10cSrcweir 
Notify(SfxBroadcaster & rBC,const SfxHint & rHint)3391cdf0e10cSrcweir void SwFrmHolder::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
3392cdf0e10cSrcweir {
3393cdf0e10cSrcweir     if ( rHint.IsA(TYPE(SfxSimpleHint)) )
3394cdf0e10cSrcweir     {
3395cdf0e10cSrcweir         if ( ( (SfxSimpleHint&) rHint ).GetId() == SFX_HINT_DYING && &rBC == pFrm )
3396cdf0e10cSrcweir             pFrm = 0;
3397cdf0e10cSrcweir     }
3398cdf0e10cSrcweir }
3399cdf0e10cSrcweir 
GetFrmOfModify(const SwRootFrm * pLayout,SwModify const & rMod,sal_uInt16 const nFrmType,const Point * pPoint,const SwPosition * pPos,const sal_Bool bCalcFrm)3400cdf0e10cSrcweir SwFrm* GetFrmOfModify( const SwRootFrm* pLayout, SwModify const& rMod, sal_uInt16 const nFrmType,
3401cdf0e10cSrcweir         const Point* pPoint, const SwPosition *pPos, const sal_Bool bCalcFrm )
3402cdf0e10cSrcweir {
3403cdf0e10cSrcweir     SwFrm *pMinFrm = 0, *pTmpFrm;
3404cdf0e10cSrcweir     SwFrmHolder aHolder;
3405cdf0e10cSrcweir     SwRect aCalcRect;
3406cdf0e10cSrcweir     bool bClientIterChanged = false;
3407cdf0e10cSrcweir 
3408cdf0e10cSrcweir     SwIterator<SwFrm,SwModify> aIter( rMod );
3409cdf0e10cSrcweir     do {
3410cdf0e10cSrcweir         pMinFrm = 0;
3411cdf0e10cSrcweir         aHolder.Reset();
3412cdf0e10cSrcweir         sal_uInt64 nMinDist = 0;
3413cdf0e10cSrcweir         bClientIterChanged = false;
3414cdf0e10cSrcweir 
3415cdf0e10cSrcweir         for( pTmpFrm = aIter.First(); pTmpFrm; pTmpFrm = aIter.Next() )
3416cdf0e10cSrcweir         {
3417cdf0e10cSrcweir             if( pTmpFrm->GetType() & nFrmType &&
3418cdf0e10cSrcweir                 ( !pLayout || pLayout == pTmpFrm->getRootFrm() ) &&
3419cdf0e10cSrcweir                 (!pTmpFrm->IsFlowFrm() ||
3420cdf0e10cSrcweir                  !SwFlowFrm::CastFlowFrm( pTmpFrm )->IsFollow() ))
3421cdf0e10cSrcweir             {
3422cdf0e10cSrcweir                 if( pPoint )
3423cdf0e10cSrcweir                 {
3424cdf0e10cSrcweir                     // watch for Frm being deleted
3425cdf0e10cSrcweir                     if ( pMinFrm )
3426cdf0e10cSrcweir                         aHolder.SetFrm( pMinFrm );
3427cdf0e10cSrcweir                     else
3428cdf0e10cSrcweir                         aHolder.Reset();
3429cdf0e10cSrcweir 
3430cdf0e10cSrcweir                     if( bCalcFrm )
3431cdf0e10cSrcweir                     {
3432cdf0e10cSrcweir                         // --> OD 2005-03-04 #b6234250# - format parent Writer
3433cdf0e10cSrcweir                         // fly frame, if it isn't been formatted yet.
3434cdf0e10cSrcweir                         // Note: The Writer fly frame could be the frame itself.
3435cdf0e10cSrcweir                         SwFlyFrm* pFlyFrm( pTmpFrm->FindFlyFrm() );
3436cdf0e10cSrcweir                         if ( pFlyFrm &&
3437cdf0e10cSrcweir                              pFlyFrm->Frm().Pos().X() == WEIT_WECH &&
3438cdf0e10cSrcweir                              pFlyFrm->Frm().Pos().Y() == WEIT_WECH )
3439cdf0e10cSrcweir                         {
3440cdf0e10cSrcweir                             SwObjectFormatter::FormatObj( *pFlyFrm );
3441cdf0e10cSrcweir                         }
3442cdf0e10cSrcweir                         // <--
3443cdf0e10cSrcweir                         pTmpFrm->Calc();
3444cdf0e10cSrcweir                     }
3445cdf0e10cSrcweir 
3446cdf0e10cSrcweir                     // #127369#
3447cdf0e10cSrcweir                     // aIter.IsChanged checks if the current pTmpFrm has been deleted while
3448cdf0e10cSrcweir                     // it is the current iterator
3449cdf0e10cSrcweir                     // FrmHolder watches for deletion of the current pMinFrm
3450cdf0e10cSrcweir                     if( aIter.IsChanged() || ( aHolder.IsSet() && !aHolder.GetFrm() ) )
3451cdf0e10cSrcweir                     {
3452cdf0e10cSrcweir                         // restart iteration
3453cdf0e10cSrcweir                         bClientIterChanged = true;
3454cdf0e10cSrcweir                         break;
3455cdf0e10cSrcweir                     }
3456cdf0e10cSrcweir 
3457cdf0e10cSrcweir                     // bei Flys ggfs. ueber den Parent gehen wenn sie selbst
3458cdf0e10cSrcweir                     // nocht nicht "formatiert" sind
3459cdf0e10cSrcweir                     if( !bCalcFrm && nFrmType & FRM_FLY &&
3460cdf0e10cSrcweir                         ((SwFlyFrm*)pTmpFrm)->GetAnchorFrm() &&
3461cdf0e10cSrcweir                         WEIT_WECH == pTmpFrm->Frm().Pos().X() &&
3462cdf0e10cSrcweir                         WEIT_WECH == pTmpFrm->Frm().Pos().Y() )
3463cdf0e10cSrcweir                         aCalcRect = ((SwFlyFrm*)pTmpFrm)->GetAnchorFrm()->Frm();
3464cdf0e10cSrcweir                     else
3465cdf0e10cSrcweir                         aCalcRect = pTmpFrm->Frm();
3466cdf0e10cSrcweir 
3467cdf0e10cSrcweir                     if ( aCalcRect.IsInside( *pPoint ) )
3468cdf0e10cSrcweir                     {
3469cdf0e10cSrcweir                         pMinFrm = pTmpFrm;
3470cdf0e10cSrcweir                         break;
3471cdf0e10cSrcweir                     }
3472cdf0e10cSrcweir 
3473cdf0e10cSrcweir                     // Point not in rectangle. Compare distances:
3474cdf0e10cSrcweir                     const Point aCalcRectCenter = aCalcRect.Center();
3475cdf0e10cSrcweir                     const Point aDiff = aCalcRectCenter - *pPoint;
3476cdf0e10cSrcweir                     const sal_uInt64 nCurrentDist = aDiff.X() * aDiff.X() + aDiff.Y() * aDiff.Y(); // opt: no sqrt
3477cdf0e10cSrcweir                     if ( !pMinFrm || nCurrentDist < nMinDist )
3478cdf0e10cSrcweir                     {
3479cdf0e10cSrcweir                         pMinFrm = pTmpFrm;
3480cdf0e10cSrcweir                         nMinDist = nCurrentDist;
3481cdf0e10cSrcweir                     }
3482cdf0e10cSrcweir                 }
3483cdf0e10cSrcweir                 else
3484cdf0e10cSrcweir                 {
3485cdf0e10cSrcweir                     // Wenn kein pPoint angegeben ist, dann reichen
3486cdf0e10cSrcweir                     // wir irgendeinen raus: den ersten!
3487cdf0e10cSrcweir                     pMinFrm = pTmpFrm;
3488cdf0e10cSrcweir                     break;
3489cdf0e10cSrcweir                 }
3490cdf0e10cSrcweir             }
3491cdf0e10cSrcweir         }
3492cdf0e10cSrcweir     } while( bClientIterChanged );
3493cdf0e10cSrcweir 
3494cdf0e10cSrcweir     if( pPos && pMinFrm && pMinFrm->IsTxtFrm() )
3495cdf0e10cSrcweir         return ((SwTxtFrm*)pMinFrm)->GetFrmAtPos( *pPos );
3496cdf0e10cSrcweir 
3497cdf0e10cSrcweir     return pMinFrm;
3498cdf0e10cSrcweir }
3499cdf0e10cSrcweir 
IsExtraData(const SwDoc * pDoc)3500cdf0e10cSrcweir sal_Bool IsExtraData( const SwDoc *pDoc )
3501cdf0e10cSrcweir {
3502cdf0e10cSrcweir     const SwLineNumberInfo &rInf = pDoc->GetLineNumberInfo();
3503cdf0e10cSrcweir     return rInf.IsPaintLineNumbers() ||
3504cdf0e10cSrcweir            rInf.IsCountInFlys() ||
3505cdf0e10cSrcweir            ((sal_Int16)SW_MOD()->GetRedlineMarkPos() != text::HoriOrientation::NONE &&
3506cdf0e10cSrcweir             pDoc->GetRedlineTbl().Count());
3507cdf0e10cSrcweir }
3508cdf0e10cSrcweir 
3509cdf0e10cSrcweir // OD 22.09.2003 #110978#
PrtWithoutHeaderAndFooter() const3510cdf0e10cSrcweir const SwRect SwPageFrm::PrtWithoutHeaderAndFooter() const
3511cdf0e10cSrcweir {
3512cdf0e10cSrcweir     SwRect aPrtWithoutHeaderFooter( Prt() );
3513cdf0e10cSrcweir     aPrtWithoutHeaderFooter.Pos() += Frm().Pos();
3514cdf0e10cSrcweir 
3515cdf0e10cSrcweir     const SwFrm* pLowerFrm = Lower();
3516cdf0e10cSrcweir     while ( pLowerFrm )
3517cdf0e10cSrcweir     {
3518cdf0e10cSrcweir         // Note: independent on text direction page header and page footer are
3519cdf0e10cSrcweir         //       always at top respectively at bottom of the page frame.
3520cdf0e10cSrcweir         if ( pLowerFrm->IsHeaderFrm() )
3521cdf0e10cSrcweir         {
3522cdf0e10cSrcweir             aPrtWithoutHeaderFooter.Top( aPrtWithoutHeaderFooter.Top() +
3523cdf0e10cSrcweir                                          pLowerFrm->Frm().Height() );
3524cdf0e10cSrcweir         }
3525cdf0e10cSrcweir         if ( pLowerFrm->IsFooterFrm() )
3526cdf0e10cSrcweir         {
3527cdf0e10cSrcweir             aPrtWithoutHeaderFooter.Bottom( aPrtWithoutHeaderFooter.Bottom() -
3528cdf0e10cSrcweir                                             pLowerFrm->Frm().Height() );
3529cdf0e10cSrcweir         }
3530cdf0e10cSrcweir 
3531cdf0e10cSrcweir         pLowerFrm = pLowerFrm->GetNext();
3532cdf0e10cSrcweir     }
3533cdf0e10cSrcweir 
3534cdf0e10cSrcweir     return aPrtWithoutHeaderFooter;
3535cdf0e10cSrcweir }
3536cdf0e10cSrcweir 
3537cdf0e10cSrcweir /** method to determine the spacing values of a frame
3538cdf0e10cSrcweir 
3539cdf0e10cSrcweir     OD 2004-03-10 #i28701#
3540cdf0e10cSrcweir     OD 2009-08-28 #i102458#
3541cdf0e10cSrcweir     Add output parameter <obIsLineSpacingProportional>
3542cdf0e10cSrcweir 
3543cdf0e10cSrcweir     @author OD
3544cdf0e10cSrcweir */
GetSpacingValuesOfFrm(const SwFrm & rFrm,SwTwips & onLowerSpacing,SwTwips & onLineSpacing,bool & obIsLineSpacingProportional)3545cdf0e10cSrcweir void GetSpacingValuesOfFrm( const SwFrm& rFrm,
3546cdf0e10cSrcweir                             SwTwips& onLowerSpacing,
3547cdf0e10cSrcweir                             SwTwips& onLineSpacing,
3548cdf0e10cSrcweir                             bool& obIsLineSpacingProportional )
3549cdf0e10cSrcweir {
3550cdf0e10cSrcweir     if ( !rFrm.IsFlowFrm() )
3551cdf0e10cSrcweir     {
3552cdf0e10cSrcweir         onLowerSpacing = 0;
3553cdf0e10cSrcweir         onLineSpacing = 0;
3554cdf0e10cSrcweir     }
3555cdf0e10cSrcweir     else
3556cdf0e10cSrcweir     {
3557cdf0e10cSrcweir         const SvxULSpaceItem& rULSpace = rFrm.GetAttrSet()->GetULSpace();
3558cdf0e10cSrcweir         onLowerSpacing = rULSpace.GetLower();
3559cdf0e10cSrcweir 
3560cdf0e10cSrcweir         onLineSpacing = 0;
3561cdf0e10cSrcweir         obIsLineSpacingProportional = false;
3562cdf0e10cSrcweir         if ( rFrm.IsTxtFrm() )
3563cdf0e10cSrcweir         {
3564cdf0e10cSrcweir             onLineSpacing = static_cast<const SwTxtFrm&>(rFrm).GetLineSpace();
3565cdf0e10cSrcweir             obIsLineSpacingProportional =
3566cdf0e10cSrcweir                 onLineSpacing != 0 &&
3567cdf0e10cSrcweir                 static_cast<const SwTxtFrm&>(rFrm).GetLineSpace( true ) == 0;
3568cdf0e10cSrcweir         }
3569cdf0e10cSrcweir 
3570cdf0e10cSrcweir         ASSERT( onLowerSpacing >= 0 && onLineSpacing >= 0,
3571cdf0e10cSrcweir                 "<GetSpacingValuesOfFrm(..)> - spacing values aren't positive!" );
3572cdf0e10cSrcweir     }
3573cdf0e10cSrcweir }
3574cdf0e10cSrcweir 
3575cdf0e10cSrcweir /** method to get the content of the table cell, skipping content from nested tables
3576cdf0e10cSrcweir */
GetCellCntnt(const SwLayoutFrm & rCell)3577cdf0e10cSrcweir const SwCntntFrm* GetCellCntnt( const SwLayoutFrm& rCell )
3578cdf0e10cSrcweir {
3579cdf0e10cSrcweir     const SwCntntFrm* pCntnt = rCell.ContainsCntnt();
3580cdf0e10cSrcweir     const SwTabFrm* pTab = rCell.FindTabFrm();
3581cdf0e10cSrcweir 
3582cdf0e10cSrcweir     while ( pCntnt && rCell.IsAnLower( pCntnt ) )
3583cdf0e10cSrcweir     {
3584cdf0e10cSrcweir         const SwTabFrm* pTmpTab = pCntnt->FindTabFrm();
3585cdf0e10cSrcweir         if ( pTmpTab != pTab )
3586cdf0e10cSrcweir         {
3587cdf0e10cSrcweir             pCntnt = pTmpTab->FindLastCntnt();
3588cdf0e10cSrcweir             if ( pCntnt )
3589cdf0e10cSrcweir 
3590cdf0e10cSrcweir                 pCntnt = pCntnt->FindNextCnt();
3591cdf0e10cSrcweir 
3592cdf0e10cSrcweir         }
3593cdf0e10cSrcweir         else
3594cdf0e10cSrcweir             break;
3595cdf0e10cSrcweir     }
3596cdf0e10cSrcweir     return pCntnt;
3597cdf0e10cSrcweir }
3598cdf0e10cSrcweir 
3599cdf0e10cSrcweir /** Can be used to check if a frame has been deleted
3600cdf0e10cSrcweir  */
HasBeenDeleted()3601cdf0e10cSrcweir bool SwDeletionChecker::HasBeenDeleted()
3602cdf0e10cSrcweir {
3603cdf0e10cSrcweir     if ( !mpFrm || !mpRegIn )
3604cdf0e10cSrcweir         return false;
3605cdf0e10cSrcweir 
3606cdf0e10cSrcweir     SwIterator<SwFrm,SwModify> aIter(*mpRegIn);
3607cdf0e10cSrcweir     SwFrm* pLast = aIter.First();
3608cdf0e10cSrcweir     while ( pLast )
3609cdf0e10cSrcweir     {
3610cdf0e10cSrcweir         if ( pLast == mpFrm )
3611cdf0e10cSrcweir             return false;
3612cdf0e10cSrcweir         pLast = aIter.Next();
3613cdf0e10cSrcweir     }
3614cdf0e10cSrcweir 
3615cdf0e10cSrcweir     return true;
3616cdf0e10cSrcweir }
3617