LibreOffice Module sw (master) 1
unfmco.cxx
Go to the documentation of this file.
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 <UndoCore.hxx>
24#include <rolbck.hxx>
25
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 )
35{
36 // #i31191#
37 if ( pColl )
38 maFormatName = pColl->GetName();
39}
40
42{
43}
44
46{
47 // restore old values
48 mpHistory->TmpRollback(& rContext.GetDoc(), 0);
49 mpHistory->SetTmpEnd( mpHistory->Count() );
50
51 // create cursor for undo range
52 AddUndoRedoPaM(rContext);
53}
54
56{
57 SwPaM & rPam = AddUndoRedoPaM(rContext);
58
59 DoSetFormatColl(rContext.GetDoc(), rPam);
60}
61
63{
64 DoSetFormatColl(rContext.GetDoc(), rContext.GetRepeatPaM());
65}
66
68{
69 // Only one TextFrameColl can be applied to a section, thus request only in
70 // this array.
72 if (pFormatColl)
73 {
74 rDoc.SetTextFormatColl(rPaM, pFormatColl, mbReset, mbResetListAttrs);
75 }
76}
77
79{
80 SwRewriter aResult;
81
82 aResult.AddRule(UndoArg1, maFormatName );
83
84 return aResult;
85}
86
87/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@ UndoArg1
Definition: SwRewriter.hxx:29
Definition: doc.hxx:197
SwTextFormatColl * FindTextFormatCollByName(const OUString &rName) const
Definition: doc.hxx:814
bool SetTextFormatColl(const SwPaM &rRg, SwTextFormatColl *pFormat, const bool bReset=true, const bool bResetListAttrs=false, SwRootFrame const *pLayout=nullptr)
Add 4th optional parameter <bResetListAttrs>.
Definition: docfmt.cxx:1100
SwFormatColl is just an SwFormat subclass that defaults to m_bAutoFormat=false, expressing that this ...
Definition: fmtcol.hxx:38
const OUString & GetName() const
Definition: format.hxx:131
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Definition: SwRewriter.cxx:25
Represents the style of a paragraph.
Definition: fmtcol.hxx:61
SwPaM & AddUndoRedoPaM(::sw::UndoRedoContext &, bool const bCorrToContent=false) const
Definition: undobj.cxx:100
void DoSetFormatColl(SwDoc &rDoc, SwPaM const &rPaM)
Definition: unfmco.cxx:67
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unfmco.cxx:55
virtual ~SwUndoFormatColl() override
Definition: unfmco.cxx:41
const bool mbReset
Definition: UndoCore.hxx:157
std::unique_ptr< SwHistory > mpHistory
Definition: UndoCore.hxx:153
virtual SwRewriter GetRewriter() const override
Returns the rewriter for this undo object.
Definition: unfmco.cxx:78
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: unfmco.cxx:62
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unfmco.cxx:45
const bool mbResetListAttrs
Definition: UndoCore.hxx:160
SwUndoFormatColl(const SwPaM &, const SwFormatColl *, const bool bReset, const bool bResetListAttrs)
Definition: unfmco.cxx:26
OUString maFormatName
Definition: UndoCore.hxx:152
SwDoc & GetDoc() const
Definition: UndoCore.hxx:132
SwPaM & GetRepeatPaM()
Definition: UndoCore.hxx:134
SwDoc & GetDoc() const
Definition: UndoCore.hxx:95
SwUndoId
Definition: swundo.hxx:30