android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / core / undo / unfmco.cxx
blob7ea43d0d5fef93b8caa27c0ee2e921d0457dc0e7
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 <UndoCore.hxx>
24 #include <rolbck.hxx>
26 SwUndoFormatColl::SwUndoFormatColl( const SwPaM& rRange,
27 const SwFormatColl* pColl,
28 const bool bReset,
29 const bool bResetListAttrs )
30 : SwUndo( SwUndoId::SETFMTCOLL, &rRange.GetDoc() ),
31 SwUndRng( rRange ),
32 mpHistory( new SwHistory ),
33 mbReset( bReset ),
34 mbResetListAttrs( bResetListAttrs )
36 // #i31191#
37 if ( pColl )
38 maFormatName = pColl->GetName();
41 SwUndoFormatColl::~SwUndoFormatColl()
45 void SwUndoFormatColl::UndoImpl(::sw::UndoRedoContext & rContext)
47 // restore old values
48 mpHistory->TmpRollback(& rContext.GetDoc(), 0);
49 mpHistory->SetTmpEnd( mpHistory->Count() );
51 // create cursor for undo range
52 AddUndoRedoPaM(rContext);
55 void SwUndoFormatColl::RedoImpl(::sw::UndoRedoContext & rContext)
57 SwPaM & rPam = AddUndoRedoPaM(rContext);
59 DoSetFormatColl(rContext.GetDoc(), rPam);
62 void SwUndoFormatColl::RepeatImpl(::sw::RepeatContext & rContext)
64 DoSetFormatColl(rContext.GetDoc(), rContext.GetRepeatPaM());
67 void SwUndoFormatColl::DoSetFormatColl(SwDoc & rDoc, SwPaM const & rPaM)
69 // Only one TextFrameColl can be applied to a section, thus request only in
70 // this array.
71 SwTextFormatColl * pFormatColl = rDoc.FindTextFormatCollByName(maFormatName);
72 if (pFormatColl)
74 rDoc.SetTextFormatColl(rPaM, pFormatColl, mbReset, mbResetListAttrs);
78 SwRewriter SwUndoFormatColl::GetRewriter() const
80 SwRewriter aResult;
82 aResult.AddRule(UndoArg1, maFormatName );
84 return aResult;
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */