xref: /aoo41x/main/sw/inc/fmtfld.hxx (revision 69a74367)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _FMTFLD_HXX
24 #define _FMTFLD_HXX
25 
26 #include <list>
27 #include <svl/poolitem.hxx>
28 #include <svl/brdcst.hxx>
29 #include <svl/smplhint.hxx>
30 
31 #include "swdllapi.h"
32 #include <calbck.hxx>
33 
34 class SwField;
35 class SwTxtFld;
36 class SwView;
37 class SwFieldType;
38 
39 // ATT_FLD ***********************************
40 class SW_DLLPUBLIC SwFmtFld : public SfxPoolItem, public SwClient, public SfxBroadcaster
41 {
42     friend void _InitCore();
43     SwFmtFld( sal_uInt16 nWhich ); // for default-Attibute
44 
45     SwField* mpField;
46     SwTxtFld* mpTxtFld; // the TextAttribute
47 
48 
49     // @@@ copy construction allowed, but copy assignment is not? @@@
50     SwFmtFld& operator=(const SwFmtFld& rFld);
51 
52 protected:
53     virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
54     virtual void SwClientNotify( const SwModify& rModify, const SfxHint& rHint );
55 
56 public:
57 	TYPEINFO();
58 
59 	// single argument constructors shall be explicit.
60 	explicit SwFmtFld( const SwField &rFld );
61 
62 	// @@@ copy construction allowed, but copy assignment is not? @@@
63 	SwFmtFld( const SwFmtFld& rAttr );
64 
65 	virtual ~SwFmtFld();
66 
67 	// "pure virtual Methoden" vom SfxPoolItem
68 	virtual int             operator==( const SfxPoolItem& ) const;
69 	virtual SfxPoolItem*	Clone( SfxItemPool* pPool = 0 ) const;
70 
71 	virtual sal_Bool GetInfo( SfxPoolItem& rInfo ) const;
72 
GetField() const73     const SwField* GetField() const
74     {
75         return mpField;
76     }
GetField()77     SwField* GetField()
78     {
79         return mpField;
80     }
81 
82     // #111840#
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 
GetTxtFld() const93     const SwTxtFld* GetTxtFld() const
94     {
95         return mpTxtFld;
96     }
GetTxtFld()97     SwTxtFld* GetTxtFld()
98     {
99         return mpTxtFld;
100     }
101     void SetTxtFld( SwTxtFld& rTxtFld );
102     void ClearTxtFld();
103 
104 
105     void RegisterToFieldType( SwFieldType& );
106     bool IsFldInDoc() const;
107     sal_Bool IsProtect() const;
108 };
109 
110 class SW_DLLPUBLIC SwFmtFldHint : public SfxHint
111 {
112 #define SWFMTFLD_INSERTED	1
113 #define SWFMTFLD_REMOVED	2
114 #define SWFMTFLD_FOCUS		3
115 #define SWFMTFLD_CHANGED	4
116 #define SWFMTFLD_LANGUAGE	5
117 
118 	const SwFmtFld* pFld;
119 	sal_Int16 nWhich;
120 	const SwView* pView;
121 
122 public:
SwFmtFldHint(const SwFmtFld * p,sal_Int16 n,const SwView * pV=0)123 	SwFmtFldHint( const SwFmtFld* p, sal_Int16 n, const SwView* pV = 0)
124 		: pFld(p)
125 		, nWhich(n)
126 		, pView(pV)
127 	{}
128 
129 	TYPEINFO();
GetField() const130 	const SwFmtFld* GetField() const { return pFld; }
Which() const131 	sal_Int16 Which() const { return nWhich; }
GetView() const132 	const SwView* GetView() const { return pView; }
133 };
134 
135 #endif
136