1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
30 * The shared part of a user field.
32 * Tracks the value, but conversion between the float and string representation
33 * always happens with the system locale.
35 class SW_DLLPUBLIC SwUserFieldType final
: public SwValueFieldType
37 bool m_bValidValue
: 1;
42 /// String value type.
44 /// Language used by m_aContents
45 OUString m_aContentLang
;
49 SwUserFieldType( SwDoc
* pDocPtr
, const OUString
& );
51 virtual OUString
GetName() const override
;
52 virtual std::unique_ptr
<SwFieldType
> Copy() const override
;
54 OUString
Expand(sal_uInt32 nFormat
, sal_uInt16 nSubType
, LanguageType nLng
);
56 OUString
GetContent( sal_uInt32 nFormat
= 0 );
57 void SetContent( const OUString
& rStr
, sal_uInt32 nFormat
= 0 );
59 inline bool IsValid() const;
61 double GetValue(SwCalc
& rCalc
); // Recalculate member nValue.
62 inline double GetValue() const;
63 inline void SetValue(const double nVal
);
65 inline sal_uInt16
GetType() const;
66 inline void SetType(sal_uInt16
);
68 bool IsDeleted() const { return m_bDeleted
; }
69 void SetDeleted( bool b
) { m_bDeleted
= b
; }
71 virtual void QueryValue( css::uno::Any
& rVal
, sal_uInt16 nMId
) const override
;
72 virtual void PutValue( const css::uno::Any
& rVal
, sal_uInt16 nMId
) override
;
73 void dumpAsXml(xmlTextWriterPtr pWriter
) const override
;
76 virtual void Modify( const SfxPoolItem
* pOld
, const SfxPoolItem
* pNew
) override
;
79 inline bool SwUserFieldType::IsValid() const
80 { return m_bValidValue
; }
82 inline double SwUserFieldType::GetValue() const
85 inline void SwUserFieldType::SetValue(const double nVal
)
88 inline sal_uInt16
SwUserFieldType::GetType() const
91 inline void SwUserFieldType::SetType(sal_uInt16 nSub
)
94 EnableFormat(!(nSub
& nsSwGetSetExpType::GSE_STRING
));
98 * The non-shared part of a user field.
100 * Tracks the number format and the language, conversion between the float and
101 * string representation is independent from the system locale.
103 class SwUserField final
: public SwValueField
105 sal_uInt16 m_nSubType
;
107 virtual OUString
ExpandImpl(SwRootFrame
const* pLayout
) const override
;
108 virtual std::unique_ptr
<SwField
> Copy() const override
;
111 SwUserField(SwUserFieldType
*, sal_uInt16 nSub
, sal_uInt32 nFormat
);
113 virtual sal_uInt16
GetSubType() const override
;
114 virtual void SetSubType(sal_uInt16 nSub
) override
;
116 virtual double GetValue() const override
;
117 virtual void SetValue( const double& rVal
) override
;
119 virtual OUString
GetFieldName() const override
;
121 // Name cannot be changed.
122 virtual OUString
GetPar1() const override
;
125 virtual OUString
GetPar2() const override
;
126 virtual void SetPar2(const OUString
& rStr
) override
;
127 virtual bool QueryValue( css::uno::Any
& rVal
, sal_uInt16 nWhichId
) const override
;
128 virtual bool PutValue( const css::uno::Any
& rVal
, sal_uInt16 nWhichId
) override
;
129 void dumpAsXml(xmlTextWriterPtr pWriter
) const override
;
132 #endif // INCLUDED_SW_INC_USRFLD_HXX
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */