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 #pragma once
20 
21 #include "swdllapi.h"
22 #include "fldbas.hxx"
23 
24 class SfxPoolItem;
25 class SwCalc;
26 class SwDoc;
27 
35 {
36  bool m_bValidValue : 1;
37  bool m_bDeleted : 1;
39  double m_nValue;
40  OUString m_aName;
42  OUString m_aContent;
44  OUString m_aContentLang;
45  sal_uInt16 m_nType;
46 
47 public:
48  SwUserFieldType( SwDoc* pDocPtr, const OUString& );
49 
50  virtual OUString GetName() const override;
51  virtual std::unique_ptr<SwFieldType> Copy() const override;
52 
53  OUString Expand(sal_uInt32 nFormat, sal_uInt16 nSubType, LanguageType nLng);
54 
55  OUString GetContent( sal_uInt32 nFormat = 0 );
56  void SetContent( const OUString& rStr, sal_uInt32 nFormat = 0 );
57 
58  inline bool IsValid() const;
59 
60  double GetValue(SwCalc& rCalc); // Recalculate member nValue.
61  inline double GetValue() const;
62  inline void SetValue(const double nVal);
63 
64  inline sal_uInt16 GetType() const;
65  inline void SetType(sal_uInt16);
66 
67  bool IsDeleted() const { return m_bDeleted; }
68  void SetDeleted( bool b ) { m_bDeleted = b; }
69 
70  virtual void QueryValue( css::uno::Any& rVal, sal_uInt16 nMId ) const override;
71  virtual void PutValue( const css::uno::Any& rVal, sal_uInt16 nMId ) override;
72  void dumpAsXml(xmlTextWriterPtr pWriter) const override;
73 
74 private:
75  virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
76 };
77 
78 inline bool SwUserFieldType::IsValid() const
79  { return m_bValidValue; }
80 
81 inline double SwUserFieldType::GetValue() const
82  { return m_nValue; }
83 
84 inline void SwUserFieldType::SetValue(const double nVal)
85  { m_nValue = nVal; }
86 
87 inline sal_uInt16 SwUserFieldType::GetType() const
88  { return m_nType; }
89 
90 inline void SwUserFieldType::SetType(sal_uInt16 nSub)
91 {
92  m_nType = nSub;
94 }
95 
102 class SwUserField final : public SwValueField
103 {
104  sal_uInt16 m_nSubType;
105 
106  virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override;
107  virtual std::unique_ptr<SwField> Copy() const override;
108 
109 public:
110  SwUserField(SwUserFieldType*, sal_uInt16 nSub, sal_uInt32 nFormat);
111 
112  virtual sal_uInt16 GetSubType() const override;
113  virtual void SetSubType(sal_uInt16 nSub) override;
114 
115  virtual double GetValue() const override;
116  virtual void SetValue( const double& rVal ) override;
117 
118  virtual OUString GetFieldName() const override;
119 
120  // Name cannot be changed.
121  virtual OUString GetPar1() const override;
122 
123  // Content.
124  virtual OUString GetPar2() const override;
125  virtual void SetPar2(const OUString& rStr) override;
126  virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhichId ) const override;
127  virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhichId ) override;
128  void dumpAsXml(xmlTextWriterPtr pWriter) const override;
129 };
130 
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 m_nType
Definition: usrfld.hxx:45
OUString m_aContentLang
Language used by m_aContents.
Definition: usrfld.hxx:44
Definition: calc.hxx:192
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: usrfld.cxx:60
The shared part of a user field.
Definition: usrfld.hxx:34
virtual double GetValue() const override
Definition: usrfld.cxx:82
virtual OUString GetPar2() const override
Get content.
Definition: usrfld.cxx:99
void EnableFormat(bool bFormat=true)
Definition: fldbas.hxx:429
std::string GetValue
sal_uInt16 GetType() const
Definition: usrfld.hxx:87
virtual std::unique_ptr< SwFieldType > Copy() const =0
Definition: doc.hxx:188
bool m_bValidValue
Definition: usrfld.hxx:36
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
double m_nValue
Float value type.
Definition: usrfld.hxx:39
bool IsDeleted() const
Definition: usrfld.hxx:67
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhichId) const override
Definition: usrfld.cxx:120
virtual OUString GetFieldName() const override
get name or content
Definition: usrfld.cxx:75
struct _xmlTextWriter * xmlTextWriterPtr
virtual std::unique_ptr< SwField > Copy() const override
Definition: usrfld.cxx:68
OUString m_aContent
String value type.
Definition: usrfld.hxx:42
The non-shared part of a user field.
Definition: usrfld.hxx:102
virtual void SetPar2(const OUString &rStr) override
Definition: usrfld.cxx:104
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: fldbas.cxx:160
OUString m_aName
Definition: usrfld.hxx:40
double GetValue() const
Definition: usrfld.hxx:81
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
virtual void SetValue(const double &rVal) override
Definition: usrfld.cxx:87
virtual void QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const
Definition: fldbas.cxx:142
virtual OUString GetPar1() const override
Get name.
Definition: usrfld.cxx:93
SwUserField(SwUserFieldType *, sal_uInt16 nSub, sal_uInt32 nFormat)
Definition: usrfld.cxx:54
Fields containing values that have to be formatted via number formatter.
Definition: fldbas.hxx:408
bool IsValid() const
Definition: usrfld.hxx:78
virtual sal_uInt16 GetSubType() const override
Definition: usrfld.cxx:109
virtual OUString GetName() const
Only in derived classes.
Definition: fldbas.cxx:137
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: usrfld.cxx:168
void SetDeleted(bool b)
Definition: usrfld.hxx:68
void SetValue(const double nVal)
Definition: usrfld.hxx:84
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhichId) override
Definition: usrfld.cxx:139
virtual void PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich)
Definition: fldbas.cxx:145
virtual void SetSubType(sal_uInt16 nSub) override
Definition: usrfld.cxx:114
const SwGetSetExpType GSE_STRING
String.
Definition: fldbas.hxx:202
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: calbck.cxx:304
void SetType(sal_uInt16)
Definition: usrfld.hxx:90
sal_uInt16 m_nSubType
Definition: usrfld.hxx:104