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
24class SfxPoolItem;
25class SwCalc;
26class 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;
45 sal_uInt16 m_nType;
46
47public:
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 ) const;
56 void SetContent( const OUString& rStr, sal_uInt32 nFormat = 0 );
57
58 OUString GetInputOrDateTime( sal_uInt32 nFormat ) const;
59
60 inline bool IsValid() const;
61
62 double GetValue(SwCalc& rCalc); // Recalculate member nValue.
63 inline double GetValue() const;
64 inline void SetValue(const double nVal);
65
66 inline sal_uInt16 GetType() const;
67 inline void SetType(sal_uInt16);
68
69 bool IsDeleted() const { return m_bDeleted; }
70 void SetDeleted( bool b ) { m_bDeleted = b; }
71
72 virtual void QueryValue( css::uno::Any& rVal, sal_uInt16 nMId ) const override;
73 virtual void PutValue( const css::uno::Any& rVal, sal_uInt16 nMId ) override;
74 void EnsureValid();
75 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
76
77private:
78 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
79};
80
81inline bool SwUserFieldType::IsValid() const
82 { return m_bValidValue; }
83
84inline double SwUserFieldType::GetValue() const
85 { return m_nValue; }
86
87inline void SwUserFieldType::SetValue(const double nVal)
88 { m_nValue = nVal; }
89
90inline sal_uInt16 SwUserFieldType::GetType() const
91 { return m_nType; }
92
93inline void SwUserFieldType::SetType(sal_uInt16 nSub)
94{
95 m_nType = nSub;
97}
98
105class SwUserField final : public SwValueField
106{
107 sal_uInt16 m_nSubType;
108
109 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override;
110 virtual std::unique_ptr<SwField> Copy() const override;
111
112public:
113 SwUserField(SwUserFieldType*, sal_uInt16 nSub, sal_uInt32 nFormat);
114
115 virtual sal_uInt16 GetSubType() const override;
116 virtual void SetSubType(sal_uInt16 nSub) override;
117
118 virtual double GetValue() const override;
119 virtual void SetValue( const double& rVal ) override;
120
121 virtual OUString GetFieldName() const override;
122
123 // Name cannot be changed.
124 virtual OUString GetPar1() const override;
125
126 // Content.
127 virtual OUString GetPar2() const override;
128 virtual void SetPar2(const OUString& rStr) override;
129 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhichId ) const override;
130 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhichId ) override;
131 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
132};
133
134/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: calc.hxx:200
Definition: doc.hxx:197
virtual OUString GetName() const
Only in derived classes.
Definition: fldbas.cxx:139
virtual void QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const
Definition: fldbas.cxx:144
virtual void PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich)
Definition: fldbas.cxx:147
virtual std::unique_ptr< SwFieldType > Copy() const =0
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: fldbas.cxx:157
The root element of a Writer document layout.
Definition: rootfrm.hxx:85
The shared part of a user field.
Definition: usrfld.hxx:35
OUString m_aContentLang
Language used by m_aContents.
Definition: usrfld.hxx:44
bool m_bValidValue
Definition: usrfld.hxx:36
OUString m_aName
Definition: usrfld.hxx:40
bool IsDeleted() const
Definition: usrfld.hxx:69
void SetValue(const double nVal)
Definition: usrfld.hxx:87
bool m_bDeleted
Definition: usrfld.hxx:37
sal_uInt16 GetType() const
Definition: usrfld.hxx:90
OUString m_aContent
String value type.
Definition: usrfld.hxx:42
double GetValue() const
Definition: usrfld.hxx:84
void SetType(sal_uInt16)
Definition: usrfld.hxx:93
sal_uInt16 m_nType
Definition: usrfld.hxx:45
double m_nValue
Float value type.
Definition: usrfld.hxx:39
bool IsValid() const
Definition: usrfld.hxx:81
void SetDeleted(bool b)
Definition: usrfld.hxx:70
The non-shared part of a user field.
Definition: usrfld.hxx:106
virtual OUString GetPar2() const override
Get content.
Definition: usrfld.cxx:99
virtual sal_uInt16 GetSubType() const override
Definition: usrfld.cxx:109
virtual OUString GetPar1() const override
Get name.
Definition: usrfld.cxx:93
virtual double GetValue() const override
Definition: usrfld.cxx:82
sal_uInt16 m_nSubType
Definition: usrfld.hxx:107
virtual void SetSubType(sal_uInt16 nSub) override
Definition: usrfld.cxx:114
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhichId) const override
Definition: usrfld.cxx:120
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: usrfld.cxx:168
SwUserField(SwUserFieldType *, sal_uInt16 nSub, sal_uInt32 nFormat)
Definition: usrfld.cxx:53
virtual std::unique_ptr< SwField > Copy() const override
Definition: usrfld.cxx:67
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhichId) override
Definition: usrfld.cxx:139
virtual OUString GetFieldName() const override
get name or content
Definition: usrfld.cxx:75
virtual void SetValue(const double &rVal) override
Definition: usrfld.cxx:87
virtual void SetPar2(const OUString &rStr) override
Definition: usrfld.cxx:104
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: usrfld.cxx:59
Fields containing values that have to be formatted via number formatter.
Definition: fldbas.hxx:419
OUString GetInputOrDateTime(const OUString &rInput, const double &rVal, sal_uInt32 nFormat) const
Query input or formatted value for dialog.
Definition: fldbas.cxx:660
void EnableFormat(bool bFormat=true)
Definition: fldbas.hxx:439
struct _xmlTextWriter * xmlTextWriterPtr
virtual void SetValue(tools::Long nNew) override
const SwGetSetExpType GSE_STRING
String.
Definition: fldbas.hxx:207
const char GetValue[]
#define SW_DLLPUBLIC
Definition: swdllapi.h:28