Line data Source code
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 <com/sun/star/text/XTextField.hpp>
24 :
25 : #include <cppuhelper/weakref.hxx>
26 : #include <svl/poolitem.hxx>
27 : #include <svl/brdcst.hxx>
28 : #include <svl/smplhint.hxx>
29 :
30 : #include "swdllapi.h"
31 : #include <calbck.hxx>
32 :
33 : class SwField;
34 : class SwTxtFld;
35 : class SwView;
36 : class SwFieldType;
37 :
38 : // ATT_FLD
39 : class SW_DLLPUBLIC SwFmtFld : public SfxPoolItem, public SwClient, public SfxBroadcaster
40 : {
41 : friend void _InitCore();
42 : SwFmtFld( sal_uInt16 nWhich ); // for default-Attibute
43 :
44 : ::com::sun::star::uno::WeakReference<
45 : ::com::sun::star::text::XTextField> m_wXTextField;
46 :
47 : SwField* mpField;
48 : SwTxtFld* mpTxtFld; // the TextAttribute
49 :
50 : // @@@ copy construction allowed, but copy assignment is not? @@@
51 : SwFmtFld& operator=(const SwFmtFld& rFld);
52 :
53 : protected:
54 : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
55 : virtual void SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) SAL_OVERRIDE;
56 :
57 : public:
58 : TYPEINFO_OVERRIDE();
59 :
60 : /// Single argument constructors shall be explicit.
61 : explicit SwFmtFld( const SwField &rFld );
62 :
63 : /// @@@ copy construction allowed, but copy assignment is not? @@@
64 : SwFmtFld( const SwFmtFld& rAttr );
65 :
66 : virtual ~SwFmtFld();
67 :
68 : /// "Pure virtual methods" of SfxPoolItem.
69 : virtual bool operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
70 : virtual SfxPoolItem* Clone( SfxItemPool* pPool = 0 ) const SAL_OVERRIDE;
71 :
72 : virtual bool GetInfo( SfxPoolItem& rInfo ) const SAL_OVERRIDE;
73 :
74 0 : const SwField* GetField() const
75 : {
76 0 : return mpField;
77 : }
78 0 : SwField* GetField()
79 : {
80 0 : return mpField;
81 : }
82 :
83 : /**
84 : Sets current field.
85 :
86 : @param pField new field
87 :
88 : @attention The current field will be destroyed before setting the new field.
89 : */
90 : void SetField( SwField * pField );
91 :
92 0 : const SwTxtFld* GetTxtFld() const
93 : {
94 0 : return mpTxtFld;
95 : }
96 0 : SwTxtFld* GetTxtFld()
97 : {
98 0 : return mpTxtFld;
99 : }
100 : void SetTxtFld( SwTxtFld& rTxtFld );
101 : void ClearTxtFld();
102 :
103 : void RegisterToFieldType( SwFieldType& );
104 : bool IsFldInDoc() const;
105 : sal_Bool IsProtect() const;
106 :
107 : SAL_DLLPRIVATE ::com::sun::star::uno::WeakReference<
108 0 : ::com::sun::star::text::XTextField> const& GetXTextField() const
109 0 : { return m_wXTextField; }
110 0 : SAL_DLLPRIVATE void SetXTextField(::com::sun::star::uno::Reference<
111 : ::com::sun::star::text::XTextField> const& xTextField)
112 0 : { m_wXTextField = xTextField; }
113 : };
114 :
115 0 : class SW_DLLPUBLIC SwFmtFldHint : public SfxHint
116 : {
117 : #define SWFMTFLD_INSERTED 1
118 : #define SWFMTFLD_REMOVED 2
119 : #define SWFMTFLD_FOCUS 3
120 : #define SWFMTFLD_CHANGED 4
121 : #define SWFMTFLD_LANGUAGE 5
122 :
123 : const SwFmtFld* pFld;
124 : sal_Int16 nWhich;
125 : const SwView* pView;
126 :
127 : public:
128 0 : SwFmtFldHint( const SwFmtFld* p, sal_Int16 n, const SwView* pV = 0)
129 : : pFld(p)
130 : , nWhich(n)
131 0 : , pView(pV)
132 0 : {}
133 :
134 : TYPEINFO_OVERRIDE();
135 0 : const SwFmtFld* GetField() const { return pFld; }
136 0 : sal_Int16 Which() const { return nWhich; }
137 0 : const SwView* GetView() const { return pView; }
138 : };
139 :
140 : #endif
141 :
142 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|