xref: /aoo42x/main/sw/inc/fmtfld.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _FMTFLD_HXX
28 #define _FMTFLD_HXX
29 
30 #include <list>
31 #include <svl/poolitem.hxx>
32 #include <svl/brdcst.hxx>
33 #include <svl/smplhint.hxx>
34 
35 #include "swdllapi.h"
36 #include <calbck.hxx>
37 
38 class SwField;
39 class SwTxtFld;
40 class SwView;
41 class SwFieldType;
42 
43 // ATT_FLD ***********************************
44 class SW_DLLPUBLIC SwFmtFld : public SfxPoolItem, public SwClient, public SfxBroadcaster
45 {
46 	friend class SwTxtFld;
47 	friend void _InitCore();
48 
49 	SwField *pField;
50 	SwTxtFld* pTxtAttr;		// mein TextAttribut
51 
52 	SwFmtFld();				// das default-Attibut
53 
54 	// geschuetzter CopyCtor
55 	// @@@ copy construction allowed, but copy assignment is not? @@@
56 	SwFmtFld& operator=(const SwFmtFld& rFld);
57 
58 protected:
59     virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
60     virtual void SwClientNotify( const SwModify& rModify, const SfxHint& rHint );
61 
62 public:
63 	TYPEINFO();
64 
65 	// single argument constructors shall be explicit.
66 	explicit SwFmtFld( const SwField &rFld );
67 
68 	// @@@ copy construction allowed, but copy assignment is not? @@@
69 	SwFmtFld( const SwFmtFld& rAttr );
70 
71 	virtual ~SwFmtFld();
72 
73 	// "pure virtual Methoden" vom SfxPoolItem
74 	virtual int             operator==( const SfxPoolItem& ) const;
75 	virtual SfxPoolItem*	Clone( SfxItemPool* pPool = 0 ) const;
76 
77 	virtual sal_Bool GetInfo( SfxPoolItem& rInfo ) const;
78 
79 	const SwField *GetFld() const	{ return pField; }
80 	SwField *GetFld()				{ return pField; }
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 SetFld(SwField * pField);
91 
92 	const SwTxtFld *GetTxtFld() const	{ return pTxtAttr; }
93 	SwTxtFld *GetTxtFld()				{ return pTxtAttr; }
94 
95     void RegisterToFieldType( SwFieldType& );
96 	sal_Bool IsFldInDoc() const;
97 	sal_Bool IsProtect() const;
98 };
99 
100 class SW_DLLPUBLIC SwFmtFldHint : public SfxHint
101 {
102 #define SWFMTFLD_INSERTED	1
103 #define SWFMTFLD_REMOVED	2
104 #define SWFMTFLD_FOCUS		3
105 #define SWFMTFLD_CHANGED	4
106 #define SWFMTFLD_LANGUAGE	5
107 
108 	const SwFmtFld* pFld;
109 	sal_Int16 nWhich;
110 	const SwView* pView;
111 
112 public:
113 	SwFmtFldHint( const SwFmtFld* p, sal_Int16 n, const SwView* pV = 0)
114 		: pFld(p)
115 		, nWhich(n)
116 		, pView(pV)
117 	{}
118 
119 	TYPEINFO();
120 	const SwFmtFld* GetField() const { return pFld; }
121 	sal_Int16 Which() const { return nWhich; }
122 	const SwView* GetView() const { return pView; }
123 };
124 
125 #endif
126