xref: /trunk/main/sw/inc/usrfld.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
1*1d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1d2dbeb0SAndrew Rist  * distributed with this work for additional information
6*1d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
9*1d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*1d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*1d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
15*1d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
18*1d2dbeb0SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*1d2dbeb0SAndrew Rist  *************************************************************/
21*1d2dbeb0SAndrew Rist 
22*1d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir #ifndef SW_USRFLD_HXX
24cdf0e10cSrcweir #define SW_USRFLD_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "swdllapi.h"
27cdf0e10cSrcweir #include "fldbas.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir class SfxPoolItem;
30cdf0e10cSrcweir class SwCalc;
31cdf0e10cSrcweir class SwDoc;
32cdf0e10cSrcweir 
33cdf0e10cSrcweir /*--------------------------------------------------------------------
34cdf0e10cSrcweir     Beschreibung: Benutzerfelder
35cdf0e10cSrcweir  --------------------------------------------------------------------*/
36cdf0e10cSrcweir 
37cdf0e10cSrcweir class SW_DLLPUBLIC SwUserFieldType : public SwValueFieldType
38cdf0e10cSrcweir {
39cdf0e10cSrcweir     sal_Bool    bValidValue : 1;
40cdf0e10cSrcweir     sal_Bool    bDeleted : 1;
41cdf0e10cSrcweir     double  nValue;
42cdf0e10cSrcweir     String  aName;
43cdf0e10cSrcweir     String  aContent;
44cdf0e10cSrcweir     sal_uInt16  nType;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir public:
47cdf0e10cSrcweir     SwUserFieldType( SwDoc* pDocPtr, const String& );
48cdf0e10cSrcweir 
49cdf0e10cSrcweir     virtual const String&   GetName() const;
50cdf0e10cSrcweir     virtual SwFieldType*    Copy() const;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir     String                  Expand(sal_uInt32 nFmt, sal_uInt16 nSubType, sal_uInt16 nLng);
53cdf0e10cSrcweir 
54cdf0e10cSrcweir     String                  GetContent( sal_uInt32 nFmt = 0 );
55cdf0e10cSrcweir            void             SetContent( const String& rStr, sal_uInt32 nFmt = 0 );
56cdf0e10cSrcweir 
57cdf0e10cSrcweir     inline sal_Bool             IsValid() const;
58cdf0e10cSrcweir     inline void             ChgValid( sal_Bool bNew );
59cdf0e10cSrcweir 
60cdf0e10cSrcweir            double           GetValue(SwCalc& rCalc);    // Member nValue neu berrechnen
61cdf0e10cSrcweir     inline double           GetValue() const;
62cdf0e10cSrcweir     inline void             SetValue(const double nVal);
63cdf0e10cSrcweir 
64cdf0e10cSrcweir     inline sal_uInt16           GetType() const;
65cdf0e10cSrcweir     inline void             SetType(sal_uInt16);
66cdf0e10cSrcweir 
IsDeleted() const67cdf0e10cSrcweir     sal_Bool                    IsDeleted() const       { return bDeleted; }
SetDeleted(sal_Bool b)68cdf0e10cSrcweir     void                    SetDeleted( sal_Bool b )    { bDeleted = b; }
69cdf0e10cSrcweir 
70cdf0e10cSrcweir     virtual sal_Bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nMId ) const;
71cdf0e10cSrcweir     virtual sal_Bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nMId );
72cdf0e10cSrcweir 
73cdf0e10cSrcweir protected:
74cdf0e10cSrcweir    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew );
75cdf0e10cSrcweir };
76cdf0e10cSrcweir 
IsValid() const77cdf0e10cSrcweir inline sal_Bool SwUserFieldType::IsValid() const
78cdf0e10cSrcweir     { return bValidValue; }
79cdf0e10cSrcweir 
ChgValid(sal_Bool bNew)80cdf0e10cSrcweir inline void SwUserFieldType::ChgValid( sal_Bool bNew )
81cdf0e10cSrcweir     { bValidValue = bNew; }
82cdf0e10cSrcweir 
GetValue() const83cdf0e10cSrcweir inline double SwUserFieldType::GetValue() const
84cdf0e10cSrcweir     { return nValue; }
85cdf0e10cSrcweir 
SetValue(const double nVal)86cdf0e10cSrcweir inline void SwUserFieldType::SetValue(const double nVal)
87cdf0e10cSrcweir     { nValue = nVal; }
88cdf0e10cSrcweir 
GetType() const89cdf0e10cSrcweir inline sal_uInt16 SwUserFieldType::GetType() const
90cdf0e10cSrcweir     { return nType; }
91cdf0e10cSrcweir 
SetType(sal_uInt16 nSub)92cdf0e10cSrcweir inline void SwUserFieldType::SetType(sal_uInt16 nSub)
93cdf0e10cSrcweir {
94cdf0e10cSrcweir     nType = nSub;
95cdf0e10cSrcweir     EnableFormat(!(nSub & nsSwGetSetExpType::GSE_STRING));
96cdf0e10cSrcweir }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir /*--------------------------------------------------------------------
99cdf0e10cSrcweir     Beschreibung: Benutzerfelder
100cdf0e10cSrcweir  --------------------------------------------------------------------*/
101cdf0e10cSrcweir 
102cdf0e10cSrcweir class SW_DLLPUBLIC SwUserField : public SwValueField
103cdf0e10cSrcweir {
104cdf0e10cSrcweir     sal_uInt16  nSubType;
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     virtual String          Expand() const;
107cdf0e10cSrcweir     virtual SwField*        Copy() const;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir public:
110cdf0e10cSrcweir     SwUserField(SwUserFieldType*, sal_uInt16 nSub = 0, sal_uInt32 nFmt = 0);
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     virtual sal_uInt16          GetSubType() const;
113cdf0e10cSrcweir     virtual void            SetSubType(sal_uInt16 nSub);
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     virtual double          GetValue() const;
116cdf0e10cSrcweir     virtual void            SetValue( const double& rVal );
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     virtual String          GetFieldName() const;
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     // Name kann nicht geaendert werden
121cdf0e10cSrcweir     virtual const String&   GetPar1() const;
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     // Inhalt
124cdf0e10cSrcweir     virtual String          GetPar2() const;
125cdf0e10cSrcweir     virtual void            SetPar2(const String& rStr);
126cdf0e10cSrcweir     virtual sal_Bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) const;
127cdf0e10cSrcweir     virtual sal_Bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId );
128cdf0e10cSrcweir };
129cdf0e10cSrcweir 
130cdf0e10cSrcweir #endif // SW_USRFLD_HXX
131