LibreOffice Module sw (master) 1
fmtfld.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
20#ifndef INCLUDED_SW_INC_FMTFLD_HXX
21#define INCLUDED_SW_INC_FMTFLD_HXX
22
24#include <svl/poolitem.hxx>
26#include <com/sun/star/text/XTextField.hpp>
27#include <unotools/weakref.hxx>
28
29#include "swdllapi.h"
30#include "calbck.hxx"
31#include "reffld.hxx"
32#include "nodeoffset.hxx"
33
34class SwField;
35class SwTextField;
36class SwView;
37class SwFieldType;
38class SwDDETable;
39class SwFormatField;
40class SwXTextField;
42
43namespace sw {
47 FindFormatForFieldHint(const SwField* pField, SwFormatField*& rpFormat)
48 : SfxHint(SfxHintId::SwFindFormatForField), m_pField(pField), m_rpFormat(rpFormat) {};
49 };
51 const sal_uInt32 m_nPostItId;
53 FindFormatForPostItIdHint(const sal_uInt32 nPostItId, SwFormatField*& rpFormat)
55 };
56 struct CollectPostItsHint final : SfxHint {
57 std::vector<SwFormatField*>& m_rvFormatFields;
59 const bool m_bHideRedlines;
60 CollectPostItsHint(std::vector<SwFormatField*>& rvFormatFields, IDocumentRedlineAccess const& rIDRA, bool bHideRedlines)
62 m_rvFormatFields(rvFormatFields), m_rIDRA(rIDRA), m_bHideRedlines(bHideRedlines) {};
63 };
66 HasHiddenInformationNotesHint(bool& rbHasHiddenInformationNotes)
68 m_rbHasHiddenInformationNotes(rbHasHiddenInformationNotes) {};
69 };
71 std::vector<SwNodeOffset>& m_rvNodeIndex;
72 GatherNodeIndexHint(std::vector<SwNodeOffset>& rvNodeIndex)
74 m_rvNodeIndex(rvNodeIndex) {};
75 };
77 std::vector<SwGetRefField*>& m_rvRFields;
78 const sal_uInt16 m_nType;
79 GatherRefFieldsHint(std::vector<SwGetRefField*>& rvRFields, const sal_uInt16 nType)
81 m_rvRFields(rvRFields), m_nType(nType) {};
82 };
83 struct GatherFieldsHint final : SfxHint {
85 std::vector<SwFormatField*>& m_rvFields;
86 GatherFieldsHint(std::vector<SwFormatField*>& rvFields, bool bCollectOnlyInDocNodes = true)
88 m_bCollectOnlyInDocNodes(bCollectOnlyInDocNodes), m_rvFields(rvFields) {};
89 };
91 std::vector<SwDDETable*>& m_rvTables;
92 GatherDdeTablesHint(std::vector<SwDDETable*>& rvTables) : m_rvTables(rvTables) {};
93 };
94}
95
96
97// ATT_FLD
99 : public SfxPoolItem
101 , public SfxBroadcaster
102{
103 friend void InitCore();
104 SwFormatField( sal_uInt16 nWhich ); // for default-Attribute
105
107
108 std::unique_ptr<SwField> mpField;
109 SwTextField* mpTextField; // the TextAttribute
110
111 virtual void SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) override;
112
113public:
114
116 explicit SwFormatField( const SwField &rField );
117
118 SwFormatField( const SwFormatField& rAttr );
119
120 virtual ~SwFormatField() override;
121
123 virtual bool operator==( const SfxPoolItem& ) const override;
124 virtual SwFormatField* Clone( SfxItemPool* pPool = nullptr ) const override;
125
126 virtual bool GetInfo( SfxPoolItem& rInfo ) const override;
127
128 void InvalidateField();
129
130 const SwField* GetField() const
131 {
132 return mpField.get();
133 }
135 {
136 return mpField.get();
137 }
138
146 void SetField( std::unique_ptr<SwField> pField );
147
149 {
150 return mpTextField;
151 }
153 {
154 return mpTextField;
155 }
156 void SetTextField( SwTextField& rTextField );
157 void ClearTextField();
158
159 void RegisterToFieldType( SwFieldType& );
160 bool IsFieldInDoc() const;
161 bool IsProtect() const;
162
164 { return m_wXTextField; }
165 SAL_DLLPRIVATE void SetXTextField(rtl::Reference<SwXTextField> const& xTextField);
166
167 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
168
169 void UpdateTextNode(const SfxPoolItem* pOld, const SfxPoolItem* pNew);
170};
171
173{
174 INSERTED = 1,
175 REMOVED = 2,
176 FOCUS = 3,
177 CHANGED = 4,
178 LANGUAGE = 5,
179 RESOLVED = 6
180};
181
183{
187
188public:
189 SwFormatFieldHint( const SwFormatField* pField, SwFormatFieldHintWhich nWhich, const SwView* pView = nullptr)
190 : m_pField(pField)
191 , m_nWhich(nWhich)
192 , m_pView(pView)
193 {}
194
195 const SwFormatField* GetField() const { return m_pField; }
197 const SwView* GetView() const { return m_pView; }
198};
199
200#endif
201
202/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _xmlTextWriter * xmlTextWriterPtr
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
virtual bool operator==(const SfxPoolItem &) const=0
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
sal_uInt16 m_nWhich
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
const SwView * GetView() const
Definition: fmtfld.hxx:197
const SwView * m_pView
Definition: fmtfld.hxx:186
SwFormatFieldHintWhich Which() const
Definition: fmtfld.hxx:196
SwFormatFieldHintWhich m_nWhich
Definition: fmtfld.hxx:185
const SwFormatField * m_pField
Definition: fmtfld.hxx:184
const SwFormatField * GetField() const
Definition: fmtfld.hxx:195
SwFormatFieldHint(const SwFormatField *pField, SwFormatFieldHintWhich nWhich, const SwView *pView=nullptr)
Definition: fmtfld.hxx:189
const SwField * GetField() const
Definition: fmtfld.hxx:130
std::unique_ptr< SwField > mpField
Definition: fmtfld.hxx:108
unotools::WeakReference< SwXTextField > m_wXTextField
Definition: fmtfld.hxx:106
const SwTextField * GetTextField() const
Definition: fmtfld.hxx:148
SwField * GetField()
Definition: fmtfld.hxx:134
SwTextField * GetTextField()
Definition: fmtfld.hxx:152
SAL_DLLPRIVATE unotools::WeakReference< SwXTextField > const & GetXTextField() const
Definition: fmtfld.hxx:163
SwTextField * mpTextField
Definition: fmtfld.hxx:109
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: calbck.cxx:303
virtual bool GetInfo(SfxPoolItem &) const override
Definition: calbck.cxx:161
Definition: view.hxx:146
UNO wrapper around an SwFormatField, i.e.
Definition: unofield.hxx:129
SwFormatFieldHintWhich
Definition: fmtfld.hxx:173
SfxHintId
@ SwGatherRefFields
@ SwFindFormatForPostItId
@ SwFindFormatForField
@ SwHasHiddenInformationNotes
@ SwCollectPostIts
@ SwGatherNodeIndex
void InitCore()
Definition: init.cxx:449
Dialog to specify the properties of date form field.
QPRO_FUNC_TYPE nType
const bool m_bHideRedlines
Definition: fmtfld.hxx:59
CollectPostItsHint(std::vector< SwFormatField * > &rvFormatFields, IDocumentRedlineAccess const &rIDRA, bool bHideRedlines)
Definition: fmtfld.hxx:60
IDocumentRedlineAccess const & m_rIDRA
Definition: fmtfld.hxx:58
std::vector< SwFormatField * > & m_rvFormatFields
Definition: fmtfld.hxx:57
SwFormatField *& m_rpFormat
Definition: fmtfld.hxx:46
const SwField * m_pField
Definition: fmtfld.hxx:45
FindFormatForFieldHint(const SwField *pField, SwFormatField *&rpFormat)
Definition: fmtfld.hxx:47
SwFormatField *& m_rpFormat
Definition: fmtfld.hxx:52
FindFormatForPostItIdHint(const sal_uInt32 nPostItId, SwFormatField *&rpFormat)
Definition: fmtfld.hxx:53
const sal_uInt32 m_nPostItId
Definition: fmtfld.hxx:51
std::vector< SwDDETable * > & m_rvTables
Definition: fmtfld.hxx:91
GatherDdeTablesHint(std::vector< SwDDETable * > &rvTables)
Definition: fmtfld.hxx:92
GatherFieldsHint(std::vector< SwFormatField * > &rvFields, bool bCollectOnlyInDocNodes=true)
Definition: fmtfld.hxx:86
const bool m_bCollectOnlyInDocNodes
Definition: fmtfld.hxx:84
std::vector< SwFormatField * > & m_rvFields
Definition: fmtfld.hxx:85
GatherNodeIndexHint(std::vector< SwNodeOffset > &rvNodeIndex)
Definition: fmtfld.hxx:72
std::vector< SwNodeOffset > & m_rvNodeIndex
Definition: fmtfld.hxx:71
const sal_uInt16 m_nType
Definition: fmtfld.hxx:78
GatherRefFieldsHint(std::vector< SwGetRefField * > &rvRFields, const sal_uInt16 nType)
Definition: fmtfld.hxx:79
std::vector< SwGetRefField * > & m_rvRFields
Definition: fmtfld.hxx:77
HasHiddenInformationNotesHint(bool &rbHasHiddenInformationNotes)
Definition: fmtfld.hxx:66
#define SW_DLLPUBLIC
Definition: swdllapi.h:28