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