nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / core / inc / mvsave.hxx
blob6aeefcd950d3ddd3c6f9d8f02e9f7f980e7ed175
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_SOURCE_CORE_INC_MVSAVE_HXX
20 #define INCLUDED_SW_SOURCE_CORE_INC_MVSAVE_HXX
22 #include <vcl/keycod.hxx>
23 #include <IDocumentMarkAccess.hxx>
24 #include <vector>
25 #include <deque>
26 #include <o3tl/typed_flags_set.hxx>
28 namespace sfx2 {
29 class MetadatableUndo;
32 class SvNumberFormatter;
33 class SwDoc;
34 class SwFormatAnchor;
35 class SwFrameFormat;
36 class SwIndex;
37 class SwNodeIndex;
38 class SwNodeRange;
39 class SwPaM;
40 class SwNode;
41 struct SwPosition;
43 namespace sw::mark
45 class IMark;
47 class SaveBookmark
49 public:
50 SaveBookmark(
51 const ::sw::mark::IMark& rBkmk,
52 const SwNodeIndex& rMvPos,
53 const SwIndex* pIdx);
54 void SetInDoc(SwDoc* pDoc,
55 const SwNodeIndex&,
56 const SwIndex* pIdx =nullptr);
58 private:
59 OUString m_aName;
60 OUString m_aShortName;
61 bool m_bHidden;
62 OUString m_aHideCondition;
63 vcl::KeyCode m_aCode;
64 IDocumentMarkAccess::MarkType m_eOrigBkmType;
65 sal_uLong m_nNode1;
66 sal_uLong m_nNode2;
67 sal_Int32 m_nContent1;
68 sal_Int32 m_nContent2;
69 std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo;
72 enum class RestoreMode { Flys = 1, NonFlys = 2, All = 3 };
74 /// Takes care of storing relevant attributes of an SwTextNode before split, then restore them on the new node.
75 class ContentIdxStore
77 public:
79 virtual void Clear() =0;
80 virtual bool Empty() =0;
81 virtual void Save(SwDoc& rDoc, sal_uLong nNode, sal_Int32 nContent, bool bSaveFlySplit=false) =0;
82 virtual void Restore(SwDoc& rDoc, sal_uLong nNode, sal_Int32 nOffset=0, bool bAuto = false, RestoreMode = RestoreMode::All) =0;
83 virtual void Restore(SwNode& rNd, sal_Int32 nLen, sal_Int32 nCorrLen, RestoreMode = RestoreMode::All) =0;
84 virtual ~ContentIdxStore() {};
85 static std::shared_ptr<ContentIdxStore> Create();
89 namespace o3tl {
90 template<> struct typed_flags<sw::mark::RestoreMode> : is_typed_flags<sw::mark::RestoreMode, 3> {};
93 void DelBookmarks(const SwNodeIndex& rStt,
94 const SwNodeIndex& rEnd,
95 std::vector< ::sw::mark::SaveBookmark> * SaveBkmk =nullptr,
96 const SwIndex* pSttIdx =nullptr,
97 const SwIndex* pEndIdx =nullptr);
99 /** data structure to temporarily hold fly anchor positions relative to some
100 * location. */
101 struct SaveFly
103 SwFrameFormat* pFrameFormat; /// the fly's frame format
104 sal_uLong nNdDiff; /// relative node difference
105 sal_Int32 nContentIndex; ///< index in node
106 bool isAtInsertNode; ///< if true, anchor _at_ insert node index
108 SaveFly( sal_uLong nNodeDiff, sal_Int32 const nCntntIdx, SwFrameFormat* pFormat, bool bInsert )
109 : pFrameFormat(pFormat)
110 , nNdDiff(nNodeDiff)
111 , nContentIndex(nCntntIdx)
112 , isAtInsertNode(bInsert)
116 typedef std::deque< SaveFly > SaveFlyArr;
118 void RestFlyInRange( SaveFlyArr& rArr, const SwPosition& rSttIdx,
119 const SwNodeIndex* pInsPos );
120 void SaveFlyInRange( const SwNodeRange& rRg, SaveFlyArr& rArr );
121 void SaveFlyInRange( const SwPaM& rPam, const SwPosition& rInsPos,
122 SaveFlyArr& rArr, bool bMoveAllFlys );
124 void DelFlyInRange( const SwNodeIndex& rMkNdIdx,
125 const SwNodeIndex& rPtNdIdx,
126 SwIndex const* pMkIdx = nullptr,
127 SwIndex const* pPtIdx = nullptr);
129 class SwDataChanged
131 const SwPaM* m_pPam;
132 const SwPosition* m_pPos;
133 SwDoc& m_rDoc;
134 sal_Int32 m_nContent;
136 public:
137 SwDataChanged( const SwPaM& rPam );
138 SwDataChanged( SwDoc& rDoc, const SwPosition& rPos );
139 ~SwDataChanged();
141 sal_Int32 GetContent() const { return m_nContent; }
145 * Function declarations so that everything below the CursorShell can
146 * move the Cursor once in a while.
147 * These functions do not call the SwDoc::Corr methods!
149 void PaMCorrAbs( const SwPaM& rRange,
150 const SwPosition& rNewPos );
152 /// Sets all PaMs in OldNode to relative Pos
153 void PaMCorrRel( const SwNodeIndex &rOldNode,
154 const SwPosition &rNewPos,
155 const sal_Int32 nOffset = 0 );
158 * Helper to copy paragraph-bound Flys.
159 * By sorting by order number, we try to retain the layout.
161 class ZSortFly
163 const SwFrameFormat* m_pFormat;
164 const SwFormatAnchor* m_pAnchor;
165 sal_uInt32 m_nOrdNum;
167 public:
168 ZSortFly( const SwFrameFormat* pFrameFormat, const SwFormatAnchor* pFlyAnchor,
169 sal_uInt32 nArrOrdNum );
171 bool operator==( const ZSortFly& ) const { return false; }
172 bool operator<( const ZSortFly& rCmp ) const
173 { return m_nOrdNum < rCmp.m_nOrdNum; }
175 const SwFrameFormat* GetFormat() const { return m_pFormat; }
176 const SwFormatAnchor* GetAnchor() const { return m_pAnchor; }
179 class SwTableNumFormatMerge
181 SvNumberFormatter* pNFormat;
182 public:
183 SwTableNumFormatMerge( const SwDoc& rSrc, SwDoc& rDest );
184 ~SwTableNumFormatMerge();
187 class SaveRedlEndPosForRestore
189 std::vector<SwPosition*> mvSavArr;
190 std::unique_ptr<SwNodeIndex> mpSaveIndex;
191 sal_Int32 mnSaveContent;
193 public:
194 SaveRedlEndPosForRestore( const SwNodeIndex& rInsIdx, sal_Int32 nContent );
195 ~SaveRedlEndPosForRestore();
196 void Restore();
199 #endif // INCLUDED_SW_SOURCE_CORE_INC_MVSAVE_HXX
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */