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 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 nContentIndex;
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* m_pPam;
132  sal_Int32 m_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 m_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 m_nOrdNum;
164 
165 public:
166  ZSortFly( const SwFrameFormat* pFrameFormat, const SwFormatAnchor* pFlyAnchor,
167  sal_uInt32 nArrOrdNum );
168 
169  bool operator==( const ZSortFly& ) const { return false; }
170  bool operator<( const ZSortFly& rCmp ) const
171  { return m_nOrdNum < rCmp.m_nOrdNum; }
172 
173  const SwFrameFormat* GetFormat() const { return m_pFormat; }
174  const SwFormatAnchor* GetAnchor() const { return m_pAnchor; }
175 };
176 
178 {
180 public:
181  SwTableNumFormatMerge( const SwDoc& rSrc, SwDoc& rDest );
183 };
184 
186 {
187  std::vector<SwPosition*> mvSavArr;
188  std::unique_ptr<SwNodeIndex> mpSaveIndex;
189  sal_Int32 mnSaveContent;
190 
191 public:
192  SaveRedlEndPosForRestore( const SwNodeIndex& rInsIdx, sal_Int32 nContent );
194  void Restore();
195 };
196 
197 #endif // INCLUDED_SW_SOURCE_CORE_INC_MVSAVE_HXX
198 
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< SwPosition * > mvSavArr
Definition: mvsave.hxx:187
virtual void Restore(SwDoc *pDoc, sal_uLong nNode, sal_Int32 nOffset=0, bool bAuto=false, RestoreMode=RestoreMode::All)=0
Marks a position in the document model.
Definition: pam.hxx:35
sal_uLong nNdDiff
Definition: mvsave.hxx:101
const SwFrameFormat * m_pFormat
Definition: mvsave.hxx:161
ZSortFly(const SwFrameFormat *pFrameFormat, const SwFormatAnchor *pFlyAnchor, sal_uInt32 nArrOrdNum)
Definition: docdraw.cxx:465
sal_uLong m_nNode2
Definition: mvsave.hxx:64
sal_uIntPtr sal_uLong
bool operator<(const ZSortFly &rCmp) const
Definition: mvsave.hxx:170
Definition: doc.hxx:186
void SetInDoc(SwDoc *pDoc, const SwNodeIndex &, const SwIndex *pIdx=nullptr)
Definition: docbm.cxx:1734
Dialog to specify the properties of date form field.
void SaveFlyInRange(const SwNodeRange &rRg, SaveFlyArr &rArr)
Definition: docedt.cxx:104
std::unique_ptr< SwNodeIndex > mpSaveIndex
Definition: mvsave.hxx:188
sal_uInt32 m_nOrdNum
Definition: mvsave.hxx:163
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:277
SwFrameFormat * pFrameFormat
Definition: mvsave.hxx:103
bool operator==(const ZSortFly &) const
Definition: mvsave.hxx:169
SaveFly(sal_uLong nNodeDiff, sal_Int32 const nCntntIdx, SwFrameFormat *pFormat, bool bInsert)
Definition: mvsave.hxx:106
virtual bool Empty()=0
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
const SwFormatAnchor * m_pAnchor
Definition: mvsave.hxx:162
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:203
OUString m_aShortName
Definition: mvsave.hxx:60
sal_Int32 m_nContent
Definition: mvsave.hxx:132
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:240
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:85
std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo
Definition: mvsave.hxx:67
Marks a node in the document model.
Definition: ndindex.hxx:31
Helper to copy paragraph-bound Flys.
Definition: mvsave.hxx:159
std::deque< SaveFly > SaveFlyArr
Definition: mvsave.hxx:114
RestoreMode
Definition: mvsave.hxx:70
bool isAtInsertNode
the fly's frame format
Definition: mvsave.hxx:104
const SwPaM * m_pPam
Definition: mvsave.hxx:129
SwTableNumFormatMerge(const SwDoc &rSrc, SwDoc &rDest)
Definition: docfmt.cxx:1732
void DelBookmarks(const SwNodeIndex &rStt, const SwNodeIndex &rEnd, std::vector< ::sw::mark::SaveBookmark > *SaveBkmk=nullptr, const SwIndex *pSttIdx=nullptr, const SwIndex *pEndIdx=nullptr)
const SwPosition * m_pPos
Definition: mvsave.hxx:130
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:52
virtual ~ContentIdxStore()
Definition: mvsave.hxx:82
const SwFrameFormat * GetFormat() const
Definition: mvsave.hxx:173
SwDoc * m_pDoc
Definition: mvsave.hxx:131
IDocumentMarkAccess::MarkType m_eOrigBkmType
Definition: mvsave.hxx:62
SaveRedlEndPosForRestore(const SwNodeIndex &rInsIdx, sal_Int32 nContent)
Definition: docedt.cxx:262
sal_Int32 nContentIndex
relative node difference
Definition: mvsave.hxx:102
const SwFormatAnchor * GetAnchor() const
Definition: mvsave.hxx:174
vcl::KeyCode m_aCode
Definition: mvsave.hxx:61
SvNumberFormatter * pNFormat
Definition: mvsave.hxx:179
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:1689
Base class of the Writer document model elements.
Definition: node.hxx:79