android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / filter / inc / fltshell.hxx
blob12ec446bf081a4dbde853976218375bd75e1d79f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_SOURCE_FILTER_INC_FLTSHELL_HXX
20 #define INCLUDED_SW_SOURCE_FILTER_INC_FLTSHELL_HXX
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>
31 #include <cstddef>
32 #include <memory>
34 class SwTOXBase;
35 class SwField;
36 class SwFieldType;
37 class Graphic;
38 class SwTableBox;
39 class SwDoc;
40 class SwPaM;
42 inline bool SwFltGetFlag(sal_uLong nFieldFlags, int no)
43 { return (nFieldFlags & (sal_uLong(1) << no)) != 0; }
45 //Subvert the Node/Content system to get positions which don't update as
46 //content is appended to them
47 struct SW_DLLPUBLIC SwFltPosition
49 public:
50 SwNodeIndex m_nNode;
51 sal_Int32 m_nContent;
52 public:
53 bool operator==(const SwFltPosition &rOther) const
55 return (m_nContent == rOther.m_nContent &&
56 m_nNode == rOther.m_nNode);
58 void SetPos(SwNodeIndex const &rNode, sal_uInt16 nIdx)
60 m_nNode = rNode;
61 m_nContent = nIdx;
64 //operators with SwPosition, where the node is hacked to the previous one,
65 //and the offset to content is de-dynamic-ified
66 SwFltPosition(const SwPosition &rPos)
67 : m_nNode(rPos.GetNode(), -1)
68 , m_nContent(rPos.GetContentIndex())
72 void FromSwPosition(const SwPosition &rPos)
74 m_nNode = rPos.GetNodeIndex()-1;
75 m_nContent = rPos.GetContentIndex();
79 // Stack entry for the attributes. It is always pointers to new attributes that are passed.
80 class SwFltStackEntry
82 private:
83 SwFltStackEntry(SwFltStackEntry const&) = delete;
84 SwFltStackEntry& operator=(SwFltStackEntry const&) = delete;
86 public:
87 SwFltPosition m_aMkPos;
88 SwFltPosition m_aPtPos;
90 std::unique_ptr<SfxPoolItem> m_pAttr;// Format Attribute
92 bool m_bOld; // to mark Attributes *before* skipping field results
93 bool m_bOpen; //Entry open, awaiting being closed
94 bool m_bConsumedByField;
95 bool m_isAnnotationOnEnd; ///< annotation already moved onto its end pos.
97 SW_DLLPUBLIC SwFltStackEntry(const SwPosition & rStartPos, std::unique_ptr<SfxPoolItem> pHt );
98 SW_DLLPUBLIC ~SwFltStackEntry();
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);
108 template<> struct o3tl::typed_flags<SwFltStackEntry::RegionMode>: o3tl::is_typed_flags<SwFltStackEntry::RegionMode, 0x03> {};
110 class SW_DLLPUBLIC SwFltControlStack
112 private:
113 SwFltControlStack(SwFltControlStack const&) = delete;
114 SwFltControlStack& operator=(SwFltControlStack const&) = delete;
116 typedef std::vector<std::unique_ptr<SwFltStackEntry>> Entries;
117 Entries m_Entries;
119 sal_uLong m_nFieldFlags;
121 protected:
122 SwDoc& m_rDoc;
123 bool m_bIsEndStack;
125 virtual void SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry& rEntry);
127 public:
128 enum class MoveAttrsMode { DEFAULT, POSTIT_INSERTED };
129 void MoveAttrs(const SwPosition& rPos, MoveAttrsMode = MoveAttrsMode::DEFAULT);
130 enum Flags
132 HYPO,
133 TAGS_DO_ID,
134 TAGS_VISIBLE,
135 BOOK_TO_VAR_REF,
136 BOOK_AND_REF,
137 TAGS_IN_TEXT,
138 ALLOW_FLD_CR
141 SwFltControlStack(SwDoc& rDo, sal_uLong nFieldFl);
142 virtual ~SwFltControlStack();
144 bool IsFlagSet(Flags no) const { return ::SwFltGetFlag(m_nFieldFlags, no);}
146 void NewAttr(const SwPosition& rPos, const SfxPoolItem & rAttr );
148 virtual SwFltStackEntry* SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId, bool bTstEnd=true, tools::Long nHand = LONG_MAX, bool consumedByField=false);
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);
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);
164 class SwFltAnchorListener;
166 class SW_DLLPUBLIC SwFltAnchor final : public SfxPoolItem
168 SwFrameFormat* m_pFrameFormat;
169 std::unique_ptr<SwFltAnchorListener> m_pListener;
171 public:
172 SwFltAnchor(SwFrameFormat* pFlyFormat);
173 SwFltAnchor(const SwFltAnchor&);
174 virtual ~SwFltAnchor() override;
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; }
184 /// Used by SwFltAnchor, to listen to an SwFrameFormat (to be aware when it is replaced or deleted).
185 class SwFltAnchorListener final : public SvtListener
187 SwFltAnchor* m_pFltAnchor;
188 public:
189 SwFltAnchorListener(SwFltAnchor* pFltAnchor);
190 virtual void Notify(const SfxHint&) override;
193 class SW_DLLPUBLIC SwFltRedline final : public SfxPoolItem
195 public:
196 DateTime m_aStamp;
197 RedlineType m_eType;
198 std::size_t m_nAutorNo;
200 SwFltRedline(RedlineType eType_,
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_)
209 // "purely virtual methods" of SfxPoolItem
210 virtual bool operator==(const SfxPoolItem& rItem) const override;
211 virtual SwFltRedline* Clone(SfxItemPool* = nullptr) const override;
214 class SW_DLLPUBLIC SwFltBookmark final : public SfxPoolItem
216 private:
218 tools::Long mnHandle;
219 OUString maName;
220 OUString maVal;
221 bool mbIsTOCBookmark;
223 public:
224 SwFltBookmark( const OUString& rNa,
225 OUString aVa,
226 tools::Long nHand,
227 const bool bIsTOCBookmark = false );
229 // "purely virtual methods" of SfxPoolItem
230 virtual bool operator==(const SfxPoolItem&) const override;
231 virtual SwFltBookmark* Clone(SfxItemPool* = nullptr) const override;
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
238 return mbIsTOCBookmark;
242 /// Stores RDF statements on a paragraph (key-value pairs where the subject is the paragraph).
243 class SW_DLLPUBLIC SwFltRDFMark final : public SfxPoolItem
245 tools::Long m_nHandle;
246 std::vector< std::pair<OUString, OUString> > m_aAttributes;
248 public:
249 SwFltRDFMark();
251 virtual bool operator==(const SfxPoolItem&) const override;
252 virtual SwFltRDFMark* Clone(SfxItemPool* = nullptr) const override;
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;
260 class SW_DLLPUBLIC SwFltTOX final : public SfxPoolItem
262 std::shared_ptr<SwTOXBase> m_xTOXBase;
263 bool m_bHadBreakItem; // there was a break item BEFORE insertion of the TOX
264 bool m_bHadPageDescItem;
265 public:
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; }
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.).
280 class SwFltEndStack : public SwFltControlStack
282 public:
283 SwFltEndStack(SwDoc& rDo, sal_uLong nFieldFl)
284 :SwFltControlStack(rDo, nFieldFl)
286 m_bIsEndStack = true;
290 SW_DLLPUBLIC void UpdatePageDescs(SwDoc &rDoc, size_t nInPageDescOffset);
292 class ImportProgress
294 private:
295 SwDocShell *m_pDocShell;
296 public:
297 ImportProgress(SwDocShell *pDocShell, tools::Long nStartVal, tools::Long nEndVal)
298 : m_pDocShell(pDocShell)
300 ::StartProgress(STR_STATSTR_W4WREAD, nStartVal, nEndVal, m_pDocShell);
303 void Update(sal_uInt16 nProgress)
305 ::SetProgressState(nProgress, m_pDocShell); // Update
308 ~ImportProgress()
310 ::EndProgress(m_pDocShell);
314 // detect if the SwFrameFormat it is watching was deleted
315 class SW_DLLPUBLIC FrameDeleteWatch final: public SvtListener
317 SwFrameFormat* m_pFormat;
318 public:
319 FrameDeleteWatch(SwFrameFormat* pFormat);
321 virtual void Notify(const SfxHint& rHint) override;
323 SwFrameFormat* GetFormat()
325 return m_pFormat;
328 bool WasDeleted() const
330 return !m_pFormat;
333 virtual ~FrameDeleteWatch() override;
336 #endif
338 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */