update dev300-m58
[ooovba.git] / sw / source / core / inc / mvsave.hxx
blobe6c864f93e64b31b0388da3c452a89ecf91d9ee1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: mvsave.hxx,v $
10 * $Revision: 1.9 $
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 ************************************************************************/
30 #ifndef _MVSAVE_HXX
31 #define _MVSAVE_HXX
34 #include <tools/string.hxx>
35 #ifndef _KEYCOD_HXX //autogen
36 #include <vcl/keycod.hxx>
37 #endif
38 #include <svtools/svarray.hxx>
39 #include <IDocumentMarkAccess.hxx>
40 #include <vector>
42 class SvNumberFormatter;
43 class SvULongs;
44 class SwDoc;
45 class SwFmtAnchor;
46 class SwFrmFmt;
47 class SwIndex;
48 class SwNodeIndex;
49 class SwNodeRange;
50 class SwPaM;
51 class SwNode;
52 struct SwPosition;
54 namespace sw { namespace mark
56 class IMark;
58 class SaveBookmark
60 public:
61 SaveBookmark(bool bSavePos,
62 bool bSaveOtherPos,
63 const ::sw::mark::IMark& rBkmk,
64 const SwNodeIndex& rMvPos,
65 const SwIndex* pIdx =0);
66 void SetInDoc(SwDoc* pDoc,
67 const SwNodeIndex&,
68 const SwIndex* pIdx =0);
69 IDocumentMarkAccess::MarkType GetOriginalBkmType() const
70 { return m_eOrigBkmType; }
72 private:
73 ::rtl::OUString m_aName;
74 ::rtl::OUString m_aShortName;
75 KeyCode m_aCode;
76 bool m_bSavePos;
77 bool m_bSaveOtherPos;
78 IDocumentMarkAccess::MarkType m_eOrigBkmType;
79 ULONG m_nNode1;
80 ULONG m_nNode2;
81 xub_StrLen m_nCntnt1;
82 xub_StrLen m_nCntnt2;
86 #define SAVEFLY 1
87 #define SAVEFLY_SPLIT 2
89 void _DelBookmarks(const SwNodeIndex& rStt,
90 const SwNodeIndex& rEnd,
91 ::std::vector< ::sw::mark::SaveBookmark> * SaveBkmk =0,
92 const SwIndex* pSttIdx =0,
93 const SwIndex* pEndIdx =0);
94 void _SaveCntntIdx( SwDoc* pDoc, ULONG nNode, xub_StrLen nCntnt,
95 SvULongs& rSaveArr, BYTE nSaveFly = 0 );
96 void _RestoreCntntIdx( SwDoc* pDoc, SvULongs& rSaveArr,
97 ULONG nNode, xub_StrLen nOffset = 0,
98 BOOL bAuto = FALSE );
99 void _RestoreCntntIdx( SvULongs& rSaveArr, const SwNode& rNd,
100 xub_StrLen nLen, xub_StrLen nCorrLen );
103 /** data structure to temporarily hold fly anchor positions relative to some
104 * location. */
105 struct _SaveFly
107 ULONG nNdDiff; /// relative node difference
108 SwFrmFmt* pFrmFmt; /// the fly's frame format
109 sal_Bool bInsertPosition; /// if true, anchor _at_ insert position
111 _SaveFly( ULONG nNodeDiff, SwFrmFmt* pFmt, sal_Bool bInsert )
112 : nNdDiff( nNodeDiff ), pFrmFmt( pFmt ), bInsertPosition( bInsert )
116 SV_DECL_VARARR( _SaveFlyArr, _SaveFly, 0, 10 )
118 void _RestFlyInRange( _SaveFlyArr& rArr, const SwNodeIndex& rSttIdx,
119 const SwNodeIndex* pInsPos );
120 void _SaveFlyInRange( const SwNodeRange& rRg, _SaveFlyArr& rArr );
121 void _SaveFlyInRange( const SwPaM& rPam, const SwNodeIndex& rInsPos,
122 _SaveFlyArr& rArr, sal_Bool bMoveAllFlys );
124 void DelFlyInRange( const SwNodeIndex& rMkNdIdx,
125 const SwNodeIndex& rPtNdIdx );
128 class SwDataChanged
130 const SwPaM* pPam;
131 const SwPosition* pPos;
132 SwDoc* pDoc;
133 ULONG nNode;
134 xub_StrLen nCntnt;
135 USHORT nType; // Insert/Move/Delete/... (UndoIds)
137 public:
138 SwDataChanged( const SwPaM& rPam, USHORT nType );
139 SwDataChanged( SwDoc* pDoc, const SwPosition& rPos, USHORT nType );
140 ~SwDataChanged();
142 ULONG GetNode() const { return nNode; }
143 xub_StrLen GetCntnt() const { return nCntnt; }
147 // Funktions-Deklaration damit auch alles unter der CrsrShell mal die
148 // Crsr verschieben kann
149 // die Funktionen rufen nicht die SwDoc::Corr - Methoden!
151 // Setzt alle PaMs an OldPos auf NewPos + Offset
152 void PaMCorrAbs( const SwPosition &rOldPos,
153 const SwPosition &rNewPos,
154 const xub_StrLen nOffset = 0 );
156 // Setzt alle PaMs in OldNode auf NewPos + Offset
157 void PaMCorrAbs( const SwNodeIndex &rOldNode,
158 const SwPosition &rNewPos,
159 const xub_StrLen nOffset = 0 );
161 // Setzt alle PaMs im Bereich vom Range nach NewPos
162 void PaMCorrAbs( const SwPaM& rRange,
163 const SwPosition& rNewPos );
165 // Setzt alle PaMs im Bereich von [StartNode, EndNode] nach NewPos
166 void PaMCorrAbs( const SwNodeIndex &rStartNode,
167 const SwNodeIndex &rEndNode,
168 const SwPosition &rNewPos );
170 // Setzt alle PaMs in OldNode auf relative Pos
171 void PaMCorrRel( const SwNodeIndex &rOldNode,
172 const SwPosition &rNewPos,
173 const xub_StrLen nOffset = 0 );
176 // Hilfsklasse zum kopieren von absatzgebundenen Flys. Durch die Sortierung
177 // nach der Ordnungsnummer wird versucht die layout seitige Anordnung
178 // bei zu behalten
179 class _ZSortFly
181 const SwFrmFmt* pFmt;
182 const SwFmtAnchor* pAnchor;
183 UINT32 nOrdNum;
185 public:
186 _ZSortFly( const SwFrmFmt* pFrmFmt, const SwFmtAnchor* pFlyAnchor,
187 UINT32 nArrOrdNum );
188 _ZSortFly& operator=( const _ZSortFly& rCpy )
190 pFmt = rCpy.pFmt, pAnchor = rCpy.pAnchor, nOrdNum = rCpy.nOrdNum;
191 return *this;
194 int operator==( const _ZSortFly& ) const { return FALSE; }
195 int operator<( const _ZSortFly& rCmp ) const
196 { return nOrdNum < rCmp.nOrdNum; }
198 const SwFrmFmt* GetFmt() const { return pFmt; }
199 const SwFmtAnchor* GetAnchor() const { return pAnchor; }
202 SV_DECL_VARARR_SORT( _ZSortFlys, _ZSortFly, 0, 10 )
205 class SwTblNumFmtMerge
207 SvNumberFormatter* pNFmt;
208 public:
209 SwTblNumFmtMerge( const SwDoc& rSrc, SwDoc& rDest );
210 ~SwTblNumFmtMerge();
214 class _SaveRedlEndPosForRestore
216 SvPtrarr* pSavArr;
217 SwNodeIndex* pSavIdx;
218 xub_StrLen nSavCntnt;
220 void _Restore();
221 public:
222 _SaveRedlEndPosForRestore( const SwNodeIndex& rInsIdx, xub_StrLen nCntnt );
223 ~_SaveRedlEndPosForRestore();
224 void Restore() { if( pSavArr ) _Restore(); }
228 #endif // _MVSAVE_HXX