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>
23 #include <IDocumentMarkAccess.hxx>
24 #include <vector>
25 #include <deque>
26 #include <o3tl/typed_flags_set.hxx>
27 
28 namespace sfx2 {
29  class MetadatableUndo;
30 }
31 
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;
42 
43 namespace sw { namespace mark
44 {
45  class IMark;
46 
48  {
49  public:
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);
57 
58  private:
59  OUString const m_aName;
60  OUString m_aShortName;
65  sal_Int32 m_nContent1;
66  sal_Int32 m_nContent2;
67  std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo;
68  };
69 
70  enum class RestoreMode { Flys = 1, NonFlys = 2, All = 3 };
71 
74  {
75  public:
76 
77  virtual void Clear() =0;
78  virtual bool Empty() =0;
79  virtual void Save(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nContent, bool bSaveFlySplit=false) =0;
80  virtual void Restore(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nOffset=0, bool bAuto = false, RestoreMode = RestoreMode::All) =0;
81  virtual void Restore(SwNode& rNd, sal_Int32 nLen, sal_Int32 nCorrLen, RestoreMode = RestoreMode::All) =0;
82  virtual ~ContentIdxStore() {};
83  static std::shared_ptr<ContentIdxStore> Create();
84  };
85 }}
86 
87 namespace o3tl {
88  template<> struct typed_flags<sw::mark::RestoreMode> : is_typed_flags<sw::mark::RestoreMode, 3> {};
89 }
90 
91 void DelBookmarks(const SwNodeIndex& rStt,
92  const SwNodeIndex& rEnd,
93  std::vector< ::sw::mark::SaveBookmark> * SaveBkmk =nullptr,
94  const SwIndex* pSttIdx =nullptr,
95  const SwIndex* pEndIdx =nullptr);
96 
99 struct SaveFly
100 {
102  sal_Int32 const nContentIndex;
104  bool const isAtInsertNode;
105 
106  SaveFly( sal_uLong nNodeDiff, sal_Int32 const nCntntIdx, SwFrameFormat* pFormat, bool bInsert )
107  : nNdDiff(nNodeDiff)
108  , nContentIndex(nCntntIdx)
109  , pFrameFormat(pFormat)
110  , isAtInsertNode(bInsert)
111  { }
112 };
113 
114 typedef std::deque< SaveFly > SaveFlyArr;
115 
116 void RestFlyInRange( SaveFlyArr& rArr, const SwPosition& rSttIdx,
117  const SwNodeIndex* pInsPos );
118 void SaveFlyInRange( const SwNodeRange& rRg, SaveFlyArr& rArr );
119 void SaveFlyInRange( const SwPaM& rPam, const SwPosition& rInsPos,
120  SaveFlyArr& rArr, bool bMoveAllFlys );
121 
122 void DelFlyInRange( const SwNodeIndex& rMkNdIdx,
123  const SwNodeIndex& rPtNdIdx,
124  SwIndex const* pMkIdx = nullptr,
125  SwIndex const* pPtIdx = nullptr);
126 
128 {
129  const SwPaM* pPam;
130  const SwPosition* pPos;
132  sal_Int32 nContent;
133 
134 public:
135  SwDataChanged( const SwPaM& rPam );
136  SwDataChanged( SwDoc* pDoc, const SwPosition& rPos );
137  ~SwDataChanged();
138 
139  sal_Int32 GetContent() const { return nContent; }
140 };
141 
147 void PaMCorrAbs( const SwPaM& rRange,
148  const SwPosition& rNewPos );
149 
151 void PaMCorrRel( const SwNodeIndex &rOldNode,
152  const SwPosition &rNewPos,
153  const sal_Int32 nOffset = 0 );
154 
159 class ZSortFly
160 {
163  sal_uInt32 nOrdNum;
164 
165 public:
166  ZSortFly( const SwFrameFormat* pFrameFormat, const SwFormatAnchor* pFlyAnchor,
167  sal_uInt32 nArrOrdNum );
168  ZSortFly& operator=( const ZSortFly& rCpy )
169  {
170  pFormat = rCpy.pFormat;
171  pAnchor = rCpy.pAnchor;
172  nOrdNum = rCpy.nOrdNum;
173  return *this;
174  }
175 
176  bool operator==( const ZSortFly& ) const { return false; }
177  bool operator<( const ZSortFly& rCmp ) const
178  { return nOrdNum < rCmp.nOrdNum; }
179 
180  const SwFrameFormat* GetFormat() const { return pFormat; }
181  const SwFormatAnchor* GetAnchor() const { return pAnchor; }
182 };
183 
185 {
187 public:
188  SwTableNumFormatMerge( const SwDoc& rSrc, SwDoc& rDest );
190 };
191 
193 {
194  std::vector<SwPosition*> mvSavArr;
195  std::unique_ptr<SwNodeIndex> pSavIdx;
196  sal_Int32 const nSavContent;
197 
198 public:
199  SaveRedlEndPosForRestore( const SwNodeIndex& rInsIdx, sal_Int32 nContent );
201  void Restore();
202 };
203 
204 #endif // INCLUDED_SW_SOURCE_CORE_INC_MVSAVE_HXX
205 
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< SwPosition * > mvSavArr
Definition: mvsave.hxx:194
sal_uLong const nNdDiff
Definition: mvsave.hxx:101
virtual void Restore(SwDoc *pDoc, sal_uLong nNode, sal_Int32 nOffset=0, bool bAuto=false, RestoreMode=RestoreMode::All)=0
const SwPosition * pPos
Definition: mvsave.hxx:130
Marks a position in the document model.
Definition: pam.hxx:35
ZSortFly(const SwFrameFormat *pFrameFormat, const SwFormatAnchor *pFlyAnchor, sal_uInt32 nArrOrdNum)
Definition: docdraw.cxx:481
sal_uLong m_nNode2
Definition: mvsave.hxx:64
const SwFrameFormat * pFormat
Definition: mvsave.hxx:161
sal_uIntPtr sal_uLong
bool operator<(const ZSortFly &rCmp) const
Definition: mvsave.hxx:177
Definition: doc.hxx:185
void SetInDoc(SwDoc *pDoc, const SwNodeIndex &, const SwIndex *pIdx=nullptr)
Definition: docbm.cxx:1603
Dialog to specify the properties of date form field.
void SaveFlyInRange(const SwNodeRange &rRg, SaveFlyArr &rArr)
Definition: docedt.cxx:110
IDocumentMarkAccess::MarkType const m_eOrigBkmType
Definition: mvsave.hxx:62
const SwPaM * pPam
Definition: mvsave.hxx:129
virtual void Clear()=0
virtual void Save(SwDoc *pDoc, sal_uLong nNode, sal_Int32 nContent, bool bSaveFlySplit=false)=0
sal_Int32 m_nContent1
Definition: mvsave.hxx:65
sal_uLong m_nNode1
Definition: mvsave.hxx:63
SwDataChanged(const SwPaM &rPam)
Definition: swserv.cxx:280
sal_Int32 nContent
Definition: mvsave.hxx:132
bool operator==(const ZSortFly &) const
Definition: mvsave.hxx:176
SaveFly(sal_uLong nNodeDiff, sal_Int32 const nCntntIdx, SwFrameFormat *pFormat, bool bInsert)
Definition: mvsave.hxx:106
virtual bool Empty()=0
SwDoc * pDoc
Definition: mvsave.hxx:131
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
Style of a layout element.
Definition: frmfmt.hxx:57
void DelFlyInRange(const SwNodeIndex &rMkNdIdx, const SwNodeIndex &rPtNdIdx, SwIndex const *pMkIdx=nullptr, SwIndex const *pPtIdx=nullptr)
Delete and move all Flys at the paragraph, that are within the selection.
Definition: docedt.cxx:222
OUString m_aShortName
Definition: mvsave.hxx:60
OUString const m_aName
Definition: mvsave.hxx:59
Takes care of storing relevant attributes of an SwTextNode before split, then restore them on the new...
Definition: mvsave.hxx:73
FlyAnchors.
Definition: fmtanchr.hxx:34
void PaMCorrRel(const SwNodeIndex &rOldNode, const SwPosition &rNewPos, const sal_Int32 nOffset=0)
Sets all PaMs in OldNode to relative Pos.
Definition: doccorr.cxx:241
Marks a character position inside a document model node.
Definition: index.hxx:37
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:91
const SwFormatAnchor * pAnchor
Definition: mvsave.hxx:162
std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo
Definition: mvsave.hxx:67
std::unique_ptr< SwNodeIndex > pSavIdx
Definition: mvsave.hxx:195
sal_uInt32 nOrdNum
Definition: mvsave.hxx:163
Marks a node in the document model.
Definition: ndindex.hxx:31
ZSortFly & operator=(const ZSortFly &rCpy)
Definition: mvsave.hxx:168
Helper to copy paragraph-bound Flys.
Definition: mvsave.hxx:159
bool const isAtInsertNode
the fly's frame format
Definition: mvsave.hxx:104
std::deque< SaveFly > SaveFlyArr
Definition: mvsave.hxx:114
sal_Int32 const nContentIndex
relative node difference
Definition: mvsave.hxx:102
RestoreMode
Definition: mvsave.hxx:70
SwTableNumFormatMerge(const SwDoc &rSrc, SwDoc &rDest)
Definition: docfmt.cxx:1741
SwFrameFormat *const pFrameFormat
Definition: mvsave.hxx:103
void DelBookmarks(const SwNodeIndex &rStt, const SwNodeIndex &rEnd, std::vector< ::sw::mark::SaveBookmark > *SaveBkmk=nullptr, const SwIndex *pSttIdx=nullptr, const SwIndex *pEndIdx=nullptr)
data structure to temporarily hold fly anchor positions relative to some location.
Definition: mvsave.hxx:99
static std::shared_ptr< ContentIdxStore > Create()
void RestFlyInRange(SaveFlyArr &rArr, const SwPosition &rSttIdx, const SwNodeIndex *pInsPos)
Definition: docedt.cxx:58
virtual ~ContentIdxStore()
Definition: mvsave.hxx:82
const SwFrameFormat * GetFormat() const
Definition: mvsave.hxx:180
SaveRedlEndPosForRestore(const SwNodeIndex &rInsIdx, sal_Int32 nContent)
Definition: docedt.cxx:294
sal_Int32 const nSavContent
Definition: mvsave.hxx:196
const SwFormatAnchor * GetAnchor() const
Definition: mvsave.hxx:181
vcl::KeyCode m_aCode
Definition: mvsave.hxx:61
SvNumberFormatter * pNFormat
Definition: mvsave.hxx:186
sal_Int32 GetContent() const
Definition: mvsave.hxx:139
sal_Int32 m_nContent2
Definition: mvsave.hxx:66
SaveBookmark(const ::sw::mark::IMark &rBkmk, const SwNodeIndex &rMvPos, const SwIndex *pIdx)
Definition: docbm.cxx:1558
Base class of the Writer document model elements.
Definition: node.hxx:79