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