LibreOffice Module sw (master)  1
usrfld.hxx
Go to the documentation of this file.
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 
36 {
37  bool m_bValidValue : 1;
38  bool m_bDeleted : 1;
40  double m_nValue;
41  OUString m_aName;
43  OUString m_aContent;
44  sal_uInt16 m_nType;
45 
46 public:
47  SwUserFieldType( SwDoc* pDocPtr, const OUString& );
48 
49  virtual OUString GetName() const override;
50  virtual std::unique_ptr<SwFieldType> Copy() const override;
51 
52  OUString Expand(sal_uInt32 nFormat, sal_uInt16 nSubType, LanguageType nLng);
53 
54  OUString GetContent( sal_uInt32 nFormat = 0 );
55  void SetContent( const OUString& rStr, sal_uInt32 nFormat = 0 );
56 
57  inline bool IsValid() const;
58 
59  double GetValue(SwCalc& rCalc); // Recalculate member nValue.
60  inline double GetValue() const;
61  inline void SetValue(const double nVal);
62 
63  inline sal_uInt16 GetType() const;
64  inline void SetType(sal_uInt16);
65 
66  bool IsDeleted() const { return m_bDeleted; }
67  void SetDeleted( bool b ) { m_bDeleted = b; }
68 
69  virtual void QueryValue( css::uno::Any& rVal, sal_uInt16 nMId ) const override;
70  virtual void PutValue( const css::uno::Any& rVal, sal_uInt16 nMId ) override;
71  void dumpAsXml(xmlTextWriterPtr pWriter) const override;
72 
73 protected:
74  virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) override;
75 };
76 
77 inline bool SwUserFieldType::IsValid() const
78  { return m_bValidValue; }
79 
80 inline double SwUserFieldType::GetValue() const
81  { return m_nValue; }
82 
83 inline void SwUserFieldType::SetValue(const double nVal)
84  { m_nValue = nVal; }
85 
86 inline sal_uInt16 SwUserFieldType::GetType() const
87  { return m_nType; }
88 
89 inline void SwUserFieldType::SetType(sal_uInt16 nSub)
90 {
91  m_nType = nSub;
93 }
94 
102 {
103  sal_uInt16 m_nSubType;
104 
105  virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override;
106  virtual std::unique_ptr<SwField> Copy() const override;
107 
108 public:
109  SwUserField(SwUserFieldType*, sal_uInt16 nSub, sal_uInt32 nFormat);
110 
111  virtual sal_uInt16 GetSubType() const override;
112  virtual void SetSubType(sal_uInt16 nSub) override;
113 
114  virtual double GetValue() const override;
115  virtual void SetValue( const double& rVal ) override;
116 
117  virtual OUString GetFieldName() const override;
118 
119  // Name cannot be changed.
120  virtual OUString GetPar1() const override;
121 
122  // Content.
123  virtual OUString GetPar2() const override;
124  virtual void SetPar2(const OUString& rStr) override;
125  virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhichId ) const override;
126  virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhichId ) override;
127  void dumpAsXml(xmlTextWriterPtr pWriter) const override;
128 };
129 
130 #endif // INCLUDED_SW_INC_USRFLD_HXX
131 
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 m_nType
Definition: usrfld.hxx:44
Definition: calc.hxx:184
The shared part of a user field.
Definition: usrfld.hxx:35
void EnableFormat(bool bFormat=true)
Definition: fldbas.hxx:420
std::string GetValue
sal_uInt16 GetType() const
Definition: usrfld.hxx:86
virtual std::unique_ptr< SwFieldType > Copy() const =0
Definition: doc.hxx:185
bool m_bValidValue
Definition: usrfld.hxx:37
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
virtual OUString GetPar1() const
Definition: fldbas.cxx:271
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const =0
virtual void SetPar2(const OUString &rStr)
Definition: fldbas.cxx:289
double m_nValue
Float value type.
Definition: usrfld.hxx:40
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhichId)
Definition: fldbas.cxx:314
bool IsDeleted() const
Definition: usrfld.hxx:66
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhichId) const
Definition: fldbas.cxx:301
struct _xmlTextWriter * xmlTextWriterPtr
virtual std::unique_ptr< SwField > Copy() const =0
OUString m_aContent
String value type.
Definition: usrfld.hxx:43
The non-shared part of a user field.
Definition: usrfld.hxx:101
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: fldbas.cxx:155
OUString m_aName
Definition: usrfld.hxx:41
double GetValue() const
Definition: usrfld.hxx:80
virtual OUString GetPar2() const
Definition: fldbas.cxx:276
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override
Definition: calbck.hxx:183
virtual sal_uInt16 GetSubType() const
Definition: fldbas.cxx:292
virtual void QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const
Definition: fldbas.cxx:148
Fields containing values that have to be formatted via number formatter.
Definition: fldbas.hxx:399
bool IsValid() const
Definition: usrfld.hxx:77
virtual OUString GetName() const
Only in derived classes.
Definition: fldbas.cxx:143
void SetDeleted(bool b)
Definition: usrfld.hxx:67
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: fldbas.cxx:624
void SetValue(const double nVal)
Definition: usrfld.hxx:83
virtual void PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich)
Definition: fldbas.cxx:151
virtual OUString GetFieldName() const
get name or content
Definition: fldbas.cxx:255
const SwGetSetExpType GSE_STRING
String.
Definition: fldbas.hxx:196
virtual void SetValue(const double &rVal)
Definition: fldbas.cxx:680
virtual void SetSubType(sal_uInt16)
Definition: fldbas.cxx:297
virtual double GetValue() const
Definition: fldbas.cxx:675
void SetType(sal_uInt16)
Definition: usrfld.hxx:89
sal_uInt16 m_nSubType
Definition: usrfld.hxx:103