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 INCLUDED_SW_INC_USRFLD_HXX
20 : #define INCLUDED_SW_INC_USRFLD_HXX
21 :
22 : #include "swdllapi.h"
23 : #include "fldbas.hxx"
24 :
25 : class SfxPoolItem;
26 : class SwCalc;
27 : class SwDoc;
28 :
29 0 : class SW_DLLPUBLIC SwUserFieldType : public SwValueFieldType
30 : {
31 : bool bValidValue : 1;
32 : bool bDeleted : 1;
33 : double nValue;
34 : OUString aName;
35 : OUString aContent;
36 : sal_uInt16 nType;
37 :
38 : public:
39 : SwUserFieldType( SwDoc* pDocPtr, const OUString& );
40 :
41 : virtual OUString GetName() const SAL_OVERRIDE;
42 : virtual SwFieldType* Copy() const SAL_OVERRIDE;
43 :
44 : OUString Expand(sal_uInt32 nFmt, sal_uInt16 nSubType, sal_uInt16 nLng);
45 :
46 : OUString GetContent( sal_uInt32 nFmt = 0 );
47 : void SetContent( const OUString& rStr, sal_uInt32 nFmt = 0 );
48 :
49 : inline bool IsValid() const;
50 : inline void ChgValid( bool bNew );
51 :
52 : double GetValue(SwCalc& rCalc); // Recalculate member nValue.
53 : inline double GetValue() const;
54 : inline void SetValue(const double nVal);
55 :
56 : inline sal_uInt16 GetType() const;
57 : inline void SetType(sal_uInt16);
58 :
59 0 : bool IsDeleted() const { return bDeleted; }
60 0 : void SetDeleted( bool b ) { bDeleted = b; }
61 :
62 : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nMId ) const SAL_OVERRIDE;
63 : virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nMId ) SAL_OVERRIDE;
64 :
65 : protected:
66 : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) SAL_OVERRIDE;
67 : };
68 :
69 0 : inline bool SwUserFieldType::IsValid() const
70 0 : { return bValidValue; }
71 :
72 0 : inline void SwUserFieldType::ChgValid( bool bNew )
73 0 : { bValidValue = bNew; }
74 :
75 0 : inline double SwUserFieldType::GetValue() const
76 0 : { return nValue; }
77 :
78 0 : inline void SwUserFieldType::SetValue(const double nVal)
79 0 : { nValue = nVal; }
80 :
81 0 : inline sal_uInt16 SwUserFieldType::GetType() const
82 0 : { return nType; }
83 :
84 0 : inline void SwUserFieldType::SetType(sal_uInt16 nSub)
85 : {
86 0 : nType = nSub;
87 0 : EnableFormat(!(nSub & nsSwGetSetExpType::GSE_STRING));
88 0 : }
89 :
90 0 : class SW_DLLPUBLIC SwUserField : public SwValueField
91 : {
92 : sal_uInt16 nSubType;
93 :
94 : virtual OUString Expand() const SAL_OVERRIDE;
95 : virtual SwField* Copy() const SAL_OVERRIDE;
96 :
97 : public:
98 : SwUserField(SwUserFieldType*, sal_uInt16 nSub = 0, sal_uInt32 nFmt = 0);
99 :
100 : virtual sal_uInt16 GetSubType() const SAL_OVERRIDE;
101 : virtual void SetSubType(sal_uInt16 nSub) SAL_OVERRIDE;
102 :
103 : virtual double GetValue() const SAL_OVERRIDE;
104 : virtual void SetValue( const double& rVal ) SAL_OVERRIDE;
105 :
106 : virtual OUString GetFieldName() const SAL_OVERRIDE;
107 :
108 : // Name cannot be changed.
109 : virtual OUString GetPar1() const SAL_OVERRIDE;
110 :
111 : // Content.
112 : virtual OUString GetPar2() const SAL_OVERRIDE;
113 : virtual void SetPar2(const OUString& rStr) SAL_OVERRIDE;
114 : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) const SAL_OVERRIDE;
115 : virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) SAL_OVERRIDE;
116 : };
117 :
118 : #endif // INCLUDED_SW_INC_USRFLD_HXX
119 :
120 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|