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 
30 class SwField;
31 class SwTextField;
32 class SwView;
33 class SwFieldType;
34 namespace com { namespace sun { namespace star { namespace text { class XTextField; } } } }
35 
36 // ATT_FLD
38  : public SfxPoolItem
39  , public sw::BroadcastingModify
40  , public SfxBroadcaster
41 {
42  friend void InitCore();
43  SwFormatField( sal_uInt16 nWhich ); // for default-Attribute
44 
45  css::uno::WeakReference<css::text::XTextField> m_wXTextField;
46 
47  std::unique_ptr<SwField> mpField;
48  SwTextField* mpTextField; // the TextAttribute
49 
50 protected:
51  virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override;
52  virtual void SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) override;
53 
54 public:
55 
57  explicit SwFormatField( const SwField &rField );
58 
59  SwFormatField( const SwFormatField& rAttr );
60 
61  virtual ~SwFormatField() override;
62 
64  virtual bool operator==( const SfxPoolItem& ) const override;
65  virtual SfxPoolItem* Clone( SfxItemPool* pPool = nullptr ) const override;
66 
67  virtual bool GetInfo( SfxPoolItem& rInfo ) const override;
68 
69  void InvalidateField();
70 
71  const SwField* GetField() const
72  {
73  return mpField.get();
74  }
76  {
77  return mpField.get();
78  }
79 
87  void SetField( std::unique_ptr<SwField> pField );
88 
89  const SwTextField* GetTextField() const
90  {
91  return mpTextField;
92  }
94  {
95  return mpTextField;
96  }
97  void SetTextField( SwTextField& rTextField );
98  void ClearTextField();
99 
100  void RegisterToFieldType( SwFieldType& );
101  bool IsFieldInDoc() const;
102  bool IsProtect() const;
103 
104  SAL_DLLPRIVATE css::uno::WeakReference<css::text::XTextField> const& GetXTextField() const
105  { return m_wXTextField; }
106  SAL_DLLPRIVATE void SetXTextField(css::uno::Reference<css::text::XTextField> const& xTextField)
107  { m_wXTextField = xTextField; }
108  void dumpAsXml(xmlTextWriterPtr pWriter) const override;
109 };
110 
112 {
113  INSERTED = 1,
114  REMOVED = 2,
115  FOCUS = 3,
116  CHANGED = 4,
117  LANGUAGE = 5,
118  RESOLVED = 6
119 };
120 
122 {
125  const SwView* m_pView;
126 
127 public:
128  SwFormatFieldHint( const SwFormatField* pField, SwFormatFieldHintWhich nWhich, const SwView* pView = nullptr)
129  : m_pField(pField)
130  , m_nWhich(nWhich)
131  , m_pView(pView)
132  {}
133 
134  const SwFormatField* GetField() const { return m_pField; }
135  SwFormatFieldHintWhich Which() const { return m_nWhich; }
136  const SwView* GetView() const { return m_pView; }
137 };
138 
139 #endif
140 
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:234
SwTextField * mpTextField
Definition: fmtfld.hxx:48
const SwField * GetField() const
Definition: fmtfld.hxx:71
virtual bool operator==(const SfxPoolItem &) const =0
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
Base class of all fields.
Definition: fldbas.hxx:280
SwFormatFieldHintWhich Which() const
Definition: fmtfld.hxx:135
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: calbck.cxx:108
virtual bool GetInfo(SfxPoolItem &) const override
Definition: calbck.cxx:206
SwFormatFieldHint(const SwFormatField *pField, SwFormatFieldHintWhich nWhich, const SwView *pView=nullptr)
Definition: fmtfld.hxx:128
const SwTextField * GetTextField() const
Definition: fmtfld.hxx:89
SAL_DLLPRIVATE void SetXTextField(css::uno::Reference< css::text::XTextField > const &xTextField)
Definition: fmtfld.hxx:106
struct _xmlTextWriter * xmlTextWriterPtr
const SwFormatField * GetField() const
Definition: fmtfld.hxx:134
const SwFormatField * m_pField
Definition: fmtfld.hxx:123
const SwView * GetView() const
Definition: fmtfld.hxx:136
std::unique_ptr< SwField > mpField
Definition: fmtfld.hxx:47
SwFormatFieldHintWhich
Definition: fmtfld.hxx:111
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override
Definition: calbck.hxx:183
SAL_DLLPRIVATE css::uno::WeakReference< css::text::XTextField > const & GetXTextField() const
Definition: fmtfld.hxx:104
void InitCore()
Definition: init.cxx:455
SwTextField * GetTextField()
Definition: fmtfld.hxx:93
css::uno::WeakReference< css::text::XTextField > m_wXTextField
Definition: fmtfld.hxx:45
def text(shape, st)
SwFormatFieldHintWhich const m_nWhich
Definition: fmtfld.hxx:124
Definition: view.hxx:146
SwField * GetField()
Definition: fmtfld.hxx:75
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
const SwView * m_pView
Definition: fmtfld.hxx:125