nss: upgrade to release 3.73
[LibreOffice.git] / xmloff / inc / txtfldi.hxx
blobbebc30a5b1356253224a02fafee4e84de3063792
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/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>
39 namespace com::sun::star {
40 namespace xml::sax { class XAttributeList; }
41 namespace text { class XTextField; }
42 namespace beans { class XPropertySet; struct PropertyValue; }
45 class SvXMLImport;
46 class XMLTextImportHelper;
47 class SvXMLTokenMap;
49 /// abstract class for text field import
50 class XMLTextFieldImportContext : public SvXMLImportContext
52 // data members
53 OUStringBuffer sContentBuffer; /// collect character data
54 OUString sContent; /// character data after collection
55 OUString sServiceName; /// service name for text field
56 XMLTextImportHelper& rTextImportHelper; /// the import helper
58 protected:
59 OUString sServicePrefix;
61 // data members for use in subclasses
62 bool bValid; /// whether this field is valid ?
64 public:
66 XMLTextFieldImportContext(
67 SvXMLImport& rImport, /// XML Import
68 XMLTextImportHelper& rHlp, /// Text import helper
69 const char* pService, /// name of SO API service
70 sal_uInt16 nPrfx, /// namespace prefix
71 const OUString& rLocalName); /// element name w/o prefix
73 /// process character data: will be collected in member sContentBuffer
74 virtual void SAL_CALL characters( const OUString& sContent ) override;
76 /// parses attributes and calls ProcessAttribute
77 virtual void SAL_CALL startFastElement(
78 sal_Int32 nElement,
79 const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList) override;
81 /// create XTextField and insert into document; calls PrepareTextField
82 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
84 /// create the appropriate field context from
85 /// (for use in paragraph import)
86 static XMLTextFieldImportContext* CreateTextFieldImportContext(
87 SvXMLImport& rImport,
88 XMLTextImportHelper& rHlp,
89 sal_uInt16 nPrefix,
90 const OUString& rName,
91 sal_uInt16 nToken);
93 protected:
94 /// get helper
95 XMLTextImportHelper& GetImportHelper() { return rTextImportHelper; }
97 const OUString& GetServiceName() const { return sServiceName; }
98 void SetServiceName(const OUString& sStr) { sServiceName = sStr; }
100 OUString const & GetContent();
102 /// process attribute values
103 virtual void ProcessAttribute( sal_Int32 nAttrToken,
104 const OUString& sAttrValue ) = 0;
106 /// prepare XTextField for insertion into document
107 virtual void PrepareField(
108 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) = 0;
110 /// create field from ServiceName
111 bool CreateField(css::uno::Reference< css::beans::XPropertySet> & xField,
112 const OUString& sServiceName);
114 /// force an update of the field's value
115 /// call update on optional XUpdatable interface; (disable Fixed property)
116 static void ForceUpdate(
117 const css::uno::Reference< css::beans::XPropertySet> & rPropertySet);
120 class XMLSenderFieldImportContext : public XMLTextFieldImportContext
123 sal_Int16 nSubType; /// API subtype for ExtUser field
125 const OUString sPropertyFixed;
126 const OUString sPropertyContent;
128 protected:
129 // variables for access in subclass
130 bool bFixed;
132 public:
134 XMLSenderFieldImportContext(
135 SvXMLImport& rImport, /// XML Import
136 XMLTextImportHelper& rHlp, /// Text import helper
137 sal_uInt16 nPrfx, /// namespace prefix
138 const OUString& sLocalName); /// element name w/o prefix
140 protected:
141 /// start element
142 virtual void SAL_CALL startFastElement(
143 sal_Int32 nElement,
144 const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList) override;
146 /// process attribute values
147 virtual void ProcessAttribute( sal_Int32 nAttrToken,
148 const OUString& sAttrValue ) override;
150 /// prepare XTextField for insertion into document
151 virtual void PrepareField(
152 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
155 /** inherit sender field because of fixed attribute in ProcessAttributes */
156 class XMLAuthorFieldImportContext final : public XMLSenderFieldImportContext
158 bool bAuthorFullName;
159 const OUString sPropertyFixed;
160 const OUString sPropertyContent;
162 public:
164 XMLAuthorFieldImportContext(
165 SvXMLImport& rImport, /// XML Import
166 XMLTextImportHelper& rHlp, /// Text import helper
167 sal_uInt16 nPrfx, /// namespace prefix
168 const OUString& sLocalName); /// element name w/o prefix
170 private:
171 /// start element
172 virtual void SAL_CALL startFastElement(
173 sal_Int32 nElement,
174 const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList) override;
176 /// process attribute values
177 virtual void ProcessAttribute( sal_Int32 nAttrToken,
178 const OUString& sAttrValue ) override;
180 /// prepare XTextField for insertion into document
181 virtual void PrepareField(
182 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
185 class XMLPlaceholderFieldImportContext final : public XMLTextFieldImportContext
187 const OUString sPropertyHint;
189 OUString sDescription;
191 sal_Int16 nPlaceholderType;
193 public:
195 XMLPlaceholderFieldImportContext(
196 SvXMLImport& rImport, /// XML Import
197 XMLTextImportHelper& rHlp, /// Text import helper
198 sal_uInt16 nPrfx, /// namespace prefix
199 const OUString& sLocalName); /// element name w/o prefix
201 private:
202 /// process attribute values
203 virtual void ProcessAttribute( sal_Int32 nAttrToken,
204 const OUString& sAttrValue ) override;
206 /// prepare XTextField for insertion into document
207 virtual void PrepareField(
208 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
211 class XMLTimeFieldImportContext : public XMLTextFieldImportContext
213 protected:
214 const OUString sPropertyNumberFormat;
215 const OUString sPropertyFixed;
216 const OUString sPropertyDateTimeValue;
217 const OUString sPropertyDateTime;
218 const OUString sPropertyIsDate;
219 const OUString sPropertyIsFixedLanguage;
221 css::util::DateTime aDateTimeValue;
222 sal_Int32 nAdjust;
223 sal_Int32 nFormatKey;
224 bool bTimeOK;
225 bool bFormatOK;
226 bool bFixed;
227 bool bIsDate; // is this a date?
228 // (for XMLDateFieldImportContext, really)
229 bool bIsDefaultLanguage;
231 public:
233 XMLTimeFieldImportContext(
234 SvXMLImport& rImport, /// XML Import
235 XMLTextImportHelper& rHlp, /// Text import helper
236 sal_uInt16 nPrfx, /// namespace prefix
237 const OUString& sLocalName); /// element name w/o prefix
239 /// process attribute values
240 virtual void ProcessAttribute( sal_Int32 nAttrToken,
241 const OUString& sAttrValue ) override;
243 /// prepare XTextField for insertion into document
244 virtual void PrepareField(
245 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
248 /** import date fields (<text:date>);
249 inherit from TimeField to reuse implementation */
250 class XMLDateFieldImportContext final : public XMLTimeFieldImportContext
252 public:
254 XMLDateFieldImportContext(
255 SvXMLImport& rImport, /// XML Import
256 XMLTextImportHelper& rHlp, /// Text import helper
257 sal_uInt16 nPrfx, /// namespace prefix
258 const OUString& sLocalName); /// element name w/o prefix
260 /// process attribute values
261 virtual void ProcessAttribute( sal_Int32 nAttrToken,
262 const OUString& sAttrValue ) override;
265 /** import page continuation fields (<text:page-continuation-string>) */
266 class XMLPageContinuationImportContext final : public XMLTextFieldImportContext
268 const OUString sPropertySubType;
269 const OUString sPropertyNumberingType;
271 OUString sString; /// continuation string
272 css::text::PageNumberType eSelectPage; /// previous, current
273 /// or next page
274 bool sStringOK; /// continuation string encountered?
276 public:
278 XMLPageContinuationImportContext(
279 SvXMLImport& rImport, /// XML Import
280 XMLTextImportHelper& rHlp, /// Text import helper
281 sal_uInt16 nPrfx, /// namespace prefix
282 const OUString& sLocalName); /// element name w/o prefix
284 /// process attribute values
285 virtual void ProcessAttribute( sal_Int32 nAttrToken,
286 const OUString& sAttrValue ) override;
288 /// prepare XTextField for insertion into document
289 virtual void PrepareField(
290 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
293 /** import page number fields (<text:page-number>) */
294 class XMLPageNumberImportContext final : public XMLTextFieldImportContext
296 const OUString sPropertySubType;
297 const OUString sPropertyNumberingType;
298 const OUString sPropertyOffset;
300 OUString sNumberFormat;
301 OUString sNumberSync;
302 sal_Int16 nPageAdjust;
303 css::text::PageNumberType eSelectPage; /// previous, current
304 /// or next page
305 bool sNumberFormatOK;
307 public:
309 XMLPageNumberImportContext(
310 SvXMLImport& rImport, /// XML Import
311 XMLTextImportHelper& rHlp, /// Text import helper
312 sal_uInt16 nPrfx, /// namespace prefix
313 const OUString& sLocalName); /// element name w/o prefix
316 /// process attribute values
317 virtual void ProcessAttribute( sal_Int32 nAttrToken,
318 const OUString& sAttrValue ) override;
320 /// prepare XTextField for insertion into document
321 virtual void PrepareField(
322 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
325 /** superclass for database fields: handle database and table names */
326 class XMLDatabaseFieldImportContext : public XMLTextFieldImportContext
328 OUString m_sDatabaseName;
329 OUString m_sDatabaseURL;
330 OUString m_sTableName;
332 sal_Int32 m_nCommandType;
333 bool m_bCommandTypeOK;
335 bool m_bDisplay;
336 bool m_bDisplayOK;
337 bool m_bUseDisplay;
339 protected:
340 bool m_bDatabaseOK;
341 bool m_bDatabaseNameOK;
342 bool m_bDatabaseURLOK;
343 bool m_bTableOK;
345 /// protected constructor: only for subclasses
346 XMLDatabaseFieldImportContext(SvXMLImport& rImport,
347 XMLTextImportHelper& rHlp,
348 const char* pServiceName,
349 sal_uInt16 nPrfx,
350 const OUString& sLocalName,
351 bool bUseDisplay );
353 public:
355 /// process attribute values
356 virtual void ProcessAttribute( sal_Int32 nAttrToken,
357 const OUString& sAttrValue ) override;
359 /// prepare XTextField for insertion into document
360 virtual void PrepareField(
361 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
363 /// handle database-location children
364 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
365 sal_Int32 nElement,
366 const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
369 /** import database name fields (<text:database-name>) */
370 class XMLDatabaseNameImportContext final : public XMLDatabaseFieldImportContext
372 public:
374 XMLDatabaseNameImportContext(SvXMLImport& rImport,
375 XMLTextImportHelper& rHlp,
376 sal_uInt16 nPrfx,
377 const OUString& sLocalName);
379 /// process attribute values
380 virtual void ProcessAttribute( sal_Int32 nAttrToken,
381 const OUString& sAttrValue ) override;
384 /** import database next fields (<text:database-next>) */
385 class XMLDatabaseNextImportContext : public XMLDatabaseFieldImportContext
387 const OUString sPropertyCondition;
388 const OUString sTrue;
389 OUString sCondition;
390 bool bConditionOK;
392 protected:
393 // for use in child classes
394 XMLDatabaseNextImportContext(SvXMLImport& rImport,
395 XMLTextImportHelper& rHlp,
396 const char* pServiceName,
397 sal_uInt16 nPrfx,
398 const OUString& sLocalName);
400 public:
402 XMLDatabaseNextImportContext(SvXMLImport& rImport,
403 XMLTextImportHelper& rHlp,
404 sal_uInt16 nPrfx,
405 const OUString& sLocalName);
407 /// process attribute values
408 virtual void ProcessAttribute( sal_Int32 nAttrToken,
409 const OUString& sAttrValue ) override;
411 /// prepare XTextField for insertion into document
412 virtual void PrepareField(
413 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
416 /** import database select fields (<text:database-select>) */
417 class XMLDatabaseSelectImportContext final : public XMLDatabaseNextImportContext
419 const OUString sPropertySetNumber;
420 sal_Int32 nNumber;
421 bool bNumberOK;
423 public:
425 XMLDatabaseSelectImportContext(SvXMLImport& rImport,
426 XMLTextImportHelper& rHlp,
427 sal_uInt16 nPrfx,
428 const OUString& sLocalName);
430 /// process attribute values
431 virtual void ProcessAttribute( sal_Int32 nAttrToken,
432 const OUString& sAttrValue ) override;
434 /// prepare XTextField for insertion into document
435 virtual void PrepareField(
436 const css::uno::Reference<
437 css::beans::XPropertySet> & xPropertySet) override;
440 /** import database display number fields (<text:database-row-number>) */
441 class XMLDatabaseNumberImportContext final : public XMLDatabaseFieldImportContext
443 const OUString sPropertyNumberingType;
444 const OUString sPropertySetNumber;
445 OUString sNumberFormat;
446 OUString sNumberSync;
447 sal_Int32 nValue;
448 bool bValueOK;
450 public:
452 XMLDatabaseNumberImportContext(SvXMLImport& rImport,
453 XMLTextImportHelper& rHlp,
454 sal_uInt16 nPrfx,
455 const OUString& sLocalName);
457 /// process attribute values
458 virtual void ProcessAttribute( sal_Int32 nAttrToken,
459 const OUString& sAttrValue ) override;
461 /// prepare XTextField for insertion into document
462 virtual void PrepareField(
463 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
466 /** import docinfo fields with only fixed attribute */
467 class XMLSimpleDocInfoImportContext : public XMLTextFieldImportContext
469 const OUString sPropertyFixed;
470 const OUString sPropertyContent;
471 const OUString sPropertyAuthor;
472 const OUString sPropertyCurrentPresentation;
474 protected:
475 bool bFixed;
476 bool bHasAuthor;
477 bool bHasContent;
479 public:
481 XMLSimpleDocInfoImportContext(SvXMLImport& rImport,
482 XMLTextImportHelper& rHlp,
483 sal_uInt16 nPrfx,
484 const OUString& sLocalName,
485 sal_uInt16 nToken,
486 bool bContent,
487 bool bAuthor);
489 protected:
490 /// process attribute values
491 virtual void ProcessAttribute( sal_Int32 nAttrToken,
492 const OUString& sAttrValue ) override;
494 /// prepare XTextField for insertion into document
495 virtual void PrepareField(
496 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
498 static const char* MapTokenToServiceName(sal_uInt16 nToken);
501 /** import docinfo fields with date or time attributes and numberformats */
502 class XMLDateTimeDocInfoImportContext final : public XMLSimpleDocInfoImportContext
504 const OUString sPropertyNumberFormat;
505 const OUString sPropertyIsDate;
506 const OUString sPropertyIsFixedLanguage;
508 sal_Int32 nFormat;
509 bool bFormatOK;
510 bool bIsDate;
511 bool bHasDateTime;
512 bool bIsDefaultLanguage;
514 public:
516 XMLDateTimeDocInfoImportContext(SvXMLImport& rImport,
517 XMLTextImportHelper& rHlp,
518 sal_uInt16 nPrfx,
519 const OUString& sLocalName,
520 sal_uInt16 nToken);
522 private:
523 /// process attribute values
524 virtual void ProcessAttribute( sal_Int32 nAttrToken,
525 const OUString& sAttrValue ) override;
527 /// prepare XTextField for insertion into document
528 virtual void PrepareField(
529 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
532 /** import revision field (<text:editing-cycles>) */
533 class XMLRevisionDocInfoImportContext final : public XMLSimpleDocInfoImportContext
535 public:
537 XMLRevisionDocInfoImportContext(SvXMLImport& rImport,
538 XMLTextImportHelper& rHlp,
539 sal_uInt16 nPrfx,
540 const OUString& sLocalName,
541 sal_uInt16 nToken);
543 private:
544 /// prepare XTextField for insertion into document
545 virtual void PrepareField(
546 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
549 /** import user docinfo field (<text:user-defined>) */
550 class XMLUserDocInfoImportContext final : public XMLSimpleDocInfoImportContext
552 OUString aName;
553 const OUString sPropertyName;
554 const OUString sPropertyNumberFormat;
555 const OUString sPropertyIsFixedLanguage;
556 sal_Int32 nFormat;
557 bool bFormatOK;
558 bool bIsDefaultLanguage;
560 public:
562 XMLUserDocInfoImportContext(SvXMLImport& rImport,
563 XMLTextImportHelper& rHlp,
564 sal_uInt16 nPrfx,
565 const OUString& sLocalName,
566 sal_uInt16 nToken);
568 private:
569 /// process attribute values
570 virtual void ProcessAttribute( sal_Int32 nAttrToken,
571 const OUString& sAttrValue ) override;
572 virtual void PrepareField(
573 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
576 /** import hidden paragraph fields (<text:hidden-paragraph>) */
577 class XMLHiddenParagraphImportContext final : public XMLTextFieldImportContext
579 const OUString sPropertyCondition;
580 const OUString sPropertyIsHidden;
582 OUString sCondition;
583 bool bIsHidden;
585 public:
587 XMLHiddenParagraphImportContext(SvXMLImport& rImport,
588 XMLTextImportHelper& rHlp,
589 sal_uInt16 nPrfx,
590 const OUString& sLocalName);
592 private:
593 /// process attribute values
594 virtual void ProcessAttribute( sal_Int32 nAttrToken,
595 const OUString& sAttrValue ) override;
597 /// prepare XTextField for insertion into document
598 virtual void PrepareField(
599 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
602 /** import conditional text fields (<text:conditional-text>) */
603 class XMLConditionalTextImportContext final : public XMLTextFieldImportContext
605 const OUString sPropertyCondition;
606 const OUString sPropertyCurrentPresentation;
608 OUString sCondition;
609 OUString sTrueContent;
610 OUString sFalseContent;
612 bool bConditionOK;
613 bool bTrueOK;
614 bool bFalseOK;
615 bool bCurrentValue;
617 public:
619 XMLConditionalTextImportContext(SvXMLImport& rImport,
620 XMLTextImportHelper& rHlp,
621 sal_uInt16 nPrfx,
622 const OUString& sLocalName);
624 private:
625 /// process attribute values
626 virtual void ProcessAttribute( sal_Int32 nAttrToken,
627 const OUString& sAttrValue ) override;
629 /// prepare XTextField for insertion into document
630 virtual void PrepareField(
631 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
634 /** import conditional text fields (<text:hidden-text>) */
635 class XMLHiddenTextImportContext final : public XMLTextFieldImportContext
637 const OUString sPropertyCondition;
638 const OUString sPropertyContent;
639 const OUString sPropertyIsHidden;
641 OUString sCondition;
642 OUString sString;
644 bool bConditionOK;
645 bool bStringOK;
646 bool bIsHidden;
648 public:
650 XMLHiddenTextImportContext(SvXMLImport& rImport,
651 XMLTextImportHelper& rHlp,
652 sal_uInt16 nPrfx,
653 const OUString& sLocalName);
655 private:
656 /// process attribute values
657 virtual void ProcessAttribute( sal_Int32 nAttrToken,
658 const OUString& sAttrValue ) override;
660 /// prepare XTextField for insertion into document
661 virtual void PrepareField(
662 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
665 /** import file name fields (<text:file-name>) */
666 class XMLFileNameImportContext final : public XMLTextFieldImportContext
668 const OUString sPropertyFixed;
669 const OUString sPropertyFileFormat;
670 const OUString sPropertyCurrentPresentation;
672 sal_Int16 nFormat;
673 bool bFixed;
675 public:
677 XMLFileNameImportContext(SvXMLImport& rImport,
678 XMLTextImportHelper& rHlp,
679 sal_uInt16 nPrfx,
680 const OUString& sLocalName);
682 private:
683 /// process attribute values
684 virtual void ProcessAttribute( sal_Int32 nAttrToken,
685 const OUString& sAttrValue ) override;
687 /// prepare XTextField for insertion into document
688 virtual void PrepareField(
689 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
692 /** import document template name fields (<text:template-name>) */
693 class XMLTemplateNameImportContext final : public XMLTextFieldImportContext
695 const OUString sPropertyFileFormat;
697 sal_Int16 nFormat;
699 public:
701 XMLTemplateNameImportContext(SvXMLImport& rImport,
702 XMLTextImportHelper& rHlp,
703 sal_uInt16 nPrfx,
704 const OUString& sLocalName);
706 private:
707 /// process attribute values
708 virtual void ProcessAttribute( sal_Int32 nAttrToken,
709 const OUString& sAttrValue ) override;
711 /// prepare XTextField for insertion into document
712 virtual void PrepareField(
713 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
716 /** import chapter fields (<text:chapter>) */
717 class XMLChapterImportContext final : public XMLTextFieldImportContext
719 sal_Int16 nFormat;
720 sal_Int8 nLevel;
722 public:
724 XMLChapterImportContext(SvXMLImport& rImport,
725 XMLTextImportHelper& rHlp,
726 sal_uInt16 nPrfx,
727 const OUString& sLocalName);
729 private:
730 /// process attribute values
731 virtual void ProcessAttribute( sal_Int32 nAttrToken,
732 const OUString& sAttrValue ) override;
734 /// prepare XTextField for insertion into document
735 virtual void PrepareField(
736 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
739 /** import count fields (<text:[XXX]-count>) */
740 class XMLCountFieldImportContext final : public XMLTextFieldImportContext
742 const OUString sPropertyNumberingType;
744 OUString sNumberFormat;
745 OUString sLetterSync;
747 bool bNumberFormatOK;
749 public:
751 XMLCountFieldImportContext(SvXMLImport& rImport,
752 XMLTextImportHelper& rHlp,
753 sal_uInt16 nPrfx,
754 const OUString& sLocalName,
755 sal_uInt16 nToken);
757 private:
758 /// process attribute values
759 virtual void ProcessAttribute( sal_Int32 nAttrToken,
760 const OUString& sAttrValue ) override;
762 /// prepare XTextField for insertion into document
763 virtual void PrepareField(
764 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
766 static const char* MapTokenToServiceName(sal_uInt16 nToken);
769 /** import page variable fields (<text:get-page-variable>) */
770 class XMLPageVarGetFieldImportContext final : public XMLTextFieldImportContext
772 OUString sNumberFormat;
773 OUString sLetterSync;
775 bool bNumberFormatOK;
777 public:
779 XMLPageVarGetFieldImportContext(SvXMLImport& rImport,
780 XMLTextImportHelper& rHlp,
781 sal_uInt16 nPrfx,
782 const OUString& sLocalName);
784 private:
785 /// process attribute values
786 virtual void ProcessAttribute( sal_Int32 nAttrToken,
787 const OUString& sAttrValue ) override;
789 /// prepare XTextField for insertion into document
790 virtual void PrepareField(
791 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
794 /** import page variable fields (<text:get-page-variable>) */
795 class XMLPageVarSetFieldImportContext final : public XMLTextFieldImportContext
797 sal_Int16 nAdjust;
798 bool bActive;
800 public:
802 XMLPageVarSetFieldImportContext(SvXMLImport& rImport,
803 XMLTextImportHelper& rHlp,
804 sal_uInt16 nPrfx,
805 const OUString& sLocalName);
807 private:
808 /// process attribute values
809 virtual void ProcessAttribute( sal_Int32 nAttrToken,
810 const OUString& sAttrValue ) override;
812 /// prepare XTextField for insertion into document
813 virtual void PrepareField(
814 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
817 /** import macro fields (<text:execute-macro>) */
818 class XMLMacroFieldImportContext final : public XMLTextFieldImportContext
820 OUString sDescription;
821 rtl::Reference<XMLEventsImportContext> xEventContext;
823 OUString sMacro; // macro for old documents (pre 638i)
825 bool bDescriptionOK;
827 public:
829 XMLMacroFieldImportContext(SvXMLImport& rImport,
830 XMLTextImportHelper& rHlp,
831 sal_uInt16 nPrfx,
832 const OUString& sLocalName);
834 private:
835 /// for <office:events> children
836 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
837 sal_Int32 nElement,
838 const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
840 /// process attribute values
841 virtual void ProcessAttribute( sal_Int32 nAttrToken,
842 const OUString& sAttrValue ) override;
844 /// prepare XTextField for insertion into document
845 virtual void PrepareField(
846 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
849 /** import reference fields (<text:reference-get>) */
850 class XMLReferenceFieldImportContext final : public XMLTextFieldImportContext
852 OUString sName;
853 OUString sLanguage;
854 sal_uInt16 nElementToken;
855 sal_Int16 nSource;
856 sal_Int16 nType;
858 bool bNameOK;
859 bool bTypeOK;
861 public:
863 XMLReferenceFieldImportContext(SvXMLImport& rImport,
864 XMLTextImportHelper& rHlp,
865 sal_uInt16 nToken,
866 sal_uInt16 nPrfx,
867 const OUString& sLocalName);
869 private:
870 /// start element
871 virtual void SAL_CALL startFastElement(
872 sal_Int32 nElement,
873 const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList) override;
875 /// process attribute values
876 virtual void ProcessAttribute( sal_Int32 nAttrToken,
877 const OUString& sAttrValue ) override;
879 /// prepare XTextField for insertion into document
880 virtual void PrepareField(
881 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
884 /** import dde field declaration container (<text:dde-connection-decls>) */
885 class XMLDdeFieldDeclsImportContext final : public SvXMLImportContext
887 public:
889 XMLDdeFieldDeclsImportContext(SvXMLImport& rImport,
890 sal_uInt16 nPrfx,
891 const OUString& sLocalName);
893 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
894 sal_Int32 nElement,
895 const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
898 /** import dde field declaration (<text:dde-connection-decl>) */
899 class XMLDdeFieldDeclImportContext final : public SvXMLImportContext
901 public:
903 XMLDdeFieldDeclImportContext(SvXMLImport& rImport);
905 // create fieldmaster
906 virtual void SAL_CALL startFastElement(
907 sal_Int32 nElement,
908 const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList) override;
911 /** import dde fields (<text:dde-connection>) */
912 class XMLDdeFieldImportContext final : public XMLTextFieldImportContext
914 OUString sName;
915 OUString sPropertyContent;
917 public:
919 XMLDdeFieldImportContext(SvXMLImport& rImport,
920 XMLTextImportHelper& rHlp,
921 sal_uInt16 nPrfx,
922 const OUString& sLocalName);
924 private:
925 /// process attribute values
926 virtual void ProcessAttribute( sal_Int32 nAttrToken,
927 const OUString& sAttrValue ) override;
929 /// create textfield, attach master, and insert into document
930 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
932 /// empty method
933 virtual void PrepareField(
934 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
937 /** import sheet name fields (Calc) dde fields (<text:sheet-name>) */
938 class XMLSheetNameImportContext final : public XMLTextFieldImportContext
941 public:
943 XMLSheetNameImportContext(SvXMLImport& rImport,
944 XMLTextImportHelper& rHlp,
945 sal_uInt16 nPrfx,
946 const OUString& sLocalName);
948 private:
949 /// no attributes -> empty method
950 virtual void ProcessAttribute( sal_Int32 nAttrToken,
951 const OUString& sAttrValue ) override;
953 /// no attributes -> empty method
954 virtual void PrepareField(
955 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
958 /** import page|slide name fields (<text:page-name>) */
959 class XMLPageNameFieldImportContext final : public XMLTextFieldImportContext
961 public:
963 XMLPageNameFieldImportContext(
964 SvXMLImport& rImport, /// XML Import
965 XMLTextImportHelper& rHlp, /// Text import helper
966 sal_uInt16 nPrfx, /// namespace prefix
967 const OUString& sLocalName); /// element name w/o prefix
969 /// process attribute values
970 virtual void ProcessAttribute( sal_Int32 nAttrToken,
971 const OUString& sAttrValue ) override;
973 /// prepare XTextField for insertion into document
974 virtual void PrepareField(
975 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
978 /** import hyperlinks as URL fields (Calc, Impress, Draw) (<office:a>) */
979 class XMLUrlFieldImportContext final : public XMLTextFieldImportContext
981 OUString sURL;
982 OUString sFrame;
983 bool bFrameOK;
985 public:
987 XMLUrlFieldImportContext(SvXMLImport& rImport,
988 XMLTextImportHelper& rHlp,
989 sal_uInt16 nPrfx,
990 const OUString& sLocalName);
992 private:
993 /// no attributes -> empty method
994 virtual void ProcessAttribute( sal_Int32 nAttrToken,
995 const OUString& sAttrValue ) override;
997 /// no attributes -> empty method
998 virtual void PrepareField(
999 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1002 /** import bibliography info fields (<text:bibliography-mark>) */
1003 class XMLBibliographyFieldImportContext final : public XMLTextFieldImportContext
1005 ::std::vector< css::beans::PropertyValue> aValues;
1007 public:
1009 XMLBibliographyFieldImportContext(SvXMLImport& rImport,
1010 XMLTextImportHelper& rHlp,
1011 sal_uInt16 nPrfx,
1012 const OUString& sLocalName);
1014 private:
1015 /// process attributes (fill aValues)
1016 virtual void SAL_CALL startFastElement(
1017 sal_Int32 nElement,
1018 const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList) override;
1020 /// empty method; all attributes are handled in startFastElement
1021 virtual void ProcessAttribute( sal_Int32 nAttrToken,
1022 const OUString& sAttrValue ) override;
1024 /// convert aValues into sequence and set property
1025 virtual void PrepareField(
1026 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1028 static const char* MapBibliographyFieldName(const OUString& sName);
1031 /** Import an annotation field (<text:annotation>) */
1032 class XMLAnnotationImportContext final : public XMLTextFieldImportContext
1034 OUStringBuffer aAuthorBuffer;
1035 OUStringBuffer aInitialsBuffer;
1036 OUString aName;
1037 OUStringBuffer aTextBuffer;
1038 OUStringBuffer aDateBuffer;
1039 OUString aResolved;
1041 css::uno::Reference < css::beans::XPropertySet > mxField;
1042 css::uno::Reference < css::text::XTextCursor > mxCursor;
1043 css::uno::Reference < css::text::XTextCursor > mxOldCursor;
1045 sal_uInt16 m_nToken;
1047 public:
1049 XMLAnnotationImportContext(SvXMLImport& rImport,
1050 XMLTextImportHelper& rHlp,
1051 sal_uInt16 nToken,
1052 sal_uInt16 nPrfx,
1053 const OUString& sLocalName);
1055 private:
1056 /// process attributes
1057 virtual void ProcessAttribute( sal_Int32 nAttrToken,
1058 const OUString& sAttrValue ) override;
1060 /// set properties
1061 virtual void PrepareField(
1062 const css::uno::Reference< css::beans::XPropertySet > & xPropertySet) override;
1064 virtual SvXMLImportContextRef CreateChildContext(
1065 sal_uInt16 nPrefix,
1066 const OUString& rLocalName,
1067 const css::uno::Reference<css::xml::sax::XAttributeList >& xAttrList ) override;
1068 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
1071 /** Import a script field (<text:script>) */
1072 class XMLScriptImportContext final : public XMLTextFieldImportContext
1074 OUString sContent;
1075 OUString sScriptType;
1077 bool bContentOK;
1079 public:
1081 XMLScriptImportContext(SvXMLImport& rImport,
1082 XMLTextImportHelper& rHlp,
1083 sal_uInt16 nPrfx,
1084 const OUString& sLocalName);
1086 private:
1087 /// process attributes
1088 virtual void ProcessAttribute( sal_Int32 nAttrToken,
1089 const OUString& sAttrValue ) override;
1091 /// set properties
1092 virtual void PrepareField(
1093 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1096 /** import measure fields (<text:measure>) */
1097 class XMLMeasureFieldImportContext final : public XMLTextFieldImportContext
1099 sal_Int16 mnKind;
1101 public:
1103 XMLMeasureFieldImportContext(SvXMLImport& rImport,
1104 XMLTextImportHelper& rHlp,
1105 sal_uInt16 nPrfx,
1106 const OUString& sLocalName);
1108 private:
1109 /// process attribute values
1110 virtual void ProcessAttribute( sal_Int32 nAttrToken,
1111 const OUString& sAttrValue ) override;
1113 /// prepare XTextField for insertion into document
1114 virtual void PrepareField(
1115 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1118 /** dropdown field (filter legacy) */
1119 class XMLDropDownFieldImportContext final : public XMLTextFieldImportContext
1121 std::vector<OUString> aLabels;
1122 OUString sName;
1123 OUString sHelp;
1124 OUString sHint;
1125 sal_Int32 nSelected;
1126 bool bNameOK;
1127 bool bHelpOK;
1128 bool bHintOK;
1130 public:
1132 XMLDropDownFieldImportContext(SvXMLImport& rImport,
1133 XMLTextImportHelper& rHlp,
1134 sal_uInt16 nPrfx,
1135 const OUString& sLocalName);
1137 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
1138 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
1140 private:
1141 /// process attribute values
1142 virtual void ProcessAttribute( sal_Int32 nAttrToken,
1143 const OUString& sAttrValue ) override;
1145 /// prepare XTextField for insertion into document
1146 virtual void PrepareField(
1147 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1150 /** import header fields (<draw:header>) */
1151 class XMLHeaderFieldImportContext final : public XMLTextFieldImportContext
1153 public:
1155 XMLHeaderFieldImportContext(
1156 SvXMLImport& rImport, /// XML Import
1157 XMLTextImportHelper& rHlp, /// Text import helper
1158 sal_uInt16 nPrfx, /// namespace prefix
1159 const OUString& sLocalName); /// element name w/o prefix
1161 /// process attribute values
1162 virtual void ProcessAttribute( sal_Int32 nAttrToken,
1163 const OUString& sAttrValue ) override;
1165 /// prepare XTextField for insertion into document
1166 virtual void PrepareField(
1167 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1170 /** import footer fields (<draw:footer>) */
1171 class XMLFooterFieldImportContext final : public XMLTextFieldImportContext
1173 public:
1175 XMLFooterFieldImportContext(
1176 SvXMLImport& rImport, /// XML Import
1177 XMLTextImportHelper& rHlp, /// Text import helper
1178 sal_uInt16 nPrfx, /// namespace prefix
1179 const OUString& sLocalName); /// element name w/o prefix
1181 /// process attribute values
1182 virtual void ProcessAttribute( sal_Int32 nAttrToken,
1183 const OUString& sAttrValue ) override;
1185 /// prepare XTextField for insertion into document
1186 virtual void PrepareField(
1187 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1190 /** import footer fields (<draw:date-and-time>) */
1191 class XMLDateTimeFieldImportContext final : public XMLTextFieldImportContext
1193 public:
1195 XMLDateTimeFieldImportContext(
1196 SvXMLImport& rImport, /// XML Import
1197 XMLTextImportHelper& rHlp, /// Text import helper
1198 sal_uInt16 nPrfx, /// namespace prefix
1199 const OUString& sLocalName); /// element name w/o prefix
1201 /// process attribute values
1202 virtual void ProcessAttribute( sal_Int32 nAttrToken,
1203 const OUString& sAttrValue ) override;
1205 /// prepare XTextField for insertion into document
1206 virtual void PrepareField(
1207 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1210 #endif
1212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */