lok: Hide file linking in section
[LibreOffice.git] / sw / inc / fmtfld.hxx
blob34c7d73aab5d346df38a5b7143368ad94e704b3e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SW_INC_FMTFLD_HXX
21 #define INCLUDED_SW_INC_FMTFLD_HXX
23 #include <cppuhelper/weakref.hxx>
24 #include <svl/poolitem.hxx>
25 #include <svl/SfxBroadcaster.hxx>
27 #include "swdllapi.h"
28 #include "calbck.hxx"
30 class SwField;
31 class SwTextField;
32 class SwView;
33 class SwFieldType;
34 namespace com { namespace sun { namespace star { namespace text { class XTextField; } } } }
36 // ATT_FLD
37 class SW_DLLPUBLIC SwFormatField final
38 : public SfxPoolItem
39 , public sw::BroadcastingModify
40 , public SfxBroadcaster
42 friend void InitCore();
43 SwFormatField( sal_uInt16 nWhich ); // for default-Attribute
45 css::uno::WeakReference<css::text::XTextField> m_wXTextField;
47 std::unique_ptr<SwField> mpField;
48 SwTextField* mpTextField; // the TextAttribute
50 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override;
51 virtual void SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) override;
53 public:
55 /// Single argument constructors shall be explicit.
56 explicit SwFormatField( const SwField &rField );
58 SwFormatField( const SwFormatField& rAttr );
60 virtual ~SwFormatField() override;
62 /// "Pure virtual methods" of SfxPoolItem.
63 virtual bool operator==( const SfxPoolItem& ) const override;
64 virtual SfxPoolItem* Clone( SfxItemPool* pPool = nullptr ) const override;
66 virtual bool GetInfo( SfxPoolItem& rInfo ) const override;
68 void InvalidateField();
70 const SwField* GetField() const
72 return mpField.get();
74 SwField* GetField()
76 return mpField.get();
79 /**
80 Sets current field.
82 @param pField new field
84 @attention The current field will be destroyed before setting the new field.
86 void SetField( std::unique_ptr<SwField> pField );
88 const SwTextField* GetTextField() const
90 return mpTextField;
92 SwTextField* GetTextField()
94 return mpTextField;
96 void SetTextField( SwTextField& rTextField );
97 void ClearTextField();
99 void RegisterToFieldType( SwFieldType& );
100 bool IsFieldInDoc() const;
101 bool IsProtect() const;
103 SAL_DLLPRIVATE css::uno::WeakReference<css::text::XTextField> const& GetXTextField() const
104 { return m_wXTextField; }
105 SAL_DLLPRIVATE void SetXTextField(css::uno::Reference<css::text::XTextField> const& xTextField)
106 { m_wXTextField = xTextField; }
107 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
110 enum class SwFormatFieldHintWhich
112 INSERTED = 1,
113 REMOVED = 2,
114 FOCUS = 3,
115 CHANGED = 4,
116 LANGUAGE = 5,
117 RESOLVED = 6
120 class SW_DLLPUBLIC SwFormatFieldHint final : public SfxHint
122 const SwFormatField* m_pField;
123 SwFormatFieldHintWhich const m_nWhich;
124 const SwView* m_pView;
126 public:
127 SwFormatFieldHint( const SwFormatField* pField, SwFormatFieldHintWhich nWhich, const SwView* pView = nullptr)
128 : m_pField(pField)
129 , m_nWhich(nWhich)
130 , m_pView(pView)
133 const SwFormatField* GetField() const { return m_pField; }
134 SwFormatFieldHintWhich Which() const { return m_nWhich; }
135 const SwView* GetView() const { return m_pView; }
138 #endif
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */