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);
236
242{
243 css::uno::WeakReference<css::beans::XPropertySet> m_wXFieldMaster;
244
246
247 friend void FinitUI();
248 static std::vector<OUString>* s_pFieldNames;
249
250 static void GetFieldName_();
251
252protected:
254 explicit SwFieldType( SwFieldIds nWhichId );
255
256public:
257
258 SAL_DLLPRIVATE css::uno::WeakReference<css::beans::XPropertySet> const& GetXObject() const {
259 return m_wXFieldMaster;
260 }
261 SAL_DLLPRIVATE void SetXObject(css::uno::Reference<css::beans::XPropertySet> const& xFieldMaster) {
262 m_wXFieldMaster = xFieldMaster;
263 }
264
265 static const OUString & GetTypeStr( SwFieldTypesEnum nTypeId );
266
268 virtual OUString GetName() const;
269 virtual std::unique_ptr<SwFieldType> Copy() const = 0;
270 virtual void QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const;
271 virtual void PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich );
272
273 SwFieldIds Which() const { return m_nWhich; }
274
275 void PrintHiddenPara();
276 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
277 SwFormatField* FindFormatForField(const SwField*) const;
278 SwFormatField* FindFormatForPostItId(sal_uInt32 nPostItId) const;
279 void CollectPostIts(std::vector<SwFormatField*>& rvFormatFields, IDocumentRedlineAccess const& rIDRA, bool HideRedlines);
280 bool HasHiddenInformationNotes() const;
281 void GatherNodeIndex(std::vector<SwNodeOffset>& rvNodeIndex);
282 void GatherRefFields(std::vector<SwGetRefField*>& rvRFields, const sal_uInt16 nTyp);
283 void GatherFields(std::vector<SwFormatField*>& rvFormatFields, bool bCollectOnlyInDocNodes=true) const;
284 void GatherDdeTables(std::vector<SwDDETable*>& rvTables) const;
285 virtual void UpdateFields();
286};
287
292{
293private:
294 mutable OUString m_Cache;
296 sal_uInt32 m_nFormat;
301 OUString m_aTitle;
302
303 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const = 0;
304 virtual std::unique_ptr<SwField> Copy() const = 0;
305
306protected:
307 void SetFormat(sal_uInt32 const nSet) {
308 m_nFormat = nSet;
309 }
310
311 SwField( SwFieldType* pTyp,
312 sal_uInt32 nFormat = 0,
313 LanguageType nLang = LANGUAGE_SYSTEM,
314 bool m_bUseFieldValueCache = true );
315
316public:
317 virtual ~SwField();
318
319 SwField(SwField const &) = default;
320 SwField(SwField &&) = default;
321 SwField & operator =(SwField const &) = default;
322 SwField & operator =(SwField &&) = default;
323
324 inline SwFieldType* GetTyp() const;
325
327 virtual SwFieldType* ChgTyp( SwFieldType* );
328
339 OUString ExpandField(bool bCached, SwRootFrame const* pLayout) const;
340
342 virtual OUString GetFieldName() const;
343
344 std::unique_ptr<SwField> CopyField() const;
345
347 SwFieldIds Which() const
348#ifdef DBG_UTIL
349 ; // implemented in fldbas.cxx
350#else
351 {
352 return m_pType->Which();
353 }
354#endif
355
356 // TYP_ID
357 SwFieldTypesEnum GetTypeId() const;
358 virtual sal_uInt16 GetSubType() const;
359 virtual void SetSubType(sal_uInt16);
360
362 inline LanguageType GetLanguage() const;
363 virtual void SetLanguage(LanguageType nLng);
364
366 inline sal_uInt32 GetFormat() const;
367 virtual OUString GetPar1() const;
368 virtual OUString GetPar2() const;
369
370 virtual OUString GetFormula() const;
371
372 void ChangeFormat(sal_uInt32 n);
373 virtual void SetPar1(const OUString& rStr);
374 virtual void SetPar2(const OUString& rStr);
375
376 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhichId ) const;
377 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhichId );
378
380 bool HasClickHdl() const;
381 bool IsFixed() const;
382
383 bool IsAutomaticLanguage() const {
384 return m_bIsAutomaticLanguage;
385 }
386 void SetAutomaticLanguage(bool const bSet) {
387 m_bIsAutomaticLanguage = bSet;
388 }
389
390 virtual OUString GetDescription() const;
392 bool IsClickable() const;
393 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
394 const OUString & GetTitle() const { return m_aTitle; }
395 void SetTitle(const OUString& rTitle) { m_aTitle = rTitle; }
396};
397
399{
400 return m_pType;
401}
402
403inline sal_uInt32 SwField::GetFormat() const
404{
405 return m_nFormat;
406}
407
409{
410 return m_nLang;
411}
412
415{
416private:
419
420protected:
421 SwValueFieldType( SwDoc* pDocPtr, SwFieldIds nWhichId );
422 SwValueFieldType( const SwValueFieldType& rTyp );
423
424public:
425 SwDoc* GetDoc() const {
426 return m_pDoc;
427 }
428 void SetDoc(SwDoc* pNewDoc) {
429 m_pDoc = pNewDoc;
430 }
431
432 bool UseFormat() const {
433 return m_bUseFormat;
434 }
435 void EnableFormat(bool bFormat = true) {
436 m_bUseFormat = bFormat;
437 }
438
439 OUString ExpandValue(const double& rVal, sal_uInt32 nFormat, LanguageType nLng) const;
440 OUString DoubleToString(const double &rVal, LanguageType eLng) const;
441 OUString DoubleToString(const double &rVal, sal_uInt32 nFormat) const;
442};
443
445{
446private:
447 double m_fValue;
448
449protected:
450 SwValueField( SwValueFieldType* pFieldType, sal_uInt32 nFormat, LanguageType nLang = LANGUAGE_SYSTEM, const double fVal = 0.0 );
451 SwValueField( const SwValueField& rField );
452
453public:
454 virtual ~SwValueField() override;
455
456 virtual SwFieldType* ChgTyp( SwFieldType* ) override;
457 virtual void SetLanguage(LanguageType nLng) override;
458
459 SwDoc* GetDoc() const {
460 return static_cast<const SwValueFieldType*>(GetTyp())->GetDoc();
461 }
462
463 virtual double GetValue() const;
464 virtual void SetValue( const double& rVal );
465
466 OUString ExpandValue(const double& rVal, sal_uInt32 nFormat, LanguageType nLng) const {
467 return static_cast<SwValueFieldType*>(GetTyp())->ExpandValue(rVal, nFormat, nLng);
468 }
469
470 static sal_uInt32 GetSystemFormat(SvNumberFormatter* pFormatter, sal_uInt32 nFormat);
471 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
472};
473
475{
476private:
477 OUString m_sFormula;
478
479protected:
480 SwFormulaField( SwValueFieldType* pFieldType, sal_uInt32 nFormat, const double fVal );
481 SwFormulaField( const SwFormulaField& rField );
482
483public:
484 virtual OUString GetFormula() const override;
485 void SetFormula(const OUString& rStr);
486
487 void SetExpandedFormula(const OUString& rStr);
488 OUString GetExpandedFormula() const;
489};
490
491#endif // INCLUDED_SW_INC_FLDBAS_HXX
492
493/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _ADOUser User
struct _xmlTextWriter * xmlTextWriterPtr
Definition: doc.hxx:192
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:242
SAL_DLLPRIVATE void SetXObject(css::uno::Reference< css::beans::XPropertySet > const &xFieldMaster)
Definition: fldbas.hxx:261
SAL_DLLPRIVATE css::uno::WeakReference< css::beans::XPropertySet > const & GetXObject() const
Definition: fldbas.hxx:258
css::uno::WeakReference< css::beans::XPropertySet > m_wXFieldMaster
Definition: fldbas.hxx:243
SwFieldIds Which() const
Definition: fldbas.hxx:273
SwFieldIds m_nWhich
Definition: fldbas.hxx:245
virtual std::unique_ptr< SwFieldType > Copy() const =0
static std::vector< OUString > * s_pFieldNames
field names
Definition: fldbas.hxx:248
Base class of all fields.
Definition: fldbas.hxx:292
SwFieldType * m_pType
Definition: fldbas.hxx:295
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const =0
bool IsAutomaticLanguage() const
Definition: fldbas.hxx:383
OUString m_Cache
Cached expansion (for clipboard).
Definition: fldbas.hxx:294
OUString m_aTitle
Used for tooltip purposes when it's not-empty.
Definition: fldbas.hxx:301
void SetFormat(sal_uInt32 const nSet)
Definition: fldbas.hxx:307
sal_uInt32 m_nFormat
Definition: fldbas.hxx:296
LanguageType m_nLang
this can be either SvxNumType or SwChapterFormat depending on the subtype
Definition: fldbas.hxx:297
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
Definition: fldbas.hxx:403
SwField(SwField &&)=default
bool m_bIsAutomaticLanguage
control the usage of the cached field value
Definition: fldbas.hxx:299
void SetTitle(const OUString &rTitle)
Definition: fldbas.hxx:395
SwFieldType * GetTyp() const
Definition: fldbas.hxx:398
LanguageType GetLanguage() const
Language at field position.
Definition: fldbas.hxx:408
virtual std::unique_ptr< SwField > Copy() const =0
void SetAutomaticLanguage(bool const bSet)
Definition: fldbas.hxx:386
bool m_bUseFieldValueCache
Definition: fldbas.hxx:298
const OUString & GetTitle() const
Definition: fldbas.hxx:394
SwField(SwField const &)=default
OUString m_sFormula
Definition: fldbas.hxx:477
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
Fields containing values that have to be formatted via number formatter.
Definition: fldbas.hxx:415
bool UseFormat() const
Definition: fldbas.hxx:432
OUString ExpandValue(const double &rVal, sal_uInt32 nFormat, LanguageType nLng) const
return value formatted as string
Definition: fldbas.cxx:547
SwValueFieldType(SwDoc *pDocPtr, SwFieldIds nWhichId)
Definition: fldbas.cxx:532
void SetDoc(SwDoc *pNewDoc)
Definition: fldbas.hxx:428
OUString DoubleToString(const double &rVal, LanguageType eLng) const
Definition: fldbas.cxx:608
SwDoc * m_pDoc
Definition: fldbas.hxx:417
SwDoc * GetDoc() const
Definition: fldbas.hxx:425
bool m_bUseFormat
Use number formatter.
Definition: fldbas.hxx:418
void EnableFormat(bool bFormat=true)
Definition: fldbas.hxx:435
OUString ExpandValue(const double &rVal, sal_uInt32 nFormat, LanguageType nLng) const
Definition: fldbas.hxx:466
SwDoc * GetDoc() const
Definition: fldbas.hxx:459
double m_fValue
Definition: fldbas.hxx:447
BroadcasterMixin & operator=(const BroadcasterMixin &)
Definition: calbck.hxx:97
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
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