update credits
[LibreOffice.git] / sw / source / core / undo / unfmco.cxx
blobbfce6d1211cf56091857c770543718f57abab307
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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"
28 //--------------------------------------------------
30 SwUndoFmtColl::SwUndoFmtColl( const SwPaM& rRange,
31 SwFmtColl* pColl,
32 const bool bReset,
33 const bool bResetListAttrs )
34 : SwUndo( UNDO_SETFMTCOLL ),
35 SwUndRng( rRange ),
36 pHistory( new SwHistory ),
37 pFmtColl( pColl ),
38 mbReset( bReset ),
39 mbResetListAttrs( bResetListAttrs )
41 // #i31191#
42 if ( pColl )
43 aFmtName = pColl->GetName();
46 SwUndoFmtColl::~SwUndoFmtColl()
48 delete pHistory;
51 void SwUndoFmtColl::UndoImpl(::sw::UndoRedoContext & rContext)
53 // restore old values
54 pHistory->TmpRollback(& rContext.GetDoc(), 0);
55 pHistory->SetTmpEnd( pHistory->Count() );
57 // create cursor for undo range
58 AddUndoRedoPaM(rContext);
61 void SwUndoFmtColl::RedoImpl(::sw::UndoRedoContext & rContext)
63 SwPaM & rPam = AddUndoRedoPaM(rContext);
65 DoSetFmtColl(rContext.GetDoc(), rPam);
68 void SwUndoFmtColl::RepeatImpl(::sw::RepeatContext & rContext)
70 DoSetFmtColl(rContext.GetDoc(), rContext.GetRepeatPaM());
73 void SwUndoFmtColl::DoSetFmtColl(SwDoc & rDoc, SwPaM & rPaM)
75 // Only one TextFrmColl can be applied to a section, thus request only in
76 // this array.
77 sal_uInt16 const nPos = rDoc.GetTxtFmtColls()->GetPos(
78 (SwTxtFmtColl*)pFmtColl );
79 // does the format still exist?
80 if( USHRT_MAX != nPos )
82 rDoc.SetTxtFmtColl(rPaM,
83 (SwTxtFmtColl*)pFmtColl,
84 mbReset,
85 mbResetListAttrs );
89 SwRewriter SwUndoFmtColl::GetRewriter() const
91 SwRewriter aResult;
93 // #i31191# Use stored format name instead of
94 // pFmtColl->GetName(), because pFmtColl does not have to be available
95 // anymore.
96 aResult.AddRule(UndoArg1, aFmtName );
98 return aResult;
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */