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:
217  std::size_t const nAutorNo;
218 
220  std::size_t nAutorNo_,
221  const DateTime& rStamp_,
222  RedlineType eTypePrev_ = RedlineType::Insert)
223  : SfxPoolItem(RES_FLTR_REDLINE), aStamp(rStamp_),
224  aStampPrev( DateTime::EMPTY ),
225  eType(eType_),
226  eTypePrev(eTypePrev_), nAutorNo(nAutorNo_)
227  {
228  }
229 
230  // "purely virtual methods" of SfxPoolItem
231  virtual bool operator==(const SfxPoolItem& rItem) const override;
232  virtual SfxPoolItem* Clone(SfxItemPool* = nullptr) const override;
233 };
234 
236 {
237 private:
238 
239  long const mnHandle;
240  OUString maName;
241  OUString const maVal;
242  bool const mbIsTOCBookmark;
243 
244 public:
245  SwFltBookmark( const OUString& rNa,
246  const OUString& rVa,
247  long nHand,
248  const bool bIsTOCBookmark = false );
249 
250  // "purely virtual methods" of SfxPoolItem
251  virtual bool operator==(const SfxPoolItem&) const override;
252  virtual SfxPoolItem* Clone(SfxItemPool* = nullptr) const override;
253 
254  long GetHandle() const { return mnHandle; }
255  const OUString& GetName() const { return maName; }
256  const OUString& GetValSys() const { return maVal; }
257  bool IsTOCBookmark() const
258  {
259  return mbIsTOCBookmark;
260  }
261 };
262 
265 {
266  long m_nHandle;
267  std::vector< std::pair<OUString, OUString> > m_aAttributes;
268 
269 public:
270  SwFltRDFMark();
271 
272  virtual bool operator==(const SfxPoolItem&) const override;
273  virtual SfxPoolItem* Clone(SfxItemPool* = nullptr) const override;
274 
275  void SetHandle(long nHandle);
276  long GetHandle() const;
277  void SetAttributes(const std::vector< std::pair<OUString, OUString> >& rAttributes);
278  const std::vector< std::pair<OUString, OUString> >& GetAttributes() const;
279 };
280 
282 {
283  std::shared_ptr<SwTOXBase> m_xTOXBase;
284  bool bHadBreakItem; // there was a break item BEFORE insertion of the TOX
286 public:
287  SwFltTOX(SwTOXBase* pBase);
288  // "purely virtual methods" of SfxPoolItem
289  virtual bool operator==(const SfxPoolItem&) const override;
290  virtual SfxPoolItem* Clone(SfxItemPool* = nullptr) const override;
291  const SwTOXBase& GetBase() { return *m_xTOXBase; }
292  void SetHadBreakItem( bool bVal ) { bHadBreakItem = bVal; }
293  void SetHadPageDescItem( bool bVal ) { bHadPageDescItem = bVal; }
294  bool HadBreakItem() const { return bHadBreakItem; }
295  bool HadPageDescItem() const { return bHadPageDescItem; }
296 };
297 
298 // The WWEndStack behaves like the WWControlStack, except that the attributes
299 // on it are hoarded to the end of the document if they need to be accessed
300 // (e.g., book/RefMarks, index, etc.).
302 {
303 public:
304  SwFltEndStack(SwDoc* pDo, sal_uLong nFieldFl)
305  :SwFltControlStack(pDo, nFieldFl)
306  {
307  bIsEndStack = true;
308  }
309 };
310 
311 SW_DLLPUBLIC void UpdatePageDescs(SwDoc &rDoc, size_t nInPageDescOffset);
312 
314 {
315 private:
317 public:
318  ImportProgress(SwDocShell *pDocShell, long nStartVal, long nEndVal)
319  : m_pDocShell(pDocShell)
320  {
321  ::StartProgress(STR_STATSTR_W4WREAD, nStartVal, nEndVal, m_pDocShell);
322  }
323 
324  void Update(sal_uInt16 nProgress)
325  {
326  ::SetProgressState(nProgress, m_pDocShell); // Update
327  }
328 
330  {
331  ::EndProgress(m_pDocShell);
332  }
333 };
334 
335 #endif
336 
337 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< std::pair< OUString, OUString > > m_aAttributes
Definition: fltshell.hxx:267
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:233
long m_nHandle
Definition: fltshell.hxx:266
sal_Int32 mnStartCP
Definition: fltshell.hxx:95
bool bHadPageDescItem
Definition: fltshell.hxx:285
Marks a position in the document model.
Definition: pam.hxx:35
bool IsTOCBookmark() const
Definition: fltshell.hxx:257
virtual bool operator==(const SfxPoolItem &) const =0
SwFltEndStack(SwDoc *pDo, sal_uLong nFieldFl)
Definition: fltshell.hxx:304
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:283
sal_uIntPtr sal_uLong
#define RES_FLTR_REDLINE
Definition: hintids.hxx:325
long const mnHandle
Definition: fltshell.hxx:239
Base class of all fields.
Definition: fldbas.hxx:279
Definition: doc.hxx:185
SwFrameFormat * GetFrameFormat()
Definition: fltshell.hxx:197
DateTime const aStampPrev
Definition: fltshell.hxx:214
void EndProgress(SwDocShell const *pDocShell)
Definition: mainwn.cxx:88
void Update(sal_uInt16 nProgress)
Definition: fltshell.hxx:324
bool bConsumedByField
Definition: fltshell.hxx:92
OUString maName
Definition: fltshell.hxx:240
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:264
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:284
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:293
long GetHandle() const
Definition: fltshell.hxx:254
void SetProgressState(long nPosition, SwDocShell const *pDocShell)
Definition: mainwn.cxx:78
SwFltRedline(RedlineType eType_, std::size_t nAutorNo_, const DateTime &rStamp_, RedlineType eTypePrev_=RedlineType::Insert)
Definition: fltshell.hxx:219
SwDocShell *const m_pDocShell
Definition: fltshell.hxx:316
void SetHadBreakItem(bool bVal)
Definition: fltshell.hxx:292
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:241
SwFltPosition m_aMkPos
Definition: fltshell.hxx:85
ImportProgress(SwDocShell *pDocShell, long nStartVal, long nEndVal)
Definition: fltshell.hxx:318
const SwTOXBase & GetBase()
Definition: fltshell.hxx:291
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
RedlineType const eTypePrev
Definition: fltshell.hxx:216
std::size_t const nAutorNo
Definition: fltshell.hxx:217
RedlineType const eType
Definition: fltshell.hxx:215
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:295
bool const mbIsTOCBookmark
Definition: fltshell.hxx:242
bool HadBreakItem() const
Definition: fltshell.hxx:294
const OUString & GetName() const
Definition: fltshell.hxx:255
const OUString & GetValSys() const
Definition: fltshell.hxx:256
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
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