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 "swtypes.hxx"
31#include "calbck.hxx"
32#include "reffld.hxx"
33#include "nodeoffset.hxx"
34
35class SwField;
36class SwTextField;
37class SwView;
38class SwFieldType;
39class SwDDETable;
40class SwFormatField;
41class SwXTextField;
43
44namespace sw {
48 FindFormatForFieldHint(const SwField* pField, SwFormatField*& rpFormat)
49 : SfxHint(SfxHintId::SwFindFormatForField), m_pField(pField), m_rpFormat(rpFormat) {};
50 };
52 const sal_uInt32 m_nPostItId;
54 FindFormatForPostItIdHint(const sal_uInt32 nPostItId, SwFormatField*& rpFormat)
56 };
57 struct CollectPostItsHint final : SfxHint {
58 std::vector<SwFormatField*>& m_rvFormatFields;
60 const bool m_bHideRedlines;
61 CollectPostItsHint(std::vector<SwFormatField*>& rvFormatFields, IDocumentRedlineAccess const& rIDRA, bool bHideRedlines)
63 m_rvFormatFields(rvFormatFields), m_rIDRA(rIDRA), m_bHideRedlines(bHideRedlines) {};
64 };
67 HasHiddenInformationNotesHint(bool& rbHasHiddenInformationNotes)
69 m_rbHasHiddenInformationNotes(rbHasHiddenInformationNotes) {};
70 };
72 std::vector<SwNodeOffset>& m_rvNodeIndex;
73 GatherNodeIndexHint(std::vector<SwNodeOffset>& rvNodeIndex)
75 m_rvNodeIndex(rvNodeIndex) {};
76 };
78 std::vector<SwGetRefField*>& m_rvRFields;
79 const sal_uInt16 m_nType;
80 GatherRefFieldsHint(std::vector<SwGetRefField*>& rvRFields, const sal_uInt16 nType)
82 m_rvRFields(rvRFields), m_nType(nType) {};
83 };
84 struct GatherFieldsHint final : SfxHint {
86 std::vector<SwFormatField*>& m_rvFields;
87 GatherFieldsHint(std::vector<SwFormatField*>& rvFields, bool bCollectOnlyInDocNodes = true)
89 m_bCollectOnlyInDocNodes(bCollectOnlyInDocNodes), m_rvFields(rvFields) {};
90 };
92 std::vector<SwDDETable*>& m_rvTables;
93 GatherDdeTablesHint(std::vector<SwDDETable*>& rvTables) : m_rvTables(rvTables) {};
94 };
95}
96
97
98// ATT_FLD
100 : public SfxPoolItem
101 , public sw::BroadcastingModify
102 , public SfxBroadcaster
103{
104 friend void InitCore();
105 SwFormatField( sal_uInt16 nWhich ); // for default-Attribute
106
108
109 std::unique_ptr<SwField> mpField;
110 SwTextField* mpTextField; // the TextAttribute
111
112 virtual void SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) override;
113
114public:
115
117 explicit SwFormatField( const SwField &rField );
118
119 SwFormatField( const SwFormatField& rAttr );
120
121 virtual ~SwFormatField() override;
122
124 virtual bool operator==( const SfxPoolItem& ) const override;
125 virtual SwFormatField* Clone( SfxItemPool* pPool = nullptr ) const override;
126
127 virtual bool GetInfo( SfxPoolItem& rInfo ) const override;
128
129 void InvalidateField();
130
131 const SwField* GetField() const
132 {
133 return mpField.get();
134 }
136 {
137 return mpField.get();
138 }
139
147 void SetField( std::unique_ptr<SwField> pField );
148
150 {
151 return mpTextField;
152 }
154 {
155 return mpTextField;
156 }
157 void SetTextField( SwTextField& rTextField );
158 void ClearTextField();
159
160 void RegisterToFieldType( SwFieldType& );
161 bool IsFieldInDoc() const;
162 bool IsProtect() const;
163
165 { return m_wXTextField; }
166 SAL_DLLPRIVATE void SetXTextField(rtl::Reference<SwXTextField> const& xTextField);
167
168 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
169
170 void ForceUpdateTextNode();
171 void UpdateTextNode(const SfxHint& rHint);
172 void UpdateDocPos(const SwTwips nDocPos);
173};
174
176{
177 INSERTED = 1,
178 REMOVED = 2,
179 FOCUS = 3,
180 CHANGED = 4,
181 RESOLVED = 5
182};
183
185{
189
190public:
191 SwFormatFieldHint( const SwFormatField* pField, SwFormatFieldHintWhich nWhich, const SwView* pView = nullptr)
192 : m_pField(pField)
193 , m_nWhich(nWhich)
194 , m_pView(pView)
195 {}
196
197 const SwFormatField* GetField() const { return m_pField; }
199 const SwView* GetView() const { return m_pView; }
200};
201
202#endif
203
204/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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:247
Base class of all fields.
Definition: fldbas.hxx:296
const SwView * GetView() const
Definition: fmtfld.hxx:199
const SwView * m_pView
Definition: fmtfld.hxx:188
SwFormatFieldHintWhich Which() const
Definition: fmtfld.hxx:198
SwFormatFieldHintWhich m_nWhich
Definition: fmtfld.hxx:187
const SwFormatField * m_pField
Definition: fmtfld.hxx:186
const SwFormatField * GetField() const
Definition: fmtfld.hxx:197
SwFormatFieldHint(const SwFormatField *pField, SwFormatFieldHintWhich nWhich, const SwView *pView=nullptr)
Definition: fmtfld.hxx:191
const SwField * GetField() const
Definition: fmtfld.hxx:131
std::unique_ptr< SwField > mpField
Definition: fmtfld.hxx:109
unotools::WeakReference< SwXTextField > m_wXTextField
Definition: fmtfld.hxx:107
const SwTextField * GetTextField() const
Definition: fmtfld.hxx:149
SwField * GetField()
Definition: fmtfld.hxx:135
SwTextField * GetTextField()
Definition: fmtfld.hxx:153
SAL_DLLPRIVATE unotools::WeakReference< SwXTextField > const & GetXTextField() const
Definition: fmtfld.hxx:164
SwTextField * mpTextField
Definition: fmtfld.hxx:110
Definition: view.hxx:146
UNO wrapper around an SwFormatField, i.e.
Definition: unofield.hxx:120
struct _xmlTextWriter * xmlTextWriterPtr
SwFormatFieldHintWhich
Definition: fmtfld.hxx:176
SfxHintId
@ SwGatherRefFields
@ SwFindFormatForPostItId
@ SwFindFormatForField
@ SwHasHiddenInformationNotes
@ SwCollectPostIts
@ SwGatherNodeIndex
void InitCore()
Definition: init.cxx:459
Dialog to specify the properties of date form field.
QPRO_FUNC_TYPE nType
const bool m_bHideRedlines
Definition: fmtfld.hxx:60
CollectPostItsHint(std::vector< SwFormatField * > &rvFormatFields, IDocumentRedlineAccess const &rIDRA, bool bHideRedlines)
Definition: fmtfld.hxx:61
IDocumentRedlineAccess const & m_rIDRA
Definition: fmtfld.hxx:59
std::vector< SwFormatField * > & m_rvFormatFields
Definition: fmtfld.hxx:58
SwFormatField *& m_rpFormat
Definition: fmtfld.hxx:47
const SwField * m_pField
Definition: fmtfld.hxx:46
FindFormatForFieldHint(const SwField *pField, SwFormatField *&rpFormat)
Definition: fmtfld.hxx:48
SwFormatField *& m_rpFormat
Definition: fmtfld.hxx:53
FindFormatForPostItIdHint(const sal_uInt32 nPostItId, SwFormatField *&rpFormat)
Definition: fmtfld.hxx:54
const sal_uInt32 m_nPostItId
Definition: fmtfld.hxx:52
std::vector< SwDDETable * > & m_rvTables
Definition: fmtfld.hxx:92
GatherDdeTablesHint(std::vector< SwDDETable * > &rvTables)
Definition: fmtfld.hxx:93
GatherFieldsHint(std::vector< SwFormatField * > &rvFields, bool bCollectOnlyInDocNodes=true)
Definition: fmtfld.hxx:87
const bool m_bCollectOnlyInDocNodes
Definition: fmtfld.hxx:85
std::vector< SwFormatField * > & m_rvFields
Definition: fmtfld.hxx:86
GatherNodeIndexHint(std::vector< SwNodeOffset > &rvNodeIndex)
Definition: fmtfld.hxx:73
std::vector< SwNodeOffset > & m_rvNodeIndex
Definition: fmtfld.hxx:72
const sal_uInt16 m_nType
Definition: fmtfld.hxx:79
GatherRefFieldsHint(std::vector< SwGetRefField * > &rvRFields, const sal_uInt16 nType)
Definition: fmtfld.hxx:80
std::vector< SwGetRefField * > & m_rvRFields
Definition: fmtfld.hxx:78
HasHiddenInformationNotesHint(bool &rbHasHiddenInformationNotes)
Definition: fmtfld.hxx:67
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
tools::Long SwTwips
Definition: swtypes.hxx:51