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