1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
23 #include <UndoCore.hxx>
26 SwUndoFormatColl::SwUndoFormatColl( const SwPaM
& rRange
,
27 const SwFormatColl
* pColl
,
29 const bool bResetListAttrs
)
30 : SwUndo( SwUndoId::SETFMTCOLL
, &rRange
.GetDoc() ),
32 mpHistory( new SwHistory
),
34 mbResetListAttrs( bResetListAttrs
)
38 maFormatName
= pColl
->GetName();
41 SwUndoFormatColl::~SwUndoFormatColl()
45 void SwUndoFormatColl::UndoImpl(::sw::UndoRedoContext
& rContext
)
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
71 SwTextFormatColl
* pFormatColl
= rDoc
.FindTextFormatCollByName(maFormatName
);
74 rDoc
.SetTextFormatColl(rPaM
, pFormatColl
, mbReset
, mbResetListAttrs
);
78 SwRewriter
SwUndoFormatColl::GetRewriter() const
82 aResult
.AddRule(UndoArg1
, maFormatName
);
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */