LCOV - code coverage report
Current view: top level - sw/source/core/undo - undraw.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 20 288 6.9 %
Date: 2012-08-25 Functions: 6 36 16.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 14 320 4.4 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <UndoDraw.hxx>
      31                 :            : 
      32                 :            : #include <rtl/string.h>
      33                 :            : #include <rtl/memory.h>
      34                 :            : 
      35                 :            : #include <svx/svdogrp.hxx>
      36                 :            : #include <svx/svdundo.hxx>
      37                 :            : #include <svx/svdpage.hxx>
      38                 :            : #include <svx/svdmark.hxx>
      39                 :            : 
      40                 :            : #include <hintids.hxx>
      41                 :            : #include <hints.hxx>
      42                 :            : #include <fmtanchr.hxx>
      43                 :            : #include <fmtflcnt.hxx>
      44                 :            : #include <txtflcnt.hxx>
      45                 :            : #include <frmfmt.hxx>
      46                 :            : #include <doc.hxx>
      47                 :            : #include <IDocumentUndoRedo.hxx>
      48                 :            : #include <docary.hxx>
      49                 :            : #include <frame.hxx>
      50                 :            : #include <swundo.hxx>           // fuer die UndoIds
      51                 :            : #include <pam.hxx>
      52                 :            : #include <ndtxt.hxx>
      53                 :            : #include <UndoCore.hxx>
      54                 :            : #include <dcontact.hxx>
      55                 :            : #include <dview.hxx>
      56                 :            : #include <rootfrm.hxx>
      57                 :            : #include <viewsh.hxx>
      58                 :            : 
      59                 :            : 
      60                 :            : struct SwUndoGroupObjImpl
      61                 :            : {
      62                 :            :     SwDrawFrmFmt* pFmt;
      63                 :            :     SdrObject* pObj;
      64                 :            :     sal_uLong nNodeIdx;
      65                 :            : };
      66                 :            : 
      67                 :            : 
      68                 :            : // Draw-Objecte
      69                 :            : 
      70                 :      11234 : IMPL_LINK( SwDoc, AddDrawUndo, SdrUndoAction *, pUndo )
      71                 :            : {
      72                 :            : #if OSL_DEBUG_LEVEL > 1
      73                 :            :     sal_uInt16 nId = pUndo->GetId();
      74                 :            :     (void)nId;
      75                 :            :     String sComment( pUndo->GetComment() );
      76                 :            : #endif
      77                 :            : 
      78   [ +  -  +  - ]:      22468 :     if (GetIDocumentUndoRedo().DoesUndo() &&
                 [ +  - ]
      79                 :      11234 :         GetIDocumentUndoRedo().DoesDrawUndo())
      80                 :            :     {
      81                 :      11234 :         const SdrMarkList* pMarkList = 0;
      82                 :      11234 :         ViewShell* pSh = GetCurrentViewShell();
      83 [ +  - ][ +  - ]:      11234 :         if( pSh && pSh->HasDrawView() )
                 [ +  - ]
      84                 :      11234 :             pMarkList = &pSh->GetDrawView()->GetMarkedObjectList();
      85                 :            : 
      86         [ +  - ]:      11234 :         GetIDocumentUndoRedo().AppendUndo( new SwSdrUndo(pUndo, pMarkList) );
      87                 :            :     }
      88                 :            :     else
      89         [ #  # ]:          0 :         delete pUndo;
      90                 :      11234 :     return 0;
      91                 :            : }
      92                 :            : 
      93                 :      11234 : SwSdrUndo::SwSdrUndo( SdrUndoAction* pUndo, const SdrMarkList* pMrkLst )
      94                 :      11234 :     : SwUndo( UNDO_DRAWUNDO ), pSdrUndo( pUndo )
      95                 :            : {
      96 [ -  + ][ -  + ]:      11234 :     if( pMrkLst && pMrkLst->GetMarkCount() )
                 [ +  - ]
      97 [ #  # ][ #  # ]:          0 :         pMarkList = new SdrMarkList( *pMrkLst );
      98                 :            :     else
      99                 :      11234 :         pMarkList = 0;
     100                 :      11234 : }
     101                 :            : 
     102                 :      11234 : SwSdrUndo::~SwSdrUndo()
     103                 :            : {
     104 [ +  - ][ +  - ]:      11234 :     delete pSdrUndo;
     105 [ -  + ][ #  # ]:      11234 :     delete pMarkList;
     106         [ -  + ]:      22468 : }
     107                 :            : 
     108                 :          0 : void SwSdrUndo::UndoImpl(::sw::UndoRedoContext & rContext)
     109                 :            : {
     110                 :          0 :     pSdrUndo->Undo();
     111                 :          0 :     rContext.SetSelections(0, pMarkList);
     112                 :          0 : }
     113                 :            : 
     114                 :          0 : void SwSdrUndo::RedoImpl(::sw::UndoRedoContext & rContext)
     115                 :            : {
     116                 :          0 :     pSdrUndo->Redo();
     117                 :          0 :     rContext.SetSelections(0, pMarkList);
     118                 :          0 : }
     119                 :            : 
     120                 :      11352 : rtl::OUString SwSdrUndo::GetComment() const
     121                 :            : {
     122                 :      11352 :     return pSdrUndo->GetComment();
     123                 :            : }
     124                 :            : 
     125                 :            : //--------------------------------------------
     126                 :            : 
     127                 :          0 : void lcl_SendRemoveToUno( SwFmt& rFmt )
     128                 :            : {
     129         [ #  # ]:          0 :     SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, &rFmt );
     130 [ #  # ][ #  # ]:          0 :     rFmt.ModifyNotification( &aMsgHint, &aMsgHint );
     131                 :          0 : }
     132                 :            : 
     133                 :          0 : void lcl_SaveAnchor( SwFrmFmt* pFmt, sal_uLong& rNodePos )
     134                 :            : {
     135                 :          0 :     const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
     136 [ #  # ][ #  #  :          0 :     if ((FLY_AT_PARA == rAnchor.GetAnchorId()) ||
          #  #  #  #  #  
                      # ]
     137                 :          0 :         (FLY_AT_CHAR == rAnchor.GetAnchorId()) ||
     138                 :          0 :         (FLY_AT_FLY  == rAnchor.GetAnchorId()) ||
     139                 :          0 :         (FLY_AS_CHAR == rAnchor.GetAnchorId()))
     140                 :            :     {
     141                 :          0 :         rNodePos = rAnchor.GetCntntAnchor()->nNode.GetIndex();
     142                 :          0 :         xub_StrLen nCntntPos = 0;
     143                 :            : 
     144         [ #  # ]:          0 :         if (FLY_AS_CHAR == rAnchor.GetAnchorId())
     145                 :            :         {
     146                 :          0 :             nCntntPos = rAnchor.GetCntntAnchor()->nContent.GetIndex();
     147                 :            : 
     148                 :            :             // destroy TextAttribute
     149                 :          0 :             SwTxtNode *pTxtNd = pFmt->GetDoc()->GetNodes()[ rNodePos ]->GetTxtNode();
     150                 :            :             OSL_ENSURE( pTxtNd, "No text node found!" );
     151                 :            :             SwTxtFlyCnt* pAttr = static_cast<SwTxtFlyCnt*>(
     152                 :          0 :                 pTxtNd->GetTxtAttrForCharAt( nCntntPos, RES_TXTATR_FLYCNT ));
     153                 :            :             // attribute still in text node, delete
     154 [ #  # ][ #  # ]:          0 :             if( pAttr && pAttr->GetFlyCnt().GetFrmFmt() == pFmt )
                 [ #  # ]
     155                 :            :             {
     156                 :            :                 // just set pointer to 0, don't delete
     157                 :          0 :                 ((SwFmtFlyCnt&)pAttr->GetFlyCnt()).SetFlyFmt();
     158 [ #  # ][ #  # ]:          0 :                 SwIndex aIdx( pTxtNd, nCntntPos );
     159 [ #  # ][ #  # ]:          0 :                 pTxtNd->EraseText( aIdx, 1 );
     160                 :            :             }
     161                 :            :         }
     162         [ #  # ]:          0 :         else if (FLY_AT_CHAR == rAnchor.GetAnchorId())
     163                 :            :         {
     164                 :          0 :             nCntntPos = rAnchor.GetCntntAnchor()->nContent.GetIndex();
     165                 :            :         }
     166                 :            : 
     167         [ #  # ]:          0 :         pFmt->SetFmtAttr( SwFmtAnchor( rAnchor.GetAnchorId(), nCntntPos ) );
     168                 :            :     }
     169                 :          0 : }
     170                 :            : 
     171                 :          0 : void lcl_RestoreAnchor( SwFrmFmt* pFmt, sal_uLong& rNodePos )
     172                 :            : {
     173                 :          0 :     const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
     174 [ #  # ][ #  #  :          0 :     if ((FLY_AT_PARA == rAnchor.GetAnchorId()) ||
          #  #  #  #  #  
                      # ]
     175                 :          0 :         (FLY_AT_CHAR == rAnchor.GetAnchorId()) ||
     176                 :          0 :         (FLY_AT_FLY  == rAnchor.GetAnchorId()) ||
     177                 :          0 :         (FLY_AS_CHAR == rAnchor.GetAnchorId()))
     178                 :            :     {
     179                 :          0 :         xub_StrLen nCntntPos = rAnchor.GetPageNum();
     180         [ #  # ]:          0 :         SwNodes& rNds = pFmt->GetDoc()->GetNodes();
     181                 :            : 
     182         [ #  # ]:          0 :         SwNodeIndex aIdx( rNds, rNodePos );
     183         [ #  # ]:          0 :         SwPosition aPos( aIdx );
     184                 :            : 
     185         [ #  # ]:          0 :         SwFmtAnchor aTmp( rAnchor.GetAnchorId() );
     186   [ #  #  #  # ]:          0 :         if ((FLY_AS_CHAR == rAnchor.GetAnchorId()) ||
                 [ #  # ]
     187                 :          0 :             (FLY_AT_CHAR == rAnchor.GetAnchorId()))
     188                 :            :         {
     189 [ #  # ][ #  # ]:          0 :             aPos.nContent.Assign( aIdx.GetNode().GetCntntNode(), nCntntPos );
     190                 :            :         }
     191         [ #  # ]:          0 :         aTmp.SetAnchor( &aPos );
     192         [ #  # ]:          0 :         pFmt->SetFmtAttr( aTmp );
     193                 :            : 
     194         [ #  # ]:          0 :         if (FLY_AS_CHAR == rAnchor.GetAnchorId())
     195                 :            :         {
     196                 :          0 :             SwTxtNode *pTxtNd = aIdx.GetNode().GetTxtNode();
     197                 :            :             OSL_ENSURE( pTxtNd, "no Text Node" );
     198         [ #  # ]:          0 :             SwFmtFlyCnt aFmt( pFmt );
     199 [ #  # ][ #  # ]:          0 :             pTxtNd->InsertItem( aFmt, nCntntPos, nCntntPos );
     200 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     201                 :            :     }
     202                 :          0 : }
     203                 :            : 
     204                 :          0 : SwUndoDrawGroup::SwUndoDrawGroup( sal_uInt16 nCnt )
     205                 :          0 :     : SwUndo( UNDO_DRAWGROUP ), nSize( nCnt + 1 ), bDelFmt( sal_True )
     206                 :            : {
     207         [ #  # ]:          0 :     pObjArr = new SwUndoGroupObjImpl[ nSize ];
     208                 :          0 : }
     209                 :            : 
     210                 :          0 : SwUndoDrawGroup::~SwUndoDrawGroup()
     211                 :            : {
     212         [ #  # ]:          0 :     if( bDelFmt )
     213                 :            :     {
     214                 :          0 :         SwUndoGroupObjImpl* pTmp = pObjArr + 1;
     215         [ #  # ]:          0 :         for( sal_uInt16 n = 1; n < nSize; ++n, ++pTmp )
     216 [ #  # ][ #  # ]:          0 :             delete pTmp->pFmt;
     217                 :            :     }
     218                 :            :     else
     219 [ #  # ][ #  # ]:          0 :         delete pObjArr->pFmt;
     220                 :            : 
     221         [ #  # ]:          0 :     delete [] pObjArr;
     222         [ #  # ]:          0 : }
     223                 :            : 
     224                 :          0 : void SwUndoDrawGroup::UndoImpl(::sw::UndoRedoContext &)
     225                 :            : {
     226                 :          0 :     bDelFmt = sal_False;
     227                 :            : 
     228                 :            :     // save group object
     229                 :          0 :     SwDrawFrmFmt* pFmt = pObjArr->pFmt;
     230         [ #  # ]:          0 :     SwDrawContact* pDrawContact = (SwDrawContact*)pFmt->FindContactObj();
     231         [ #  # ]:          0 :     SdrObject* pObj = pDrawContact->GetMaster();
     232                 :          0 :     pObjArr->pObj = pObj;
     233                 :            : 
     234                 :            :     // object will destroy itself
     235 [ #  # ][ #  # ]:          0 :     pDrawContact->Changed( *pObj, SDRUSERCALL_DELETE, pObj->GetLastBoundRect() );
     236         [ #  # ]:          0 :     pObj->SetUserCall( 0 );
     237                 :            : 
     238         [ #  # ]:          0 :     ::lcl_SaveAnchor( pFmt, pObjArr->nNodeIdx );
     239                 :            : 
     240                 :            :     // notify UNO objects to decouple
     241         [ #  # ]:          0 :     ::lcl_SendRemoveToUno( *pFmt );
     242                 :            : 
     243                 :            :     // remove from array
     244                 :          0 :     SwDoc* pDoc = pFmt->GetDoc();
     245                 :          0 :     SwFrmFmts& rFlyFmts = *(SwFrmFmts*)pDoc->GetSpzFrmFmts();
     246 [ #  # ][ #  # ]:          0 :     rFlyFmts.erase( std::find( rFlyFmts.begin(), rFlyFmts.end(), pFmt ));
     247                 :            : 
     248         [ #  # ]:          0 :     for( sal_uInt16 n = 1; n < nSize; ++n )
     249                 :            :     {
     250                 :          0 :         SwUndoGroupObjImpl& rSave = *( pObjArr + n );
     251                 :            : 
     252         [ #  # ]:          0 :         ::lcl_RestoreAnchor( rSave.pFmt, rSave.nNodeIdx );
     253         [ #  # ]:          0 :         rFlyFmts.push_back( rSave.pFmt );
     254                 :            : 
     255                 :          0 :         pObj = rSave.pObj;
     256                 :            : 
     257 [ #  # ][ #  # ]:          0 :         SwDrawContact *pContact = new SwDrawContact( rSave.pFmt, pObj );
     258         [ #  # ]:          0 :         pContact->ConnectToLayout();
     259                 :            :         // #i45718# - follow-up of #i35635# move object to visible layer
     260         [ #  # ]:          0 :         pContact->MoveObjToVisibleLayer( pObj );
     261                 :            :         // #i45952# - notify that position attributes are already set
     262                 :            :         OSL_ENSURE( rSave.pFmt->ISA(SwDrawFrmFmt),
     263                 :            :                 "<SwUndoDrawGroup::Undo(..)> - wrong type of frame format for drawing object" );
     264 [ #  # ][ #  # ]:          0 :         if ( rSave.pFmt->ISA(SwDrawFrmFmt) )
                 [ #  # ]
     265                 :            :         {
     266                 :          0 :             static_cast<SwDrawFrmFmt*>(rSave.pFmt)->PosAttrSet();
     267                 :            :         }
     268                 :            :     }
     269                 :          0 : }
     270                 :            : 
     271                 :          0 : void SwUndoDrawGroup::RedoImpl(::sw::UndoRedoContext &)
     272                 :            : {
     273                 :          0 :     bDelFmt = sal_True;
     274                 :            : 
     275                 :            :     // remove from array
     276                 :          0 :     SwDoc* pDoc = pObjArr->pFmt->GetDoc();
     277                 :          0 :     SwFrmFmts& rFlyFmts = *(SwFrmFmts*)pDoc->GetSpzFrmFmts();
     278                 :            :     SdrObject* pObj;
     279                 :            : 
     280         [ #  # ]:          0 :     for( sal_uInt16 n = 1; n < nSize; ++n )
     281                 :            :     {
     282                 :          0 :         SwUndoGroupObjImpl& rSave = *( pObjArr + n );
     283                 :            : 
     284                 :          0 :         pObj = rSave.pObj;
     285                 :            : 
     286                 :          0 :         SwDrawContact *pContact = (SwDrawContact*)GetUserCall(pObj);
     287                 :            : 
     288                 :            :         // object will destroy itself
     289                 :          0 :         pContact->Changed( *pObj, SDRUSERCALL_DELETE, pObj->GetLastBoundRect() );
     290                 :          0 :         pObj->SetUserCall( 0 );
     291                 :            : 
     292                 :          0 :         ::lcl_SaveAnchor( rSave.pFmt, rSave.nNodeIdx );
     293                 :            : 
     294                 :            :         // notify UNO objects to decouple
     295                 :          0 :         ::lcl_SendRemoveToUno( *rSave.pFmt );
     296                 :            : 
     297                 :          0 :         rFlyFmts.erase( std::find( rFlyFmts.begin(), rFlyFmts.end(), rSave.pFmt ));
     298                 :            :     }
     299                 :            : 
     300                 :            :     // re-insert group object
     301                 :          0 :     ::lcl_RestoreAnchor( pObjArr->pFmt, pObjArr->nNodeIdx );
     302         [ #  # ]:          0 :     rFlyFmts.push_back( pObjArr->pFmt );
     303                 :            : 
     304         [ #  # ]:          0 :     SwDrawContact *pContact = new SwDrawContact( pObjArr->pFmt, pObjArr->pObj );
     305                 :            :     // #i26791# - correction: connect object to layout
     306                 :          0 :     pContact->ConnectToLayout();
     307                 :            :     // #i45718# - follow-up of #i35635# move object to visible layer
     308                 :          0 :     pContact->MoveObjToVisibleLayer( pObjArr->pObj );
     309                 :            :     // #i45952# - notify that position attributes are already set
     310                 :            :     OSL_ENSURE( pObjArr->pFmt->ISA(SwDrawFrmFmt),
     311                 :            :             "<SwUndoDrawGroup::Undo(..)> - wrong type of frame format for drawing object" );
     312         [ #  # ]:          0 :     if ( pObjArr->pFmt->ISA(SwDrawFrmFmt) )
     313                 :            :     {
     314                 :          0 :         static_cast<SwDrawFrmFmt*>(pObjArr->pFmt)->PosAttrSet();
     315                 :            :     }
     316                 :          0 : }
     317                 :            : 
     318                 :          0 : void SwUndoDrawGroup::AddObj( sal_uInt16 nPos, SwDrawFrmFmt* pFmt, SdrObject* pObj )
     319                 :            : {
     320                 :          0 :     SwUndoGroupObjImpl& rSave = *( pObjArr + nPos + 1 );
     321                 :          0 :     rSave.pObj = pObj;
     322                 :          0 :     rSave.pFmt = pFmt;
     323                 :          0 :     ::lcl_SaveAnchor( pFmt, rSave.nNodeIdx );
     324                 :            : 
     325                 :            :        // notify UNO objects to decouple
     326                 :          0 :     ::lcl_SendRemoveToUno( *pFmt );
     327                 :            : 
     328                 :            :     // remove from array
     329                 :          0 :     SwFrmFmts& rFlyFmts = *(SwFrmFmts*)pFmt->GetDoc()->GetSpzFrmFmts();
     330                 :          0 :     rFlyFmts.erase( std::find( rFlyFmts.begin(), rFlyFmts.end(), pFmt ));
     331                 :          0 : }
     332                 :            : 
     333                 :          0 : void SwUndoDrawGroup::SetGroupFmt( SwDrawFrmFmt* pFmt )
     334                 :            : {
     335                 :          0 :     pObjArr->pObj = 0;
     336                 :          0 :     pObjArr->pFmt = pFmt;
     337                 :          0 : }
     338                 :            : 
     339                 :            : 
     340                 :            : // ------------------------------
     341                 :            : 
     342                 :          0 : SwUndoDrawUnGroup::SwUndoDrawUnGroup( SdrObjGroup* pObj )
     343                 :          0 :     : SwUndo( UNDO_DRAWUNGROUP ), bDelFmt( sal_False )
     344                 :            : {
     345 [ #  # ][ #  # ]:          0 :     nSize = (sal_uInt16)pObj->GetSubList()->GetObjCount() + 1;
     346         [ #  # ]:          0 :     pObjArr = new SwUndoGroupObjImpl[ nSize ];
     347                 :            : 
     348         [ #  # ]:          0 :     SwDrawContact *pContact = (SwDrawContact*)GetUserCall(pObj);
     349                 :          0 :     SwDrawFrmFmt* pFmt = (SwDrawFrmFmt*)pContact->GetFmt();
     350                 :            : 
     351                 :          0 :     pObjArr->pObj = pObj;
     352                 :          0 :     pObjArr->pFmt = pFmt;
     353                 :            : 
     354                 :            :     // object will destroy itself
     355 [ #  # ][ #  # ]:          0 :     pContact->Changed( *pObj, SDRUSERCALL_DELETE, pObj->GetLastBoundRect() );
     356         [ #  # ]:          0 :     pObj->SetUserCall( 0 );
     357                 :            : 
     358         [ #  # ]:          0 :     ::lcl_SaveAnchor( pFmt, pObjArr->nNodeIdx );
     359                 :            : 
     360                 :            :        // notify UNO objects to decouple
     361         [ #  # ]:          0 :     ::lcl_SendRemoveToUno( *pFmt );
     362                 :            : 
     363                 :            :     // remove from array
     364                 :          0 :     SwFrmFmts& rFlyFmts = *(SwFrmFmts*)pFmt->GetDoc()->GetSpzFrmFmts();
     365 [ #  # ][ #  # ]:          0 :     rFlyFmts.erase( std::find( rFlyFmts.begin(), rFlyFmts.end(), pFmt ));
     366                 :          0 : }
     367                 :            : 
     368                 :          0 : SwUndoDrawUnGroup::~SwUndoDrawUnGroup()
     369                 :            : {
     370         [ #  # ]:          0 :     if( bDelFmt )
     371                 :            :     {
     372                 :          0 :         SwUndoGroupObjImpl* pTmp = pObjArr + 1;
     373         [ #  # ]:          0 :         for( sal_uInt16 n = 1; n < nSize; ++n, ++pTmp )
     374 [ #  # ][ #  # ]:          0 :             delete pTmp->pFmt;
     375                 :            :     }
     376                 :            :     else
     377 [ #  # ][ #  # ]:          0 :         delete pObjArr->pFmt;
     378                 :            : 
     379         [ #  # ]:          0 :     delete [] pObjArr;
     380         [ #  # ]:          0 : }
     381                 :            : 
     382                 :          0 : void SwUndoDrawUnGroup::UndoImpl(::sw::UndoRedoContext & rContext)
     383                 :            : {
     384                 :          0 :     bDelFmt = sal_True;
     385                 :            : 
     386                 :          0 :     SwDoc *const pDoc = & rContext.GetDoc();
     387                 :          0 :     SwFrmFmts& rFlyFmts = *(SwFrmFmts*)pDoc->GetSpzFrmFmts();
     388                 :            : 
     389                 :            :     // remove from array
     390         [ #  # ]:          0 :     for( sal_uInt16 n = 1; n < nSize; ++n )
     391                 :            :     {
     392                 :          0 :         SwUndoGroupObjImpl& rSave = *( pObjArr + n );
     393                 :            : 
     394                 :          0 :         ::lcl_SaveAnchor( rSave.pFmt, rSave.nNodeIdx );
     395                 :            : 
     396                 :            :            // notify UNO objects to decouple
     397                 :          0 :         ::lcl_SendRemoveToUno( *rSave.pFmt );
     398                 :            : 
     399                 :          0 :         rFlyFmts.erase( std::find( rFlyFmts.begin(), rFlyFmts.end(), rSave.pFmt ));
     400                 :            :     }
     401                 :            : 
     402                 :            :     // re-insert group object
     403                 :          0 :     ::lcl_RestoreAnchor( pObjArr->pFmt, pObjArr->nNodeIdx );
     404         [ #  # ]:          0 :     rFlyFmts.push_back( pObjArr->pFmt );
     405                 :            : 
     406         [ #  # ]:          0 :     SwDrawContact *pContact = new SwDrawContact( pObjArr->pFmt, pObjArr->pObj );
     407                 :          0 :     pContact->ConnectToLayout();
     408                 :            :     // #i45718# - follow-up of #i35635# move object to visible layer
     409                 :          0 :     pContact->MoveObjToVisibleLayer( pObjArr->pObj );
     410                 :            :     // #i45952# - notify that position attributes are already set
     411                 :            :     OSL_ENSURE( pObjArr->pFmt->ISA(SwDrawFrmFmt),
     412                 :            :             "<SwUndoDrawGroup::Undo(..)> - wrong type of frame format for drawing object" );
     413         [ #  # ]:          0 :     if ( pObjArr->pFmt->ISA(SwDrawFrmFmt) )
     414                 :            :     {
     415                 :          0 :         static_cast<SwDrawFrmFmt*>(pObjArr->pFmt)->PosAttrSet();
     416                 :            :     }
     417                 :          0 : }
     418                 :            : 
     419                 :          0 : void SwUndoDrawUnGroup::RedoImpl(::sw::UndoRedoContext &)
     420                 :            : {
     421                 :          0 :     bDelFmt = sal_False;
     422                 :            : 
     423                 :            :     // save group object
     424                 :          0 :     SwDrawFrmFmt* pFmt = pObjArr->pFmt;
     425         [ #  # ]:          0 :     SwDrawContact* pContact = (SwDrawContact*)pFmt->FindContactObj();
     426                 :            : 
     427                 :            :         // object will destroy itself
     428                 :            :     pContact->Changed( *pObjArr->pObj, SDRUSERCALL_DELETE,
     429 [ #  # ][ #  # ]:          0 :         pObjArr->pObj->GetLastBoundRect() );
     430         [ #  # ]:          0 :     pObjArr->pObj->SetUserCall( 0 );
     431                 :            : 
     432         [ #  # ]:          0 :     ::lcl_SaveAnchor( pFmt, pObjArr->nNodeIdx );
     433                 :            : 
     434                 :            :        // notify UNO objects to decouple
     435         [ #  # ]:          0 :     ::lcl_SendRemoveToUno( *pFmt );
     436                 :            : 
     437                 :            :     // remove from array
     438                 :          0 :     SwDoc* pDoc = pFmt->GetDoc();
     439                 :          0 :     SwFrmFmts& rFlyFmts = *(SwFrmFmts*)pDoc->GetSpzFrmFmts();
     440 [ #  # ][ #  # ]:          0 :     rFlyFmts.erase( std::find( rFlyFmts.begin(), rFlyFmts.end(), pFmt ));
     441                 :            : 
     442         [ #  # ]:          0 :     for( sal_uInt16 n = 1; n < nSize; ++n )
     443                 :            :     {
     444                 :          0 :         SwUndoGroupObjImpl& rSave = *( pObjArr + n );
     445                 :            : 
     446         [ #  # ]:          0 :         ::lcl_RestoreAnchor( rSave.pFmt, rSave.nNodeIdx );
     447         [ #  # ]:          0 :         rFlyFmts.push_back( rSave.pFmt );
     448                 :            : 
     449                 :            :         // #i45952# - notify that position attributes are already set
     450                 :            :         OSL_ENSURE( rSave.pFmt->ISA(SwDrawFrmFmt),
     451                 :            :                 "<SwUndoDrawGroup::Undo(..)> - wrong type of frame format for drawing object" );
     452 [ #  # ][ #  # ]:          0 :         if ( rSave.pFmt->ISA(SwDrawFrmFmt) )
                 [ #  # ]
     453                 :            :         {
     454                 :          0 :             static_cast<SwDrawFrmFmt*>(rSave.pFmt)->PosAttrSet();
     455                 :            :         }
     456                 :            :     }
     457                 :          0 : }
     458                 :            : 
     459                 :          0 : void SwUndoDrawUnGroup::AddObj( sal_uInt16 nPos, SwDrawFrmFmt* pFmt )
     460                 :            : {
     461                 :          0 :     SwUndoGroupObjImpl& rSave = *( pObjArr + nPos + 1 );
     462                 :          0 :     rSave.pFmt = pFmt;
     463                 :          0 :     rSave.pObj = 0;
     464                 :          0 : }
     465                 :            : 
     466                 :          0 : SwUndoDrawUnGroupConnectToLayout::SwUndoDrawUnGroupConnectToLayout()
     467         [ #  # ]:          0 :     : SwUndo( UNDO_DRAWUNGROUP )
     468                 :            : {
     469                 :          0 : }
     470                 :            : 
     471                 :          0 : SwUndoDrawUnGroupConnectToLayout::~SwUndoDrawUnGroupConnectToLayout()
     472                 :            : {
     473         [ #  # ]:          0 : }
     474                 :            : 
     475                 :            : void
     476                 :          0 : SwUndoDrawUnGroupConnectToLayout::UndoImpl(::sw::UndoRedoContext &)
     477                 :            : {
     478         [ #  # ]:          0 :     for ( std::vector< SdrObject >::size_type i = 0;
     479                 :          0 :           i < aDrawFmtsAndObjs.size(); ++i )
     480                 :            :     {
     481                 :          0 :         SdrObject* pObj( aDrawFmtsAndObjs[i].second );
     482         [ #  # ]:          0 :         SwDrawContact* pDrawContact( dynamic_cast<SwDrawContact*>(pObj->GetUserCall()) );
     483                 :            :         OSL_ENSURE( pDrawContact,
     484                 :            :                 "<SwUndoDrawUnGroupConnectToLayout::Undo(..)> -- missing SwDrawContact instance" );
     485         [ #  # ]:          0 :         if ( pDrawContact )
     486                 :            :         {
     487                 :            :             // deletion of instance <pDrawContact> and thus disconnection from
     488                 :            :             // the Writer layout.
     489                 :          0 :             pDrawContact->Changed( *pObj, SDRUSERCALL_DELETE, pObj->GetLastBoundRect() );
     490                 :          0 :             pObj->SetUserCall( 0 );
     491                 :            :         }
     492                 :            :     }
     493                 :          0 : }
     494                 :            : 
     495                 :            : void
     496                 :          0 : SwUndoDrawUnGroupConnectToLayout::RedoImpl(::sw::UndoRedoContext &)
     497                 :            : {
     498         [ #  # ]:          0 :     for ( std::vector< std::pair< SwDrawFrmFmt*, SdrObject* > >::size_type i = 0;
     499                 :          0 :           i < aDrawFmtsAndObjs.size(); ++i )
     500                 :            :     {
     501                 :          0 :         SwDrawFrmFmt* pFmt( aDrawFmtsAndObjs[i].first );
     502                 :          0 :         SdrObject* pObj( aDrawFmtsAndObjs[i].second );
     503         [ #  # ]:          0 :         SwDrawContact *pContact = new SwDrawContact( pFmt, pObj );
     504                 :          0 :         pContact->ConnectToLayout();
     505                 :          0 :         pContact->MoveObjToVisibleLayer( pObj );
     506                 :            :     }
     507                 :          0 : }
     508                 :            : 
     509                 :          0 : void SwUndoDrawUnGroupConnectToLayout::AddFmtAndObj( SwDrawFrmFmt* pDrawFrmFmt,
     510                 :            :                                                      SdrObject* pDrawObject )
     511                 :            : {
     512                 :            :     aDrawFmtsAndObjs.push_back(
     513         [ #  # ]:          0 :             std::pair< SwDrawFrmFmt*, SdrObject* >( pDrawFrmFmt, pDrawObject ) );
     514                 :          0 : }
     515                 :            : 
     516                 :            : //-------------------------------------
     517                 :            : 
     518                 :          0 : SwUndoDrawDelete::SwUndoDrawDelete( sal_uInt16 nCnt )
     519                 :          0 :     : SwUndo( UNDO_DRAWDELETE ), nSize( nCnt ), bDelFmt( sal_True )
     520                 :            : {
     521         [ #  # ]:          0 :     pObjArr = new SwUndoGroupObjImpl[ nSize ];
     522 [ #  # ][ #  # ]:          0 :     pMarkLst = new SdrMarkList();
     523                 :          0 : }
     524                 :            : 
     525                 :          0 : SwUndoDrawDelete::~SwUndoDrawDelete()
     526                 :            : {
     527         [ #  # ]:          0 :     if( bDelFmt )
     528                 :            :     {
     529                 :          0 :         SwUndoGroupObjImpl* pTmp = pObjArr;
     530         [ #  # ]:          0 :         for( sal_uInt16 n = 0; n < pMarkLst->GetMarkCount(); ++n, ++pTmp )
     531 [ #  # ][ #  # ]:          0 :             delete pTmp->pFmt;
     532                 :            :     }
     533         [ #  # ]:          0 :     delete [] pObjArr;
     534 [ #  # ][ #  # ]:          0 :     delete pMarkLst;
     535         [ #  # ]:          0 : }
     536                 :            : 
     537                 :          0 : void SwUndoDrawDelete::UndoImpl(::sw::UndoRedoContext & rContext)
     538                 :            : {
     539                 :          0 :     bDelFmt = sal_False;
     540                 :          0 :     SwFrmFmts & rFlyFmts = *rContext.GetDoc().GetSpzFrmFmts();
     541         [ #  # ]:          0 :     for( sal_uInt16 n = 0; n < pMarkLst->GetMarkCount(); ++n )
     542                 :            :     {
     543                 :          0 :         SwUndoGroupObjImpl& rSave = *( pObjArr + n );
     544                 :          0 :         ::lcl_RestoreAnchor( rSave.pFmt, rSave.nNodeIdx );
     545         [ #  # ]:          0 :         rFlyFmts.push_back( rSave.pFmt );
     546                 :          0 :         SdrObject *pObj = rSave.pObj;
     547         [ #  # ]:          0 :         SwDrawContact *pContact = new SwDrawContact( rSave.pFmt, pObj );
     548                 :          0 :         pContact->_Changed( *pObj, SDRUSERCALL_INSERTED, NULL );
     549                 :            :         // #i45718# - follow-up of #i35635# move object to visible layer
     550                 :          0 :         pContact->MoveObjToVisibleLayer( pObj );
     551                 :            :         // #i45952# - notify that position attributes are already set
     552                 :            :         OSL_ENSURE( rSave.pFmt->ISA(SwDrawFrmFmt),
     553                 :            :                 "<SwUndoDrawGroup::Undo(..)> - wrong type of frame format for drawing object" );
     554         [ #  # ]:          0 :         if ( rSave.pFmt->ISA(SwDrawFrmFmt) )
     555                 :            :         {
     556                 :          0 :             static_cast<SwDrawFrmFmt*>(rSave.pFmt)->PosAttrSet();
     557                 :            :         }
     558                 :            :     }
     559                 :          0 :     rContext.SetSelections(0, pMarkLst);
     560                 :          0 : }
     561                 :            : 
     562                 :          0 : void SwUndoDrawDelete::RedoImpl(::sw::UndoRedoContext & rContext)
     563                 :            : {
     564                 :          0 :     bDelFmt = sal_True;
     565                 :          0 :     SwFrmFmts & rFlyFmts = *rContext.GetDoc().GetSpzFrmFmts();
     566         [ #  # ]:          0 :     for( sal_uInt16 n = 0; n < pMarkLst->GetMarkCount(); ++n )
     567                 :            :     {
     568                 :          0 :         SwUndoGroupObjImpl& rSave = *( pObjArr + n );
     569                 :          0 :         SdrObject *pObj = rSave.pObj;
     570         [ #  # ]:          0 :         SwDrawContact *pContact = (SwDrawContact*)GetUserCall(pObj);
     571                 :          0 :         SwDrawFrmFmt *pFmt = (SwDrawFrmFmt*)pContact->GetFmt();
     572                 :            : 
     573                 :            :         // object will destroy itself
     574 [ #  # ][ #  # ]:          0 :         pContact->Changed( *pObj, SDRUSERCALL_DELETE, pObj->GetLastBoundRect() );
     575         [ #  # ]:          0 :         pObj->SetUserCall( 0 );
     576                 :            : 
     577                 :            :            // notify UNO objects to decouple
     578         [ #  # ]:          0 :         ::lcl_SendRemoveToUno( *pFmt );
     579                 :            : 
     580 [ #  # ][ #  # ]:          0 :         rFlyFmts.erase( std::find( rFlyFmts.begin(), rFlyFmts.end(), pFmt ));
     581         [ #  # ]:          0 :         ::lcl_SaveAnchor( pFmt, rSave.nNodeIdx );
     582                 :            :     }
     583                 :          0 : }
     584                 :            : 
     585                 :          0 : void SwUndoDrawDelete::AddObj( sal_uInt16 , SwDrawFrmFmt* pFmt,
     586                 :            :                                 const SdrMark& rMark )
     587                 :            : {
     588                 :          0 :     SwUndoGroupObjImpl& rSave = *( pObjArr + pMarkLst->GetMarkCount() );
     589                 :          0 :     rSave.pObj = rMark.GetMarkedSdrObj();
     590                 :          0 :     rSave.pFmt = pFmt;
     591                 :          0 :     ::lcl_SaveAnchor( pFmt, rSave.nNodeIdx );
     592                 :            : 
     593                 :            :        // notify UNO objects to decouple
     594                 :          0 :     ::lcl_SendRemoveToUno( *pFmt );
     595                 :            : 
     596                 :            :     // remove from array
     597                 :          0 :     SwDoc* pDoc = pFmt->GetDoc();
     598                 :          0 :     SwFrmFmts& rFlyFmts = *(SwFrmFmts*)pDoc->GetSpzFrmFmts();
     599                 :          0 :     rFlyFmts.erase( std::find( rFlyFmts.begin(), rFlyFmts.end(), pFmt ));
     600                 :            : 
     601                 :          0 :     pMarkLst->InsertEntry( rMark );
     602                 :          0 : }
     603                 :            : 
     604                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10