1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
34 namespace com
{ namespace sun
{ namespace star
{ namespace text
{ class XTextField
; } } } }
37 class SW_DLLPUBLIC SwFormatField final
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
;
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
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
92 SwTextField
* GetTextField()
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
120 class SW_DLLPUBLIC SwFormatFieldHint final
: public SfxHint
122 const SwFormatField
* m_pField
;
123 SwFormatFieldHintWhich
const m_nWhich
;
124 const SwView
* m_pView
;
127 SwFormatFieldHint( const SwFormatField
* pField
, SwFormatFieldHintWhich nWhich
, const SwView
* pView
= nullptr)
133 const SwFormatField
* GetField() const { return m_pField
; }
134 SwFormatFieldHintWhich
Which() const { return m_nWhich
; }
135 const SwView
* GetView() const { return m_pView
; }
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */