LCOV - code coverage report
Current view: top level - sw/source/core/doc - DocumentLayoutManager.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 173 204 84.8 %
Date: 2014-11-03 Functions: 18 18 100.0 %
Legend: Lines: hit not hit

          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             : #include <DocumentLayoutManager.hxx>
      20             : #include <doc.hxx>
      21             : #include <IDocumentState.hxx>
      22             : #include <IDocumentUndoRedo.hxx>
      23             : #include <DocumentContentOperationsManager.hxx>
      24             : #include <IDocumentStylePoolAccess.hxx>
      25             : #include <undobj.hxx>
      26             : #include <viewsh.hxx>
      27             : #include <layouter.hxx>
      28             : #include <poolfmt.hxx>
      29             : #include <frmfmt.hxx>
      30             : #include <fmtcntnt.hxx>
      31             : #include <fmtcnct.hxx>
      32             : #include <ndole.hxx>
      33             : #include <com/sun/star/embed/EmbedStates.hpp>
      34             : #include <fmtanchr.hxx>
      35             : #include <txtflcnt.hxx>
      36             : #include <fmtflcnt.hxx>
      37             : #include <ndtxt.hxx>
      38             : #include <dcontact.hxx>
      39             : #include <unoframe.hxx>
      40             : #include <docary.hxx>
      41             : #include <textboxhelper.hxx>
      42             : 
      43             : using namespace ::com::sun::star;
      44             : 
      45             : namespace sw
      46             : {
      47             : 
      48        5052 : DocumentLayoutManager::DocumentLayoutManager( SwDoc& i_rSwdoc ) :
      49             :     m_rSwdoc( i_rSwdoc ),
      50             :     mpCurrentView( 0 ),
      51        5052 :     mpLayouter( 0 )
      52             : {
      53        5052 : }
      54             : 
      55      832443 : const SwViewShell *DocumentLayoutManager::GetCurrentViewShell() const
      56             : {
      57      832443 :     return mpCurrentView;
      58             : }
      59             : 
      60     2513070 : SwViewShell *DocumentLayoutManager::GetCurrentViewShell()
      61             : {
      62     2513070 :     return mpCurrentView;
      63             : }
      64             : 
      65       14756 : void DocumentLayoutManager::SetCurrentViewShell( SwViewShell* pNew )
      66             : {
      67       14756 :     mpCurrentView = pNew;
      68       14756 : }
      69             : 
      70             : // It must be able to communicate to a SwViewShell. This is going to be removed later.
      71      350144 : const SwRootFrm *DocumentLayoutManager::GetCurrentLayout() const
      72             : {
      73      350144 :     if(GetCurrentViewShell())
      74      334844 :         return GetCurrentViewShell()->GetLayout();
      75       15300 :     return 0;
      76             : }
      77             : 
      78     1184886 : SwRootFrm *DocumentLayoutManager::GetCurrentLayout()
      79             : {
      80     1184886 :     if(GetCurrentViewShell())
      81      443666 :         return GetCurrentViewShell()->GetLayout();
      82      741220 :     return 0;
      83             : }
      84             : 
      85       10556 : bool DocumentLayoutManager::HasLayout() const
      86             : {
      87             :     // if there is a view, there is always a layout
      88       10556 :     return (mpCurrentView != 0);
      89             : }
      90             : 
      91      203263 : SwLayouter* DocumentLayoutManager::GetLayouter()
      92             : {
      93      203263 :     return mpLayouter;
      94             : }
      95             : 
      96     5457728 : const SwLayouter* DocumentLayoutManager::GetLayouter() const
      97             : {
      98     5457728 :     return mpLayouter;
      99             : }
     100             : 
     101        4714 : void DocumentLayoutManager::SetLayouter( SwLayouter* pNew )
     102             : {
     103        4714 :     mpLayouter = pNew;
     104        4714 : }
     105             : 
     106             : /** Create a new format whose settings fit to the Request by default.
     107             : 
     108             :     The format is put into the respective format array.
     109             :     If there already is a fitting format, it is returned instead. */
     110        2674 : SwFrmFmt *DocumentLayoutManager::MakeLayoutFmt( RndStdIds eRequest, const SfxItemSet* pSet )
     111             : {
     112        2674 :     SwFrmFmt *pFmt = 0;
     113        2674 :     const bool bMod = m_rSwdoc.getIDocumentState().IsModified();
     114        2674 :     bool bHeader = false;
     115             : 
     116        2674 :     switch ( eRequest )
     117             :     {
     118             :     case RND_STD_HEADER:
     119             :     case RND_STD_HEADERL:
     120             :     case RND_STD_HEADERR:
     121             :         {
     122        1332 :             bHeader = true;
     123             :             // no break, we continue further down
     124             :         }
     125             :     case RND_STD_FOOTER:
     126             :     case RND_STD_FOOTERL:
     127             :     case RND_STD_FOOTERR:
     128             :         {
     129        2674 :             pFmt = new SwFrmFmt( m_rSwdoc.GetAttrPool(),
     130             :                                  (bHeader ? "Right header" : "Right footer"),
     131        2674 :                                  m_rSwdoc.GetDfltFrmFmt() );
     132             : 
     133        2674 :             SwNodeIndex aTmpIdx( m_rSwdoc.GetNodes().GetEndOfAutotext() );
     134             :             SwStartNode* pSttNd =
     135        2674 :                 m_rSwdoc.GetNodes().MakeTextSection
     136             :                 ( aTmpIdx,
     137             :                   bHeader ? SwHeaderStartNode : SwFooterStartNode,
     138        2674 :                   m_rSwdoc.getIDocumentStylePoolAccess().GetTxtCollFromPool(static_cast<sal_uInt16>( bHeader
     139             :                                      ? ( eRequest == RND_STD_HEADERL
     140             :                                          ? RES_POOLCOLL_HEADERL
     141             :                                          : eRequest == RND_STD_HEADERR
     142             :                                          ? RES_POOLCOLL_HEADERR
     143             :                                          : RES_POOLCOLL_HEADER )
     144             :                                      : ( eRequest == RND_STD_FOOTERL
     145             :                                          ? RES_POOLCOLL_FOOTERL
     146             :                                          : eRequest == RND_STD_FOOTERR
     147             :                                          ? RES_POOLCOLL_FOOTERR
     148             :                                          : RES_POOLCOLL_FOOTER )
     149        5348 :                                      ) ) );
     150        2674 :             pFmt->SetFmtAttr( SwFmtCntnt( pSttNd ));
     151             : 
     152        2674 :             if( pSet )      // Set a few more attributes
     153           0 :                 pFmt->SetFmtAttr( *pSet );
     154             : 
     155             :             // Why set it back?  Doc has changed, or not?
     156             :             // In any case, wrong for the FlyFrames!
     157        2674 :             if ( !bMod )
     158           0 :                 m_rSwdoc.getIDocumentState().ResetModified();
     159             :         }
     160        2674 :         break;
     161             : 
     162             :     case RND_DRAW_OBJECT:
     163             :         {
     164           0 :             pFmt = m_rSwdoc.MakeDrawFrmFmt( OUString(), m_rSwdoc.GetDfltFrmFmt() );
     165           0 :             if( pSet )      // Set a few more attributes
     166           0 :                 pFmt->SetFmtAttr( *pSet );
     167             : 
     168           0 :             if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
     169             :             {
     170           0 :                 m_rSwdoc.GetIDocumentUndoRedo().AppendUndo(
     171           0 :                     new SwUndoInsLayFmt(pFmt, 0, 0));
     172             :             }
     173             :         }
     174           0 :         break;
     175             : 
     176             : #if OSL_DEBUG_LEVEL > 0
     177             :     case FLY_AT_PAGE:
     178             :     case FLY_AT_CHAR:
     179             :     case FLY_AT_FLY:
     180             :     case FLY_AT_PARA:
     181             :     case FLY_AS_CHAR:
     182             :         OSL_FAIL( "use new interface instead: SwDoc::MakeFlySection!" );
     183             :         break;
     184             : #endif
     185             : 
     186             :     default:
     187             :         OSL_ENSURE( false,
     188             :                 "LayoutFormat was requested with an invalid Request." );
     189             : 
     190             :     }
     191        2674 :     return pFmt;
     192             : }
     193             : 
     194             : /// Deletes the denoted format and its content.
     195        4226 : void DocumentLayoutManager::DelLayoutFmt( SwFrmFmt *pFmt )
     196             : {
     197             :     // A chain of frames needs to be merged, if necessary,
     198             :     // so that the Frame's contents are adjusted accordingly before we destroy the Frames.
     199        4226 :     const SwFmtChain &rChain = pFmt->GetChain();
     200        4226 :     if ( rChain.GetPrev() )
     201             :     {
     202           0 :         SwFmtChain aChain( rChain.GetPrev()->GetChain() );
     203           0 :         aChain.SetNext( rChain.GetNext() );
     204           0 :         m_rSwdoc.SetAttr( aChain, *rChain.GetPrev() );
     205             :     }
     206        4226 :     if ( rChain.GetNext() )
     207             :     {
     208           0 :         SwFmtChain aChain( rChain.GetNext()->GetChain() );
     209           0 :         aChain.SetPrev( rChain.GetPrev() );
     210           0 :         m_rSwdoc.SetAttr( aChain, *rChain.GetNext() );
     211             :     }
     212             : 
     213        4226 :     const SwNodeIndex* pCntIdx = 0;
     214             :     // The draw format doesn't own its content, it just has a pointer to it.
     215        4226 :     if (pFmt->Which() != RES_DRAWFRMFMT)
     216        1978 :         pCntIdx = pFmt->GetCntnt().GetCntntIdx();
     217        4226 :     if (pCntIdx && !m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
     218             :     {
     219             :         // Disconnect if it's an OLE object
     220         654 :         SwOLENode* pOLENd = m_rSwdoc.GetNodes()[ pCntIdx->GetIndex()+1 ]->GetOLENode();
     221         654 :         if( pOLENd && pOLENd->GetOLEObj().IsOleRef() )
     222             :         {
     223             : 
     224             :             // TODO: the old object closed the object and cleared all references to it, but didn't remove it from the container.
     225             :             // I have no idea, why, nobody could explain it - so I do my very best to mimic this behavior
     226             :             //uno::Reference < util::XCloseable > xClose( pOLENd->GetOLEObj().GetOleRef(), uno::UNO_QUERY );
     227             :             //if ( xClose.is() )
     228             :             {
     229             :                 try
     230             :                 {
     231          38 :                     pOLENd->GetOLEObj().GetOleRef()->changeState( embed::EmbedStates::LOADED );
     232             :                 }
     233           0 :                 catch ( uno::Exception& )
     234             :                 {
     235             :                 }
     236             :             }
     237             : 
     238             :         }
     239             :     }
     240             : 
     241             :     // Destroy Frames
     242        4226 :     pFmt->DelFrms();
     243             : 
     244             :     // Only FlyFrames are undoable at first
     245        4226 :     const sal_uInt16 nWh = pFmt->Which();
     246        4238 :     if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo() &&
     247           2 :         (RES_FLYFRMFMT == nWh || RES_DRAWFRMFMT == nWh))
     248             :     {
     249          12 :         m_rSwdoc.GetIDocumentUndoRedo().AppendUndo( new SwUndoDelLayFmt( pFmt ));
     250             :     }
     251             :     else
     252             :     {
     253             :         // #i32089# - delete at-frame anchored objects
     254        4214 :         if ( nWh == RES_FLYFRMFMT )
     255             :         {
     256             :             // determine frame formats of at-frame anchored objects
     257        1968 :             const SwNodeIndex* pCntntIdx = 0;
     258        1968 :             if (pFmt->Which() != RES_DRAWFRMFMT)
     259        1968 :                 pCntntIdx = pFmt->GetCntnt().GetCntntIdx();
     260        1968 :             if (pCntntIdx)
     261             :             {
     262         654 :                 const SwFrmFmts* pTbl = pFmt->GetDoc()->GetSpzFrmFmts();
     263         654 :                 if ( pTbl )
     264             :                 {
     265         654 :                     std::vector<SwFrmFmt*> aToDeleteFrmFmts;
     266         654 :                     const sal_uLong nNodeIdxOfFlyFmt( pCntntIdx->GetIndex() );
     267             : 
     268        7494 :                     for ( sal_uInt16 i = 0; i < pTbl->size(); ++i )
     269             :                     {
     270        6840 :                         SwFrmFmt* pTmpFmt = (*pTbl)[i];
     271        6840 :                         const SwFmtAnchor &rAnch = pTmpFmt->GetAnchor();
     272        6840 :                         if ( rAnch.GetAnchorId() == FLY_AT_FLY &&
     273           0 :                              rAnch.GetCntntAnchor()->nNode.GetIndex() == nNodeIdxOfFlyFmt )
     274             :                         {
     275           0 :                             aToDeleteFrmFmts.push_back( pTmpFmt );
     276             :                         }
     277             :                     }
     278             : 
     279             :                     // delete found frame formats
     280        1308 :                     while ( !aToDeleteFrmFmts.empty() )
     281             :                     {
     282           0 :                         SwFrmFmt* pTmpFmt = aToDeleteFrmFmts.back();
     283           0 :                         pFmt->GetDoc()->getIDocumentLayoutAccess().DelLayoutFmt( pTmpFmt );
     284             : 
     285           0 :                         aToDeleteFrmFmts.pop_back();
     286         654 :                     }
     287             :                 }
     288             :             }
     289             :         }
     290             : 
     291             :         // Delete content
     292        4214 :         if( pCntIdx )
     293             :         {
     294         654 :             SwNode *pNode = &pCntIdx->GetNode();
     295         654 :             ((SwFmtCntnt&)pFmt->GetFmtAttr( RES_CNTNT )).SetNewCntntIdx( 0 );
     296         654 :             m_rSwdoc.getIDocumentContentOperations().DeleteSection( pNode );
     297             :         }
     298             : 
     299             :         // Delete the character for FlyFrames anchored as char (if necessary)
     300        4214 :         const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
     301        4214 :         if ((FLY_AS_CHAR == rAnchor.GetAnchorId()) && rAnchor.GetCntntAnchor())
     302             :         {
     303         504 :             const SwPosition* pPos = rAnchor.GetCntntAnchor();
     304         504 :             SwTxtNode *pTxtNd = pPos->nNode.GetNode().GetTxtNode();
     305             : 
     306             :             // attribute is still in text node, delete it
     307         504 :             if ( pTxtNd )
     308             :             {
     309             :                 SwTxtFlyCnt* const pAttr = static_cast<SwTxtFlyCnt*>(
     310             :                     pTxtNd->GetTxtAttrForCharAt( pPos->nContent.GetIndex(),
     311         292 :                         RES_TXTATR_FLYCNT ));
     312         292 :                 if ( pAttr && (pAttr->GetFlyCnt().GetFrmFmt() == pFmt) )
     313             :                 {
     314             :                     // dont delete, set pointer to 0
     315           0 :                     const_cast<SwFmtFlyCnt&>(pAttr->GetFlyCnt()).SetFlyFmt();
     316           0 :                     SwIndex aIdx( pPos->nContent );
     317           0 :                     pTxtNd->EraseText( aIdx, 1 );
     318             :                 }
     319             :             }
     320             :         }
     321             : 
     322        4214 :         m_rSwdoc.DelFrmFmt( pFmt );
     323             :     }
     324        4226 :     m_rSwdoc.getIDocumentState().SetModified();
     325        4226 : }
     326             : 
     327             : /** Copies the stated format (pSrc) to pDest and returns pDest.
     328             : 
     329             :     If there's no pDest, it is created.
     330             :     If the source format is located in another document, also copy correctly
     331             :     in this case.
     332             :     The Anchor attribute's position is always set to 0! */
     333        1156 : SwFrmFmt *DocumentLayoutManager::CopyLayoutFmt(
     334             :     const SwFrmFmt& rSource,
     335             :     const SwFmtAnchor& rNewAnchor,
     336             :     bool bSetTxtFlyAtt,
     337             :     bool bMakeFrms )
     338             : {
     339        1156 :     const bool bFly = RES_FLYFRMFMT == rSource.Which();
     340        1156 :     const bool bDraw = RES_DRAWFRMFMT == rSource.Which();
     341             :     OSL_ENSURE( bFly || bDraw, "this method only works for fly or draw" );
     342             : 
     343        1156 :     SwDoc* pSrcDoc = (SwDoc*)rSource.GetDoc();
     344             : 
     345             :     // May we copy this object?
     346             :     // We may, unless it's 1) it's a control (and therfore a draw)
     347             :     //                     2) anchored in a header/footer
     348             :     //                     3) anchored (to paragraph?)
     349        1156 :     bool bMayNotCopy = false;
     350        1156 :     if( bDraw )
     351             :     {
     352             :         const SwDrawContact* pDrawContact =
     353         450 :             static_cast<const SwDrawContact*>( rSource.FindContactObj() );
     354             : 
     355             :         bMayNotCopy =
     356         632 :             ((FLY_AT_PARA == rNewAnchor.GetAnchorId()) ||
     357         364 :              (FLY_AT_FLY  == rNewAnchor.GetAnchorId()) ||
     358         556 :              (FLY_AT_CHAR == rNewAnchor.GetAnchorId())) &&
     359         748 :             rNewAnchor.GetCntntAnchor() &&
     360         720 :             m_rSwdoc.IsInHeaderFooter( rNewAnchor.GetCntntAnchor()->nNode ) &&
     361         346 :             pDrawContact != NULL  &&
     362        1142 :             pDrawContact->GetMaster() != NULL  &&
     363         796 :             CheckControlLayer( pDrawContact->GetMaster() );
     364             :     }
     365             : 
     366             :     // just return if we can't copy this
     367        1156 :     if( bMayNotCopy )
     368           0 :         return NULL;
     369             : 
     370        1156 :     SwFrmFmt* pDest = m_rSwdoc.GetDfltFrmFmt();
     371        1156 :     if( rSource.GetRegisteredIn() != pSrcDoc->GetDfltFrmFmt() )
     372         706 :         pDest = m_rSwdoc.CopyFrmFmt( *(SwFrmFmt*)rSource.GetRegisteredIn() );
     373        1156 :     if( bFly )
     374             :     {
     375             :         // #i11176#
     376             :         // To do a correct cloning concerning the ZOrder for all objects
     377             :         // it is necessary to actually create a draw object for fly frames, too.
     378             :         // These are then added to the DrawingLayer (which needs to exist).
     379             :         // Together with correct sorting of all drawinglayer based objects
     380             :         // before cloning ZOrder transfer works correctly then.
     381         706 :         SwFlyFrmFmt *pFormat = m_rSwdoc.MakeFlyFrmFmt( rSource.GetName(), pDest );
     382         706 :         pDest = pFormat;
     383             : 
     384         706 :         SwXFrame::GetOrCreateSdrObject(*pFormat);
     385             :     }
     386             :     else
     387         450 :         pDest = m_rSwdoc.MakeDrawFrmFmt( OUString(), pDest );
     388             : 
     389             :     // Copy all other or new attributes
     390        1156 :     pDest->CopyAttrs( rSource );
     391             : 
     392             :     // Do not copy chains
     393        1156 :     pDest->ResetFmtAttr( RES_CHAIN );
     394             : 
     395        1156 :     if( bFly )
     396             :     {
     397             :         // Duplicate the content.
     398         706 :         const SwNode& rCSttNd = rSource.GetCntnt().GetCntntIdx()->GetNode();
     399         706 :         SwNodeRange aRg( rCSttNd, 1, *rCSttNd.EndOfSectionNode() );
     400             : 
     401        1412 :         SwNodeIndex aIdx( m_rSwdoc.GetNodes().GetEndOfAutotext() );
     402         706 :         SwStartNode* pSttNd = m_rSwdoc.GetNodes().MakeEmptySection( aIdx, SwFlyStartNode );
     403             : 
     404             :         // Set the Anchor/CntntIndex first.
     405             :         // Within the copying part, we can access the values (DrawFmt in Headers and Footers)
     406         706 :         aIdx = *pSttNd;
     407        1412 :         SwFmtCntnt aAttr( rSource.GetCntnt() );
     408         706 :         aAttr.SetNewCntntIdx( &aIdx );
     409         706 :         pDest->SetFmtAttr( aAttr );
     410         706 :         pDest->SetFmtAttr( rNewAnchor );
     411             : 
     412         706 :         if( !m_rSwdoc.IsCopyIsMove() || &m_rSwdoc != pSrcDoc )
     413             :         {
     414         656 :             if( m_rSwdoc.IsInReading() || m_rSwdoc.IsInMailMerge() )
     415         628 :                 pDest->SetName( OUString() );
     416             :             else
     417             :             {
     418             :                 // Test first if the name is already taken, if so generate a new one.
     419          28 :                 sal_Int8 nNdTyp = aRg.aStart.GetNode().GetNodeType();
     420             : 
     421          28 :                 OUString sOld( pDest->GetName() );
     422          28 :                 pDest->SetName( OUString() );
     423          28 :                 if( m_rSwdoc.FindFlyByName( sOld, nNdTyp ) )     // found one
     424           2 :                     switch( nNdTyp )
     425             :                     {
     426           0 :                     case ND_GRFNODE:    sOld = m_rSwdoc.GetUniqueGrfName();      break;
     427           0 :                     case ND_OLENODE:    sOld = m_rSwdoc.GetUniqueOLEName();      break;
     428           2 :                     default:            sOld = m_rSwdoc.GetUniqueFrameName();    break;
     429             :                     }
     430             : 
     431          28 :                 pDest->SetName( sOld );
     432             :             }
     433             :         }
     434             : 
     435         706 :         if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
     436             :         {
     437           4 :             m_rSwdoc.GetIDocumentUndoRedo().AppendUndo(new SwUndoInsLayFmt(pDest,0,0));
     438             :         }
     439             : 
     440             :         // Make sure that FlyFrames in FlyFrames are copied
     441         706 :         aIdx = *pSttNd->EndOfSectionNode();
     442             : 
     443             :         //fdo#36631 disable (scoped) any undo operations associated with the
     444             :         //contact object itself. They should be managed by SwUndoInsLayFmt.
     445         706 :         const ::sw::DrawUndoGuard drawUndoGuard(m_rSwdoc.GetIDocumentUndoRedo());
     446             : 
     447        1412 :         pSrcDoc->GetDocumentContentOperationsManager().CopyWithFlyInFly( aRg, 0, aIdx, NULL, false, true, true );
     448             :     }
     449             :     else
     450             :     {
     451             :         OSL_ENSURE( RES_DRAWFRMFMT == rSource.Which(), "Neither Fly nor Draw." );
     452             :         // #i52780# - Note: moving object to visible layer not needed.
     453         450 :         SwDrawContact* pSourceContact = (SwDrawContact *)rSource.FindContactObj();
     454             : 
     455             :         SwDrawContact* pContact = new SwDrawContact( (SwDrawFrmFmt*)pDest,
     456         450 :                                 m_rSwdoc.CloneSdrObj( *pSourceContact->GetMaster(),
     457         900 :                                         m_rSwdoc.IsCopyIsMove() && &m_rSwdoc == pSrcDoc ) );
     458             :         // #i49730# - notify draw frame format that position attributes are
     459             :         // already set, if the position attributes are already set at the
     460             :         // source draw frame format.
     461        1350 :         if ( pDest->ISA(SwDrawFrmFmt) &&
     462         900 :              rSource.ISA(SwDrawFrmFmt) &&
     463         450 :              static_cast<const SwDrawFrmFmt&>(rSource).IsPosAttrSet() )
     464             :         {
     465          48 :             static_cast<SwDrawFrmFmt*>(pDest)->PosAttrSet();
     466             :         }
     467             : 
     468         450 :         if( pDest->GetAnchor() == rNewAnchor )
     469             :         {
     470             :             // Do *not* connect to layout, if a <MakeFrms> will not be called.
     471          64 :             if ( bMakeFrms )
     472             :             {
     473          20 :                 pContact->ConnectToLayout( &rNewAnchor );
     474             :             }
     475             :         }
     476             :         else
     477         386 :             pDest->SetFmtAttr( rNewAnchor );
     478             : 
     479         450 :         if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
     480             :         {
     481          18 :             m_rSwdoc.GetIDocumentUndoRedo().AppendUndo(new SwUndoInsLayFmt(pDest,0,0));
     482             :         }
     483             :     }
     484             : 
     485        1156 :     if (bSetTxtFlyAtt && (FLY_AS_CHAR == rNewAnchor.GetAnchorId()))
     486             :     {
     487           0 :         const SwPosition* pPos = rNewAnchor.GetCntntAnchor();
     488           0 :         SwFmtFlyCnt aFmt( pDest );
     489           0 :         pPos->nNode.GetNode().GetTxtNode()->InsertItem(
     490           0 :             aFmt, pPos->nContent.GetIndex(), 0 );
     491             :     }
     492             : 
     493        1156 :     if( bMakeFrms )
     494         884 :         pDest->MakeFrms();
     495             : 
     496             :     // If the draw format has a TextBox, then copy its fly format as well.
     497        1156 :     if (SwFrmFmt* pSourceTextBox = SwTextBoxHelper::findTextBox(&rSource))
     498             :     {
     499           4 :         SwFrmFmt* pDestTextBox = CopyLayoutFmt(*pSourceTextBox, rNewAnchor, bSetTxtFlyAtt, bMakeFrms);
     500           4 :         SwAttrSet aSet(pDest->GetAttrSet());
     501           8 :         SwFmtCntnt aCntnt(pDestTextBox->GetCntnt().GetCntntIdx()->GetNode().GetStartNode());
     502           4 :         aSet.Put(aCntnt);
     503           8 :         pDest->SetFmtAttr(aSet);
     504             :     }
     505             : 
     506        1156 :     return pDest;
     507             : }
     508             : 
     509             : //Load document from fdo#42534 under valgrind, drag the scrollbar down so full
     510             : //document layout is triggered. Close document before layout has completed, and
     511             : //SwAnchoredObject objects deleted by the deletion of layout remain referenced
     512             : //by the SwLayouter
     513     1667852 : void DocumentLayoutManager::ClearSwLayouterEntries()
     514             : {
     515     1667852 :     SwLayouter::ClearMovedFwdFrms( m_rSwdoc );
     516     1667852 :     SwLayouter::ClearObjsTmpConsiderWrapInfluence( m_rSwdoc );
     517             :     // #i65250#
     518     1667852 :     SwLayouter::ClearMoveBwdLayoutInfo( m_rSwdoc );
     519     1667852 : }
     520             : 
     521       15135 : DocumentLayoutManager::~DocumentLayoutManager()
     522             : {
     523        5045 :     delete mpLayouter;
     524        5045 :     mpLayouter = 0L;
     525       10090 : }
     526             : 
     527         270 : }
     528             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
     529             : 

Generated by: LCOV version 1.10