Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef SW_MVSAVE_HXX
20 : #define SW_MVSAVE_HXX
21 :
22 : #include <vcl/keycod.hxx>
23 : #include <IDocumentMarkAccess.hxx>
24 : #include <vector>
25 : #include <deque>
26 :
27 : namespace sfx2 {
28 : class MetadatableUndo;
29 : }
30 :
31 : class SvNumberFormatter;
32 : class SwDoc;
33 : class SwFmtAnchor;
34 : class SwFrmFmt;
35 : class SwIndex;
36 : class SwNodeIndex;
37 : class SwNodeRange;
38 : class SwPaM;
39 : class SwNode;
40 : struct SwPosition;
41 :
42 : namespace sw { namespace mark
43 : {
44 : class IMark;
45 :
46 0 : class SaveBookmark
47 : {
48 : public:
49 : SaveBookmark(bool bSavePos,
50 : bool bSaveOtherPos,
51 : const ::sw::mark::IMark& rBkmk,
52 : const SwNodeIndex& rMvPos,
53 : const SwIndex* pIdx =0);
54 : void SetInDoc(SwDoc* pDoc,
55 : const SwNodeIndex&,
56 : const SwIndex* pIdx =0);
57 : IDocumentMarkAccess::MarkType GetOriginalBkmType() const
58 : { return m_eOrigBkmType; }
59 :
60 : private:
61 : ::rtl::OUString m_aName;
62 : ::rtl::OUString m_aShortName;
63 : KeyCode m_aCode;
64 : bool m_bSavePos;
65 : bool m_bSaveOtherPos;
66 : IDocumentMarkAccess::MarkType m_eOrigBkmType;
67 : sal_uLong m_nNode1;
68 : sal_uLong m_nNode2;
69 : xub_StrLen m_nCntnt1;
70 : xub_StrLen m_nCntnt2;
71 : ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo;
72 : };
73 : }}
74 :
75 : #define SAVEFLY 1
76 : #define SAVEFLY_SPLIT 2
77 :
78 : void _DelBookmarks(const SwNodeIndex& rStt,
79 : const SwNodeIndex& rEnd,
80 : ::std::vector< ::sw::mark::SaveBookmark> * SaveBkmk =0,
81 : const SwIndex* pSttIdx =0,
82 : const SwIndex* pEndIdx =0);
83 : void _SaveCntntIdx( SwDoc* pDoc, sal_uLong nNode, xub_StrLen nCntnt,
84 : std::vector<sal_uLong>& rSaveArr, sal_uInt8 nSaveFly = 0 );
85 : void _RestoreCntntIdx( SwDoc* pDoc, std::vector<sal_uLong>& rSaveArr,
86 : sal_uLong nNode, xub_StrLen nOffset = 0,
87 : bool bAuto = false );
88 : void _RestoreCntntIdx( std::vector<sal_uLong>& rSaveArr, const SwNode& rNd,
89 : xub_StrLen nLen, xub_StrLen nCorrLen );
90 :
91 :
92 : /** data structure to temporarily hold fly anchor positions relative to some
93 : * location. */
94 : struct _SaveFly
95 : {
96 : sal_uLong nNdDiff; /// relative node difference
97 : SwFrmFmt* pFrmFmt; /// the fly's frame format
98 : bool bInsertPosition; /// if true, anchor _at_ insert position
99 :
100 0 : _SaveFly( sal_uLong nNodeDiff, SwFrmFmt* pFmt, bool bInsert )
101 0 : : nNdDiff( nNodeDiff ), pFrmFmt( pFmt ), bInsertPosition( bInsert )
102 0 : { }
103 : };
104 :
105 : typedef ::std::deque< _SaveFly > _SaveFlyArr;
106 :
107 : void _RestFlyInRange( _SaveFlyArr& rArr, const SwNodeIndex& rSttIdx,
108 : const SwNodeIndex* pInsPos );
109 : void _SaveFlyInRange( const SwNodeRange& rRg, _SaveFlyArr& rArr );
110 : void _SaveFlyInRange( const SwPaM& rPam, const SwNodeIndex& rInsPos,
111 : _SaveFlyArr& rArr, sal_Bool bMoveAllFlys );
112 :
113 : void DelFlyInRange( const SwNodeIndex& rMkNdIdx,
114 : const SwNodeIndex& rPtNdIdx );
115 :
116 :
117 : class SwDataChanged
118 : {
119 : const SwPaM* pPam;
120 : const SwPosition* pPos;
121 : SwDoc* pDoc;
122 : sal_uLong nNode;
123 : xub_StrLen nCntnt;
124 :
125 : public:
126 : SwDataChanged( const SwPaM& rPam );
127 : SwDataChanged( SwDoc* pDoc, const SwPosition& rPos );
128 : ~SwDataChanged();
129 :
130 : sal_uLong GetNode() const { return nNode; }
131 714 : xub_StrLen GetCntnt() const { return nCntnt; }
132 : };
133 :
134 :
135 : // Funktions-Deklaration damit auch alles unter der CrsrShell mal die
136 : // Crsr verschieben kann
137 : // die Funktionen rufen nicht die SwDoc::Corr - Methoden!
138 :
139 : // Setzt alle PaMs im Bereich vom Range nach NewPos
140 : void PaMCorrAbs( const SwPaM& rRange,
141 : const SwPosition& rNewPos );
142 :
143 : // Setzt alle PaMs in OldNode auf relative Pos
144 : void PaMCorrRel( const SwNodeIndex &rOldNode,
145 : const SwPosition &rNewPos,
146 : const xub_StrLen nOffset = 0 );
147 :
148 :
149 : // Hilfsklasse zum kopieren von absatzgebundenen Flys. Durch die Sortierung
150 : // nach der Ordnungsnummer wird versucht die layout seitige Anordnung
151 : // bei zu behalten
152 : class _ZSortFly
153 : {
154 : const SwFrmFmt* pFmt;
155 : const SwFmtAnchor* pAnchor;
156 : sal_uInt32 nOrdNum;
157 :
158 : public:
159 : _ZSortFly( const SwFrmFmt* pFrmFmt, const SwFmtAnchor* pFlyAnchor,
160 : sal_uInt32 nArrOrdNum );
161 : _ZSortFly& operator=( const _ZSortFly& rCpy )
162 : {
163 : pFmt = rCpy.pFmt, pAnchor = rCpy.pAnchor, nOrdNum = rCpy.nOrdNum;
164 : return *this;
165 : }
166 :
167 : int operator==( const _ZSortFly& ) const { return sal_False; }
168 7 : int operator<( const _ZSortFly& rCmp ) const
169 7 : { return nOrdNum < rCmp.nOrdNum; }
170 :
171 30 : const SwFrmFmt* GetFmt() const { return pFmt; }
172 6 : const SwFmtAnchor* GetAnchor() const { return pAnchor; }
173 : };
174 :
175 :
176 : class SwTblNumFmtMerge
177 : {
178 : SvNumberFormatter* pNFmt;
179 : public:
180 : SwTblNumFmtMerge( const SwDoc& rSrc, SwDoc& rDest );
181 : ~SwTblNumFmtMerge();
182 : };
183 :
184 :
185 : class _SaveRedlEndPosForRestore
186 : {
187 : std::vector<SwPosition*>* pSavArr;
188 : SwNodeIndex* pSavIdx;
189 : xub_StrLen nSavCntnt;
190 :
191 : void _Restore();
192 : public:
193 : _SaveRedlEndPosForRestore( const SwNodeIndex& rInsIdx, xub_StrLen nCntnt );
194 : ~_SaveRedlEndPosForRestore();
195 18 : void Restore() { if( pSavArr ) _Restore(); }
196 : };
197 :
198 :
199 : #endif // SW_MVSAVE_HXX
200 :
201 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|