Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef SW_USRFLD_HXX
20 : #define SW_USRFLD_HXX
21 :
22 : #include "swdllapi.h"
23 : #include "fldbas.hxx"
24 :
25 : class SfxPoolItem;
26 : class SwCalc;
27 : class SwDoc;
28 :
29 :
30 1 : class SW_DLLPUBLIC SwUserFieldType : public SwValueFieldType
31 : {
32 : bool bValidValue : 1;
33 : bool bDeleted : 1;
34 : double nValue;
35 : rtl::OUString aName;
36 : String aContent;
37 : sal_uInt16 nType;
38 :
39 : public:
40 : SwUserFieldType( SwDoc* pDocPtr, const String& );
41 :
42 : virtual const rtl::OUString& GetName() const;
43 : virtual SwFieldType* Copy() const;
44 :
45 : String Expand(sal_uInt32 nFmt, sal_uInt16 nSubType, sal_uInt16 nLng);
46 :
47 : String GetContent( sal_uInt32 nFmt = 0 );
48 : void SetContent( const String& rStr, sal_uInt32 nFmt = 0 );
49 :
50 : inline bool IsValid() const;
51 : inline void ChgValid( bool bNew );
52 :
53 : double GetValue(SwCalc& rCalc); // Recalculate member nValue.
54 : inline double GetValue() const;
55 : inline void SetValue(const double nVal);
56 :
57 : inline sal_uInt16 GetType() const;
58 : inline void SetType(sal_uInt16);
59 :
60 0 : bool IsDeleted() const { return bDeleted; }
61 0 : void SetDeleted( bool b ) { bDeleted = b; }
62 :
63 : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nMId ) const;
64 : virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nMId );
65 :
66 : protected:
67 : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew );
68 : };
69 :
70 0 : inline bool SwUserFieldType::IsValid() const
71 0 : { return bValidValue; }
72 :
73 1 : inline void SwUserFieldType::ChgValid( bool bNew )
74 1 : { bValidValue = bNew; }
75 :
76 0 : inline double SwUserFieldType::GetValue() const
77 0 : { return nValue; }
78 :
79 1 : inline void SwUserFieldType::SetValue(const double nVal)
80 1 : { nValue = nVal; }
81 :
82 2 : inline sal_uInt16 SwUserFieldType::GetType() const
83 2 : { return nType; }
84 :
85 1 : inline void SwUserFieldType::SetType(sal_uInt16 nSub)
86 : {
87 1 : nType = nSub;
88 1 : EnableFormat(!(nSub & nsSwGetSetExpType::GSE_STRING));
89 1 : }
90 :
91 :
92 0 : class SW_DLLPUBLIC SwUserField : public SwValueField
93 : {
94 : sal_uInt16 nSubType;
95 :
96 : virtual String Expand() const;
97 : virtual SwField* Copy() const;
98 :
99 : public:
100 : SwUserField(SwUserFieldType*, sal_uInt16 nSub = 0, sal_uInt32 nFmt = 0);
101 :
102 : virtual sal_uInt16 GetSubType() const;
103 : virtual void SetSubType(sal_uInt16 nSub);
104 :
105 : virtual double GetValue() const;
106 : virtual void SetValue( const double& rVal );
107 :
108 : virtual String GetFieldName() const;
109 :
110 : // Name cannot be changed.
111 : virtual const rtl::OUString& GetPar1() const;
112 :
113 : // Content.
114 : virtual rtl::OUString GetPar2() const;
115 : virtual void SetPar2(const rtl::OUString& rStr);
116 : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) const;
117 : virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId );
118 : };
119 :
120 : #endif // SW_USRFLD_HXX
121 :
122 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|