Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "hintids.hxx"
21 : #include <svl/itemiter.hxx>
22 : #include <svtools/imap.hxx>
23 : #include <vcl/graph.hxx>
24 : #include <tools/poly.hxx>
25 : #include <tools/helpers.hxx>
26 : #include <svx/contdlg.hxx>
27 : #include <editeng/protitem.hxx>
28 : #include <editeng/opaqitem.hxx>
29 : #include <editeng/ulspitem.hxx>
30 : #include <editeng/lrspitem.hxx>
31 : #include <editeng/frmdiritem.hxx>
32 : #include <editeng/keepitem.hxx>
33 : #include <fmtanchr.hxx>
34 : #include <fmtfsize.hxx>
35 : #include <fmtclds.hxx>
36 : #include <fmtcntnt.hxx>
37 : #include <fmturl.hxx>
38 : #include <fmtsrnd.hxx>
39 : #include <fmtornt.hxx>
40 : #include <fmtpdsc.hxx>
41 : #include <fmtcnct.hxx>
42 : #include <layhelp.hxx>
43 : #include <ndtxt.hxx>
44 : #include <svx/svdogrp.hxx>
45 : #include <ndgrf.hxx>
46 : #include <tolayoutanchoredobjectposition.hxx>
47 : #include <fmtfollowtextflow.hxx>
48 : #include <sortedobjs.hxx>
49 : #include <objectformatter.hxx>
50 : #include <anchoredobject.hxx>
51 : #include <ndole.hxx>
52 : #include <swtable.hxx>
53 : #include <svx/svdpage.hxx>
54 : #include "doc.hxx"
55 : #include "viewsh.hxx"
56 : #include "layouter.hxx"
57 : #include "pagefrm.hxx"
58 : #include "rootfrm.hxx"
59 : #include "cntfrm.hxx"
60 : #include "pam.hxx"
61 : #include "frmatr.hxx"
62 : #include "viewimp.hxx"
63 : #include "viewopt.hxx"
64 : #include "dcontact.hxx"
65 : #include "dflyobj.hxx"
66 : #include "dview.hxx"
67 : #include "flyfrm.hxx"
68 : #include "frmtool.hxx"
69 : #include "frmfmt.hxx"
70 : #include "hints.hxx"
71 : #include "swregion.hxx"
72 : #include "tabfrm.hxx"
73 : #include "txtfrm.hxx"
74 : #include "ndnotxt.hxx"
75 : #include "notxtfrm.hxx" // GetGrfArea
76 : #include "flyfrms.hxx"
77 : #include "ndindex.hxx" // GetGrfArea
78 : #include "sectfrm.hxx"
79 : #include <vcl/svapp.hxx>
80 : #include "switerator.hxx"
81 :
82 : using namespace ::com::sun::star;
83 :
84 :
85 36888 : TYPEINIT2(SwFlyFrm,SwLayoutFrm,SwAnchoredObject);
86 :
87 : /*************************************************************************
88 : |*
89 : |* SwFlyFrm::SwFlyFrm()
90 : |*
91 : |*************************************************************************/
92 :
93 328 : SwFlyFrm::SwFlyFrm( SwFlyFrmFmt *pFmt, SwFrm* pSib, SwFrm *pAnch ) :
94 : SwLayoutFrm( pFmt, pSib ),
95 : SwAnchoredObject(), // #i26791#
96 : pPrevLink( 0 ),
97 : pNextLink( 0 ),
98 : bInCnt( sal_False ),
99 : bAtCnt( sal_False ),
100 : bLayout( sal_False ),
101 : bAutoPosition( sal_False ),
102 : bNoShrink( sal_False ),
103 328 : bLockDeleteContent( sal_False )
104 : {
105 328 : mnType = FRMC_FLY;
106 :
107 328 : bInvalid = bNotifyBack = sal_True;
108 : bLocked = bMinHeight =
109 328 : bHeightClipped = bWidthClipped = bFormatHeightOnly = sal_False;
110 :
111 : //Grosseneinstellung, Fixe groesse ist immer die Breite
112 328 : const SwFmtFrmSize &rFrmSize = pFmt->GetFrmSize();
113 : sal_uInt16 nDir =
114 328 : ((SvxFrameDirectionItem&)pFmt->GetFmtAttr( RES_FRAMEDIR )).GetValue();
115 328 : if( FRMDIR_ENVIRONMENT == nDir )
116 : {
117 308 : mbDerivedVert = 1;
118 308 : mbDerivedR2L = 1;
119 : }
120 : else
121 : {
122 20 : mbInvalidVert = 0;
123 20 : mbDerivedVert = 0;
124 20 : mbDerivedR2L = 0;
125 20 : if( FRMDIR_HORI_LEFT_TOP == nDir || FRMDIR_HORI_RIGHT_TOP == nDir )
126 : {
127 : //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
128 20 : mbVertLR = 0;
129 20 : mbVertical = 0;
130 : }
131 : else
132 : {
133 0 : const ViewShell *pSh = getRootFrm() ? getRootFrm()->GetCurrShell() : 0;
134 0 : if( pSh && pSh->GetViewOptions()->getBrowseMode() )
135 : {
136 : //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
137 0 : mbVertLR = 0;
138 0 : mbVertical = 0;
139 : }
140 : else
141 : {
142 0 : mbVertical = 1;
143 : //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
144 0 : if ( FRMDIR_VERT_TOP_LEFT == nDir )
145 0 : mbVertLR = 1;
146 : else
147 0 : mbVertLR = 0;
148 : }
149 : }
150 :
151 20 : mbInvalidR2L = 0;
152 20 : if( FRMDIR_HORI_RIGHT_TOP == nDir )
153 0 : mbRightToLeft = 1;
154 : else
155 20 : mbRightToLeft = 0;
156 : }
157 :
158 328 : Frm().Width( rFrmSize.GetWidth() );
159 328 : Frm().Height( rFrmSize.GetHeightSizeType() == ATT_VAR_SIZE ? MINFLY : rFrmSize.GetHeight() );
160 :
161 : // Fixed or variable Height?
162 328 : if ( rFrmSize.GetHeightSizeType() == ATT_MIN_SIZE )
163 16 : bMinHeight = sal_True;
164 312 : else if ( rFrmSize.GetHeightSizeType() == ATT_FIX_SIZE )
165 67 : mbFixSize = sal_True;
166 :
167 : // insert columns, if necessary
168 328 : InsertColumns();
169 :
170 : //Erst das Init, dann den Inhalt, denn zum Inhalt koennen widerum
171 : //Objekte/Rahmen gehoeren die dann angemeldet werden.
172 328 : InitDrawObj( sal_False );
173 :
174 328 : Chain( pAnch );
175 :
176 328 : InsertCnt();
177 :
178 : //Und erstmal in den Wald stellen die Kiste, damit bei neuen Dokument nicht
179 : //unnoetig viel formatiert wird.
180 328 : Frm().Pos().setX(FAR_AWAY);
181 328 : Frm().Pos().setY(FAR_AWAY);
182 328 : }
183 :
184 328 : void SwFlyFrm::Chain( SwFrm* _pAnch )
185 : {
186 : // Connect to chain neighboors.
187 : // No problem, if a neighboor doesn't exist - the construction of the
188 : // neighboor will make the connection
189 328 : const SwFmtChain& rChain = GetFmt()->GetChain();
190 328 : if ( rChain.GetPrev() || rChain.GetNext() )
191 : {
192 0 : if ( rChain.GetNext() )
193 : {
194 0 : SwFlyFrm* pFollow = FindChainNeighbour( *rChain.GetNext(), _pAnch );
195 0 : if ( pFollow )
196 : {
197 : OSL_ENSURE( !pFollow->GetPrevLink(), "wrong chain detected" );
198 0 : if ( !pFollow->GetPrevLink() )
199 0 : SwFlyFrm::ChainFrames( this, pFollow );
200 : }
201 : }
202 0 : if ( rChain.GetPrev() )
203 : {
204 0 : SwFlyFrm *pMaster = FindChainNeighbour( *rChain.GetPrev(), _pAnch );
205 0 : if ( pMaster )
206 : {
207 : OSL_ENSURE( !pMaster->GetNextLink(), "wrong chain detected" );
208 0 : if ( !pMaster->GetNextLink() )
209 0 : SwFlyFrm::ChainFrames( pMaster, this );
210 : }
211 : }
212 : }
213 328 : }
214 :
215 328 : void SwFlyFrm::InsertCnt()
216 : {
217 328 : if ( !GetPrevLink() )
218 : {
219 328 : const SwFmtCntnt& rCntnt = GetFmt()->GetCntnt();
220 : OSL_ENSURE( rCntnt.GetCntntIdx(), ":-( no content prepared." );
221 328 : sal_uLong nIndex = rCntnt.GetCntntIdx()->GetIndex();
222 : // Lower() bedeutet SwColumnFrm, eingefuegt werden muss der Inhalt dann in den (Column)BodyFrm
223 328 : ::_InsertCnt( Lower() ? (SwLayoutFrm*)((SwLayoutFrm*)Lower())->Lower() : (SwLayoutFrm*)this,
224 656 : GetFmt()->GetDoc(), nIndex );
225 :
226 : // NoTxt always have a fixed height.
227 328 : if ( Lower() && Lower()->IsNoTxtFrm() )
228 : {
229 200 : mbFixSize = sal_True;
230 200 : bMinHeight = sal_False;
231 : }
232 : }
233 328 : }
234 :
235 328 : void SwFlyFrm::InsertColumns()
236 : {
237 : // #i97379#
238 : // Check, if column are allowed.
239 : // Columns are not allowed for fly frames, which represent graphics or embedded objects.
240 328 : const SwFmtCntnt& rCntnt = GetFmt()->GetCntnt();
241 : OSL_ENSURE( rCntnt.GetCntntIdx(), "<SwFlyFrm::InsertColumns()> - no content prepared." );
242 328 : SwNodeIndex aFirstCntnt( *(rCntnt.GetCntntIdx()), 1 );
243 328 : if ( aFirstCntnt.GetNode().IsNoTxtNode() )
244 : {
245 528 : return;
246 : }
247 :
248 128 : const SwFmtCol &rCol = GetFmt()->GetCol();
249 128 : if ( rCol.GetNumCols() > 1 )
250 : {
251 : //PrtArea ersteinmal so gross wie der Frm, damit die Spalten
252 : //vernuenftig eingesetzt werden koennen; das schaukelt sich dann
253 : //schon zurecht.
254 0 : Prt().Width( Frm().Width() );
255 0 : Prt().Height( Frm().Height() );
256 0 : const SwFmtCol aOld; //ChgColumns() verlaesst sich darauf, dass auch ein
257 : //Old-Wert hereingereicht wird.
258 0 : ChgColumns( aOld, rCol );
259 128 : }
260 : }
261 :
262 : /*************************************************************************
263 : |*
264 : |* SwFlyFrm::~SwFlyFrm()
265 : |*
266 : |*************************************************************************/
267 :
268 656 : SwFlyFrm::~SwFlyFrm()
269 : {
270 : // Accessible objects for fly frames will be destroyed in this destructor.
271 : // For frames bound as char or frames that don't have an anchor we have
272 : // to do that ourselves. For any other frame the call RemoveFly at the
273 : // anchor will do that.
274 328 : if( IsAccessibleFrm() && GetFmt() && (IsFlyInCntFrm() || !GetAnchorFrm()) )
275 : {
276 189 : SwRootFrm *pRootFrm = getRootFrm();
277 189 : if( pRootFrm && pRootFrm->IsAnyShellAccessible() )
278 : {
279 0 : ViewShell *pVSh = pRootFrm->GetCurrShell();
280 0 : if( pVSh && pVSh->Imp() )
281 : {
282 : // Lowers aren't disposed already, so we have to do a recursive
283 : // dispose
284 0 : pVSh->Imp()->DisposeAccessibleFrm( this, sal_True );
285 : }
286 : }
287 : }
288 :
289 328 : if( GetFmt() && !GetFmt()->GetDoc()->IsInDtor() )
290 : {
291 : // OD 2004-01-19 #110582#
292 328 : Unchain();
293 :
294 : // OD 2004-01-19 #110582#
295 328 : DeleteCnt();
296 :
297 : //Tschuess sagen.
298 328 : if ( GetAnchorFrm() )
299 328 : AnchorFrm()->RemoveFly( this );
300 : }
301 :
302 328 : FinitDrawObj();
303 328 : }
304 :
305 0 : const IDocumentDrawModelAccess* SwFlyFrm::getIDocumentDrawModelAccess()
306 : {
307 0 : return GetFmt()->getIDocumentDrawModelAccess();
308 : }
309 :
310 : // OD 2004-01-19 #110582#
311 328 : void SwFlyFrm::Unchain()
312 : {
313 328 : if ( GetPrevLink() )
314 0 : UnchainFrames( GetPrevLink(), this );
315 328 : if ( GetNextLink() )
316 0 : UnchainFrames( this, GetNextLink() );
317 328 : }
318 :
319 : // OD 2004-01-19 #110582#
320 328 : void SwFlyFrm::DeleteCnt()
321 : {
322 : // #110582#-2
323 328 : if ( IsLockDeleteContent() )
324 328 : return;
325 :
326 328 : SwFrm* pFrm = pLower;
327 1013 : while ( pFrm )
328 : {
329 715 : while ( pFrm->GetDrawObjs() && pFrm->GetDrawObjs()->Count() )
330 : {
331 1 : SwAnchoredObject *pAnchoredObj = (*pFrm->GetDrawObjs())[0];
332 1 : if ( pAnchoredObj->ISA(SwFlyFrm) )
333 0 : delete pAnchoredObj;
334 1 : else if ( pAnchoredObj->ISA(SwAnchoredDrawObject) )
335 : {
336 : // OD 23.06.2003 #108784# - consider 'virtual' drawing objects
337 1 : SdrObject* pObj = pAnchoredObj->DrawObj();
338 1 : if ( pObj->ISA(SwDrawVirtObj) )
339 : {
340 0 : SwDrawVirtObj* pDrawVirtObj = static_cast<SwDrawVirtObj*>(pObj);
341 0 : pDrawVirtObj->RemoveFromWriterLayout();
342 0 : pDrawVirtObj->RemoveFromDrawingPage();
343 : }
344 : else
345 : {
346 : SwDrawContact* pContact =
347 1 : static_cast<SwDrawContact*>(::GetUserCall( pObj ));
348 1 : if ( pContact )
349 : {
350 1 : pContact->DisconnectFromLayout();
351 : }
352 : }
353 : }
354 : }
355 :
356 357 : pFrm->Remove();
357 357 : delete pFrm;
358 357 : pFrm = pLower;
359 : }
360 :
361 328 : InvalidatePage();
362 : }
363 :
364 : /*************************************************************************
365 : |*
366 : |* SwFlyFrm::InitDrawObj()
367 : |*
368 : |*************************************************************************/
369 :
370 233 : sal_uInt32 SwFlyFrm::_GetOrdNumForNewRef( const SwFlyDrawContact* pContact )
371 : {
372 233 : sal_uInt32 nOrdNum( 0L );
373 :
374 : // search for another Writer fly frame registered at same frame format
375 233 : SwIterator<SwFlyFrm,SwFmt> aIter( *pContact->GetFmt() );
376 233 : const SwFlyFrm* pFlyFrm( 0L );
377 466 : for ( pFlyFrm = aIter.First(); pFlyFrm; pFlyFrm = aIter.Next() )
378 : {
379 233 : if ( pFlyFrm != this )
380 : {
381 0 : break;
382 : }
383 : }
384 :
385 233 : if ( pFlyFrm )
386 : {
387 : // another Writer fly frame found. Take its order number
388 0 : nOrdNum = pFlyFrm->GetVirtDrawObj()->GetOrdNum();
389 : }
390 : else
391 : {
392 : // no other Writer fly frame found. Take order number of 'master' object
393 : // #i35748# - use method <GetOrdNumDirect()> instead
394 : // of method <GetOrdNum()> to avoid a recalculation of the order number,
395 : // which isn't intended.
396 233 : nOrdNum = pContact->GetMaster()->GetOrdNumDirect();
397 : }
398 :
399 233 : return nOrdNum;
400 : }
401 :
402 328 : SwVirtFlyDrawObj* SwFlyFrm::CreateNewRef( SwFlyDrawContact *pContact )
403 : {
404 328 : SwVirtFlyDrawObj *pDrawObj = new SwVirtFlyDrawObj( *pContact->GetMaster(), this );
405 328 : pDrawObj->SetModel( pContact->GetMaster()->GetModel() );
406 328 : pDrawObj->SetUserCall( pContact );
407 :
408 : //Der Reader erzeugt die Master und setzt diese, um die Z-Order zu
409 : //transportieren, in die Page ein. Beim erzeugen der ersten Referenz werden
410 : //die Master aus der Liste entfernt und fuehren von da an ein
411 : //Schattendasein.
412 328 : SdrPage* pPg( 0L );
413 328 : if ( 0 != ( pPg = pContact->GetMaster()->GetPage() ) )
414 : {
415 95 : const sal_uInt32 nOrdNum = pContact->GetMaster()->GetOrdNum();
416 95 : pPg->ReplaceObject( pDrawObj, nOrdNum );
417 : }
418 : // #i27030# - insert new <SwVirtFlyDrawObj> instance
419 : // into drawing page with correct order number
420 : else
421 : {
422 233 : pContact->GetFmt()->getIDocumentDrawModelAccess()->GetDrawModel()->GetPage( 0 )->
423 233 : InsertObject( pDrawObj, _GetOrdNumForNewRef( pContact ) );
424 : }
425 : // #i38889# - assure, that new <SwVirtFlyDrawObj> instance
426 : // is in a visible layer.
427 328 : pContact->MoveObjToVisibleLayer( pDrawObj );
428 328 : return pDrawObj;
429 : }
430 :
431 :
432 :
433 328 : void SwFlyFrm::InitDrawObj( sal_Bool bNotify )
434 : {
435 : //ContactObject aus dem Format suchen. Wenn bereits eines existiert, so
436 : //braucht nur eine neue Ref erzeugt werden, anderfalls ist es jetzt an
437 : //der Zeit das Contact zu erzeugen.
438 :
439 328 : IDocumentDrawModelAccess* pIDDMA = GetFmt()->getIDocumentDrawModelAccess();
440 328 : SwFlyDrawContact *pContact = SwIterator<SwFlyDrawContact,SwFmt>::FirstElement( *GetFmt() );
441 328 : if ( !pContact )
442 : {
443 : // #i52858# - method name changed
444 210 : pContact = new SwFlyDrawContact( (SwFlyFrmFmt*)GetFmt(),
445 210 : pIDDMA->GetOrCreateDrawModel() );
446 : }
447 : OSL_ENSURE( pContact, "InitDrawObj failed" );
448 : // OD 2004-03-22 #i26791#
449 328 : SetDrawObj( *(CreateNewRef( pContact )) );
450 :
451 : //Den richtigen Layer setzen.
452 : // OD 2004-01-19 #110582#
453 328 : SdrLayerID nHeavenId = pIDDMA->GetHeavenId();
454 328 : SdrLayerID nHellId = pIDDMA->GetHellId();
455 : // OD 2004-03-22 #i26791#
456 656 : GetVirtDrawObj()->SetLayer( GetFmt()->GetOpaque().GetValue()
457 : ? nHeavenId
458 656 : : nHellId );
459 328 : if ( bNotify )
460 0 : NotifyDrawObj();
461 328 : }
462 :
463 : /*************************************************************************
464 : |*
465 : |* SwFlyFrm::FinitDrawObj()
466 : |*
467 : |*************************************************************************/
468 :
469 328 : void SwFlyFrm::FinitDrawObj()
470 : {
471 328 : if ( !GetVirtDrawObj() )
472 328 : return;
473 :
474 : //Bei den SdrPageViews abmelden falls das Objekt dort noch selektiert ist.
475 328 : if ( !GetFmt()->GetDoc()->IsInDtor() )
476 : {
477 328 : ViewShell *p1St = getRootFrm()->GetCurrShell();
478 328 : if ( p1St )
479 : {
480 9 : ViewShell *pSh = p1St;
481 9 : do
482 : { //z.Zt. kann das Drawing nur ein Unmark auf alles, weil das
483 : //Objekt bereits Removed wurde.
484 9 : if( pSh->HasDrawView() )
485 9 : pSh->Imp()->GetDrawView()->UnmarkAll();
486 9 : pSh = (ViewShell*)pSh->GetNext();
487 :
488 : } while ( pSh != p1St );
489 : }
490 : }
491 :
492 : //VirtObject mit in das Grab nehmen. Wenn das letzte VirObject
493 : //zerstoert wird, mussen das DrawObject und DrawContact ebenfalls
494 : //zerstoert werden.
495 328 : SwFlyDrawContact *pMyContact = 0;
496 328 : if ( GetFmt() )
497 : {
498 328 : bool bContinue = true;
499 328 : SwIterator<SwFrm,SwFmt> aFrmIter( *GetFmt() );
500 656 : for ( SwFrm* pFrm = aFrmIter.First(); pFrm; pFrm = aFrmIter.Next() )
501 328 : if ( pFrm != this )
502 : {
503 : // don't delete Contact if there is still a Frm
504 0 : bContinue = false;
505 0 : break;
506 : }
507 :
508 328 : if ( bContinue )
509 : // no Frm left, find Contact object to destroy
510 328 : pMyContact = SwIterator<SwFlyDrawContact,SwFmt>::FirstElement( *GetFmt() );
511 : }
512 :
513 : // OD, OS 2004-03-31 #116203# - clear user call of Writer fly frame 'master'
514 : // <SdrObject> to assure, that a <SwXFrame::dispose()> doesn't delete the
515 : // Writer fly frame again.
516 328 : if ( pMyContact )
517 : {
518 328 : pMyContact->GetMaster()->SetUserCall( 0 );
519 : }
520 328 : GetVirtDrawObj()->SetUserCall( 0 ); //Ruft sonst Delete des ContactObj
521 328 : delete GetVirtDrawObj(); //Meldet sich selbst beim Master ab.
522 328 : delete pMyContact; //zerstoert den Master selbst.
523 : }
524 :
525 : /*************************************************************************
526 : |*
527 : |* SwFlyFrm::ChainFrames()
528 : |*
529 : |*************************************************************************/
530 :
531 0 : void SwFlyFrm::ChainFrames( SwFlyFrm *pMaster, SwFlyFrm *pFollow )
532 : {
533 : OSL_ENSURE( pMaster && pFollow, "uncomplete chain" );
534 : OSL_ENSURE( !pMaster->GetNextLink(), "link can not be changed" );
535 : OSL_ENSURE( !pFollow->GetPrevLink(), "link can not be changed" );
536 :
537 0 : pMaster->pNextLink = pFollow;
538 0 : pFollow->pPrevLink = pMaster;
539 :
540 0 : if ( pMaster->ContainsCntnt() )
541 : {
542 : //Damit ggf. ein Textfluss zustande kommt muss invalidiert werden.
543 0 : SwFrm *pInva = pMaster->FindLastLower();
544 0 : SWRECTFN( pMaster )
545 0 : const long nBottom = (pMaster->*fnRect->fnGetPrtBottom)();
546 0 : while ( pInva )
547 : {
548 0 : if( (pInva->Frm().*fnRect->fnBottomDist)( nBottom ) <= 0 )
549 : {
550 0 : pInva->InvalidateSize();
551 0 : pInva->Prepare( PREP_CLEAR );
552 0 : pInva = pInva->FindPrev();
553 : }
554 : else
555 0 : pInva = 0;
556 : }
557 : }
558 :
559 0 : if ( pFollow->ContainsCntnt() )
560 : {
561 : //Es gibt nur noch den Inhalt des Masters, der Inhalt vom Follow
562 : //hat keine Frames mehr (sollte immer nur genau ein leerer TxtNode sein).
563 0 : SwFrm *pFrm = pFollow->ContainsCntnt();
564 : OSL_ENSURE( !pFrm->IsTabFrm() && !pFrm->FindNext(), "follow in chain contains content" );
565 0 : pFrm->Cut();
566 0 : delete pFrm;
567 : }
568 :
569 : // invalidate accessible relation set (accessibility wrapper)
570 0 : ViewShell* pSh = pMaster->getRootFrm()->GetCurrShell();
571 0 : if( pSh )
572 : {
573 0 : SwRootFrm* pLayout = pMaster->getRootFrm();
574 0 : if( pLayout && pLayout->IsAnyShellAccessible() )
575 0 : pSh->Imp()->InvalidateAccessibleRelationSet( pMaster, pFollow );
576 : }
577 0 : }
578 :
579 0 : void SwFlyFrm::UnchainFrames( SwFlyFrm *pMaster, SwFlyFrm *pFollow )
580 : {
581 0 : pMaster->pNextLink = 0;
582 0 : pFollow->pPrevLink = 0;
583 :
584 0 : if ( pFollow->ContainsCntnt() )
585 : {
586 : //Der Master saugt den Inhalt vom Follow auf
587 0 : SwLayoutFrm *pUpper = pMaster;
588 0 : if ( pUpper->Lower()->IsColumnFrm() )
589 : {
590 0 : pUpper = static_cast<SwLayoutFrm*>(pUpper->GetLastLower());
591 0 : pUpper = static_cast<SwLayoutFrm*>(pUpper->Lower()); // der (Column)BodyFrm
592 : OSL_ENSURE( pUpper && pUpper->IsColBodyFrm(), "Missing ColumnBody" );
593 : }
594 0 : SwFlyFrm *pFoll = pFollow;
595 0 : while ( pFoll )
596 : {
597 0 : SwFrm *pTmp = ::SaveCntnt( pFoll );
598 0 : if ( pTmp )
599 0 : ::RestoreCntnt( pTmp, pUpper, pMaster->FindLastLower(), true );
600 0 : pFoll->SetCompletePaint();
601 0 : pFoll->InvalidateSize();
602 0 : pFoll = pFoll->GetNextLink();
603 : }
604 : }
605 :
606 : //Der Follow muss mit seinem eigenen Inhalt versorgt werden.
607 0 : const SwFmtCntnt &rCntnt = pFollow->GetFmt()->GetCntnt();
608 : OSL_ENSURE( rCntnt.GetCntntIdx(), ":-( Kein Inhalt vorbereitet." );
609 0 : sal_uLong nIndex = rCntnt.GetCntntIdx()->GetIndex();
610 : // Lower() bedeutet SwColumnFrm, dieser beinhaltet wieder einen SwBodyFrm
611 0 : ::_InsertCnt( pFollow->Lower() ? (SwLayoutFrm*)((SwLayoutFrm*)pFollow->Lower())->Lower()
612 : : (SwLayoutFrm*)pFollow,
613 0 : pFollow->GetFmt()->GetDoc(), ++nIndex );
614 :
615 : // invalidate accessible relation set (accessibility wrapper)
616 0 : ViewShell* pSh = pMaster->getRootFrm()->GetCurrShell();
617 0 : if( pSh )
618 : {
619 0 : SwRootFrm* pLayout = pMaster->getRootFrm();
620 0 : if( pLayout && pLayout->IsAnyShellAccessible() )
621 0 : pSh->Imp()->InvalidateAccessibleRelationSet( pMaster, pFollow );
622 : }
623 0 : }
624 :
625 : /*************************************************************************
626 : |*
627 : |* SwFlyFrm::FindChainNeighbour()
628 : |*
629 : |*************************************************************************/
630 :
631 0 : SwFlyFrm *SwFlyFrm::FindChainNeighbour( SwFrmFmt &rChain, SwFrm *pAnch )
632 : {
633 : //Wir suchen denjenigen Fly, der in dem selben Bereich steht.
634 : //Bereiche koennen zunaechst nur Kopf-/Fusszeilen oder Flys sein.
635 :
636 0 : if ( !pAnch ) //Wenn ein Anchor uebergeben Wurde zaehlt dieser: Ctor!
637 0 : pAnch = AnchorFrm();
638 :
639 : SwLayoutFrm *pLay;
640 0 : if ( pAnch->IsInFly() )
641 0 : pLay = pAnch->FindFlyFrm();
642 : else
643 : {
644 : //FindFooterOrHeader taugt hier nicht, weil evtl. noch keine Verbindung
645 : //zum Anker besteht.
646 0 : pLay = pAnch->GetUpper();
647 0 : while ( pLay && !(pLay->GetType() & (FRM_HEADER|FRM_FOOTER)) )
648 0 : pLay = pLay->GetUpper();
649 : }
650 :
651 0 : SwIterator<SwFlyFrm,SwFmt> aIter( rChain );
652 0 : SwFlyFrm *pFly = aIter.First();
653 0 : if ( pLay )
654 : {
655 0 : while ( pFly )
656 : {
657 0 : if ( pFly->GetAnchorFrm() )
658 : {
659 0 : if ( pFly->GetAnchorFrm()->IsInFly() )
660 : {
661 0 : if ( pFly->AnchorFrm()->FindFlyFrm() == pLay )
662 0 : break;
663 : }
664 0 : else if ( pLay == pFly->FindFooterOrHeader() )
665 0 : break;
666 : }
667 0 : pFly = aIter.Next();
668 : }
669 : }
670 : else if ( pFly )
671 : {
672 : OSL_ENSURE( !aIter.Next(), "chain with more than one inkarnation" );
673 : }
674 0 : return pFly;
675 : }
676 :
677 :
678 : /*************************************************************************
679 : |*
680 : |* SwFlyFrm::FindLastLower()
681 : |*
682 : |*************************************************************************/
683 :
684 0 : SwFrm *SwFlyFrm::FindLastLower()
685 : {
686 0 : SwFrm *pRet = ContainsAny();
687 0 : if ( pRet && pRet->IsInTab() )
688 0 : pRet = pRet->FindTabFrm();
689 0 : SwFrm *pNxt = pRet;
690 0 : while ( pNxt && IsAnLower( pNxt ) )
691 0 : { pRet = pNxt;
692 0 : pNxt = pNxt->FindNext();
693 : }
694 0 : return pRet;
695 : }
696 :
697 :
698 : /*************************************************************************
699 : |*
700 : |* SwFlyFrm::FrmSizeChg()
701 : |*
702 : |*************************************************************************/
703 :
704 18 : sal_Bool SwFlyFrm::FrmSizeChg( const SwFmtFrmSize &rFrmSize )
705 : {
706 18 : sal_Bool bRet = sal_False;
707 18 : SwTwips nDiffHeight = Frm().Height();
708 18 : if ( rFrmSize.GetHeightSizeType() == ATT_VAR_SIZE )
709 16 : mbFixSize = bMinHeight = sal_False;
710 : else
711 : {
712 2 : if ( rFrmSize.GetHeightSizeType() == ATT_FIX_SIZE )
713 : {
714 1 : mbFixSize = sal_True;
715 1 : bMinHeight = sal_False;
716 : }
717 1 : else if ( rFrmSize.GetHeightSizeType() == ATT_MIN_SIZE )
718 : {
719 1 : mbFixSize = sal_False;
720 1 : bMinHeight = sal_True;
721 : }
722 2 : nDiffHeight -= rFrmSize.GetHeight();
723 : }
724 : //Wenn der Fly Spalten enthaehlt muessen der Fly und
725 : //die Spalten schon einmal auf die Wunschwerte gebracht
726 : //werden, sonst haben wir ein kleines Problem.
727 18 : if ( Lower() )
728 : {
729 18 : if ( Lower()->IsColumnFrm() )
730 : {
731 0 : const SwRect aOld( GetObjRectWithSpaces() );
732 0 : const Size aOldSz( Prt().SSize() );
733 0 : const SwTwips nDiffWidth = Frm().Width() - rFrmSize.GetWidth();
734 0 : maFrm.Height( maFrm.Height() - nDiffHeight );
735 0 : maFrm.Width ( maFrm.Width() - nDiffWidth );
736 : // #i68520#
737 0 : InvalidateObjRectWithSpaces();
738 0 : maPrt.Height( maPrt.Height() - nDiffHeight );
739 0 : maPrt.Width ( maPrt.Width() - nDiffWidth );
740 0 : ChgLowersProp( aOldSz );
741 0 : ::Notify( this, FindPageFrm(), aOld );
742 0 : mbValidPos = sal_False;
743 0 : bRet = sal_True;
744 : }
745 18 : else if ( Lower()->IsNoTxtFrm() )
746 : {
747 11 : mbFixSize = sal_True;
748 11 : bMinHeight = sal_False;
749 : }
750 : }
751 18 : return bRet;
752 : }
753 :
754 : /*************************************************************************
755 : |*
756 : |* SwFlyFrm::Modify()
757 : |*
758 : |*************************************************************************/
759 :
760 77 : void SwFlyFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
761 : {
762 77 : sal_uInt8 nInvFlags = 0;
763 :
764 77 : if( pNew && RES_ATTRSET_CHG == pNew->Which() )
765 : {
766 33 : SfxItemIter aNIter( *((SwAttrSetChg*)pNew)->GetChgSet() );
767 66 : SfxItemIter aOIter( *((SwAttrSetChg*)pOld)->GetChgSet() );
768 66 : SwAttrSetChg aOldSet( *(SwAttrSetChg*)pOld );
769 66 : SwAttrSetChg aNewSet( *(SwAttrSetChg*)pNew );
770 : while( true )
771 : {
772 : _UpdateAttr( (SfxPoolItem*)aOIter.GetCurItem(),
773 : (SfxPoolItem*)aNIter.GetCurItem(), nInvFlags,
774 33 : &aOldSet, &aNewSet );
775 33 : if( aNIter.IsAtEnd() )
776 33 : break;
777 0 : aNIter.NextItem();
778 0 : aOIter.NextItem();
779 : }
780 33 : if ( aOldSet.Count() || aNewSet.Count() )
781 35 : SwLayoutFrm::Modify( &aOldSet, &aNewSet );
782 : }
783 : else
784 44 : _UpdateAttr( pOld, pNew, nInvFlags );
785 :
786 77 : if ( nInvFlags != 0 )
787 : {
788 31 : _Invalidate();
789 31 : if ( nInvFlags & 0x01 )
790 : {
791 31 : _InvalidatePos();
792 : // #i68520#
793 31 : InvalidateObjRectWithSpaces();
794 : }
795 31 : if ( nInvFlags & 0x02 )
796 : {
797 18 : _InvalidateSize();
798 : // #i68520#
799 18 : InvalidateObjRectWithSpaces();
800 : }
801 31 : if ( nInvFlags & 0x04 )
802 18 : _InvalidatePrt();
803 31 : if ( nInvFlags & 0x08 )
804 28 : SetNotifyBack();
805 31 : if ( nInvFlags & 0x10 )
806 18 : SetCompletePaint();
807 31 : if ( ( nInvFlags & 0x40 ) && Lower() && Lower()->IsNoTxtFrm() )
808 14 : ClrContourCache( GetVirtDrawObj() );
809 : SwRootFrm *pRoot;
810 31 : if ( nInvFlags & 0x20 && 0 != (pRoot = getRootFrm()) )
811 18 : pRoot->InvalidateBrowseWidth();
812 : // #i28701#
813 31 : if ( nInvFlags & 0x80 )
814 : {
815 : // update sorted object lists, the Writer fly frame is registered at.
816 21 : UpdateObjInSortedList();
817 : }
818 :
819 : // #i87645# - reset flags for the layout process (only if something has been invalidated)
820 31 : ResetLayoutProcessBools();
821 : }
822 77 : }
823 :
824 77 : void SwFlyFrm::_UpdateAttr( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
825 : sal_uInt8 &rInvFlags,
826 : SwAttrSetChg *pOldSet, SwAttrSetChg *pNewSet )
827 : {
828 77 : bool bClear = true;
829 77 : const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
830 77 : ViewShell *pSh = getRootFrm()->GetCurrShell();
831 77 : switch( nWhich )
832 : {
833 : case RES_VERT_ORIENT:
834 : case RES_HORI_ORIENT:
835 : // OD 22.09.2003 #i18732# - consider new option 'follow text flow'
836 : case RES_FOLLOW_TEXT_FLOW:
837 : {
838 : //Achtung! _immer_ Aktion in ChgRePos() mitpflegen.
839 10 : rInvFlags |= 0x09;
840 : }
841 10 : break;
842 : // OD 2004-07-01 #i28701# - consider new option 'wrap influence on position'
843 : case RES_WRAP_INFLUENCE_ON_OBJPOS:
844 : {
845 0 : rInvFlags |= 0x89;
846 : }
847 0 : break;
848 : case RES_SURROUND:
849 : {
850 : // OD 2004-05-13 #i28701# - invalidate position on change of
851 : // wrapping style.
852 : //rInvFlags |= 0x40;
853 3 : rInvFlags |= 0x41;
854 : //Der Hintergrund muss benachrichtigt und Invalidiert werden.
855 3 : const SwRect aTmp( GetObjRectWithSpaces() );
856 3 : NotifyBackground( FindPageFrm(), aTmp, PREP_FLY_ATTR_CHG );
857 :
858 : // Durch eine Umlaufaenderung von rahmengebundenen Rahmen kann eine
859 : // vertikale Ausrichtung aktiviert/deaktiviert werden => MakeFlyPos
860 3 : if( FLY_AT_FLY == GetFmt()->GetAnchor().GetAnchorId() )
861 0 : rInvFlags |= 0x09;
862 :
863 : //Ggf. die Kontur am Node loeschen.
864 6 : if ( Lower() && Lower()->IsNoTxtFrm() &&
865 3 : !GetFmt()->GetSurround().IsContour() )
866 : {
867 1 : SwNoTxtNode *pNd = (SwNoTxtNode*)((SwCntntFrm*)Lower())->GetNode();
868 1 : if ( pNd->HasContour() )
869 0 : pNd->SetContour( 0 );
870 : }
871 : // #i28701# - perform reorder of object lists
872 : // at anchor frame and at page frame.
873 3 : rInvFlags |= 0x80;
874 : }
875 3 : break;
876 :
877 : case RES_PROTECT:
878 : {
879 1 : const SvxProtectItem *pP = (SvxProtectItem*)pNew;
880 1 : GetVirtDrawObj()->SetMoveProtect( pP->IsPosProtected() );
881 1 : GetVirtDrawObj()->SetResizeProtect( pP->IsSizeProtected() );
882 1 : if( pSh )
883 : {
884 1 : SwRootFrm* pLayout = getRootFrm();
885 1 : if( pLayout && pLayout->IsAnyShellAccessible() )
886 0 : pSh->Imp()->InvalidateAccessibleEditableState( sal_True, this );
887 : }
888 1 : break;
889 : }
890 :
891 : case RES_COL:
892 : {
893 0 : ChgColumns( *(const SwFmtCol*)pOld, *(const SwFmtCol*)pNew );
894 0 : const SwFmtFrmSize &rNew = GetFmt()->GetFrmSize();
895 0 : if ( FrmSizeChg( rNew ) )
896 0 : NotifyDrawObj();
897 0 : rInvFlags |= 0x1A;
898 0 : break;
899 : }
900 :
901 : case RES_FRM_SIZE:
902 : case RES_FMT_CHG:
903 : {
904 18 : const SwFmtFrmSize &rNew = GetFmt()->GetFrmSize();
905 18 : if ( FrmSizeChg( rNew ) )
906 0 : NotifyDrawObj();
907 18 : rInvFlags |= 0x7F;
908 18 : if ( RES_FMT_CHG == nWhich )
909 : {
910 3 : SwRect aNew( GetObjRectWithSpaces() );
911 3 : SwRect aOld( maFrm );
912 3 : const SvxULSpaceItem &rUL = ((SwFmtChg*)pOld)->pChangedFmt->GetULSpace();
913 3 : aOld.Top( std::max( aOld.Top() - long(rUL.GetUpper()), 0L ) );
914 3 : aOld.SSize().Height()+= rUL.GetLower();
915 3 : const SvxLRSpaceItem &rLR = ((SwFmtChg*)pOld)->pChangedFmt->GetLRSpace();
916 3 : aOld.Left ( std::max( aOld.Left() - long(rLR.GetLeft()), 0L ) );
917 3 : aOld.SSize().Width() += rLR.GetRight();
918 3 : aNew.Union( aOld );
919 3 : NotifyBackground( FindPageFrm(), aNew, PREP_CLEAR );
920 :
921 : //Dummer Fall. Bei der Zusweisung einer Vorlage k?nnen wir uns
922 : //nicht auf das alte Spaltenattribut verlassen. Da diese
923 : //wenigstens anzahlgemass fuer ChgColumns vorliegen muessen,
924 : //bleibt uns nur einen temporaeres Attribut zu basteln.
925 3 : SwFmtCol aCol;
926 3 : if ( Lower() && Lower()->IsColumnFrm() )
927 : {
928 0 : sal_uInt16 nCol = 0;
929 0 : SwFrm *pTmp = Lower();
930 0 : do
931 0 : { ++nCol;
932 0 : pTmp = pTmp->GetNext();
933 : } while ( pTmp );
934 0 : aCol.Init( nCol, 0, 1000 );
935 : }
936 3 : ChgColumns( aCol, GetFmt()->GetCol() );
937 : }
938 :
939 18 : SwFmtURL aURL( GetFmt()->GetURL() );
940 18 : if ( aURL.GetMap() )
941 : {
942 : const SwFmtFrmSize &rOld = nWhich == RES_FRM_SIZE ?
943 : *(SwFmtFrmSize*)pNew :
944 1 : ((SwFmtChg*)pOld)->pChangedFmt->GetFrmSize();
945 : //#35091# Kann beim Laden von Vorlagen mal 0 sein
946 1 : if ( rOld.GetWidth() && rOld.GetHeight() )
947 : {
948 :
949 1 : Fraction aScaleX( rOld.GetWidth(), rNew.GetWidth() );
950 1 : Fraction aScaleY( rOld.GetHeight(), rOld.GetHeight() );
951 1 : aURL.GetMap()->Scale( aScaleX, aScaleY );
952 1 : SwFrmFmt *pFmt = GetFmt();
953 1 : pFmt->LockModify();
954 1 : pFmt->SetFmtAttr( aURL );
955 1 : pFmt->UnlockModify();
956 : }
957 : }
958 18 : const SvxProtectItem &rP = GetFmt()->GetProtect();
959 18 : GetVirtDrawObj()->SetMoveProtect( rP.IsPosProtected() );
960 18 : GetVirtDrawObj()->SetResizeProtect( rP.IsSizeProtected() );
961 :
962 18 : if ( pSh )
963 18 : pSh->InvalidateWindows( Frm() );
964 18 : const IDocumentDrawModelAccess* pIDDMA = GetFmt()->getIDocumentDrawModelAccess();
965 18 : const sal_uInt8 nId = GetFmt()->GetOpaque().GetValue() ?
966 18 : pIDDMA->GetHeavenId() :
967 36 : pIDDMA->GetHellId();
968 18 : GetVirtDrawObj()->SetLayer( nId );
969 :
970 18 : if ( Lower() )
971 : {
972 : //Ggf. die Kontur am Node loeschen.
973 29 : if( Lower()->IsNoTxtFrm() &&
974 11 : !GetFmt()->GetSurround().IsContour() )
975 : {
976 10 : SwNoTxtNode *pNd = (SwNoTxtNode*)((SwCntntFrm*)Lower())->GetNode();
977 10 : if ( pNd->HasContour() )
978 0 : pNd->SetContour( 0 );
979 : }
980 8 : else if( !Lower()->IsColumnFrm() )
981 : {
982 8 : SwFrm* pFrm = GetLastLower();
983 8 : if( pFrm->IsTxtFrm() && ((SwTxtFrm*)pFrm)->IsUndersized() )
984 0 : pFrm->Prepare( PREP_ADJUST_FRM );
985 : }
986 : }
987 :
988 : // #i28701# - perform reorder of object lists
989 : // at anchor frame and at page frame.
990 18 : rInvFlags |= 0x80;
991 :
992 18 : break;
993 : }
994 : case RES_UL_SPACE:
995 : case RES_LR_SPACE:
996 : {
997 0 : rInvFlags |= 0x41;
998 0 : if( pSh && pSh->GetViewOptions()->getBrowseMode() )
999 0 : getRootFrm()->InvalidateBrowseWidth();
1000 0 : SwRect aNew( GetObjRectWithSpaces() );
1001 0 : SwRect aOld( maFrm );
1002 0 : if ( RES_UL_SPACE == nWhich )
1003 : {
1004 0 : const SvxULSpaceItem &rUL = *(SvxULSpaceItem*)pNew;
1005 0 : aOld.Top( std::max( aOld.Top() - long(rUL.GetUpper()), 0L ) );
1006 0 : aOld.SSize().Height()+= rUL.GetLower();
1007 : }
1008 : else
1009 : {
1010 0 : const SvxLRSpaceItem &rLR = *(SvxLRSpaceItem*)pNew;
1011 0 : aOld.Left ( std::max( aOld.Left() - long(rLR.GetLeft()), 0L ) );
1012 0 : aOld.SSize().Width() += rLR.GetRight();
1013 : }
1014 0 : aNew.Union( aOld );
1015 0 : NotifyBackground( FindPageFrm(), aNew, PREP_CLEAR );
1016 : }
1017 0 : break;
1018 :
1019 : case RES_BOX:
1020 : case RES_SHADOW:
1021 0 : rInvFlags |= 0x17;
1022 0 : break;
1023 :
1024 : case RES_FRAMEDIR :
1025 1 : SetDerivedVert( sal_False );
1026 1 : SetDerivedR2L( sal_False );
1027 1 : CheckDirChange();
1028 1 : break;
1029 :
1030 : case RES_OPAQUE:
1031 : {
1032 0 : if ( pSh )
1033 0 : pSh->InvalidateWindows( Frm() );
1034 :
1035 0 : const IDocumentDrawModelAccess* pIDDMA = GetFmt()->getIDocumentDrawModelAccess();
1036 0 : const sal_uInt8 nId = ((SvxOpaqueItem*)pNew)->GetValue() ?
1037 0 : pIDDMA->GetHeavenId() :
1038 0 : pIDDMA->GetHellId();
1039 0 : GetVirtDrawObj()->SetLayer( nId );
1040 0 : if( pSh )
1041 : {
1042 0 : SwRootFrm* pLayout = getRootFrm();
1043 0 : if( pLayout && pLayout->IsAnyShellAccessible() )
1044 : {
1045 0 : pSh->Imp()->DisposeAccessibleFrm( this );
1046 0 : pSh->Imp()->AddAccessibleFrm( this );
1047 : }
1048 : }
1049 : // #i28701# - perform reorder of object lists
1050 : // at anchor frame and at page frame.
1051 0 : rInvFlags |= 0x80;
1052 : }
1053 0 : break;
1054 :
1055 : case RES_URL:
1056 : //Das Interface arbeitet bei Textrahmen auf der Rahmengroesse,
1057 : //die Map muss sich aber auf die FrmSize beziehen
1058 3 : if ( (!Lower() || !Lower()->IsNoTxtFrm()) &&
1059 1 : ((SwFmtURL*)pNew)->GetMap() && ((SwFmtURL*)pOld)->GetMap() )
1060 : {
1061 0 : const SwFmtFrmSize &rSz = GetFmt()->GetFrmSize();
1062 0 : if ( rSz.GetHeight() != Frm().Height() ||
1063 0 : rSz.GetWidth() != Frm().Width() )
1064 : {
1065 0 : SwFmtURL aURL( GetFmt()->GetURL() );
1066 0 : Fraction aScaleX( Frm().Width(), rSz.GetWidth() );
1067 0 : Fraction aScaleY( Frm().Height(), rSz.GetHeight() );
1068 0 : aURL.GetMap()->Scale( aScaleX, aScaleY );
1069 0 : SwFrmFmt *pFmt = GetFmt();
1070 0 : pFmt->LockModify();
1071 0 : pFmt->SetFmtAttr( aURL );
1072 0 : pFmt->UnlockModify();
1073 : }
1074 : }
1075 : /* Keine Invalidierung notwendig */
1076 1 : break;
1077 :
1078 : case RES_CHAIN:
1079 : {
1080 0 : SwFmtChain *pChain = (SwFmtChain*)pNew;
1081 0 : if ( pChain->GetNext() )
1082 : {
1083 0 : SwFlyFrm *pFollow = FindChainNeighbour( *pChain->GetNext() );
1084 0 : if ( GetNextLink() && pFollow != GetNextLink() )
1085 0 : SwFlyFrm::UnchainFrames( this, GetNextLink());
1086 0 : if ( pFollow )
1087 : {
1088 0 : if ( pFollow->GetPrevLink() &&
1089 0 : pFollow->GetPrevLink() != this )
1090 : SwFlyFrm::UnchainFrames( pFollow->GetPrevLink(),
1091 0 : pFollow );
1092 0 : if ( !GetNextLink() )
1093 0 : SwFlyFrm::ChainFrames( this, pFollow );
1094 : }
1095 : }
1096 0 : else if ( GetNextLink() )
1097 0 : SwFlyFrm::UnchainFrames( this, GetNextLink() );
1098 0 : if ( pChain->GetPrev() )
1099 : {
1100 0 : SwFlyFrm *pMaster = FindChainNeighbour( *pChain->GetPrev() );
1101 0 : if ( GetPrevLink() && pMaster != GetPrevLink() )
1102 0 : SwFlyFrm::UnchainFrames( GetPrevLink(), this );
1103 0 : if ( pMaster )
1104 : {
1105 0 : if ( pMaster->GetNextLink() &&
1106 0 : pMaster->GetNextLink() != this )
1107 : SwFlyFrm::UnchainFrames( pMaster,
1108 0 : pMaster->GetNextLink() );
1109 0 : if ( !GetPrevLink() )
1110 0 : SwFlyFrm::ChainFrames( pMaster, this );
1111 : }
1112 : }
1113 0 : else if ( GetPrevLink() )
1114 0 : SwFlyFrm::UnchainFrames( GetPrevLink(), this );
1115 : }
1116 :
1117 : default:
1118 43 : bClear = false;
1119 : }
1120 77 : if ( bClear )
1121 : {
1122 34 : if ( pOldSet || pNewSet )
1123 : {
1124 31 : if ( pOldSet )
1125 31 : pOldSet->ClearItem( nWhich );
1126 62 : if ( pNewSet )
1127 31 : pNewSet->ClearItem( nWhich );
1128 : }
1129 : else
1130 3 : SwLayoutFrm::Modify( pOld, pNew );
1131 : }
1132 77 : }
1133 :
1134 : /*************************************************************************
1135 : |*
1136 : |* SwFlyFrm::GetInfo()
1137 : |*
1138 : |* Beschreibung erfragt Informationen
1139 : |*
1140 : *************************************************************************/
1141 :
1142 : // erfrage vom Modify Informationen
1143 27 : bool SwFlyFrm::GetInfo( SfxPoolItem & rInfo ) const
1144 : {
1145 27 : if( RES_AUTOFMT_DOCNODE == rInfo.Which() )
1146 27 : return false; // es gibt einen FlyFrm also wird er benutzt
1147 0 : return true; // weiter suchen
1148 : }
1149 :
1150 : /*************************************************************************
1151 : |*
1152 : |* SwFlyFrm::_Invalidate()
1153 : |*
1154 : |*************************************************************************/
1155 :
1156 579 : void SwFlyFrm::_Invalidate( SwPageFrm *pPage )
1157 : {
1158 579 : InvalidatePage( pPage );
1159 579 : bNotifyBack = bInvalid = sal_True;
1160 :
1161 : SwFlyFrm *pFrm;
1162 579 : if ( GetAnchorFrm() && 0 != (pFrm = AnchorFrm()->FindFlyFrm()) )
1163 : {
1164 : //Gaanz dumm: Wenn der Fly innerhalb eines Fly gebunden ist, der
1165 : //Spalten enthaehlt, sollte das Format von diesem ausgehen.
1166 0 : if ( !pFrm->IsLocked() && !pFrm->IsColLocked() &&
1167 0 : pFrm->Lower() && pFrm->Lower()->IsColumnFrm() )
1168 0 : pFrm->InvalidateSize();
1169 : }
1170 :
1171 : // #i85216#
1172 : // if vertical position is oriented at a layout frame inside a ghost section,
1173 : // assure that the position is invalidated and that the information about
1174 : // the vertical position oriented frame is cleared
1175 579 : if ( GetVertPosOrientFrm() && GetVertPosOrientFrm()->IsLayoutFrm() )
1176 : {
1177 115 : const SwSectionFrm* pSectFrm( GetVertPosOrientFrm()->FindSctFrm() );
1178 115 : if ( pSectFrm && pSectFrm->GetSection() == 0 )
1179 : {
1180 0 : InvalidatePos();
1181 0 : ClearVertPosOrientFrm();
1182 : }
1183 : }
1184 579 : }
1185 :
1186 : /*************************************************************************
1187 : |*
1188 : |* SwFlyFrm::ChgRelPos()
1189 : |*
1190 : |* Beschreibung Aenderung der relativen Position, die Position wird
1191 : |* damit automatisch Fix, das Attribut wird entprechend angepasst.
1192 : |*
1193 : |*************************************************************************/
1194 :
1195 0 : void SwFlyFrm::ChgRelPos( const Point &rNewPos )
1196 : {
1197 0 : if ( GetCurrRelPos() != rNewPos )
1198 : {
1199 0 : SwFrmFmt *pFmt = GetFmt();
1200 0 : const bool bVert = GetAnchorFrm()->IsVertical();
1201 0 : const SwTwips nNewY = bVert ? rNewPos.X() : rNewPos.Y();
1202 0 : SwTwips nTmpY = nNewY == LONG_MAX ? 0 : nNewY;
1203 0 : if( bVert )
1204 0 : nTmpY = -nTmpY;
1205 0 : SfxItemSet aSet( pFmt->GetDoc()->GetAttrPool(),
1206 0 : RES_VERT_ORIENT, RES_HORI_ORIENT);
1207 :
1208 0 : SwFmtVertOrient aVert( pFmt->GetVertOrient() );
1209 0 : SwTxtFrm *pAutoFrm = NULL;
1210 : // #i34948# - handle also at-page and at-fly anchored
1211 : // Writer fly frames
1212 0 : const RndStdIds eAnchorType = GetFrmFmt().GetAnchor().GetAnchorId();
1213 0 : if ( eAnchorType == FLY_AT_PAGE )
1214 : {
1215 0 : aVert.SetVertOrient( text::VertOrientation::NONE );
1216 0 : aVert.SetRelationOrient( text::RelOrientation::PAGE_FRAME );
1217 : }
1218 0 : else if ( eAnchorType == FLY_AT_FLY )
1219 : {
1220 0 : aVert.SetVertOrient( text::VertOrientation::NONE );
1221 0 : aVert.SetRelationOrient( text::RelOrientation::FRAME );
1222 : }
1223 0 : else if ( IsFlyAtCntFrm() || text::VertOrientation::NONE != aVert.GetVertOrient() )
1224 : {
1225 0 : if( text::RelOrientation::CHAR == aVert.GetRelationOrient() && IsAutoPos() )
1226 : {
1227 0 : if( LONG_MAX != nNewY )
1228 : {
1229 0 : aVert.SetVertOrient( text::VertOrientation::NONE );
1230 : xub_StrLen nOfs =
1231 0 : pFmt->GetAnchor().GetCntntAnchor()->nContent.GetIndex();
1232 : OSL_ENSURE( GetAnchorFrm()->IsTxtFrm(), "TxtFrm expected" );
1233 0 : pAutoFrm = (SwTxtFrm*)GetAnchorFrm();
1234 0 : while( pAutoFrm->GetFollow() &&
1235 0 : pAutoFrm->GetFollow()->GetOfst() <= nOfs )
1236 : {
1237 0 : if( pAutoFrm == GetAnchorFrm() )
1238 0 : nTmpY += pAutoFrm->GetRelPos().Y();
1239 0 : nTmpY -= pAutoFrm->GetUpper()->Prt().Height();
1240 0 : pAutoFrm = pAutoFrm->GetFollow();
1241 : }
1242 0 : nTmpY = ((SwFlyAtCntFrm*)this)->GetRelCharY(pAutoFrm)-nTmpY;
1243 : }
1244 : else
1245 0 : aVert.SetVertOrient( text::VertOrientation::CHAR_BOTTOM );
1246 : }
1247 : else
1248 : {
1249 0 : aVert.SetVertOrient( text::VertOrientation::NONE );
1250 0 : aVert.SetRelationOrient( text::RelOrientation::FRAME );
1251 : }
1252 : }
1253 0 : aVert.SetPos( nTmpY );
1254 0 : aSet.Put( aVert );
1255 :
1256 : //Fuer Flys im Cnt ist die horizontale Ausrichtung uninteressant,
1257 : //den sie ist stets 0.
1258 0 : if ( !IsFlyInCntFrm() )
1259 : {
1260 0 : const SwTwips nNewX = bVert ? rNewPos.Y() : rNewPos.X();
1261 0 : SwTwips nTmpX = nNewX == LONG_MAX ? 0 : nNewX;
1262 0 : SwFmtHoriOrient aHori( pFmt->GetHoriOrient() );
1263 : // #i34948# - handle also at-page and at-fly anchored
1264 : // Writer fly frames
1265 0 : if ( eAnchorType == FLY_AT_PAGE )
1266 : {
1267 0 : aHori.SetHoriOrient( text::HoriOrientation::NONE );
1268 0 : aHori.SetRelationOrient( text::RelOrientation::PAGE_FRAME );
1269 0 : aHori.SetPosToggle( sal_False );
1270 : }
1271 0 : else if ( eAnchorType == FLY_AT_FLY )
1272 : {
1273 0 : aHori.SetHoriOrient( text::HoriOrientation::NONE );
1274 0 : aHori.SetRelationOrient( text::RelOrientation::FRAME );
1275 0 : aHori.SetPosToggle( sal_False );
1276 : }
1277 0 : else if ( IsFlyAtCntFrm() || text::HoriOrientation::NONE != aHori.GetHoriOrient() )
1278 : {
1279 0 : aHori.SetHoriOrient( text::HoriOrientation::NONE );
1280 0 : if( text::RelOrientation::CHAR == aHori.GetRelationOrient() && IsAutoPos() )
1281 : {
1282 0 : if( LONG_MAX != nNewX )
1283 : {
1284 0 : if( !pAutoFrm )
1285 : {
1286 0 : xub_StrLen nOfs = pFmt->GetAnchor().GetCntntAnchor()
1287 0 : ->nContent.GetIndex();
1288 : OSL_ENSURE( GetAnchorFrm()->IsTxtFrm(), "TxtFrm expected");
1289 0 : pAutoFrm = (SwTxtFrm*)GetAnchorFrm();
1290 0 : while( pAutoFrm->GetFollow() &&
1291 0 : pAutoFrm->GetFollow()->GetOfst() <= nOfs )
1292 0 : pAutoFrm = pAutoFrm->GetFollow();
1293 : }
1294 0 : nTmpX -= ((SwFlyAtCntFrm*)this)->GetRelCharX(pAutoFrm);
1295 : }
1296 : }
1297 : else
1298 0 : aHori.SetRelationOrient( text::RelOrientation::FRAME );
1299 0 : aHori.SetPosToggle( sal_False );
1300 : }
1301 0 : aHori.SetPos( nTmpX );
1302 0 : aSet.Put( aHori );
1303 : }
1304 0 : SetCurrRelPos( rNewPos );
1305 0 : pFmt->GetDoc()->SetAttr( aSet, *pFmt );
1306 : }
1307 0 : }
1308 : /*************************************************************************
1309 : |*
1310 : |* SwFlyFrm::Format()
1311 : |*
1312 : |* Beschreibung: "Formatiert" den Frame; Frm und PrtArea.
1313 : |* Die Fixsize wird hier nicht eingestellt.
1314 : |*
1315 : |*************************************************************************/
1316 :
1317 870 : void SwFlyFrm::Format( const SwBorderAttrs *pAttrs )
1318 : {
1319 : OSL_ENSURE( pAttrs, "FlyFrm::Format, pAttrs ist 0." );
1320 :
1321 870 : ColLock();
1322 :
1323 870 : if ( !mbValidSize )
1324 : {
1325 870 : if ( Frm().Top() == FAR_AWAY && Frm().Left() == FAR_AWAY )
1326 : {
1327 : //Sicherheitsschaltung wegnehmen (siehe SwFrm::CTor)
1328 312 : Frm().Pos().setX(0);
1329 312 : Frm().Pos().setY(0);
1330 : // #i68520#
1331 312 : InvalidateObjRectWithSpaces();
1332 : }
1333 :
1334 : //Breite der Spalten pruefen und ggf. einstellen.
1335 870 : if ( Lower() && Lower()->IsColumnFrm() )
1336 0 : AdjustColumns( 0, sal_False );
1337 :
1338 870 : mbValidSize = sal_True;
1339 :
1340 870 : const SwTwips nUL = pAttrs->CalcTopLine() + pAttrs->CalcBottomLine();
1341 870 : const SwTwips nLR = pAttrs->CalcLeftLine() + pAttrs->CalcRightLine();
1342 870 : const SwFmtFrmSize &rFrmSz = GetFmt()->GetFrmSize();
1343 870 : Size aRelSize( CalcRel( rFrmSz ) );
1344 :
1345 : OSL_ENSURE( pAttrs->GetSize().Height() != 0 || rFrmSz.GetHeightPercent(), "Hoehe des RahmenAttr ist 0." );
1346 : OSL_ENSURE( pAttrs->GetSize().Width() != 0 || rFrmSz.GetWidthPercent(), "Breite des RahmenAttr ist 0." );
1347 :
1348 870 : SWRECTFN( this )
1349 870 : if( !HasFixSize() )
1350 : {
1351 341 : SwTwips nRemaining = 0;
1352 :
1353 341 : long nMinHeight = 0;
1354 341 : if( IsMinHeight() )
1355 42 : nMinHeight = bVert ? aRelSize.Width() : aRelSize.Height();
1356 :
1357 341 : if ( Lower() )
1358 : {
1359 341 : if ( Lower()->IsColumnFrm() )
1360 : {
1361 0 : FormatWidthCols( *pAttrs, nUL, nMinHeight );
1362 0 : nRemaining = (Lower()->Frm().*fnRect->fnGetHeight)();
1363 : }
1364 : else
1365 : {
1366 341 : SwFrm *pFrm = Lower();
1367 1100 : while ( pFrm )
1368 : {
1369 418 : nRemaining += (pFrm->Frm().*fnRect->fnGetHeight)();
1370 418 : if( pFrm->IsTxtFrm() && ((SwTxtFrm*)pFrm)->IsUndersized() )
1371 : // Dieser TxtFrm waere gern ein bisschen groesser
1372 11 : nRemaining += ((SwTxtFrm*)pFrm)->GetParHeight()
1373 11 : - (pFrm->Prt().*fnRect->fnGetHeight)();
1374 407 : else if( pFrm->IsSctFrm() && ((SwSectionFrm*)pFrm)->IsUndersized() )
1375 0 : nRemaining += ((SwSectionFrm*)pFrm)->Undersize();
1376 418 : pFrm = pFrm->GetNext();
1377 : }
1378 : // #130878#
1379 : // Do not keep old height, if content has no height.
1380 : // The old height could be wrong due to wrong layout cache
1381 : // and isn't corrected in the further formatting, because
1382 : // the fly frame doesn't become invalid anymore.
1383 : // if( !nRemaining )
1384 : // nRemaining = nOldHeight - nUL;
1385 : }
1386 341 : if ( GetDrawObjs() )
1387 : {
1388 0 : sal_uInt32 nCnt = GetDrawObjs()->Count();
1389 0 : SwTwips nTop = (Frm().*fnRect->fnGetTop)();
1390 0 : SwTwips nBorder = (Frm().*fnRect->fnGetHeight)() -
1391 0 : (Prt().*fnRect->fnGetHeight)();
1392 0 : for ( sal_uInt16 i = 0; i < nCnt; ++i )
1393 : {
1394 0 : SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[i];
1395 0 : if ( pAnchoredObj->ISA(SwFlyFrm) )
1396 : {
1397 0 : SwFlyFrm* pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
1398 : // OD 06.11.2003 #i22305# - consider
1399 : // only Writer fly frames, which follow the text flow.
1400 0 : if ( pFly->IsFlyLayFrm() &&
1401 0 : pFly->Frm().Top() != FAR_AWAY &&
1402 0 : pFly->GetFmt()->GetFollowTextFlow().GetValue() )
1403 : {
1404 0 : SwTwips nDist = -(pFly->Frm().*fnRect->
1405 0 : fnBottomDist)( nTop );
1406 0 : if( nDist > nBorder + nRemaining )
1407 0 : nRemaining = nDist - nBorder;
1408 : }
1409 : }
1410 : }
1411 : }
1412 : }
1413 :
1414 341 : if( IsMinHeight() && (nRemaining + nUL) < nMinHeight )
1415 29 : nRemaining = nMinHeight - nUL;
1416 : //Weil das Grow/Shrink der Flys die Groessen nicht direkt
1417 : //einstellt, sondern indirekt per Invalidate ein Format
1418 : //ausloesst, muessen die Groessen hier direkt eingestellt
1419 : //werden. Benachrichtung laeuft bereits mit.
1420 : //Weil bereits haeufiger 0en per Attribut hereinkamen wehre
1421 : //ich mich ab sofort dagegen.
1422 341 : if ( nRemaining < MINFLY )
1423 92 : nRemaining = MINFLY;
1424 341 : (Prt().*fnRect->fnSetHeight)( nRemaining );
1425 341 : nRemaining -= (Frm().*fnRect->fnGetHeight)();
1426 341 : (Frm().*fnRect->fnAddBottom)( nRemaining + nUL );
1427 : // #i68520#
1428 341 : if ( nRemaining + nUL != 0 )
1429 : {
1430 177 : InvalidateObjRectWithSpaces();
1431 : }
1432 341 : mbValidSize = sal_True;
1433 : }
1434 : else
1435 : {
1436 529 : mbValidSize = sal_True; //Fixe Frms formatieren sich nicht.
1437 : //Flys stellen ihre Groesse anhand des Attr ein.
1438 529 : SwTwips nNewSize = bVert ? aRelSize.Width() : aRelSize.Height();
1439 529 : nNewSize -= nUL;
1440 529 : if( nNewSize < MINFLY )
1441 2 : nNewSize = MINFLY;
1442 529 : (Prt().*fnRect->fnSetHeight)( nNewSize );
1443 529 : nNewSize += nUL - (Frm().*fnRect->fnGetHeight)();
1444 529 : (Frm().*fnRect->fnAddBottom)( nNewSize );
1445 : // #i68520#
1446 529 : if ( nNewSize != 0 )
1447 : {
1448 196 : InvalidateObjRectWithSpaces();
1449 : }
1450 : }
1451 :
1452 870 : if ( !bFormatHeightOnly )
1453 : {
1454 : OSL_ENSURE( aRelSize == CalcRel( rFrmSz ), "SwFlyFrm::Format CalcRel problem" );
1455 870 : SwTwips nNewSize = bVert ? aRelSize.Height() : aRelSize.Width();
1456 :
1457 870 : if ( rFrmSz.GetWidthSizeType() != ATT_FIX_SIZE )
1458 : {
1459 : // #i9046# Autowidth for fly frames
1460 0 : const SwTwips nAutoWidth = CalcAutoWidth();
1461 0 : if ( nAutoWidth )
1462 : {
1463 0 : if( ATT_MIN_SIZE == rFrmSz.GetWidthSizeType() )
1464 0 : nNewSize = std::max( nNewSize - nLR, nAutoWidth );
1465 : else
1466 0 : nNewSize = nAutoWidth;
1467 : }
1468 : }
1469 : else
1470 870 : nNewSize -= nLR;
1471 :
1472 870 : if( nNewSize < MINFLY )
1473 0 : nNewSize = MINFLY;
1474 870 : (Prt().*fnRect->fnSetWidth)( nNewSize );
1475 870 : nNewSize += nLR - (Frm().*fnRect->fnGetWidth)();
1476 870 : (Frm().*fnRect->fnAddRight)( nNewSize );
1477 : // #i68520#
1478 870 : if ( nNewSize != 0 )
1479 : {
1480 8 : InvalidateObjRectWithSpaces();
1481 : }
1482 : }
1483 : }
1484 870 : ColUnlock();
1485 870 : }
1486 :
1487 : // OD 14.03.2003 #i11760# - change parameter <bNoColl>: type <bool>;
1488 : // default value = false.
1489 : // OD 14.03.2003 #i11760# - add new parameter <bNoCalcFollow> with
1490 : // default value = false.
1491 : // OD 11.04.2003 #108824# - new parameter <bNoCalcFollow> was used by method
1492 : // <FormatWidthCols(..)> to avoid follow formatting
1493 : // for text frames. But, unformatted follows causes
1494 : // problems in method <SwCntntFrm::_WouldFit(..)>,
1495 : // which assumes that the follows are formatted.
1496 : // Thus, <bNoCalcFollow> no longer used by <FormatWidthCols(..)>.
1497 : //void CalcCntnt( SwLayoutFrm *pLay, sal_Bool bNoColl )
1498 54 : void CalcCntnt( SwLayoutFrm *pLay,
1499 : bool bNoColl,
1500 : bool bNoCalcFollow )
1501 : {
1502 : SwSectionFrm* pSect;
1503 54 : bool bCollect = false;
1504 54 : if( pLay->IsSctFrm() )
1505 : {
1506 54 : pSect = (SwSectionFrm*)pLay;
1507 54 : if( pSect->IsEndnAtEnd() && !bNoColl )
1508 : {
1509 0 : bCollect = true;
1510 0 : SwLayouter::CollectEndnotes( pLay->GetFmt()->GetDoc(), pSect );
1511 : }
1512 54 : pSect->CalcFtnCntnt();
1513 : }
1514 : else
1515 0 : pSect = NULL;
1516 54 : SwFrm *pFrm = pLay->ContainsAny();
1517 54 : if ( !pFrm )
1518 : {
1519 16 : if( pSect )
1520 : {
1521 16 : if( pSect->HasFollow() )
1522 13 : pFrm = pSect->GetFollow()->ContainsAny();
1523 16 : if( !pFrm )
1524 : {
1525 3 : if( pSect->IsEndnAtEnd() )
1526 : {
1527 0 : if( bCollect )
1528 0 : pLay->GetFmt()->GetDoc()->GetLayouter()->
1529 0 : InsertEndnotes( pSect );
1530 0 : sal_Bool bLock = pSect->IsFtnLock();
1531 0 : pSect->SetFtnLock( sal_True );
1532 0 : pSect->CalcFtnCntnt();
1533 0 : pSect->CalcFtnCntnt();
1534 0 : pSect->SetFtnLock( bLock );
1535 : }
1536 3 : return;
1537 : }
1538 13 : pFrm->_InvalidatePos();
1539 : }
1540 : else
1541 0 : return;
1542 : }
1543 51 : pFrm->InvalidatePage();
1544 :
1545 : do
1546 : {
1547 : // local variables to avoid loops caused by anchored object positioning
1548 51 : SwAnchoredObject* pAgainObj1 = 0;
1549 51 : SwAnchoredObject* pAgainObj2 = 0;
1550 :
1551 : // FME 2007-08-30 #i81146# new loop control
1552 51 : sal_uInt16 nLoopControlRuns = 0;
1553 51 : const sal_uInt16 nLoopControlMax = 20;
1554 51 : const SwFrm* pLoopControlCond = 0;
1555 :
1556 : SwFrm* pLast;
1557 51 : do
1558 : {
1559 51 : pLast = pFrm;
1560 102 : if( pFrm->IsVertical() ?
1561 0 : ( pFrm->GetUpper()->Prt().Height() != pFrm->Frm().Height() )
1562 51 : : ( pFrm->GetUpper()->Prt().Width() != pFrm->Frm().Width() ) )
1563 : {
1564 2 : pFrm->Prepare( PREP_FIXSIZE_CHG );
1565 2 : pFrm->_InvalidateSize();
1566 : }
1567 :
1568 51 : if ( pFrm->IsTabFrm() )
1569 : {
1570 0 : ((SwTabFrm*)pFrm)->bCalcLowers = sal_True;
1571 : // OD 26.08.2003 #i18103# - lock move backward of follow table,
1572 : // if no section content is formatted or follow table belongs
1573 : // to the section, which content is formatted.
1574 0 : if ( ((SwTabFrm*)pFrm)->IsFollow() &&
1575 0 : ( !pSect || pSect == pFrm->FindSctFrm() ) )
1576 : {
1577 0 : ((SwTabFrm*)pFrm)->bLockBackMove = sal_True;
1578 : }
1579 : }
1580 :
1581 : // OD 14.03.2003 #i11760# - forbid format of follow, if requested.
1582 51 : if ( bNoCalcFollow && pFrm->IsTxtFrm() )
1583 0 : static_cast<SwTxtFrm*>(pFrm)->ForbidFollowFormat();
1584 :
1585 51 : pFrm->Calc();
1586 :
1587 : // OD 14.03.2003 #i11760# - reset control flag for follow format.
1588 51 : if ( pFrm->IsTxtFrm() )
1589 : {
1590 51 : static_cast<SwTxtFrm*>(pFrm)->AllowFollowFormat();
1591 : }
1592 :
1593 : // #111937# The keep-attribute can cause the position
1594 : // of the prev to be invalid:
1595 : // OD 2004-03-15 #116560# - Do not consider invalid previous frame
1596 : // due to its keep-attribute, if current frame is a follow or is locked.
1597 : // #i44049# - do not consider invalid previous
1598 : // frame due to its keep-attribute, if it can't move forward.
1599 : // #i57765# - do not consider invalid previous
1600 : // frame, if current frame has a column/page break before attribute.
1601 51 : SwFrm* pTmpPrev = pFrm->FindPrev();
1602 51 : SwFlowFrm* pTmpPrevFlowFrm = pTmpPrev && pTmpPrev->IsFlowFrm() ? SwFlowFrm::CastFlowFrm(pTmpPrev) : 0;
1603 51 : SwFlowFrm* pTmpFlowFrm = pFrm->IsFlowFrm() ? SwFlowFrm::CastFlowFrm(pFrm) : 0;
1604 :
1605 102 : bool bPrevInvalid = pTmpPrevFlowFrm && pTmpFlowFrm &&
1606 102 : !pTmpFlowFrm->IsFollow() &&
1607 102 : !StackHack::IsLocked() && // #i76382#
1608 102 : !pTmpFlowFrm->IsJoinLocked() &&
1609 51 : !pTmpPrev->GetValidPosFlag() &&
1610 0 : pLay->IsAnLower( pTmpPrev ) &&
1611 51 : pTmpPrevFlowFrm->IsKeep( *pTmpPrev->GetAttrSet() ) &&
1612 51 : pTmpPrevFlowFrm->IsKeepFwdMoveAllowed();
1613 :
1614 : // format floating screen objects anchored to the frame.
1615 51 : bool bRestartLayoutProcess = false;
1616 51 : if ( !bPrevInvalid && pFrm->GetDrawObjs() && pLay->IsAnLower( pFrm ) )
1617 : {
1618 0 : bool bAgain = false;
1619 0 : SwPageFrm* pPageFrm = pFrm->FindPageFrm();
1620 0 : sal_uInt32 nCnt = pFrm->GetDrawObjs()->Count();
1621 0 : for ( sal_uInt16 i = 0; i < nCnt; ++i )
1622 : {
1623 : // #i28701#
1624 0 : SwAnchoredObject* pAnchoredObj = (*pFrm->GetDrawObjs())[i];
1625 : // determine, if anchored object has to be formatted.
1626 0 : if ( pAnchoredObj->PositionLocked() )
1627 : {
1628 0 : continue;
1629 : }
1630 :
1631 : // format anchored object
1632 0 : if ( pAnchoredObj->IsFormatPossible() )
1633 : {
1634 : // #i43737# - no invalidation of
1635 : // anchored object needed - causes loops for as-character
1636 : // anchored objects.
1637 : //pAnchoredObj->InvalidateObjPos();
1638 0 : SwRect aRect( pAnchoredObj->GetObjRect() );
1639 0 : if ( !SwObjectFormatter::FormatObj( *pAnchoredObj, pFrm, pPageFrm ) )
1640 : {
1641 0 : bRestartLayoutProcess = true;
1642 0 : break;
1643 : }
1644 : // #i3317# - restart layout process,
1645 : // if the position of the anchored object is locked now.
1646 0 : if ( pAnchoredObj->PositionLocked() )
1647 : {
1648 0 : bRestartLayoutProcess = true;
1649 0 : break;
1650 : }
1651 :
1652 0 : if ( aRect != pAnchoredObj->GetObjRect() )
1653 : {
1654 0 : bAgain = true;
1655 0 : if ( pAgainObj2 == pAnchoredObj )
1656 : {
1657 : OSL_FAIL( "::CalcCntnt(..) - loop detected, perform attribute changes to avoid the loop" );
1658 : //Oszillation unterbinden.
1659 0 : SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt();
1660 0 : SwFmtSurround aAttr( rFmt.GetSurround() );
1661 0 : if( SURROUND_THROUGHT != aAttr.GetSurround() )
1662 : {
1663 : // Bei autopositionierten hilft manchmal nur
1664 : // noch, auf Durchlauf zu schalten
1665 0 : if ((rFmt.GetAnchor().GetAnchorId() ==
1666 0 : FLY_AT_CHAR) &&
1667 : (SURROUND_PARALLEL ==
1668 0 : aAttr.GetSurround()))
1669 : {
1670 0 : aAttr.SetSurround( SURROUND_THROUGHT );
1671 : }
1672 : else
1673 : {
1674 0 : aAttr.SetSurround( SURROUND_PARALLEL );
1675 : }
1676 0 : rFmt.LockModify();
1677 0 : rFmt.SetFmtAttr( aAttr );
1678 0 : rFmt.UnlockModify();
1679 0 : }
1680 : }
1681 : else
1682 : {
1683 0 : if ( pAgainObj1 == pAnchoredObj )
1684 0 : pAgainObj2 = pAnchoredObj;
1685 0 : pAgainObj1 = pAnchoredObj;
1686 : }
1687 : }
1688 :
1689 0 : if ( !pFrm->GetDrawObjs() )
1690 0 : break;
1691 0 : if ( pFrm->GetDrawObjs()->Count() < nCnt )
1692 : {
1693 0 : --i;
1694 0 : --nCnt;
1695 : }
1696 : }
1697 : }
1698 :
1699 : // #i28701# - restart layout process, if
1700 : // requested by floating screen object formatting
1701 0 : if ( bRestartLayoutProcess )
1702 : {
1703 0 : pFrm = pLay->ContainsAny();
1704 0 : pAgainObj1 = 0L;
1705 0 : pAgainObj2 = 0L;
1706 0 : continue;
1707 : }
1708 :
1709 : // OD 2004-05-17 #i28701# - format anchor frame after its objects
1710 : // are formatted, if the wrapping style influence has to be considered.
1711 0 : if ( pLay->GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) )
1712 : {
1713 0 : pFrm->Calc();
1714 : }
1715 :
1716 0 : if ( bAgain )
1717 : {
1718 0 : pFrm = pLay->ContainsCntnt();
1719 0 : if ( pFrm && pFrm->IsInTab() )
1720 0 : pFrm = pFrm->FindTabFrm();
1721 0 : if( pFrm && pFrm->IsInSct() )
1722 : {
1723 0 : SwSectionFrm* pTmp = pFrm->FindSctFrm();
1724 0 : if( pTmp != pLay && pLay->IsAnLower( pTmp ) )
1725 0 : pFrm = pTmp;
1726 : }
1727 :
1728 0 : if ( pFrm == pLoopControlCond )
1729 0 : ++nLoopControlRuns;
1730 : else
1731 : {
1732 0 : nLoopControlRuns = 0;
1733 0 : pLoopControlCond = pFrm;
1734 : }
1735 :
1736 0 : if ( nLoopControlRuns < nLoopControlMax )
1737 0 : continue;
1738 :
1739 : OSL_FAIL( "LoopControl in CalcCntnt" );
1740 : }
1741 : }
1742 51 : if ( pFrm->IsTabFrm() )
1743 : {
1744 0 : if ( ((SwTabFrm*)pFrm)->IsFollow() )
1745 0 : ((SwTabFrm*)pFrm)->bLockBackMove = sal_False;
1746 : }
1747 :
1748 51 : pFrm = bPrevInvalid ? pTmpPrev : pFrm->FindNext();
1749 51 : if( !bPrevInvalid && pFrm && pFrm->IsSctFrm() && pSect )
1750 : {
1751 : // Es koennen hier leere SectionFrms herumspuken
1752 201 : while( pFrm && pFrm->IsSctFrm() && !((SwSectionFrm*)pFrm)->GetSection() )
1753 113 : pFrm = pFrm->FindNext();
1754 : // Wenn FindNext den Follow des urspruenglichen Bereichs liefert,
1755 : // wollen wir mit dessen Inhalt weitermachen, solange dieser
1756 : // zurueckfliesst.
1757 72 : if( pFrm && pFrm->IsSctFrm() && ( pFrm == pSect->GetFollow() ||
1758 28 : ((SwSectionFrm*)pFrm)->IsAnFollow( pSect ) ) )
1759 : {
1760 1 : pFrm = ((SwSectionFrm*)pFrm)->ContainsAny();
1761 1 : if( pFrm )
1762 0 : pFrm->_InvalidatePos();
1763 : }
1764 : }
1765 : // Im pLay bleiben, Ausnahme, bei SectionFrms mit Follow wird der erste
1766 : // CntntFrm des Follows anformatiert, damit er die Chance erhaelt, in
1767 : // pLay zu landen. Solange diese Frames in pLay landen, geht's weiter.
1768 101 : } while ( pFrm &&
1769 100 : ( pLay->IsAnLower( pFrm ) ||
1770 50 : ( pSect &&
1771 63 : ( ( pSect->HasFollow() &&
1772 26 : ( pLay->IsAnLower( pLast ) ||
1773 26 : ( pLast->IsInSct() &&
1774 13 : pLast->FindSctFrm()->IsAnFollow(pSect) ) ) &&
1775 50 : pSect->GetFollow()->IsAnLower( pFrm ) ) ||
1776 77 : ( pFrm->IsInSct() &&
1777 27 : pFrm->FindSctFrm()->IsAnFollow( pSect ) ) ) ) ) );
1778 51 : if( pSect )
1779 : {
1780 51 : if( bCollect )
1781 : {
1782 0 : pLay->GetFmt()->GetDoc()->GetLayouter()->InsertEndnotes(pSect);
1783 0 : pSect->CalcFtnCntnt();
1784 : }
1785 51 : if( pSect->HasFollow() )
1786 : {
1787 13 : SwSectionFrm* pNxt = pSect->GetFollow();
1788 26 : while( pNxt && !pNxt->ContainsCntnt() )
1789 0 : pNxt = pNxt->GetFollow();
1790 13 : if( pNxt )
1791 13 : pNxt->CalcFtnCntnt();
1792 : }
1793 51 : if( bCollect )
1794 : {
1795 0 : pFrm = pLay->ContainsAny();
1796 0 : bCollect = false;
1797 0 : if( pFrm )
1798 0 : continue;
1799 : }
1800 : }
1801 51 : break;
1802 : }
1803 0 : while( true );
1804 : }
1805 :
1806 : /*************************************************************************
1807 : |*
1808 : |* SwFlyFrm::MakeFlyPos()
1809 : |*
1810 : |*************************************************************************/
1811 : // OD 2004-03-23 #i26791#
1812 : //void SwFlyFrm::MakeFlyPos()
1813 38 : void SwFlyFrm::MakeObjPos()
1814 : {
1815 38 : if ( !mbValidPos )
1816 : {
1817 38 : mbValidPos = sal_True;
1818 :
1819 : // OD 29.10.2003 #113049# - use new class to position object
1820 38 : GetAnchorFrm()->Calc();
1821 : objectpositioning::SwToLayoutAnchoredObjectPosition
1822 38 : aObjPositioning( *GetVirtDrawObj() );
1823 38 : aObjPositioning.CalcPosition();
1824 :
1825 : // #i58280#
1826 : // update relative position
1827 38 : SetCurrRelPos( aObjPositioning.GetRelPos() );
1828 :
1829 38 : SWRECTFN( GetAnchorFrm() );
1830 38 : maFrm.Pos( aObjPositioning.GetRelPos() );
1831 38 : maFrm.Pos() += (GetAnchorFrm()->Frm().*fnRect->fnGetPos)();
1832 : // #i69335#
1833 38 : InvalidateObjRectWithSpaces();
1834 : }
1835 38 : }
1836 :
1837 : /*************************************************************************
1838 : |*
1839 : |* SwFlyFrm::MakePrtArea()
1840 : |*
1841 : |*************************************************************************/
1842 870 : void SwFlyFrm::MakePrtArea( const SwBorderAttrs &rAttrs )
1843 : {
1844 :
1845 870 : if ( !mbValidPrtArea )
1846 : {
1847 870 : mbValidPrtArea = sal_True;
1848 :
1849 : // OD 31.07.2003 #110978# - consider vertical layout
1850 870 : SWRECTFN( this )
1851 870 : (this->*fnRect->fnSetXMargins)( rAttrs.CalcLeftLine(),
1852 1740 : rAttrs.CalcRightLine() );
1853 870 : (this->*fnRect->fnSetYMargins)( rAttrs.CalcTopLine(),
1854 1740 : rAttrs.CalcBottomLine() );
1855 : }
1856 870 : }
1857 :
1858 : /*************************************************************************
1859 : |*
1860 : |* SwFlyFrm::_Grow(), _Shrink()
1861 : |*
1862 : |*************************************************************************/
1863 :
1864 134 : SwTwips SwFlyFrm::_Grow( SwTwips nDist, sal_Bool bTst )
1865 : {
1866 134 : SWRECTFN( this )
1867 134 : if ( Lower() && !IsColLocked() && !HasFixSize() )
1868 : {
1869 123 : SwTwips nSize = (Frm().*fnRect->fnGetHeight)();
1870 123 : if( nSize > 0 && nDist > ( LONG_MAX - nSize ) )
1871 0 : nDist = LONG_MAX - nSize;
1872 :
1873 123 : if ( nDist <= 0L )
1874 0 : return 0L;
1875 :
1876 123 : if ( Lower()->IsColumnFrm() )
1877 : { //Bei Spaltigkeit ubernimmt das Format die Kontrolle ueber
1878 : //das Wachstum (wg. des Ausgleichs).
1879 0 : if ( !bTst )
1880 : {
1881 : // #i28701# - unlock position of Writer fly frame
1882 0 : UnlockPosition();
1883 0 : _InvalidatePos();
1884 0 : InvalidateSize();
1885 : }
1886 0 : return 0L;
1887 : }
1888 :
1889 123 : if ( !bTst )
1890 : {
1891 123 : const SwRect aOld( GetObjRectWithSpaces() );
1892 123 : _InvalidateSize();
1893 123 : const sal_Bool bOldLock = bLocked;
1894 123 : Unlock();
1895 123 : if ( IsFlyFreeFrm() )
1896 : {
1897 : // #i37068# - no format of position here
1898 : // and prevent move in method <CheckClip(..)>.
1899 : // This is needed to prevent layout loop caused by nested
1900 : // Writer fly frames - inner Writer fly frames format its
1901 : // anchor, which grows/shrinks the outer Writer fly frame.
1902 : // Note: position will be invalidated below.
1903 109 : mbValidPos = sal_True;
1904 : // #i55416#
1905 : // Suppress format of width for autowidth frame, because the
1906 : // format of the width would call <SwTxtFrm::CalcFitToContent()>
1907 : // for the lower frame, which initiated this grow.
1908 109 : const sal_Bool bOldFormatHeightOnly = bFormatHeightOnly;
1909 109 : const SwFmtFrmSize& rFrmSz = GetFmt()->GetFrmSize();
1910 109 : if ( rFrmSz.GetWidthSizeType() != ATT_FIX_SIZE )
1911 : {
1912 0 : bFormatHeightOnly = sal_True;
1913 : }
1914 109 : static_cast<SwFlyFreeFrm*>(this)->SetNoMoveOnCheckClip( true );
1915 109 : ((SwFlyFreeFrm*)this)->SwFlyFreeFrm::MakeAll();
1916 109 : static_cast<SwFlyFreeFrm*>(this)->SetNoMoveOnCheckClip( false );
1917 : // #i55416#
1918 109 : if ( rFrmSz.GetWidthSizeType() != ATT_FIX_SIZE )
1919 : {
1920 0 : bFormatHeightOnly = bOldFormatHeightOnly;
1921 : }
1922 : }
1923 : else
1924 14 : MakeAll();
1925 123 : _InvalidateSize();
1926 123 : InvalidatePos();
1927 123 : if ( bOldLock )
1928 0 : Lock();
1929 123 : const SwRect aNew( GetObjRectWithSpaces() );
1930 123 : if ( aOld != aNew )
1931 103 : ::Notify( this, FindPageFrm(), aOld );
1932 123 : return (aNew.*fnRect->fnGetHeight)()-(aOld.*fnRect->fnGetHeight)();
1933 : }
1934 0 : return nDist;
1935 : }
1936 11 : return 0L;
1937 : }
1938 :
1939 9 : SwTwips SwFlyFrm::_Shrink( SwTwips nDist, sal_Bool bTst )
1940 : {
1941 9 : if( Lower() && !IsColLocked() && !HasFixSize() && !IsNoShrink() )
1942 : {
1943 5 : SWRECTFN( this )
1944 5 : SwTwips nHeight = (Frm().*fnRect->fnGetHeight)();
1945 5 : if ( nDist > nHeight )
1946 0 : nDist = nHeight;
1947 :
1948 5 : SwTwips nVal = nDist;
1949 5 : if ( IsMinHeight() )
1950 : {
1951 0 : const SwFmtFrmSize& rFmtSize = GetFmt()->GetFrmSize();
1952 0 : SwTwips nFmtHeight = bVert ? rFmtSize.GetWidth() : rFmtSize.GetHeight();
1953 :
1954 0 : nVal = std::min( nDist, nHeight - nFmtHeight );
1955 : }
1956 :
1957 5 : if ( nVal <= 0L )
1958 0 : return 0L;
1959 :
1960 5 : if ( Lower()->IsColumnFrm() )
1961 : { //Bei Spaltigkeit ubernimmt das Format die Kontrolle ueber
1962 : //das Wachstum (wg. des Ausgleichs).
1963 0 : if ( !bTst )
1964 : {
1965 0 : SwRect aOld( GetObjRectWithSpaces() );
1966 0 : (Frm().*fnRect->fnSetHeight)( nHeight - nVal );
1967 : // #i68520#
1968 0 : if ( nHeight - nVal != 0 )
1969 : {
1970 0 : InvalidateObjRectWithSpaces();
1971 : }
1972 0 : nHeight = (Prt().*fnRect->fnGetHeight)();
1973 0 : (Prt().*fnRect->fnSetHeight)( nHeight - nVal );
1974 0 : _InvalidatePos();
1975 0 : InvalidateSize();
1976 0 : ::Notify( this, FindPageFrm(), aOld );
1977 0 : NotifyDrawObj();
1978 0 : if ( GetAnchorFrm()->IsInFly() )
1979 0 : AnchorFrm()->FindFlyFrm()->Shrink( nDist, bTst );
1980 : }
1981 0 : return 0L;
1982 : }
1983 :
1984 5 : if ( !bTst )
1985 : {
1986 5 : const SwRect aOld( GetObjRectWithSpaces() );
1987 5 : _InvalidateSize();
1988 5 : const sal_Bool bOldLocked = bLocked;
1989 5 : Unlock();
1990 5 : if ( IsFlyFreeFrm() )
1991 : {
1992 : // #i37068# - no format of position here
1993 : // and prevent move in method <CheckClip(..)>.
1994 : // This is needed to prevent layout loop caused by nested
1995 : // Writer fly frames - inner Writer fly frames format its
1996 : // anchor, which grows/shrinks the outer Writer fly frame.
1997 : // Note: position will be invalidated below.
1998 5 : mbValidPos = sal_True;
1999 : // #i55416#
2000 : // Suppress format of width for autowidth frame, because the
2001 : // format of the width would call <SwTxtFrm::CalcFitToContent()>
2002 : // for the lower frame, which initiated this shrink.
2003 5 : const sal_Bool bOldFormatHeightOnly = bFormatHeightOnly;
2004 5 : const SwFmtFrmSize& rFrmSz = GetFmt()->GetFrmSize();
2005 5 : if ( rFrmSz.GetWidthSizeType() != ATT_FIX_SIZE )
2006 : {
2007 0 : bFormatHeightOnly = sal_True;
2008 : }
2009 5 : static_cast<SwFlyFreeFrm*>(this)->SetNoMoveOnCheckClip( true );
2010 5 : ((SwFlyFreeFrm*)this)->SwFlyFreeFrm::MakeAll();
2011 5 : static_cast<SwFlyFreeFrm*>(this)->SetNoMoveOnCheckClip( false );
2012 : // #i55416#
2013 5 : if ( rFrmSz.GetWidthSizeType() != ATT_FIX_SIZE )
2014 : {
2015 0 : bFormatHeightOnly = bOldFormatHeightOnly;
2016 : }
2017 : }
2018 : else
2019 0 : MakeAll();
2020 5 : _InvalidateSize();
2021 5 : InvalidatePos();
2022 5 : if ( bOldLocked )
2023 0 : Lock();
2024 5 : const SwRect aNew( GetObjRectWithSpaces() );
2025 5 : if ( aOld != aNew )
2026 : {
2027 5 : ::Notify( this, FindPageFrm(), aOld );
2028 5 : if ( GetAnchorFrm()->IsInFly() )
2029 0 : AnchorFrm()->FindFlyFrm()->Shrink( nDist, bTst );
2030 : }
2031 5 : return (aOld.*fnRect->fnGetHeight)() -
2032 5 : (aNew.*fnRect->fnGetHeight)();
2033 : }
2034 0 : return nVal;
2035 : }
2036 4 : return 0L;
2037 : }
2038 :
2039 : /*************************************************************************
2040 : |*
2041 : |* SwFlyFrm::ChgSize()
2042 : |*
2043 : |*************************************************************************/
2044 :
2045 1 : Size SwFlyFrm::ChgSize( const Size& aNewSize )
2046 : {
2047 : // #i53298#
2048 : // If the fly frame anchored at-paragraph or at-character contains an OLE
2049 : // object, assure that the new size fits into the current clipping area
2050 : // of the fly frame
2051 1 : Size aAdjustedNewSize( aNewSize );
2052 : {
2053 3 : if ( dynamic_cast<SwFlyAtCntFrm*>(this) &&
2054 4 : Lower() && dynamic_cast<SwNoTxtFrm*>(Lower()) &&
2055 1 : static_cast<SwNoTxtFrm*>(Lower())->GetNode()->GetOLENode() )
2056 : {
2057 1 : SwRect aClipRect;
2058 1 : ::CalcClipRect( GetVirtDrawObj(), aClipRect, sal_False );
2059 1 : if ( aAdjustedNewSize.Width() > aClipRect.Width() )
2060 : {
2061 0 : aAdjustedNewSize.setWidth( aClipRect.Width() );
2062 : }
2063 1 : if ( aAdjustedNewSize.Height() > aClipRect.Height() )
2064 : {
2065 0 : aAdjustedNewSize.setWidth( aClipRect.Height() );
2066 : }
2067 : }
2068 : }
2069 1 : if ( aAdjustedNewSize != Frm().SSize() )
2070 : {
2071 1 : SwFrmFmt *pFmt = GetFmt();
2072 1 : SwFmtFrmSize aSz( pFmt->GetFrmSize() );
2073 1 : aSz.SetWidth( aAdjustedNewSize.Width() );
2074 : // #i53298# - no tolerance any more.
2075 : // If it reveals that the tolerance is still needed, then suppress a
2076 : // <SetAttr> call, if <aSz> equals the current <SwFmtFrmSize> attribute.
2077 : // if ( Abs(aAdjustedNewSize.Height() - aSz.GetHeight()) > 1 )
2078 1 : aSz.SetHeight( aAdjustedNewSize.Height() );
2079 : // uebers Doc fuers Undo!
2080 1 : pFmt->GetDoc()->SetAttr( aSz, *pFmt );
2081 1 : return aSz.GetSize();
2082 : }
2083 : else
2084 0 : return Frm().SSize();
2085 : }
2086 :
2087 : /*************************************************************************
2088 : |*
2089 : |* SwFlyFrm::IsLowerOf()
2090 : |*
2091 : |*************************************************************************/
2092 :
2093 493 : sal_Bool SwFlyFrm::IsLowerOf( const SwLayoutFrm* pUpperFrm ) const
2094 : {
2095 : OSL_ENSURE( GetAnchorFrm(), "8-( Fly is lost in Space." );
2096 493 : const SwFrm* pFrm = GetAnchorFrm();
2097 1819 : do
2098 : {
2099 1824 : if ( pFrm == pUpperFrm )
2100 5 : return sal_True;
2101 1819 : pFrm = pFrm->IsFlyFrm()
2102 0 : ? ((const SwFlyFrm*)pFrm)->GetAnchorFrm()
2103 1819 : : pFrm->GetUpper();
2104 : } while ( pFrm );
2105 488 : return sal_False;
2106 : }
2107 :
2108 : /*************************************************************************
2109 : |*
2110 : |* SwFlyFrm::Cut()
2111 : |*
2112 : |*************************************************************************/
2113 :
2114 9 : void SwFlyFrm::Cut()
2115 : {
2116 9 : }
2117 :
2118 : /*************************************************************************
2119 : |*
2120 : |* SwFrm::AppendFly(), RemoveFly()
2121 : |*
2122 : |*************************************************************************/
2123 :
2124 328 : void SwFrm::AppendFly( SwFlyFrm *pNew )
2125 : {
2126 328 : if ( !mpDrawObjs )
2127 260 : mpDrawObjs = new SwSortedObjs();
2128 328 : mpDrawObjs->Insert( *pNew );
2129 328 : pNew->ChgAnchorFrm( this );
2130 :
2131 : //Bei der Seite anmelden; kann sein, dass noch keine da ist - die
2132 : //Anmeldung wird dann in SwPageFrm::PreparePage durch gefuehrt.
2133 328 : SwPageFrm *pPage = FindPageFrm();
2134 328 : if ( pPage )
2135 : {
2136 324 : if ( pNew->IsFlyAtCntFrm() && pNew->Frm().Top() == FAR_AWAY )
2137 : {
2138 : //Versuch die Seitenformatierung von neuen Dokumenten etwas
2139 : //guenstiger zu gestalten.
2140 : //Wir haengen die Flys erstenmal nach hinten damit sie bei heftigem
2141 : //Fluss der Anker nicht unoetig oft formatiert werden.
2142 : //Damit man noch brauchbar an das Ende des Dokumentes springen
2143 : //kann werden die Flys nicht ganz an das Ende gehaengt.
2144 126 : SwRootFrm *pRoot = (SwRootFrm*)pPage->GetUpper();
2145 126 : if( !SwLayHelper::CheckPageFlyCache( pPage, pNew ) )
2146 : {
2147 123 : SwPageFrm *pTmp = pRoot->GetLastPage();
2148 123 : if ( pTmp->GetPhyPageNum() > 30 )
2149 : {
2150 0 : for ( sal_uInt16 i = 0; i < 10; ++i )
2151 : {
2152 0 : pTmp = (SwPageFrm*)pTmp->GetPrev();
2153 0 : if( pTmp->GetPhyPageNum() <= pPage->GetPhyPageNum() )
2154 0 : break; // damit wir nicht vor unserem Anker landen
2155 : }
2156 0 : if ( pTmp->IsEmptyPage() )
2157 0 : pTmp = (SwPageFrm*)pTmp->GetPrev();
2158 0 : pPage = pTmp;
2159 : }
2160 : }
2161 126 : pPage->AppendFlyToPage( pNew );
2162 : }
2163 : else
2164 198 : pPage->AppendFlyToPage( pNew );
2165 : }
2166 328 : }
2167 :
2168 328 : void SwFrm::RemoveFly( SwFlyFrm *pToRemove )
2169 : {
2170 : //Bei der Seite Abmelden - kann schon passiert sein weil die Seite
2171 : //bereits destruiert wurde.
2172 328 : SwPageFrm *pPage = pToRemove->FindPageFrm();
2173 328 : if ( pPage && pPage->GetSortedObjs() )
2174 : {
2175 16 : pPage->RemoveFlyFromPage( pToRemove );
2176 : }
2177 : // #i73201#
2178 : else
2179 : {
2180 936 : if ( pToRemove->IsAccessibleFrm() &&
2181 624 : pToRemove->GetFmt() &&
2182 312 : !pToRemove->IsFlyInCntFrm() )
2183 : {
2184 126 : SwRootFrm *pRootFrm = getRootFrm();
2185 126 : if( pRootFrm && pRootFrm->IsAnyShellAccessible() )
2186 : {
2187 0 : ViewShell *pVSh = pRootFrm->GetCurrShell();
2188 0 : if( pVSh && pVSh->Imp() )
2189 : {
2190 0 : pVSh->Imp()->DisposeAccessibleFrm( pToRemove );
2191 : }
2192 : }
2193 : }
2194 : }
2195 :
2196 328 : mpDrawObjs->Remove( *pToRemove );
2197 328 : if ( !mpDrawObjs->Count() )
2198 260 : DELETEZ( mpDrawObjs );
2199 :
2200 328 : pToRemove->ChgAnchorFrm( 0 );
2201 :
2202 328 : if ( !pToRemove->IsFlyInCntFrm() && GetUpper() && IsInTab() )//MA_FLY_HEIGHT
2203 2 : GetUpper()->InvalidateSize();
2204 328 : }
2205 :
2206 : /*************************************************************************
2207 : |*
2208 : |* SwFrm::AppendDrawObj(), RemoveDrawObj()
2209 : |*
2210 : |* --> OD 2004-07-06 #i28701# - new methods
2211 : |*
2212 : |*************************************************************************/
2213 305 : void SwFrm::AppendDrawObj( SwAnchoredObject& _rNewObj )
2214 : {
2215 305 : if ( !_rNewObj.ISA(SwAnchoredDrawObject) )
2216 : {
2217 : OSL_FAIL( "SwFrm::AppendDrawObj(..) - anchored object of unexcepted type -> object not appended" );
2218 305 : return;
2219 : }
2220 :
2221 915 : if ( !_rNewObj.GetDrawObj()->ISA(SwDrawVirtObj) &&
2222 305 : _rNewObj.GetAnchorFrm() && _rNewObj.GetAnchorFrm() != this )
2223 : {
2224 : // perform disconnect from layout, if 'master' drawing object is appended
2225 : // to a new frame.
2226 0 : static_cast<SwDrawContact*>(::GetUserCall( _rNewObj.GetDrawObj() ))->
2227 0 : DisconnectFromLayout( false );
2228 : }
2229 :
2230 305 : if ( _rNewObj.GetAnchorFrm() != this )
2231 : {
2232 305 : if ( !mpDrawObjs )
2233 176 : mpDrawObjs = new SwSortedObjs();
2234 305 : mpDrawObjs->Insert( _rNewObj );
2235 305 : _rNewObj.ChgAnchorFrm( this );
2236 : }
2237 :
2238 : // #i113730#
2239 : // Assure the control objects and group objects containing controls are on the control layer
2240 305 : if ( ::CheckControlLayer( _rNewObj.DrawObj() ) )
2241 : {
2242 237 : const IDocumentDrawModelAccess* pIDDMA = getIDocumentDrawModelAccess();
2243 237 : const SdrLayerID aCurrentLayer(_rNewObj.DrawObj()->GetLayer());
2244 237 : const SdrLayerID aControlLayerID(pIDDMA->GetControlsId());
2245 237 : const SdrLayerID aInvisibleControlLayerID(pIDDMA->GetInvisibleControlsId());
2246 :
2247 237 : if(aCurrentLayer != aControlLayerID && aCurrentLayer != aInvisibleControlLayerID)
2248 : {
2249 0 : if ( aCurrentLayer == pIDDMA->GetInvisibleHellId() ||
2250 0 : aCurrentLayer == pIDDMA->GetInvisibleHeavenId() )
2251 : {
2252 0 : _rNewObj.DrawObj()->SetLayer(aInvisibleControlLayerID);
2253 : }
2254 : else
2255 : {
2256 0 : _rNewObj.DrawObj()->SetLayer(aControlLayerID);
2257 : }
2258 : }
2259 : }
2260 :
2261 : // no direct positioning needed, but invalidate the drawing object position
2262 305 : _rNewObj.InvalidateObjPos();
2263 :
2264 : // register at page frame
2265 305 : SwPageFrm* pPage = FindPageFrm();
2266 305 : if ( pPage )
2267 : {
2268 289 : pPage->AppendDrawObjToPage( _rNewObj );
2269 : }
2270 :
2271 : // Notify accessible layout.
2272 305 : ViewShell* pSh = getRootFrm()->GetCurrShell();
2273 305 : if( pSh )
2274 : {
2275 305 : SwRootFrm* pLayout = getRootFrm();
2276 305 : if( pLayout && pLayout->IsAnyShellAccessible() )
2277 0 : pSh->Imp()->AddAccessibleObj( _rNewObj.GetDrawObj() );
2278 : }
2279 : }
2280 :
2281 305 : void SwFrm::RemoveDrawObj( SwAnchoredObject& _rToRemoveObj )
2282 : {
2283 : // Notify accessible layout.
2284 305 : ViewShell* pSh = getRootFrm()->GetCurrShell();
2285 305 : if( pSh )
2286 : {
2287 12 : SwRootFrm* pLayout = getRootFrm();
2288 12 : if( pLayout && pLayout->IsAnyShellAccessible() )
2289 0 : pSh->Imp()->DisposeAccessibleObj( _rToRemoveObj.GetDrawObj() );
2290 : }
2291 :
2292 : // deregister from page frame
2293 305 : SwPageFrm* pPage = _rToRemoveObj.GetPageFrm();
2294 305 : if ( pPage && pPage->GetSortedObjs() )
2295 11 : pPage->RemoveDrawObjFromPage( _rToRemoveObj );
2296 :
2297 305 : mpDrawObjs->Remove( _rToRemoveObj );
2298 305 : if ( !mpDrawObjs->Count() )
2299 176 : DELETEZ( mpDrawObjs );
2300 :
2301 305 : _rToRemoveObj.ChgAnchorFrm( 0 );
2302 305 : }
2303 :
2304 : /*************************************************************************
2305 : |*
2306 : |* SwFrm::InvalidateObjs()
2307 : |*
2308 : |*************************************************************************/
2309 : // #i28701# - change purpose of method and adjust its name
2310 5199 : void SwFrm::InvalidateObjs( const bool _bInvaPosOnly,
2311 : const bool _bNoInvaOfAsCharAnchoredObjs )
2312 : {
2313 5199 : if ( GetDrawObjs() )
2314 : {
2315 : // #i26945# - determine page the frame is on,
2316 : // in order to check, if anchored object is registered at the same
2317 : // page.
2318 276 : const SwPageFrm* pPageFrm = FindPageFrm();
2319 : // #i28701# - re-factoring
2320 276 : sal_uInt32 i = 0;
2321 614 : for ( ; i < GetDrawObjs()->Count(); ++i )
2322 : {
2323 338 : SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[i];
2324 676 : if ( _bNoInvaOfAsCharAnchoredObjs &&
2325 338 : (pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId()
2326 : == FLY_AS_CHAR) )
2327 : {
2328 194 : continue;
2329 : }
2330 : // #i26945# - no invalidation, if anchored object
2331 : // isn't registered at the same page and instead is registered at
2332 : // the page, where its anchor character text frame is on.
2333 288 : if ( pAnchoredObj->GetPageFrm() &&
2334 144 : pAnchoredObj->GetPageFrm() != pPageFrm )
2335 : {
2336 0 : SwTxtFrm* pAnchorCharFrm = pAnchoredObj->FindAnchorCharFrm();
2337 0 : if ( pAnchorCharFrm &&
2338 0 : pAnchoredObj->GetPageFrm() == pAnchorCharFrm->FindPageFrm() )
2339 : {
2340 0 : continue;
2341 : }
2342 : // #115759# - unlock its position, if anchored
2343 : // object isn't registered at the page, where its anchor
2344 : // character text frame is on, respectively if it has no
2345 : // anchor character text frame.
2346 : else
2347 : {
2348 0 : pAnchoredObj->UnlockPosition();
2349 : }
2350 : }
2351 : // #i51474# - reset flag, that anchored object
2352 : // has cleared environment, and unlock its position, if the anchored
2353 : // object is registered at the same page as the anchor frame is on.
2354 288 : if ( pAnchoredObj->ClearedEnvironment() &&
2355 144 : pAnchoredObj->GetPageFrm() &&
2356 0 : pAnchoredObj->GetPageFrm() == pPageFrm )
2357 : {
2358 0 : pAnchoredObj->UnlockPosition();
2359 0 : pAnchoredObj->SetClearedEnvironment( false );
2360 : }
2361 : // distinguish between writer fly frames and drawing objects
2362 144 : if ( pAnchoredObj->ISA(SwFlyFrm) )
2363 : {
2364 99 : SwFlyFrm* pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
2365 99 : pFly->_Invalidate();
2366 99 : pFly->_InvalidatePos();
2367 99 : if ( !_bInvaPosOnly )
2368 0 : pFly->_InvalidateSize();
2369 : }
2370 : else
2371 : {
2372 45 : pAnchoredObj->InvalidateObjPos();
2373 : } // end of distinction between writer fly frames and drawing objects
2374 :
2375 : } // end of loop on objects, which are connected to the frame
2376 : }
2377 5199 : }
2378 :
2379 : /*************************************************************************
2380 : |*
2381 : |* SwLayoutFrm::NotifyLowerObjs()
2382 : |*
2383 : |*************************************************************************/
2384 : // #i28701# - change purpose of method and its name
2385 : // #i26945# - correct check, if anchored object is a lower
2386 : // of the layout frame. E.g., anchor character text frame can be a follow text
2387 : // frame.
2388 : // #i44016# - add parameter <_bUnlockPosOfObjs> to
2389 : // force an unlockposition call for the lower objects.
2390 5937 : void SwLayoutFrm::NotifyLowerObjs( const bool _bUnlockPosOfObjs )
2391 : {
2392 : // invalidate lower floating screen objects
2393 5937 : SwPageFrm* pPageFrm = FindPageFrm();
2394 5937 : if ( pPageFrm && pPageFrm->GetSortedObjs() )
2395 : {
2396 920 : SwSortedObjs& rObjs = *(pPageFrm->GetSortedObjs());
2397 2640 : for ( sal_uInt32 i = 0; i < rObjs.Count(); ++i )
2398 : {
2399 1720 : SwAnchoredObject* pObj = rObjs[i];
2400 : // #i26945# - check, if anchored object is a lower
2401 : // of the layout frame is changed to check, if its anchor frame
2402 : // is a lower of the layout frame.
2403 : // determine the anchor frame - usually it's the anchor frame,
2404 : // for at-character/as-character anchored objects the anchor character
2405 : // text frame is taken.
2406 1720 : const SwFrm* pAnchorFrm = pObj->GetAnchorFrmContainingAnchPos();
2407 1720 : if ( pObj->ISA(SwFlyFrm) )
2408 : {
2409 866 : SwFlyFrm* pFly = static_cast<SwFlyFrm*>(pObj);
2410 :
2411 866 : if ( pFly->Frm().Left() == FAR_AWAY )
2412 188 : continue;
2413 :
2414 678 : if ( pFly->IsAnLower( this ) )
2415 455 : continue;
2416 :
2417 : // #i26945# - use <pAnchorFrm> to check, if
2418 : // fly frame is lower of layout frame resp. if fly frame is
2419 : // at a different page registered as its anchor frame is on.
2420 223 : const bool bLow = IsAnLower( pAnchorFrm );
2421 223 : if ( bLow || pAnchorFrm->FindPageFrm() != pPageFrm )
2422 : {
2423 8 : pFly->_Invalidate( pPageFrm );
2424 8 : if ( !bLow || pFly->IsFlyAtCntFrm() )
2425 : {
2426 : // #i44016#
2427 8 : if ( _bUnlockPosOfObjs )
2428 : {
2429 4 : pFly->UnlockPosition();
2430 : }
2431 8 : pFly->_InvalidatePos();
2432 : }
2433 : else
2434 0 : pFly->_InvalidatePrt();
2435 : }
2436 : }
2437 : else
2438 : {
2439 : OSL_ENSURE( pObj->ISA(SwAnchoredDrawObject),
2440 : "<SwLayoutFrm::NotifyFlys() - anchored object of unexcepted type" );
2441 : // #i26945# - use <pAnchorFrm> to check, if
2442 : // fly frame is lower of layout frame resp. if fly frame is
2443 : // at a different page registered as its anchor frame is on.
2444 1682 : if ( IsAnLower( pAnchorFrm ) ||
2445 828 : pAnchorFrm->FindPageFrm() != pPageFrm )
2446 : {
2447 : // #i44016#
2448 26 : if ( _bUnlockPosOfObjs )
2449 : {
2450 17 : pObj->UnlockPosition();
2451 : }
2452 26 : pObj->InvalidateObjPos();
2453 : }
2454 : }
2455 : }
2456 : }
2457 5937 : }
2458 :
2459 : /*************************************************************************
2460 : |*
2461 : |* SwFlyFrm::NotifyDrawObj()
2462 : |*
2463 : |*************************************************************************/
2464 :
2465 767 : void SwFlyFrm::NotifyDrawObj()
2466 : {
2467 767 : SwVirtFlyDrawObj* pObj = GetVirtDrawObj();
2468 767 : pObj->SetRect();
2469 767 : pObj->SetRectsDirty();
2470 767 : pObj->SetChanged();
2471 767 : pObj->BroadcastObjectChange();
2472 767 : if ( GetFmt()->GetSurround().IsContour() )
2473 0 : ClrContourCache( pObj );
2474 767 : }
2475 :
2476 : /*************************************************************************
2477 : |*
2478 : |* SwFlyFrm::CalcRel()
2479 : |*
2480 : |*************************************************************************/
2481 :
2482 870 : Size SwFlyFrm::CalcRel( const SwFmtFrmSize &rSz ) const
2483 : {
2484 870 : Size aRet( rSz.GetSize() );
2485 :
2486 870 : const SwFrm *pRel = IsFlyLayFrm() ? GetAnchorFrm() : GetAnchorFrm()->GetUpper();
2487 870 : if( pRel ) // LAYER_IMPL
2488 : {
2489 870 : long nRelWidth = LONG_MAX, nRelHeight = LONG_MAX;
2490 870 : const ViewShell *pSh = getRootFrm()->GetCurrShell();
2491 1886 : if ( ( pRel->IsBodyFrm() || pRel->IsPageFrm() ) &&
2492 1708 : pSh && pSh->GetViewOptions()->getBrowseMode() &&
2493 0 : pSh->VisArea().HasArea() )
2494 : {
2495 0 : nRelWidth = pSh->GetBrowseWidth();
2496 0 : nRelHeight = pSh->VisArea().Height();
2497 0 : Size aBorder = pSh->GetOut()->PixelToLogic( pSh->GetBrowseBorder() );
2498 0 : long nDiff = nRelWidth - pRel->Prt().Width();
2499 0 : if ( nDiff > 0 )
2500 0 : nRelWidth -= nDiff;
2501 0 : nRelHeight -= 2*aBorder.Height();
2502 0 : nDiff = nRelHeight - pRel->Prt().Height();
2503 0 : if ( nDiff > 0 )
2504 0 : nRelHeight -= nDiff;
2505 : }
2506 870 : nRelWidth = std::min( nRelWidth, pRel->Prt().Width() );
2507 870 : nRelHeight = std::min( nRelHeight, pRel->Prt().Height() );
2508 870 : if( !pRel->IsPageFrm() )
2509 : {
2510 756 : const SwPageFrm* pPage = FindPageFrm();
2511 756 : if( pPage )
2512 : {
2513 756 : nRelWidth = std::min( nRelWidth, pPage->Prt().Width() );
2514 756 : nRelHeight = std::min( nRelHeight, pPage->Prt().Height() );
2515 : }
2516 : }
2517 :
2518 870 : if ( rSz.GetWidthPercent() && rSz.GetWidthPercent() != 0xFF )
2519 20 : aRet.Width() = nRelWidth * rSz.GetWidthPercent() / 100;
2520 870 : if ( rSz.GetHeightPercent() && rSz.GetHeightPercent() != 0xFF )
2521 4 : aRet.Height() = nRelHeight * rSz.GetHeightPercent() / 100;
2522 :
2523 870 : if ( rSz.GetWidthPercent() == 0xFF )
2524 : {
2525 0 : aRet.Width() *= aRet.Height();
2526 0 : aRet.Width() /= rSz.GetHeight();
2527 : }
2528 870 : else if ( rSz.GetHeightPercent() == 0xFF )
2529 : {
2530 0 : aRet.Height() *= aRet.Width();
2531 0 : aRet.Height() /= rSz.GetWidth();
2532 : }
2533 : }
2534 870 : return aRet;
2535 : }
2536 :
2537 : /*************************************************************************
2538 : |*
2539 : |* SwFlyFrm::CalcAutoWidth()
2540 : |*
2541 : |*************************************************************************/
2542 :
2543 0 : static SwTwips lcl_CalcAutoWidth( const SwLayoutFrm& rFrm )
2544 : {
2545 0 : SwTwips nRet = 0;
2546 0 : SwTwips nMin = 0;
2547 0 : const SwFrm* pFrm = rFrm.Lower();
2548 :
2549 : // No autowidth defined for columned frames
2550 0 : if ( !pFrm || pFrm->IsColumnFrm() )
2551 0 : return nRet;
2552 :
2553 0 : while ( pFrm )
2554 : {
2555 0 : if ( pFrm->IsSctFrm() )
2556 : {
2557 0 : nMin = lcl_CalcAutoWidth( *(SwSectionFrm*)pFrm );
2558 : }
2559 0 : if ( pFrm->IsTxtFrm() )
2560 : {
2561 0 : nMin = ((SwTxtFrm*)pFrm)->CalcFitToContent();
2562 : const SvxLRSpaceItem &rSpace =
2563 0 : ((SwTxtFrm*)pFrm)->GetTxtNode()->GetSwAttrSet().GetLRSpace();
2564 0 : if (!((SwTxtFrm*)pFrm)->IsLocked())
2565 0 : nMin += rSpace.GetRight() + rSpace.GetTxtLeft() + rSpace.GetTxtFirstLineOfst();
2566 : }
2567 0 : else if ( pFrm->IsTabFrm() )
2568 : {
2569 0 : const SwFmtFrmSize& rTblFmtSz = ((SwTabFrm*)pFrm)->GetTable()->GetFrmFmt()->GetFrmSize();
2570 0 : if ( USHRT_MAX == rTblFmtSz.GetSize().Width() ||
2571 0 : text::HoriOrientation::NONE == ((SwTabFrm*)pFrm)->GetFmt()->GetHoriOrient().GetHoriOrient() )
2572 : {
2573 0 : const SwPageFrm* pPage = rFrm.FindPageFrm();
2574 : // auto width table
2575 0 : nMin = pFrm->GetUpper()->IsVertical() ?
2576 0 : pPage->Prt().Height() :
2577 0 : pPage->Prt().Width();
2578 : }
2579 : else
2580 : {
2581 0 : nMin = rTblFmtSz.GetSize().Width();
2582 : }
2583 : }
2584 :
2585 0 : if ( nMin > nRet )
2586 0 : nRet = nMin;
2587 :
2588 0 : pFrm = pFrm->GetNext();
2589 : }
2590 :
2591 0 : return nRet;
2592 : }
2593 :
2594 0 : SwTwips SwFlyFrm::CalcAutoWidth() const
2595 : {
2596 0 : return lcl_CalcAutoWidth( *this );
2597 : }
2598 :
2599 : /*************************************************************************
2600 : |*
2601 : |* SwFlyFrm::GetContour()
2602 : |*
2603 : |*************************************************************************/
2604 : /// OD 16.04.2003 #i13147# - If called for paint and the <SwNoTxtFrm> contains
2605 : /// a graphic, load of intrinsic graphic has to be avoided.
2606 66 : sal_Bool SwFlyFrm::GetContour( PolyPolygon& rContour,
2607 : const sal_Bool _bForPaint ) const
2608 : {
2609 66 : sal_Bool bRet = sal_False;
2610 85 : if( GetFmt()->GetSurround().IsContour() && Lower() &&
2611 19 : Lower()->IsNoTxtFrm() )
2612 : {
2613 19 : SwNoTxtNode *pNd = (SwNoTxtNode*)((SwCntntFrm*)Lower())->GetNode();
2614 : // OD 16.04.2003 #i13147# - determine <GraphicObject> instead of <Graphic>
2615 : // in order to avoid load of graphic, if <SwNoTxtNode> contains a graphic
2616 : // node and method is called for paint.
2617 19 : const GraphicObject* pGrfObj = NULL;
2618 19 : bool bGrfObjCreated = false;
2619 19 : const SwGrfNode* pGrfNd = pNd->GetGrfNode();
2620 19 : if ( pGrfNd && _bForPaint )
2621 : {
2622 14 : pGrfObj = &(pGrfNd->GetGrfObj());
2623 : }
2624 : else
2625 : {
2626 5 : pGrfObj = new GraphicObject( pNd->GetGraphic() );
2627 5 : bGrfObjCreated = true;
2628 : }
2629 : OSL_ENSURE( pGrfObj, "SwFlyFrm::GetContour() - No Graphic/GraphicObject found at <SwNoTxtNode>." );
2630 19 : if ( pGrfObj && pGrfObj->GetType() != GRAPHIC_NONE )
2631 : {
2632 0 : if( !pNd->HasContour() )
2633 : {
2634 : // OD 16.04.2003 #i13147# - no <CreateContour> for a graphic
2635 : // during paint. Thus, return (value of <bRet> should be <sal_False>).
2636 0 : if ( pGrfNd && _bForPaint )
2637 : {
2638 : OSL_FAIL( "SwFlyFrm::GetContour() - No Contour found at <SwNoTxtNode> during paint." );
2639 0 : return bRet;
2640 : }
2641 0 : pNd->CreateContour();
2642 : }
2643 0 : pNd->GetContour( rContour );
2644 : //Der Node haelt das Polygon passend zur Originalgroesse der Grafik
2645 : //hier muss die Skalierung einkalkuliert werden.
2646 0 : SwRect aClip;
2647 0 : SwRect aOrig;
2648 0 : Lower()->Calc();
2649 0 : ((SwNoTxtFrm*)Lower())->GetGrfArea( aClip, &aOrig, false );
2650 : // OD 16.04.2003 #i13147# - copy method code <SvxContourDlg::ScaleContour(..)>
2651 : // in order to avoid that graphic has to be loaded for contour scale.
2652 : //SvxContourDlg::ScaleContour( rContour, aGrf, MAP_TWIP, aOrig.SSize() );
2653 : {
2654 0 : OutputDevice* pOutDev = Application::GetDefaultDevice();
2655 0 : const MapMode aDispMap( MAP_TWIP );
2656 0 : const MapMode aGrfMap( pGrfObj->GetPrefMapMode() );
2657 0 : const Size aGrfSize( pGrfObj->GetPrefSize() );
2658 0 : Size aOrgSize;
2659 0 : Point aNewPoint;
2660 0 : bool bPixelMap = aGrfMap.GetMapUnit() == MAP_PIXEL;
2661 :
2662 0 : if ( bPixelMap )
2663 0 : aOrgSize = pOutDev->PixelToLogic( aGrfSize, aDispMap );
2664 : else
2665 0 : aOrgSize = pOutDev->LogicToLogic( aGrfSize, aGrfMap, aDispMap );
2666 :
2667 0 : if ( aOrgSize.Width() && aOrgSize.Height() )
2668 : {
2669 0 : double fScaleX = (double) aOrig.Width() / aOrgSize.Width();
2670 0 : double fScaleY = (double) aOrig.Height() / aOrgSize.Height();
2671 :
2672 0 : for ( sal_uInt16 j = 0, nPolyCount = rContour.Count(); j < nPolyCount; j++ )
2673 : {
2674 0 : Polygon& rPoly = rContour[ j ];
2675 :
2676 0 : for ( sal_uInt16 i = 0, nCount = rPoly.GetSize(); i < nCount; i++ )
2677 : {
2678 0 : if ( bPixelMap )
2679 0 : aNewPoint = pOutDev->PixelToLogic( rPoly[ i ], aDispMap );
2680 : else
2681 0 : aNewPoint = pOutDev->LogicToLogic( rPoly[ i ], aGrfMap, aDispMap );
2682 :
2683 0 : rPoly[ i ] = Point( FRound( aNewPoint.getX() * fScaleX ), FRound( aNewPoint.getY() * fScaleY ) );
2684 : }
2685 : }
2686 0 : }
2687 : }
2688 : // OD 17.04.2003 #i13147# - destroy created <GraphicObject>.
2689 0 : if ( bGrfObjCreated )
2690 : {
2691 0 : delete pGrfObj;
2692 : }
2693 0 : rContour.Move( aOrig.Left(), aOrig.Top() );
2694 0 : if( !aClip.Width() )
2695 0 : aClip.Width( 1 );
2696 0 : if( !aClip.Height() )
2697 0 : aClip.Height( 1 );
2698 0 : rContour.Clip( aClip.SVRect() );
2699 0 : rContour.Optimize(POLY_OPTIMIZE_CLOSE);
2700 0 : bRet = sal_True;
2701 : }
2702 : }
2703 66 : return bRet;
2704 : }
2705 :
2706 : // OD 2004-03-25 #i26791#
2707 1060 : const SwVirtFlyDrawObj* SwFlyFrm::GetVirtDrawObj() const
2708 : {
2709 1060 : return static_cast<const SwVirtFlyDrawObj*>(GetDrawObj());
2710 : }
2711 6893 : SwVirtFlyDrawObj* SwFlyFrm::GetVirtDrawObj()
2712 : {
2713 6893 : return static_cast<SwVirtFlyDrawObj*>(DrawObj());
2714 : }
2715 :
2716 : // =============================================================================
2717 : // OD 2004-03-24 #i26791# - implementation of pure virtual method declared in
2718 : // base class <SwAnchoredObject>
2719 : // =============================================================================
2720 96 : void SwFlyFrm::InvalidateObjPos()
2721 : {
2722 96 : InvalidatePos();
2723 : // #i68520#
2724 96 : InvalidateObjRectWithSpaces();
2725 96 : }
2726 :
2727 10705 : SwFrmFmt& SwFlyFrm::GetFrmFmt()
2728 : {
2729 : OSL_ENSURE( GetFmt(),
2730 : "<SwFlyFrm::GetFrmFmt()> - missing frame format -> crash." );
2731 10705 : return *GetFmt();
2732 : }
2733 14960 : const SwFrmFmt& SwFlyFrm::GetFrmFmt() const
2734 : {
2735 : OSL_ENSURE( GetFmt(),
2736 : "<SwFlyFrm::GetFrmFmt()> - missing frame format -> crash." );
2737 14960 : return *GetFmt();
2738 : }
2739 :
2740 15535 : const SwRect SwFlyFrm::GetObjRect() const
2741 : {
2742 15535 : return Frm();
2743 : }
2744 :
2745 : // #i70122#
2746 : // for Writer fly frames the bounding rectangle equals the object rectangles
2747 1215 : const SwRect SwFlyFrm::GetObjBoundRect() const
2748 : {
2749 1215 : return GetObjRect();
2750 : }
2751 :
2752 : // #i68520#
2753 636 : bool SwFlyFrm::_SetObjTop( const SwTwips _nTop )
2754 : {
2755 636 : const bool bChanged( Frm().Pos().getY() != _nTop );
2756 :
2757 636 : Frm().Pos().setY(_nTop);
2758 :
2759 636 : return bChanged;
2760 : }
2761 212 : bool SwFlyFrm::_SetObjLeft( const SwTwips _nLeft )
2762 : {
2763 212 : const bool bChanged( Frm().Pos().getX() != _nLeft );
2764 :
2765 212 : Frm().Pos().setX(_nLeft);
2766 :
2767 212 : return bChanged;
2768 : }
2769 :
2770 : /** method to assure that anchored object is registered at the correct
2771 : page frame
2772 :
2773 : OD 2004-07-02 #i28701#
2774 :
2775 : @author OD
2776 : */
2777 0 : void SwFlyFrm::RegisterAtCorrectPage()
2778 : {
2779 : // default behaviour is to do nothing.
2780 0 : }
2781 :
2782 : /** method to determine, if a <MakeAll()> on the Writer fly frame is possible
2783 :
2784 : OD 2004-05-11 #i28701#
2785 :
2786 : @author OD
2787 : */
2788 984 : bool SwFlyFrm::IsFormatPossible() const
2789 : {
2790 1968 : return SwAnchoredObject::IsFormatPossible() &&
2791 1968 : !IsLocked() && !IsColLocked();
2792 : }
2793 :
2794 4 : void SwFlyFrm::GetAnchoredObjects( std::list<SwAnchoredObject*>& aList, const SwFmt& rFmt )
2795 : {
2796 4 : SwIterator<SwFlyFrm,SwFmt> aIter( rFmt );
2797 8 : for( SwFlyFrm* pFlyFrm = aIter.First(); pFlyFrm; pFlyFrm = aIter.Next() )
2798 8 : aList.push_back( pFlyFrm );
2799 4 : }
2800 :
2801 26478 : const SwFlyFrmFmt * SwFlyFrm::GetFmt() const
2802 : {
2803 26478 : return static_cast< const SwFlyFrmFmt * >( GetDep() );
2804 : }
2805 :
2806 27439 : SwFlyFrmFmt * SwFlyFrm::GetFmt()
2807 : {
2808 27439 : return static_cast< SwFlyFrmFmt * >( GetDep() );
2809 99 : }
2810 :
2811 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|