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 .
24 #include <UndoCore.hxx>
28 //--------------------------------------------------
30 SwUndoFmtColl::SwUndoFmtColl( const SwPaM
& rRange
,
33 const bool bResetListAttrs
)
34 : SwUndo( UNDO_SETFMTCOLL
),
36 pHistory( new SwHistory
),
39 mbResetListAttrs( bResetListAttrs
)
43 aFmtName
= pColl
->GetName();
46 SwUndoFmtColl::~SwUndoFmtColl()
51 void SwUndoFmtColl::UndoImpl(::sw::UndoRedoContext
& rContext
)
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
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
,
89 SwRewriter
SwUndoFmtColl::GetRewriter() const
93 // #i31191# Use stored format name instead of
94 // pFmtColl->GetName(), because pFmtColl does not have to be available
96 aResult
.AddRule(UndoArg1
, aFmtName
);
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */