Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/inc/docufld.hxx
Line
Count
Source
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 <sal/config.h>
22
23
#include <config_collab.h>
24
25
#include <string_view>
26
27
#include <editeng/outlobj.hxx>
28
#include <tools/solar.h>
29
#include <tools/date.hxx>
30
#include <tools/datetime.hxx>
31
#include <rtl/ref.hxx>
32
#include <svl/macitem.hxx>
33
34
#include "fldbas.hxx"
35
#include "names.hxx"
36
37
class SetGetExpFields;
38
class SwTextField;
39
class SwFrame;
40
class SwTextAPIObject;
41
class SwCharFormat;
42
43
enum class SwAuthorFormat : sal_uInt32
44
{
45
    // most of the constants are a regular enum
46
    Name,
47
    Shortcut,
48
    Mask = Name | Shortcut, // mask off the enum part
49
    // except for this, which is a flag
50
    Fixed = 0x8000
51
};
52
namespace o3tl { template<> struct typed_flags<SwAuthorFormat> : is_typed_flags<SwAuthorFormat, 0x8003> {}; }
53
54
// Subtype of document statistics.
55
enum class SwDocStatSubType : sal_uInt16
56
{
57
    Page,
58
    // page count in current section
59
    PageRange,
60
    Paragraph,
61
    Word,
62
    Character,
63
    Table,
64
    Graphic,
65
    OLE
66
};
67
68
enum class SwDocInfoSubType : sal_uInt16
69
{
70
    /** NB: these must denote consecutive integers!
71
     NB2: these are extended by 4 DI_INFO values for backward compatibility
72
          in filter/html/htmlfld.cxx, so make sure that DI_SUBTYPE_END
73
          really is the end, and is at least 4 less than DI_SUB_*! */
74
    SubtypeBegin =  0,
75
    Title         = SubtypeBegin,
76
    Subject       =  1,
77
    Keys          =  2,
78
    Comment       =  3,
79
    Create        =  4,
80
    Change        =  5,
81
    Print         =  6,
82
    DocNo         =  7,
83
    Edit          =  8,
84
    Custom        =  9,
85
    SubtypeEnd    = 10,
86
    LowerMask     = 0x00ff,
87
    UpperMask     = 0xff00,
88
89
    // UGLY: these are necessary for importing document info fields written by
90
    //       older versions of OOo (< 3.0) which did not have Custom fields
91
    Info1         =  SubtypeEnd + 1,
92
    Info2         =  SubtypeEnd + 2,
93
    Info3         =  SubtypeEnd + 3,
94
    Info4         =  SubtypeEnd + 4,
95
96
    SubAuthor     = 0x0100,
97
    SubTime       = 0x0200,
98
    SubDate       = 0x0300,
99
    SubFixed      = 0x1000,
100
    // SubSoftFixed: not saved to file (ephemeral / transient),
101
    // prevents automatic updates (especially import time updates),
102
    // unset when user explicitly triggers update (e.g. via UI button)
103
    SubSoftFixed  = 0x2000,
104
    SubMask       = 0x0f00,
105
106
    Max           = 0xffff // used as a flag by SwFieldDokInfPage
107
};
108
namespace o3tl { template<> struct typed_flags<SwDocInfoSubType> : is_typed_flags<SwDocInfoSubType, 0xffff> {}; }
109
110
enum class SwPageNumSubType
111
{
112
    Random,
113
    Next,
114
    Previous
115
};
116
117
// NOTE: Possibly the first 15 values in the below enum are required
118
// to exactly match the published constants in css::text::UserDataPart
119
// (see offapi/com/sun/star/text/UserDataPart.idl).
120
121
enum class SwExtUserSubType : sal_uInt16
122
{
123
    Company,
124
    Firstname,
125
    Name,
126
    Shortcut,
127
    Street,
128
    Country,
129
    Zip,
130
    City,
131
    Title,
132
    Position,
133
    PhonePrivate,
134
    PhoneCompany,
135
    Fax,
136
    Email,
137
    State,
138
    FathersName,
139
    Apartment
140
};
141
142
enum class SwJumpEditFormat
143
{
144
    Text,
145
    Table,
146
    Frame,
147
    Graphic,
148
    OLE
149
};
150
151
class SAL_DLLPUBLIC_RTTI SwPageNumberFieldType final : public SwFieldType
152
{
153
    SvxNumType      m_nNumberingType;
154
    bool            m_bVirtual;
155
156
public:
157
    SwPageNumberFieldType();
158
159
    OUString Expand( SvxNumType nFormat, short nOff, sal_uInt16 const nPageNumber,
160
                     sal_uInt16 const nMaxPage, const OUString&, LanguageType = LANGUAGE_NONE ) const;
161
    void ChangeExpansion( SwDoc* pDoc,
162
                          bool bVirtPageNum, const SvxNumType* pNumFormat );
163
    virtual std::unique_ptr<SwFieldType> Copy() const override;
164
};
165
166
// Page numbering.
167
class SW_DLLPUBLIC SwPageNumberField final : public SwField
168
{
169
    OUString m_sUserStr;
170
    SwPageNumSubType  m_nSubType;
171
    short   m_nOffset;
172
    // fdo#58074 store page number in SwField, not SwFieldType
173
    sal_uInt16 m_nPageNumber;
174
    sal_uInt16 m_nMaxPage;
175
    SvxNumType m_nFormat;
176
177
public:
178
    SwPageNumberField(SwPageNumberFieldType*, SwPageNumSubType nSub,
179
                      SvxNumType nFormat, short nOff = 0,
180
                      sal_uInt16 const nPageNumber = 0,
181
                      sal_uInt16 const nMaxPage = 0);
182
183
38.9k
    SvxNumType GetFormat() const { return m_nFormat; }
184
0
    void SetFormat(SvxNumType n) { m_nFormat = n; }
185
186
    void ChangeExpansion(sal_uInt16 const nPageNumber,
187
            sal_uInt16 const nMaxPage);
188
189
    virtual OUString    ExpandImpl(SwRootFrame const* pLayout) const override;
190
    virtual std::unique_ptr<SwField> Copy() const override;
191
192
    virtual OUString GetPar2() const override;
193
    virtual void        SetPar2(const OUString& rStr) override;
194
195
    SwPageNumSubType    GetSubType() const;
196
0
    void                SetSubType(SwPageNumSubType n) { m_nSubType = n; }
197
    virtual bool        QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
198
    virtual bool        PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
199
200
0
    const OUString& GetUserString() const            { return m_sUserStr; }
201
28.3k
    void SetUserString( const OUString& rS )  { m_sUserStr = rS; }
202
};
203
204
class SwAuthorFieldType final : public SwFieldType
205
{
206
public:
207
    SwAuthorFieldType();
208
209
    static OUString         Expand(SwAuthorFormat);
210
    virtual std::unique_ptr<SwFieldType> Copy() const override;
211
};
212
213
/// Insert -> Field -> More fields -> Document -> Author -> Name on the UI.  This expands to the
214
/// name of the current user, first author would be an SwDocInfoField.
215
class SAL_DLLPUBLIC_RTTI SwAuthorField final : public SwField
216
{
217
    OUString m_aContent;
218
    SwAuthorFormat m_nFormat;
219
220
public:
221
    SwAuthorField(SwAuthorFieldType*, SwAuthorFormat nFormat);
222
223
0
    SwAuthorFormat GetFormat() const { return m_nFormat; }
224
0
    void SetFormat(SwAuthorFormat n) { m_nFormat = n; }
225
226
    virtual OUString    ExpandImpl(SwRootFrame const* pLayout) const override;
227
    virtual std::unique_ptr<SwField> Copy() const override;
228
229
0
    void         SetExpansion(const OUString& rStr) { m_aContent = rStr; }
230
231
    virtual bool        QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
232
    virtual bool        PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
233
};
234
235
/// Provides the expansion of an SwFileNameField to a string.
236
class SAL_DLLPUBLIC_RTTI SwFileNameFieldType final : public SwFieldType
237
{
238
    SwDoc& m_rDoc;
239
public:
240
    SwFileNameFieldType(SwDoc&);
241
242
    OUString                Expand(SwFileNameFormat) const;
243
    virtual std::unique_ptr<SwFieldType> Copy() const override;
244
};
245
246
/// Expands to the current file name. The format is stored in SwField::m_nFormat and is interpreted
247
/// as an SwFileNameFormat.
248
///
249
/// 'Insert' -> 'Field' -> 'More Fields' -> 'Document' -> 'File name' on the UI.
250
class SW_DLLPUBLIC SwFileNameField final : public SwField
251
{
252
    OUString m_aContent;
253
    SwFileNameFormat m_nFormat;
254
255
public:
256
    SwFileNameField(SwFileNameFieldType*, SwFileNameFormat nFormat);
257
258
6.39k
    SwFileNameFormat GetFormat() const { return m_nFormat; }
259
0
    void SetFormat(SwFileNameFormat n) { m_nFormat = n; }
260
261
    virtual OUString    ExpandImpl(SwRootFrame const* pLayout) const override;
262
    virtual std::unique_ptr<SwField> Copy() const override;
263
264
2.22k
    void         SetExpansion(const OUString& rStr) { m_aContent = rStr; }
265
266
    virtual bool        QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
267
    virtual bool        PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
268
};
269
270
class SAL_DLLPUBLIC_RTTI SwTemplNameFieldType final : public SwFieldType
271
{
272
    SwDoc& m_rDoc;
273
public:
274
    SwTemplNameFieldType(SwDoc&);
275
276
    OUString                Expand(SwFileNameFormat) const;
277
    virtual std::unique_ptr<SwFieldType> Copy() const override;
278
};
279
280
class SW_DLLPUBLIC SwTemplNameField final : public SwField
281
{
282
    SwFileNameFormat m_nFormat;
283
public:
284
    SwTemplNameField(SwTemplNameFieldType*, SwFileNameFormat nFormat);
285
286
26
    SwFileNameFormat GetFormat() const { return m_nFormat; }
287
0
    void SetFormat(SwFileNameFormat n) { m_nFormat = n; }
288
    virtual OUString    ExpandImpl(SwRootFrame const* pLayout) const override;
289
    virtual std::unique_ptr<SwField> Copy() const override;
290
    virtual bool        QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
291
    virtual bool        PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
292
};
293
294
// Document statistics
295
class SAL_DLLPUBLIC_RTTI SwDocStatFieldType final : public SwFieldType
296
{
297
    SwDoc&          m_rDoc;
298
    SvxNumType      m_nNumberingType;
299
300
public:
301
    SwDocStatFieldType(SwDoc&);
302
    OUString                Expand(SwDocStatSubType nSubType, SvxNumType nFormat,
303
        sal_uInt16 nVirtPageCount) const;
304
    virtual std::unique_ptr<SwFieldType> Copy() const override;
305
306
388
    void             SetNumFormat( SvxNumType eFormat )  { m_nNumberingType = eFormat; }
307
    void             UpdateRangeFields(SwRootFrame const*const pLayout);
308
};
309
310
class SW_DLLPUBLIC SwDocStatField final : public SwField
311
{
312
    SwDocStatSubType m_nSubType;
313
    sal_uInt16 m_nVirtPageCount;
314
    SvxNumType m_nFormat;
315
public:
316
    SwDocStatField( SwDocStatFieldType*,
317
                    SwDocStatSubType nSubType, SvxNumType nFormat, sal_uInt16 nVirtPageCount = 0);
318
319
0
    SvxNumType GetFormat() const { return m_nFormat; }
320
0
    void SetFormat(SvxNumType n) { m_nFormat = n; }
321
322
    void ChangeExpansion( const SwFrame* pFrame, sal_uInt16 nVirtPageCount);
323
324
    virtual OUString    ExpandImpl(SwRootFrame const* pLayout) const override;
325
    virtual std::unique_ptr<SwField> Copy() const override;
326
327
    SwDocStatSubType    GetSubType() const;
328
    void                SetSubType(SwDocStatSubType nSub);
329
    virtual bool        QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
330
    virtual bool        PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
331
};
332
333
class SAL_DLLPUBLIC_RTTI SwHiddenTextFieldType final : public SwFieldType
334
{
335
    bool m_bHidden;
336
public:
337
    SwHiddenTextFieldType(bool bSetHidden = true);
338
339
    virtual std::unique_ptr<SwFieldType> Copy() const override;
340
4.01k
    virtual void UpdateFields() override {};
341
342
    void SetHiddenFlag( bool bSetHidden );
343
0
    bool GetHiddenFlag() const { return m_bHidden; }
344
};
345
346
class SW_DLLPUBLIC SwHiddenTextField final : public SwField
347
{
348
    OUString m_aTRUEText; ///< Text if condition true.
349
    OUString m_aFALSEText; ///< If condition false.
350
    OUString m_aContent; ///< Evaluated DB-text.
351
352
    OUString m_aCond; ///< Condition.
353
    SwFieldTypesEnum m_nSubType;
354
355
    bool m_bCanToggle : 1; ///< Can field be toggled alone?
356
    bool m_bIsHidden : 1; ///< Is it not visible?
357
    bool m_bValid : 1; ///< Is DB-field evaluated?
358
359
    virtual OUString    ExpandImpl(SwRootFrame const* pLayout) const override;
360
    virtual std::unique_ptr<SwField> Copy() const override;
361
362
public:
363
    SwHiddenTextField( SwHiddenTextFieldType*,
364
                     bool   bConditional,
365
                     OUString aCond,
366
                     const OUString& rText,
367
                     bool   bHidden,
368
                     SwFieldTypesEnum nSubType = SwFieldTypesEnum::HiddenText);
369
370
    SwHiddenTextField( SwHiddenTextFieldType*,
371
                      OUString aCond,
372
                      OUString aTrue,
373
                      OUString aFalse,
374
                      SwFieldTypesEnum nSubType = SwFieldTypesEnum::HiddenText);
375
376
    virtual OUString    GetFieldName() const override;
377
378
    void                Evaluate(SwDoc& rDoc);
379
380
0
    void         SetValue(bool bHidden)  { m_bIsHidden = bHidden; }
381
    static OUString     GetColumnName(const OUString& rName);
382
    static OUString     GetDBName(std::u16string_view rName, SwDoc& rDoc);
383
384
    /// Condition
385
    virtual void        SetPar1(const OUString& rStr) override;
386
    virtual OUString    GetPar1() const override;
387
388
    /// True/False - String
389
    virtual void        SetPar2(const OUString& rStr) override;
390
    virtual OUString    GetPar2() const override;
391
392
    SwFieldTypesEnum    GetSubType() const;
393
0
    void SetSubType(SwFieldTypesEnum n) { m_nSubType = n; }
394
395
    virtual bool        QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
396
    virtual bool        PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
397
398
    static void         ParseIfFieldDefinition(std::u16string_view aFieldDefinition,
399
                                               OUString& rCondition,
400
                                               OUString& rTrue,
401
                                               OUString& rFalse);
402
};
403
404
// Field that expands to an empty line (without height).
405
class SwHiddenParaFieldType final : public SwFieldType
406
{
407
public:
408
    SwHiddenParaFieldType();
409
410
    virtual std::unique_ptr<SwFieldType> Copy() const override;
411
4.01k
    virtual void UpdateFields() override {};
412
};
413
414
class SwHiddenParaField final : public SwField
415
{
416
    OUString m_aCond;
417
    bool m_bIsHidden;
418
public:
419
    /// Direct input, delete old value.
420
    SwHiddenParaField(SwHiddenParaFieldType*, OUString aCond);
421
422
    virtual OUString    ExpandImpl(SwRootFrame const* pLayout) const override;
423
    virtual std::unique_ptr<SwField> Copy() const override;
424
425
0
    void                SetHidden(bool bHidden)     { m_bIsHidden = bHidden; }
426
0
    bool                IsHidden() const            { return m_bIsHidden;    }
427
428
    /// Query, set condition.
429
    virtual OUString    GetPar1() const override;
430
    virtual void        SetPar1(const OUString& rStr) override;
431
    virtual bool        QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
432
    virtual bool        PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
433
};
434
435
class SAL_DLLPUBLIC_RTTI SwMacroFieldType final : public SwFieldType
436
{
437
    SwDoc& m_rDoc;
438
439
public:
440
    SwMacroFieldType(SwDoc&);
441
442
    virtual std::unique_ptr<SwFieldType> Copy() const override;
443
};
444
445
class SW_DLLPUBLIC SwMacroField final : public SwField
446
{
447
    OUString m_aMacro;
448
    OUString m_aText;
449
    bool      m_bIsScriptURL;
450
451
    virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override;
452
    virtual std::unique_ptr<SwField> Copy() const override;
453
454
public:
455
    /// Direct input, delete old value.
456
    SwMacroField( SwMacroFieldType*, OUString aLibAndName,
457
                  OUString aText);
458
459
0
    const OUString&  GetMacro() const { return m_aMacro; }
460
    OUString         GetLibName() const;
461
    OUString         GetMacroName() const;
462
    SvxMacro         GetSvxMacro() const;
463
464
    virtual OUString GetFieldName() const override;
465
466
    /// Library and FileName
467
    virtual OUString GetPar1() const override;
468
    virtual void     SetPar1(const OUString& rStr) override;
469
470
    /// Macrotext
471
    virtual OUString  GetPar2() const override;
472
    virtual void    SetPar2(const OUString& rStr) override;
473
    virtual bool        QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
474
    virtual bool        PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
475
476
    static void CreateMacroString( OUString& rMacro,
477
                                   std::u16string_view rMacroName,
478
                                   const OUString& rLibraryName );
479
480
    static bool isScriptURL( const OUString& str );
481
};
482
483
class SAL_DLLPUBLIC_RTTI SwPostItFieldType final : public SwFieldType
484
{
485
private:
486
    SwDoc& mrDoc;
487
public:
488
    SwPostItFieldType(SwDoc& rDoc);
489
490
    virtual std::unique_ptr<SwFieldType> Copy() const override;
491
492
    SwDoc& GetDoc() const
493
14
    {
494
14
        return mrDoc;
495
14
    };
496
};
497
498
class SW_DLLPUBLIC SwPostItField final : public SwField
499
{
500
    OUString m_sText;
501
    OUString m_sAuthor;
502
    OUString m_sInitials; ///< Initials of the author.
503
    SwMarkName m_sName;     ///< Name of the comment.
504
    DateTime    m_aDateTime;
505
    bool     m_bResolved;
506
    std::optional<OutlinerParaObject> mpText;
507
    rtl::Reference<SwTextAPIObject> m_xTextObject;
508
    sal_uInt32 m_nPostItId;
509
    sal_uInt32 m_nParentId;
510
    sal_uInt32 m_nParaId;
511
    sal_uInt32 m_nParentPostItId;
512
    SwMarkName m_sParentName; /// Parent comment's name.
513
#if ENABLE_YRS
514
    OString m_CommentId;
515
public:
516
    OString GetYrsCommentId() const { return m_CommentId; }
517
    void SetYrsCommentId(OString const& rCommentId) { m_CommentId = rCommentId; }
518
#endif
519
520
public:
521
    static sal_uInt32 s_nLastPostItId;
522
523
    SwPostItField( SwPostItFieldType*,
524
                   OUString aAuthor,
525
                   OUString aText,
526
                   OUString aInitials,
527
                   SwMarkName aName,
528
                   const DateTime& rDate,
529
                   const bool bResolved = false,
530
                   const sal_uInt32 nPostItId = 0,
531
                   const sal_uInt32 nParentId = 0,
532
                   const sal_uInt32 nParaId = 0,
533
                   const sal_uInt32 nParentPostItId = 0,
534
                   const SwMarkName aParentName = SwMarkName());
535
536
    SwPostItField(const SwPostItField&) = delete;
537
    SwPostItField* operator=(const SwPostItField&) = delete;
538
539
    virtual ~SwPostItField() override;
540
541
    virtual OUString    ExpandImpl(SwRootFrame const* pLayout) const override;
542
    virtual std::unique_ptr<SwField> Copy() const override;
543
544
0
    const DateTime&         GetDateTime() const             { return m_aDateTime; }
545
27
    Date       GetDate() const                 { return Date(m_aDateTime); }
546
0
    tools::Time GetTime() const                 { return tools::Time(m_aDateTime); }
547
1.02k
    sal_uInt32 GetPostItId() const             { return m_nPostItId; }
548
    void SetPostItId(const sal_uInt32 nPostItId = 0);
549
    void SetParentPostItId(const sal_uInt32 nParentPostItId = 0);
550
27
    sal_uInt32 GetParentId() const             { return m_nParentId; }
551
340
    sal_uInt32 GetParentPostItId() const       { return m_nParentPostItId; }
552
    void SetParentId(const sal_uInt32 nParentId);
553
0
    sal_uInt32 GetParaId() const               { return m_nParaId; }
554
    void SetParaId(const sal_uInt32 nParaId);
555
556
    /// Author
557
    virtual OUString        GetPar1() const override;
558
    virtual void            SetPar1(const OUString& rStr) override;
559
560
    /// Text
561
    virtual OUString   GetPar2() const override;
562
    virtual void            SetPar2(const OUString& rStr) override;
563
27
    const OUString&         GetText() const { return m_sText; }
564
0
    const OUString&         GetInitials() const { return m_sInitials;}
565
    void                    SetName(const SwMarkName& rStr);
566
77.7k
    const SwMarkName& GetName() const { return m_sName;}
567
27
    const SwMarkName& GetParentName() const { return m_sParentName; }
568
    void                    SetParentName(const SwMarkName& rStr);
569
570
0
    const OutlinerParaObject* GetTextObject() const { return mpText ? &*mpText : nullptr;}
571
    void SetTextObject( std::optional<OutlinerParaObject> pText );
572
573
    void SetResolved(bool bNewState);
574
    void ToggleResolved();
575
    bool GetResolved() const;
576
577
    sal_Int32 GetNumberOfParagraphs() const;
578
    void ChangeStyleSheetName(std::u16string_view rOldName, const SfxStyleSheetBase* pStyleSheet);
579
580
    virtual bool        QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
581
    virtual bool        PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
582
    virtual OUString    GetDescription() const override;
583
    virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
584
};
585
586
class SAL_DLLPUBLIC_RTTI SwDocInfoFieldType final : public SwValueFieldType
587
{
588
public:
589
    SwDocInfoFieldType(SwDoc* pDc);
590
591
    OUString                Expand(SwDocInfoSubType nSubType, sal_uInt32 nFormat, LanguageType nLang, const OUString& rName) const;
592
    virtual std::unique_ptr<SwFieldType> Copy() const override;
593
};
594
595
/// A field that expands to the value of some document information, e.g. Insert -> Field -> First
596
/// Author on the UI.
597
class SW_DLLPUBLIC SwDocInfoField final : public SwValueField
598
{
599
    SwDocInfoSubType  m_nSubType;
600
    OUString  m_aContent;
601
    OUString  m_aName;
602
603
    virtual OUString    ExpandImpl(SwRootFrame const* pLayout) const override;
604
    virtual std::unique_ptr<SwField> Copy() const override;
605
606
public:
607
    SwDocInfoField(SwDocInfoFieldType*, SwDocInfoSubType nSub, const OUString& rName, sal_uInt32 nFormat=0);
608
    SwDocInfoField(SwDocInfoFieldType*, SwDocInfoSubType nSub, const OUString& rName, const OUString& rValue, sal_uInt32 nFormat=0);
609
610
    void                    SetSubType(SwDocInfoSubType);
611
    SwDocInfoSubType        GetSubType() const;
612
    virtual void            SetLanguage(LanguageType nLng) override;
613
    virtual OUString        GetFieldName() const override;
614
0
    const OUString&         GetName() const { return m_aName; }
615
0
    void                    SetName( const OUString& rName ) { m_aName = rName; }
616
147
    void             SetExpansion(const OUString& rStr) { m_aContent = rStr; }
617
    virtual bool        QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
618
    virtual bool        PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
619
};
620
621
// Extended User settings.
622
class SwExtUserFieldType final : public SwFieldType
623
{
624
public:
625
    SwExtUserFieldType();
626
627
    static OUString         Expand(SwExtUserSubType nSubType);
628
    virtual std::unique_ptr<SwFieldType> Copy() const override;
629
};
630
631
class SAL_DLLPUBLIC_RTTI SwExtUserField final : public SwField
632
{
633
    OUString m_aContent;
634
    SwExtUserSubType  m_nType;
635
    SwAuthorFormat m_nFormat;
636
637
public:
638
    SwExtUserField(SwExtUserFieldType*, SwExtUserSubType nSub, SwAuthorFormat nFormat);
639
640
426
    SwAuthorFormat GetFormat() const { return m_nFormat; }
641
0
    void SetFormat(SwAuthorFormat n) { m_nFormat = n; }
642
643
    virtual OUString    ExpandImpl(SwRootFrame const* pLayout) const override;
644
    virtual std::unique_ptr<SwField> Copy() const override;
645
646
    SW_DLLPUBLIC SwExtUserSubType GetSubType() const;
647
    void SetSubType(SwExtUserSubType nSub);
648
649
426
    void         SetExpansion(const OUString& rStr) { m_aContent = rStr; }
650
651
    virtual bool        QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
652
    virtual bool        PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
653
};
654
655
// Relative page numbers - field.
656
class SwRefPageSetFieldType final : public SwFieldType
657
{
658
public:
659
    SwRefPageSetFieldType();
660
661
    virtual std::unique_ptr<SwFieldType> Copy() const override;
662
4.01k
    virtual void UpdateFields() override {};
663
664
private:
665
    /// noop, there is nothing to update!
666
    virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
667
};
668
669
// Relative page numbering.
670
class SAL_DLLPUBLIC_RTTI SwRefPageSetField final : public SwField
671
{
672
    short   m_nOffset;
673
    bool    m_bOn;
674
675
public:
676
    SwRefPageSetField( SwRefPageSetFieldType*, short nOff, bool bOn );
677
678
    virtual OUString    ExpandImpl(SwRootFrame const* pLayout) const override;
679
    virtual std::unique_ptr<SwField> Copy() const override;
680
681
    virtual OUString  GetPar2() const override;
682
    virtual void    SetPar2(const OUString& rStr) override;
683
684
0
    bool IsOn() const               { return m_bOn; }
685
686
0
    short GetOffset() const         { return m_nOffset; }
687
0
    void SetOffset( short nOff )    { m_nOffset = nOff; }
688
    virtual bool        QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
689
    virtual bool        PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
690
};
691
692
// Relative page numbers - query field.
693
class SwRefPageGetFieldType final : public SwFieldType
694
{
695
    SwDoc&          m_rDoc;
696
    sal_Int16       m_nNumberingType;
697
698
    void UpdateField(SwTextField const * pTextField,
699
            SetGetExpFields const & rSetList, SwRootFrame const* pLayout);
700
701
    /// overwritten to update all RefPageGet fields
702
    virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
703
public:
704
    SwRefPageGetFieldType( SwDoc& rDoc );
705
    virtual std::unique_ptr<SwFieldType> Copy() const override;
706
    bool MakeSetList(SetGetExpFields& rTmpLst, SwRootFrame const* pLayout);
707
0
    SwDoc&  GetDoc() const                  { return m_rDoc; }
708
};
709
710
// Query relative page numbering.
711
class SwRefPageGetField final : public SwField
712
{
713
    OUString m_sText;
714
    OUString m_sTextRLHidden; ///< hidden redlines
715
    SvxNumType m_nFormat;
716
717
public:
718
    SwRefPageGetField( SwRefPageGetFieldType*, SvxNumType nFormat );
719
720
0
    SvxNumType GetFormat() const { return m_nFormat; }
721
0
    void SetFormat(SvxNumType n) { m_nFormat = n; }
722
723
    virtual OUString    ExpandImpl(SwRootFrame const* pLayout) const override;
724
    virtual std::unique_ptr<SwField> Copy() const override;
725
726
    void SetText(const OUString& rText, SwRootFrame const* pLayout);
727
728
    void ChangeExpansion(const SwFrame& rFrame, const SwTextField* pField);
729
    virtual bool        QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
730
    virtual bool        PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
731
};
732
733
// Field to jump to and edit.
734
class SwJumpEditFieldType final : public SwFieldType
735
{
736
    SwDoc& m_rDoc;
737
    sw::WriterMultiListener m_aDep;
738
739
public:
740
    SwJumpEditFieldType( SwDoc& rDoc );
741
    virtual std::unique_ptr<SwFieldType> Copy() const override;
742
4.01k
    virtual void UpdateFields() override {};
743
744
    SwCharFormat* GetCharFormat();
745
};
746
747
class SAL_DLLPUBLIC_RTTI SwJumpEditField final : public SwField
748
{
749
    OUString m_sText;
750
    OUString m_sHelp;
751
    SwJumpEditFormat m_nFormat;
752
public:
753
    SwJumpEditField( SwJumpEditFieldType*, SwJumpEditFormat nFormat,
754
                     OUString sText, OUString sHelp );
755
756
0
    SwJumpEditFormat GetFormat() const { return m_nFormat; }
757
0
    void SetFormat(SwJumpEditFormat n) { m_nFormat = n; }
758
759
    virtual OUString    ExpandImpl(SwRootFrame const* pLayout) const override;
760
    virtual std::unique_ptr<SwField> Copy() const override;
761
762
    /// Placeholder-Text
763
    virtual OUString GetPar1() const override;
764
    virtual void    SetPar1(const OUString& rStr) override;
765
766
    /// Hint-Text
767
    virtual OUString  GetPar2() const override;
768
    virtual void    SetPar2(const OUString& rStr) override;
769
770
    SwCharFormat* GetCharFormat() const
771
0
        { return static_cast<SwJumpEditFieldType*>(GetTyp())->GetCharFormat(); }
772
    virtual bool        QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
773
    virtual bool        PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
774
};
775
776
class SwScriptFieldType final : public SwFieldType
777
{
778
    SwDoc& m_rDoc;
779
public:
780
    SwScriptFieldType( SwDoc& rDoc );
781
782
    virtual std::unique_ptr<SwFieldType> Copy() const override;
783
};
784
785
class SW_DLLPUBLIC SwScriptField final : public SwField
786
{
787
    OUString m_sType;  ///< Type of Code (Java/VBScript/...)
788
    OUString m_sCode;  /**< Code as text.
789
                          Code as JavaCode ? */
790
791
    bool    m_bCodeURL; ///< Code contains URL of a script.
792
793
public:
794
    SwScriptField( SwScriptFieldType*, OUString aType,
795
                   OUString aCode, bool bURL );
796
797
    virtual OUString        GetDescription() const override;
798
799
    virtual OUString    ExpandImpl(SwRootFrame const* pLayout) const override;
800
    virtual std::unique_ptr<SwField> Copy() const override;
801
802
    /// Type
803
    virtual OUString        GetPar1() const override;
804
    virtual void            SetPar1(const OUString& rStr) override;
805
    /// Text
806
    virtual OUString   GetPar2() const override;
807
    virtual void            SetPar2(const OUString& rStr) override;
808
809
0
    bool                    IsCodeURL() const { return m_bCodeURL; }
810
0
    void                    SetCodeURL( bool bURL ) { m_bCodeURL = bURL; }
811
    virtual bool        QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
812
    virtual bool        PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
813
};
814
815
// Combined Character Fieldtype
816
class SAL_DLLPUBLIC_RTTI SwCombinedCharFieldType final : public SwFieldType
817
{
818
public:
819
    SwCombinedCharFieldType();
820
821
    virtual std::unique_ptr<SwFieldType> Copy() const override;
822
};
823
824
// ScriptField
825
100
#define MAX_COMBINED_CHARACTERS     6
826
827
class SW_DLLPUBLIC SwCombinedCharField final : public SwField
828
{
829
    OUString m_sCharacters;    ///< combine these characters
830
831
public:
832
    SwCombinedCharField( SwCombinedCharFieldType*, const OUString& rChars );
833
834
    virtual OUString    ExpandImpl(SwRootFrame const* pLayout) const override;
835
    virtual std::unique_ptr<SwField> Copy() const override;
836
837
    /// Characters
838
    virtual OUString    GetPar1() const override;
839
    virtual void        SetPar1(const OUString& rStr) override;
840
841
    virtual bool        QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
842
    virtual bool        PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
843
};
844
845
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */