/src/libreoffice/editeng/source/outliner/outlundo.cxx
Line | Count | Source |
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 | | |
26 | | OutlinerUndoBase::OutlinerUndoBase( sal_uInt16 _nId, Outliner* pOutliner ) |
27 | 12.0k | : EditUndo( _nId, nullptr ) |
28 | 12.0k | { |
29 | 12.0k | DBG_ASSERT( pOutliner, "Undo: Outliner?!" ); |
30 | 12.0k | mpOutliner = pOutliner; |
31 | 12.0k | } |
32 | | |
33 | | OutlinerUndoChangeParaFlags::OutlinerUndoChangeParaFlags( Outliner* pOutliner, sal_Int32 nPara, ParaFlag nOldFlags, ParaFlag nNewFlags ) |
34 | 0 | : OutlinerUndoBase( OLUNDO_DEPTH, pOutliner ), mnPara(nPara), mnOldFlags(nOldFlags), mnNewFlags(nNewFlags) |
35 | 0 | { |
36 | 0 | } |
37 | | |
38 | | void OutlinerUndoChangeParaFlags::Undo() |
39 | 0 | { |
40 | 0 | ImplChangeFlags( mnOldFlags ); |
41 | 0 | } |
42 | | |
43 | | void OutlinerUndoChangeParaFlags::Redo() |
44 | 0 | { |
45 | 0 | ImplChangeFlags( mnNewFlags ); |
46 | 0 | } |
47 | | |
48 | | void OutlinerUndoChangeParaFlags::ImplChangeFlags( ParaFlag nFlags ) |
49 | 0 | { |
50 | 0 | Outliner* pOutliner = GetOutliner(); |
51 | 0 | Paragraph* pPara = pOutliner->GetParagraph( mnPara ); |
52 | 0 | if( pPara ) |
53 | 0 | { |
54 | 0 | pOutliner->nDepthChangedHdlPrevDepth = pPara->GetDepth(); |
55 | 0 | ParaFlag nPrevFlags = pPara->nFlags; |
56 | |
|
57 | 0 | pPara->nFlags = nFlags; |
58 | 0 | pOutliner->DepthChangedHdl(pPara, nPrevFlags); |
59 | 0 | } |
60 | 0 | } |
61 | | |
62 | | OutlinerUndoChangeParaNumberingRestart::OutlinerUndoChangeParaNumberingRestart( Outliner* pOutliner, sal_Int32 nPara, |
63 | | sal_Int16 nOldNumberingStartValue, sal_Int16 nNewNumberingStartValue, |
64 | | bool bOldParaIsNumberingRestart, bool bNewParaIsNumberingRestart ) |
65 | 0 | : OutlinerUndoBase( OLUNDO_DEPTH, pOutliner ), mnPara(nPara) |
66 | 0 | { |
67 | 0 | maUndoData.mnNumberingStartValue = nOldNumberingStartValue; |
68 | 0 | maUndoData.mbParaIsNumberingRestart = bOldParaIsNumberingRestart; |
69 | 0 | maRedoData.mnNumberingStartValue = nNewNumberingStartValue; |
70 | 0 | maRedoData.mbParaIsNumberingRestart = bNewParaIsNumberingRestart; |
71 | 0 | } |
72 | | |
73 | | void OutlinerUndoChangeParaNumberingRestart::Undo() |
74 | 0 | { |
75 | 0 | ImplApplyData( maUndoData ); |
76 | 0 | } |
77 | | |
78 | | void OutlinerUndoChangeParaNumberingRestart::Redo() |
79 | 0 | { |
80 | 0 | ImplApplyData( maRedoData ); |
81 | 0 | } |
82 | | |
83 | | void OutlinerUndoChangeParaNumberingRestart::ImplApplyData( const ParaRestartData& rData ) |
84 | 0 | { |
85 | 0 | Outliner* pOutliner = GetOutliner(); |
86 | 0 | pOutliner->SetNumberingStartValue( mnPara, rData.mnNumberingStartValue ); |
87 | 0 | pOutliner->SetParaIsNumberingRestart( mnPara, rData.mbParaIsNumberingRestart ); |
88 | 0 | } |
89 | | |
90 | | OutlinerUndoChangeDepth::OutlinerUndoChangeDepth( Outliner* pOutliner, sal_Int32 nPara, sal_Int16 nOldDepth, sal_Int16 nNewDepth ) |
91 | 12.0k | : OutlinerUndoBase( OLUNDO_DEPTH, pOutliner ), mnPara(nPara), mnOldDepth(nOldDepth), mnNewDepth(nNewDepth) |
92 | 12.0k | { |
93 | 12.0k | } |
94 | | |
95 | | void OutlinerUndoChangeDepth::Undo() |
96 | 0 | { |
97 | 0 | GetOutliner()->ImplInitDepth( mnPara, mnOldDepth, false ); |
98 | 0 | } |
99 | | |
100 | | void OutlinerUndoChangeDepth::Redo() |
101 | 0 | { |
102 | 0 | GetOutliner()->ImplInitDepth( mnPara, mnNewDepth, false ); |
103 | 0 | } |
104 | | |
105 | | OutlinerUndoCheckPara::OutlinerUndoCheckPara( Outliner* pOutliner, sal_Int32 nPara ) |
106 | 0 | : OutlinerUndoBase( OLUNDO_DEPTH, pOutliner ), mnPara(nPara) |
107 | 0 | { |
108 | 0 | } |
109 | | |
110 | | void OutlinerUndoCheckPara::Undo() |
111 | 0 | { |
112 | 0 | Paragraph* pPara = GetOutliner()->GetParagraph( mnPara ); |
113 | 0 | pPara->Invalidate(); |
114 | 0 | GetOutliner()->ImplCalcBulletText( mnPara, false, false ); |
115 | 0 | } |
116 | | |
117 | | void OutlinerUndoCheckPara::Redo() |
118 | 0 | { |
119 | 0 | Paragraph* pPara = GetOutliner()->GetParagraph( mnPara ); |
120 | 0 | pPara->Invalidate(); |
121 | 0 | GetOutliner()->ImplCalcBulletText( mnPara, false, false ); |
122 | 0 | } |
123 | | |
124 | | OLUndoExpand::OLUndoExpand(Outliner* pOut, sal_uInt16 _nId ) |
125 | 0 | : EditUndo( _nId, nullptr ), pOutliner(pOut), nCount(0) |
126 | 0 | { |
127 | 0 | DBG_ASSERT(pOut,"Undo:No Outliner"); |
128 | 0 | } |
129 | | |
130 | | OLUndoExpand::~OLUndoExpand() |
131 | 0 | { |
132 | 0 | } |
133 | | |
134 | | void OLUndoExpand::Restore( bool bUndo ) |
135 | 0 | { |
136 | 0 | assert(pOutliner && "Undo:No Outliner"); |
137 | 0 | DBG_ASSERT(pOutliner->pEditEngine,"Outliner already deleted"); |
138 | 0 | Paragraph* pPara; |
139 | |
|
140 | 0 | bool bExpand = false; |
141 | 0 | sal_uInt16 _nId = GetId(); |
142 | 0 | if((_nId == OLUNDO_EXPAND && !bUndo) || (_nId == OLUNDO_COLLAPSE && bUndo)) |
143 | 0 | bExpand = true; |
144 | |
|
145 | 0 | pPara = pOutliner->GetParagraph( nCount ); |
146 | 0 | if( bExpand ) |
147 | 0 | pOutliner->Expand( pPara ); |
148 | 0 | else |
149 | 0 | pOutliner->Collapse( pPara ); |
150 | 0 | } |
151 | | |
152 | | void OLUndoExpand::Undo() |
153 | 0 | { |
154 | 0 | Restore( true ); |
155 | 0 | } |
156 | | |
157 | | void OLUndoExpand::Redo() |
158 | 0 | { |
159 | 0 | Restore( false ); |
160 | 0 | } |
161 | | |
162 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |