LCOV - code coverage report
Current view: top level - sw/source/core/undo - unfmco.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 14 31 45.2 %
Date: 2014-11-03 Functions: 6 10 60.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             : 
      20             : #include "doc.hxx"
      21             : #include "swundo.hxx"
      22             : #include "pam.hxx"
      23             : #include "ndtxt.hxx"
      24             : #include <UndoCore.hxx>
      25             : #include "rolbck.hxx"
      26             : #include "docary.hxx"
      27             : 
      28        3866 : SwUndoFmtColl::SwUndoFmtColl( const SwPaM& rRange,
      29             :                               SwFmtColl* pColl,
      30             :                               const bool bReset,
      31             :                               const bool bResetListAttrs )
      32             :     : SwUndo( UNDO_SETFMTCOLL ),
      33             :       SwUndRng( rRange ),
      34        3866 :       pHistory( new SwHistory ),
      35             :       pFmtColl( pColl ),
      36             :       mbReset( bReset ),
      37        7732 :       mbResetListAttrs( bResetListAttrs )
      38             : {
      39             :     // #i31191#
      40        3866 :     if ( pColl )
      41        3866 :         aFmtName = pColl->GetName();
      42        3866 : }
      43             : 
      44       11598 : SwUndoFmtColl::~SwUndoFmtColl()
      45             : {
      46        3866 :     delete pHistory;
      47        7732 : }
      48             : 
      49           0 : void SwUndoFmtColl::UndoImpl(::sw::UndoRedoContext & rContext)
      50             : {
      51             :     // restore old values
      52           0 :     pHistory->TmpRollback(& rContext.GetDoc(), 0);
      53           0 :     pHistory->SetTmpEnd( pHistory->Count() );
      54             : 
      55             :     // create cursor for undo range
      56           0 :     AddUndoRedoPaM(rContext);
      57           0 : }
      58             : 
      59           0 : void SwUndoFmtColl::RedoImpl(::sw::UndoRedoContext & rContext)
      60             : {
      61           0 :     SwPaM & rPam = AddUndoRedoPaM(rContext);
      62             : 
      63           0 :     DoSetFmtColl(rContext.GetDoc(), rPam);
      64           0 : }
      65             : 
      66           0 : void SwUndoFmtColl::RepeatImpl(::sw::RepeatContext & rContext)
      67             : {
      68           0 :     DoSetFmtColl(rContext.GetDoc(), rContext.GetRepeatPaM());
      69           0 : }
      70             : 
      71           0 : void SwUndoFmtColl::DoSetFmtColl(SwDoc & rDoc, SwPaM & rPaM)
      72             : {
      73             :     // Only one TextFrmColl can be applied to a section, thus request only in
      74             :     // this array.
      75             :     sal_uInt16 const nPos = rDoc.GetTxtFmtColls()->GetPos(
      76           0 :                                                      (SwTxtFmtColl*)pFmtColl );
      77             :     // does the format still exist?
      78           0 :     if( USHRT_MAX != nPos )
      79             :     {
      80             :         rDoc.SetTxtFmtColl(rPaM, (SwTxtFmtColl*)pFmtColl, mbReset,
      81           0 :                            mbResetListAttrs);
      82             :     }
      83           0 : }
      84             : 
      85        3866 : SwRewriter SwUndoFmtColl::GetRewriter() const
      86             : {
      87        3866 :     SwRewriter aResult;
      88             : 
      89             :     // #i31191# Use stored format name instead of
      90             :     // pFmtColl->GetName(), because pFmtColl does not have to be available
      91             :     // anymore.
      92        3866 :     aResult.AddRule(UndoArg1, aFmtName );
      93             : 
      94        3866 :     return aResult;
      95         270 : }
      96             : 
      97             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10