LibreOffice Module editeng (master) 1
outlundo.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
21#include <editeng/outliner.hxx>
22#include <tools/debug.hxx>
23#include "outlundo.hxx"
24
25
26OutlinerUndoBase::OutlinerUndoBase( sal_uInt16 _nId, Outliner* pOutliner )
27 : EditUndo( _nId, nullptr )
28{
29 DBG_ASSERT( pOutliner, "Undo: Outliner?!" );
30 mpOutliner = pOutliner;
31}
32
33OutlinerUndoChangeParaFlags::OutlinerUndoChangeParaFlags( Outliner* pOutliner, sal_Int32 nPara, ParaFlag nOldFlags, ParaFlag nNewFlags )
34: OutlinerUndoBase( OLUNDO_DEPTH, pOutliner ), mnPara(nPara), mnOldFlags(nOldFlags), mnNewFlags(nNewFlags)
35{
36}
37
39{
41}
42
44{
46}
47
49{
50 Outliner* pOutliner = GetOutliner();
51 Paragraph* pPara = pOutliner->GetParagraph( mnPara );
52 if( pPara )
53 {
54 pOutliner->nDepthChangedHdlPrevDepth = pPara->GetDepth();
55 ParaFlag nPrevFlags = pPara->nFlags;
56
57 pPara->nFlags = nFlags;
58 pOutliner->DepthChangedHdl(pPara, nPrevFlags);
59 }
60}
61
63 sal_Int16 nOldNumberingStartValue, sal_Int16 nNewNumberingStartValue,
64 bool bOldParaIsNumberingRestart, bool bNewParaIsNumberingRestart )
65: OutlinerUndoBase( OLUNDO_DEPTH, pOutliner ), mnPara(nPara)
66{
67 maUndoData.mnNumberingStartValue = nOldNumberingStartValue;
68 maUndoData.mbParaIsNumberingRestart = bOldParaIsNumberingRestart;
69 maRedoData.mnNumberingStartValue = nNewNumberingStartValue;
70 maRedoData.mbParaIsNumberingRestart = bNewParaIsNumberingRestart;
71}
72
74{
76}
77
79{
81}
82
84{
85 Outliner* pOutliner = GetOutliner();
88}
89
90OutlinerUndoChangeDepth::OutlinerUndoChangeDepth( Outliner* pOutliner, sal_Int32 nPara, sal_Int16 nOldDepth, sal_Int16 nNewDepth )
91 : OutlinerUndoBase( OLUNDO_DEPTH, pOutliner ), mnPara(nPara), mnOldDepth(nOldDepth), mnNewDepth(nNewDepth)
92{
93}
94
96{
98}
99
101{
103}
104
106 : OutlinerUndoBase( OLUNDO_DEPTH, pOutliner ), mnPara(nPara)
107{
108}
109
111{
113 pPara->Invalidate();
114 GetOutliner()->ImplCalcBulletText( mnPara, false, false );
115}
116
118{
120 pPara->Invalidate();
121 GetOutliner()->ImplCalcBulletText( mnPara, false, false );
122}
123
124OLUndoExpand::OLUndoExpand(Outliner* pOut, sal_uInt16 _nId )
125 : EditUndo( _nId, nullptr ), pOutliner(pOut), nCount(0)
126{
127 DBG_ASSERT(pOut,"Undo:No Outliner");
128}
129
130
132{
133}
134
135
136void OLUndoExpand::Restore( bool bUndo )
137{
138 DBG_ASSERT(pOutliner,"Undo:No Outliner");
139 DBG_ASSERT(pOutliner->pEditEngine,"Outliner already deleted");
140 Paragraph* pPara;
141
142 bool bExpand = false;
143 sal_uInt16 _nId = GetId();
144 if((_nId == OLUNDO_EXPAND && !bUndo) || (_nId == OLUNDO_COLLAPSE && bUndo))
145 bExpand = true;
146
147 pPara = pOutliner->GetParagraph( nCount );
148 if( bExpand )
149 pOutliner->Expand( pPara );
150 else
151 pOutliner->Collapse( pPara );
152}
153
155{
156 Restore( true );
157}
158
160{
161 Restore( false );
162}
163
164/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 GetId() const
Definition: editundo.cxx:135
sal_Int32 nCount
Definition: outlundo.hxx:115
void Restore(bool bUndo)
Definition: outlundo.cxx:136
virtual ~OLUndoExpand() override
Definition: outlundo.cxx:131
Outliner * pOutliner
Definition: outlundo.hxx:114
virtual void Redo() override
Definition: outlundo.cxx:159
OLUndoExpand(Outliner *pOut, sal_uInt16 nId)
Definition: outlundo.cxx:124
virtual void Undo() override
Definition: outlundo.cxx:154
Outliner * GetOutliner() const
Definition: outlundo.hxx:33
OutlinerUndoBase(sal_uInt16 nId, Outliner *pOutliner)
Definition: outlundo.cxx:26
Outliner * mpOutliner
Definition: outlundo.hxx:28
virtual void Redo() override
Definition: outlundo.cxx:100
OutlinerUndoChangeDepth(Outliner *pOutliner, sal_Int32 nPara, sal_Int16 nOldDepth, sal_Int16 nNewDepth)
Definition: outlundo.cxx:90
virtual void Undo() override
Definition: outlundo.cxx:95
virtual void Redo() override
Definition: outlundo.cxx:43
virtual void Undo() override
Definition: outlundo.cxx:38
OutlinerUndoChangeParaFlags(Outliner *pOutliner, sal_Int32 nPara, ParaFlag nOldFlags, ParaFlag nNewFlags)
Definition: outlundo.cxx:33
void ImplChangeFlags(ParaFlag nFlags)
Definition: outlundo.cxx:48
virtual void Redo() override
Definition: outlundo.cxx:78
virtual void Undo() override
Definition: outlundo.cxx:73
OutlinerUndoChangeParaNumberingRestart(Outliner *pOutliner, sal_Int32 nPara, sal_Int16 nOldNumberingStartValue, sal_Int16 mnNewNumberingStartValue, bool bOldbParaIsNumberingRestart, bool bNewParaIsNumberingRestart)
Definition: outlundo.cxx:62
void ImplApplyData(const ParaRestartData &rData)
Definition: outlundo.cxx:83
virtual void Redo() override
Definition: outlundo.cxx:117
virtual void Undo() override
Definition: outlundo.cxx:110
OutlinerUndoCheckPara(Outliner *pOutliner, sal_Int32 nPara)
Definition: outlundo.cxx:105
bool Expand(Paragraph const *)
Definition: outliner.cxx:760
Paragraph * GetParagraph(sal_Int32 nAbsPos) const
Definition: outliner.cxx:1345
std::unique_ptr< OutlinerEditEng > pEditEngine
Definition: outliner.hxx:587
void ImplCalcBulletText(sal_Int32 nPara, bool bRecalcLevel, bool bRecalcChildren)
Definition: outliner.cxx:1810
bool Collapse(Paragraph const *)
Definition: outliner.cxx:783
void DepthChangedHdl(Paragraph *, ParaFlag nPrevFlags)
Definition: outliner.cxx:1327
void ImplInitDepth(sal_Int32 nPara, sal_Int16 nDepth, bool bCreateUndo)
Definition: outliner.cxx:715
void SetNumberingStartValue(sal_Int32 nPara, sal_Int16 nNumberingStartValue)
Definition: outliner.cxx:264
sal_Int32 nDepthChangedHdlPrevDepth
Definition: outliner.hxx:607
void SetParaIsNumberingRestart(sal_Int32 nPara, bool bParaIsNumberingRestart)
Definition: outliner.cxx:288
sal_Int16 GetDepth() const
Definition: outliner.hxx:145
ParaFlag nFlags
Definition: outliner.hxx:132
void Invalidate()
Definition: outliner.hxx:137
int nCount
#define DBG_ASSERT(sCon, aError)
ParaFlag
Definition: outliner.hxx:97
#define OLUNDO_DEPTH
Definition: outliner.hxx:108
#define OLUNDO_COLLAPSE
Definition: outliner.hxx:111
#define OLUNDO_EXPAND
Definition: outliner.hxx:110
oslFileHandle & pOut