Bump version to 21.06.18.1
[LibreOffice.git] / sw / inc / fmtfld.hxx
blob4c0b3c58b11ea24a3277184d485fd3193df597b9
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 .
20 #ifndef INCLUDED_SW_INC_FMTFLD_HXX
21 #define INCLUDED_SW_INC_FMTFLD_HXX
23 #include <cppuhelper/weakref.hxx>
24 #include <svl/poolitem.hxx>
25 #include <svl/SfxBroadcaster.hxx>
27 #include "swdllapi.h"
28 #include "calbck.hxx"
29 #include "ndindex.hxx"
30 #include "reffld.hxx"
32 class SwField;
33 class SwTextField;
34 class SwView;
35 class SwFieldType;
36 class SwDDETable;
37 class SwFormatField;
38 class IDocumentRedlineAccess;
39 namespace com::sun::star::text { class XTextField; }
41 namespace sw {
42 struct FindFormatForFieldHint final : SfxHint {
43 const SwField* m_pField;
44 SwFormatField*& m_rpFormat;
45 FindFormatForFieldHint(const SwField* pField, SwFormatField*& rpFormat) : m_pField(pField), m_rpFormat(rpFormat) {};
47 struct FindFormatForPostItIdHint final : SfxHint {
48 const sal_uInt32 m_nPostItId;
49 SwFormatField*& m_rpFormat;
50 FindFormatForPostItIdHint(const sal_uInt32 nPostItId, SwFormatField*& rpFormat) : m_nPostItId(nPostItId), m_rpFormat(rpFormat) {};
52 struct CollectPostItsHint final : SfxHint {
53 std::vector<SwFormatField*>& m_rvFormatFields;
54 IDocumentRedlineAccess const& m_rIDRA;
55 const bool m_bHideRedlines;
56 CollectPostItsHint(std::vector<SwFormatField*>& rvFormatFields, IDocumentRedlineAccess const& rIDRA, bool bHideRedlines) : m_rvFormatFields(rvFormatFields), m_rIDRA(rIDRA), m_bHideRedlines(bHideRedlines) {};
58 struct HasHiddenInformationNotesHint final : SfxHint {
59 bool& m_rbHasHiddenInformationNotes;
60 HasHiddenInformationNotesHint(bool& rbHasHiddenInformationNotes) : m_rbHasHiddenInformationNotes(rbHasHiddenInformationNotes) {};
62 struct GatherNodeIndexHint final : SfxHint {
63 std::vector<sal_uLong>& m_rvNodeIndex;
64 GatherNodeIndexHint(std::vector<sal_uLong>& rvNodeIndex) : m_rvNodeIndex(rvNodeIndex) {};
66 struct GatherRefFieldsHint final : SfxHint {
67 std::vector<SwGetRefField*>& m_rvRFields;
68 const sal_uInt16 m_nType;
69 GatherRefFieldsHint(std::vector<SwGetRefField*>& rvRFields, const sal_uInt16 nType) : m_rvRFields(rvRFields), m_nType(nType) {};
71 struct GatherFieldsHint final : SfxHint {
72 const bool m_bCollectOnlyInDocNodes;
73 std::vector<SwFormatField*>& m_rvFields;
74 GatherFieldsHint(std::vector<SwFormatField*>& rvFields, bool bCollectOnlyInDocNodes = true) : m_bCollectOnlyInDocNodes(bCollectOnlyInDocNodes), m_rvFields(rvFields) {};
76 struct GatherDdeTablesHint final : SfxHint {
77 std::vector<SwDDETable*>& m_rvTables;
78 GatherDdeTablesHint(std::vector<SwDDETable*>& rvTables) : m_rvTables(rvTables) {};
83 // ATT_FLD
84 class SW_DLLPUBLIC SwFormatField final
85 : public SfxPoolItem
86 , public sw::BroadcastingModify
87 , public SfxBroadcaster
89 friend void InitCore();
90 SwFormatField( sal_uInt16 nWhich ); // for default-Attribute
92 css::uno::WeakReference<css::text::XTextField> m_wXTextField;
94 std::unique_ptr<SwField> mpField;
95 SwTextField* mpTextField; // the TextAttribute
97 virtual void SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) override;
99 public:
101 /// Single argument constructors shall be explicit.
102 explicit SwFormatField( const SwField &rField );
104 SwFormatField( const SwFormatField& rAttr );
106 virtual ~SwFormatField() override;
108 /// "Pure virtual methods" of SfxPoolItem.
109 virtual bool operator==( const SfxPoolItem& ) const override;
110 virtual SwFormatField* Clone( SfxItemPool* pPool = nullptr ) const override;
112 virtual bool GetInfo( SfxPoolItem& rInfo ) const override;
114 void InvalidateField();
116 const SwField* GetField() const
118 return mpField.get();
120 SwField* GetField()
122 return mpField.get();
126 Sets current field.
128 @param pField new field
130 @attention The current field will be destroyed before setting the new field.
132 void SetField( std::unique_ptr<SwField> pField );
134 const SwTextField* GetTextField() const
136 return mpTextField;
138 SwTextField* GetTextField()
140 return mpTextField;
142 void SetTextField( SwTextField& rTextField );
143 void ClearTextField();
145 void RegisterToFieldType( SwFieldType& );
146 bool IsFieldInDoc() const;
147 bool IsProtect() const;
149 SAL_DLLPRIVATE css::uno::WeakReference<css::text::XTextField> const& GetXTextField() const
150 { return m_wXTextField; }
151 SAL_DLLPRIVATE void SetXTextField(css::uno::Reference<css::text::XTextField> const& xTextField)
152 { m_wXTextField = xTextField; }
153 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
155 void UpdateTextNode(const SfxPoolItem* pOld, const SfxPoolItem* pNew);
158 enum class SwFormatFieldHintWhich
160 INSERTED = 1,
161 REMOVED = 2,
162 FOCUS = 3,
163 CHANGED = 4,
164 LANGUAGE = 5,
165 RESOLVED = 6
168 class SW_DLLPUBLIC SwFormatFieldHint final : public SfxHint
170 const SwFormatField* m_pField;
171 SwFormatFieldHintWhich m_nWhich;
172 const SwView* m_pView;
174 public:
175 SwFormatFieldHint( const SwFormatField* pField, SwFormatFieldHintWhich nWhich, const SwView* pView = nullptr)
176 : m_pField(pField)
177 , m_nWhich(nWhich)
178 , m_pView(pView)
181 const SwFormatField* GetField() const { return m_pField; }
182 SwFormatFieldHintWhich Which() const { return m_nWhich; }
183 const SwView* GetView() const { return m_pView; }
186 #endif
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */