xref: /aoo42x/main/sw/source/core/inc/mvsave.hxx (revision 1d2dbeb0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef SW_MVSAVE_HXX
24 #define SW_MVSAVE_HXX
25 
26 #include <tools/string.hxx>
27 #include <vcl/keycod.hxx>
28 #include <svl/svarray.hxx>
29 #include <IDocumentMarkAccess.hxx>
30 #include <vector>
31 
32 namespace sfx2 {
33     class MetadatableUndo;
34 }
35 
36 class SvNumberFormatter;
37 class SvULongs;
38 class SwDoc;
39 class SwFmtAnchor;
40 class SwFrmFmt;
41 class SwIndex;
42 class SwNodeIndex;
43 class SwNodeRange;
44 class SwPaM;
45 class SwNode;
46 struct SwPosition;
47 
48 namespace sw { namespace mark
49 {
50     class IMark;
51 
52     class SaveBookmark
53     {
54         public:
55             SaveBookmark(bool bSavePos,
56                 bool bSaveOtherPos,
57                 const ::sw::mark::IMark& rBkmk,
58                 const SwNodeIndex& rMvPos,
59                 const SwIndex* pIdx =0);
60             void SetInDoc(SwDoc* pDoc,
61                 const SwNodeIndex&,
62                 const SwIndex* pIdx =0);
GetOriginalBkmType() const63             IDocumentMarkAccess::MarkType GetOriginalBkmType() const
64                 { return m_eOrigBkmType; }
65 
66         private:
67             ::rtl::OUString m_aName;
68             ::rtl::OUString m_aShortName;
69             KeyCode m_aCode;
70             bool m_bSavePos;
71             bool m_bSaveOtherPos;
72             IDocumentMarkAccess::MarkType m_eOrigBkmType;
73             sal_uLong m_nNode1;
74             sal_uLong m_nNode2;
75             xub_StrLen m_nCntnt1;
76             xub_StrLen m_nCntnt2;
77             ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo;
78     };
79 }}
80 
81 #define SAVEFLY 1
82 #define SAVEFLY_SPLIT 2
83 
84 void _DelBookmarks(const SwNodeIndex& rStt,
85     const SwNodeIndex& rEnd,
86     ::std::vector< ::sw::mark::SaveBookmark> * SaveBkmk =0,
87     const SwIndex* pSttIdx =0,
88     const SwIndex* pEndIdx =0);
89 void _SaveCntntIdx( SwDoc* pDoc, sal_uLong nNode, xub_StrLen nCntnt,
90 					SvULongs& rSaveArr, sal_uInt8 nSaveFly = 0 );
91 void _RestoreCntntIdx( SwDoc* pDoc, SvULongs& rSaveArr,
92 						sal_uLong nNode, xub_StrLen nOffset = 0,
93 						sal_Bool bAuto = sal_False );
94 void _RestoreCntntIdx( SvULongs& rSaveArr, const SwNode& rNd,
95 						xub_StrLen nLen, xub_StrLen nCorrLen );
96 
97 
98 /** data structure to temporarily hold fly anchor positions relative to some
99  *  location. */
100 struct _SaveFly
101 {
102 	sal_uLong nNdDiff;              /// relative node difference
103 	SwFrmFmt* pFrmFmt;          /// the fly's frame format
104     sal_Bool bInsertPosition;   /// if true, anchor _at_ insert position
105 
_SaveFly_SaveFly106 	_SaveFly( sal_uLong nNodeDiff, SwFrmFmt* pFmt, sal_Bool bInsert )
107 		: nNdDiff( nNodeDiff ), pFrmFmt( pFmt ), bInsertPosition( bInsert )
108     { }
109 };
110 
111 SV_DECL_VARARR( _SaveFlyArr, _SaveFly, 0, 10 )
112 
113 void _RestFlyInRange( _SaveFlyArr& rArr, const SwNodeIndex& rSttIdx,
114                       const SwNodeIndex* pInsPos );
115 void _SaveFlyInRange( const SwNodeRange& rRg, _SaveFlyArr& rArr );
116 void _SaveFlyInRange( const SwPaM& rPam, const SwNodeIndex& rInsPos,
117 					   _SaveFlyArr& rArr, sal_Bool bMoveAllFlys );
118 
119 void DelFlyInRange( const SwNodeIndex& rMkNdIdx,
120 					const SwNodeIndex& rPtNdIdx );
121 
122 
123 class SwDataChanged
124 {
125 	const SwPaM* pPam;
126 	const SwPosition* pPos;
127 	SwDoc* pDoc;
128 	sal_uLong nNode;
129 	xub_StrLen nCntnt;
130 	sal_uInt16 nType;		// Insert/Move/Delete/... (UndoIds)
131 
132 public:
133 	SwDataChanged( const SwPaM& rPam, sal_uInt16 nType );
134 	SwDataChanged( SwDoc* pDoc, const SwPosition& rPos, sal_uInt16 nType );
135 	~SwDataChanged();
136 
GetNode() const137 	sal_uLong GetNode() const 			{ return nNode; }
GetCntnt() const138 	xub_StrLen GetCntnt() const 	{ return nCntnt; }
139 };
140 
141 
142 // Funktions-Deklaration damit auch alles unter der CrsrShell mal die
143 // Crsr verschieben kann
144 // die Funktionen rufen nicht die SwDoc::Corr - Methoden!
145 
146 	// Setzt alle PaMs im Bereich vom Range nach NewPos
147 void PaMCorrAbs( const SwPaM& rRange,
148 				 const SwPosition& rNewPos );
149 
150 	// Setzt alle PaMs in OldNode auf relative Pos
151 void PaMCorrRel( const SwNodeIndex &rOldNode,
152 				 const SwPosition &rNewPos,
153 				 const xub_StrLen nOffset = 0 );
154 
155 
156 // Hilfsklasse zum kopieren von absatzgebundenen Flys. Durch die Sortierung
157 // nach der Ordnungsnummer wird versucht die layout seitige Anordnung
158 // bei zu behalten
159 class _ZSortFly
160 {
161 	const SwFrmFmt* pFmt;
162 	const SwFmtAnchor* pAnchor;
163 	sal_uInt32 nOrdNum;
164 
165 public:
166 	_ZSortFly( const SwFrmFmt* pFrmFmt, const SwFmtAnchor* pFlyAnchor,
167 				sal_uInt32 nArrOrdNum );
operator =(const _ZSortFly & rCpy)168 	_ZSortFly& operator=( const _ZSortFly& rCpy )
169 	{
170 		pFmt = rCpy.pFmt, pAnchor = rCpy.pAnchor, nOrdNum = rCpy.nOrdNum;
171 		return *this;
172 	}
173 
operator ==(const _ZSortFly &) const174 	int operator==( const _ZSortFly& ) const { return sal_False; }
operator <(const _ZSortFly & rCmp) const175 	int operator<( const _ZSortFly& rCmp ) const
176 		{ return nOrdNum < rCmp.nOrdNum; }
177 
GetFmt() const178 	const SwFrmFmt* GetFmt() const				{ return pFmt; }
GetAnchor() const179 	const SwFmtAnchor* GetAnchor() const		{ return pAnchor; }
180 };
181 
182 SV_DECL_VARARR_SORT( _ZSortFlys, _ZSortFly, 0, 10 )
183 
184 
185 class SwTblNumFmtMerge
186 {
187 	SvNumberFormatter* pNFmt;
188 public:
189 	SwTblNumFmtMerge( const SwDoc& rSrc, SwDoc& rDest );
190 	~SwTblNumFmtMerge();
191 };
192 
193 
194 class _SaveRedlEndPosForRestore
195 {
196 	SvPtrarr* pSavArr;
197 	SwNodeIndex* pSavIdx;
198     xub_StrLen nSavCntnt;
199 
200 	void _Restore();
201 public:
202 	_SaveRedlEndPosForRestore( const SwNodeIndex& rInsIdx, xub_StrLen nCntnt );
203 	~_SaveRedlEndPosForRestore();
Restore()204 	void Restore() { if( pSavArr ) _Restore(); }
205 };
206 
207 
208 #endif  // SW_MVSAVE_HXX
209 
210