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_DOCUFLD_HXX 20 #define INCLUDED_SW_INC_DOCUFLD_HXX 21 22 #include <sal/config.h> 23 24 #include <string_view> 25 26 #include <tools/solar.h> 27 #include <tools/date.hxx> 28 #include <tools/datetime.hxx> 29 #include <rtl/ref.hxx> 30 #include <svl/macitem.hxx> 31 32 #include "fldbas.hxx" 33 34 class SetGetExpFields; 35 class SwTextField; 36 class SwFrame; 37 class OutlinerParaObject; 38 class SwTextAPIObject; 39 class SwCharFormat; 40 41 enum SwAuthorFormat 42 { 43 AF_BEGIN, 44 AF_NAME = AF_BEGIN, 45 AF_SHORTCUT, 46 AF_FIXED = 0x8000 47 }; 48 49 // Subtype of document statistics. 50 enum SwDocStatSubType 51 { 52 DS_BEGIN, 53 DS_PAGE = DS_BEGIN, 54 DS_PARA, 55 DS_WORD, 56 DS_CHAR, 57 DS_TBL, 58 DS_GRF, 59 DS_OLE, 60 }; 61 62 typedef sal_uInt16 SwDocInfoSubType; 63 namespace nsSwDocInfoSubType 64 { 65 /** NB: these must denote consecutive integers! 66 NB2: these are extended by 4 DI_INFO values for backward compatibility 67 in filter/html/htmlfld.cxx, so make sure that DI_SUBTYPE_END 68 really is the end, and is at least 4 less than DI_SUB_*! */ 69 const SwDocInfoSubType DI_SUBTYPE_BEGIN = 0; 70 const SwDocInfoSubType DI_TITLE = DI_SUBTYPE_BEGIN; 71 const SwDocInfoSubType DI_SUBJECT = 1; 72 const SwDocInfoSubType DI_KEYS = 2; 73 const SwDocInfoSubType DI_COMMENT = 3; 74 const SwDocInfoSubType DI_CREATE = 4; 75 const SwDocInfoSubType DI_CHANGE = 5; 76 const SwDocInfoSubType DI_PRINT = 6; 77 const SwDocInfoSubType DI_DOCNO = 7; 78 const SwDocInfoSubType DI_EDIT = 8; 79 const SwDocInfoSubType DI_CUSTOM = 9; 80 const SwDocInfoSubType DI_SUBTYPE_END = 10; 81 82 const SwDocInfoSubType DI_SUB_AUTHOR = 0x0100; 83 const SwDocInfoSubType DI_SUB_TIME = 0x0200; 84 const SwDocInfoSubType DI_SUB_DATE = 0x0300; 85 const SwDocInfoSubType DI_SUB_FIXED = 0x1000; 86 const SwDocInfoSubType DI_SUB_MASK = 0xff00; 87 } 88 89 enum SwPageNumSubType 90 { 91 PG_RANDOM, 92 PG_NEXT, 93 PG_PREV 94 }; 95 96 // NOTE: Possibly the first 15 values in the below enum are required 97 // to exactly match the published constants in css::text::UserDataPart 98 // (see offapi/com/sun/star/text/UserDataPart.idl). 99 100 enum SwExtUserSubType 101 { 102 EU_COMPANY, 103 EU_FIRSTNAME, 104 EU_NAME, 105 EU_SHORTCUT, 106 EU_STREET, 107 EU_COUNTRY, 108 EU_ZIP, 109 EU_CITY, 110 EU_TITLE, 111 EU_POSITION, 112 EU_PHONE_PRIVATE, 113 EU_PHONE_COMPANY, 114 EU_FAX, 115 EU_EMAIL, 116 EU_STATE, 117 EU_FATHERSNAME, 118 EU_APARTMENT 119 }; 120 121 enum SwJumpEditFormat 122 { 123 JE_FMT_TEXT, 124 JE_FMT_TABLE, 125 JE_FMT_FRAME, 126 JE_FMT_GRAPHIC, 127 JE_FMT_OLE 128 }; 129 130 class SAL_DLLPUBLIC_RTTI SwPageNumberFieldType final : public SwFieldType 131 { 132 SvxNumType m_nNumberingType; 133 bool m_bVirtual; 134 135 public: 136 SwPageNumberFieldType(); 137 138 OUString Expand( SvxNumType nFormat, short nOff, sal_uInt16 const nPageNumber, 139 sal_uInt16 const nMaxPage, const OUString&, LanguageType = LANGUAGE_NONE ) const; 140 void ChangeExpansion( SwDoc* pDoc, 141 bool bVirtPageNum, const SvxNumType* pNumFormat ); 142 virtual std::unique_ptr<SwFieldType> Copy() const override; 143 }; 144 145 // Page numbering. 146 class SW_DLLPUBLIC SwPageNumberField final : public SwField 147 { 148 OUString m_sUserStr; 149 sal_uInt16 m_nSubType; 150 short m_nOffset; 151 // fdo#58074 store page number in SwField, not SwFieldType 152 sal_uInt16 m_nPageNumber; 153 sal_uInt16 m_nMaxPage; 154 155 public: 156 SwPageNumberField(SwPageNumberFieldType*, sal_uInt16 nSub, 157 sal_uInt32 nFormat, short nOff = 0, 158 sal_uInt16 const nPageNumber = 0, 159 sal_uInt16 const nMaxPage = 0); 160 161 void ChangeExpansion(sal_uInt16 const nPageNumber, 162 sal_uInt16 const nMaxPage); 163 164 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; 165 virtual std::unique_ptr<SwField> Copy() const override; 166 167 virtual OUString GetPar2() const override; 168 virtual void SetPar2(const OUString& rStr) override; 169 170 virtual sal_uInt16 GetSubType() const override; 171 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override; 172 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override; 173 GetUserString() const174 const OUString& GetUserString() const { return m_sUserStr; } SetUserString(const OUString & rS)175 void SetUserString( const OUString& rS ) { m_sUserStr = rS; } 176 }; 177 178 class SwAuthorFieldType final : public SwFieldType 179 { 180 public: 181 SwAuthorFieldType(); 182 183 static OUString Expand(sal_uLong); 184 virtual std::unique_ptr<SwFieldType> Copy() const override; 185 }; 186 187 class SwAuthorField final : public SwField 188 { 189 OUString m_aContent; 190 191 public: 192 SwAuthorField(SwAuthorFieldType*, sal_uInt32 nFormat); 193 194 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; 195 virtual std::unique_ptr<SwField> Copy() const override; 196 SetExpansion(const OUString & rStr)197 void SetExpansion(const OUString& rStr) { m_aContent = rStr; } 198 199 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override; 200 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override; 201 }; 202 203 class SAL_DLLPUBLIC_RTTI SwFileNameFieldType final : public SwFieldType 204 { 205 SwDoc& m_rDoc; 206 public: 207 SwFileNameFieldType(SwDoc&); 208 209 OUString Expand(sal_uLong) const; 210 virtual std::unique_ptr<SwFieldType> Copy() const override; 211 }; 212 213 class SW_DLLPUBLIC SwFileNameField final : public SwField 214 { 215 OUString m_aContent; 216 217 public: 218 SwFileNameField(SwFileNameFieldType*, sal_uInt32 nFormat); 219 220 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; 221 virtual std::unique_ptr<SwField> Copy() const override; 222 SetExpansion(const OUString & rStr)223 void SetExpansion(const OUString& rStr) { m_aContent = rStr; } 224 225 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override; 226 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override; 227 }; 228 229 class SAL_DLLPUBLIC_RTTI SwTemplNameFieldType final : public SwFieldType 230 { 231 SwDoc& m_rDoc; 232 public: 233 SwTemplNameFieldType(SwDoc&); 234 235 OUString Expand(sal_uLong) const; 236 virtual std::unique_ptr<SwFieldType> Copy() const override; 237 }; 238 239 class SW_DLLPUBLIC SwTemplNameField final : public SwField 240 { 241 public: 242 SwTemplNameField(SwTemplNameFieldType*, sal_uInt32 nFormat); 243 244 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; 245 virtual std::unique_ptr<SwField> Copy() const override; 246 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override; 247 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override; 248 }; 249 250 // Document statistics 251 class SAL_DLLPUBLIC_RTTI SwDocStatFieldType final : public SwFieldType 252 { 253 SwDoc& m_rDoc; 254 SvxNumType m_nNumberingType; 255 256 public: 257 SwDocStatFieldType(SwDoc&); 258 OUString Expand(sal_uInt16 nSubType, SvxNumType nFormat) const; 259 virtual std::unique_ptr<SwFieldType> Copy() const override; 260 SetNumFormat(SvxNumType eFormat)261 void SetNumFormat( SvxNumType eFormat ) { m_nNumberingType = eFormat; } 262 }; 263 264 class SW_DLLPUBLIC SwDocStatField final : public SwField 265 { 266 sal_uInt16 m_nSubType; 267 268 public: 269 SwDocStatField( SwDocStatFieldType*, 270 sal_uInt16 nSubType, sal_uInt32 nFormat); 271 272 void ChangeExpansion( const SwFrame* pFrame ); 273 274 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; 275 virtual std::unique_ptr<SwField> Copy() const override; 276 277 virtual sal_uInt16 GetSubType() const override; 278 virtual void SetSubType(sal_uInt16 nSub) override; 279 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override; 280 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override; 281 }; 282 283 class SAL_DLLPUBLIC_RTTI SwHiddenTextFieldType final : public SwFieldType 284 { 285 bool m_bHidden; 286 public: 287 SwHiddenTextFieldType(bool bSetHidden = true); 288 289 virtual std::unique_ptr<SwFieldType> Copy() const override; 290 291 void SetHiddenFlag( bool bSetHidden ); GetHiddenFlag() const292 bool GetHiddenFlag() const { return m_bHidden; } 293 }; 294 295 class SW_DLLPUBLIC SwHiddenTextField final : public SwField 296 { 297 OUString m_aTRUEText; ///< Text if condition true. 298 OUString m_aFALSEText; ///< If condition false. 299 OUString m_aContent; ///< Evaluated DB-text. 300 301 OUString m_aCond; ///< Condition. 302 SwFieldTypesEnum m_nSubType; 303 304 bool m_bCanToggle : 1; ///< Can field be toggled alone? 305 bool m_bIsHidden : 1; ///< Is it not visible? 306 bool m_bValid : 1; ///< Is DB-field evaluated? 307 308 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; 309 virtual std::unique_ptr<SwField> Copy() const override; 310 311 public: 312 SwHiddenTextField( SwHiddenTextFieldType*, 313 bool bConditional, 314 const OUString& rCond, 315 const OUString& rText, 316 bool bHidden, 317 SwFieldTypesEnum nSubType = SwFieldTypesEnum::HiddenText); 318 319 SwHiddenTextField( SwHiddenTextFieldType*, 320 const OUString& rCond, 321 const OUString& rTrue, 322 const OUString& rFalse, 323 SwFieldTypesEnum nSubType = SwFieldTypesEnum::HiddenText); 324 325 virtual OUString GetFieldName() const override; 326 327 void Evaluate(SwDoc& rDoc); 328 SetValue(bool bHidden)329 void SetValue(bool bHidden) { m_bIsHidden = bHidden; } 330 static OUString GetColumnName(const OUString& rName); 331 static OUString GetDBName(const OUString& rName, SwDoc& rDoc); 332 333 /// Condition 334 virtual void SetPar1(const OUString& rStr) override; 335 virtual OUString GetPar1() const override; 336 337 /// True/False - String 338 virtual void SetPar2(const OUString& rStr) override; 339 virtual OUString GetPar2() const override; 340 341 virtual sal_uInt16 GetSubType() const override; 342 343 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override; 344 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override; 345 346 static void ParseIfFieldDefinition(const OUString& aFieldDefinition, 347 OUString& rCondition, 348 OUString& rTrue, 349 OUString& rFalse); 350 }; 351 352 // Field that expands to an empty line (without height). 353 class SwHiddenParaFieldType final : public SwFieldType 354 { 355 public: 356 SwHiddenParaFieldType(); 357 358 virtual std::unique_ptr<SwFieldType> Copy() const override; 359 }; 360 361 class SwHiddenParaField final : public SwField 362 { 363 OUString m_aCond; 364 bool m_bIsHidden; 365 public: 366 /// Direct input, delete old value. 367 SwHiddenParaField(SwHiddenParaFieldType*, const OUString& rCond); 368 369 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; 370 virtual std::unique_ptr<SwField> Copy() const override; 371 SetHidden(bool bHidden)372 void SetHidden(bool bHidden) { m_bIsHidden = bHidden; } IsHidden() const373 bool IsHidden() const { return m_bIsHidden; } 374 375 /// Query, set condition. 376 virtual OUString GetPar1() const override; 377 virtual void SetPar1(const OUString& rStr) override; 378 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override; 379 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override; 380 }; 381 382 class SAL_DLLPUBLIC_RTTI SwMacroFieldType final : public SwFieldType 383 { 384 SwDoc& m_rDoc; 385 386 public: 387 SwMacroFieldType(SwDoc&); 388 389 virtual std::unique_ptr<SwFieldType> Copy() const override; 390 }; 391 392 class SW_DLLPUBLIC SwMacroField final : public SwField 393 { 394 OUString m_aMacro; 395 OUString m_aText; 396 bool m_bIsScriptURL; 397 398 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; 399 virtual std::unique_ptr<SwField> Copy() const override; 400 401 public: 402 /// Direct input, delete old value. 403 SwMacroField( SwMacroFieldType*, const OUString& rLibAndName, 404 const OUString& rText); 405 GetMacro() const406 const OUString& GetMacro() const { return m_aMacro; } 407 OUString GetLibName() const; 408 OUString GetMacroName() const; 409 SvxMacro GetSvxMacro() const; 410 411 virtual OUString GetFieldName() const override; 412 413 /// Library and FileName 414 virtual OUString GetPar1() const override; 415 virtual void SetPar1(const OUString& rStr) override; 416 417 /// Macrotext 418 virtual OUString GetPar2() const override; 419 virtual void SetPar2(const OUString& rStr) override; 420 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override; 421 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override; 422 423 static void CreateMacroString( OUString& rMacro, 424 std::u16string_view rMacroName, 425 const OUString& rLibraryName ); 426 427 static bool isScriptURL( const OUString& str ); 428 }; 429 430 class SAL_DLLPUBLIC_RTTI SwPostItFieldType final : public SwFieldType 431 { 432 private: 433 SwDoc& mrDoc; 434 public: 435 SwPostItFieldType(SwDoc& rDoc); 436 437 virtual std::unique_ptr<SwFieldType> Copy() const override; 438 GetDoc() const439 SwDoc& GetDoc() const 440 { 441 return mrDoc; 442 }; 443 }; 444 445 class SW_DLLPUBLIC SwPostItField final : public SwField 446 { 447 OUString m_sText; 448 OUString m_sAuthor; 449 OUString m_sInitials; ///< Initials of the author. 450 OUString m_sName; ///< Name of the comment. 451 DateTime m_aDateTime; 452 bool m_bResolved; 453 std::unique_ptr<OutlinerParaObject> mpText; 454 rtl::Reference<SwTextAPIObject> m_xTextObject; 455 sal_uInt32 m_nPostItId; 456 457 public: 458 static sal_uInt32 s_nLastPostItId; 459 460 SwPostItField( SwPostItFieldType*, 461 const OUString& rAuthor, 462 const OUString& rText, 463 const OUString& rInitials, 464 const OUString& rName, 465 const DateTime& rDate, 466 const bool bResolved = false, 467 const sal_uInt32 nPostItId = 0); 468 469 SwPostItField(const SwPostItField&) = delete; 470 SwPostItField* operator=(const SwPostItField&) = delete; 471 472 virtual ~SwPostItField() override; 473 474 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; 475 virtual std::unique_ptr<SwField> Copy() const override; 476 GetDateTime() const477 const DateTime& GetDateTime() const { return m_aDateTime; } GetDate() const478 Date GetDate() const { return Date(m_aDateTime.GetDate()); } GetTime() const479 tools::Time GetTime() const { return tools::Time(m_aDateTime.GetTime()); } GetPostItId() const480 sal_uInt32 GetPostItId() const { return m_nPostItId; } 481 482 /// Author 483 virtual OUString GetPar1() const override; 484 virtual void SetPar1(const OUString& rStr) override; 485 486 /// Text 487 virtual OUString GetPar2() const override; 488 virtual void SetPar2(const OUString& rStr) override; GetText() const489 const OUString& GetText() const { return m_sText; } GetInitials() const490 const OUString& GetInitials() const { return m_sInitials;} 491 void SetName(const OUString& rStr); GetName() const492 const OUString& GetName() const { return m_sName;} 493 GetTextObject() const494 const OutlinerParaObject* GetTextObject() const { return mpText.get();} 495 void SetTextObject( std::unique_ptr<OutlinerParaObject> pText ); 496 497 void SetResolved(bool bNewState); 498 void ToggleResolved(); 499 bool GetResolved() const; 500 501 sal_Int32 GetNumberOfParagraphs() const; 502 503 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override; 504 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override; 505 virtual OUString GetDescription() const override; 506 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override; 507 }; 508 509 class SAL_DLLPUBLIC_RTTI SwDocInfoFieldType final : public SwValueFieldType 510 { 511 public: 512 SwDocInfoFieldType(SwDoc* pDc); 513 514 OUString Expand(sal_uInt16 nSubType, sal_uInt32 nFormat, LanguageType nLang, const OUString& rName) const; 515 virtual std::unique_ptr<SwFieldType> Copy() const override; 516 }; 517 518 class SW_DLLPUBLIC SwDocInfoField final : public SwValueField 519 { 520 sal_uInt16 m_nSubType; 521 OUString m_aContent; 522 OUString m_aName; 523 524 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; 525 virtual std::unique_ptr<SwField> Copy() const override; 526 527 public: 528 SwDocInfoField(SwDocInfoFieldType*, sal_uInt16 nSub, const OUString& rName, sal_uInt32 nFormat=0); 529 SwDocInfoField(SwDocInfoFieldType*, sal_uInt16 nSub, const OUString& rName, const OUString& rValue, sal_uInt32 nFormat=0); 530 531 virtual void SetSubType(sal_uInt16) override; 532 virtual sal_uInt16 GetSubType() const override; 533 virtual void SetLanguage(LanguageType nLng) override; 534 virtual OUString GetFieldName() const override; GetName() const535 const OUString& GetName() const { return m_aName; } SetName(const OUString & rName)536 void SetName( const OUString& rName ) { m_aName = rName; } SetExpansion(const OUString & rStr)537 void SetExpansion(const OUString& rStr) { m_aContent = rStr; } 538 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override; 539 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override; 540 }; 541 542 // Extended User settings. 543 class SwExtUserFieldType final : public SwFieldType 544 { 545 public: 546 SwExtUserFieldType(); 547 548 static OUString Expand(sal_uInt16 nSubType); 549 virtual std::unique_ptr<SwFieldType> Copy() const override; 550 }; 551 552 class SwExtUserField final : public SwField 553 { 554 OUString m_aContent; 555 sal_uInt16 m_nType; 556 557 public: 558 SwExtUserField(SwExtUserFieldType*, sal_uInt16 nSub, sal_uInt32 nFormat); 559 560 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; 561 virtual std::unique_ptr<SwField> Copy() const override; 562 563 virtual sal_uInt16 GetSubType() const override; 564 virtual void SetSubType(sal_uInt16 nSub) override; 565 SetExpansion(const OUString & rStr)566 void SetExpansion(const OUString& rStr) { m_aContent = rStr; } 567 568 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override; 569 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override; 570 }; 571 572 // Relative page numbers - field. 573 class SwRefPageSetFieldType final : public SwFieldType 574 { 575 public: 576 SwRefPageSetFieldType(); 577 578 virtual std::unique_ptr<SwFieldType> Copy() const override; 579 580 private: 581 /// noop, there is nothing to update! 582 virtual void SwClientNotify(const SwModify&, const SfxHint&) override; 583 }; 584 585 // Relative page numbering. 586 class SAL_DLLPUBLIC_RTTI SwRefPageSetField final : public SwField 587 { 588 short m_nOffset; 589 bool m_bOn; 590 591 public: 592 SwRefPageSetField( SwRefPageSetFieldType*, short nOff, bool bOn ); 593 594 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; 595 virtual std::unique_ptr<SwField> Copy() const override; 596 597 virtual OUString GetPar2() const override; 598 virtual void SetPar2(const OUString& rStr) override; 599 IsOn() const600 bool IsOn() const { return m_bOn; } 601 GetOffset() const602 short GetOffset() const { return m_nOffset; } SetOffset(short nOff)603 void SetOffset( short nOff ) { m_nOffset = nOff; } 604 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override; 605 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override; 606 }; 607 608 // Relative page numbers - query field. 609 class SwRefPageGetFieldType final : public SwFieldType 610 { 611 SwDoc& m_rDoc; 612 sal_Int16 m_nNumberingType; 613 614 void UpdateField(SwTextField const * pTextField, 615 SetGetExpFields const & rSetList, SwRootFrame const* pLayout); 616 617 /// overwritten to update all RefPageGet fields 618 virtual void SwClientNotify(const SwModify&, const SfxHint&) override; 619 public: 620 SwRefPageGetFieldType( SwDoc& rDoc ); 621 virtual std::unique_ptr<SwFieldType> Copy() const override; 622 bool MakeSetList(SetGetExpFields& rTmpLst, SwRootFrame const* pLayout); GetDoc() const623 SwDoc& GetDoc() const { return m_rDoc; } 624 }; 625 626 // Query relative page numbering. 627 class SwRefPageGetField final : public SwField 628 { 629 OUString m_sText; 630 OUString m_sTextRLHidden; ///< hidden redlines 631 632 public: 633 SwRefPageGetField( SwRefPageGetFieldType*, sal_uInt32 nFormat ); 634 635 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; 636 virtual std::unique_ptr<SwField> Copy() const override; 637 638 void SetText(const OUString& rText, SwRootFrame const* pLayout); 639 640 void ChangeExpansion(const SwFrame& rFrame, const SwTextField* pField); 641 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override; 642 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override; 643 }; 644 645 // Field to jump to and edit. 646 class SwJumpEditFieldType final : public SwFieldType 647 { 648 SwDoc& m_rDoc; 649 sw::WriterMultiListener m_aDep; 650 651 public: 652 SwJumpEditFieldType( SwDoc& rDoc ); 653 virtual std::unique_ptr<SwFieldType> Copy() const override; 654 655 SwCharFormat* GetCharFormat(); 656 }; 657 658 class SwJumpEditField final : public SwField 659 { 660 OUString m_sText; 661 OUString m_sHelp; 662 public: 663 SwJumpEditField( SwJumpEditFieldType*, sal_uInt32 nFormat, 664 const OUString& sText, const OUString& sHelp ); 665 666 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; 667 virtual std::unique_ptr<SwField> Copy() const override; 668 669 /// Placeholder-Text 670 virtual OUString GetPar1() const override; 671 virtual void SetPar1(const OUString& rStr) override; 672 673 /// Hint-Text 674 virtual OUString GetPar2() const override; 675 virtual void SetPar2(const OUString& rStr) override; 676 GetCharFormat() const677 SwCharFormat* GetCharFormat() const 678 { return static_cast<SwJumpEditFieldType*>(GetTyp())->GetCharFormat(); } 679 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override; 680 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override; 681 }; 682 683 class SwScriptFieldType final : public SwFieldType 684 { 685 SwDoc& m_rDoc; 686 public: 687 SwScriptFieldType( SwDoc& rDoc ); 688 689 virtual std::unique_ptr<SwFieldType> Copy() const override; 690 }; 691 692 class SW_DLLPUBLIC SwScriptField final : public SwField 693 { 694 OUString m_sType; ///< Type of Code (Java/VBScript/...) 695 OUString m_sCode; /**< Code as text. 696 Code as JavaCode ? */ 697 698 bool m_bCodeURL; ///< Code contains URL of a script. 699 700 public: 701 SwScriptField( SwScriptFieldType*, const OUString& rType, 702 const OUString& rCode, bool bURL ); 703 704 virtual OUString GetDescription() const override; 705 706 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; 707 virtual std::unique_ptr<SwField> Copy() const override; 708 709 /// Type 710 virtual OUString GetPar1() const override; 711 virtual void SetPar1(const OUString& rStr) override; 712 /// Text 713 virtual OUString GetPar2() const override; 714 virtual void SetPar2(const OUString& rStr) override; 715 IsCodeURL() const716 bool IsCodeURL() const { return m_bCodeURL; } SetCodeURL(bool bURL)717 void SetCodeURL( bool bURL ) { m_bCodeURL = bURL; } 718 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override; 719 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override; 720 }; 721 722 // Combined Character Fieldtype 723 class SAL_DLLPUBLIC_RTTI SwCombinedCharFieldType final : public SwFieldType 724 { 725 public: 726 SwCombinedCharFieldType(); 727 728 virtual std::unique_ptr<SwFieldType> Copy() const override; 729 }; 730 731 // ScriptField 732 #define MAX_COMBINED_CHARACTERS 6 733 734 class SW_DLLPUBLIC SwCombinedCharField final : public SwField 735 { 736 OUString m_sCharacters; ///< combine these characters 737 738 public: 739 SwCombinedCharField( SwCombinedCharFieldType*, const OUString& rChars ); 740 741 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; 742 virtual std::unique_ptr<SwField> Copy() const override; 743 744 /// Characters 745 virtual OUString GetPar1() const override; 746 virtual void SetPar1(const OUString& rStr) override; 747 748 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override; 749 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override; 750 }; 751 752 #endif // INCLUDED_SW_INC_DOCUFLD_HXX 753 754 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 755