update credits
[LibreOffice.git] / editeng / source / outliner / outlundo.cxx
blobdcd41e2539cb3a69544c8c23078f56ebb29ada05
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 #include <svl/intitem.hxx>
22 #include <editeng/editeng.hxx>
23 #include <editeng/editview.hxx>
24 #include <editeng/editdata.hxx>
25 #include <editeng/eerdll.hxx>
26 #include <editeng/lrspitem.hxx>
27 #include <editeng/fhgtitem.hxx>
29 #include <editeng/outliner.hxx>
30 #include <outlundo.hxx>
33 OutlinerUndoBase::OutlinerUndoBase( sal_uInt16 _nId, Outliner* pOutliner )
34 : EditUndo( _nId, NULL )
36 DBG_ASSERT( pOutliner, "Undo: Outliner?!" );
37 mpOutliner = pOutliner;
40 OutlinerUndoChangeParaFlags::OutlinerUndoChangeParaFlags( Outliner* pOutliner, sal_Int32 nPara, sal_uInt16 nOldFlags, sal_uInt16 nNewFlags )
41 : OutlinerUndoBase( OLUNDO_DEPTH, pOutliner )
43 mnPara = nPara;
44 mnOldFlags = nOldFlags;
45 mnNewFlags = nNewFlags;
48 void OutlinerUndoChangeParaFlags::Undo()
50 ImplChangeFlags( mnOldFlags );
53 void OutlinerUndoChangeParaFlags::Redo()
55 ImplChangeFlags( mnNewFlags );
58 void OutlinerUndoChangeParaFlags::ImplChangeFlags( sal_uInt16 nFlags )
60 Outliner* pOutliner = GetOutliner();
61 Paragraph* pPara = pOutliner->GetParagraph( mnPara );
62 if( pPara )
64 pOutliner->nDepthChangedHdlPrevDepth = pPara->GetDepth();
65 pOutliner->mnDepthChangeHdlPrevFlags = pPara->nFlags;
66 pOutliner->pHdlParagraph = pPara;
68 pPara->nFlags = nFlags;
69 pOutliner->DepthChangedHdl();
73 OutlinerUndoChangeParaNumberingRestart::OutlinerUndoChangeParaNumberingRestart( Outliner* pOutliner, sal_Int32 nPara,
74 sal_Int16 nOldNumberingStartValue, sal_Int16 nNewNumberingStartValue,
75 sal_Bool bOldParaIsNumberingRestart, sal_Bool bNewParaIsNumberingRestart )
76 : OutlinerUndoBase( OLUNDO_DEPTH, pOutliner )
78 mnPara = nPara;
80 maUndoData.mnNumberingStartValue = nOldNumberingStartValue;
81 maUndoData.mbParaIsNumberingRestart = bOldParaIsNumberingRestart;
82 maRedoData.mnNumberingStartValue = nNewNumberingStartValue;
83 maRedoData.mbParaIsNumberingRestart = bNewParaIsNumberingRestart;
86 void OutlinerUndoChangeParaNumberingRestart::Undo()
88 ImplApplyData( maUndoData );
91 void OutlinerUndoChangeParaNumberingRestart::Redo()
93 ImplApplyData( maRedoData );
96 void OutlinerUndoChangeParaNumberingRestart::ImplApplyData( const ParaRestartData& rData )
98 Outliner* pOutliner = GetOutliner();
99 pOutliner->SetNumberingStartValue( mnPara, rData.mnNumberingStartValue );
100 pOutliner->SetParaIsNumberingRestart( mnPara, rData.mbParaIsNumberingRestart );
103 OutlinerUndoChangeDepth::OutlinerUndoChangeDepth( Outliner* pOutliner, sal_Int32 nPara, sal_Int16 nOldDepth, sal_Int16 nNewDepth )
104 : OutlinerUndoBase( OLUNDO_DEPTH, pOutliner )
106 mnPara = nPara;
107 mnOldDepth = nOldDepth;
108 mnNewDepth = nNewDepth;
111 void OutlinerUndoChangeDepth::Undo()
113 GetOutliner()->ImplInitDepth( mnPara, mnOldDepth, sal_False );
116 void OutlinerUndoChangeDepth::Redo()
118 GetOutliner()->ImplInitDepth( mnPara, mnNewDepth, sal_False );
121 void OutlinerUndoChangeDepth::Repeat()
123 OSL_FAIL( "Repeat not implemented!" );
127 OutlinerUndoCheckPara::OutlinerUndoCheckPara( Outliner* pOutliner, sal_Int32 nPara )
128 : OutlinerUndoBase( OLUNDO_DEPTH, pOutliner )
130 mnPara = nPara;
133 void OutlinerUndoCheckPara::Undo()
135 Paragraph* pPara = GetOutliner()->GetParagraph( mnPara );
136 pPara->Invalidate();
137 GetOutliner()->ImplCalcBulletText( mnPara, sal_False, sal_False );
140 void OutlinerUndoCheckPara::Redo()
142 Paragraph* pPara = GetOutliner()->GetParagraph( mnPara );
143 pPara->Invalidate();
144 GetOutliner()->ImplCalcBulletText( mnPara, sal_False, sal_False );
147 void OutlinerUndoCheckPara::Repeat()
149 OSL_FAIL( "Repeat not implemented!" );
152 DBG_NAME(OLUndoExpand);
154 OLUndoExpand::OLUndoExpand(Outliner* pOut, sal_uInt16 _nId )
155 : EditUndo( _nId, 0 )
157 DBG_CTOR(OLUndoExpand,0);
158 DBG_ASSERT(pOut,"Undo:No Outliner");
159 pOutliner = pOut;
160 nCount = 0;
161 pParas = 0;
165 OLUndoExpand::~OLUndoExpand()
167 DBG_DTOR(OLUndoExpand,0);
168 delete pParas;
172 void OLUndoExpand::Restore( sal_Bool bUndo )
174 DBG_CHKTHIS(OLUndoExpand,0);
175 DBG_ASSERT(pOutliner,"Undo:No Outliner");
176 DBG_ASSERT(pOutliner->pEditEngine,"Outliner already deleted");
177 Paragraph* pPara;
179 sal_Bool bExpand = sal_False;
180 sal_uInt16 _nId = GetId();
181 if((_nId == OLUNDO_EXPAND && !bUndo) || (_nId == OLUNDO_COLLAPSE && bUndo))
182 bExpand = sal_True;
183 if( !pParas )
185 pPara = pOutliner->GetParagraph( nCount );
186 if( bExpand )
187 pOutliner->Expand( pPara );
188 else
189 pOutliner->Collapse( pPara );
191 else
193 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ )
195 pPara = pOutliner->GetParagraph( pParas[nIdx] );
196 if( bExpand )
197 pOutliner->Expand( pPara );
198 else
199 pOutliner->Collapse( pPara );
205 void OLUndoExpand::Undo()
207 DBG_CHKTHIS(OLUndoExpand,0);
208 Restore( sal_True );
212 void OLUndoExpand::Redo()
214 DBG_CHKTHIS(OLUndoExpand,0);
215 Restore( sal_False );
219 void OLUndoExpand::Repeat()
221 DBG_CHKTHIS(OLUndoExpand,0);
222 OSL_FAIL("Not implemented");
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */