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 {
103  bool const bInsertPosition;
104 
105  SaveFly( sal_uLong nNodeDiff, SwFrameFormat* pFormat, bool bInsert )
106  : nNdDiff( nNodeDiff ), pFrameFormat( pFormat ), bInsertPosition( bInsert )
107  { }
108 };
109 
110 typedef std::deque< SaveFly > SaveFlyArr;
111 
112 void RestFlyInRange( SaveFlyArr& rArr, const SwNodeIndex& rSttIdx,
113  const SwNodeIndex* pInsPos );
114 void SaveFlyInRange( const SwNodeRange& rRg, SaveFlyArr& rArr );
115 void SaveFlyInRange( const SwPaM& rPam, const SwNodeIndex& rInsPos,
116  SaveFlyArr& rArr, bool bMoveAllFlys );
117 
118 void DelFlyInRange( const SwNodeIndex& rMkNdIdx,
119  const SwNodeIndex& rPtNdIdx );
120 
122 {
123  const SwPaM* pPam;
124  const SwPosition* pPos;
126  sal_Int32 nContent;
127 
128 public:
129  SwDataChanged( const SwPaM& rPam );
130  SwDataChanged( SwDoc* pDoc, const SwPosition& rPos );
131  ~SwDataChanged();
132 
133  sal_Int32 GetContent() const { return nContent; }
134 };
135 
141 void PaMCorrAbs( const SwPaM& rRange,
142  const SwPosition& rNewPos );
143 
145 void PaMCorrRel( const SwNodeIndex &rOldNode,
146  const SwPosition &rNewPos,
147  const sal_Int32 nOffset = 0 );
148 
153 class ZSortFly
154 {
157  sal_uInt32 nOrdNum;
158 
159 public:
160  ZSortFly( const SwFrameFormat* pFrameFormat, const SwFormatAnchor* pFlyAnchor,
161  sal_uInt32 nArrOrdNum );
162  ZSortFly& operator=( const ZSortFly& rCpy )
163  {
164  pFormat = rCpy.pFormat;
165  pAnchor = rCpy.pAnchor;
166  nOrdNum = rCpy.nOrdNum;
167  return *this;
168  }
169 
170  bool operator==( const ZSortFly& ) const { return false; }
171  bool operator<( const ZSortFly& rCmp ) const
172  { return nOrdNum < rCmp.nOrdNum; }
173 
174  const SwFrameFormat* GetFormat() const { return pFormat; }
175  const SwFormatAnchor* GetAnchor() const { return pAnchor; }
176 };
177 
179 {
181 public:
182  SwTableNumFormatMerge( const SwDoc& rSrc, SwDoc& rDest );
184 };
185 
187 {
188  std::vector<SwPosition*> mvSavArr;
189  std::unique_ptr<SwNodeIndex> pSavIdx;
190  sal_Int32 const nSavContent;
191 
192 public:
193  SaveRedlEndPosForRestore( const SwNodeIndex& rInsIdx, sal_Int32 nContent );
195  void Restore();
196 };
197 
198 #endif // INCLUDED_SW_SOURCE_CORE_INC_MVSAVE_HXX
199 
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< SwPosition * > mvSavArr
Definition: mvsave.hxx:188
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:124
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:155
sal_uIntPtr sal_uLong
bool operator<(const ZSortFly &rCmp) const
Definition: mvsave.hxx:171
Definition: doc.hxx:185
void SetInDoc(SwDoc *pDoc, const SwNodeIndex &, const SwIndex *pIdx=nullptr)
Definition: docbm.cxx:1603
bool const bInsertPosition
the fly's frame format
Definition: mvsave.hxx:103
Dialog to specify the properties of date form field.
Definition: accfrmobj.cxx:40
void SaveFlyInRange(const SwNodeRange &rRg, SaveFlyArr &rArr)
Definition: docedt.cxx:89
IDocumentMarkAccess::MarkType const m_eOrigBkmType
Definition: mvsave.hxx:62
const SwPaM * pPam
Definition: mvsave.hxx:123
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:126
bool operator==(const ZSortFly &) const
Definition: mvsave.hxx:170
virtual bool Empty()=0
SaveFly(sal_uLong nNodeDiff, SwFrameFormat *pFormat, bool bInsert)
if true, anchor at insert position
Definition: mvsave.hxx:105
SwDoc * pDoc
Definition: mvsave.hxx:125
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
Style of a layout element.
Definition: frmfmt.hxx:57
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:156
std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo
Definition: mvsave.hxx:67
std::unique_ptr< SwNodeIndex > pSavIdx
Definition: mvsave.hxx:189
sal_uInt32 nOrdNum
Definition: mvsave.hxx:157
Marks a node in the document model.
Definition: ndindex.hxx:31
ZSortFly & operator=(const ZSortFly &rCpy)
Definition: mvsave.hxx:162
void RestFlyInRange(SaveFlyArr &rArr, const SwNodeIndex &rSttIdx, const SwNodeIndex *pInsPos)
Definition: docedt.cxx:57
Helper to copy paragraph-bound Flys.
Definition: mvsave.hxx:153
std::deque< SaveFly > SaveFlyArr
Definition: mvsave.hxx:110
RestoreMode
Definition: mvsave.hxx:70
SwTableNumFormatMerge(const SwDoc &rSrc, SwDoc &rDest)
Definition: docfmt.cxx:1751
SwFrameFormat *const pFrameFormat
relative node difference
Definition: mvsave.hxx:102
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()
virtual ~ContentIdxStore()
Definition: mvsave.hxx:82
const SwFrameFormat * GetFormat() const
Definition: mvsave.hxx:174
SaveRedlEndPosForRestore(const SwNodeIndex &rInsIdx, sal_Int32 nContent)
Definition: docedt.cxx:243
sal_Int32 const nSavContent
Definition: mvsave.hxx:190
void DelFlyInRange(const SwNodeIndex &rMkNdIdx, const SwNodeIndex &rPtNdIdx)
Delete and move all Flys at the paragraph, that are within the selection.
Definition: docedt.cxx:185
const SwFormatAnchor * GetAnchor() const
Definition: mvsave.hxx:175
vcl::KeyCode m_aCode
Definition: mvsave.hxx:61
SvNumberFormatter * pNFormat
Definition: mvsave.hxx:180
sal_Int32 GetContent() const
Definition: mvsave.hxx:133
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