LibreOffice Module sw (master) 1
mvsave.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#ifndef INCLUDED_SW_SOURCE_CORE_INC_MVSAVE_HXX
20#define INCLUDED_SW_SOURCE_CORE_INC_MVSAVE_HXX
21
22#include <vcl/keycod.hxx>
24#include <ndindex.hxx>
25#include <deque>
26#include <optional>
27#include <vector>
29
30namespace sfx2 {
31 class MetadatableUndo;
32}
33
35class SwDoc;
36class SwFormatAnchor;
37class SwFrameFormat;
38class SwContentIndex;
39class SwNodeRange;
40class SwPaM;
41class SwNode;
42struct SwPosition;
43
44namespace sw::mark
45{
46 class IMark;
47
49 {
50 public:
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);
58
59 private:
60 OUString m_aName;
61 OUString m_aShortName;
68 sal_Int32 m_nContent1;
69 sal_Int32 m_nContent2;
70 std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo;
71 };
72
73 enum class RestoreMode { Flys = 1, NonFlys = 2, All = 3 };
74
77 {
78 public:
79
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();
87 };
88}
89
90namespace o3tl {
91 template<> struct typed_flags<sw::mark::RestoreMode> : is_typed_flags<sw::mark::RestoreMode, 3> {};
92}
93
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);
99
103{
106 sal_Int32 nContentIndex;
108
109 SaveFly( SwNodeOffset nNodeDiff, sal_Int32 const nCntntIdx, SwFrameFormat* pFormat, bool bInsert )
110 : pFrameFormat(pFormat)
111 , nNdDiff(nNodeDiff)
112 , nContentIndex(nCntntIdx)
113 , isAtInsertNode(bInsert)
114 { }
115};
116
117typedef std::deque< SaveFly > SaveFlyArr;
118
119void RestFlyInRange( SaveFlyArr& rArr, const SwPosition& rSttIdx,
120 const SwNode* pInsPos, bool isForceToStartPos = false);
121void SaveFlyInRange( const SwNodeRange& rRg, SaveFlyArr& rArr );
122void SaveFlyInRange( const SwPaM& rPam, const SwPosition& rInsPos,
123 SaveFlyArr& rArr, bool bMoveAllFlys, SwHistory * pHistory = nullptr);
124
125void DelFlyInRange( SwNode& rMkNd,
126 SwNode& rPtNd,
127 std::optional<sal_Int32> nMkContentIdx = std::nullopt,
128 std::optional<sal_Int32> pPtContentIdx = std::nullopt);
129
131{
132 const SwPaM* m_pPam;
135 sal_Int32 m_nContent;
136
137public:
138 SwDataChanged( const SwPaM& rPam );
139 SwDataChanged( SwDoc& rDoc, const SwPosition& rPos );
141
142 sal_Int32 GetContent() const { return m_nContent; }
143};
144
150void PaMCorrAbs( const SwPaM& rRange,
151 const SwPosition& rNewPos );
152
154void PaMCorrRel( const SwNode &rOldNode,
155 const SwPosition &rNewPos,
156 const sal_Int32 nOffset = 0 );
157
163{
166 sal_uInt32 m_nOrdNum;
167
168public:
169 ZSortFly( const SwFrameFormat* pFrameFormat, const SwFormatAnchor* pFlyAnchor,
170 sal_uInt32 nArrOrdNum );
171
172 bool operator==( const ZSortFly& ) const { return false; }
173 bool operator<( const ZSortFly& rCmp ) const
174 { return m_nOrdNum < rCmp.m_nOrdNum; }
175
176 const SwFrameFormat* GetFormat() const { return m_pFormat; }
177 const SwFormatAnchor* GetAnchor() const { return m_pAnchor; }
178};
179
181{
183public:
184 SwTableNumFormatMerge( const SwDoc& rSrc, SwDoc& rDest );
186};
187
189{
190 std::vector<SwPosition*> mvSavArr;
191 std::optional<SwNodeIndex> moSaveIndex;
192 sal_Int32 mnSaveContent;
193
194public:
195 SaveRedlEndPosForRestore( const SwNode& rInsIdx, sal_Int32 nContent );
197 void Restore();
198};
199
200#endif // INCLUDED_SW_SOURCE_CORE_INC_MVSAVE_HXX
201
202/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::optional< SwNodeIndex > moSaveIndex
Definition: mvsave.hxx:191
SaveRedlEndPosForRestore(const SwNode &rInsIdx, sal_Int32 nContent)
Definition: docedt.cxx:267
std::vector< SwPosition * > mvSavArr
Definition: mvsave.hxx:190
Marks a character position inside a document model content node (SwContentNode)
const SwPaM * m_pPam
Definition: mvsave.hxx:132
sal_Int32 GetContent() const
Definition: mvsave.hxx:142
SwDataChanged(const SwPaM &rPam)
Definition: swserv.cxx:277
sal_Int32 m_nContent
Definition: mvsave.hxx:135
const SwPosition * m_pPos
Definition: mvsave.hxx:133
SwDoc & m_rDoc
Definition: mvsave.hxx:134
Definition: doc.hxx:197
FlyAnchors.
Definition: fmtanchr.hxx:37
Style of a layout element.
Definition: frmfmt.hxx:72
Base class of the Writer document model elements.
Definition: node.hxx:98
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
SwTableNumFormatMerge(const SwDoc &rSrc, SwDoc &rDest)
Definition: docfmt.cxx:1766
SvNumberFormatter * pNFormat
Definition: mvsave.hxx:182
Helper to copy paragraph-bound Flys.
Definition: mvsave.hxx:163
sal_uInt32 m_nOrdNum
Definition: mvsave.hxx:166
bool operator==(const ZSortFly &) const
Definition: mvsave.hxx:172
const SwFormatAnchor * m_pAnchor
Definition: mvsave.hxx:165
ZSortFly(const SwFrameFormat *pFrameFormat, const SwFormatAnchor *pFlyAnchor, sal_uInt32 nArrOrdNum)
Definition: docdraw.cxx:530
bool operator<(const ZSortFly &rCmp) const
Definition: mvsave.hxx:173
const SwFormatAnchor * GetAnchor() const
Definition: mvsave.hxx:177
const SwFrameFormat * m_pFormat
Definition: mvsave.hxx:164
const SwFrameFormat * GetFormat() const
Definition: mvsave.hxx:176
Takes care of storing relevant attributes of an SwTextNode before split, then restore them on the new...
Definition: mvsave.hxx:77
virtual void Save(SwDoc &rDoc, SwNodeOffset nNode, sal_Int32 nContent, bool bSaveFlySplit=false)=0
virtual ~ContentIdxStore()
Definition: mvsave.hxx:85
static std::shared_ptr< ContentIdxStore > Create()
virtual void Restore(SwDoc &rDoc, SwNodeOffset nNode, sal_Int32 nOffset=0, bool bAuto=false, bool bAtStart=false, RestoreMode=RestoreMode::All)=0
virtual void Clear()=0
virtual bool Empty()=0
virtual void Restore(SwNode &rNd, sal_Int32 nLen, sal_Int32 nCorrLen, RestoreMode=RestoreMode::All)=0
vcl::KeyCode m_aCode
Definition: mvsave.hxx:64
void SetInDoc(SwDoc *pDoc, const SwNode &, std::optional< sal_Int32 > oContentIdx=std::nullopt)
Definition: docbm.cxx:1942
IDocumentMarkAccess::MarkType m_eOrigBkmType
Definition: mvsave.hxx:65
OUString m_aHideCondition
Definition: mvsave.hxx:63
sal_Int32 m_nContent1
Definition: mvsave.hxx:68
SaveBookmark(const ::sw::mark::IMark &rBkmk, const SwNode &rMvPos, std::optional< sal_Int32 > oContentIdx)
Definition: docbm.cxx:1896
SwNodeOffset m_nNode1
Definition: mvsave.hxx:66
std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo
Definition: mvsave.hxx:70
SwNodeOffset m_nNode2
Definition: mvsave.hxx:67
sal_Int32 m_nContent2
Definition: mvsave.hxx:69
OUString m_aShortName
Definition: mvsave.hxx:61
void PaMCorrRel(const SwNode &rOldNode, const SwPosition &rNewPos, const sal_Int32 nOffset=0)
Sets all PaMs in OldNode to relative Pos.
Definition: doccorr.cxx:244
void DelFlyInRange(SwNode &rMkNd, SwNode &rPtNd, std::optional< sal_Int32 > nMkContentIdx=std::nullopt, std::optional< sal_Int32 > pPtContentIdx=std::nullopt)
Delete and move all Flys at the paragraph, that are within the selection.
Definition: docedt.cxx:208
void SaveFlyInRange(const SwNodeRange &rRg, SaveFlyArr &rArr)
Definition: docedt.cxx:106
void RestFlyInRange(SaveFlyArr &rArr, const SwPosition &rSttIdx, const SwNode *pInsPos, bool isForceToStartPos=false)
Definition: docedt.cxx:53
void PaMCorrAbs(const SwPaM &rRange, const SwPosition &rNewPos)
Function declarations so that everything below the CursorShell can move the Cursor once in a while.
Definition: doccorr.cxx:90
void DelBookmarks(SwNode &rStt, const SwNode &rEnd, std::vector< ::sw::mark::SaveBookmark > *SaveBkmk=nullptr, std::optional< sal_Int32 > oStartContentIdx=std::nullopt, std::optional< sal_Int32 > oEndContentIdx=std::nullopt)
std::deque< SaveFly > SaveFlyArr
Definition: mvsave.hxx:117
RestoreMode
Definition: mvsave.hxx:73
Dialog to specify the properties of date form field.
data structure to temporarily hold fly anchor positions relative to some location.
Definition: mvsave.hxx:103
SaveFly(SwNodeOffset nNodeDiff, sal_Int32 const nCntntIdx, SwFrameFormat *pFormat, bool bInsert)
Definition: mvsave.hxx:109
bool isAtInsertNode
if true, anchor at insert node index
Definition: mvsave.hxx:107
SwFrameFormat * pFrameFormat
Definition: mvsave.hxx:104
sal_Int32 nContentIndex
relative node difference
Definition: mvsave.hxx:106
SwNodeOffset nNdDiff
the fly's frame format
Definition: mvsave.hxx:105
Marks a position in the document model.
Definition: pam.hxx:38