LibreOffice Module sw (master)  1
fltshell.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_FILTER_INC_FLTSHELL_HXX
20 #define INCLUDED_SW_SOURCE_FILTER_INC_FLTSHELL_HXX
21 
22 #include <hintids.hxx>
23 #include <svl/listener.hxx>
24 #include <tools/datetime.hxx>
25 #include <mdiexp.hxx>
26 #include <ndindex.hxx>
27 #include <pam.hxx>
28 #include <strings.hrc>
30 
31 #include <cstddef>
32 #include <limits>
33 #include <memory>
34 
35 class SwTOXBase;
36 class SwField;
37 class SwFieldType;
38 class Graphic;
39 class SwTableBox;
40 class SwDoc;
41 class SwPaM;
42 
43 inline bool SwFltGetFlag(sal_uLong nFieldFlags, int no)
44  { return (nFieldFlags & (sal_uLong(1) << no)) != 0; }
45 
46 //Subvert the Node/Content system to get positions which don't update as
47 //content is appended to them
49 {
50 public:
52  sal_Int32 m_nContent;
53 public:
54  bool operator==(const SwFltPosition &rOther) const
55  {
56  return (m_nContent == rOther.m_nContent &&
57  m_nNode == rOther.m_nNode);
58  }
59  void SetPos(SwNodeIndex const &rNode, sal_uInt16 nIdx)
60  {
61  m_nNode = rNode;
62  m_nContent = nIdx;
63  }
64  //operators with SwPosition, where the node is hacked to the previous one,
65  //and the offset to content is de-dynamic-ified
67  : m_nNode(rPos.nNode, -1)
68  , m_nContent(rPos.nContent.GetIndex())
69  {
70  }
71  void SetPos(const SwPosition &rPos)
72  {
73  m_nNode = rPos.nNode.GetIndex()-1;
74  m_nContent = rPos.nContent.GetIndex();
75  }
76 };
77 
78 // Stack entry for the attributes. It is always pointers to new attributes that are passed.
80 {
81 private:
82  SwFltStackEntry(SwFltStackEntry const&) = delete;
83  SwFltStackEntry& operator=(SwFltStackEntry const&) = delete;
84 
85 public:
88 
89  std::unique_ptr<SfxPoolItem> pAttr;// Format Attribute
90 
91  bool bOld; // to mark Attributes *before* skipping field results
92  bool bOpen; //Entry open, awaiting being closed
95 
96  sal_Int32 mnStartCP;
97  sal_Int32 mnEndCP;
98  bool bIsParaEnd;
99 
100  SW_DLLPUBLIC SwFltStackEntry(const SwPosition & rStartPos, std::unique_ptr<SfxPoolItem> pHt );
102 
103  enum class RegionMode { NoCheck = 0, CheckNodes = 1<<0, CheckFieldmark = 1<<1 };
104  SW_DLLPUBLIC void SetEndPos( const SwPosition & rEndPos);
105  SW_DLLPUBLIC bool MakeRegion(SwDoc& rDoc, SwPaM& rRegion, RegionMode eCheck) const;
106  SW_DLLPUBLIC static bool MakeRegion(SwDoc& rDoc, SwPaM& rRegion,
107  RegionMode eCheck, const SwFltPosition &rMkPos, const SwFltPosition &rPtPos, bool bIsParaEnd=false,
108  sal_uInt16 nWhich=0);
109 
110  void SetStartCP(sal_Int32 nCP) {mnStartCP = nCP;}
111  void SetEndCP(sal_Int32 nCP) {mnEndCP = nCP;}
112  sal_Int32 GetStartCP() const {return mnStartCP;}
113  sal_Int32 GetEndCP() const {return mnEndCP;}
114  bool IsParaEnd() const { return bIsParaEnd;}
115  void SetIsParaEnd(bool bArg){ bIsParaEnd = bArg;}
116 };
117 
118 template<> struct o3tl::typed_flags<SwFltStackEntry::RegionMode>: o3tl::is_typed_flags<SwFltStackEntry::RegionMode, 0x03> {};
119 
121 {
122 private:
123  SwFltControlStack(SwFltControlStack const&) = delete;
124  SwFltControlStack& operator=(SwFltControlStack const&) = delete;
125 
126  typedef std::vector<std::unique_ptr<SwFltStackEntry>> Entries;
127  Entries m_Entries;
128 
130 
131  bool bHasSdOD;
133 
134 protected:
137 
138  virtual void SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry& rEntry);
139  virtual sal_Int32 GetCurrAttrCP() const {return -1;}
140  virtual bool IsParaEndInCPs(sal_Int32 nStart,sal_Int32 nEnd,bool bSdOD) const;
141 
142  //Clear the para end position recorded in reader intermittently for the least impact on loading performance
143  virtual void ClearParaEndPosition(){};
144  virtual bool CheckSdOD(sal_Int32 nStart,sal_Int32 nEnd);
145  bool HasSdOD();
146 
147 public:
148  enum class MoveAttrsMode { DEFAULT, POSTIT_INSERTED };
149  void MoveAttrs(const SwPosition& rPos, MoveAttrsMode = MoveAttrsMode::DEFAULT);
150  enum Flags
151  {
158  ALLOW_FLD_CR
159  };
160 
161  SwFltControlStack(SwDoc& rDo, sal_uLong nFieldFl);
162  virtual ~SwFltControlStack();
163 
164  bool IsFlagSet(Flags no) const { return ::SwFltGetFlag(nFieldFlags, no);}
165 
166  void NewAttr(const SwPosition& rPos, const SfxPoolItem & rAttr );
167 
168  virtual SwFltStackEntry* SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId, bool bTstEnd=true, tools::Long nHand = LONG_MAX, bool consumedByField=false);
169 
170  void StealAttr(const SwNodeIndex& rNode);
171  void MarkAllAttrsOld();
172  void KillUnlockedAttrs(const SwPosition& pPos);
173  SfxPoolItem* GetFormatStackAttr(sal_uInt16 nWhich, sal_uInt16 * pPos);
174  const SfxPoolItem* GetOpenStackAttr(const SwPosition& rPos, sal_uInt16 nWhich);
175  void Delete(const SwPaM &rPam);
176 
177  bool empty() const { return m_Entries.empty(); }
178  Entries::size_type size() const { return m_Entries.size(); }
179  SwFltStackEntry& operator[](Entries::size_type nIndex)
180  { return *m_Entries[nIndex]; }
181  void DeleteAndDestroy(Entries::size_type nCnt);
182 };
183 
184 class SwFltAnchorListener;
185 
187 {
189  std::unique_ptr<SwFltAnchorListener> pListener;
190 
191 public:
192  SwFltAnchor(SwFrameFormat* pFlyFormat);
193  SwFltAnchor(const SwFltAnchor&);
194  virtual ~SwFltAnchor() override;
195 
196  // "purely virtual methods" of SfxPoolItem
197  virtual bool operator==(const SfxPoolItem&) const override;
198  virtual SwFltAnchor* Clone(SfxItemPool* = nullptr) const override;
199  void SetFrameFormat(SwFrameFormat* _pFrameFormat);
200  const SwFrameFormat* GetFrameFormat() const { return pFrameFormat; }
201  SwFrameFormat* GetFrameFormat() { return pFrameFormat; }
202 };
203 
205 {
207  public:
208  SwFltAnchorListener(SwFltAnchor* pFltAnchor);
209  virtual void Notify(const SfxHint&) override;
210 };
211 
213 {
214 public:
217  std::size_t nAutorNo;
218 
220  std::size_t nAutorNo_,
221  const DateTime& rStamp_)
222  : SfxPoolItem(RES_FLTR_REDLINE), aStamp(rStamp_),
223  eType(eType_),
224  nAutorNo(nAutorNo_)
225  {
226  }
227 
228  // "purely virtual methods" of SfxPoolItem
229  virtual bool operator==(const SfxPoolItem& rItem) const override;
230  virtual SwFltRedline* Clone(SfxItemPool* = nullptr) const override;
231 };
232 
234 {
235 private:
236 
238  OUString maName;
239  OUString maVal;
241 
242 public:
243  SwFltBookmark( const OUString& rNa,
244  const OUString& rVa,
245  tools::Long nHand,
246  const bool bIsTOCBookmark = false );
247 
248  // "purely virtual methods" of SfxPoolItem
249  virtual bool operator==(const SfxPoolItem&) const override;
250  virtual SwFltBookmark* Clone(SfxItemPool* = nullptr) const override;
251 
252  tools::Long GetHandle() const { return mnHandle; }
253  const OUString& GetName() const { return maName; }
254  const OUString& GetValSys() const { return maVal; }
255  bool IsTOCBookmark() const
256  {
257  return mbIsTOCBookmark;
258  }
259 };
260 
263 {
265  std::vector< std::pair<OUString, OUString> > m_aAttributes;
266 
267 public:
268  SwFltRDFMark();
269 
270  virtual bool operator==(const SfxPoolItem&) const override;
271  virtual SwFltRDFMark* Clone(SfxItemPool* = nullptr) const override;
272 
273  void SetHandle(tools::Long nHandle);
274  tools::Long GetHandle() const;
275  void SetAttributes(const std::vector< std::pair<OUString, OUString> >& rAttributes);
276  const std::vector< std::pair<OUString, OUString> >& GetAttributes() const;
277 };
278 
280 {
281  std::shared_ptr<SwTOXBase> m_xTOXBase;
282  bool bHadBreakItem; // there was a break item BEFORE insertion of the TOX
284 public:
285  SwFltTOX(std::shared_ptr<SwTOXBase> xBase);
286  // "purely virtual methods" of SfxPoolItem
287  virtual bool operator==(const SfxPoolItem&) const override;
288  virtual SwFltTOX* Clone(SfxItemPool* = nullptr) const override;
289  const SwTOXBase& GetBase() const { return *m_xTOXBase; }
290  void SetHadBreakItem( bool bVal ) { bHadBreakItem = bVal; }
291  void SetHadPageDescItem( bool bVal ) { bHadPageDescItem = bVal; }
292  bool HadBreakItem() const { return bHadBreakItem; }
293  bool HadPageDescItem() const { return bHadPageDescItem; }
294 };
295 
296 // The WWEndStack behaves like the WWControlStack, except that the attributes
297 // on it are hoarded to the end of the document if they need to be accessed
298 // (e.g., book/RefMarks, index, etc.).
300 {
301 public:
302  SwFltEndStack(SwDoc& rDo, sal_uLong nFieldFl)
303  :SwFltControlStack(rDo, nFieldFl)
304  {
305  bIsEndStack = true;
306  }
307 };
308 
309 SW_DLLPUBLIC void UpdatePageDescs(SwDoc &rDoc, size_t nInPageDescOffset);
310 
312 {
313 private:
315 public:
316  ImportProgress(SwDocShell *pDocShell, tools::Long nStartVal, tools::Long nEndVal)
317  : m_pDocShell(pDocShell)
318  {
319  ::StartProgress(STR_STATSTR_W4WREAD, nStartVal, nEndVal, m_pDocShell);
320  }
321 
322  void Update(sal_uInt16 nProgress)
323  {
324  ::SetProgressState(nProgress, m_pDocShell); // Update
325  }
326 
328  {
329  ::EndProgress(m_pDocShell);
330  }
331 };
332 
333 #endif
334 
335 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< std::pair< OUString, OUString > > m_aAttributes
Definition: fltshell.hxx:265
tools::Long mnHandle
Definition: fltshell.hxx:237
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:240
sal_Int32 mnStartCP
Definition: fltshell.hxx:96
bool bHadPageDescItem
Definition: fltshell.hxx:283
Marks a position in the document model.
Definition: pam.hxx:35
const SwTOXBase & GetBase() const
Definition: fltshell.hxx:289
bool IsTOCBookmark() const
Definition: fltshell.hxx:255
SW_DLLPUBLIC bool MakeRegion(SwDoc &rDoc, SwPaM &rRegion, RegionMode eCheck) const
Definition: fltshell.cxx:170
virtual bool operator==(const SfxPoolItem &) const =0
SwNodeIndex m_nNode
Definition: fltshell.hxx:51
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
SwNodeIndex nNode
Definition: pam.hxx:37
std::shared_ptr< SwTOXBase > m_xTOXBase
Definition: fltshell.hxx:281
sal_uIntPtr sal_uLong
long Long
Base class of all fields.
Definition: fldbas.hxx:293
Definition: doc.hxx:184
SwFrameFormat * GetFrameFormat()
Definition: fltshell.hxx:201
void EndProgress(SwDocShell const *pDocShell)
Definition: mainwn.cxx:92
void Update(sal_uInt16 nProgress)
Definition: fltshell.hxx:322
bool bConsumedByField
Definition: fltshell.hxx:93
OUString maName
Definition: fltshell.hxx:238
tools::Long m_nHandle
Definition: fltshell.hxx:264
SwFltAnchor * m_pFltAnchor
Definition: fltshell.hxx:206
Stores RDF statements on a paragraph (key-value pairs where the subject is the paragraph).
Definition: fltshell.hxx:262
RedlineType eType
Definition: fltshell.hxx:216
void StartProgress(const char *pMessResId, tools::Long nStartValue, tools::Long nEndValue, SwDocShell *pDocShell)
Definition: mainwn.cxx:52
SW_DLLPUBLIC ~SwFltStackEntry()
Definition: fltshell.cxx:93
SwIndex nContent
Definition: pam.hxx:38
void SetPos(const SwPosition &rPos)
Definition: fltshell.hxx:71
sal_Int32 mnEndCP
Definition: fltshell.hxx:97
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
bool bHadBreakItem
Definition: fltshell.hxx:282
void SetIsParaEnd(bool bArg)
Definition: fltshell.hxx:115
constexpr TypedWhichId< SwFltRedline > RES_FLTR_REDLINE(192)
SwFltAnchorListener(SwFltAnchor *pFltAnchor)
Definition: fltshell.cxx:959
bool operator==(const SwFltPosition &rOther) const
Definition: fltshell.hxx:54
void SetHadPageDescItem(bool bVal)
Definition: fltshell.hxx:291
void SetHadBreakItem(bool bVal)
Definition: fltshell.hxx:290
std::unique_ptr< SwFltAnchorListener > pListener
Definition: fltshell.hxx:189
bool IsParaEnd() const
Definition: fltshell.hxx:114
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
SW_DLLPUBLIC void SetEndPos(const SwPosition &rEndPos)
Definition: fltshell.cxx:98
const SwFrameFormat * GetFrameFormat() const
Definition: fltshell.hxx:200
ImportProgress(SwDocShell *pDocShell, tools::Long nStartVal, tools::Long nEndVal)
Definition: fltshell.hxx:316
virtual void Notify(const SfxHint &) override
Definition: fltshell.cxx:963
bool empty() const
Definition: fltshell.hxx:177
Style of a layout element.
Definition: frmfmt.hxx:57
virtual sal_Int32 GetCurrAttrCP() const
Definition: fltshell.hxx:139
tools::Long GetHandle() const
Definition: fltshell.hxx:252
RegionMode
Definition: swcont.hxx:51
SwFltStackEntry & operator=(SwFltStackEntry const &)=delete
sal_uLong nFieldFlags
Definition: fltshell.hxx:129
bool SwFltGetFlag(sal_uLong nFieldFlags, int no)
Definition: fltshell.hxx:43
SwDocShell * m_pDocShell
Definition: fltshell.hxx:314
SwFltStackEntry(SwFltStackEntry const &)=delete
Marks a node in the document model.
Definition: ndindex.hxx:31
SwFltPosition(const SwPosition &rPos)
Definition: fltshell.hxx:66
sal_Int32 m_nContent
Definition: fltshell.hxx:52
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
std::vector< std::unique_ptr< SwFltStackEntry > > Entries
Definition: fltshell.hxx:126
std::size_t nAutorNo
Definition: fltshell.hxx:217
bool IsFlagSet(Flags no) const
Definition: fltshell.hxx:164
SwFltPosition m_aMkPos
Definition: fltshell.hxx:86
std::unique_ptr< SfxPoolItem > pAttr
Definition: fltshell.hxx:89
SwFltPosition m_aPtPos
Definition: fltshell.hxx:87
SwFltEndStack(SwDoc &rDo, sal_uLong nFieldFl)
Definition: fltshell.hxx:302
bool m_isAnnotationOnEnd
annotation already moved onto its end pos.
Definition: fltshell.hxx:94
OUString maVal
Definition: fltshell.hxx:239
sal_Int32 GetIndex() const
Definition: index.hxx:91
void SetProgressState(tools::Long nPosition, SwDocShell const *pDocShell)
Definition: mainwn.cxx:82
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:392
sal_Int32 GetStartCP() const
Definition: fltshell.hxx:112
bool HadPageDescItem() const
Definition: fltshell.hxx:293
bool mbIsTOCBookmark
Definition: fltshell.hxx:240
bool HadBreakItem() const
Definition: fltshell.hxx:292
const OUString & GetName() const
Definition: fltshell.hxx:253
const OUString & GetValSys() const
Definition: fltshell.hxx:254
sal_Int32 GetEndCP() const
Definition: fltshell.hxx:113
void SetStartCP(sal_Int32 nCP)
Definition: fltshell.hxx:110
DateTime aStamp
Definition: fltshell.hxx:215
RedlineType
void SetEndCP(sal_Int32 nCP)
Definition: fltshell.hxx:111
SwFltRedline(RedlineType eType_, std::size_t nAutorNo_, const DateTime &rStamp_)
Definition: fltshell.hxx:219
SwFltStackEntry & operator[](Entries::size_type nIndex)
Definition: fltshell.hxx:179
virtual void ClearParaEndPosition()
Definition: fltshell.hxx:143
void SetPos(SwNodeIndex const &rNode, sal_uInt16 nIdx)
Definition: fltshell.hxx:59
Entries::size_type size() const
Definition: fltshell.hxx:178
SwFrameFormat * pFrameFormat
Definition: fltshell.hxx:188
SW_DLLPUBLIC void UpdatePageDescs(SwDoc &rDoc, size_t nInPageDescOffset)
Definition: fltshell.cxx:1091