LCOV - code coverage report
Current view: top level - sw/source/core/undo - unfmco.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 14 30 46.7 %
Date: 2015-06-13 12:38:46 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        1936 : SwUndoFormatColl::SwUndoFormatColl( const SwPaM& rRange,
      29             :                               SwFormatColl* pColl,
      30             :                               const bool bReset,
      31             :                               const bool bResetListAttrs )
      32             :     : SwUndo( UNDO_SETFMTCOLL ),
      33             :       SwUndRng( rRange ),
      34        1936 :       pHistory( new SwHistory ),
      35             :       pFormatColl( pColl ),
      36             :       mbReset( bReset ),
      37        3872 :       mbResetListAttrs( bResetListAttrs )
      38             : {
      39             :     // #i31191#
      40        1936 :     if ( pColl )
      41        1936 :         aFormatName = pColl->GetName();
      42        1936 : }
      43             : 
      44        5808 : SwUndoFormatColl::~SwUndoFormatColl()
      45             : {
      46        1936 :     delete pHistory;
      47        3872 : }
      48             : 
      49           0 : void SwUndoFormatColl::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 SwUndoFormatColl::RedoImpl(::sw::UndoRedoContext & rContext)
      60             : {
      61           0 :     SwPaM & rPam = AddUndoRedoPaM(rContext);
      62             : 
      63           0 :     DoSetFormatColl(rContext.GetDoc(), rPam);
      64           0 : }
      65             : 
      66           0 : void SwUndoFormatColl::RepeatImpl(::sw::RepeatContext & rContext)
      67             : {
      68           0 :     DoSetFormatColl(rContext.GetDoc(), rContext.GetRepeatPaM());
      69           0 : }
      70             : 
      71           0 : void SwUndoFormatColl::DoSetFormatColl(SwDoc & rDoc, SwPaM & rPaM)
      72             : {
      73             :     // Only one TextFrmColl can be applied to a section, thus request only in
      74             :     // this array.
      75             : 
      76             :     // does the format still exist?
      77           0 :     if( rDoc.GetTextFormatColls()->Contains(static_cast<SwTextFormatColl*>(pFormatColl)) )
      78             :     {
      79             :         rDoc.SetTextFormatColl(rPaM, static_cast<SwTextFormatColl*>(pFormatColl), mbReset,
      80           0 :                            mbResetListAttrs);
      81             :     }
      82           0 : }
      83             : 
      84        1936 : SwRewriter SwUndoFormatColl::GetRewriter() const
      85             : {
      86        1936 :     SwRewriter aResult;
      87             : 
      88             :     // #i31191# Use stored format name instead of
      89             :     // pFormatColl->GetName(), because pFormatColl does not have to be available
      90             :     // anymore.
      91        1936 :     aResult.AddRule(UndoArg1, aFormatName );
      92             : 
      93        1936 :     return aResult;
      94         177 : }
      95             : 
      96             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11