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