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  SW_DLLPUBLIC void SetEndPos( const SwPosition & rEndPos);
104  SW_DLLPUBLIC bool MakeRegion(SwDoc* pDoc, SwPaM& rRegion, bool bCheck) const;
105  SW_DLLPUBLIC static bool MakeRegion(SwDoc* pDoc, SwPaM& rRegion,
106  bool bCheck, const SwFltPosition &rMkPos, const SwFltPosition &rPtPos, bool bIsParaEnd=false,
107  sal_uInt16 nWhich=0);
108 
109  void SetStartCP(sal_Int32 nCP) {mnStartCP = nCP;}
110  void SetEndCP(sal_Int32 nCP) {mnEndCP = nCP;}
111  sal_Int32 GetStartCP() const {return mnStartCP;}
112  sal_Int32 GetEndCP() const {return mnEndCP;}
113  bool IsParaEnd() const { return bIsParaEnd;}
114  void SetIsParaEnd(bool bArg){ bIsParaEnd = bArg;}
115 };
116 
118 {
119 private:
120  SwFltControlStack(SwFltControlStack const&) = delete;
121  SwFltControlStack& operator=(SwFltControlStack const&) = delete;
122 
123  typedef std::vector<std::unique_ptr<SwFltStackEntry>> Entries;
124  Entries m_Entries;
125 
127 
128  bool bHasSdOD;
130 
131 protected:
134 
135  virtual void SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry& rEntry);
136  virtual sal_Int32 GetCurrAttrCP() const {return -1;}
137  virtual bool IsParaEndInCPs(sal_Int32 nStart,sal_Int32 nEnd,bool bSdOD) const;
138 
139  //Clear the para end position recorded in reader intermittently for the least impact on loading performance
140  virtual void ClearParaEndPosition(){};
141  virtual bool CheckSdOD(sal_Int32 nStart,sal_Int32 nEnd);
142  bool HasSdOD();
143 
144 public:
145  enum class MoveAttrsMode { DEFAULT, POSTIT_INSERTED };
146  void MoveAttrs(const SwPosition& rPos, MoveAttrsMode = MoveAttrsMode::DEFAULT);
147  enum Flags
148  {
155  ALLOW_FLD_CR
156  };
157 
158  SwFltControlStack(SwDoc* pDo, sal_uLong nFieldFl);
159  virtual ~SwFltControlStack();
160 
161  bool IsFlagSet(Flags no) const { return ::SwFltGetFlag(nFieldFlags, no);}
162 
163  void NewAttr(const SwPosition& rPos, const SfxPoolItem & rAttr );
164 
165  virtual SwFltStackEntry* SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId, bool bTstEnde=true, long nHand = LONG_MAX, bool consumedByField=false);
166 
167  void StealAttr(const SwNodeIndex& rNode);
168  void MarkAllAttrsOld();
169  void KillUnlockedAttrs(const SwPosition& pPos);
170  SfxPoolItem* GetFormatStackAttr(sal_uInt16 nWhich, sal_uInt16 * pPos);
171  const SfxPoolItem* GetOpenStackAttr(const SwPosition& rPos, sal_uInt16 nWhich);
172  void Delete(const SwPaM &rPam);
173 
174  bool empty() const { return m_Entries.empty(); }
175  Entries::size_type size() const { return m_Entries.size(); }
176  SwFltStackEntry& operator[](Entries::size_type nIndex)
177  { return *m_Entries[nIndex]; }
178  void DeleteAndDestroy(Entries::size_type nCnt);
179 };
180 
181 class SwFltAnchorListener;
182 
184 {
186  std::unique_ptr<SwFltAnchorListener> pListener;
187 
188 public:
189  SwFltAnchor(SwFrameFormat* pFlyFormat);
190  SwFltAnchor(const SwFltAnchor&);
191  virtual ~SwFltAnchor() override;
192 
193  // "purely virtual methods" of SfxPoolItem
194  virtual bool operator==(const SfxPoolItem&) const override;
195  virtual SfxPoolItem* Clone(SfxItemPool* = nullptr) const override;
196  void SetFrameFormat(SwFrameFormat* _pFrameFormat);
197  const SwFrameFormat* GetFrameFormat() const { return pFrameFormat; }
198  SwFrameFormat* GetFrameFormat() { return pFrameFormat; }
199 };
200 
202 {
204  public:
205  SwFltAnchorListener(SwFltAnchor* pFltAnchor);
206  virtual void Notify(const SfxHint&) override;
207 };
208 
210 {
211 public:
214  std::size_t const nAutorNo;
215 
217  std::size_t nAutorNo_,
218  const DateTime& rStamp_)
219  : SfxPoolItem(RES_FLTR_REDLINE), aStamp(rStamp_),
220  eType(eType_),
221  nAutorNo(nAutorNo_)
222  {
223  }
224 
225  // "purely virtual methods" of SfxPoolItem
226  virtual bool operator==(const SfxPoolItem& rItem) const override;
227  virtual SfxPoolItem* Clone(SfxItemPool* = nullptr) const override;
228 };
229 
231 {
232 private:
233 
234  long const mnHandle;
235  OUString maName;
236  OUString const maVal;
237  bool const mbIsTOCBookmark;
238 
239 public:
240  SwFltBookmark( const OUString& rNa,
241  const OUString& rVa,
242  long nHand,
243  const bool bIsTOCBookmark = false );
244 
245  // "purely virtual methods" of SfxPoolItem
246  virtual bool operator==(const SfxPoolItem&) const override;
247  virtual SfxPoolItem* Clone(SfxItemPool* = nullptr) const override;
248 
249  long GetHandle() const { return mnHandle; }
250  const OUString& GetName() const { return maName; }
251  const OUString& GetValSys() const { return maVal; }
252  bool IsTOCBookmark() const
253  {
254  return mbIsTOCBookmark;
255  }
256 };
257 
260 {
261  long m_nHandle;
262  std::vector< std::pair<OUString, OUString> > m_aAttributes;
263 
264 public:
265  SwFltRDFMark();
266 
267  virtual bool operator==(const SfxPoolItem&) const override;
268  virtual SfxPoolItem* Clone(SfxItemPool* = nullptr) const override;
269 
270  void SetHandle(long nHandle);
271  long GetHandle() const;
272  void SetAttributes(const std::vector< std::pair<OUString, OUString> >& rAttributes);
273  const std::vector< std::pair<OUString, OUString> >& GetAttributes() const;
274 };
275 
277 {
278  std::shared_ptr<SwTOXBase> m_xTOXBase;
279  bool bHadBreakItem; // there was a break item BEFORE insertion of the TOX
281 public:
282  SwFltTOX(SwTOXBase* pBase);
283  // "purely virtual methods" of SfxPoolItem
284  virtual bool operator==(const SfxPoolItem&) const override;
285  virtual SfxPoolItem* Clone(SfxItemPool* = nullptr) const override;
286  const SwTOXBase& GetBase() const { return *m_xTOXBase; }
287  void SetHadBreakItem( bool bVal ) { bHadBreakItem = bVal; }
288  void SetHadPageDescItem( bool bVal ) { bHadPageDescItem = bVal; }
289  bool HadBreakItem() const { return bHadBreakItem; }
290  bool HadPageDescItem() const { return bHadPageDescItem; }
291 };
292 
293 // The WWEndStack behaves like the WWControlStack, except that the attributes
294 // on it are hoarded to the end of the document if they need to be accessed
295 // (e.g., book/RefMarks, index, etc.).
297 {
298 public:
299  SwFltEndStack(SwDoc* pDo, sal_uLong nFieldFl)
300  :SwFltControlStack(pDo, nFieldFl)
301  {
302  bIsEndStack = true;
303  }
304 };
305 
306 SW_DLLPUBLIC void UpdatePageDescs(SwDoc &rDoc, size_t nInPageDescOffset);
307 
309 {
310 private:
312 public:
313  ImportProgress(SwDocShell *pDocShell, long nStartVal, long nEndVal)
314  : m_pDocShell(pDocShell)
315  {
316  ::StartProgress(STR_STATSTR_W4WREAD, nStartVal, nEndVal, m_pDocShell);
317  }
318 
319  void Update(sal_uInt16 nProgress)
320  {
321  ::SetProgressState(nProgress, m_pDocShell); // Update
322  }
323 
325  {
326  ::EndProgress(m_pDocShell);
327  }
328 };
329 
330 #endif
331 
332 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< std::pair< OUString, OUString > > m_aAttributes
Definition: fltshell.hxx:262
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:234
long m_nHandle
Definition: fltshell.hxx:261
sal_Int32 mnStartCP
Definition: fltshell.hxx:96
bool bHadPageDescItem
Definition: fltshell.hxx:280
Marks a position in the document model.
Definition: pam.hxx:35
const SwTOXBase & GetBase() const
Definition: fltshell.hxx:286
bool IsTOCBookmark() const
Definition: fltshell.hxx:252
virtual bool operator==(const SfxPoolItem &) const =0
SwFltEndStack(SwDoc *pDo, sal_uLong nFieldFl)
Definition: fltshell.hxx:299
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:278
sal_uIntPtr sal_uLong
#define RES_FLTR_REDLINE
Definition: hintids.hxx:326
long const mnHandle
Definition: fltshell.hxx:234
Base class of all fields.
Definition: fldbas.hxx:280
Definition: doc.hxx:185
SwFrameFormat * GetFrameFormat()
Definition: fltshell.hxx:198
void EndProgress(SwDocShell const *pDocShell)
Definition: mainwn.cxx:88
void Update(sal_uInt16 nProgress)
Definition: fltshell.hxx:319
bool bConsumedByField
Definition: fltshell.hxx:93
OUString maName
Definition: fltshell.hxx:235
SwFltAnchor * m_pFltAnchor
Definition: fltshell.hxx:203
Stores RDF statements on a paragraph (key-value pairs where the subject is the paragraph).
Definition: fltshell.hxx:259
SW_DLLPUBLIC ~SwFltStackEntry()
Definition: fltshell.cxx:119
void StartProgress(const char *pMessResId, long nStartValue, long nEndValue, SwDocShell *pDocShell)
Definition: mainwn.cxx:48
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:279
void SetIsParaEnd(bool bArg)
Definition: fltshell.hxx:114
SwFltAnchorListener(SwFltAnchor *pFltAnchor)
Definition: fltshell.cxx:978
bool operator==(const SwFltPosition &rOther) const
Definition: fltshell.hxx:54
void SetHadPageDescItem(bool bVal)
Definition: fltshell.hxx:288
long GetHandle() const
Definition: fltshell.hxx:249
void SetProgressState(long nPosition, SwDocShell const *pDocShell)
Definition: mainwn.cxx:78
SwDocShell *const m_pDocShell
Definition: fltshell.hxx:311
void SetHadBreakItem(bool bVal)
Definition: fltshell.hxx:287
std::unique_ptr< SwFltAnchorListener > pListener
Definition: fltshell.hxx:186
bool IsParaEnd() const
Definition: fltshell.hxx:113
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:124
const SwFrameFormat * GetFrameFormat() const
Definition: fltshell.hxx:197
virtual void Notify(const SfxHint &) override
Definition: fltshell.cxx:982
bool empty() const
Definition: fltshell.hxx:174
Style of a layout element.
Definition: frmfmt.hxx:57
virtual sal_Int32 GetCurrAttrCP() const
Definition: fltshell.hxx:136
SW_DLLPUBLIC bool MakeRegion(SwDoc *pDoc, SwPaM &rRegion, bool bCheck) const
Definition: fltshell.cxx:190
SwFltStackEntry & operator=(SwFltStackEntry const &)=delete
bool SwFltGetFlag(sal_uLong nFieldFlags, int no)
Definition: fltshell.hxx:43
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:123
bool IsFlagSet(Flags no) const
Definition: fltshell.hxx:161
OUString const maVal
Definition: fltshell.hxx:236
SwFltPosition m_aMkPos
Definition: fltshell.hxx:86
ImportProgress(SwDocShell *pDocShell, long nStartVal, long nEndVal)
Definition: fltshell.hxx:313
std::unique_ptr< SfxPoolItem > pAttr
Definition: fltshell.hxx:89
sal_uLong const nFieldFlags
Definition: fltshell.hxx:126
SwFltPosition m_aPtPos
Definition: fltshell.hxx:87
std::size_t const nAutorNo
Definition: fltshell.hxx:214
RedlineType const eType
Definition: fltshell.hxx:213
bool m_isAnnotationOnEnd
annotation already moved onto its end pos.
Definition: fltshell.hxx:94
sal_Int32 GetIndex() const
Definition: index.hxx:95
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:386
sal_Int32 GetStartCP() const
Definition: fltshell.hxx:111
bool HadPageDescItem() const
Definition: fltshell.hxx:290
bool const mbIsTOCBookmark
Definition: fltshell.hxx:237
bool HadBreakItem() const
Definition: fltshell.hxx:289
const OUString & GetName() const
Definition: fltshell.hxx:250
const OUString & GetValSys() const
Definition: fltshell.hxx:251
sal_Int32 GetEndCP() const
Definition: fltshell.hxx:112
void SetStartCP(sal_Int32 nCP)
Definition: fltshell.hxx:109
DateTime const aStamp
Definition: fltshell.hxx:212
void SetEndCP(sal_Int32 nCP)
Definition: fltshell.hxx:110
SwFltRedline(RedlineType eType_, std::size_t nAutorNo_, const DateTime &rStamp_)
Definition: fltshell.hxx:216
SwFltStackEntry & operator[](Entries::size_type nIndex)
Definition: fltshell.hxx:176
virtual void ClearParaEndPosition()
Definition: fltshell.hxx:140
void SetPos(SwNodeIndex const &rNode, sal_uInt16 nIdx)
Definition: fltshell.hxx:59
Entries::size_type size() const
Definition: fltshell.hxx:175
SwFrameFormat * pFrameFormat
Definition: fltshell.hxx:185
SW_DLLPUBLIC void UpdatePageDescs(SwDoc &rDoc, size_t nInPageDescOffset)
Definition: fltshell.cxx:1102