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 <svx/ctredlin.hxx>
25#include <tools/datetime.hxx>
26#include <mdiexp.hxx>
27#include <ndindex.hxx>
28#include <pam.hxx>
29#include <strings.hrc>
30
31#include <cstddef>
32#include <memory>
33
34class SwTOXBase;
35class SwField;
36class SwFieldType;
37class Graphic;
38class SwTableBox;
39class SwDoc;
40class SwPaM;
41
42inline 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{
49public:
51 sal_Int32 m_nContent;
52public:
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
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.GetNode(), -1)
68 , m_nContent(rPos.GetContentIndex())
69 {
70 }
71
72 void FromSwPosition(const SwPosition &rPos)
73 {
74 m_nNode = rPos.GetNodeIndex()-1;
75 m_nContent = rPos.GetContentIndex();
76 }
77};
78
79// Stack entry for the attributes. It is always pointers to new attributes that are passed.
81{
82private:
85
86public:
89
90 std::unique_ptr<SfxPoolItem> m_pAttr;// Format Attribute
91
92 bool m_bOld; // to mark Attributes *before* skipping field results
93 bool m_bOpen; //Entry open, awaiting being closed
96
97 SW_DLLPUBLIC SwFltStackEntry(const SwPosition & rStartPos, std::unique_ptr<SfxPoolItem> pHt );
99
100 enum class RegionMode { NoCheck = 0, CheckNodes = 1<<0, CheckFieldmark = 1<<1 };
101 SW_DLLPUBLIC void SetEndPos( const SwPosition & rEndPos);
102 SW_DLLPUBLIC bool MakeRegion(SwDoc& rDoc, SwPaM& rRegion, RegionMode eCheck) const;
103 SW_DLLPUBLIC static bool MakeRegion(SwDoc& rDoc, SwPaM& rRegion,
104 RegionMode eCheck, const SwFltPosition &rMkPos, const SwFltPosition &rPtPos,
105 sal_uInt16 nWhich=0);
106};
107
108template<> struct o3tl::typed_flags<SwFltStackEntry::RegionMode>: o3tl::is_typed_flags<SwFltStackEntry::RegionMode, 0x03> {};
109
111{
112private:
115
116 typedef std::vector<std::unique_ptr<SwFltStackEntry>> Entries;
118
120
121protected:
124
125 virtual void SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry& rEntry);
126
127public:
128 enum class MoveAttrsMode { DEFAULT, POSTIT_INSERTED };
129 void MoveAttrs(const SwPosition& rPos, MoveAttrsMode = MoveAttrsMode::DEFAULT);
130 enum Flags
131 {
138 ALLOW_FLD_CR
139 };
140
141 SwFltControlStack(SwDoc& rDo, sal_uLong nFieldFl);
142 virtual ~SwFltControlStack();
143
144 bool IsFlagSet(Flags no) const { return ::SwFltGetFlag(m_nFieldFlags, no);}
145
146 void NewAttr(const SwPosition& rPos, const SfxPoolItem & rAttr );
147
148 virtual SwFltStackEntry* SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId, bool bTstEnd=true, tools::Long nHand = LONG_MAX, bool consumedByField=false);
149
150 void StealAttr(const SwNode& rNode);
151 void MarkAllAttrsOld();
152 void KillUnlockedAttrs(const SwPosition& pPos);
153 SfxPoolItem* GetFormatStackAttr(sal_uInt16 nWhich, sal_uInt16 * pPos);
154 const SfxPoolItem* GetOpenStackAttr(const SwPosition& rPos, sal_uInt16 nWhich);
155 void Delete(const SwPaM &rPam);
156
157 bool empty() const { return m_Entries.empty(); }
158 Entries::size_type size() const { return m_Entries.size(); }
159 SwFltStackEntry& operator[](Entries::size_type nIndex)
160 { return *m_Entries[nIndex]; }
161 void DeleteAndDestroy(Entries::size_type nCnt);
162};
163
165
167{
169 std::unique_ptr<SwFltAnchorListener> m_pListener;
170
171public:
172 SwFltAnchor(SwFrameFormat* pFlyFormat);
173 SwFltAnchor(const SwFltAnchor&);
174 virtual ~SwFltAnchor() override;
175
176 // "purely virtual methods" of SfxPoolItem
177 virtual bool operator==(const SfxPoolItem&) const override;
178 virtual SwFltAnchor* Clone(SfxItemPool* = nullptr) const override;
179 void SetFrameFormat(SwFrameFormat* _pFrameFormat);
180 const SwFrameFormat* GetFrameFormat() const { return m_pFrameFormat; }
181 SwFrameFormat* GetFrameFormat() { return m_pFrameFormat; }
182};
183
186{
188 public:
189 SwFltAnchorListener(SwFltAnchor* pFltAnchor);
190 virtual void Notify(const SfxHint&) override;
191};
192
194{
195public:
198 std::size_t m_nAutorNo;
199
201 std::size_t nAutorNo_,
202 const DateTime& rStamp_)
203 : SfxPoolItem(RES_FLTR_REDLINE), m_aStamp(rStamp_),
204 m_eType(eType_),
205 m_nAutorNo(nAutorNo_)
206 {
207 }
208
209 // "purely virtual methods" of SfxPoolItem
210 virtual bool operator==(const SfxPoolItem& rItem) const override;
211 virtual SwFltRedline* Clone(SfxItemPool* = nullptr) const override;
212};
213
215{
216private:
217
219 OUString maName;
220 OUString maVal;
222
223public:
224 SwFltBookmark( const OUString& rNa,
225 OUString aVa,
226 tools::Long nHand,
227 const bool bIsTOCBookmark = false );
228
229 // "purely virtual methods" of SfxPoolItem
230 virtual bool operator==(const SfxPoolItem&) const override;
231 virtual SwFltBookmark* Clone(SfxItemPool* = nullptr) const override;
232
233 tools::Long GetHandle() const { return mnHandle; }
234 const OUString& GetName() const { return maName; }
235 const OUString& GetValSys() const { return maVal; }
236 bool IsTOCBookmark() const
237 {
238 return mbIsTOCBookmark;
239 }
240};
241
244{
246 std::vector< std::pair<OUString, OUString> > m_aAttributes;
247
248public:
249 SwFltRDFMark();
250
251 virtual bool operator==(const SfxPoolItem&) const override;
252 virtual SwFltRDFMark* Clone(SfxItemPool* = nullptr) const override;
253
254 void SetHandle(tools::Long nHandle);
255 tools::Long GetHandle() const;
256 void SetAttributes(std::vector< std::pair<OUString, OUString> >&& rAttributes);
257 const std::vector< std::pair<OUString, OUString> >& GetAttributes() const;
258};
259
261{
262 std::shared_ptr<SwTOXBase> m_xTOXBase;
263 bool m_bHadBreakItem; // there was a break item BEFORE insertion of the TOX
265public:
266 SwFltTOX(std::shared_ptr<SwTOXBase> xBase);
267 // "purely virtual methods" of SfxPoolItem
268 virtual bool operator==(const SfxPoolItem&) const override;
269 virtual SwFltTOX* Clone(SfxItemPool* = nullptr) const override;
270 const SwTOXBase& GetBase() const { return *m_xTOXBase; }
271 void SetHadBreakItem( bool bVal ) { m_bHadBreakItem = bVal; }
272 void SetHadPageDescItem( bool bVal ) { m_bHadPageDescItem = bVal; }
273 bool HadBreakItem() const { return m_bHadBreakItem; }
274 bool HadPageDescItem() const { return m_bHadPageDescItem; }
275};
276
277// The WWEndStack behaves like the WWControlStack, except that the attributes
278// on it are hoarded to the end of the document if they need to be accessed
279// (e.g., book/RefMarks, index, etc.).
281{
282public:
284 :SwFltControlStack(rDo, nFieldFl)
285 {
286 m_bIsEndStack = true;
287 }
288};
289
290SW_DLLPUBLIC void UpdatePageDescs(SwDoc &rDoc, size_t nInPageDescOffset);
291
293{
294private:
296public:
297 ImportProgress(SwDocShell *pDocShell, tools::Long nStartVal, tools::Long nEndVal)
298 : m_pDocShell(pDocShell)
299 {
300 ::StartProgress(STR_STATSTR_W4WREAD, nStartVal, nEndVal, m_pDocShell);
301 }
302
303 void Update(sal_uInt16 nProgress)
304 {
305 ::SetProgressState(nProgress, m_pDocShell); // Update
306 }
307
309 {
311 }
312};
313
314// detect if the SwFrameFormat it is watching was deleted
316{
318public:
320
321 virtual void Notify(const SfxHint& rHint) override;
322
324 {
325 return m_pFormat;
326 }
327
328 bool WasDeleted() const
329 {
330 return !m_pFormat;
331 }
332
333 virtual ~FrameDeleteWatch() override;
334};
335
336#endif
337
338/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString maName
SwFrameFormat * m_pFormat
Definition: fltshell.hxx:317
SwFrameFormat * GetFormat()
Definition: fltshell.hxx:323
bool WasDeleted() const
Definition: fltshell.hxx:328
ImportProgress(SwDocShell *pDocShell, tools::Long nStartVal, tools::Long nEndVal)
Definition: fltshell.hxx:297
void Update(sal_uInt16 nProgress)
Definition: fltshell.hxx:303
SwDocShell * m_pDocShell
Definition: fltshell.hxx:295
Definition: doc.hxx:194
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:242
Base class of all fields.
Definition: fldbas.hxx:292
Used by SwFltAnchor, to listen to an SwFrameFormat (to be aware when it is replaced or deleted).
Definition: fltshell.hxx:186
virtual void Notify(const SfxHint &) override
Definition: fltshell.cxx:890
SwFltAnchorListener(SwFltAnchor *pFltAnchor)
Definition: fltshell.cxx:886
SwFltAnchor * m_pFltAnchor
Definition: fltshell.hxx:187
SwFrameFormat * GetFrameFormat()
Definition: fltshell.hxx:181
SwFrameFormat * m_pFrameFormat
Definition: fltshell.hxx:168
std::unique_ptr< SwFltAnchorListener > m_pListener
Definition: fltshell.hxx:169
const SwFrameFormat * GetFrameFormat() const
Definition: fltshell.hxx:180
OUString maName
Definition: fltshell.hxx:219
tools::Long mnHandle
Definition: fltshell.hxx:218
OUString maVal
Definition: fltshell.hxx:220
const OUString & GetName() const
Definition: fltshell.hxx:234
bool mbIsTOCBookmark
Definition: fltshell.hxx:221
tools::Long GetHandle() const
Definition: fltshell.hxx:233
bool IsTOCBookmark() const
Definition: fltshell.hxx:236
const OUString & GetValSys() const
Definition: fltshell.hxx:235
std::vector< std::unique_ptr< SwFltStackEntry > > Entries
Definition: fltshell.hxx:116
sal_uLong m_nFieldFlags
Definition: fltshell.hxx:119
SwFltControlStack & operator=(SwFltControlStack const &)=delete
bool IsFlagSet(Flags no) const
Definition: fltshell.hxx:144
Entries::size_type size() const
Definition: fltshell.hxx:158
SwFltControlStack(SwFltControlStack const &)=delete
bool empty() const
Definition: fltshell.hxx:157
SwFltStackEntry & operator[](Entries::size_type nIndex)
Definition: fltshell.hxx:159
SwFltEndStack(SwDoc &rDo, sal_uLong nFieldFl)
Definition: fltshell.hxx:283
Stores RDF statements on a paragraph (key-value pairs where the subject is the paragraph).
Definition: fltshell.hxx:244
tools::Long m_nHandle
Definition: fltshell.hxx:245
std::vector< std::pair< OUString, OUString > > m_aAttributes
Definition: fltshell.hxx:246
RedlineType m_eType
Definition: fltshell.hxx:197
std::size_t m_nAutorNo
Definition: fltshell.hxx:198
SwFltRedline(RedlineType eType_, std::size_t nAutorNo_, const DateTime &rStamp_)
Definition: fltshell.hxx:200
DateTime m_aStamp
Definition: fltshell.hxx:196
SW_DLLPUBLIC ~SwFltStackEntry()
Definition: fltshell.cxx:90
SwFltStackEntry & operator=(SwFltStackEntry const &)=delete
bool m_isAnnotationOnEnd
annotation already moved onto its end pos.
Definition: fltshell.hxx:95
SW_DLLPUBLIC bool MakeRegion(SwDoc &rDoc, SwPaM &rRegion, RegionMode eCheck) const
Definition: fltshell.cxx:161
SwFltPosition m_aMkPos
Definition: fltshell.hxx:87
SW_DLLPUBLIC void SetEndPos(const SwPosition &rEndPos)
Definition: fltshell.cxx:95
SwFltStackEntry(SwFltStackEntry const &)=delete
SwFltPosition m_aPtPos
Definition: fltshell.hxx:88
bool m_bConsumedByField
Definition: fltshell.hxx:94
std::unique_ptr< SfxPoolItem > m_pAttr
Definition: fltshell.hxx:90
std::shared_ptr< SwTOXBase > m_xTOXBase
Definition: fltshell.hxx:262
void SetHadBreakItem(bool bVal)
Definition: fltshell.hxx:271
bool HadBreakItem() const
Definition: fltshell.hxx:273
bool m_bHadPageDescItem
Definition: fltshell.hxx:264
void SetHadPageDescItem(bool bVal)
Definition: fltshell.hxx:272
bool HadPageDescItem() const
Definition: fltshell.hxx:274
bool m_bHadBreakItem
Definition: fltshell.hxx:263
const SwTOXBase & GetBase() const
Definition: fltshell.hxx:270
Style of a layout element.
Definition: frmfmt.hxx:62
Marks a node in the document model.
Definition: ndindex.hxx:31
Base class of the Writer document model elements.
Definition: node.hxx:98
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:426
RedlineType
const EnumerationType m_eType
bool SwFltGetFlag(sal_uLong nFieldFlags, int no)
Definition: fltshell.hxx:42
SW_DLLPUBLIC void UpdatePageDescs(SwDoc &rDoc, size_t nInPageDescOffset)
Definition: fltshell.cxx:1020
void Notify(SwFlyFrame *pFly, SwPageFrame *pOld, const SwRect &rOld, const SwRect *pOldRect=nullptr)
Notify the background based on the difference between old and new rectangle.
Definition: frmtool.cxx:3243
constexpr TypedWhichId< SwFltRedline > RES_FLTR_REDLINE(194)
sal_Int32 nIndex
void StartProgress(TranslateId pMessResId, tools::Long nStartValue, tools::Long nEndValue, SwDocShell *pDocShell)
Definition: mainwn.cxx:52
void EndProgress(SwDocShell const *pDocShell)
Definition: mainwn.cxx:92
void SetProgressState(tools::Long nPosition, SwDocShell const *pDocShell)
Definition: mainwn.cxx:82
RegionMode
css::uno::Reference< css::animations::XAnimationNode > Clone(const css::uno::Reference< css::animations::XAnimationNode > &xSourceNode, const SdPage *pSource=nullptr, const SdPage *pTarget=nullptr)
long Long
SwContentNode * GetNode(SwPaM &rPam, bool &rbFirst, SwMoveFnCollection const &fnMove, bool const bInReadOnly, SwRootFrame const *const i_pLayout)
This function returns the next node in direction of search.
Definition: pam.cxx:1019
sal_uIntPtr sal_uLong
bool operator==(const SwFltPosition &rOther) const
Definition: fltshell.hxx:53
sal_Int32 m_nContent
Definition: fltshell.hxx:51
SwFltPosition(const SwPosition &rPos)
Definition: fltshell.hxx:66
void FromSwPosition(const SwPosition &rPos)
Definition: fltshell.hxx:72
SwNodeIndex m_nNode
Definition: fltshell.hxx:50
void SetPos(SwNodeIndex const &rNode, sal_uInt16 nIdx)
Definition: fltshell.hxx:58
Marks a position in the document model.
Definition: pam.hxx:37
SwNodeOffset GetNodeIndex() const
Definition: pam.hxx:77
sal_Int32 GetContentIndex() const
Definition: pam.hxx:84
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
bool operator==(const XclFontData &rLeft, const XclFontData &rRight)