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::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;
61  bool m_bHidden;
62  OUString m_aHideCondition;
67  sal_Int32 m_nContent1;
68  sal_Int32 m_nContent2;
69  std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo;
70  };
71 
72  enum class RestoreMode { Flys = 1, NonFlys = 2, All = 3 };
73 
76  {
77  public:
78 
79  virtual void Clear() =0;
80  virtual bool Empty() =0;
81  virtual void Save(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nContent, bool bSaveFlySplit=false) =0;
82  virtual void Restore(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nOffset=0, bool bAuto = false, RestoreMode = RestoreMode::All) =0;
83  virtual void Restore(SwNode& rNd, sal_Int32 nLen, sal_Int32 nCorrLen, RestoreMode = RestoreMode::All) =0;
84  virtual ~ContentIdxStore() {};
85  static std::shared_ptr<ContentIdxStore> Create();
86  };
87 }
88 
89 namespace o3tl {
90  template<> struct typed_flags<sw::mark::RestoreMode> : is_typed_flags<sw::mark::RestoreMode, 3> {};
91 }
92 
93 void DelBookmarks(const SwNodeIndex& rStt,
94  const SwNodeIndex& rEnd,
95  std::vector< ::sw::mark::SaveBookmark> * SaveBkmk =nullptr,
96  const SwIndex* pSttIdx =nullptr,
97  const SwIndex* pEndIdx =nullptr);
98 
101 struct SaveFly
102 {
105  sal_Int32 nContentIndex;
107 
108  SaveFly( sal_uLong nNodeDiff, sal_Int32 const nCntntIdx, SwFrameFormat* pFormat, bool bInsert )
109  : pFrameFormat(pFormat)
110  , nNdDiff(nNodeDiff)
111  , nContentIndex(nCntntIdx)
112  , isAtInsertNode(bInsert)
113  { }
114 };
115 
116 typedef std::deque< SaveFly > SaveFlyArr;
117 
118 void RestFlyInRange( SaveFlyArr& rArr, const SwPosition& rSttIdx,
119  const SwNodeIndex* pInsPos );
120 void SaveFlyInRange( const SwNodeRange& rRg, SaveFlyArr& rArr );
121 void SaveFlyInRange( const SwPaM& rPam, const SwPosition& rInsPos,
122  SaveFlyArr& rArr, bool bMoveAllFlys );
123 
124 void DelFlyInRange( const SwNodeIndex& rMkNdIdx,
125  const SwNodeIndex& rPtNdIdx,
126  SwIndex const* pMkIdx = nullptr,
127  SwIndex const* pPtIdx = nullptr);
128 
130 {
131  const SwPaM* m_pPam;
134  sal_Int32 m_nContent;
135 
136 public:
137  SwDataChanged( const SwPaM& rPam );
138  SwDataChanged( SwDoc* pDoc, const SwPosition& rPos );
139  ~SwDataChanged();
140 
141  sal_Int32 GetContent() const { return m_nContent; }
142 };
143 
149 void PaMCorrAbs( const SwPaM& rRange,
150  const SwPosition& rNewPos );
151 
153 void PaMCorrRel( const SwNodeIndex &rOldNode,
154  const SwPosition &rNewPos,
155  const sal_Int32 nOffset = 0 );
156 
161 class ZSortFly
162 {
165  sal_uInt32 m_nOrdNum;
166 
167 public:
168  ZSortFly( const SwFrameFormat* pFrameFormat, const SwFormatAnchor* pFlyAnchor,
169  sal_uInt32 nArrOrdNum );
170 
171  bool operator==( const ZSortFly& ) const { return false; }
172  bool operator<( const ZSortFly& rCmp ) const
173  { return m_nOrdNum < rCmp.m_nOrdNum; }
174 
175  const SwFrameFormat* GetFormat() const { return m_pFormat; }
176  const SwFormatAnchor* GetAnchor() const { return m_pAnchor; }
177 };
178 
180 {
182 public:
183  SwTableNumFormatMerge( const SwDoc& rSrc, SwDoc& rDest );
185 };
186 
188 {
189  std::vector<SwPosition*> mvSavArr;
190  std::unique_ptr<SwNodeIndex> mpSaveIndex;
191  sal_Int32 mnSaveContent;
192 
193 public:
194  SaveRedlEndPosForRestore( const SwNodeIndex& rInsIdx, sal_Int32 nContent );
196  void Restore();
197 };
198 
199 #endif // INCLUDED_SW_SOURCE_CORE_INC_MVSAVE_HXX
200 
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< SwPosition * > mvSavArr
Definition: mvsave.hxx:189
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
the fly's frame format
Definition: mvsave.hxx:104
const SwFrameFormat * m_pFormat
Definition: mvsave.hxx:163
ZSortFly(const SwFrameFormat *pFrameFormat, const SwFormatAnchor *pFlyAnchor, sal_uInt32 nArrOrdNum)
Definition: docdraw.cxx:465
sal_uLong m_nNode2
Definition: mvsave.hxx:66
sal_uIntPtr sal_uLong
bool operator<(const ZSortFly &rCmp) const
Definition: mvsave.hxx:172
Definition: doc.hxx:184
void SetInDoc(SwDoc *pDoc, const SwNodeIndex &, const SwIndex *pIdx=nullptr)
Definition: docbm.cxx:1735
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:190
sal_uInt32 m_nOrdNum
Definition: mvsave.hxx:165
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:67
sal_uLong m_nNode1
Definition: mvsave.hxx:65
SwDataChanged(const SwPaM &rPam)
Definition: swserv.cxx:277
SwFrameFormat * pFrameFormat
Definition: mvsave.hxx:103
bool operator==(const ZSortFly &) const
Definition: mvsave.hxx:171
SaveFly(sal_uLong nNodeDiff, sal_Int32 const nCntntIdx, SwFrameFormat *pFormat, bool bInsert)
Definition: mvsave.hxx:108
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:164
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:134
Takes care of storing relevant attributes of an SwTextNode before split, then restore them on the new...
Definition: mvsave.hxx:75
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:33
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:69
Marks a node in the document model.
Definition: ndindex.hxx:31
Helper to copy paragraph-bound Flys.
Definition: mvsave.hxx:161
std::deque< SaveFly > SaveFlyArr
Definition: mvsave.hxx:116
RestoreMode
Definition: mvsave.hxx:72
bool isAtInsertNode
if true, anchor at insert node index
Definition: mvsave.hxx:106
const SwPaM * m_pPam
Definition: mvsave.hxx:131
SwTableNumFormatMerge(const SwDoc &rSrc, SwDoc &rDest)
Definition: docfmt.cxx:1734
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:132
data structure to temporarily hold fly anchor positions relative to some location.
Definition: mvsave.hxx:101
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:84
const SwFrameFormat * GetFormat() const
Definition: mvsave.hxx:175
SwDoc * m_pDoc
Definition: mvsave.hxx:133
IDocumentMarkAccess::MarkType m_eOrigBkmType
Definition: mvsave.hxx:64
SaveRedlEndPosForRestore(const SwNodeIndex &rInsIdx, sal_Int32 nContent)
Definition: docedt.cxx:262
sal_Int32 nContentIndex
relative node difference
Definition: mvsave.hxx:105
const SwFormatAnchor * GetAnchor() const
Definition: mvsave.hxx:176
vcl::KeyCode m_aCode
Definition: mvsave.hxx:63
SvNumberFormatter * pNFormat
Definition: mvsave.hxx:181
sal_Int32 GetContent() const
Definition: mvsave.hxx:141
sal_Int32 m_nContent2
Definition: mvsave.hxx:68
OUString m_aHideCondition
Definition: mvsave.hxx:62
SaveBookmark(const ::sw::mark::IMark &rBkmk, const SwNodeIndex &rMvPos, const SwIndex *pIdx)
Definition: docbm.cxx:1688
Base class of the Writer document model elements.
Definition: node.hxx:79