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>
29 #include "ndindex.hxx"
38 class IDocumentRedlineAccess
;
39 namespace com::sun::star::text
{ class XTextField
; }
42 struct FindFormatForFieldHint final
: SfxHint
{
43 const SwField
* m_pField
;
44 SwFormatField
*& m_rpFormat
;
45 FindFormatForFieldHint(const SwField
* pField
, SwFormatField
*& rpFormat
) : m_pField(pField
), m_rpFormat(rpFormat
) {};
47 struct FindFormatForPostItIdHint final
: SfxHint
{
48 const sal_uInt32 m_nPostItId
;
49 SwFormatField
*& m_rpFormat
;
50 FindFormatForPostItIdHint(const sal_uInt32 nPostItId
, SwFormatField
*& rpFormat
) : m_nPostItId(nPostItId
), m_rpFormat(rpFormat
) {};
52 struct CollectPostItsHint final
: SfxHint
{
53 std::vector
<SwFormatField
*>& m_rvFormatFields
;
54 IDocumentRedlineAccess
const& m_rIDRA
;
55 const bool m_bHideRedlines
;
56 CollectPostItsHint(std::vector
<SwFormatField
*>& rvFormatFields
, IDocumentRedlineAccess
const& rIDRA
, bool bHideRedlines
) : m_rvFormatFields(rvFormatFields
), m_rIDRA(rIDRA
), m_bHideRedlines(bHideRedlines
) {};
58 struct HasHiddenInformationNotesHint final
: SfxHint
{
59 bool& m_rbHasHiddenInformationNotes
;
60 HasHiddenInformationNotesHint(bool& rbHasHiddenInformationNotes
) : m_rbHasHiddenInformationNotes(rbHasHiddenInformationNotes
) {};
62 struct GatherNodeIndexHint final
: SfxHint
{
63 std::vector
<sal_uLong
>& m_rvNodeIndex
;
64 GatherNodeIndexHint(std::vector
<sal_uLong
>& rvNodeIndex
) : m_rvNodeIndex(rvNodeIndex
) {};
66 struct GatherRefFieldsHint final
: SfxHint
{
67 std::vector
<SwGetRefField
*>& m_rvRFields
;
68 const sal_uInt16 m_nType
;
69 GatherRefFieldsHint(std::vector
<SwGetRefField
*>& rvRFields
, const sal_uInt16 nType
) : m_rvRFields(rvRFields
), m_nType(nType
) {};
71 struct GatherFieldsHint final
: SfxHint
{
72 const bool m_bCollectOnlyInDocNodes
;
73 std::vector
<SwFormatField
*>& m_rvFields
;
74 GatherFieldsHint(std::vector
<SwFormatField
*>& rvFields
, bool bCollectOnlyInDocNodes
= true) : m_bCollectOnlyInDocNodes(bCollectOnlyInDocNodes
), m_rvFields(rvFields
) {};
76 struct GatherDdeTablesHint final
: SfxHint
{
77 std::vector
<SwDDETable
*>& m_rvTables
;
78 GatherDdeTablesHint(std::vector
<SwDDETable
*>& rvTables
) : m_rvTables(rvTables
) {};
84 class SW_DLLPUBLIC SwFormatField final
86 , public sw::BroadcastingModify
87 , public SfxBroadcaster
89 friend void InitCore();
90 SwFormatField( sal_uInt16 nWhich
); // for default-Attribute
92 css::uno::WeakReference
<css::text::XTextField
> m_wXTextField
;
94 std::unique_ptr
<SwField
> mpField
;
95 SwTextField
* mpTextField
; // the TextAttribute
97 virtual void SwClientNotify( const SwModify
& rModify
, const SfxHint
& rHint
) override
;
101 /// Single argument constructors shall be explicit.
102 explicit SwFormatField( const SwField
&rField
);
104 SwFormatField( const SwFormatField
& rAttr
);
106 virtual ~SwFormatField() override
;
108 /// "Pure virtual methods" of SfxPoolItem.
109 virtual bool operator==( const SfxPoolItem
& ) const override
;
110 virtual SwFormatField
* Clone( SfxItemPool
* pPool
= nullptr ) const override
;
112 virtual bool GetInfo( SfxPoolItem
& rInfo
) const override
;
114 void InvalidateField();
116 const SwField
* GetField() const
118 return mpField
.get();
122 return mpField
.get();
128 @param pField new field
130 @attention The current field will be destroyed before setting the new field.
132 void SetField( std::unique_ptr
<SwField
> pField
);
134 const SwTextField
* GetTextField() const
138 SwTextField
* GetTextField()
142 void SetTextField( SwTextField
& rTextField
);
143 void ClearTextField();
145 void RegisterToFieldType( SwFieldType
& );
146 bool IsFieldInDoc() const;
147 bool IsProtect() const;
149 SAL_DLLPRIVATE
css::uno::WeakReference
<css::text::XTextField
> const& GetXTextField() const
150 { return m_wXTextField
; }
151 SAL_DLLPRIVATE
void SetXTextField(css::uno::Reference
<css::text::XTextField
> const& xTextField
)
152 { m_wXTextField
= xTextField
; }
153 void dumpAsXml(xmlTextWriterPtr pWriter
) const override
;
155 void UpdateTextNode(const SfxPoolItem
* pOld
, const SfxPoolItem
* pNew
);
158 enum class SwFormatFieldHintWhich
168 class SW_DLLPUBLIC SwFormatFieldHint final
: public SfxHint
170 const SwFormatField
* m_pField
;
171 SwFormatFieldHintWhich m_nWhich
;
172 const SwView
* m_pView
;
175 SwFormatFieldHint( const SwFormatField
* pField
, SwFormatFieldHintWhich nWhich
, const SwView
* pView
= nullptr)
181 const SwFormatField
* GetField() const { return m_pField
; }
182 SwFormatFieldHintWhich
Which() const { return m_nWhich
; }
183 const SwView
* GetView() const { return m_pView
; }
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */