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 
23 #include <cppuhelper/weakref.hxx>
24 #include <svl/poolitem.hxx>
25 #include <svl/SfxBroadcaster.hxx>
26 
27 #include "swdllapi.h"
28 #include "calbck.hxx"
29 #include "reffld.hxx"
30 #include "nodeoffset.hxx"
31 
32 class SwField;
33 class SwTextField;
34 class SwView;
35 class SwFieldType;
36 class SwDDETable;
37 class SwFormatField;
39 namespace com::sun::star::text { class XTextField; }
40 
41 namespace sw {
43  const SwField* m_pField;
45  FindFormatForFieldHint(const SwField* pField, SwFormatField*& rpFormat) : m_pField(pField), m_rpFormat(rpFormat) {};
46  };
48  const sal_uInt32 m_nPostItId;
50  FindFormatForPostItIdHint(const sal_uInt32 nPostItId, SwFormatField*& rpFormat) : m_nPostItId(nPostItId), m_rpFormat(rpFormat) {};
51  };
52  struct CollectPostItsHint final : SfxHint {
53  std::vector<SwFormatField*>& m_rvFormatFields;
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) {};
57  };
60  HasHiddenInformationNotesHint(bool& rbHasHiddenInformationNotes) : m_rbHasHiddenInformationNotes(rbHasHiddenInformationNotes) {};
61  };
62  struct GatherNodeIndexHint final : SfxHint {
63  std::vector<SwNodeOffset>& m_rvNodeIndex;
64  GatherNodeIndexHint(std::vector<SwNodeOffset>& rvNodeIndex) : m_rvNodeIndex(rvNodeIndex) {};
65  };
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) {};
70  };
71  struct GatherFieldsHint final : SfxHint {
73  std::vector<SwFormatField*>& m_rvFields;
74  GatherFieldsHint(std::vector<SwFormatField*>& rvFields, bool bCollectOnlyInDocNodes = true) : m_bCollectOnlyInDocNodes(bCollectOnlyInDocNodes), m_rvFields(rvFields) {};
75  };
76  struct GatherDdeTablesHint final : SfxHint {
77  std::vector<SwDDETable*>& m_rvTables;
78  GatherDdeTablesHint(std::vector<SwDDETable*>& rvTables) : m_rvTables(rvTables) {};
79  };
80 }
81 
82 
83 // ATT_FLD
85  : public SfxPoolItem
86  , public sw::BroadcastingModify
87  , public SfxBroadcaster
88 {
89  friend void InitCore();
90  SwFormatField( sal_uInt16 nWhich ); // for default-Attribute
91 
92  css::uno::WeakReference<css::text::XTextField> m_wXTextField;
93 
94  std::unique_ptr<SwField> mpField;
95  SwTextField* mpTextField; // the TextAttribute
96 
97  virtual void SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) override;
98 
99 public:
100 
102  explicit SwFormatField( const SwField &rField );
103 
104  SwFormatField( const SwFormatField& rAttr );
105 
106  virtual ~SwFormatField() override;
107 
109  virtual bool operator==( const SfxPoolItem& ) const override;
110  virtual SwFormatField* Clone( SfxItemPool* pPool = nullptr ) const override;
111 
112  virtual bool GetInfo( SfxPoolItem& rInfo ) const override;
113 
114  void InvalidateField();
115 
116  const SwField* GetField() const
117  {
118  return mpField.get();
119  }
121  {
122  return mpField.get();
123  }
124 
132  void SetField( std::unique_ptr<SwField> pField );
133 
134  const SwTextField* GetTextField() const
135  {
136  return mpTextField;
137  }
139  {
140  return mpTextField;
141  }
142  void SetTextField( SwTextField& rTextField );
143  void ClearTextField();
144 
145  void RegisterToFieldType( SwFieldType& );
146  bool IsFieldInDoc() const;
147  bool IsProtect() const;
148 
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;
154 
155  void UpdateTextNode(const SfxPoolItem* pOld, const SfxPoolItem* pNew);
156 };
157 
159 {
160  INSERTED = 1,
161  REMOVED = 2,
162  FOCUS = 3,
163  CHANGED = 4,
164  LANGUAGE = 5,
165  RESOLVED = 6
166 };
167 
169 {
172  const SwView* m_pView;
173 
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)
179  {}
180 
181  const SwFormatField* GetField() const { return m_pField; }
182  SwFormatFieldHintWhich Which() const { return m_nWhich; }
183  const SwView* GetView() const { return m_pView; }
184 };
185 
186 #endif
187 
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:242
SwTextField * mpTextField
Definition: fmtfld.hxx:95
const SwField * GetField() const
Definition: fmtfld.hxx:116
virtual bool operator==(const SfxPoolItem &) const =0
SwFormatField *& m_rpFormat
Definition: fmtfld.hxx:44
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
Base class of all fields.
Definition: fldbas.hxx:292
SwFormatFieldHintWhich Which() const
Definition: fmtfld.hxx:182
FindFormatForFieldHint(const SwField *pField, SwFormatField *&rpFormat)
Definition: fmtfld.hxx:45
GatherRefFieldsHint(std::vector< SwGetRefField * > &rvRFields, const sal_uInt16 nType)
Definition: fmtfld.hxx:69
std::vector< SwFormatField * > & m_rvFormatFields
Definition: fmtfld.hxx:53
SwFormatFieldHintWhich m_nWhich
Definition: fmtfld.hxx:171
Dialog to specify the properties of date form field.
IDocumentRedlineAccess const & m_rIDRA
Definition: fmtfld.hxx:54
virtual bool GetInfo(SfxPoolItem &) const override
Definition: calbck.cxx:162
SwFormatFieldHint(const SwFormatField *pField, SwFormatFieldHintWhich nWhich, const SwView *pView=nullptr)
Definition: fmtfld.hxx:175
const SwTextField * GetTextField() const
Definition: fmtfld.hxx:134
const sal_uInt16 m_nType
Definition: fmtfld.hxx:68
std::vector< SwDDETable * > & m_rvTables
Definition: fmtfld.hxx:77
FindFormatForPostItIdHint(const sal_uInt32 nPostItId, SwFormatField *&rpFormat)
Definition: fmtfld.hxx:50
SAL_DLLPRIVATE void SetXTextField(css::uno::Reference< css::text::XTextField > const &xTextField)
Definition: fmtfld.hxx:151
GatherNodeIndexHint(std::vector< SwNodeOffset > &rvNodeIndex)
Definition: fmtfld.hxx:64
const sal_uInt32 m_nPostItId
Definition: fmtfld.hxx:48
const SwFormatField * GetField() const
Definition: fmtfld.hxx:181
const SwFormatField * m_pField
Definition: fmtfld.hxx:170
const SwView * GetView() const
Definition: fmtfld.hxx:183
std::unique_ptr< SwField > mpField
Definition: fmtfld.hxx:94
SwFormatField *& m_rpFormat
Definition: fmtfld.hxx:49
const bool m_bHideRedlines
Definition: fmtfld.hxx:55
const SwField * m_pField
Definition: fmtfld.hxx:43
SwFormatFieldHintWhich
Definition: fmtfld.hxx:158
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
SAL_DLLPRIVATE css::uno::WeakReference< css::text::XTextField > const & GetXTextField() const
Definition: fmtfld.hxx:149
HasHiddenInformationNotesHint(bool &rbHasHiddenInformationNotes)
Definition: fmtfld.hxx:60
void InitCore()
Definition: init.cxx:447
std::vector< SwGetRefField * > & m_rvRFields
Definition: fmtfld.hxx:67
std::vector< SwNodeOffset > & m_rvNodeIndex
Definition: fmtfld.hxx:63
SwTextField * GetTextField()
Definition: fmtfld.hxx:138
css::uno::WeakReference< css::text::XTextField > m_wXTextField
Definition: fmtfld.hxx:92
const bool m_bCollectOnlyInDocNodes
Definition: fmtfld.hxx:72
CollectPostItsHint(std::vector< SwFormatField * > &rvFormatFields, IDocumentRedlineAccess const &rIDRA, bool bHideRedlines)
Definition: fmtfld.hxx:56
struct _xmlTextWriter * xmlTextWriterPtr
GatherFieldsHint(std::vector< SwFormatField * > &rvFields, bool bCollectOnlyInDocNodes=true)
Definition: fmtfld.hxx:74
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: calbck.cxx:304
GatherDdeTablesHint(std::vector< SwDDETable * > &rvTables)
Definition: fmtfld.hxx:78
Definition: view.hxx:144
SwField * GetField()
Definition: fmtfld.hxx:120
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
std::vector< SwFormatField * > & m_rvFields
Definition: fmtfld.hxx:73
const SwView * m_pView
Definition: fmtfld.hxx:172