Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef SW_USRFLD_HXX
29 : : #define SW_USRFLD_HXX
30 : :
31 : : #include "swdllapi.h"
32 : : #include "fldbas.hxx"
33 : :
34 : : class SfxPoolItem;
35 : : class SwCalc;
36 : : class SwDoc;
37 : :
38 : :
39 [ + - ][ - + ]: 120 : class SW_DLLPUBLIC SwUserFieldType : public SwValueFieldType
40 : : {
41 : : sal_Bool bValidValue : 1;
42 : : sal_Bool bDeleted : 1;
43 : : double nValue;
44 : : rtl::OUString aName;
45 : : String aContent;
46 : : sal_uInt16 nType;
47 : :
48 : : public:
49 : : SwUserFieldType( SwDoc* pDocPtr, const String& );
50 : :
51 : : virtual const rtl::OUString& GetName() const;
52 : : virtual SwFieldType* Copy() const;
53 : :
54 : : String Expand(sal_uInt32 nFmt, sal_uInt16 nSubType, sal_uInt16 nLng);
55 : :
56 : : String GetContent( sal_uInt32 nFmt = 0 );
57 : : void SetContent( const String& rStr, sal_uInt32 nFmt = 0 );
58 : :
59 : : inline sal_Bool IsValid() const;
60 : : inline void ChgValid( sal_Bool bNew );
61 : :
62 : : double GetValue(SwCalc& rCalc); // Recalculate member nValue.
63 : : inline double GetValue() const;
64 : : inline void SetValue(const double nVal);
65 : :
66 : : inline sal_uInt16 GetType() const;
67 : : inline void SetType(sal_uInt16);
68 : :
69 : 0 : sal_Bool IsDeleted() const { return bDeleted; }
70 : 0 : void SetDeleted( sal_Bool b ) { bDeleted = b; }
71 : :
72 : : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nMId ) const;
73 : : virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nMId );
74 : :
75 : : protected:
76 : : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew );
77 : : };
78 : :
79 : 0 : inline sal_Bool SwUserFieldType::IsValid() const
80 : 0 : { return bValidValue; }
81 : :
82 : 3 : inline void SwUserFieldType::ChgValid( sal_Bool bNew )
83 : 3 : { bValidValue = bNew; }
84 : :
85 : 0 : inline double SwUserFieldType::GetValue() const
86 : 0 : { return nValue; }
87 : :
88 : 54 : inline void SwUserFieldType::SetValue(const double nVal)
89 : 54 : { nValue = nVal; }
90 : :
91 : 6 : inline sal_uInt16 SwUserFieldType::GetType() const
92 : 6 : { return nType; }
93 : :
94 : 54 : inline void SwUserFieldType::SetType(sal_uInt16 nSub)
95 : : {
96 : 54 : nType = nSub;
97 : 54 : EnableFormat(!(nSub & nsSwGetSetExpType::GSE_STRING));
98 : 54 : }
99 : :
100 : :
101 [ # # ]: 0 : class SW_DLLPUBLIC SwUserField : public SwValueField
102 : : {
103 : : sal_uInt16 nSubType;
104 : :
105 : : virtual String Expand() const;
106 : : virtual SwField* Copy() const;
107 : :
108 : : public:
109 : : SwUserField(SwUserFieldType*, sal_uInt16 nSub = 0, sal_uInt32 nFmt = 0);
110 : :
111 : : virtual sal_uInt16 GetSubType() const;
112 : : virtual void SetSubType(sal_uInt16 nSub);
113 : :
114 : : virtual double GetValue() const;
115 : : virtual void SetValue( const double& rVal );
116 : :
117 : : virtual String GetFieldName() const;
118 : :
119 : : // Name cannot be changed.
120 : : virtual const rtl::OUString& GetPar1() const;
121 : :
122 : : // Content.
123 : : virtual rtl::OUString GetPar2() const;
124 : : virtual void SetPar2(const rtl::OUString& rStr);
125 : : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) const;
126 : : virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId );
127 : : };
128 : :
129 : : #endif // SW_USRFLD_HXX
130 : :
131 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|