1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: outlundo.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #include <outl_pch.hxx>
37 #include <svx/outliner.hxx>
38 #include <outlundo.hxx>
41 OutlinerUndoBase::OutlinerUndoBase( USHORT _nId
, Outliner
* pOutliner
)
42 : EditUndo( _nId
, NULL
)
44 DBG_ASSERT( pOutliner
, "Undo: Outliner?!" );
45 mpOutliner
= pOutliner
;
48 OutlinerUndoChangeParaFlags::OutlinerUndoChangeParaFlags( Outliner
* pOutliner
, sal_uInt16 nPara
, sal_uInt16 nOldFlags
, sal_uInt16 nNewFlags
)
49 : OutlinerUndoBase( OLUNDO_DEPTH
, pOutliner
)
52 mnOldFlags
= nOldFlags
;
53 mnNewFlags
= nNewFlags
;
56 void OutlinerUndoChangeParaFlags::Undo()
58 ImplChangeFlags( mnOldFlags
);
61 void OutlinerUndoChangeParaFlags::Redo()
63 ImplChangeFlags( mnNewFlags
);
66 void OutlinerUndoChangeParaFlags::ImplChangeFlags( sal_uInt16 nFlags
)
68 Outliner
* pOutliner
= GetOutliner();
69 Paragraph
* pPara
= pOutliner
->GetParagraph( mnPara
);
72 pOutliner
->nDepthChangedHdlPrevDepth
= pPara
->GetDepth();
73 pOutliner
->mnDepthChangeHdlPrevFlags
= pPara
->nFlags
;
74 pOutliner
->pHdlParagraph
= pPara
;
76 pPara
->nFlags
= nFlags
;
77 pOutliner
->DepthChangedHdl();
81 OutlinerUndoChangeParaNumberingRestart::OutlinerUndoChangeParaNumberingRestart( Outliner
* pOutliner
, sal_uInt16 nPara
,
82 sal_Int16 nOldNumberingStartValue
, sal_Int16 nNewNumberingStartValue
,
83 sal_Bool bOldParaIsNumberingRestart
, sal_Bool bNewParaIsNumberingRestart
)
84 : OutlinerUndoBase( OLUNDO_DEPTH
, pOutliner
)
88 maUndoData
.mnNumberingStartValue
= nOldNumberingStartValue
;
89 maUndoData
.mbParaIsNumberingRestart
= bOldParaIsNumberingRestart
;
90 maRedoData
.mnNumberingStartValue
= nNewNumberingStartValue
;
91 maRedoData
.mbParaIsNumberingRestart
= bNewParaIsNumberingRestart
;
94 void OutlinerUndoChangeParaNumberingRestart::Undo()
96 ImplApplyData( maUndoData
);
99 void OutlinerUndoChangeParaNumberingRestart::Redo()
101 ImplApplyData( maRedoData
);
104 void OutlinerUndoChangeParaNumberingRestart::ImplApplyData( const ParaRestartData
& rData
)
106 Outliner
* pOutliner
= GetOutliner();
107 pOutliner
->SetNumberingStartValue( mnPara
, rData
.mnNumberingStartValue
);
108 pOutliner
->SetParaIsNumberingRestart( mnPara
, rData
.mbParaIsNumberingRestart
);
111 OutlinerUndoChangeDepth::OutlinerUndoChangeDepth( Outliner
* pOutliner
, USHORT nPara
, sal_Int16 nOldDepth
, sal_Int16 nNewDepth
)
112 : OutlinerUndoBase( OLUNDO_DEPTH
, pOutliner
)
115 mnOldDepth
= nOldDepth
;
116 mnNewDepth
= nNewDepth
;
119 void OutlinerUndoChangeDepth::Undo()
121 GetOutliner()->ImplInitDepth( mnPara
, mnOldDepth
, FALSE
);
124 void OutlinerUndoChangeDepth::Redo()
126 GetOutliner()->ImplInitDepth( mnPara
, mnNewDepth
, FALSE
);
129 void OutlinerUndoChangeDepth::Repeat()
131 DBG_ERROR( "Repeat not implemented!" );
135 OutlinerUndoCheckPara::OutlinerUndoCheckPara( Outliner
* pOutliner
, USHORT nPara
)
136 : OutlinerUndoBase( OLUNDO_DEPTH
, pOutliner
)
141 void OutlinerUndoCheckPara::Undo()
143 Paragraph
* pPara
= GetOutliner()->GetParagraph( mnPara
);
145 GetOutliner()->ImplCalcBulletText( mnPara
, FALSE
, FALSE
);
148 void OutlinerUndoCheckPara::Redo()
150 Paragraph
* pPara
= GetOutliner()->GetParagraph( mnPara
);
152 GetOutliner()->ImplCalcBulletText( mnPara
, FALSE
, FALSE
);
155 void OutlinerUndoCheckPara::Repeat()
157 DBG_ERROR( "Repeat not implemented!" );
160 DBG_NAME(OLUndoExpand
);
162 OLUndoExpand::OLUndoExpand(Outliner
* pOut
, USHORT _nId
)
163 : EditUndo( _nId
, 0 )
165 DBG_CTOR(OLUndoExpand
,0);
166 DBG_ASSERT(pOut
,"Undo:No Outliner");
173 OLUndoExpand::~OLUndoExpand()
175 DBG_DTOR(OLUndoExpand
,0);
180 void OLUndoExpand::Restore( BOOL bUndo
)
182 DBG_CHKTHIS(OLUndoExpand
,0);
183 DBG_ASSERT(pOutliner
,"Undo:No Outliner");
184 DBG_ASSERT(pOutliner
->pEditEngine
,"Outliner already deleted");
187 BOOL bExpand
= FALSE
;
188 USHORT _nId
= GetId();
189 if((_nId
== OLUNDO_EXPAND
&& !bUndo
) || (_nId
== OLUNDO_COLLAPSE
&& bUndo
))
193 pPara
= pOutliner
->GetParagraph( (ULONG
)nCount
);
195 pOutliner
->Expand( pPara
);
197 pOutliner
->Collapse( pPara
);
201 for( USHORT nIdx
= 0; nIdx
< nCount
; nIdx
++ )
203 pPara
= pOutliner
->GetParagraph( (ULONG
)(pParas
[nIdx
]) );
205 pOutliner
->Expand( pPara
);
207 pOutliner
->Collapse( pPara
);
213 void OLUndoExpand::Undo()
215 DBG_CHKTHIS(OLUndoExpand
,0);
220 void OLUndoExpand::Redo()
222 DBG_CHKTHIS(OLUndoExpand
,0);
227 void OLUndoExpand::Repeat()
229 DBG_CHKTHIS(OLUndoExpand
,0);
230 DBG_ERROR("Not implemented");