Bump for 3.6-28
[LibreOffice.git] / editeng / source / outliner / outlundo.cxx
blobc5a3f9e3d4d52a73cef2b6bb0be4fbbdce2f9fa3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <svl/intitem.hxx>
31 #include <editeng/editeng.hxx>
32 #include <editeng/editview.hxx>
33 #include <editeng/editdata.hxx>
34 #include <editeng/eerdll.hxx>
35 #include <editeng/lrspitem.hxx>
36 #include <editeng/fhgtitem.hxx>
38 #define _OUTLINER_CXX
39 #include <editeng/outliner.hxx>
40 #include <outlundo.hxx>
43 OutlinerUndoBase::OutlinerUndoBase( sal_uInt16 _nId, Outliner* pOutliner )
44 : EditUndo( _nId, NULL )
46 DBG_ASSERT( pOutliner, "Undo: Outliner?!" );
47 mpOutliner = pOutliner;
50 OutlinerUndoChangeParaFlags::OutlinerUndoChangeParaFlags( Outliner* pOutliner, sal_uInt16 nPara, sal_uInt16 nOldFlags, sal_uInt16 nNewFlags )
51 : OutlinerUndoBase( OLUNDO_DEPTH, pOutliner )
53 mnPara = nPara;
54 mnOldFlags = nOldFlags;
55 mnNewFlags = nNewFlags;
58 void OutlinerUndoChangeParaFlags::Undo()
60 ImplChangeFlags( mnOldFlags );
63 void OutlinerUndoChangeParaFlags::Redo()
65 ImplChangeFlags( mnNewFlags );
68 void OutlinerUndoChangeParaFlags::ImplChangeFlags( sal_uInt16 nFlags )
70 Outliner* pOutliner = GetOutliner();
71 Paragraph* pPara = pOutliner->GetParagraph( mnPara );
72 if( pPara )
74 pOutliner->nDepthChangedHdlPrevDepth = pPara->GetDepth();
75 pOutliner->mnDepthChangeHdlPrevFlags = pPara->nFlags;
76 pOutliner->pHdlParagraph = pPara;
78 pPara->nFlags = nFlags;
79 pOutliner->DepthChangedHdl();
83 OutlinerUndoChangeParaNumberingRestart::OutlinerUndoChangeParaNumberingRestart( Outliner* pOutliner, sal_uInt16 nPara,
84 sal_Int16 nOldNumberingStartValue, sal_Int16 nNewNumberingStartValue,
85 sal_Bool bOldParaIsNumberingRestart, sal_Bool bNewParaIsNumberingRestart )
86 : OutlinerUndoBase( OLUNDO_DEPTH, pOutliner )
88 mnPara = nPara;
90 maUndoData.mnNumberingStartValue = nOldNumberingStartValue;
91 maUndoData.mbParaIsNumberingRestart = bOldParaIsNumberingRestart;
92 maRedoData.mnNumberingStartValue = nNewNumberingStartValue;
93 maRedoData.mbParaIsNumberingRestart = bNewParaIsNumberingRestart;
96 void OutlinerUndoChangeParaNumberingRestart::Undo()
98 ImplApplyData( maUndoData );
101 void OutlinerUndoChangeParaNumberingRestart::Redo()
103 ImplApplyData( maRedoData );
106 void OutlinerUndoChangeParaNumberingRestart::ImplApplyData( const ParaRestartData& rData )
108 Outliner* pOutliner = GetOutliner();
109 pOutliner->SetNumberingStartValue( mnPara, rData.mnNumberingStartValue );
110 pOutliner->SetParaIsNumberingRestart( mnPara, rData.mbParaIsNumberingRestart );
113 OutlinerUndoChangeDepth::OutlinerUndoChangeDepth( Outliner* pOutliner, sal_uInt16 nPara, sal_Int16 nOldDepth, sal_Int16 nNewDepth )
114 : OutlinerUndoBase( OLUNDO_DEPTH, pOutliner )
116 mnPara = nPara;
117 mnOldDepth = nOldDepth;
118 mnNewDepth = nNewDepth;
121 void OutlinerUndoChangeDepth::Undo()
123 GetOutliner()->ImplInitDepth( mnPara, mnOldDepth, sal_False );
126 void OutlinerUndoChangeDepth::Redo()
128 GetOutliner()->ImplInitDepth( mnPara, mnNewDepth, sal_False );
131 void OutlinerUndoChangeDepth::Repeat()
133 OSL_FAIL( "Repeat not implemented!" );
137 OutlinerUndoCheckPara::OutlinerUndoCheckPara( Outliner* pOutliner, sal_uInt16 nPara )
138 : OutlinerUndoBase( OLUNDO_DEPTH, pOutliner )
140 mnPara = nPara;
143 void OutlinerUndoCheckPara::Undo()
145 Paragraph* pPara = GetOutliner()->GetParagraph( mnPara );
146 pPara->Invalidate();
147 GetOutliner()->ImplCalcBulletText( mnPara, sal_False, sal_False );
150 void OutlinerUndoCheckPara::Redo()
152 Paragraph* pPara = GetOutliner()->GetParagraph( mnPara );
153 pPara->Invalidate();
154 GetOutliner()->ImplCalcBulletText( mnPara, sal_False, sal_False );
157 void OutlinerUndoCheckPara::Repeat()
159 OSL_FAIL( "Repeat not implemented!" );
162 DBG_NAME(OLUndoExpand);
164 OLUndoExpand::OLUndoExpand(Outliner* pOut, sal_uInt16 _nId )
165 : EditUndo( _nId, 0 )
167 DBG_CTOR(OLUndoExpand,0);
168 DBG_ASSERT(pOut,"Undo:No Outliner");
169 pOutliner = pOut;
170 nCount = 0;
171 pParas = 0;
175 OLUndoExpand::~OLUndoExpand()
177 DBG_DTOR(OLUndoExpand,0);
178 delete pParas;
182 void OLUndoExpand::Restore( sal_Bool bUndo )
184 DBG_CHKTHIS(OLUndoExpand,0);
185 DBG_ASSERT(pOutliner,"Undo:No Outliner");
186 DBG_ASSERT(pOutliner->pEditEngine,"Outliner already deleted");
187 Paragraph* pPara;
189 sal_Bool bExpand = sal_False;
190 sal_uInt16 _nId = GetId();
191 if((_nId == OLUNDO_EXPAND && !bUndo) || (_nId == OLUNDO_COLLAPSE && bUndo))
192 bExpand = sal_True;
193 if( !pParas )
195 pPara = pOutliner->GetParagraph( (sal_uLong)nCount );
196 if( bExpand )
197 pOutliner->Expand( pPara );
198 else
199 pOutliner->Collapse( pPara );
201 else
203 for( sal_uInt16 nIdx = 0; nIdx < nCount; nIdx++ )
205 pPara = pOutliner->GetParagraph( (sal_uLong)(pParas[nIdx]) );
206 if( bExpand )
207 pOutliner->Expand( pPara );
208 else
209 pOutliner->Collapse( pPara );
215 void OLUndoExpand::Undo()
217 DBG_CHKTHIS(OLUndoExpand,0);
218 Restore( sal_True );
222 void OLUndoExpand::Redo()
224 DBG_CHKTHIS(OLUndoExpand,0);
225 Restore( sal_False );
229 void OLUndoExpand::Repeat()
231 DBG_CHKTHIS(OLUndoExpand,0);
232 OSL_FAIL("Not implemented");
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */