Branch libreoffice-5-0-4
[LibreOffice.git] / sw / inc / fmtfld.hxx
blob0d4f86bf58f1ac376a0155e30c4f29316e77fa41
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 <com/sun/star/text/XTextField.hpp>
25 #include <cppuhelper/weakref.hxx>
26 #include <svl/poolitem.hxx>
27 #include <svl/SfxBroadcaster.hxx>
28 #include <svl/smplhint.hxx>
30 #include "swdllapi.h"
31 #include <calbck.hxx>
33 class SwField;
34 class SwTextField;
35 class SwView;
36 class SwFieldType;
38 // ATT_FLD
39 class SW_DLLPUBLIC SwFormatField
40 : public SfxPoolItem
41 , public SwModify
42 , public SfxBroadcaster
44 friend void _InitCore();
45 SwFormatField( sal_uInt16 nWhich ); // for default-Attibute
47 ::com::sun::star::uno::WeakReference<
48 ::com::sun::star::text::XTextField> m_wXTextField;
50 SwField* mpField;
51 SwTextField* mpTextField; // the TextAttribute
53 // @@@ copy construction allowed, but copy assignment is not? @@@
54 SwFormatField& operator=(const SwFormatField& rField) SAL_DELETED_FUNCTION;
56 protected:
57 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
58 virtual void SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) SAL_OVERRIDE;
60 public:
61 TYPEINFO_OVERRIDE();
63 /// Single argument constructors shall be explicit.
64 explicit SwFormatField( const SwField &rField );
66 /// @@@ copy construction allowed, but copy assignment is not? @@@
67 SwFormatField( const SwFormatField& rAttr );
69 virtual ~SwFormatField();
71 /// "Pure virtual methods" of SfxPoolItem.
72 virtual bool operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
73 virtual SfxPoolItem* Clone( SfxItemPool* pPool = 0 ) const SAL_OVERRIDE;
75 virtual bool GetInfo( SfxPoolItem& rInfo ) const SAL_OVERRIDE;
77 void InvalidateField();
79 const SwField* GetField() const
81 return mpField;
83 SwField* GetField()
85 return mpField;
88 /**
89 Sets current field.
91 @param pField new field
93 @attention The current field will be destroyed before setting the new field.
95 void SetField( SwField * pField );
97 const SwTextField* GetTextField() const
99 return mpTextField;
101 SwTextField* GetTextField()
103 return mpTextField;
105 void SetTextField( SwTextField& rTextField );
106 void ClearTextField();
108 void RegisterToFieldType( SwFieldType& );
109 bool IsFieldInDoc() const;
110 bool IsProtect() const;
112 SAL_DLLPRIVATE ::com::sun::star::uno::WeakReference<
113 ::com::sun::star::text::XTextField> const& GetXTextField() const
114 { return m_wXTextField; }
115 SAL_DLLPRIVATE void SetXTextField(::com::sun::star::uno::Reference<
116 ::com::sun::star::text::XTextField> const& xTextField)
117 { m_wXTextField = xTextField; }
120 enum class SwFormatFieldHintWhich
122 INSERTED = 1,
123 REMOVED = 2,
124 FOCUS = 3,
125 CHANGED = 4,
126 LANGUAGE = 5
129 class SW_DLLPUBLIC SwFormatFieldHint : public SfxHint
131 const SwFormatField* pField;
132 SwFormatFieldHintWhich nWhich;
133 const SwView* pView;
135 public:
136 SwFormatFieldHint( const SwFormatField* p, SwFormatFieldHintWhich n, const SwView* pV = 0)
137 : pField(p)
138 , nWhich(n)
139 , pView(pV)
142 const SwFormatField* GetField() const { return pField; }
143 SwFormatFieldHintWhich Which() const { return nWhich; }
144 const SwView* GetView() const { return pView; }
147 #endif
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */