1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef SW_MVSAVE_HXX 28 #define SW_MVSAVE_HXX 29 30 #include <tools/string.hxx> 31 #include <vcl/keycod.hxx> 32 #include <svl/svarray.hxx> 33 #include <IDocumentMarkAccess.hxx> 34 #include <vector> 35 36 namespace sfx2 { 37 class MetadatableUndo; 38 } 39 40 class SvNumberFormatter; 41 class SvULongs; 42 class SwDoc; 43 class SwFmtAnchor; 44 class SwFrmFmt; 45 class SwIndex; 46 class SwNodeIndex; 47 class SwNodeRange; 48 class SwPaM; 49 class SwNode; 50 struct SwPosition; 51 52 namespace sw { namespace mark 53 { 54 class IMark; 55 56 class SaveBookmark 57 { 58 public: 59 SaveBookmark(bool bSavePos, 60 bool bSaveOtherPos, 61 const ::sw::mark::IMark& rBkmk, 62 const SwNodeIndex& rMvPos, 63 const SwIndex* pIdx =0); 64 void SetInDoc(SwDoc* pDoc, 65 const SwNodeIndex&, 66 const SwIndex* pIdx =0); 67 IDocumentMarkAccess::MarkType GetOriginalBkmType() const 68 { return m_eOrigBkmType; } 69 70 private: 71 ::rtl::OUString m_aName; 72 ::rtl::OUString m_aShortName; 73 KeyCode m_aCode; 74 bool m_bSavePos; 75 bool m_bSaveOtherPos; 76 IDocumentMarkAccess::MarkType m_eOrigBkmType; 77 sal_uLong m_nNode1; 78 sal_uLong m_nNode2; 79 xub_StrLen m_nCntnt1; 80 xub_StrLen m_nCntnt2; 81 ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo; 82 }; 83 }} 84 85 #define SAVEFLY 1 86 #define SAVEFLY_SPLIT 2 87 88 void _DelBookmarks(const SwNodeIndex& rStt, 89 const SwNodeIndex& rEnd, 90 ::std::vector< ::sw::mark::SaveBookmark> * SaveBkmk =0, 91 const SwIndex* pSttIdx =0, 92 const SwIndex* pEndIdx =0); 93 void _SaveCntntIdx( SwDoc* pDoc, sal_uLong nNode, xub_StrLen nCntnt, 94 SvULongs& rSaveArr, sal_uInt8 nSaveFly = 0 ); 95 void _RestoreCntntIdx( SwDoc* pDoc, SvULongs& rSaveArr, 96 sal_uLong nNode, xub_StrLen nOffset = 0, 97 sal_Bool bAuto = sal_False ); 98 void _RestoreCntntIdx( SvULongs& rSaveArr, const SwNode& rNd, 99 xub_StrLen nLen, xub_StrLen nCorrLen ); 100 101 102 /** data structure to temporarily hold fly anchor positions relative to some 103 * location. */ 104 struct _SaveFly 105 { 106 sal_uLong nNdDiff; /// relative node difference 107 SwFrmFmt* pFrmFmt; /// the fly's frame format 108 sal_Bool bInsertPosition; /// if true, anchor _at_ insert position 109 110 _SaveFly( sal_uLong nNodeDiff, SwFrmFmt* pFmt, sal_Bool bInsert ) 111 : nNdDiff( nNodeDiff ), pFrmFmt( pFmt ), bInsertPosition( bInsert ) 112 { } 113 }; 114 115 SV_DECL_VARARR( _SaveFlyArr, _SaveFly, 0, 10 ) 116 117 void _RestFlyInRange( _SaveFlyArr& rArr, const SwNodeIndex& rSttIdx, 118 const SwNodeIndex* pInsPos ); 119 void _SaveFlyInRange( const SwNodeRange& rRg, _SaveFlyArr& rArr ); 120 void _SaveFlyInRange( const SwPaM& rPam, const SwNodeIndex& rInsPos, 121 _SaveFlyArr& rArr, sal_Bool bMoveAllFlys ); 122 123 void DelFlyInRange( const SwNodeIndex& rMkNdIdx, 124 const SwNodeIndex& rPtNdIdx ); 125 126 127 class SwDataChanged 128 { 129 const SwPaM* pPam; 130 const SwPosition* pPos; 131 SwDoc* pDoc; 132 sal_uLong nNode; 133 xub_StrLen nCntnt; 134 sal_uInt16 nType; // Insert/Move/Delete/... (UndoIds) 135 136 public: 137 SwDataChanged( const SwPaM& rPam, sal_uInt16 nType ); 138 SwDataChanged( SwDoc* pDoc, const SwPosition& rPos, sal_uInt16 nType ); 139 ~SwDataChanged(); 140 141 sal_uLong GetNode() const { return nNode; } 142 xub_StrLen GetCntnt() const { return nCntnt; } 143 }; 144 145 146 // Funktions-Deklaration damit auch alles unter der CrsrShell mal die 147 // Crsr verschieben kann 148 // die Funktionen rufen nicht die SwDoc::Corr - Methoden! 149 150 // Setzt alle PaMs im Bereich vom Range nach NewPos 151 void PaMCorrAbs( const SwPaM& rRange, 152 const SwPosition& rNewPos ); 153 154 // Setzt alle PaMs in OldNode auf relative Pos 155 void PaMCorrRel( const SwNodeIndex &rOldNode, 156 const SwPosition &rNewPos, 157 const xub_StrLen nOffset = 0 ); 158 159 160 // Hilfsklasse zum kopieren von absatzgebundenen Flys. Durch die Sortierung 161 // nach der Ordnungsnummer wird versucht die layout seitige Anordnung 162 // bei zu behalten 163 class _ZSortFly 164 { 165 const SwFrmFmt* pFmt; 166 const SwFmtAnchor* pAnchor; 167 sal_uInt32 nOrdNum; 168 169 public: 170 _ZSortFly( const SwFrmFmt* pFrmFmt, const SwFmtAnchor* pFlyAnchor, 171 sal_uInt32 nArrOrdNum ); 172 _ZSortFly& operator=( const _ZSortFly& rCpy ) 173 { 174 pFmt = rCpy.pFmt, pAnchor = rCpy.pAnchor, nOrdNum = rCpy.nOrdNum; 175 return *this; 176 } 177 178 int operator==( const _ZSortFly& ) const { return sal_False; } 179 int operator<( const _ZSortFly& rCmp ) const 180 { return nOrdNum < rCmp.nOrdNum; } 181 182 const SwFrmFmt* GetFmt() const { return pFmt; } 183 const SwFmtAnchor* GetAnchor() const { return pAnchor; } 184 }; 185 186 SV_DECL_VARARR_SORT( _ZSortFlys, _ZSortFly, 0, 10 ) 187 188 189 class SwTblNumFmtMerge 190 { 191 SvNumberFormatter* pNFmt; 192 public: 193 SwTblNumFmtMerge( const SwDoc& rSrc, SwDoc& rDest ); 194 ~SwTblNumFmtMerge(); 195 }; 196 197 198 class _SaveRedlEndPosForRestore 199 { 200 SvPtrarr* pSavArr; 201 SwNodeIndex* pSavIdx; 202 xub_StrLen nSavCntnt; 203 204 void _Restore(); 205 public: 206 _SaveRedlEndPosForRestore( const SwNodeIndex& rInsIdx, xub_StrLen nCntnt ); 207 ~_SaveRedlEndPosForRestore(); 208 void Restore() { if( pSavArr ) _Restore(); } 209 }; 210 211 212 #endif // SW_MVSAVE_HXX 213 214