Branch libreoffice-5-0-4
[LibreOffice.git] / sw / inc / usrfld.hxx
blobe0d1730c5ce74aa4fb1abeacad478e3d3c4c475c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_INC_USRFLD_HXX
20 #define INCLUDED_SW_INC_USRFLD_HXX
22 #include "swdllapi.h"
23 #include "fldbas.hxx"
25 class SfxPoolItem;
26 class SwCalc;
27 class SwDoc;
29 class SW_DLLPUBLIC SwUserFieldType : public SwValueFieldType
31 bool bValidValue : 1;
32 bool bDeleted : 1;
33 double nValue;
34 OUString aName;
35 OUString aContent;
36 sal_uInt16 nType;
38 public:
39 SwUserFieldType( SwDoc* pDocPtr, const OUString& );
41 virtual OUString GetName() const SAL_OVERRIDE;
42 virtual SwFieldType* Copy() const SAL_OVERRIDE;
44 OUString Expand(sal_uInt32 nFormat, sal_uInt16 nSubType, sal_uInt16 nLng);
46 OUString GetContent( sal_uInt32 nFormat = 0 );
47 void SetContent( const OUString& rStr, sal_uInt32 nFormat = 0 );
49 inline bool IsValid() const;
50 inline void ChgValid( bool bNew );
52 double GetValue(SwCalc& rCalc); // Recalculate member nValue.
53 inline double GetValue() const;
54 inline void SetValue(const double nVal);
56 inline sal_uInt16 GetType() const;
57 inline void SetType(sal_uInt16);
59 bool IsDeleted() const { return bDeleted; }
60 void SetDeleted( bool b ) { bDeleted = b; }
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;
65 protected:
66 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) SAL_OVERRIDE;
69 inline bool SwUserFieldType::IsValid() const
70 { return bValidValue; }
72 inline void SwUserFieldType::ChgValid( bool bNew )
73 { bValidValue = bNew; }
75 inline double SwUserFieldType::GetValue() const
76 { return nValue; }
78 inline void SwUserFieldType::SetValue(const double nVal)
79 { nValue = nVal; }
81 inline sal_uInt16 SwUserFieldType::GetType() const
82 { return nType; }
84 inline void SwUserFieldType::SetType(sal_uInt16 nSub)
86 nType = nSub;
87 EnableFormat(!(nSub & nsSwGetSetExpType::GSE_STRING));
90 class SW_DLLPUBLIC SwUserField : public SwValueField
92 sal_uInt16 nSubType;
94 virtual OUString Expand() const SAL_OVERRIDE;
95 virtual SwField* Copy() const SAL_OVERRIDE;
97 public:
98 SwUserField(SwUserFieldType*, sal_uInt16 nSub = 0, sal_uInt32 nFormat = 0);
100 virtual sal_uInt16 GetSubType() const SAL_OVERRIDE;
101 virtual void SetSubType(sal_uInt16 nSub) SAL_OVERRIDE;
103 virtual double GetValue() const SAL_OVERRIDE;
104 virtual void SetValue( const double& rVal ) SAL_OVERRIDE;
106 virtual OUString GetFieldName() const SAL_OVERRIDE;
108 // Name cannot be changed.
109 virtual OUString GetPar1() const SAL_OVERRIDE;
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;
118 #endif // INCLUDED_SW_INC_USRFLD_HXX
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */