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