1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <editeng/outliner.hxx>
22 #include <tools/debug.hxx>
23 #include "outlundo.hxx"
26 OutlinerUndoBase::OutlinerUndoBase( sal_uInt16 _nId
, Outliner
* pOutliner
)
27 : EditUndo( _nId
, nullptr )
29 DBG_ASSERT( pOutliner
, "Undo: Outliner?!" );
30 mpOutliner
= pOutliner
;
33 OutlinerUndoChangeParaFlags::OutlinerUndoChangeParaFlags( Outliner
* pOutliner
, sal_Int32 nPara
, ParaFlag nOldFlags
, ParaFlag nNewFlags
)
34 : OutlinerUndoBase( OLUNDO_DEPTH
, pOutliner
), mnPara(nPara
), mnOldFlags(nOldFlags
), mnNewFlags(nNewFlags
)
38 void OutlinerUndoChangeParaFlags::Undo()
40 ImplChangeFlags( mnOldFlags
);
43 void OutlinerUndoChangeParaFlags::Redo()
45 ImplChangeFlags( mnNewFlags
);
48 void OutlinerUndoChangeParaFlags::ImplChangeFlags( ParaFlag nFlags
)
50 Outliner
* pOutliner
= GetOutliner();
51 Paragraph
* pPara
= pOutliner
->GetParagraph( mnPara
);
54 pOutliner
->nDepthChangedHdlPrevDepth
= pPara
->GetDepth();
55 ParaFlag nPrevFlags
= pPara
->nFlags
;
57 pPara
->nFlags
= nFlags
;
58 pOutliner
->DepthChangedHdl(pPara
, nPrevFlags
);
62 OutlinerUndoChangeParaNumberingRestart::OutlinerUndoChangeParaNumberingRestart( Outliner
* pOutliner
, sal_Int32 nPara
,
63 sal_Int16 nOldNumberingStartValue
, sal_Int16 nNewNumberingStartValue
,
64 bool bOldParaIsNumberingRestart
, bool bNewParaIsNumberingRestart
)
65 : OutlinerUndoBase( OLUNDO_DEPTH
, pOutliner
), mnPara(nPara
)
67 maUndoData
.mnNumberingStartValue
= nOldNumberingStartValue
;
68 maUndoData
.mbParaIsNumberingRestart
= bOldParaIsNumberingRestart
;
69 maRedoData
.mnNumberingStartValue
= nNewNumberingStartValue
;
70 maRedoData
.mbParaIsNumberingRestart
= bNewParaIsNumberingRestart
;
73 void OutlinerUndoChangeParaNumberingRestart::Undo()
75 ImplApplyData( maUndoData
);
78 void OutlinerUndoChangeParaNumberingRestart::Redo()
80 ImplApplyData( maRedoData
);
83 void OutlinerUndoChangeParaNumberingRestart::ImplApplyData( const ParaRestartData
& rData
)
85 Outliner
* pOutliner
= GetOutliner();
86 pOutliner
->SetNumberingStartValue( mnPara
, rData
.mnNumberingStartValue
);
87 pOutliner
->SetParaIsNumberingRestart( mnPara
, rData
.mbParaIsNumberingRestart
);
90 OutlinerUndoChangeDepth::OutlinerUndoChangeDepth( Outliner
* pOutliner
, sal_Int32 nPara
, sal_Int16 nOldDepth
, sal_Int16 nNewDepth
)
91 : OutlinerUndoBase( OLUNDO_DEPTH
, pOutliner
), mnPara(nPara
), mnOldDepth(nOldDepth
), mnNewDepth(nNewDepth
)
95 void OutlinerUndoChangeDepth::Undo()
97 GetOutliner()->ImplInitDepth( mnPara
, mnOldDepth
, false );
100 void OutlinerUndoChangeDepth::Redo()
102 GetOutliner()->ImplInitDepth( mnPara
, mnNewDepth
, false );
105 OutlinerUndoCheckPara::OutlinerUndoCheckPara( Outliner
* pOutliner
, sal_Int32 nPara
)
106 : OutlinerUndoBase( OLUNDO_DEPTH
, pOutliner
), mnPara(nPara
)
110 void OutlinerUndoCheckPara::Undo()
112 Paragraph
* pPara
= GetOutliner()->GetParagraph( mnPara
);
114 GetOutliner()->ImplCalcBulletText( mnPara
, false, false );
117 void OutlinerUndoCheckPara::Redo()
119 Paragraph
* pPara
= GetOutliner()->GetParagraph( mnPara
);
121 GetOutliner()->ImplCalcBulletText( mnPara
, false, false );
124 OLUndoExpand::OLUndoExpand(Outliner
* pOut
, sal_uInt16 _nId
)
125 : EditUndo( _nId
, nullptr ), pOutliner(pOut
), nCount(0)
127 DBG_ASSERT(pOut
,"Undo:No Outliner");
131 OLUndoExpand::~OLUndoExpand()
136 void OLUndoExpand::Restore( bool bUndo
)
138 DBG_ASSERT(pOutliner
,"Undo:No Outliner");
139 DBG_ASSERT(pOutliner
->pEditEngine
,"Outliner already deleted");
142 bool bExpand
= false;
143 sal_uInt16 _nId
= GetId();
144 if((_nId
== OLUNDO_EXPAND
&& !bUndo
) || (_nId
== OLUNDO_COLLAPSE
&& bUndo
))
147 pPara
= pOutliner
->GetParagraph( nCount
);
149 pOutliner
->Expand( pPara
);
151 pOutliner
->Collapse( pPara
);
154 void OLUndoExpand::Undo()
159 void OLUndoExpand::Redo()
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */