add a SwFrameDeleteGuard to SwSaveFootnoteHeight
[LibreOffice.git] / xmloff / inc / txtfldi.hxx
blobf6f27d633f969f138d63db54e26b04dcb71facc0
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 #pragma once
28 #include <com/sun/star/uno/Reference.h>
29 #include <com/sun/star/beans/PropertyValue.hpp>
30 #include <com/sun/star/text/PageNumberType.hpp>
31 #include <com/sun/star/util/DateTime.hpp>
32 #include <xmloff/xmlictxt.hxx>
33 #include <xmloff/txtimp.hxx>
34 #include <xmloff/xmltkmap.hxx>
35 #include <rtl/ustrbuf.hxx>
36 #include <vector>
38 namespace com::sun::star {
39 namespace xml::sax { class XAttributeList; }
40 namespace text { class XTextField; }
41 namespace beans { class XPropertySet; struct PropertyValue; }
44 class SvXMLImport;
45 class XMLTextImportHelper;
46 class SvXMLTokenMap;
48 /// abstract class for text field import
49 class XMLTextFieldImportContext : public SvXMLImportContext
51 // data members
52 OUStringBuffer sContentBuffer; /// collect character data
53 OUString sContent; /// character data after collection
54 OUString sServiceName; /// service name for text field
55 XMLTextImportHelper& rTextImportHelper; /// the import helper
57 protected:
58 OUString sServicePrefix;
60 // data members for use in subclasses
61 bool bValid; /// whether this field is valid ?
63 public:
65 XMLTextFieldImportContext(
66 SvXMLImport& rImport, /// XML Import
67 XMLTextImportHelper& rHlp, /// Text import helper
68 const OUString& pService); /// name of SO API service
70 /// process character data: will be collected in member sContentBuffer
71 virtual void SAL_CALL characters( const OUString& sContent ) override;
73 /// parses attributes and calls ProcessAttribute
74 virtual void SAL_CALL startFastElement(
75 sal_Int32 nElement,
76 const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList) override;
78 /// create XTextField and insert into document; calls PrepareTextField
79 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
81 /// create the appropriate field context from
82 /// (for use in paragraph import)
83 static XMLTextFieldImportContext* CreateTextFieldImportContext(
84 SvXMLImport& rImport,
85 XMLTextImportHelper& rHlp,
86 sal_Int32 nElement);
88 protected:
89 /// get helper
90 XMLTextImportHelper& GetImportHelper() { return rTextImportHelper; }
92 const OUString& GetServiceName() const { return sServiceName; }
93 void SetServiceName(const OUString& sStr) { sServiceName = sStr; }
95 OUString const & GetContent();
97 /// process attribute values
98 virtual void ProcessAttribute( sal_Int32 nAttrToken,
99 std::string_view sAttrValue ) = 0;
101 /// prepare XTextField for insertion into document
102 virtual void PrepareField(
103 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) = 0;
105 /// create field from ServiceName
106 bool CreateField(css::uno::Reference< css::beans::XPropertySet> & xField,
107 const OUString& sServiceName);
109 /// force an update of the field's value
110 /// call update on optional XUpdatable interface; (disable Fixed property)
111 static void ForceUpdate(
112 const css::uno::Reference< css::beans::XPropertySet> & rPropertySet);
115 class XMLSenderFieldImportContext : public XMLTextFieldImportContext
118 sal_Int16 nSubType; /// API subtype for ExtUser field
120 const OUString sPropertyFixed;
121 const OUString sPropertyContent;
123 protected:
124 // variables for access in subclass
125 bool bFixed;
127 public:
129 XMLSenderFieldImportContext(
130 SvXMLImport& rImport, /// XML Import
131 XMLTextImportHelper& rHlp); /// Text import helper
133 protected:
134 /// start element
135 virtual void SAL_CALL startFastElement(
136 sal_Int32 nElement,
137 const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList) override;
139 /// process attribute values
140 virtual void ProcessAttribute( sal_Int32 nAttrToken,
141 std::string_view sAttrValue ) override;
143 /// prepare XTextField for insertion into document
144 virtual void PrepareField(
145 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
148 /** inherit sender field because of fixed attribute in ProcessAttributes */
149 class XMLAuthorFieldImportContext final : public XMLSenderFieldImportContext
151 bool bAuthorFullName;
152 const OUString sPropertyFixed;
153 const OUString sPropertyContent;
155 public:
157 XMLAuthorFieldImportContext(
158 SvXMLImport& rImport, /// XML Import
159 XMLTextImportHelper& rHlp); /// Text import helper
161 private:
162 /// start element
163 virtual void SAL_CALL startFastElement(
164 sal_Int32 nElement,
165 const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList) override;
167 /// process attribute values
168 virtual void ProcessAttribute( sal_Int32 nAttrToken,
169 std::string_view sAttrValue ) override;
171 /// prepare XTextField for insertion into document
172 virtual void PrepareField(
173 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
176 class XMLPlaceholderFieldImportContext final : public XMLTextFieldImportContext
178 const OUString sPropertyHint;
180 OUString sDescription;
182 sal_Int16 nPlaceholderType;
184 public:
186 XMLPlaceholderFieldImportContext(
187 SvXMLImport& rImport, /// XML Import
188 XMLTextImportHelper& rHlp); /// Text import helper
190 private:
191 /// process attribute values
192 virtual void ProcessAttribute( sal_Int32 nAttrToken,
193 std::string_view sAttrValue ) override;
195 /// prepare XTextField for insertion into document
196 virtual void PrepareField(
197 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
200 class XMLTimeFieldImportContext : public XMLTextFieldImportContext
202 protected:
203 const OUString sPropertyNumberFormat;
204 const OUString sPropertyFixed;
205 const OUString sPropertyDateTimeValue;
206 const OUString sPropertyDateTime;
207 const OUString sPropertyIsDate;
208 const OUString sPropertyIsFixedLanguage;
210 css::util::DateTime aDateTimeValue;
211 sal_Int32 nAdjust;
212 sal_Int32 nFormatKey;
213 bool bTimeOK;
214 bool bFormatOK;
215 bool bFixed;
216 bool bIsDate; // is this a date?
217 // (for XMLDateFieldImportContext, really)
218 bool bIsDefaultLanguage;
220 public:
222 XMLTimeFieldImportContext(
223 SvXMLImport& rImport, /// XML Import
224 XMLTextImportHelper& rHlp); /// Text import helper
226 /// process attribute values
227 virtual void ProcessAttribute( sal_Int32 nAttrToken,
228 std::string_view sAttrValue ) override;
230 /// prepare XTextField for insertion into document
231 virtual void PrepareField(
232 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
235 /** import date fields (<text:date>);
236 inherit from TimeField to reuse implementation */
237 class XMLDateFieldImportContext final : public XMLTimeFieldImportContext
239 public:
241 XMLDateFieldImportContext(
242 SvXMLImport& rImport, /// XML Import
243 XMLTextImportHelper& rHlp); /// Text import helper
245 /// process attribute values
246 virtual void ProcessAttribute( sal_Int32 nAttrToken,
247 std::string_view sAttrValue ) override;
250 /** import page continuation fields (<text:page-continuation-string>) */
251 class XMLPageContinuationImportContext final : public XMLTextFieldImportContext
253 const OUString sPropertySubType;
254 const OUString sPropertyNumberingType;
256 OUString sString; /// continuation string
257 css::text::PageNumberType eSelectPage; /// previous, current
258 /// or next page
259 bool sStringOK; /// continuation string encountered?
261 public:
263 XMLPageContinuationImportContext(
264 SvXMLImport& rImport, /// XML Import
265 XMLTextImportHelper& rHlp); /// Text import helper
267 /// process attribute values
268 virtual void ProcessAttribute( sal_Int32 nAttrToken,
269 std::string_view sAttrValue ) override;
271 /// prepare XTextField for insertion into document
272 virtual void PrepareField(
273 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
276 /** import page number fields (<text:page-number>) */
277 class XMLPageNumberImportContext final : public XMLTextFieldImportContext
279 const OUString sPropertySubType;
280 const OUString sPropertyNumberingType;
281 const OUString sPropertyOffset;
283 OUString sNumberFormat;
284 OUString sNumberSync;
285 sal_Int16 nPageAdjust;
286 css::text::PageNumberType eSelectPage; /// previous, current
287 /// or next page
288 bool sNumberFormatOK;
290 public:
292 XMLPageNumberImportContext(
293 SvXMLImport& rImport, /// XML Import
294 XMLTextImportHelper& rHlp); /// Text import helper
297 /// process attribute values
298 virtual void ProcessAttribute( sal_Int32 nAttrToken,
299 std::string_view sAttrValue ) override;
301 /// prepare XTextField for insertion into document
302 virtual void PrepareField(
303 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
306 /** superclass for database fields: handle database and table names */
307 class XMLDatabaseFieldImportContext : public XMLTextFieldImportContext
309 OUString m_sDatabaseName;
310 OUString m_sDatabaseURL;
311 OUString m_sTableName;
313 sal_Int32 m_nCommandType;
314 bool m_bCommandTypeOK;
316 bool m_bDisplay;
317 bool m_bDisplayOK;
318 bool m_bUseDisplay;
320 protected:
321 bool m_bDatabaseOK;
322 bool m_bDatabaseNameOK;
323 bool m_bDatabaseURLOK;
324 bool m_bTableOK;
326 /// protected constructor: only for subclasses
327 XMLDatabaseFieldImportContext(SvXMLImport& rImport,
328 XMLTextImportHelper& rHlp,
329 const OUString& pServiceName,
330 bool bUseDisplay );
332 public:
334 /// process attribute values
335 virtual void ProcessAttribute( sal_Int32 nAttrToken,
336 std::string_view sAttrValue ) override;
338 /// prepare XTextField for insertion into document
339 virtual void PrepareField(
340 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
342 /// handle database-location children
343 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
344 sal_Int32 nElement,
345 const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
348 /** import database name fields (<text:database-name>) */
349 class XMLDatabaseNameImportContext final : public XMLDatabaseFieldImportContext
351 public:
353 XMLDatabaseNameImportContext(SvXMLImport& rImport,
354 XMLTextImportHelper& rHlp);
356 /// process attribute values
357 virtual void ProcessAttribute( sal_Int32 nAttrToken,
358 std::string_view sAttrValue ) override;
361 /** import database next fields (<text:database-next>) */
362 class XMLDatabaseNextImportContext : public XMLDatabaseFieldImportContext
364 const OUString sPropertyCondition;
365 const OUString sTrue;
366 OUString sCondition;
367 bool bConditionOK;
369 protected:
370 // for use in child classes
371 XMLDatabaseNextImportContext(SvXMLImport& rImport,
372 XMLTextImportHelper& rHlp,
373 const OUString& pServiceName);
375 public:
377 XMLDatabaseNextImportContext(SvXMLImport& rImport,
378 XMLTextImportHelper& rHlp);
380 /// process attribute values
381 virtual void ProcessAttribute( sal_Int32 nAttrToken,
382 std::string_view sAttrValue ) override;
384 /// prepare XTextField for insertion into document
385 virtual void PrepareField(
386 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
389 /** import database select fields (<text:database-select>) */
390 class XMLDatabaseSelectImportContext final : public XMLDatabaseNextImportContext
392 const OUString sPropertySetNumber;
393 sal_Int32 nNumber;
394 bool bNumberOK;
396 public:
398 XMLDatabaseSelectImportContext(SvXMLImport& rImport,
399 XMLTextImportHelper& rHlp);
401 /// process attribute values
402 virtual void ProcessAttribute( sal_Int32 nAttrToken,
403 std::string_view sAttrValue ) override;
405 /// prepare XTextField for insertion into document
406 virtual void PrepareField(
407 const css::uno::Reference<
408 css::beans::XPropertySet> & xPropertySet) override;
411 /** import database display number fields (<text:database-row-number>) */
412 class XMLDatabaseNumberImportContext final : public XMLDatabaseFieldImportContext
414 const OUString sPropertyNumberingType;
415 const OUString sPropertySetNumber;
416 OUString sNumberFormat;
417 OUString sNumberSync;
418 sal_Int32 nValue;
419 bool bValueOK;
421 public:
423 XMLDatabaseNumberImportContext(SvXMLImport& rImport,
424 XMLTextImportHelper& rHlp);
426 /// process attribute values
427 virtual void ProcessAttribute( sal_Int32 nAttrToken,
428 std::string_view sAttrValue ) override;
430 /// prepare XTextField for insertion into document
431 virtual void PrepareField(
432 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
435 /** import docinfo fields with only fixed attribute */
436 class XMLSimpleDocInfoImportContext : public XMLTextFieldImportContext
438 const OUString sPropertyFixed;
439 const OUString sPropertyContent;
440 const OUString sPropertyAuthor;
441 const OUString sPropertyCurrentPresentation;
443 protected:
444 bool bFixed;
445 bool bHasAuthor;
446 bool bHasContent;
448 public:
450 XMLSimpleDocInfoImportContext(SvXMLImport& rImport,
451 XMLTextImportHelper& rHlp,
452 sal_Int32 nElementToken,
453 bool bContent,
454 bool bAuthor);
456 protected:
457 /// process attribute values
458 virtual void ProcessAttribute( sal_Int32 nAttrToken,
459 std::string_view sAttrValue ) override;
461 /// prepare XTextField for insertion into document
462 virtual void PrepareField(
463 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
465 static OUString MapTokenToServiceName(sal_Int32 nElementToken);
468 /** import docinfo fields with date or time attributes and numberformats */
469 class XMLDateTimeDocInfoImportContext final : public XMLSimpleDocInfoImportContext
471 const OUString sPropertyNumberFormat;
472 const OUString sPropertyIsDate;
473 const OUString sPropertyIsFixedLanguage;
475 sal_Int32 nFormat;
476 bool bFormatOK;
477 bool bIsDate;
478 bool bHasDateTime;
479 bool bIsDefaultLanguage;
481 public:
483 XMLDateTimeDocInfoImportContext(SvXMLImport& rImport,
484 XMLTextImportHelper& rHlp,
485 sal_Int32 nElement);
487 private:
488 /// process attribute values
489 virtual void ProcessAttribute( sal_Int32 nAttrToken,
490 std::string_view sAttrValue ) override;
492 /// prepare XTextField for insertion into document
493 virtual void PrepareField(
494 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
497 /** import revision field (<text:editing-cycles>) */
498 class XMLRevisionDocInfoImportContext final : public XMLSimpleDocInfoImportContext
500 public:
502 XMLRevisionDocInfoImportContext(SvXMLImport& rImport,
503 XMLTextImportHelper& rHlp,
504 sal_Int32 nElement);
506 private:
507 /// prepare XTextField for insertion into document
508 virtual void PrepareField(
509 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
512 /** import user docinfo field (<text:user-defined>) */
513 class XMLUserDocInfoImportContext final : public XMLSimpleDocInfoImportContext
515 OUString aName;
516 const OUString sPropertyName;
517 const OUString sPropertyNumberFormat;
518 const OUString sPropertyIsFixedLanguage;
519 sal_Int32 nFormat;
520 bool bFormatOK;
521 bool bIsDefaultLanguage;
523 public:
525 XMLUserDocInfoImportContext(SvXMLImport& rImport,
526 XMLTextImportHelper& rHlp,
527 sal_Int32 nElement);
529 private:
530 /// process attribute values
531 virtual void ProcessAttribute( sal_Int32 nAttrToken,
532 std::string_view sAttrValue ) override;
533 virtual void PrepareField(
534 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
537 /** import hidden paragraph fields (<text:hidden-paragraph>) */
538 class XMLHiddenParagraphImportContext final : public XMLTextFieldImportContext
540 const OUString sPropertyCondition;
541 const OUString sPropertyIsHidden;
543 OUString sCondition;
544 bool bIsHidden;
546 public:
548 XMLHiddenParagraphImportContext(SvXMLImport& rImport,
549 XMLTextImportHelper& rHlp);
551 private:
552 /// process attribute values
553 virtual void ProcessAttribute( sal_Int32 nAttrToken,
554 std::string_view sAttrValue ) override;
556 /// prepare XTextField for insertion into document
557 virtual void PrepareField(
558 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
561 /** import conditional text fields (<text:conditional-text>) */
562 class XMLConditionalTextImportContext final : public XMLTextFieldImportContext
564 const OUString sPropertyCondition;
565 const OUString sPropertyCurrentPresentation;
567 OUString sCondition;
568 OUString sTrueContent;
569 OUString sFalseContent;
571 bool bConditionOK;
572 bool bTrueOK;
573 bool bFalseOK;
574 bool bCurrentValue;
576 public:
578 XMLConditionalTextImportContext(SvXMLImport& rImport,
579 XMLTextImportHelper& rHlp);
581 private:
582 /// process attribute values
583 virtual void ProcessAttribute( sal_Int32 nAttrToken,
584 std::string_view sAttrValue ) override;
586 /// prepare XTextField for insertion into document
587 virtual void PrepareField(
588 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
591 /** import conditional text fields (<text:hidden-text>) */
592 class XMLHiddenTextImportContext final : public XMLTextFieldImportContext
594 const OUString sPropertyCondition;
595 const OUString sPropertyContent;
596 const OUString sPropertyIsHidden;
598 OUString sCondition;
599 OUString sString;
601 bool bConditionOK;
602 bool bStringOK;
603 bool bIsHidden;
605 public:
607 XMLHiddenTextImportContext(SvXMLImport& rImport,
608 XMLTextImportHelper& rHlp);
610 private:
611 /// process attribute values
612 virtual void ProcessAttribute( sal_Int32 nAttrToken,
613 std::string_view sAttrValue ) override;
615 /// prepare XTextField for insertion into document
616 virtual void PrepareField(
617 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
620 /** import file name fields (<text:file-name>) */
621 class XMLFileNameImportContext final : public XMLTextFieldImportContext
623 const OUString sPropertyFixed;
624 const OUString sPropertyFileFormat;
625 const OUString sPropertyCurrentPresentation;
627 sal_Int16 nFormat;
628 bool bFixed;
630 public:
632 XMLFileNameImportContext(SvXMLImport& rImport,
633 XMLTextImportHelper& rHlp);
635 private:
636 /// process attribute values
637 virtual void ProcessAttribute( sal_Int32 nAttrToken,
638 std::string_view sAttrValue ) override;
640 /// prepare XTextField for insertion into document
641 virtual void PrepareField(
642 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
645 /** import document template name fields (<text:template-name>) */
646 class XMLTemplateNameImportContext final : public XMLTextFieldImportContext
648 const OUString sPropertyFileFormat;
650 sal_Int16 nFormat;
652 public:
654 XMLTemplateNameImportContext(SvXMLImport& rImport,
655 XMLTextImportHelper& rHlp);
657 private:
658 /// process attribute values
659 virtual void ProcessAttribute( sal_Int32 nAttrToken,
660 std::string_view sAttrValue ) override;
662 /// prepare XTextField for insertion into document
663 virtual void PrepareField(
664 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
667 /** import chapter fields (<text:chapter>) */
668 class XMLChapterImportContext final : public XMLTextFieldImportContext
670 sal_Int16 nFormat;
671 sal_Int8 nLevel;
673 public:
675 XMLChapterImportContext(SvXMLImport& rImport,
676 XMLTextImportHelper& rHlp);
678 private:
679 /// process attribute values
680 virtual void ProcessAttribute( sal_Int32 nAttrToken,
681 std::string_view sAttrValue ) override;
683 /// prepare XTextField for insertion into document
684 virtual void PrepareField(
685 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
688 /** import count fields (<text:[XXX]-count>) */
689 class XMLCountFieldImportContext final : public XMLTextFieldImportContext
691 const OUString sPropertyNumberingType;
693 OUString sNumberFormat;
694 OUString sLetterSync;
696 bool bNumberFormatOK;
698 public:
700 XMLCountFieldImportContext(SvXMLImport& rImport,
701 XMLTextImportHelper& rHlp,
702 sal_Int32 nElement);
704 private:
705 /// process attribute values
706 virtual void ProcessAttribute( sal_Int32 nAttrToken,
707 std::string_view sAttrValue ) override;
709 /// prepare XTextField for insertion into document
710 virtual void PrepareField(
711 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
713 static OUString MapTokenToServiceName(sal_Int32 nElement);
716 /** import page variable fields (<text:get-page-variable>) */
717 class XMLPageVarGetFieldImportContext final : public XMLTextFieldImportContext
719 OUString sNumberFormat;
720 OUString sLetterSync;
722 bool bNumberFormatOK;
724 public:
726 XMLPageVarGetFieldImportContext(SvXMLImport& rImport,
727 XMLTextImportHelper& rHlp);
729 private:
730 /// process attribute values
731 virtual void ProcessAttribute( sal_Int32 nAttrToken,
732 std::string_view 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 page variable fields (<text:get-page-variable>) */
740 class XMLPageVarSetFieldImportContext final : public XMLTextFieldImportContext
742 sal_Int16 nAdjust;
743 bool bActive;
745 public:
747 XMLPageVarSetFieldImportContext(SvXMLImport& rImport,
748 XMLTextImportHelper& rHlp);
750 private:
751 /// process attribute values
752 virtual void ProcessAttribute( sal_Int32 nAttrToken,
753 std::string_view sAttrValue ) override;
755 /// prepare XTextField for insertion into document
756 virtual void PrepareField(
757 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
760 /** import macro fields (<text:execute-macro>) */
761 class XMLMacroFieldImportContext final : public XMLTextFieldImportContext
763 OUString sDescription;
764 rtl::Reference<XMLEventsImportContext> xEventContext;
766 OUString sMacro; // macro for old documents (pre 638i)
768 bool bDescriptionOK;
770 public:
772 XMLMacroFieldImportContext(SvXMLImport& rImport,
773 XMLTextImportHelper& rHlp);
775 private:
776 /// for <office:events> children
777 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
778 sal_Int32 nElement,
779 const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
781 /// process attribute values
782 virtual void ProcessAttribute( sal_Int32 nAttrToken,
783 std::string_view sAttrValue ) override;
785 /// prepare XTextField for insertion into document
786 virtual void PrepareField(
787 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
790 /** import reference fields (<text:reference-get>) */
791 class XMLReferenceFieldImportContext final : public XMLTextFieldImportContext
793 OUString sName;
794 OUString sLanguage;
795 sal_Int32 nElementToken;
796 sal_Int16 nSource;
797 sal_Int16 nType;
799 bool bNameOK;
800 bool bTypeOK;
802 public:
804 XMLReferenceFieldImportContext(SvXMLImport& rImport,
805 XMLTextImportHelper& rHlp,
806 sal_Int32 nToken);
808 private:
809 /// start element
810 virtual void SAL_CALL startFastElement(
811 sal_Int32 nElement,
812 const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList) override;
814 /// process attribute values
815 virtual void ProcessAttribute( sal_Int32 nAttrToken,
816 std::string_view sAttrValue ) override;
818 /// prepare XTextField for insertion into document
819 virtual void PrepareField(
820 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
823 /** import dde field declaration container (<text:dde-connection-decls>) */
824 class XMLDdeFieldDeclsImportContext final : public SvXMLImportContext
826 public:
828 XMLDdeFieldDeclsImportContext(SvXMLImport& rImport);
830 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
831 sal_Int32 nElement,
832 const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
835 /** import dde field declaration (<text:dde-connection-decl>) */
836 class XMLDdeFieldDeclImportContext final : public SvXMLImportContext
838 public:
840 XMLDdeFieldDeclImportContext(SvXMLImport& rImport);
842 // create fieldmaster
843 virtual void SAL_CALL startFastElement(
844 sal_Int32 nElement,
845 const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList) override;
848 /** import dde fields (<text:dde-connection>) */
849 class XMLDdeFieldImportContext final : public XMLTextFieldImportContext
851 OUString sName;
852 OUString sPropertyContent;
854 public:
856 XMLDdeFieldImportContext(SvXMLImport& rImport,
857 XMLTextImportHelper& rHlp);
859 private:
860 /// process attribute values
861 virtual void ProcessAttribute( sal_Int32 nAttrToken,
862 std::string_view sAttrValue ) override;
864 /// create textfield, attach master, and insert into document
865 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
867 /// empty method
868 virtual void PrepareField(
869 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
872 /** import sheet name fields (Calc) dde fields (<text:sheet-name>) */
873 class XMLSheetNameImportContext final : public XMLTextFieldImportContext
876 public:
878 XMLSheetNameImportContext(SvXMLImport& rImport,
879 XMLTextImportHelper& rHlp);
881 private:
882 /// no attributes -> empty method
883 virtual void ProcessAttribute( sal_Int32 nAttrToken,
884 std::string_view sAttrValue ) override;
886 /// no attributes -> empty method
887 virtual void PrepareField(
888 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
891 /** import page|slide name fields (<text:page-name>) */
892 class XMLPageNameFieldImportContext final : public XMLTextFieldImportContext
894 public:
896 XMLPageNameFieldImportContext(
897 SvXMLImport& rImport, /// XML Import
898 XMLTextImportHelper& rHlp); /// Text import helper
900 /// process attribute values
901 virtual void ProcessAttribute( sal_Int32 nAttrToken,
902 std::string_view sAttrValue ) override;
904 /// prepare XTextField for insertion into document
905 virtual void PrepareField(
906 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
909 /** import hyperlinks as URL fields (Calc, Impress, Draw) (<office:a>) */
910 class XMLUrlFieldImportContext final : public XMLTextFieldImportContext
912 OUString sURL;
913 OUString sFrame;
914 bool bFrameOK;
916 public:
918 XMLUrlFieldImportContext(SvXMLImport& rImport,
919 XMLTextImportHelper& rHlp);
921 private:
922 /// no attributes -> empty method
923 virtual void ProcessAttribute( sal_Int32 nAttrToken,
924 std::string_view sAttrValue ) override;
926 /// no attributes -> empty method
927 virtual void PrepareField(
928 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
931 /** import bibliography info fields (<text:bibliography-mark>) */
932 class XMLBibliographyFieldImportContext final : public XMLTextFieldImportContext
934 ::std::vector< css::beans::PropertyValue> aValues;
936 public:
938 XMLBibliographyFieldImportContext(SvXMLImport& rImport,
939 XMLTextImportHelper& rHlp);
941 private:
942 /// process attributes (fill aValues)
943 virtual void SAL_CALL startFastElement(
944 sal_Int32 nElement,
945 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList) override;
947 /// empty method; all attributes are handled in StartElement
948 virtual void ProcessAttribute( sal_Int32 nAttrToken,
949 std::string_view sAttrValue ) override;
951 /// convert aValues into sequence and set property
952 virtual void PrepareField(
953 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
955 static const char* MapBibliographyFieldName(sal_Int32 nElement);
958 /** Import an annotation field (<text:annotation>) */
959 class XMLAnnotationImportContext final : public XMLTextFieldImportContext
961 OUStringBuffer aAuthorBuffer;
962 OUStringBuffer aInitialsBuffer;
963 OUString aName;
964 OUStringBuffer aTextBuffer;
965 OUStringBuffer aDateBuffer;
966 OUString aResolved;
968 css::uno::Reference < css::beans::XPropertySet > mxField;
969 css::uno::Reference < css::text::XTextCursor > mxCursor;
970 css::uno::Reference < css::text::XTextCursor > mxOldCursor;
972 sal_Int32 mnElement;
974 public:
976 XMLAnnotationImportContext(SvXMLImport& rImport,
977 XMLTextImportHelper& rHlp,
978 sal_Int32 nElement);
980 private:
981 /// process attributes
982 virtual void ProcessAttribute( sal_Int32 nAttrToken,
983 std::string_view sAttrValue ) override;
985 /// set properties
986 virtual void PrepareField(
987 const css::uno::Reference< css::beans::XPropertySet > & xPropertySet) override;
989 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
990 sal_Int32 nElement,
991 const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
992 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
995 /** Import a script field (<text:script>) */
996 class XMLScriptImportContext final : public XMLTextFieldImportContext
998 OUString sContent;
999 OUString sScriptType;
1001 bool bContentOK;
1003 public:
1005 XMLScriptImportContext(SvXMLImport& rImport,
1006 XMLTextImportHelper& rHlp);
1008 private:
1009 /// process attributes
1010 virtual void ProcessAttribute( sal_Int32 nAttrToken,
1011 std::string_view sAttrValue ) override;
1013 /// set properties
1014 virtual void PrepareField(
1015 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1018 /** import measure fields (<text:measure>) */
1019 class XMLMeasureFieldImportContext final : public XMLTextFieldImportContext
1021 sal_Int16 mnKind;
1023 public:
1025 XMLMeasureFieldImportContext(SvXMLImport& rImport,
1026 XMLTextImportHelper& rHlp);
1028 private:
1029 /// process attribute values
1030 virtual void ProcessAttribute( sal_Int32 nAttrToken,
1031 std::string_view sAttrValue ) override;
1033 /// prepare XTextField for insertion into document
1034 virtual void PrepareField(
1035 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1038 /** dropdown field (filter legacy) */
1039 class XMLDropDownFieldImportContext final : public XMLTextFieldImportContext
1041 std::vector<OUString> aLabels;
1042 OUString sName;
1043 OUString sHelp;
1044 OUString sHint;
1045 sal_Int32 nSelected;
1046 bool bNameOK;
1047 bool bHelpOK;
1048 bool bHintOK;
1050 public:
1052 XMLDropDownFieldImportContext(SvXMLImport& rImport,
1053 XMLTextImportHelper& rHlp);
1055 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
1056 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
1058 private:
1059 /// process attribute values
1060 virtual void ProcessAttribute( sal_Int32 nAttrToken,
1061 std::string_view sAttrValue ) override;
1063 /// prepare XTextField for insertion into document
1064 virtual void PrepareField(
1065 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1068 /** import header fields (<draw:header>) */
1069 class XMLHeaderFieldImportContext final : public XMLTextFieldImportContext
1071 public:
1073 XMLHeaderFieldImportContext(
1074 SvXMLImport& rImport, /// XML Import
1075 XMLTextImportHelper& rHlp); /// Text import helper
1077 /// process attribute values
1078 virtual void ProcessAttribute( sal_Int32 nAttrToken,
1079 std::string_view sAttrValue ) override;
1081 /// prepare XTextField for insertion into document
1082 virtual void PrepareField(
1083 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1086 /** import footer fields (<draw:footer>) */
1087 class XMLFooterFieldImportContext final : public XMLTextFieldImportContext
1089 public:
1091 XMLFooterFieldImportContext(
1092 SvXMLImport& rImport, /// XML Import
1093 XMLTextImportHelper& rHlp); /// Text import helper
1095 /// process attribute values
1096 virtual void ProcessAttribute( sal_Int32 nAttrToken,
1097 std::string_view sAttrValue ) override;
1099 /// prepare XTextField for insertion into document
1100 virtual void PrepareField(
1101 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1104 /** import footer fields (<draw:date-and-time>) */
1105 class XMLDateTimeFieldImportContext final : public XMLTextFieldImportContext
1107 public:
1109 XMLDateTimeFieldImportContext(
1110 SvXMLImport& rImport, /// XML Import
1111 XMLTextImportHelper& rHlp); /// Text import helper
1113 /// process attribute values
1114 virtual void ProcessAttribute( sal_Int32 nAttrToken,
1115 std::string_view sAttrValue ) override;
1117 /// prepare XTextField for insertion into document
1118 virtual void PrepareField(
1119 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */