loplugin:constmethod in xmloff
[LibreOffice.git] / xmloff / inc / txtfldi.hxx
blob1bff41f8c29c366e21ac710567e262ef070844e5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 /** @#file
22 * import of all text fields
23 * (except variable related + database display field: see txtvfldi.hxx)
26 #ifndef INCLUDED_XMLOFF_INC_TXTFLDI_HXX
27 #define INCLUDED_XMLOFF_INC_TXTFLDI_HXX
29 #include <com/sun/star/uno/Reference.h>
30 #include <com/sun/star/text/PageNumberType.hpp>
31 #include <com/sun/star/util/DateTime.hpp>
32 #include <com/sun/star/util/Date.hpp>
33 #include <xmloff/xmlictxt.hxx>
34 #include <xmloff/txtimp.hxx>
35 #include <xmloff/xmltkmap.hxx>
36 #include <rtl/ustrbuf.hxx>
37 #include <vector>
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 } } }
45 class SvXMLImport;
46 class XMLTextImportHelper;
47 class SvXMLTokenMap;
49 enum XMLTextFieldAttrTokens
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,
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,
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,
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,
92 XML_TOK_TEXTFIELD_REFERENCE_FORMAT,
93 XML_TOK_TEXTFIELD_REFERENCE_LANGUAGE,
94 XML_TOK_TEXTFIELD_REF_NAME,
95 XML_TOK_TEXTFIELD_CONNECTION_NAME,
97 XML_TOK_TEXTFIELD_HREF,
98 XML_TOK_TEXTFIELD_TARGET_FRAME,
100 XML_TOK_TEXTFIELD_ANNOTATION,
101 XML_TOK_TEXTFIELD_LANGUAGE,
103 XML_TOK_TEXTFIELD_MEASURE_KIND,
104 XML_TOK_TEXTFIELD_TABLE_TYPE,
106 XML_TOK_TEXTFIELD_NOTE_CLASS,
109 /// abstract class for text field import
110 class XMLTextFieldImportContext : public SvXMLImportContext
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
118 protected:
119 OUString sServicePrefix;
121 // data members for use in subclasses
122 bool bValid; /// whether this field is valid ?
124 public:
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
133 /// process character data: will be collected in member sContentBuffer
134 virtual void Characters( const OUString& sContent ) override;
136 /// parses attributes and calls ProcessAttribute
137 virtual void StartElement(
138 const css::uno::Reference< css::xml::sax::XAttributeList> & xAttrList) override;
140 /// create XTextField and insert into document; calls PrepareTextField
141 virtual void EndElement() override;
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);
152 protected:
153 /// get helper
154 XMLTextImportHelper& GetImportHelper() { return rTextImportHelper; }
156 const OUString& GetServiceName() const { return sServiceName; }
157 void SetServiceName(const OUString& sStr) { sServiceName = sStr; }
159 OUString const & GetContent();
161 /// process attribute values
162 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
163 const OUString& sAttrValue ) = 0;
165 /// prepare XTextField for insertion into document
166 virtual void PrepareField(
167 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) = 0;
169 /// create field from ServiceName
170 bool CreateField(css::uno::Reference< css::beans::XPropertySet> & xField,
171 const OUString& sServiceName);
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);
179 class XMLSenderFieldImportContext : public XMLTextFieldImportContext
182 sal_Int16 nSubType; /// API subtype for ExtUser field
184 const OUString sPropertyFixed;
185 const OUString sPropertyContent;
187 protected:
188 // variables for access in subclass
189 bool bFixed;
190 sal_uInt16 const nElementToken; /// token for this element field
192 public:
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
201 protected:
202 /// start element
203 virtual void StartElement(
204 const css::uno::Reference< css::xml::sax::XAttributeList> & xAttrList) override;
206 /// process attribute values
207 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
208 const OUString& sAttrValue ) override;
210 /// prepare XTextField for insertion into document
211 virtual void PrepareField(
212 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
215 /** inherit sender field because of fixed attribute in ProcessAttributes */
216 class XMLAuthorFieldImportContext : public XMLSenderFieldImportContext
218 bool bAuthorFullName;
219 const OUString sPropertyFixed;
220 const OUString sPropertyContent;
222 public:
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
231 protected:
232 /// start element
233 virtual void StartElement(
234 const css::uno::Reference< css::xml::sax::XAttributeList> & xAttrList) override;
236 /// process attribute values
237 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
238 const OUString& sAttrValue ) override;
240 /// prepare XTextField for insertion into document
241 virtual void PrepareField(
242 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
245 class XMLPlaceholderFieldImportContext : public XMLTextFieldImportContext
247 const OUString sPropertyHint;
249 OUString sDescription;
251 sal_Int16 nPlaceholderType;
253 public:
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
261 protected:
262 /// process attribute values
263 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
264 const OUString& sAttrValue ) override;
266 /// prepare XTextField for insertion into document
267 virtual void PrepareField(
268 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
271 class XMLTimeFieldImportContext : public XMLTextFieldImportContext
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;
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;
291 public:
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
299 /// process attribute values
300 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
301 const OUString& sAttrValue ) override;
303 /// prepare XTextField for insertion into document
304 virtual void PrepareField(
305 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
308 /** import date fields (<text:date>);
309 inherit from TimeField to reuse implementation */
310 class XMLDateFieldImportContext : public XMLTimeFieldImportContext
312 public:
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
320 /// process attribute values
321 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
322 const OUString& sAttrValue ) override;
325 /** import page continuation fields (<text:page-continuation-string>) */
326 class XMLPageContinuationImportContext : public XMLTextFieldImportContext
328 const OUString sPropertySubType;
329 const OUString sPropertyNumberingType;
331 OUString sString; /// continuation string
332 css::text::PageNumberType eSelectPage; /// previous, current
333 /// or next page
334 bool sStringOK; /// continuation string encountered?
336 public:
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
344 /// process attribute values
345 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
346 const OUString& sAttrValue ) override;
348 /// prepare XTextField for insertion into document
349 virtual void PrepareField(
350 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
353 /** import page number fields (<text:page-number>) */
354 class XMLPageNumberImportContext : public XMLTextFieldImportContext
356 const OUString sPropertySubType;
357 const OUString sPropertyNumberingType;
358 const OUString sPropertyOffset;
360 OUString sNumberFormat;
361 OUString sNumberSync;
362 sal_Int16 nPageAdjust;
363 css::text::PageNumberType eSelectPage; /// previous, current
364 /// or next page
365 bool sNumberFormatOK;
367 public:
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
376 /// process attribute values
377 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
378 const OUString& sAttrValue ) override;
380 /// prepare XTextField for insertion into document
381 virtual void PrepareField(
382 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
385 /** superclass for database fields: handle database and table names */
386 class XMLDatabaseFieldImportContext : public XMLTextFieldImportContext
388 OUString sDatabaseName;
389 OUString sDatabaseURL;
390 OUString sTableName;
392 sal_Int32 nCommandType;
393 bool bCommandTypeOK;
395 bool bDisplay;
396 bool bDisplayOK;
397 bool const bUseDisplay;
399 protected:
400 bool bDatabaseOK;
401 bool bDatabaseNameOK;
402 bool bDatabaseURLOK;
403 bool bTableOK;
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 );
413 public:
415 /// process attribute values
416 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
417 const OUString& sAttrValue ) override;
419 /// prepare XTextField for insertion into document
420 virtual void PrepareField(
421 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
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;
430 /** import database name fields (<text:database-name>) */
431 class XMLDatabaseNameImportContext : public XMLDatabaseFieldImportContext
433 public:
435 XMLDatabaseNameImportContext(SvXMLImport& rImport,
436 XMLTextImportHelper& rHlp,
437 sal_uInt16 nPrfx,
438 const OUString& sLocalName);
440 /// process attribute values
441 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
442 const OUString& sAttrValue ) override;
445 /** import database next fields (<text:database-next>) */
446 class XMLDatabaseNextImportContext : public XMLDatabaseFieldImportContext
448 const OUString sPropertyCondition;
449 const OUString sTrue;
450 OUString sCondition;
451 bool bConditionOK;
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);
461 public:
463 XMLDatabaseNextImportContext(SvXMLImport& rImport,
464 XMLTextImportHelper& rHlp,
465 sal_uInt16 nPrfx,
466 const OUString& sLocalName);
468 /// process attribute values
469 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
470 const OUString& sAttrValue ) override;
472 /// prepare XTextField for insertion into document
473 virtual void PrepareField(
474 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
477 /** import database select fields (<text:database-select>) */
478 class XMLDatabaseSelectImportContext : public XMLDatabaseNextImportContext
480 const OUString sPropertySetNumber;
481 sal_Int32 nNumber;
482 bool bNumberOK;
484 public:
486 XMLDatabaseSelectImportContext(SvXMLImport& rImport,
487 XMLTextImportHelper& rHlp,
488 sal_uInt16 nPrfx,
489 const OUString& sLocalName);
491 /// process attribute values
492 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
493 const OUString& sAttrValue ) override;
495 /// prepare XTextField for insertion into document
496 virtual void PrepareField(
497 const css::uno::Reference<
498 css::beans::XPropertySet> & xPropertySet) override;
501 /** import database display number fields (<text:database-row-number>) */
502 class XMLDatabaseNumberImportContext : public XMLDatabaseFieldImportContext
504 const OUString sPropertyNumberingType;
505 const OUString sPropertySetNumber;
506 OUString sNumberFormat;
507 OUString sNumberSync;
508 sal_Int32 nValue;
509 bool bValueOK;
511 public:
513 XMLDatabaseNumberImportContext(SvXMLImport& rImport,
514 XMLTextImportHelper& rHlp,
515 sal_uInt16 nPrfx,
516 const OUString& sLocalName);
518 /// process attribute values
519 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
520 const OUString& sAttrValue ) override;
522 /// prepare XTextField for insertion into document
523 virtual void PrepareField(
524 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
527 /** import docinfo fields with only fixed attribute */
528 class XMLSimpleDocInfoImportContext : public XMLTextFieldImportContext
530 const OUString sPropertyFixed;
531 const OUString sPropertyContent;
532 const OUString sPropertyAuthor;
533 const OUString sPropertyCurrentPresentation;
535 protected:
536 bool bFixed;
537 bool const bHasAuthor;
538 bool const bHasContent;
540 public:
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);
550 protected:
551 /// process attribute values
552 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
553 const OUString& sAttrValue ) override;
555 /// prepare XTextField for insertion into document
556 virtual void PrepareField(
557 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
559 static const sal_Char* MapTokenToServiceName(sal_uInt16 nToken);
562 /** import docinfo fields with date or time attributes and numberformats */
563 class XMLDateTimeDocInfoImportContext : public XMLSimpleDocInfoImportContext
565 const OUString sPropertyNumberFormat;
566 const OUString sPropertyIsDate;
567 const OUString sPropertyIsFixedLanguage;
569 sal_Int32 nFormat;
570 bool bFormatOK;
571 bool bIsDate;
572 bool bHasDateTime;
573 bool bIsDefaultLanguage;
575 public:
577 XMLDateTimeDocInfoImportContext(SvXMLImport& rImport,
578 XMLTextImportHelper& rHlp,
579 sal_uInt16 nPrfx,
580 const OUString& sLocalName,
581 sal_uInt16 nToken);
583 protected:
584 /// process attribute values
585 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
586 const OUString& sAttrValue ) override;
588 /// prepare XTextField for insertion into document
589 virtual void PrepareField(
590 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
593 /** import revision field (<text:editing-cycles>) */
594 class XMLRevisionDocInfoImportContext : public XMLSimpleDocInfoImportContext
596 public:
598 XMLRevisionDocInfoImportContext(SvXMLImport& rImport,
599 XMLTextImportHelper& rHlp,
600 sal_uInt16 nPrfx,
601 const OUString& sLocalName,
602 sal_uInt16 nToken);
604 protected:
605 /// prepare XTextField for insertion into document
606 virtual void PrepareField(
607 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
610 /** import user docinfo field (<text:user-defined>) */
611 class XMLUserDocInfoImportContext : public XMLSimpleDocInfoImportContext
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;
621 public:
623 XMLUserDocInfoImportContext(SvXMLImport& rImport,
624 XMLTextImportHelper& rHlp,
625 sal_uInt16 nPrfx,
626 const OUString& sLocalName,
627 sal_uInt16 nToken);
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;
637 /** import hidden paragraph fields (<text:hidden-paragraph>) */
638 class XMLHiddenParagraphImportContext : public XMLTextFieldImportContext
640 const OUString sPropertyCondition;
641 const OUString sPropertyIsHidden;
643 OUString sCondition;
644 bool bIsHidden;
646 public:
648 XMLHiddenParagraphImportContext(SvXMLImport& rImport,
649 XMLTextImportHelper& rHlp,
650 sal_uInt16 nPrfx,
651 const OUString& sLocalName);
653 protected:
654 /// process attribute values
655 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
656 const OUString& sAttrValue ) override;
658 /// prepare XTextField for insertion into document
659 virtual void PrepareField(
660 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
663 /** import conditional text fields (<text:conditional-text>) */
664 class XMLConditionalTextImportContext : public XMLTextFieldImportContext
666 const OUString sPropertyCondition;
667 const OUString sPropertyCurrentPresentation;
669 OUString sCondition;
670 OUString sTrueContent;
671 OUString sFalseContent;
673 bool bConditionOK;
674 bool bTrueOK;
675 bool bFalseOK;
676 bool bCurrentValue;
678 public:
680 XMLConditionalTextImportContext(SvXMLImport& rImport,
681 XMLTextImportHelper& rHlp,
682 sal_uInt16 nPrfx,
683 const OUString& sLocalName);
685 protected:
686 /// process attribute values
687 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
688 const OUString& sAttrValue ) override;
690 /// prepare XTextField for insertion into document
691 virtual void PrepareField(
692 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
695 /** import conditional text fields (<text:hidden-text>) */
696 class XMLHiddenTextImportContext : public XMLTextFieldImportContext
698 const OUString sPropertyCondition;
699 const OUString sPropertyContent;
700 const OUString sPropertyIsHidden;
702 OUString sCondition;
703 OUString sString;
705 bool bConditionOK;
706 bool bStringOK;
707 bool bIsHidden;
709 public:
711 XMLHiddenTextImportContext(SvXMLImport& rImport,
712 XMLTextImportHelper& rHlp,
713 sal_uInt16 nPrfx,
714 const OUString& sLocalName);
716 protected:
717 /// process attribute values
718 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
719 const OUString& sAttrValue ) override;
721 /// prepare XTextField for insertion into document
722 virtual void PrepareField(
723 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
726 /** import file name fields (<text:file-name>) */
727 class XMLFileNameImportContext : public XMLTextFieldImportContext
729 const OUString sPropertyFixed;
730 const OUString sPropertyFileFormat;
731 const OUString sPropertyCurrentPresentation;
733 sal_Int16 nFormat;
734 bool bFixed;
736 public:
738 XMLFileNameImportContext(SvXMLImport& rImport,
739 XMLTextImportHelper& rHlp,
740 sal_uInt16 nPrfx,
741 const OUString& sLocalName);
743 protected:
744 /// process attribute values
745 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
746 const OUString& sAttrValue ) override;
748 /// prepare XTextField for insertion into document
749 virtual void PrepareField(
750 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
753 /** import document template name fields (<text:template-name>) */
754 class XMLTemplateNameImportContext : public XMLTextFieldImportContext
756 const OUString sPropertyFileFormat;
758 sal_Int16 nFormat;
760 public:
762 XMLTemplateNameImportContext(SvXMLImport& rImport,
763 XMLTextImportHelper& rHlp,
764 sal_uInt16 nPrfx,
765 const OUString& sLocalName);
767 protected:
768 /// process attribute values
769 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
770 const OUString& sAttrValue ) override;
772 /// prepare XTextField for insertion into document
773 virtual void PrepareField(
774 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
777 /** import chapter fields (<text:chapter>) */
778 class XMLChapterImportContext : public XMLTextFieldImportContext
780 sal_Int16 nFormat;
781 sal_Int8 nLevel;
783 public:
785 XMLChapterImportContext(SvXMLImport& rImport,
786 XMLTextImportHelper& rHlp,
787 sal_uInt16 nPrfx,
788 const OUString& sLocalName);
790 protected:
791 /// process attribute values
792 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
793 const OUString& sAttrValue ) override;
795 /// prepare XTextField for insertion into document
796 virtual void PrepareField(
797 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
800 /** import count fields (<text:[XXX]-count>) */
801 class XMLCountFieldImportContext : public XMLTextFieldImportContext
803 const OUString sPropertyNumberingType;
805 OUString sNumberFormat;
806 OUString sLetterSync;
808 bool bNumberFormatOK;
810 public:
812 XMLCountFieldImportContext(SvXMLImport& rImport,
813 XMLTextImportHelper& rHlp,
814 sal_uInt16 nPrfx,
815 const OUString& sLocalName,
816 sal_uInt16 nToken);
818 private:
819 /// process attribute values
820 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
821 const OUString& sAttrValue ) override;
823 /// prepare XTextField for insertion into document
824 virtual void PrepareField(
825 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
827 static const sal_Char* MapTokenToServiceName(sal_uInt16 nToken);
830 /** import page variable fields (<text:get-page-variable>) */
831 class XMLPageVarGetFieldImportContext : public XMLTextFieldImportContext
833 OUString sNumberFormat;
834 OUString sLetterSync;
836 bool bNumberFormatOK;
838 public:
840 XMLPageVarGetFieldImportContext(SvXMLImport& rImport,
841 XMLTextImportHelper& rHlp,
842 sal_uInt16 nPrfx,
843 const OUString& sLocalName);
845 protected:
846 /// process attribute values
847 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
848 const OUString& sAttrValue ) override;
850 /// prepare XTextField for insertion into document
851 virtual void PrepareField(
852 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
855 /** import page variable fields (<text:get-page-variable>) */
856 class XMLPageVarSetFieldImportContext : public XMLTextFieldImportContext
858 sal_Int16 nAdjust;
859 bool bActive;
861 public:
863 XMLPageVarSetFieldImportContext(SvXMLImport& rImport,
864 XMLTextImportHelper& rHlp,
865 sal_uInt16 nPrfx,
866 const OUString& sLocalName);
868 protected:
869 /// process attribute values
870 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
871 const OUString& sAttrValue ) override;
873 /// prepare XTextField for insertion into document
874 virtual void PrepareField(
875 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
878 /** import macro fields (<text:execute-macro>) */
879 class XMLMacroFieldImportContext : public XMLTextFieldImportContext
881 OUString sDescription;
882 SvXMLImportContextRef xEventContext;
884 OUString sMacro; // macro for old documents (pre 638i)
886 bool bDescriptionOK;
888 public:
890 XMLMacroFieldImportContext(SvXMLImport& rImport,
891 XMLTextImportHelper& rHlp,
892 sal_uInt16 nPrfx,
893 const OUString& sLocalName);
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;
902 /// process attribute values
903 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
904 const OUString& sAttrValue ) override;
906 /// prepare XTextField for insertion into document
907 virtual void PrepareField(
908 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
911 /** import reference fields (<text:reference-get>) */
912 class XMLReferenceFieldImportContext : public XMLTextFieldImportContext
914 OUString sName;
915 OUString sLanguage;
916 sal_uInt16 const nElementToken;
917 sal_Int16 nSource;
918 sal_Int16 nType;
920 bool bNameOK;
921 bool bTypeOK;
923 public:
925 XMLReferenceFieldImportContext(SvXMLImport& rImport,
926 XMLTextImportHelper& rHlp,
927 sal_uInt16 nToken,
928 sal_uInt16 nPrfx,
929 const OUString& sLocalName);
931 protected:
932 /// start element
933 virtual void StartElement(
934 const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList) override;
936 /// process attribute values
937 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
938 const OUString& sAttrValue ) override;
940 /// prepare XTextField for insertion into document
941 virtual void PrepareField(
942 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
945 /** import dde field declaration container (<text:dde-connection-decls>) */
946 class XMLDdeFieldDeclsImportContext : public SvXMLImportContext
948 public:
950 XMLDdeFieldDeclsImportContext(SvXMLImport& rImport,
951 sal_uInt16 nPrfx,
952 const OUString& sLocalName);
954 virtual SvXMLImportContextRef CreateChildContext(
955 sal_uInt16 nPrefix,
956 const OUString& rLocalName,
957 const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList ) override;
960 /** import dde field declaration (<text:dde-connection-decl>) */
961 class XMLDdeFieldDeclImportContext : public SvXMLImportContext
963 const SvXMLTokenMap& rTokenMap;
965 public:
967 XMLDdeFieldDeclImportContext(SvXMLImport& rImport,
968 sal_uInt16 nPrfx,
969 const OUString& sLocalName,
970 const SvXMLTokenMap& rMap);
972 // create fieldmaster
973 virtual void StartElement(
974 const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList) override;
977 /** import dde fields (<text:dde-connection>) */
978 class XMLDdeFieldImportContext : public XMLTextFieldImportContext
980 OUString sName;
981 OUString const sPropertyContent;
983 public:
985 XMLDdeFieldImportContext(SvXMLImport& rImport,
986 XMLTextImportHelper& rHlp,
987 sal_uInt16 nPrfx,
988 const OUString& sLocalName);
990 protected:
991 /// process attribute values
992 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
993 const OUString& sAttrValue ) override;
995 /// create textfield, attach master, and insert into document
996 virtual void EndElement() override;
998 /// empty method
999 virtual void PrepareField(
1000 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1003 /** import sheet name fields (Calc) dde fields (<text:sheet-name>) */
1004 class XMLSheetNameImportContext : public XMLTextFieldImportContext
1007 public:
1009 XMLSheetNameImportContext(SvXMLImport& rImport,
1010 XMLTextImportHelper& rHlp,
1011 sal_uInt16 nPrfx,
1012 const OUString& sLocalName);
1014 protected:
1015 /// no attributes -> empty method
1016 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
1017 const OUString& sAttrValue ) override;
1019 /// no attributes -> empty method
1020 virtual void PrepareField(
1021 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1024 /** import page|slide name fields (<text:page-name>) */
1025 class XMLPageNameFieldImportContext : public XMLTextFieldImportContext
1027 public:
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
1035 /// process attribute values
1036 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
1037 const OUString& sAttrValue ) override;
1039 /// prepare XTextField for insertion into document
1040 virtual void PrepareField(
1041 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1044 /** import hyperlinks as URL fields (Calc, Impress, Draw) (<office:a>) */
1045 class XMLUrlFieldImportContext : public XMLTextFieldImportContext
1047 OUString sURL;
1048 OUString sFrame;
1049 bool bFrameOK;
1051 public:
1053 XMLUrlFieldImportContext(SvXMLImport& rImport,
1054 XMLTextImportHelper& rHlp,
1055 sal_uInt16 nPrfx,
1056 const OUString& sLocalName);
1058 protected:
1059 /// no attributes -> empty method
1060 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
1061 const OUString& sAttrValue ) override;
1063 /// no attributes -> empty method
1064 virtual void PrepareField(
1065 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1068 /** import bibliography info fields (<text:bibliography-mark>) */
1069 class XMLBibliographyFieldImportContext : public XMLTextFieldImportContext
1071 ::std::vector< css::beans::PropertyValue> aValues;
1073 public:
1075 XMLBibliographyFieldImportContext(SvXMLImport& rImport,
1076 XMLTextImportHelper& rHlp,
1077 sal_uInt16 nPrfx,
1078 const OUString& sLocalName);
1080 private:
1081 /// process attributes (fill aValues)
1082 virtual void StartElement(
1083 const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList) override;
1085 /// empty method; all attributes are handled in StartElement
1086 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
1087 const OUString& sAttrValue ) override;
1089 /// convert aValues into sequence and set property
1090 virtual void PrepareField(
1091 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1093 static const sal_Char* MapBibliographyFieldName(const OUString& sName);
1096 /** Import an annotation field (<text:annotation>) */
1097 class XMLAnnotationImportContext : public XMLTextFieldImportContext
1099 OUStringBuffer aAuthorBuffer;
1100 OUStringBuffer aInitialsBuffer;
1101 OUString aName;
1102 OUStringBuffer aTextBuffer;
1103 OUStringBuffer aDateBuffer;
1104 OUString aResolved;
1106 css::uno::Reference < css::beans::XPropertySet > mxField;
1107 css::uno::Reference < css::text::XTextCursor > mxCursor;
1108 css::uno::Reference < css::text::XTextCursor > mxOldCursor;
1110 sal_uInt16 const m_nToken;
1112 public:
1114 XMLAnnotationImportContext(SvXMLImport& rImport,
1115 XMLTextImportHelper& rHlp,
1116 sal_uInt16 nToken,
1117 sal_uInt16 nPrfx,
1118 const OUString& sLocalName);
1120 protected:
1121 /// process attributes
1122 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
1123 const OUString& sAttrValue ) override;
1125 /// set properties
1126 virtual void PrepareField(
1127 const css::uno::Reference< css::beans::XPropertySet > & xPropertySet) override;
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;
1136 /** Import a script field (<text:script>) */
1137 class XMLScriptImportContext : public XMLTextFieldImportContext
1139 OUString sContent;
1140 OUString sScriptType;
1142 bool bContentOK;
1144 public:
1146 XMLScriptImportContext(SvXMLImport& rImport,
1147 XMLTextImportHelper& rHlp,
1148 sal_uInt16 nPrfx,
1149 const OUString& sLocalName);
1151 protected:
1152 /// process attributes
1153 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
1154 const OUString& sAttrValue ) override;
1156 /// set properties
1157 virtual void PrepareField(
1158 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1161 /** import measure fields (<text:measure>) */
1162 class XMLMeasureFieldImportContext : public XMLTextFieldImportContext
1164 sal_Int16 mnKind;
1166 public:
1168 XMLMeasureFieldImportContext(SvXMLImport& rImport,
1169 XMLTextImportHelper& rHlp,
1170 sal_uInt16 nPrfx,
1171 const OUString& sLocalName);
1173 protected:
1174 /// process attribute values
1175 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
1176 const OUString& sAttrValue ) override;
1178 /// prepare XTextField for insertion into document
1179 virtual void PrepareField(
1180 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1183 /** dropdown field (filter legacy) */
1184 class XMLDropDownFieldImportContext : public XMLTextFieldImportContext
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;
1195 public:
1197 XMLDropDownFieldImportContext(SvXMLImport& rImport,
1198 XMLTextImportHelper& rHlp,
1199 sal_uInt16 nPrfx,
1200 const OUString& sLocalName);
1202 virtual SvXMLImportContextRef CreateChildContext(
1203 sal_uInt16 nPrefix,
1204 const OUString& rLocalName,
1205 const css::uno::Reference<css::xml::sax::XAttributeList >& xAttrList ) override;
1207 protected:
1208 /// process attribute values
1209 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
1210 const OUString& sAttrValue ) override;
1212 /// prepare XTextField for insertion into document
1213 virtual void PrepareField(
1214 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1217 /** import header fields (<draw:header>) */
1218 class XMLHeaderFieldImportContext : public XMLTextFieldImportContext
1220 public:
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
1228 /// process attribute values
1229 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
1230 const OUString& sAttrValue ) override;
1232 /// prepare XTextField for insertion into document
1233 virtual void PrepareField(
1234 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1237 /** import footer fields (<draw:footer>) */
1238 class XMLFooterFieldImportContext : public XMLTextFieldImportContext
1240 public:
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
1248 /// process attribute values
1249 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
1250 const OUString& sAttrValue ) override;
1252 /// prepare XTextField for insertion into document
1253 virtual void PrepareField(
1254 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1257 /** import footer fields (<draw:date-and-time>) */
1258 class XMLDateTimeFieldImportContext : public XMLTextFieldImportContext
1260 public:
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
1268 /// process attribute values
1269 virtual void ProcessAttribute( sal_uInt16 nAttrToken,
1270 const OUString& sAttrValue ) override;
1272 /// prepare XTextField for insertion into document
1273 virtual void PrepareField(
1274 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1277 #endif
1279 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */