Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / core / inc / mvsave.hxx
blob024276b78ccded8056e0ea4504393f54fd6bff14
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 <ndindex.hxx>
25 #include <deque>
26 #include <optional>
27 #include <vector>
28 #include <o3tl/typed_flags_set.hxx>
30 namespace sfx2 {
31 class MetadatableUndo;
34 class SvNumberFormatter;
35 class SwDoc;
36 class SwFormatAnchor;
37 class SwFrameFormat;
38 class SwContentIndex;
39 class SwNodeRange;
40 class SwPaM;
41 class SwNode;
42 struct SwPosition;
44 namespace sw::mark
46 class IMark;
48 class SaveBookmark
50 public:
51 SaveBookmark(
52 const ::sw::mark::IMark& rBkmk,
53 const SwNode& rMvPos,
54 std::optional<sal_Int32> oContentIdx);
55 void SetInDoc(SwDoc* pDoc,
56 const SwNode&,
57 std::optional<sal_Int32> oContentIdx = std::nullopt);
59 private:
60 OUString m_aName;
61 OUString m_aShortName;
62 bool m_bHidden;
63 OUString m_aHideCondition;
64 vcl::KeyCode m_aCode;
65 IDocumentMarkAccess::MarkType m_eOrigBkmType;
66 SwNodeOffset m_nNode1;
67 SwNodeOffset m_nNode2;
68 sal_Int32 m_nContent1;
69 sal_Int32 m_nContent2;
70 std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo;
73 enum class RestoreMode { Flys = 1, NonFlys = 2, All = 3 };
75 /// Takes care of storing relevant attributes of an SwTextNode before split, then restore them on the new node.
76 class ContentIdxStore
78 public:
80 virtual void Clear() =0;
81 virtual bool Empty() =0;
82 virtual void Save(SwDoc& rDoc, SwNodeOffset nNode, sal_Int32 nContent, bool bSaveFlySplit=false) =0;
83 virtual void Restore(SwDoc& rDoc, SwNodeOffset nNode, sal_Int32 nOffset=0, bool bAuto = false, bool bAtStart = false, RestoreMode = RestoreMode::All) =0;
84 virtual void Restore(SwNode& rNd, sal_Int32 nLen, sal_Int32 nCorrLen, RestoreMode = RestoreMode::All) =0;
85 virtual ~ContentIdxStore() {};
86 static std::shared_ptr<ContentIdxStore> Create();
90 namespace o3tl {
91 template<> struct typed_flags<sw::mark::RestoreMode> : is_typed_flags<sw::mark::RestoreMode, 3> {};
94 void DelBookmarks(SwNode& rStt,
95 const SwNode& rEnd,
96 std::vector< ::sw::mark::SaveBookmark> * SaveBkmk =nullptr,
97 std::optional<sal_Int32> oStartContentIdx = std::nullopt,
98 std::optional<sal_Int32> oEndContentIdx = std::nullopt);
100 /** data structure to temporarily hold fly anchor positions relative to some
101 * location. */
102 struct SaveFly
104 SwFrameFormat* pFrameFormat; /// the fly's frame format
105 SwNodeOffset nNdDiff; /// relative node difference
106 sal_Int32 nContentIndex; ///< index in node
107 bool isAtInsertNode; ///< if true, anchor _at_ insert node index
109 SaveFly( SwNodeOffset nNodeDiff, sal_Int32 const nCntntIdx, SwFrameFormat* pFormat, bool bInsert )
110 : pFrameFormat(pFormat)
111 , nNdDiff(nNodeDiff)
112 , nContentIndex(nCntntIdx)
113 , isAtInsertNode(bInsert)
117 typedef std::deque< SaveFly > SaveFlyArr;
119 void RestFlyInRange( SaveFlyArr& rArr, const SwPosition& rSttIdx,
120 const SwNode* pInsPos, bool isForceToStartPos = false);
121 void SaveFlyInRange( const SwNodeRange& rRg, SaveFlyArr& rArr );
122 void SaveFlyInRange( const SwPaM& rPam, const SwPosition& rInsPos,
123 SaveFlyArr& rArr, bool bMoveAllFlys, SwHistory * pHistory = nullptr);
125 void DelFlyInRange( SwNode& rMkNd,
126 SwNode& rPtNd,
127 std::optional<sal_Int32> nMkContentIdx = std::nullopt,
128 std::optional<sal_Int32> pPtContentIdx = std::nullopt);
130 class SwDataChanged
132 const SwPaM* m_pPam;
133 const SwPosition* m_pPos;
134 SwDoc& m_rDoc;
135 sal_Int32 m_nContent;
137 public:
138 SwDataChanged( const SwPaM& rPam );
139 SwDataChanged( SwDoc& rDoc, const SwPosition& rPos );
140 ~SwDataChanged();
142 sal_Int32 GetContent() const { return m_nContent; }
146 * Function declarations so that everything below the CursorShell can
147 * move the Cursor once in a while.
148 * These functions do not call the SwDoc::Corr methods!
150 void PaMCorrAbs( const SwPaM& rRange,
151 const SwPosition& rNewPos );
153 /// Sets all PaMs in OldNode to relative Pos
154 void PaMCorrRel( const SwNode &rOldNode,
155 const SwPosition &rNewPos,
156 const sal_Int32 nOffset = 0 );
159 * Helper to copy paragraph-bound Flys.
160 * By sorting by order number, we try to retain the layout.
162 class ZSortFly
164 const SwFrameFormat* m_pFormat;
165 const SwFormatAnchor* m_pAnchor;
166 sal_uInt32 m_nOrdNum;
168 public:
169 ZSortFly( const SwFrameFormat* pFrameFormat, const SwFormatAnchor* pFlyAnchor,
170 sal_uInt32 nArrOrdNum );
172 bool operator==( const ZSortFly& ) const { return false; }
173 bool operator<( const ZSortFly& rCmp ) const
174 { return m_nOrdNum < rCmp.m_nOrdNum; }
176 const SwFrameFormat* GetFormat() const { return m_pFormat; }
177 const SwFormatAnchor* GetAnchor() const { return m_pAnchor; }
180 class SwTableNumFormatMerge
182 SvNumberFormatter* pNFormat;
183 public:
184 SwTableNumFormatMerge( const SwDoc& rSrc, SwDoc& rDest );
185 ~SwTableNumFormatMerge();
188 class SaveRedlEndPosForRestore
190 std::vector<SwPosition*> mvSavArr;
191 std::optional<SwNodeIndex> moSaveIndex;
192 sal_Int32 mnSaveContent;
194 public:
195 SaveRedlEndPosForRestore( const SwNode& rInsIdx, sal_Int32 nContent );
196 ~SaveRedlEndPosForRestore();
197 void Restore();
200 #endif // INCLUDED_SW_SOURCE_CORE_INC_MVSAVE_HXX
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */