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