Version 24.2.2.2, tag libreoffice-24.2.2.2
[LibreOffice.git] / xmloff / inc / txtfldi.hxx
blob3d56c547811e714b8565074781968b1319de9684
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>
37 #include "txtfld.hxx"
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 OUString aService); /// name of SO API service
71 /// process character data: will be collected in member sContentBuffer
72 virtual void SAL_CALL characters( const OUString& sContent ) override;
74 /// parses attributes and calls ProcessAttribute
75 virtual void SAL_CALL startFastElement(
76 sal_Int32 nElement,
77 const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList) override;
79 /// create XTextField and insert into document; calls PrepareTextField
80 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
82 /// create the appropriate field context from
83 /// (for use in paragraph import)
84 static XMLTextFieldImportContext* CreateTextFieldImportContext(
85 SvXMLImport& rImport,
86 XMLTextImportHelper& rHlp,
87 sal_Int32 nElement);
89 protected:
90 /// get helper
91 XMLTextImportHelper& GetImportHelper() { return rTextImportHelper; }
93 const OUString& GetServiceName() const { return sServiceName; }
94 void SetServiceName(const OUString& sStr) { sServiceName = sStr; }
96 OUString const & GetContent();
98 /// process attribute values
99 virtual void ProcessAttribute( sal_Int32 nAttrToken,
100 std::string_view sAttrValue ) = 0;
102 /// prepare XTextField for insertion into document
103 virtual void PrepareField(
104 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) = 0;
106 /// create field from ServiceName
107 bool CreateField(css::uno::Reference< css::beans::XPropertySet> & xField,
108 const OUString& sServiceName);
110 /// force an update of the field's value
111 /// call update on optional XUpdatable interface; (disable Fixed property)
112 static void ForceUpdate(
113 const css::uno::Reference< css::beans::XPropertySet> & rPropertySet);
116 class XMLSenderFieldImportContext : public XMLTextFieldImportContext
119 sal_Int16 nSubType; /// API subtype for ExtUser field
121 const OUString sPropertyFixed;
122 const OUString sPropertyContent;
124 protected:
125 // variables for access in subclass
126 bool bFixed;
128 public:
130 XMLSenderFieldImportContext(
131 SvXMLImport& rImport, /// XML Import
132 XMLTextImportHelper& rHlp); /// Text import helper
134 protected:
135 /// start element
136 virtual void SAL_CALL startFastElement(
137 sal_Int32 nElement,
138 const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList) override;
140 /// process attribute values
141 virtual void ProcessAttribute( sal_Int32 nAttrToken,
142 std::string_view sAttrValue ) override;
144 /// prepare XTextField for insertion into document
145 virtual void PrepareField(
146 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
149 /** inherit sender field because of fixed attribute in ProcessAttributes */
150 class XMLAuthorFieldImportContext final : public XMLSenderFieldImportContext
152 bool bAuthorFullName;
153 const OUString sPropertyFixed;
154 const OUString sPropertyContent;
156 public:
158 XMLAuthorFieldImportContext(
159 SvXMLImport& rImport, /// XML Import
160 XMLTextImportHelper& rHlp); /// Text import helper
162 private:
163 /// start element
164 virtual void SAL_CALL startFastElement(
165 sal_Int32 nElement,
166 const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList) override;
168 /// process attribute values
169 virtual void ProcessAttribute( sal_Int32 nAttrToken,
170 std::string_view sAttrValue ) override;
172 /// prepare XTextField for insertion into document
173 virtual void PrepareField(
174 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
177 class XMLPlaceholderFieldImportContext final : public XMLTextFieldImportContext
179 const OUString sPropertyHint;
181 OUString sDescription;
183 sal_Int16 nPlaceholderType;
185 public:
187 XMLPlaceholderFieldImportContext(
188 SvXMLImport& rImport, /// XML Import
189 XMLTextImportHelper& rHlp); /// Text import helper
191 private:
192 /// process attribute values
193 virtual void ProcessAttribute( sal_Int32 nAttrToken,
194 std::string_view sAttrValue ) override;
196 /// prepare XTextField for insertion into document
197 virtual void PrepareField(
198 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
201 class XMLTimeFieldImportContext : public XMLTextFieldImportContext
203 protected:
204 const OUString sPropertyNumberFormat;
205 const OUString sPropertyFixed;
206 const OUString sPropertyDateTimeValue;
207 const OUString sPropertyDateTime;
208 const OUString sPropertyIsDate;
209 const OUString sPropertyIsFixedLanguage;
211 css::util::DateTime aDateTimeValue;
212 sal_Int32 nAdjust;
213 sal_Int32 nFormatKey;
214 bool bTimeOK;
215 bool bFormatOK;
216 bool bFixed;
217 bool bIsDate; // is this a date?
218 // (for XMLDateFieldImportContext, really)
219 bool bIsDefaultLanguage;
221 public:
223 XMLTimeFieldImportContext(
224 SvXMLImport& rImport, /// XML Import
225 XMLTextImportHelper& rHlp); /// Text import helper
227 /// process attribute values
228 virtual void ProcessAttribute( sal_Int32 nAttrToken,
229 std::string_view sAttrValue ) override;
231 /// prepare XTextField for insertion into document
232 virtual void PrepareField(
233 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
236 /** import date fields (<text:date>);
237 inherit from TimeField to reuse implementation */
238 class XMLDateFieldImportContext final : public XMLTimeFieldImportContext
240 public:
242 XMLDateFieldImportContext(
243 SvXMLImport& rImport, /// XML Import
244 XMLTextImportHelper& rHlp); /// Text import helper
246 /// process attribute values
247 virtual void ProcessAttribute( sal_Int32 nAttrToken,
248 std::string_view sAttrValue ) override;
251 /** import page continuation fields (<text:page-continuation-string>) */
252 class XMLPageContinuationImportContext final : public XMLTextFieldImportContext
254 const OUString sPropertySubType;
255 const OUString sPropertyNumberingType;
257 OUString sString; /// continuation string
258 css::text::PageNumberType eSelectPage; /// previous, current
259 /// or next page
260 bool sStringOK; /// continuation string encountered?
262 public:
264 XMLPageContinuationImportContext(
265 SvXMLImport& rImport, /// XML Import
266 XMLTextImportHelper& rHlp); /// Text import helper
268 /// process attribute values
269 virtual void ProcessAttribute( sal_Int32 nAttrToken,
270 std::string_view sAttrValue ) override;
272 /// prepare XTextField for insertion into document
273 virtual void PrepareField(
274 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
277 /** import page number fields (<text:page-number>) */
278 class XMLPageNumberImportContext final : public XMLTextFieldImportContext
280 const OUString sPropertySubType;
281 const OUString sPropertyNumberingType;
282 const OUString sPropertyOffset;
284 OUString sNumberFormat;
285 OUString sNumberSync;
286 sal_Int16 nPageAdjust;
287 css::text::PageNumberType eSelectPage; /// previous, current
288 /// or next page
289 bool sNumberFormatOK;
291 public:
293 XMLPageNumberImportContext(
294 SvXMLImport& rImport, /// XML Import
295 XMLTextImportHelper& rHlp); /// Text import helper
298 /// process attribute values
299 virtual void ProcessAttribute( sal_Int32 nAttrToken,
300 std::string_view sAttrValue ) override;
302 /// prepare XTextField for insertion into document
303 virtual void PrepareField(
304 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
307 /** superclass for database fields: handle database and table names */
308 class XMLDatabaseFieldImportContext : public XMLTextFieldImportContext
310 OUString m_sDatabaseName;
311 OUString m_sDatabaseURL;
312 OUString m_sTableName;
314 sal_Int32 m_nCommandType;
315 bool m_bCommandTypeOK;
317 bool m_bDisplay;
318 bool m_bDisplayOK;
319 bool m_bUseDisplay;
321 protected:
322 bool m_bDatabaseOK;
323 bool m_bDatabaseNameOK;
324 bool m_bDatabaseURLOK;
325 bool m_bTableOK;
327 /// protected constructor: only for subclasses
328 XMLDatabaseFieldImportContext(SvXMLImport& rImport,
329 XMLTextImportHelper& rHlp,
330 const OUString& pServiceName,
331 bool bUseDisplay );
333 public:
335 /// process attribute values
336 virtual void ProcessAttribute( sal_Int32 nAttrToken,
337 std::string_view sAttrValue ) override;
339 /// prepare XTextField for insertion into document
340 virtual void PrepareField(
341 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
343 /// handle database-location children
344 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
345 sal_Int32 nElement,
346 const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
349 /** import database name fields (<text:database-name>) */
350 class XMLDatabaseNameImportContext final : public XMLDatabaseFieldImportContext
352 public:
354 XMLDatabaseNameImportContext(SvXMLImport& rImport,
355 XMLTextImportHelper& rHlp);
357 /// process attribute values
358 virtual void ProcessAttribute( sal_Int32 nAttrToken,
359 std::string_view sAttrValue ) override;
362 /** import database next fields (<text:database-next>) */
363 class XMLDatabaseNextImportContext : public XMLDatabaseFieldImportContext
365 const OUString sPropertyCondition;
366 const OUString sTrue;
367 OUString sCondition;
368 bool bConditionOK;
370 protected:
371 // for use in child classes
372 XMLDatabaseNextImportContext(SvXMLImport& rImport,
373 XMLTextImportHelper& rHlp,
374 const OUString& pServiceName);
376 public:
378 XMLDatabaseNextImportContext(SvXMLImport& rImport,
379 XMLTextImportHelper& rHlp);
381 /// process attribute values
382 virtual void ProcessAttribute( sal_Int32 nAttrToken,
383 std::string_view sAttrValue ) override;
385 /// prepare XTextField for insertion into document
386 virtual void PrepareField(
387 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
390 /** import database select fields (<text:database-select>) */
391 class XMLDatabaseSelectImportContext final : public XMLDatabaseNextImportContext
393 const OUString sPropertySetNumber;
394 sal_Int32 nNumber;
395 bool bNumberOK;
397 public:
399 XMLDatabaseSelectImportContext(SvXMLImport& rImport,
400 XMLTextImportHelper& rHlp);
402 /// process attribute values
403 virtual void ProcessAttribute( sal_Int32 nAttrToken,
404 std::string_view sAttrValue ) override;
406 /// prepare XTextField for insertion into document
407 virtual void PrepareField(
408 const css::uno::Reference<
409 css::beans::XPropertySet> & xPropertySet) override;
412 /** import database display number fields (<text:database-row-number>) */
413 class XMLDatabaseNumberImportContext final : public XMLDatabaseFieldImportContext
415 const OUString sPropertyNumberingType;
416 const OUString sPropertySetNumber;
417 OUString sNumberFormat;
418 OUString sNumberSync;
419 sal_Int32 nValue;
420 bool bValueOK;
422 public:
424 XMLDatabaseNumberImportContext(SvXMLImport& rImport,
425 XMLTextImportHelper& rHlp);
427 /// process attribute values
428 virtual void ProcessAttribute( sal_Int32 nAttrToken,
429 std::string_view sAttrValue ) override;
431 /// prepare XTextField for insertion into document
432 virtual void PrepareField(
433 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
436 /** import docinfo fields with only fixed attribute */
437 class XMLSimpleDocInfoImportContext : public XMLTextFieldImportContext
439 const OUString sPropertyFixed;
440 const OUString sPropertyContent;
441 const OUString sPropertyAuthor;
442 const OUString sPropertyCurrentPresentation;
444 protected:
445 bool bFixed;
446 bool bHasAuthor;
447 bool bHasContent;
449 public:
451 XMLSimpleDocInfoImportContext(SvXMLImport& rImport,
452 XMLTextImportHelper& rHlp,
453 sal_Int32 nElementToken,
454 bool bContent,
455 bool bAuthor);
457 protected:
458 /// process attribute values
459 virtual void ProcessAttribute( sal_Int32 nAttrToken,
460 std::string_view sAttrValue ) override;
462 /// prepare XTextField for insertion into document
463 virtual void PrepareField(
464 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
466 static OUString MapTokenToServiceName(sal_Int32 nElementToken);
469 /** import docinfo fields with date or time attributes and numberformats */
470 class XMLDateTimeDocInfoImportContext final : public XMLSimpleDocInfoImportContext
472 const OUString sPropertyNumberFormat;
473 const OUString sPropertyIsDate;
474 const OUString sPropertyIsFixedLanguage;
476 sal_Int32 nFormat;
477 bool bFormatOK;
478 bool bIsDate;
479 bool bHasDateTime;
480 bool bIsDefaultLanguage;
482 public:
484 XMLDateTimeDocInfoImportContext(SvXMLImport& rImport,
485 XMLTextImportHelper& rHlp,
486 sal_Int32 nElement);
488 private:
489 /// process attribute values
490 virtual void ProcessAttribute( sal_Int32 nAttrToken,
491 std::string_view sAttrValue ) override;
493 /// prepare XTextField for insertion into document
494 virtual void PrepareField(
495 const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
498 /** import revision field (<text:editing-cycles>) */
499 class XMLRevisionDocInfoImportContext final : public XMLSimpleDocInfoImportContext
501 public:
503 XMLRevisionDocInfoImportContext(SvXMLImport& rImport,
504 XMLTextImportHelper& rHlp,
505 sal_Int32 nElement);
507 private:
508 /// prepare XTextField for insertion into document
509 virtual void PrepareField(
510 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
513 /** import user docinfo field (<text:user-defined>) */
514 class XMLUserDocInfoImportContext final : public XMLSimpleDocInfoImportContext
516 OUString aName;
517 const OUString sPropertyName;
518 const OUString sPropertyNumberFormat;
519 const OUString sPropertyIsFixedLanguage;
520 sal_Int32 nFormat;
521 bool bFormatOK;
522 bool bIsDefaultLanguage;
524 public:
526 XMLUserDocInfoImportContext(SvXMLImport& rImport,
527 XMLTextImportHelper& rHlp,
528 sal_Int32 nElement);
530 private:
531 /// process attribute values
532 virtual void ProcessAttribute( sal_Int32 nAttrToken,
533 std::string_view sAttrValue ) override;
534 virtual void PrepareField(
535 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
538 /** import hidden paragraph fields (<text:hidden-paragraph>) */
539 class XMLHiddenParagraphImportContext final : public XMLTextFieldImportContext
541 const OUString sPropertyCondition;
542 const OUString sPropertyIsHidden;
544 OUString sCondition;
545 bool bIsHidden;
547 public:
549 XMLHiddenParagraphImportContext(SvXMLImport& rImport,
550 XMLTextImportHelper& rHlp);
552 private:
553 /// process attribute values
554 virtual void ProcessAttribute( sal_Int32 nAttrToken,
555 std::string_view sAttrValue ) override;
557 /// prepare XTextField for insertion into document
558 virtual void PrepareField(
559 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
562 /** import conditional text fields (<text:conditional-text>) */
563 class XMLConditionalTextImportContext final : public XMLTextFieldImportContext
565 const OUString sPropertyCondition;
566 const OUString sPropertyCurrentPresentation;
568 OUString sCondition;
569 OUString sTrueContent;
570 OUString sFalseContent;
572 bool bConditionOK;
573 bool bTrueOK;
574 bool bFalseOK;
575 bool bCurrentValue;
577 public:
579 XMLConditionalTextImportContext(SvXMLImport& rImport,
580 XMLTextImportHelper& rHlp);
582 private:
583 /// process attribute values
584 virtual void ProcessAttribute( sal_Int32 nAttrToken,
585 std::string_view sAttrValue ) override;
587 /// prepare XTextField for insertion into document
588 virtual void PrepareField(
589 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
592 /** import conditional text fields (<text:hidden-text>) */
593 class XMLHiddenTextImportContext final : public XMLTextFieldImportContext
595 const OUString sPropertyCondition;
596 const OUString sPropertyContent;
597 const OUString sPropertyIsHidden;
599 OUString sCondition;
600 OUString sString;
602 bool bConditionOK;
603 bool bStringOK;
604 bool bIsHidden;
606 public:
608 XMLHiddenTextImportContext(SvXMLImport& rImport,
609 XMLTextImportHelper& rHlp);
611 private:
612 /// process attribute values
613 virtual void ProcessAttribute( sal_Int32 nAttrToken,
614 std::string_view sAttrValue ) override;
616 /// prepare XTextField for insertion into document
617 virtual void PrepareField(
618 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
621 /** import file name fields (<text:file-name>) */
622 class XMLFileNameImportContext final : public XMLTextFieldImportContext
624 const OUString sPropertyFixed;
625 const OUString sPropertyFileFormat;
626 const OUString sPropertyCurrentPresentation;
628 sal_Int16 nFormat;
629 bool bFixed;
631 public:
633 XMLFileNameImportContext(SvXMLImport& rImport,
634 XMLTextImportHelper& rHlp);
636 private:
637 /// process attribute values
638 virtual void ProcessAttribute( sal_Int32 nAttrToken,
639 std::string_view sAttrValue ) override;
641 /// prepare XTextField for insertion into document
642 virtual void PrepareField(
643 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
646 /** import document template name fields (<text:template-name>) */
647 class XMLTemplateNameImportContext final : public XMLTextFieldImportContext
649 const OUString sPropertyFileFormat;
651 sal_Int16 nFormat;
653 public:
655 XMLTemplateNameImportContext(SvXMLImport& rImport,
656 XMLTextImportHelper& rHlp);
658 private:
659 /// process attribute values
660 virtual void ProcessAttribute( sal_Int32 nAttrToken,
661 std::string_view sAttrValue ) override;
663 /// prepare XTextField for insertion into document
664 virtual void PrepareField(
665 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
668 /** import chapter fields (<text:chapter>) */
669 class XMLChapterImportContext final : public XMLTextFieldImportContext
671 sal_Int16 nFormat;
672 sal_Int8 nLevel;
674 public:
676 XMLChapterImportContext(SvXMLImport& rImport,
677 XMLTextImportHelper& rHlp);
679 private:
680 /// process attribute values
681 virtual void ProcessAttribute( sal_Int32 nAttrToken,
682 std::string_view sAttrValue ) override;
684 /// prepare XTextField for insertion into document
685 virtual void PrepareField(
686 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
689 /** import count fields (<text:[XXX]-count>) */
690 class XMLCountFieldImportContext final : public XMLTextFieldImportContext
692 const OUString sPropertyNumberingType;
694 OUString sNumberFormat;
695 OUString sLetterSync;
697 bool bNumberFormatOK;
699 public:
701 XMLCountFieldImportContext(SvXMLImport& rImport,
702 XMLTextImportHelper& rHlp,
703 sal_Int32 nElement);
705 private:
706 /// process attribute values
707 virtual void ProcessAttribute( sal_Int32 nAttrToken,
708 std::string_view sAttrValue ) override;
710 /// prepare XTextField for insertion into document
711 virtual void PrepareField(
712 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
714 static OUString MapTokenToServiceName(sal_Int32 nElement);
717 /** import page variable fields (<text:get-page-variable>) */
718 class XMLPageVarGetFieldImportContext final : public XMLTextFieldImportContext
720 OUString sNumberFormat;
721 OUString sLetterSync;
723 bool bNumberFormatOK;
725 public:
727 XMLPageVarGetFieldImportContext(SvXMLImport& rImport,
728 XMLTextImportHelper& rHlp);
730 private:
731 /// process attribute values
732 virtual void ProcessAttribute( sal_Int32 nAttrToken,
733 std::string_view sAttrValue ) override;
735 /// prepare XTextField for insertion into document
736 virtual void PrepareField(
737 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
740 /** import page variable fields (<text:get-page-variable>) */
741 class XMLPageVarSetFieldImportContext final : public XMLTextFieldImportContext
743 sal_Int16 nAdjust;
744 bool bActive;
746 public:
748 XMLPageVarSetFieldImportContext(SvXMLImport& rImport,
749 XMLTextImportHelper& rHlp);
751 private:
752 /// process attribute values
753 virtual void ProcessAttribute( sal_Int32 nAttrToken,
754 std::string_view sAttrValue ) override;
756 /// prepare XTextField for insertion into document
757 virtual void PrepareField(
758 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
761 /** import macro fields (<text:execute-macro>) */
762 class XMLMacroFieldImportContext final : public XMLTextFieldImportContext
764 OUString sDescription;
765 rtl::Reference<XMLEventsImportContext> xEventContext;
767 OUString sMacro; // macro for old documents (pre 638i)
769 bool bDescriptionOK;
771 public:
773 XMLMacroFieldImportContext(SvXMLImport& rImport,
774 XMLTextImportHelper& rHlp);
776 private:
777 /// for <office:events> children
778 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
779 sal_Int32 nElement,
780 const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
782 /// process attribute values
783 virtual void ProcessAttribute( sal_Int32 nAttrToken,
784 std::string_view sAttrValue ) override;
786 /// prepare XTextField for insertion into document
787 virtual void PrepareField(
788 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
791 /** import reference fields (<text:reference-get>) */
792 class XMLReferenceFieldImportContext final : public XMLTextFieldImportContext
794 OUString sName;
795 OUString sLanguage;
796 sal_Int32 nElementToken;
797 sal_Int16 nSource;
798 sal_Int16 nType;
799 sal_uInt16 nFlags;
801 bool bNameOK;
802 bool bTypeOK;
804 public:
806 XMLReferenceFieldImportContext(SvXMLImport& rImport,
807 XMLTextImportHelper& rHlp,
808 sal_Int32 nToken);
810 private:
811 /// start element
812 virtual void SAL_CALL startFastElement(
813 sal_Int32 nElement,
814 const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList) override;
816 /// process attribute values
817 virtual void ProcessAttribute( sal_Int32 nAttrToken,
818 std::string_view sAttrValue ) override;
820 /// prepare XTextField for insertion into document
821 virtual void PrepareField(
822 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
825 /** import dde field declaration container (<text:dde-connection-decls>) */
826 class XMLDdeFieldDeclsImportContext final : public SvXMLImportContext
828 public:
830 XMLDdeFieldDeclsImportContext(SvXMLImport& rImport);
832 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
833 sal_Int32 nElement,
834 const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
837 /** import dde field declaration (<text:dde-connection-decl>) */
838 class XMLDdeFieldDeclImportContext final : public SvXMLImportContext
840 public:
842 XMLDdeFieldDeclImportContext(SvXMLImport& rImport);
844 // create fieldmaster
845 virtual void SAL_CALL startFastElement(
846 sal_Int32 nElement,
847 const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList) override;
850 /** import dde fields (<text:dde-connection>) */
851 class XMLDdeFieldImportContext final : public XMLTextFieldImportContext
853 OUString sName;
854 OUString sPropertyContent;
856 public:
858 XMLDdeFieldImportContext(SvXMLImport& rImport,
859 XMLTextImportHelper& rHlp);
861 private:
862 /// process attribute values
863 virtual void ProcessAttribute( sal_Int32 nAttrToken,
864 std::string_view sAttrValue ) override;
866 /// create textfield, attach master, and insert into document
867 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
869 /// empty method
870 virtual void PrepareField(
871 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
874 /** import sheet name fields (Calc) dde fields (<text:sheet-name>) */
875 class XMLSheetNameImportContext final : public XMLTextFieldImportContext
878 public:
880 XMLSheetNameImportContext(SvXMLImport& rImport,
881 XMLTextImportHelper& rHlp);
883 private:
884 /// no attributes -> empty method
885 virtual void ProcessAttribute( sal_Int32 nAttrToken,
886 std::string_view sAttrValue ) override;
888 /// no attributes -> empty method
889 virtual void PrepareField(
890 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
893 /** import page|slide name fields (<text:page-name>) */
894 class XMLPageNameFieldImportContext final : public XMLTextFieldImportContext
896 public:
898 XMLPageNameFieldImportContext(
899 SvXMLImport& rImport, /// XML Import
900 XMLTextImportHelper& rHlp); /// Text import helper
902 /// process attribute values
903 virtual void ProcessAttribute( sal_Int32 nAttrToken,
904 std::string_view 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 hyperlinks as URL fields (Calc, Impress, Draw) (<office:a>) */
912 class XMLUrlFieldImportContext final : public XMLTextFieldImportContext
914 OUString sURL;
915 OUString sFrame;
916 bool bFrameOK;
918 public:
920 XMLUrlFieldImportContext(SvXMLImport& rImport,
921 XMLTextImportHelper& rHlp);
923 private:
924 /// no attributes -> empty method
925 virtual void ProcessAttribute( sal_Int32 nAttrToken,
926 std::string_view sAttrValue ) override;
928 /// no attributes -> empty method
929 virtual void PrepareField(
930 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
933 /** import bibliography info fields (<text:bibliography-mark>) */
934 class XMLBibliographyFieldImportContext final : public XMLTextFieldImportContext
936 ::std::vector< css::beans::PropertyValue> aValues;
938 public:
940 XMLBibliographyFieldImportContext(SvXMLImport& rImport,
941 XMLTextImportHelper& rHlp);
943 private:
944 /// process attributes (fill aValues)
945 virtual void SAL_CALL startFastElement(
946 sal_Int32 nElement,
947 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList) override;
949 /// empty method; all attributes are handled in StartElement
950 virtual void ProcessAttribute( sal_Int32 nAttrToken,
951 std::string_view sAttrValue ) override;
953 /// convert aValues into sequence and set property
954 virtual void PrepareField(
955 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
957 static const char* MapBibliographyFieldName(sal_Int32 nElement);
960 /** Import an annotation field (<text:annotation>) */
961 class XMLAnnotationImportContext final : public XMLTextFieldImportContext
963 OUStringBuffer aAuthorBuffer;
964 OUStringBuffer aInitialsBuffer;
965 OUString aName;
966 OUString aParentName;
967 OUStringBuffer aTextBuffer;
968 OUStringBuffer aDateBuffer;
969 OUString aResolved;
971 css::uno::Reference < css::beans::XPropertySet > mxField;
972 css::uno::Reference < css::text::XTextCursor > mxCursor;
973 css::uno::Reference < css::text::XTextCursor > mxOldCursor;
975 sal_Int32 mnElement;
977 public:
979 XMLAnnotationImportContext(SvXMLImport& rImport,
980 XMLTextImportHelper& rHlp,
981 sal_Int32 nElement);
983 private:
984 /// process attributes
985 virtual void ProcessAttribute( sal_Int32 nAttrToken,
986 std::string_view sAttrValue ) override;
988 /// set properties
989 virtual void PrepareField(
990 const css::uno::Reference< css::beans::XPropertySet > & xPropertySet) override;
992 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
993 sal_Int32 nElement,
994 const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
995 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
998 /** Import a script field (<text:script>) */
999 class XMLScriptImportContext final : public XMLTextFieldImportContext
1001 OUString sContent;
1002 OUString sScriptType;
1004 bool bContentOK;
1006 public:
1008 XMLScriptImportContext(SvXMLImport& rImport,
1009 XMLTextImportHelper& rHlp);
1011 private:
1012 /// process attributes
1013 virtual void ProcessAttribute( sal_Int32 nAttrToken,
1014 std::string_view sAttrValue ) override;
1016 /// set properties
1017 virtual void PrepareField(
1018 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1021 /** import measure fields (<text:measure>) */
1022 class XMLMeasureFieldImportContext final : public XMLTextFieldImportContext
1024 sal_Int16 mnKind;
1026 public:
1028 XMLMeasureFieldImportContext(SvXMLImport& rImport,
1029 XMLTextImportHelper& rHlp);
1031 private:
1032 /// process attribute values
1033 virtual void ProcessAttribute( sal_Int32 nAttrToken,
1034 std::string_view sAttrValue ) override;
1036 /// prepare XTextField for insertion into document
1037 virtual void PrepareField(
1038 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1041 /** dropdown field (filter legacy) */
1042 class XMLDropDownFieldImportContext final : public XMLTextFieldImportContext
1044 std::vector<OUString> aLabels;
1045 OUString sName;
1046 OUString sHelp;
1047 OUString sHint;
1048 sal_Int32 nSelected;
1049 bool bNameOK;
1050 bool bHelpOK;
1051 bool bHintOK;
1053 public:
1055 XMLDropDownFieldImportContext(SvXMLImport& rImport,
1056 XMLTextImportHelper& rHlp);
1058 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
1059 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
1061 private:
1062 /// process attribute values
1063 virtual void ProcessAttribute( sal_Int32 nAttrToken,
1064 std::string_view sAttrValue ) override;
1066 /// prepare XTextField for insertion into document
1067 virtual void PrepareField(
1068 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1071 /** import header fields (<draw:header>) */
1072 class XMLHeaderFieldImportContext final : public XMLTextFieldImportContext
1074 public:
1076 XMLHeaderFieldImportContext(
1077 SvXMLImport& rImport, /// XML Import
1078 XMLTextImportHelper& rHlp); /// Text import helper
1080 /// process attribute values
1081 virtual void ProcessAttribute( sal_Int32 nAttrToken,
1082 std::string_view sAttrValue ) override;
1084 /// prepare XTextField for insertion into document
1085 virtual void PrepareField(
1086 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1089 /** import footer fields (<draw:footer>) */
1090 class XMLFooterFieldImportContext final : public XMLTextFieldImportContext
1092 public:
1094 XMLFooterFieldImportContext(
1095 SvXMLImport& rImport, /// XML Import
1096 XMLTextImportHelper& rHlp); /// Text import helper
1098 /// process attribute values
1099 virtual void ProcessAttribute( sal_Int32 nAttrToken,
1100 std::string_view sAttrValue ) override;
1102 /// prepare XTextField for insertion into document
1103 virtual void PrepareField(
1104 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1107 /** import footer fields (<draw:date-and-time>) */
1108 class XMLDateTimeFieldImportContext final : public XMLTextFieldImportContext
1110 public:
1112 XMLDateTimeFieldImportContext(
1113 SvXMLImport& rImport, /// XML Import
1114 XMLTextImportHelper& rHlp); /// Text import helper
1116 /// process attribute values
1117 virtual void ProcessAttribute( sal_Int32 nAttrToken,
1118 std::string_view sAttrValue ) override;
1120 /// prepare XTextField for insertion into document
1121 virtual void PrepareField(
1122 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
1125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */