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 20 /** @#file 21 * 22 * import of all text fields 23 * (except variable related + database display field: see txtvfldi.hxx) 24 */ 25 26 #ifndef INCLUDED_XMLOFF_INC_TXTFLDI_HXX 27 #define INCLUDED_XMLOFF_INC_TXTFLDI_HXX 28 29 #include <com/sun/star/uno/Reference.h> 30 #include <com/sun/star/beans/PropertyValue.hpp> 31 #include <com/sun/star/text/PageNumberType.hpp> 32 #include <com/sun/star/util/DateTime.hpp> 33 #include <xmloff/xmlictxt.hxx> 34 #include <xmloff/txtimp.hxx> 35 #include <xmloff/xmltkmap.hxx> 36 #include <rtl/ustrbuf.hxx> 37 #include <vector> 38 39 namespace com { namespace sun { namespace star { 40 namespace xml { namespace sax { class XAttributeList; } } 41 namespace text { class XTextField; } 42 namespace beans { class XPropertySet; struct PropertyValue; } 43 } } } 44 45 class SvXMLImport; 46 class XMLTextImportHelper; 47 class SvXMLTokenMap; 48 49 enum XMLTextFieldAttrTokens 50 { 51 XML_TOK_TEXTFIELD_FIXED = 0, 52 XML_TOK_TEXTFIELD_DESCRIPTION, 53 XML_TOK_TEXTFIELD_HELP, 54 XML_TOK_TEXTFIELD_HINT, 55 XML_TOK_TEXTFIELD_PLACEHOLDER_TYPE, 56 XML_TOK_TEXTFIELD_TIME_ADJUST, 57 XML_TOK_TEXTFIELD_DATE_ADJUST, 58 XML_TOK_TEXTFIELD_PAGE_ADJUST, 59 XML_TOK_TEXTFIELD_SELECT_PAGE, 60 XML_TOK_TEXTFIELD_ACTIVE, 61 62 XML_TOK_TEXTFIELD_NAME, 63 XML_TOK_TEXTFIELD_FORMULA, 64 XML_TOK_TEXTFIELD_NUM_FORMAT, 65 XML_TOK_TEXTFIELD_NUM_LETTER_SYNC, 66 XML_TOK_TEXTFIELD_DISPLAY_FORMULA, 67 XML_TOK_TEXTFIELD_NUMBERING_LEVEL, 68 XML_TOK_TEXTFIELD_NUMBERING_SEPARATOR, 69 XML_TOK_TEXTFIELD_DISPLAY, 70 XML_TOK_TEXTFIELD_OUTLINE_LEVEL, 71 72 XML_TOK_TEXTFIELD_VALUE_TYPE, 73 XML_TOK_TEXTFIELD_VALUE, 74 XML_TOK_TEXTFIELD_STRING_VALUE, 75 XML_TOK_TEXTFIELD_DATE_VALUE, 76 XML_TOK_TEXTFIELD_TIME_VALUE, 77 XML_TOK_TEXTFIELD_BOOL_VALUE, 78 XML_TOK_TEXTFIELD_CURRENCY, 79 XML_TOK_TEXTFIELD_DATA_STYLE_NAME, 80 81 XML_TOK_TEXTFIELD_DATABASE_NAME, 82 XML_TOK_TEXTFIELD_TABLE_NAME, 83 XML_TOK_TEXTFIELD_COLUMN_NAME, 84 XML_TOK_TEXTFIELD_ROW_NUMBER, 85 XML_TOK_TEXTFIELD_CONDITION, 86 XML_TOK_TEXTFIELD_STRING_VALUE_IF_TRUE, 87 XML_TOK_TEXTFIELD_STRING_VALUE_IF_FALSE, 88 XML_TOK_TEXTFIELD_REVISION, 89 XML_TOK_TEXTFIELD_IS_HIDDEN, 90 XML_TOK_TEXTFIELD_CURRENT_VALUE, 91 92 XML_TOK_TEXTFIELD_REFERENCE_FORMAT, 93 XML_TOK_TEXTFIELD_REFERENCE_LANGUAGE, 94 XML_TOK_TEXTFIELD_REF_NAME, 95 XML_TOK_TEXTFIELD_CONNECTION_NAME, 96 97 XML_TOK_TEXTFIELD_HREF, 98 XML_TOK_TEXTFIELD_TARGET_FRAME, 99 100 XML_TOK_TEXTFIELD_ANNOTATION, 101 XML_TOK_TEXTFIELD_LANGUAGE, 102 103 XML_TOK_TEXTFIELD_MEASURE_KIND, 104 XML_TOK_TEXTFIELD_TABLE_TYPE, 105 106 XML_TOK_TEXTFIELD_NOTE_CLASS, 107 }; 108 109 /// abstract class for text field import 110 class XMLTextFieldImportContext : public SvXMLImportContext 111 { 112 // data members 113 OUStringBuffer sContentBuffer; /// collect character data 114 OUString sContent; /// character data after collection 115 OUString sServiceName; /// service name for text field 116 XMLTextImportHelper& rTextImportHelper; /// the import helper 117 118 protected: 119 OUString sServicePrefix; 120 121 // data members for use in subclasses 122 bool bValid; /// whether this field is valid ? 123 124 public: 125 126 XMLTextFieldImportContext( 127 SvXMLImport& rImport, /// XML Import 128 XMLTextImportHelper& rHlp, /// Text import helper 129 const sal_Char* pService, /// name of SO API service 130 sal_uInt16 nPrfx, /// namespace prefix 131 const OUString& rLocalName); /// element name w/o prefix 132 133 /// process character data: will be collected in member sContentBuffer 134 virtual void Characters( const OUString& sContent ) override; 135 136 /// parses attributes and calls ProcessAttribute 137 virtual void StartElement( 138 const css::uno::Reference< css::xml::sax::XAttributeList> & xAttrList) override; 139 140 /// create XTextField and insert into document; calls PrepareTextField 141 virtual void EndElement() override; 142 143 /// create the appropriate field context from 144 /// (for use in paragraph import) 145 static XMLTextFieldImportContext* CreateTextFieldImportContext( 146 SvXMLImport& rImport, 147 XMLTextImportHelper& rHlp, 148 sal_uInt16 nPrefix, 149 const OUString& rName, 150 sal_uInt16 nToken); 151 152 protected: 153 /// get helper GetImportHelper()154 XMLTextImportHelper& GetImportHelper() { return rTextImportHelper; } 155 GetServiceName() const156 const OUString& GetServiceName() const { return sServiceName; } SetServiceName(const OUString & sStr)157 void SetServiceName(const OUString& sStr) { sServiceName = sStr; } 158 159 OUString const & GetContent(); 160 161 /// process attribute values 162 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 163 const OUString& sAttrValue ) = 0; 164 165 /// prepare XTextField for insertion into document 166 virtual void PrepareField( 167 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) = 0; 168 169 /// create field from ServiceName 170 bool CreateField(css::uno::Reference< css::beans::XPropertySet> & xField, 171 const OUString& sServiceName); 172 173 /// force an update of the field's value 174 /// call update on optional XUpdatable interface; (disable Fixed property) 175 static void ForceUpdate( 176 const css::uno::Reference< css::beans::XPropertySet> & rPropertySet); 177 }; 178 179 class XMLSenderFieldImportContext : public XMLTextFieldImportContext 180 { 181 182 sal_Int16 nSubType; /// API subtype for ExtUser field 183 184 const OUString sPropertyFixed; 185 const OUString sPropertyContent; 186 187 protected: 188 // variables for access in subclass 189 bool bFixed; 190 sal_uInt16 const nElementToken; /// token for this element field 191 192 public: 193 194 XMLSenderFieldImportContext( 195 SvXMLImport& rImport, /// XML Import 196 XMLTextImportHelper& rHlp, /// Text import helper 197 sal_uInt16 nPrfx, /// namespace prefix 198 const OUString& sLocalName, /// element name w/o prefix 199 sal_uInt16 nToken); /// element token 200 201 protected: 202 /// start element 203 virtual void StartElement( 204 const css::uno::Reference< css::xml::sax::XAttributeList> & xAttrList) override; 205 206 /// process attribute values 207 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 208 const OUString& sAttrValue ) override; 209 210 /// prepare XTextField for insertion into document 211 virtual void PrepareField( 212 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override; 213 }; 214 215 /** inherit sender field because of fixed attribute in ProcessAttributes */ 216 class XMLAuthorFieldImportContext : public XMLSenderFieldImportContext 217 { 218 bool bAuthorFullName; 219 const OUString sPropertyFixed; 220 const OUString sPropertyContent; 221 222 public: 223 224 XMLAuthorFieldImportContext( 225 SvXMLImport& rImport, /// XML Import 226 XMLTextImportHelper& rHlp, /// Text import helper 227 sal_uInt16 nPrfx, /// namespace prefix 228 const OUString& sLocalName, /// element name w/o prefix 229 sal_uInt16 nToken); /// element token 230 231 protected: 232 /// start element 233 virtual void StartElement( 234 const css::uno::Reference< css::xml::sax::XAttributeList> & xAttrList) override; 235 236 /// process attribute values 237 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 238 const OUString& sAttrValue ) override; 239 240 /// prepare XTextField for insertion into document 241 virtual void PrepareField( 242 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override; 243 }; 244 245 class XMLPlaceholderFieldImportContext : public XMLTextFieldImportContext 246 { 247 const OUString sPropertyHint; 248 249 OUString sDescription; 250 251 sal_Int16 nPlaceholderType; 252 253 public: 254 255 XMLPlaceholderFieldImportContext( 256 SvXMLImport& rImport, /// XML Import 257 XMLTextImportHelper& rHlp, /// Text import helper 258 sal_uInt16 nPrfx, /// namespace prefix 259 const OUString& sLocalName); /// element name w/o prefix 260 261 protected: 262 /// process attribute values 263 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 264 const OUString& sAttrValue ) override; 265 266 /// prepare XTextField for insertion into document 267 virtual void PrepareField( 268 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override; 269 }; 270 271 class XMLTimeFieldImportContext : public XMLTextFieldImportContext 272 { 273 protected: 274 const OUString sPropertyNumberFormat; 275 const OUString sPropertyFixed; 276 const OUString sPropertyDateTimeValue; 277 const OUString sPropertyDateTime; 278 const OUString sPropertyIsDate; 279 const OUString sPropertyIsFixedLanguage; 280 281 css::util::DateTime aDateTimeValue; 282 sal_Int32 nAdjust; 283 sal_Int32 nFormatKey; 284 bool bTimeOK; 285 bool bFormatOK; 286 bool bFixed; 287 bool bIsDate; // is this a date? 288 // (for XMLDateFieldImportContext, really) 289 bool bIsDefaultLanguage; 290 291 public: 292 293 XMLTimeFieldImportContext( 294 SvXMLImport& rImport, /// XML Import 295 XMLTextImportHelper& rHlp, /// Text import helper 296 sal_uInt16 nPrfx, /// namespace prefix 297 const OUString& sLocalName); /// element name w/o prefix 298 299 /// process attribute values 300 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 301 const OUString& sAttrValue ) override; 302 303 /// prepare XTextField for insertion into document 304 virtual void PrepareField( 305 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override; 306 }; 307 308 /** import date fields (<text:date>); 309 inherit from TimeField to reuse implementation */ 310 class XMLDateFieldImportContext : public XMLTimeFieldImportContext 311 { 312 public: 313 314 XMLDateFieldImportContext( 315 SvXMLImport& rImport, /// XML Import 316 XMLTextImportHelper& rHlp, /// Text import helper 317 sal_uInt16 nPrfx, /// namespace prefix 318 const OUString& sLocalName); /// element name w/o prefix 319 320 /// process attribute values 321 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 322 const OUString& sAttrValue ) override; 323 }; 324 325 /** import page continuation fields (<text:page-continuation-string>) */ 326 class XMLPageContinuationImportContext : public XMLTextFieldImportContext 327 { 328 const OUString sPropertySubType; 329 const OUString sPropertyNumberingType; 330 331 OUString sString; /// continuation string 332 css::text::PageNumberType eSelectPage; /// previous, current 333 /// or next page 334 bool sStringOK; /// continuation string encountered? 335 336 public: 337 338 XMLPageContinuationImportContext( 339 SvXMLImport& rImport, /// XML Import 340 XMLTextImportHelper& rHlp, /// Text import helper 341 sal_uInt16 nPrfx, /// namespace prefix 342 const OUString& sLocalName); /// element name w/o prefix 343 344 /// process attribute values 345 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 346 const OUString& sAttrValue ) override; 347 348 /// prepare XTextField for insertion into document 349 virtual void PrepareField( 350 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override; 351 }; 352 353 /** import page number fields (<text:page-number>) */ 354 class XMLPageNumberImportContext : public XMLTextFieldImportContext 355 { 356 const OUString sPropertySubType; 357 const OUString sPropertyNumberingType; 358 const OUString sPropertyOffset; 359 360 OUString sNumberFormat; 361 OUString sNumberSync; 362 sal_Int16 nPageAdjust; 363 css::text::PageNumberType eSelectPage; /// previous, current 364 /// or next page 365 bool sNumberFormatOK; 366 367 public: 368 369 XMLPageNumberImportContext( 370 SvXMLImport& rImport, /// XML Import 371 XMLTextImportHelper& rHlp, /// Text import helper 372 sal_uInt16 nPrfx, /// namespace prefix 373 const OUString& sLocalName); /// element name w/o prefix 374 375 376 /// process attribute values 377 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 378 const OUString& sAttrValue ) override; 379 380 /// prepare XTextField for insertion into document 381 virtual void PrepareField( 382 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override; 383 }; 384 385 /** superclass for database fields: handle database and table names */ 386 class XMLDatabaseFieldImportContext : public XMLTextFieldImportContext 387 { 388 OUString sDatabaseName; 389 OUString sDatabaseURL; 390 OUString sTableName; 391 392 sal_Int32 nCommandType; 393 bool bCommandTypeOK; 394 395 bool bDisplay; 396 bool bDisplayOK; 397 bool const bUseDisplay; 398 399 protected: 400 bool bDatabaseOK; 401 bool bDatabaseNameOK; 402 bool bDatabaseURLOK; 403 bool bTableOK; 404 405 /// protected constructor: only for subclasses 406 XMLDatabaseFieldImportContext(SvXMLImport& rImport, 407 XMLTextImportHelper& rHlp, 408 const sal_Char* pServiceName, 409 sal_uInt16 nPrfx, 410 const OUString& sLocalName, 411 bool bUseDisplay ); 412 413 public: 414 415 /// process attribute values 416 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 417 const OUString& sAttrValue ) override; 418 419 /// prepare XTextField for insertion into document 420 virtual void PrepareField( 421 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override; 422 423 /// handle database-location children 424 virtual SvXMLImportContextRef CreateChildContext( 425 sal_uInt16 nPrefix, 426 const OUString& rLocalName, 427 const css::uno::Reference< css::xml::sax::XAttributeList> & xAttrList ) override; 428 }; 429 430 /** import database name fields (<text:database-name>) */ 431 class XMLDatabaseNameImportContext : public XMLDatabaseFieldImportContext 432 { 433 public: 434 435 XMLDatabaseNameImportContext(SvXMLImport& rImport, 436 XMLTextImportHelper& rHlp, 437 sal_uInt16 nPrfx, 438 const OUString& sLocalName); 439 440 /// process attribute values 441 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 442 const OUString& sAttrValue ) override; 443 }; 444 445 /** import database next fields (<text:database-next>) */ 446 class XMLDatabaseNextImportContext : public XMLDatabaseFieldImportContext 447 { 448 const OUString sPropertyCondition; 449 const OUString sTrue; 450 OUString sCondition; 451 bool bConditionOK; 452 453 protected: 454 // for use in child classes 455 XMLDatabaseNextImportContext(SvXMLImport& rImport, 456 XMLTextImportHelper& rHlp, 457 const sal_Char* pServiceName, 458 sal_uInt16 nPrfx, 459 const OUString& sLocalName); 460 461 public: 462 463 XMLDatabaseNextImportContext(SvXMLImport& rImport, 464 XMLTextImportHelper& rHlp, 465 sal_uInt16 nPrfx, 466 const OUString& sLocalName); 467 468 /// process attribute values 469 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 470 const OUString& sAttrValue ) override; 471 472 /// prepare XTextField for insertion into document 473 virtual void PrepareField( 474 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override; 475 }; 476 477 /** import database select fields (<text:database-select>) */ 478 class XMLDatabaseSelectImportContext : public XMLDatabaseNextImportContext 479 { 480 const OUString sPropertySetNumber; 481 sal_Int32 nNumber; 482 bool bNumberOK; 483 484 public: 485 486 XMLDatabaseSelectImportContext(SvXMLImport& rImport, 487 XMLTextImportHelper& rHlp, 488 sal_uInt16 nPrfx, 489 const OUString& sLocalName); 490 491 /// process attribute values 492 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 493 const OUString& sAttrValue ) override; 494 495 /// prepare XTextField for insertion into document 496 virtual void PrepareField( 497 const css::uno::Reference< 498 css::beans::XPropertySet> & xPropertySet) override; 499 }; 500 501 /** import database display number fields (<text:database-row-number>) */ 502 class XMLDatabaseNumberImportContext : public XMLDatabaseFieldImportContext 503 { 504 const OUString sPropertyNumberingType; 505 const OUString sPropertySetNumber; 506 OUString sNumberFormat; 507 OUString sNumberSync; 508 sal_Int32 nValue; 509 bool bValueOK; 510 511 public: 512 513 XMLDatabaseNumberImportContext(SvXMLImport& rImport, 514 XMLTextImportHelper& rHlp, 515 sal_uInt16 nPrfx, 516 const OUString& sLocalName); 517 518 /// process attribute values 519 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 520 const OUString& sAttrValue ) override; 521 522 /// prepare XTextField for insertion into document 523 virtual void PrepareField( 524 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override; 525 }; 526 527 /** import docinfo fields with only fixed attribute */ 528 class XMLSimpleDocInfoImportContext : public XMLTextFieldImportContext 529 { 530 const OUString sPropertyFixed; 531 const OUString sPropertyContent; 532 const OUString sPropertyAuthor; 533 const OUString sPropertyCurrentPresentation; 534 535 protected: 536 bool bFixed; 537 bool const bHasAuthor; 538 bool const bHasContent; 539 540 public: 541 542 XMLSimpleDocInfoImportContext(SvXMLImport& rImport, 543 XMLTextImportHelper& rHlp, 544 sal_uInt16 nPrfx, 545 const OUString& sLocalName, 546 sal_uInt16 nToken, 547 bool bContent, 548 bool bAuthor); 549 550 protected: 551 /// process attribute values 552 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 553 const OUString& sAttrValue ) override; 554 555 /// prepare XTextField for insertion into document 556 virtual void PrepareField( 557 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override; 558 559 static const sal_Char* MapTokenToServiceName(sal_uInt16 nToken); 560 }; 561 562 /** import docinfo fields with date or time attributes and numberformats */ 563 class XMLDateTimeDocInfoImportContext : public XMLSimpleDocInfoImportContext 564 { 565 const OUString sPropertyNumberFormat; 566 const OUString sPropertyIsDate; 567 const OUString sPropertyIsFixedLanguage; 568 569 sal_Int32 nFormat; 570 bool bFormatOK; 571 bool bIsDate; 572 bool bHasDateTime; 573 bool bIsDefaultLanguage; 574 575 public: 576 577 XMLDateTimeDocInfoImportContext(SvXMLImport& rImport, 578 XMLTextImportHelper& rHlp, 579 sal_uInt16 nPrfx, 580 const OUString& sLocalName, 581 sal_uInt16 nToken); 582 583 protected: 584 /// process attribute values 585 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 586 const OUString& sAttrValue ) override; 587 588 /// prepare XTextField for insertion into document 589 virtual void PrepareField( 590 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override; 591 }; 592 593 /** import revision field (<text:editing-cycles>) */ 594 class XMLRevisionDocInfoImportContext : public XMLSimpleDocInfoImportContext 595 { 596 public: 597 598 XMLRevisionDocInfoImportContext(SvXMLImport& rImport, 599 XMLTextImportHelper& rHlp, 600 sal_uInt16 nPrfx, 601 const OUString& sLocalName, 602 sal_uInt16 nToken); 603 604 protected: 605 /// prepare XTextField for insertion into document 606 virtual void PrepareField( 607 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 608 }; 609 610 /** import user docinfo field (<text:user-defined>) */ 611 class XMLUserDocInfoImportContext : public XMLSimpleDocInfoImportContext 612 { 613 OUString aName; 614 const OUString sPropertyName; 615 const OUString sPropertyNumberFormat; 616 const OUString sPropertyIsFixedLanguage; 617 sal_Int32 nFormat; 618 bool bFormatOK; 619 bool bIsDefaultLanguage; 620 621 public: 622 623 XMLUserDocInfoImportContext(SvXMLImport& rImport, 624 XMLTextImportHelper& rHlp, 625 sal_uInt16 nPrfx, 626 const OUString& sLocalName, 627 sal_uInt16 nToken); 628 629 protected: 630 /// process attribute values 631 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 632 const OUString& sAttrValue ) override; 633 virtual void PrepareField( 634 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 635 }; 636 637 /** import hidden paragraph fields (<text:hidden-paragraph>) */ 638 class XMLHiddenParagraphImportContext : public XMLTextFieldImportContext 639 { 640 const OUString sPropertyCondition; 641 const OUString sPropertyIsHidden; 642 643 OUString sCondition; 644 bool bIsHidden; 645 646 public: 647 648 XMLHiddenParagraphImportContext(SvXMLImport& rImport, 649 XMLTextImportHelper& rHlp, 650 sal_uInt16 nPrfx, 651 const OUString& sLocalName); 652 653 protected: 654 /// process attribute values 655 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 656 const OUString& sAttrValue ) override; 657 658 /// prepare XTextField for insertion into document 659 virtual void PrepareField( 660 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 661 }; 662 663 /** import conditional text fields (<text:conditional-text>) */ 664 class XMLConditionalTextImportContext : public XMLTextFieldImportContext 665 { 666 const OUString sPropertyCondition; 667 const OUString sPropertyCurrentPresentation; 668 669 OUString sCondition; 670 OUString sTrueContent; 671 OUString sFalseContent; 672 673 bool bConditionOK; 674 bool bTrueOK; 675 bool bFalseOK; 676 bool bCurrentValue; 677 678 public: 679 680 XMLConditionalTextImportContext(SvXMLImport& rImport, 681 XMLTextImportHelper& rHlp, 682 sal_uInt16 nPrfx, 683 const OUString& sLocalName); 684 685 protected: 686 /// process attribute values 687 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 688 const OUString& sAttrValue ) override; 689 690 /// prepare XTextField for insertion into document 691 virtual void PrepareField( 692 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 693 }; 694 695 /** import conditional text fields (<text:hidden-text>) */ 696 class XMLHiddenTextImportContext : public XMLTextFieldImportContext 697 { 698 const OUString sPropertyCondition; 699 const OUString sPropertyContent; 700 const OUString sPropertyIsHidden; 701 702 OUString sCondition; 703 OUString sString; 704 705 bool bConditionOK; 706 bool bStringOK; 707 bool bIsHidden; 708 709 public: 710 711 XMLHiddenTextImportContext(SvXMLImport& rImport, 712 XMLTextImportHelper& rHlp, 713 sal_uInt16 nPrfx, 714 const OUString& sLocalName); 715 716 protected: 717 /// process attribute values 718 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 719 const OUString& sAttrValue ) override; 720 721 /// prepare XTextField for insertion into document 722 virtual void PrepareField( 723 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 724 }; 725 726 /** import file name fields (<text:file-name>) */ 727 class XMLFileNameImportContext : public XMLTextFieldImportContext 728 { 729 const OUString sPropertyFixed; 730 const OUString sPropertyFileFormat; 731 const OUString sPropertyCurrentPresentation; 732 733 sal_Int16 nFormat; 734 bool bFixed; 735 736 public: 737 738 XMLFileNameImportContext(SvXMLImport& rImport, 739 XMLTextImportHelper& rHlp, 740 sal_uInt16 nPrfx, 741 const OUString& sLocalName); 742 743 protected: 744 /// process attribute values 745 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 746 const OUString& sAttrValue ) override; 747 748 /// prepare XTextField for insertion into document 749 virtual void PrepareField( 750 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 751 }; 752 753 /** import document template name fields (<text:template-name>) */ 754 class XMLTemplateNameImportContext : public XMLTextFieldImportContext 755 { 756 const OUString sPropertyFileFormat; 757 758 sal_Int16 nFormat; 759 760 public: 761 762 XMLTemplateNameImportContext(SvXMLImport& rImport, 763 XMLTextImportHelper& rHlp, 764 sal_uInt16 nPrfx, 765 const OUString& sLocalName); 766 767 protected: 768 /// process attribute values 769 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 770 const OUString& sAttrValue ) override; 771 772 /// prepare XTextField for insertion into document 773 virtual void PrepareField( 774 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 775 }; 776 777 /** import chapter fields (<text:chapter>) */ 778 class XMLChapterImportContext : public XMLTextFieldImportContext 779 { 780 sal_Int16 nFormat; 781 sal_Int8 nLevel; 782 783 public: 784 785 XMLChapterImportContext(SvXMLImport& rImport, 786 XMLTextImportHelper& rHlp, 787 sal_uInt16 nPrfx, 788 const OUString& sLocalName); 789 790 protected: 791 /// process attribute values 792 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 793 const OUString& sAttrValue ) override; 794 795 /// prepare XTextField for insertion into document 796 virtual void PrepareField( 797 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 798 }; 799 800 /** import count fields (<text:[XXX]-count>) */ 801 class XMLCountFieldImportContext : public XMLTextFieldImportContext 802 { 803 const OUString sPropertyNumberingType; 804 805 OUString sNumberFormat; 806 OUString sLetterSync; 807 808 bool bNumberFormatOK; 809 810 public: 811 812 XMLCountFieldImportContext(SvXMLImport& rImport, 813 XMLTextImportHelper& rHlp, 814 sal_uInt16 nPrfx, 815 const OUString& sLocalName, 816 sal_uInt16 nToken); 817 818 private: 819 /// process attribute values 820 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 821 const OUString& sAttrValue ) override; 822 823 /// prepare XTextField for insertion into document 824 virtual void PrepareField( 825 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 826 827 static const sal_Char* MapTokenToServiceName(sal_uInt16 nToken); 828 }; 829 830 /** import page variable fields (<text:get-page-variable>) */ 831 class XMLPageVarGetFieldImportContext : public XMLTextFieldImportContext 832 { 833 OUString sNumberFormat; 834 OUString sLetterSync; 835 836 bool bNumberFormatOK; 837 838 public: 839 840 XMLPageVarGetFieldImportContext(SvXMLImport& rImport, 841 XMLTextImportHelper& rHlp, 842 sal_uInt16 nPrfx, 843 const OUString& sLocalName); 844 845 protected: 846 /// process attribute values 847 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 848 const OUString& sAttrValue ) override; 849 850 /// prepare XTextField for insertion into document 851 virtual void PrepareField( 852 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 853 }; 854 855 /** import page variable fields (<text:get-page-variable>) */ 856 class XMLPageVarSetFieldImportContext : public XMLTextFieldImportContext 857 { 858 sal_Int16 nAdjust; 859 bool bActive; 860 861 public: 862 863 XMLPageVarSetFieldImportContext(SvXMLImport& rImport, 864 XMLTextImportHelper& rHlp, 865 sal_uInt16 nPrfx, 866 const OUString& sLocalName); 867 868 protected: 869 /// process attribute values 870 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 871 const OUString& sAttrValue ) override; 872 873 /// prepare XTextField for insertion into document 874 virtual void PrepareField( 875 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 876 }; 877 878 /** import macro fields (<text:execute-macro>) */ 879 class XMLMacroFieldImportContext : public XMLTextFieldImportContext 880 { 881 OUString sDescription; 882 SvXMLImportContextRef xEventContext; 883 884 OUString sMacro; // macro for old documents (pre 638i) 885 886 bool bDescriptionOK; 887 888 public: 889 890 XMLMacroFieldImportContext(SvXMLImport& rImport, 891 XMLTextImportHelper& rHlp, 892 sal_uInt16 nPrfx, 893 const OUString& sLocalName); 894 895 protected: 896 /// for <office:events> children 897 virtual SvXMLImportContextRef CreateChildContext( 898 sal_uInt16 nPrefix, 899 const OUString& rLocalName, 900 const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList ) override; 901 902 /// process attribute values 903 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 904 const OUString& sAttrValue ) override; 905 906 /// prepare XTextField for insertion into document 907 virtual void PrepareField( 908 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 909 }; 910 911 /** import reference fields (<text:reference-get>) */ 912 class XMLReferenceFieldImportContext : public XMLTextFieldImportContext 913 { 914 OUString sName; 915 OUString sLanguage; 916 sal_uInt16 const nElementToken; 917 sal_Int16 nSource; 918 sal_Int16 nType; 919 920 bool bNameOK; 921 bool bTypeOK; 922 923 public: 924 925 XMLReferenceFieldImportContext(SvXMLImport& rImport, 926 XMLTextImportHelper& rHlp, 927 sal_uInt16 nToken, 928 sal_uInt16 nPrfx, 929 const OUString& sLocalName); 930 931 protected: 932 /// start element 933 virtual void StartElement( 934 const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList) override; 935 936 /// process attribute values 937 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 938 const OUString& sAttrValue ) override; 939 940 /// prepare XTextField for insertion into document 941 virtual void PrepareField( 942 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 943 }; 944 945 /** import dde field declaration container (<text:dde-connection-decls>) */ 946 class XMLDdeFieldDeclsImportContext : public SvXMLImportContext 947 { 948 public: 949 950 XMLDdeFieldDeclsImportContext(SvXMLImport& rImport, 951 sal_uInt16 nPrfx, 952 const OUString& sLocalName); 953 954 virtual SvXMLImportContextRef CreateChildContext( 955 sal_uInt16 nPrefix, 956 const OUString& rLocalName, 957 const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList ) override; 958 }; 959 960 /** import dde field declaration (<text:dde-connection-decl>) */ 961 class XMLDdeFieldDeclImportContext : public SvXMLImportContext 962 { 963 const SvXMLTokenMap& rTokenMap; 964 965 public: 966 967 XMLDdeFieldDeclImportContext(SvXMLImport& rImport, 968 sal_uInt16 nPrfx, 969 const OUString& sLocalName, 970 const SvXMLTokenMap& rMap); 971 972 // create fieldmaster 973 virtual void StartElement( 974 const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList) override; 975 }; 976 977 /** import dde fields (<text:dde-connection>) */ 978 class XMLDdeFieldImportContext : public XMLTextFieldImportContext 979 { 980 OUString sName; 981 OUString const sPropertyContent; 982 983 public: 984 985 XMLDdeFieldImportContext(SvXMLImport& rImport, 986 XMLTextImportHelper& rHlp, 987 sal_uInt16 nPrfx, 988 const OUString& sLocalName); 989 990 protected: 991 /// process attribute values 992 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 993 const OUString& sAttrValue ) override; 994 995 /// create textfield, attach master, and insert into document 996 virtual void EndElement() override; 997 998 /// empty method 999 virtual void PrepareField( 1000 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 1001 }; 1002 1003 /** import sheet name fields (Calc) dde fields (<text:sheet-name>) */ 1004 class XMLSheetNameImportContext : public XMLTextFieldImportContext 1005 { 1006 1007 public: 1008 1009 XMLSheetNameImportContext(SvXMLImport& rImport, 1010 XMLTextImportHelper& rHlp, 1011 sal_uInt16 nPrfx, 1012 const OUString& sLocalName); 1013 1014 protected: 1015 /// no attributes -> empty method 1016 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 1017 const OUString& sAttrValue ) override; 1018 1019 /// no attributes -> empty method 1020 virtual void PrepareField( 1021 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 1022 }; 1023 1024 /** import page|slide name fields (<text:page-name>) */ 1025 class XMLPageNameFieldImportContext : public XMLTextFieldImportContext 1026 { 1027 public: 1028 1029 XMLPageNameFieldImportContext( 1030 SvXMLImport& rImport, /// XML Import 1031 XMLTextImportHelper& rHlp, /// Text import helper 1032 sal_uInt16 nPrfx, /// namespace prefix 1033 const OUString& sLocalName); /// element name w/o prefix 1034 1035 /// process attribute values 1036 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 1037 const OUString& sAttrValue ) override; 1038 1039 /// prepare XTextField for insertion into document 1040 virtual void PrepareField( 1041 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 1042 }; 1043 1044 /** import hyperlinks as URL fields (Calc, Impress, Draw) (<office:a>) */ 1045 class XMLUrlFieldImportContext : public XMLTextFieldImportContext 1046 { 1047 OUString sURL; 1048 OUString sFrame; 1049 bool bFrameOK; 1050 1051 public: 1052 1053 XMLUrlFieldImportContext(SvXMLImport& rImport, 1054 XMLTextImportHelper& rHlp, 1055 sal_uInt16 nPrfx, 1056 const OUString& sLocalName); 1057 1058 protected: 1059 /// no attributes -> empty method 1060 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 1061 const OUString& sAttrValue ) override; 1062 1063 /// no attributes -> empty method 1064 virtual void PrepareField( 1065 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 1066 }; 1067 1068 /** import bibliography info fields (<text:bibliography-mark>) */ 1069 class XMLBibliographyFieldImportContext : public XMLTextFieldImportContext 1070 { 1071 ::std::vector< css::beans::PropertyValue> aValues; 1072 1073 public: 1074 1075 XMLBibliographyFieldImportContext(SvXMLImport& rImport, 1076 XMLTextImportHelper& rHlp, 1077 sal_uInt16 nPrfx, 1078 const OUString& sLocalName); 1079 1080 private: 1081 /// process attributes (fill aValues) 1082 virtual void StartElement( 1083 const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList) override; 1084 1085 /// empty method; all attributes are handled in StartElement 1086 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 1087 const OUString& sAttrValue ) override; 1088 1089 /// convert aValues into sequence and set property 1090 virtual void PrepareField( 1091 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 1092 1093 static const sal_Char* MapBibliographyFieldName(const OUString& sName); 1094 }; 1095 1096 /** Import an annotation field (<text:annotation>) */ 1097 class XMLAnnotationImportContext : public XMLTextFieldImportContext 1098 { 1099 OUStringBuffer aAuthorBuffer; 1100 OUStringBuffer aInitialsBuffer; 1101 OUString aName; 1102 OUStringBuffer aTextBuffer; 1103 OUStringBuffer aDateBuffer; 1104 OUString aResolved; 1105 1106 css::uno::Reference < css::beans::XPropertySet > mxField; 1107 css::uno::Reference < css::text::XTextCursor > mxCursor; 1108 css::uno::Reference < css::text::XTextCursor > mxOldCursor; 1109 1110 sal_uInt16 const m_nToken; 1111 1112 public: 1113 1114 XMLAnnotationImportContext(SvXMLImport& rImport, 1115 XMLTextImportHelper& rHlp, 1116 sal_uInt16 nToken, 1117 sal_uInt16 nPrfx, 1118 const OUString& sLocalName); 1119 1120 protected: 1121 /// process attributes 1122 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 1123 const OUString& sAttrValue ) override; 1124 1125 /// set properties 1126 virtual void PrepareField( 1127 const css::uno::Reference< css::beans::XPropertySet > & xPropertySet) override; 1128 1129 virtual SvXMLImportContextRef CreateChildContext( 1130 sal_uInt16 nPrefix, 1131 const OUString& rLocalName, 1132 const css::uno::Reference<css::xml::sax::XAttributeList >& xAttrList ) override; 1133 virtual void EndElement() override; 1134 }; 1135 1136 /** Import a script field (<text:script>) */ 1137 class XMLScriptImportContext : public XMLTextFieldImportContext 1138 { 1139 OUString sContent; 1140 OUString sScriptType; 1141 1142 bool bContentOK; 1143 1144 public: 1145 1146 XMLScriptImportContext(SvXMLImport& rImport, 1147 XMLTextImportHelper& rHlp, 1148 sal_uInt16 nPrfx, 1149 const OUString& sLocalName); 1150 1151 protected: 1152 /// process attributes 1153 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 1154 const OUString& sAttrValue ) override; 1155 1156 /// set properties 1157 virtual void PrepareField( 1158 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 1159 }; 1160 1161 /** import measure fields (<text:measure>) */ 1162 class XMLMeasureFieldImportContext : public XMLTextFieldImportContext 1163 { 1164 sal_Int16 mnKind; 1165 1166 public: 1167 1168 XMLMeasureFieldImportContext(SvXMLImport& rImport, 1169 XMLTextImportHelper& rHlp, 1170 sal_uInt16 nPrfx, 1171 const OUString& sLocalName); 1172 1173 protected: 1174 /// process attribute values 1175 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 1176 const OUString& sAttrValue ) override; 1177 1178 /// prepare XTextField for insertion into document 1179 virtual void PrepareField( 1180 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 1181 }; 1182 1183 /** dropdown field (filter legacy) */ 1184 class XMLDropDownFieldImportContext : public XMLTextFieldImportContext 1185 { 1186 std::vector<OUString> aLabels; 1187 OUString sName; 1188 OUString sHelp; 1189 OUString sHint; 1190 sal_Int32 nSelected; 1191 bool bNameOK; 1192 bool bHelpOK; 1193 bool bHintOK; 1194 1195 public: 1196 1197 XMLDropDownFieldImportContext(SvXMLImport& rImport, 1198 XMLTextImportHelper& rHlp, 1199 sal_uInt16 nPrfx, 1200 const OUString& sLocalName); 1201 1202 virtual SvXMLImportContextRef CreateChildContext( 1203 sal_uInt16 nPrefix, 1204 const OUString& rLocalName, 1205 const css::uno::Reference<css::xml::sax::XAttributeList >& xAttrList ) override; 1206 1207 protected: 1208 /// process attribute values 1209 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 1210 const OUString& sAttrValue ) override; 1211 1212 /// prepare XTextField for insertion into document 1213 virtual void PrepareField( 1214 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 1215 }; 1216 1217 /** import header fields (<draw:header>) */ 1218 class XMLHeaderFieldImportContext : public XMLTextFieldImportContext 1219 { 1220 public: 1221 1222 XMLHeaderFieldImportContext( 1223 SvXMLImport& rImport, /// XML Import 1224 XMLTextImportHelper& rHlp, /// Text import helper 1225 sal_uInt16 nPrfx, /// namespace prefix 1226 const OUString& sLocalName); /// element name w/o prefix 1227 1228 /// process attribute values 1229 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 1230 const OUString& sAttrValue ) override; 1231 1232 /// prepare XTextField for insertion into document 1233 virtual void PrepareField( 1234 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 1235 }; 1236 1237 /** import footer fields (<draw:footer>) */ 1238 class XMLFooterFieldImportContext : public XMLTextFieldImportContext 1239 { 1240 public: 1241 1242 XMLFooterFieldImportContext( 1243 SvXMLImport& rImport, /// XML Import 1244 XMLTextImportHelper& rHlp, /// Text import helper 1245 sal_uInt16 nPrfx, /// namespace prefix 1246 const OUString& sLocalName); /// element name w/o prefix 1247 1248 /// process attribute values 1249 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 1250 const OUString& sAttrValue ) override; 1251 1252 /// prepare XTextField for insertion into document 1253 virtual void PrepareField( 1254 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 1255 }; 1256 1257 /** import footer fields (<draw:date-and-time>) */ 1258 class XMLDateTimeFieldImportContext : public XMLTextFieldImportContext 1259 { 1260 public: 1261 1262 XMLDateTimeFieldImportContext( 1263 SvXMLImport& rImport, /// XML Import 1264 XMLTextImportHelper& rHlp, /// Text import helper 1265 sal_uInt16 nPrfx, /// namespace prefix 1266 const OUString& sLocalName); /// element name w/o prefix 1267 1268 /// process attribute values 1269 virtual void ProcessAttribute( sal_uInt16 nAttrToken, 1270 const OUString& sAttrValue ) override; 1271 1272 /// prepare XTextField for insertion into document 1273 virtual void PrepareField( 1274 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; 1275 }; 1276 1277 #endif 1278 1279 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 1280