LibreOffice Module sw (master) 1
fldbas.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_FLDBAS_HXX
20#define INCLUDED_SW_INC_FLDBAS_HXX
21
22#include <i18nlangtag/lang.h>
23#include "swdllapi.h"
24#include "calbck.hxx"
25#include "nodeoffset.hxx"
26
27#include <com/sun/star/beans/XPropertySet.hpp>
29#include <editeng/svxenum.hxx>
30#include <vector>
31#include <climits>
32
33class SwDoc;
34class SwField;
35class SwFormatField;
36class SwDDETable;
37class SwRootFrame;
40class SwGetRefField;
41namespace com::sun::star::uno { class Any; }
42
43typedef struct _xmlTextWriter* xmlTextWriterPtr;
44
45enum class SwFieldIds : sal_uInt16 {
48 User,
51 Date,
52 Time,
54 Author,
55 Chapter,
56 DocStat,
57 GetExp, // 10
58 SetExp,
59 GetRef,
61 Postit,
62 FixDate,
63 FixTime,
64 Reg,
65 VarReg,
66 SetRef,
67 Input, // 20
68 Macro,
69 Dde,
70 Table,
72 DocInfo,
77 ExtUser, // 30
82 Script,
89
90 Unknown = USHRT_MAX, // used as default value in some method calls
91};
92
94enum class SwFieldTypesEnum : sal_uInt16 {
95 Begin,
96 Date = Begin, // 0
97 Time,
100 Chapter,
103 Author,
104 Set,
105 Get,
106 Formel, // 10
108 SetRef,
109 GetRef,
110 DDE,
111 Macro,
112 Input,
115 Database,
116 User, // 20
117 Postit,
119 Sequence,
124 NextPage,
126 ExtendedUser, // 30
127 FixedDate,
128 FixedTime,
129 SetInput,
130 UserInput,
133 Internet,
134 JumpEdit,
135 Script,
136 Authority, // 40
138 Dropdown,
139 Custom, // Unused - necessary for alignment with aSwFields in fldmgr.cxx
141 LAST,
142 Unknown = USHRT_MAX // used by SwFieldMgr::GetCurTypeId
143};
162 FF_FIXED = 0x8000
164
166 VVF_CMD = 0x0010,
167 VVF_INVISIBLE = 0x0040,
168 VVF_XXP = 0x0400,
169 VVF_XX_XXP = 0x0800,
170 VVF_CLEAR = 0x000f,
171
172// From here new formats:
173 VVF_SYS = 0x2000,
174 VVF_X = 0x2100,
175 VVF_X_X = 0x2200,
176 VVF_X_XX = 0x2300,
177 VVF_XX_X = 0x2400,
178 VVF_XX_XX = 0x2500,
179 VVF_XX_XXX = 0x2600,
180 VVF_SYS_CUR = 0x2700,
181 VVF_CUR_X = 0x2800,
182 VVF_CUR_XX_XX = 0x2900,
183 VVF_CUR_XX_X0 = 0x2a00,
184 VVF_X_CUR = 0x2b00,
185 VVF_XX_XX_CUR = 0x2c00,
186 VVF_XX_X0_CUR = 0x2d00,
197
199
200typedef sal_uInt16 SwGetSetExpType;
202{
204const SwGetSetExpType GSE_EXPR = 0x0002;
205const SwGetSetExpType GSE_SEQ = 0x0008;
207}
208
209typedef sal_uInt16 SwExtendedSubType;
211{
215}
216
218 INP_TXT = 0x01,
219 INP_USR = 0x02,
220 INP_VAR = 0x03
222
224 UF_STRING = 0x01,
225 UF_EXPR = 0x02
227
231 TIMEFLD = 4
233
235OUString FormatNumber(sal_uInt32 nNum, SvxNumType nFormat, LanguageType nLang = LANGUAGE_NONE);
236SwFieldTypesEnum SwFieldTypeFromString(std::u16string_view rString);
237
242class SW_DLLPUBLIC SwFieldType : public sw::BroadcastingModify
243{
244 css::uno::WeakReference<css::beans::XPropertySet> m_wXFieldMaster;
245
247
248 friend void FinitUI();
249 static std::vector<OUString>* s_pFieldNames;
250
251 static void GetFieldName_();
252
253protected:
255 explicit SwFieldType( SwFieldIds nWhichId );
256
257public:
258
259 SAL_DLLPRIVATE css::uno::WeakReference<css::beans::XPropertySet> const& GetXObject() const {
260 return m_wXFieldMaster;
261 }
262 SAL_DLLPRIVATE void SetXObject(css::uno::Reference<css::beans::XPropertySet> const& xFieldMaster) {
263 m_wXFieldMaster = xFieldMaster;
264 }
265
266 static const OUString & GetTypeStr( SwFieldTypesEnum nTypeId );
267
269 virtual OUString GetName() const;
270 virtual std::unique_ptr<SwFieldType> Copy() const = 0;
271 virtual void QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const;
272 virtual void PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich );
273
274 SwFieldIds Which() const { return m_nWhich; }
275
276 void PrintHiddenPara();
277 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
278 SwFormatField* FindFormatForField(const SwField*) const;
279 SwFormatField* FindFormatForPostItId(sal_uInt32 nPostItId) const;
280 void CollectPostIts(std::vector<SwFormatField*>& rvFormatFields, IDocumentRedlineAccess const& rIDRA, bool HideRedlines);
281 bool HasHiddenInformationNotes() const;
282 void GatherNodeIndex(std::vector<SwNodeOffset>& rvNodeIndex);
283 void GatherRefFields(std::vector<SwGetRefField*>& rvRFields, const sal_uInt16 nTyp);
284 void GatherFields(std::vector<SwFormatField*>& rvFormatFields, bool bCollectOnlyInDocNodes=true) const;
285 void GatherDdeTables(std::vector<SwDDETable*>& rvTables) const;
286 virtual void UpdateFields();
287};
288
293{
294private:
295 mutable OUString m_Cache;
297 sal_uInt32 m_nFormat;
302 OUString m_aTitle;
303
304 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const = 0;
305 virtual std::unique_ptr<SwField> Copy() const = 0;
306
307protected:
308 void SetFormat(sal_uInt32 const nSet) {
309 m_nFormat = nSet;
310 }
311
312 SwField( SwFieldType* pTyp,
313 sal_uInt32 nFormat = 0,
314 LanguageType nLang = LANGUAGE_SYSTEM,
315 bool m_bUseFieldValueCache = true );
316
317public:
318 virtual ~SwField();
319
320 SwField(SwField const &) = default;
321 SwField(SwField &&) = default;
322 SwField & operator =(SwField const &) = default;
323 SwField & operator =(SwField &&) = default;
324
325 inline SwFieldType* GetTyp() const;
326
328 virtual SwFieldType* ChgTyp( SwFieldType* );
329
340 OUString ExpandField(bool bCached, SwRootFrame const* pLayout) const;
341
343 virtual OUString GetFieldName() const;
344
345 std::unique_ptr<SwField> CopyField() const;
346
348 SwFieldIds Which() const
349#ifdef DBG_UTIL
350 ; // implemented in fldbas.cxx
351#else
352 {
353 return m_pType->Which();
354 }
355#endif
356
357 // TYP_ID
358 SwFieldTypesEnum GetTypeId() const;
359 virtual sal_uInt16 GetSubType() const;
360 virtual void SetSubType(sal_uInt16);
361
363 inline LanguageType GetLanguage() const;
364 virtual void SetLanguage(LanguageType nLng);
365
367 inline sal_uInt32 GetFormat() const;
368 virtual OUString GetPar1() const;
369 virtual OUString GetPar2() const;
370
371 virtual OUString GetFormula() const;
372
373 void ChangeFormat(sal_uInt32 n);
374 virtual void SetPar1(const OUString& rStr);
375 virtual void SetPar2(const OUString& rStr);
376
377 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhichId ) const;
378 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhichId );
379
381 bool HasClickHdl() const;
382 bool IsFixed() const;
383
384 bool IsAutomaticLanguage() const {
385 return m_bIsAutomaticLanguage;
386 }
387 void SetAutomaticLanguage(bool const bSet) {
388 m_bIsAutomaticLanguage = bSet;
389 }
390
391 virtual OUString GetDescription() const;
393 bool IsClickable() const;
394 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
395 const OUString & GetTitle() const { return m_aTitle; }
396 void SetTitle(const OUString& rTitle) { m_aTitle = rTitle; }
397};
398
400{
401 return m_pType;
402}
403
404inline sal_uInt32 SwField::GetFormat() const
405{
406 return m_nFormat;
407}
408
410{
411 return m_nLang;
412}
413
416{
417private:
420
421protected:
422 SwValueFieldType( SwDoc* pDocPtr, SwFieldIds nWhichId );
423 SwValueFieldType( const SwValueFieldType& rTyp );
424
425public:
426 SwDoc* GetDoc() const {
427 return m_pDoc;
428 }
429 void SetDoc(SwDoc* pNewDoc) {
430 m_pDoc = pNewDoc;
431 }
432
433 bool UseFormat() const {
434 return m_bUseFormat;
435 }
436 void EnableFormat(bool bFormat = true) {
437 m_bUseFormat = bFormat;
438 }
439
440 OUString ExpandValue(const double& rVal, sal_uInt32 nFormat, LanguageType nLng) const;
441 OUString DoubleToString(const double &rVal, LanguageType eLng) const;
442 OUString DoubleToString(const double &rVal, sal_uInt32 nFormat) const;
443};
444
446{
447private:
448 double m_fValue;
449
450protected:
451 SwValueField( SwValueFieldType* pFieldType, sal_uInt32 nFormat, LanguageType nLang = LANGUAGE_SYSTEM, const double fVal = 0.0 );
452 SwValueField( const SwValueField& rField );
453
454public:
455 virtual ~SwValueField() override;
456
457 virtual SwFieldType* ChgTyp( SwFieldType* ) override;
458 virtual void SetLanguage(LanguageType nLng) override;
459
460 SwDoc* GetDoc() const {
461 return static_cast<const SwValueFieldType*>(GetTyp())->GetDoc();
462 }
463
464 virtual double GetValue() const;
465 virtual void SetValue( const double& rVal );
466
467 OUString ExpandValue(const double& rVal, sal_uInt32 nFormat, LanguageType nLng) const {
468 return static_cast<SwValueFieldType*>(GetTyp())->ExpandValue(rVal, nFormat, nLng);
469 }
470
471 static sal_uInt32 GetSystemFormat(SvNumberFormatter* pFormatter, sal_uInt32 nFormat);
472 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
473};
474
476{
477private:
478 OUString m_sFormula;
479
480protected:
481 SwFormulaField( SwValueFieldType* pFieldType, sal_uInt32 nFormat, const double fVal );
482 SwFormulaField( const SwFormulaField& rField );
483
484public:
485 virtual OUString GetFormula() const override;
486 void SetFormula(const OUString& rStr);
487
488 void SetExpandedFormula(const OUString& rStr);
489 OUString GetExpandedFormula() const;
490};
491
492#endif // INCLUDED_SW_INC_FLDBAS_HXX
493
494/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _ADOUser User
struct _xmlTextWriter * xmlTextWriterPtr
Definition: doc.hxx:195
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:243
SAL_DLLPRIVATE void SetXObject(css::uno::Reference< css::beans::XPropertySet > const &xFieldMaster)
Definition: fldbas.hxx:262
SAL_DLLPRIVATE css::uno::WeakReference< css::beans::XPropertySet > const & GetXObject() const
Definition: fldbas.hxx:259
css::uno::WeakReference< css::beans::XPropertySet > m_wXFieldMaster
Definition: fldbas.hxx:244
SwFieldIds Which() const
Definition: fldbas.hxx:274
SwFieldIds m_nWhich
Definition: fldbas.hxx:246
virtual std::unique_ptr< SwFieldType > Copy() const =0
static std::vector< OUString > * s_pFieldNames
field names
Definition: fldbas.hxx:249
Base class of all fields.
Definition: fldbas.hxx:293
SwFieldType * m_pType
Definition: fldbas.hxx:296
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const =0
bool IsAutomaticLanguage() const
Definition: fldbas.hxx:384
OUString m_Cache
Cached expansion (for clipboard).
Definition: fldbas.hxx:295
OUString m_aTitle
Used for tooltip purposes when it's not-empty.
Definition: fldbas.hxx:302
void SetFormat(sal_uInt32 const nSet)
Definition: fldbas.hxx:308
sal_uInt32 m_nFormat
Definition: fldbas.hxx:297
LanguageType m_nLang
this can be either SvxNumType or SwChapterFormat depending on the subtype
Definition: fldbas.hxx:298
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
Definition: fldbas.hxx:404
SwField(SwField &&)=default
bool m_bIsAutomaticLanguage
control the usage of the cached field value
Definition: fldbas.hxx:300
void SetTitle(const OUString &rTitle)
Definition: fldbas.hxx:396
SwFieldType * GetTyp() const
Definition: fldbas.hxx:399
LanguageType GetLanguage() const
Language at field position.
Definition: fldbas.hxx:409
virtual std::unique_ptr< SwField > Copy() const =0
void SetAutomaticLanguage(bool const bSet)
Definition: fldbas.hxx:387
bool m_bUseFieldValueCache
Definition: fldbas.hxx:299
const OUString & GetTitle() const
Definition: fldbas.hxx:395
SwField(SwField const &)=default
OUString m_sFormula
Definition: fldbas.hxx:478
The root element of a Writer document layout.
Definition: rootfrm.hxx:83
Fields containing values that have to be formatted via number formatter.
Definition: fldbas.hxx:416
bool UseFormat() const
Definition: fldbas.hxx:433
OUString ExpandValue(const double &rVal, sal_uInt32 nFormat, LanguageType nLng) const
return value formatted as string
Definition: fldbas.cxx:578
SwValueFieldType(SwDoc *pDocPtr, SwFieldIds nWhichId)
Definition: fldbas.cxx:563
void SetDoc(SwDoc *pNewDoc)
Definition: fldbas.hxx:429
OUString DoubleToString(const double &rVal, LanguageType eLng) const
Definition: fldbas.cxx:639
SwDoc * m_pDoc
Definition: fldbas.hxx:418
SwDoc * GetDoc() const
Definition: fldbas.hxx:426
bool m_bUseFormat
Use number formatter.
Definition: fldbas.hxx:419
void EnableFormat(bool bFormat=true)
Definition: fldbas.hxx:436
OUString ExpandValue(const double &rVal, sal_uInt32 nFormat, LanguageType nLng) const
Definition: fldbas.hxx:467
SwDoc * GetDoc() const
Definition: fldbas.hxx:460
double m_fValue
Definition: fldbas.hxx:448
virtual OUString GetName() const override
virtual void GetDescription(OUString &rName) override
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
virtual void SetValue(tools::Long nNew) override
SwFieldTypesEnum
List of FieldTypes at UI.
Definition: fldbas.hxx:94
OUString FormatNumber(sal_uInt32 nNum, SvxNumType nFormat, LanguageType nLang=LANGUAGE_NONE)
General tools.
Definition: fldbas.cxx:516
SwAttrFieldType
Definition: fldbas.hxx:144
@ ATTR_PAGENUMBERFLD
Definition: fldbas.hxx:148
@ ATTR_DATEFLD
Definition: fldbas.hxx:146
@ ATTR_BOOKMARKFLD
Definition: fldbas.hxx:150
@ ATTR_NONE
Definition: fldbas.hxx:145
@ ATTR_SETREFATTRFLD
Definition: fldbas.hxx:151
@ ATTR_PAGECOUNTFLD
Definition: fldbas.hxx:149
@ ATTR_TIMEFLD
Definition: fldbas.hxx:147
SwUserType
Definition: fldbas.hxx:223
@ UF_STRING
Definition: fldbas.hxx:224
@ UF_EXPR
Definition: fldbas.hxx:225
SwFileNameFormat
Definition: fldbas.hxx:153
@ FF_UI_RANGE
Definition: fldbas.hxx:160
@ FF_UI_NAME
Definition: fldbas.hxx:159
@ FF_FIXED
Definition: fldbas.hxx:162
@ FF_NAME_NOEXT
Definition: fldbas.hxx:158
@ FF_BEGIN
Definition: fldbas.hxx:154
@ FF_PATH
Definition: fldbas.hxx:157
@ FF_END
Definition: fldbas.hxx:161
@ FF_NAME
Definition: fldbas.hxx:155
@ FF_PATHNAME
Definition: fldbas.hxx:156
SwDateTimeSubType
Definition: fldbas.hxx:228
@ FIXEDFLD
Definition: fldbas.hxx:229
@ DATEFLD
Definition: fldbas.hxx:230
@ TIMEFLD
Definition: fldbas.hxx:231
sal_uInt16 SwExtendedSubType
Definition: fldbas.hxx:209
struct _xmlTextWriter * xmlTextWriterPtr
Definition: fldbas.hxx:43
SwVarFormat
Definition: fldbas.hxx:165
@ VVF_XX_XXX
1.234.567
Definition: fldbas.hxx:179
@ VVF_CUR_XX_X0
EUR 1234.56 EUR 1234.–.
Definition: fldbas.hxx:183
@ VVF_XX_X0_CUR
1234.56 EUR 1234.
Definition: fldbas.hxx:186
@ VF_XX_XX
Definition: fldbas.hxx:194
@ VF_CMD
Compatibility:
Definition: fldbas.hxx:188
@ VVF_XX_XX
1.234.56
Definition: fldbas.hxx:178
@ VVF_CMD
Show command.
Definition: fldbas.hxx:166
@ VF_CLEAR
Definition: fldbas.hxx:196
@ VVF_SYS_CUR
Format for currency from system.
Definition: fldbas.hxx:180
@ VF_XXP
Definition: fldbas.hxx:190
@ VVF_X
1234
Definition: fldbas.hxx:174
@ VVF_INVISIBLE
Invisible.
Definition: fldbas.hxx:167
@ VVF_X_CUR
1234 EUR
Definition: fldbas.hxx:184
@ VVF_SYS
Format for numbers from system.
Definition: fldbas.hxx:173
@ VF_XX_XX_CUR
Definition: fldbas.hxx:195
@ VF_XX
Definition: fldbas.hxx:193
@ VVF_CUR_X
EUR 1234.
Definition: fldbas.hxx:181
@ VVF_X_XX
1245.56
Definition: fldbas.hxx:176
@ VVF_XX_XX_CUR
1234.56 EUR 1234.00 EUR
Definition: fldbas.hxx:185
@ VF_INVISIBLE
Definition: fldbas.hxx:189
@ VVF_CLEAR
Definition: fldbas.hxx:170
@ VVF_CUR_XX_XX
EUR 1234.56 EUR 1234.00.
Definition: fldbas.hxx:182
@ VF_XX_XXP
Definition: fldbas.hxx:191
@ VVF_X_X
1234.5
Definition: fldbas.hxx:175
@ VF_VISIBLE
Definition: fldbas.hxx:192
@ VVF_XX_XXP
1.234,56%
Definition: fldbas.hxx:169
@ VVF_XXP
1234%
Definition: fldbas.hxx:168
@ VVF_XX_X
1.234.5
Definition: fldbas.hxx:177
sal_uInt16 SwGetSetExpType
Definition: fldbas.hxx:200
SwInputFieldSubType
Definition: fldbas.hxx:217
@ INP_VAR
Definition: fldbas.hxx:220
@ INP_USR
Definition: fldbas.hxx:219
@ INP_TXT
Definition: fldbas.hxx:218
SwFieldIds
Definition: fldbas.hxx:45
@ ParagraphSignature
@ TableOfAuthorities
SwFieldTypesEnum SwFieldTypeFromString(std::u16string_view rString)
Definition: fldbas.cxx:532
void FinitUI()
Definition: initui.cxx:68
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
def Input(s)
void SetLanguage(SwWrtShell &rWrtSh, std::u16string_view rLangText, bool bIsForSelection, SfxItemSet &rCoreSet)
Definition: langhelper.cxx:214
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
Definition: langhelper.cxx:390
@ Sequence
Unknown
const SwExtendedSubType SUB_CMD
Show command.
Definition: fldbas.hxx:212
const SwExtendedSubType SUB_INVISIBLE
Invisible.
Definition: fldbas.hxx:213
const SwExtendedSubType SUB_OWN_FMT
SwDBField: Don't accept formatting from database.
Definition: fldbas.hxx:214
const SwGetSetExpType GSE_SEQ
Sequence.
Definition: fldbas.hxx:205
const SwGetSetExpType GSE_EXPR
Expression.
Definition: fldbas.hxx:204
const SwGetSetExpType GSE_FORMULA
Formula.
Definition: fldbas.hxx:206
const SwGetSetExpType GSE_STRING
String.
Definition: fldbas.hxx:203
sal_uInt16 const m_nFormat
const char GetValue[]
static LanguageType nLang
Definition: srtdlg.cxx:51
SvxNumType
#define SW_DLLPUBLIC
Definition: swdllapi.h:28