xref: /aoo42x/main/sw/inc/usrfld.hxx (revision 1d2dbeb0)
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 SW_USRFLD_HXX
24 #define SW_USRFLD_HXX
25 
26 #include "swdllapi.h"
27 #include "fldbas.hxx"
28 
29 class SfxPoolItem;
30 class SwCalc;
31 class SwDoc;
32 
33 /*--------------------------------------------------------------------
34 	Beschreibung: Benutzerfelder
35  --------------------------------------------------------------------*/
36 
37 class SW_DLLPUBLIC SwUserFieldType : public SwValueFieldType
38 {
39 	sal_Bool	bValidValue : 1;
40 	sal_Bool	bDeleted : 1;
41 	double 	nValue;
42 	String  aName;
43 	String  aContent;
44 	sal_uInt16  nType;
45 
46 public:
47 	SwUserFieldType( SwDoc* pDocPtr, const String& );
48 
49 	virtual const String&	GetName() const;
50 	virtual SwFieldType*	Copy() const;
51 
52 	String					Expand(sal_uInt32 nFmt, sal_uInt16 nSubType, sal_uInt16 nLng);
53 
54 	String					GetContent( sal_uInt32 nFmt = 0 );
55 		   void				SetContent( const String& rStr, sal_uInt32 nFmt = 0 );
56 
57 	inline sal_Bool 			IsValid() const;
58 	inline void 			ChgValid( sal_Bool bNew );
59 
60 		   double 			GetValue(SwCalc& rCalc);	// Member nValue neu berrechnen
61 	inline double			GetValue() const;
62 	inline void				SetValue(const double nVal);
63 
64 	inline sal_uInt16			GetType() const;
65 	inline void				SetType(sal_uInt16);
66 
IsDeleted() const67 	sal_Bool					IsDeleted() const 		{ return bDeleted; }
SetDeleted(sal_Bool b)68 	void					SetDeleted( sal_Bool b )	{ bDeleted = b; }
69 
70     virtual sal_Bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nMId ) const;
71     virtual sal_Bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nMId );
72 
73 protected:
74    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew );
75 };
76 
IsValid() const77 inline sal_Bool SwUserFieldType::IsValid() const
78 	{ return bValidValue; }
79 
ChgValid(sal_Bool bNew)80 inline void SwUserFieldType::ChgValid( sal_Bool bNew )
81 	{ bValidValue = bNew; }
82 
GetValue() const83 inline double SwUserFieldType::GetValue() const
84 	{ return nValue; }
85 
SetValue(const double nVal)86 inline void SwUserFieldType::SetValue(const double nVal)
87 	{ nValue = nVal; }
88 
GetType() const89 inline sal_uInt16 SwUserFieldType::GetType() const
90 	{ return nType; }
91 
SetType(sal_uInt16 nSub)92 inline void SwUserFieldType::SetType(sal_uInt16 nSub)
93 {
94 	nType = nSub;
95 	EnableFormat(!(nSub & nsSwGetSetExpType::GSE_STRING));
96 }
97 
98 /*--------------------------------------------------------------------
99 	Beschreibung: Benutzerfelder
100  --------------------------------------------------------------------*/
101 
102 class SW_DLLPUBLIC SwUserField : public SwValueField
103 {
104 	sal_uInt16  nSubType;
105 
106     virtual String          Expand() const;
107     virtual SwField*        Copy() const;
108 
109 public:
110 	SwUserField(SwUserFieldType*, sal_uInt16 nSub = 0, sal_uInt32 nFmt = 0);
111 
112 	virtual sal_uInt16	 		GetSubType() const;
113 	virtual void	 		SetSubType(sal_uInt16 nSub);
114 
115 	virtual double			GetValue() const;
116 	virtual void 			SetValue( const double& rVal );
117 
118     virtual String          GetFieldName() const;
119 
120 	// Name kann nicht geaendert werden
121 	virtual const String& 	GetPar1() const;
122 
123 	// Inhalt
124 	virtual String	 		GetPar2() const;
125 	virtual void	 		SetPar2(const String& rStr);
126     virtual sal_Bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) const;
127     virtual sal_Bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId );
128 };
129 
130 #endif // SW_USRFLD_HXX
131