1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
28 #include <o3tl/typed_flags_set.hxx>
31 class MetadatableUndo
;
34 class SvNumberFormatter
;
52 const ::sw::mark::IMark
& rBkmk
,
54 std::optional
<sal_Int32
> oContentIdx
);
55 void SetInDoc(SwDoc
* pDoc
,
57 std::optional
<sal_Int32
> oContentIdx
= std::nullopt
);
61 OUString m_aShortName
;
63 OUString m_aHideCondition
;
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.
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();
91 template<> struct typed_flags
<sw::mark::RestoreMode
> : is_typed_flags
<sw::mark::RestoreMode
, 3> {};
94 void DelBookmarks(SwNode
& rStt
,
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
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
)
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
,
127 std::optional
<sal_Int32
> nMkContentIdx
= std::nullopt
,
128 std::optional
<sal_Int32
> pPtContentIdx
= std::nullopt
);
133 const SwPosition
* m_pPos
;
135 sal_Int32 m_nContent
;
138 SwDataChanged( const SwPaM
& rPam
);
139 SwDataChanged( SwDoc
& rDoc
, const SwPosition
& rPos
);
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.
164 const SwFrameFormat
* m_pFormat
;
165 const SwFormatAnchor
* m_pAnchor
;
166 sal_uInt32 m_nOrdNum
;
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
;
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
;
195 SaveRedlEndPosForRestore( const SwNode
& rInsIdx
, sal_Int32 nContent
);
196 ~SaveRedlEndPosForRestore();
200 #endif // INCLUDED_SW_SOURCE_CORE_INC_MVSAVE_HXX
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */