1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 * import of all text fields
23 * (except variable related + database display field: see txtvfldi.hxx)
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>
39 namespace com::sun::star
{
40 namespace xml::sax
{ class XAttributeList
; }
41 namespace text
{ class XTextField
; }
42 namespace beans
{ class XPropertySet
; struct PropertyValue
; }
46 class XMLTextImportHelper
;
49 /// abstract class for text field import
50 class XMLTextFieldImportContext
: public SvXMLImportContext
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
59 OUString sServicePrefix
;
61 // data members for use in subclasses
62 bool bValid
; /// whether this field is valid ?
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(
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(
86 XMLTextImportHelper
& rHlp
,
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
;
125 // variables for access in subclass
130 XMLSenderFieldImportContext(
131 SvXMLImport
& rImport
, /// XML Import
132 XMLTextImportHelper
& rHlp
); /// Text import helper
136 virtual void SAL_CALL
startFastElement(
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
;
158 XMLAuthorFieldImportContext(
159 SvXMLImport
& rImport
, /// XML Import
160 XMLTextImportHelper
& rHlp
); /// Text import helper
164 virtual void SAL_CALL
startFastElement(
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
;
187 XMLPlaceholderFieldImportContext(
188 SvXMLImport
& rImport
, /// XML Import
189 XMLTextImportHelper
& rHlp
); /// Text import helper
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
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
;
213 sal_Int32 nFormatKey
;
217 bool bIsDate
; // is this a date?
218 // (for XMLDateFieldImportContext, really)
219 bool bIsDefaultLanguage
;
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
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
260 bool sStringOK
; /// continuation string encountered?
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
289 bool sNumberFormatOK
;
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
;
323 bool m_bDatabaseNameOK
;
324 bool m_bDatabaseURLOK
;
327 /// protected constructor: only for subclasses
328 XMLDatabaseFieldImportContext(SvXMLImport
& rImport
,
329 XMLTextImportHelper
& rHlp
,
330 const OUString
& pServiceName
,
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(
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
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
;
371 // for use in child classes
372 XMLDatabaseNextImportContext(SvXMLImport
& rImport
,
373 XMLTextImportHelper
& rHlp
,
374 const OUString
& pServiceName
);
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
;
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
;
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
;
451 XMLSimpleDocInfoImportContext(SvXMLImport
& rImport
,
452 XMLTextImportHelper
& rHlp
,
453 sal_Int32 nElementToken
,
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
;
480 bool bIsDefaultLanguage
;
484 XMLDateTimeDocInfoImportContext(SvXMLImport
& rImport
,
485 XMLTextImportHelper
& rHlp
,
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
503 XMLRevisionDocInfoImportContext(SvXMLImport
& rImport
,
504 XMLTextImportHelper
& rHlp
,
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
517 const OUString sPropertyName
;
518 const OUString sPropertyNumberFormat
;
519 const OUString sPropertyIsFixedLanguage
;
522 bool bIsDefaultLanguage
;
526 XMLUserDocInfoImportContext(SvXMLImport
& rImport
,
527 XMLTextImportHelper
& rHlp
,
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
;
549 XMLHiddenParagraphImportContext(SvXMLImport
& rImport
,
550 XMLTextImportHelper
& rHlp
);
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
;
569 OUString sTrueContent
;
570 OUString sFalseContent
;
579 XMLConditionalTextImportContext(SvXMLImport
& rImport
,
580 XMLTextImportHelper
& rHlp
);
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
;
608 XMLHiddenTextImportContext(SvXMLImport
& rImport
,
609 XMLTextImportHelper
& rHlp
);
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
;
633 XMLFileNameImportContext(SvXMLImport
& rImport
,
634 XMLTextImportHelper
& rHlp
);
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
;
655 XMLTemplateNameImportContext(SvXMLImport
& rImport
,
656 XMLTextImportHelper
& rHlp
);
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
676 XMLChapterImportContext(SvXMLImport
& rImport
,
677 XMLTextImportHelper
& rHlp
);
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
;
701 XMLCountFieldImportContext(SvXMLImport
& rImport
,
702 XMLTextImportHelper
& rHlp
,
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
;
727 XMLPageVarGetFieldImportContext(SvXMLImport
& rImport
,
728 XMLTextImportHelper
& rHlp
);
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
748 XMLPageVarSetFieldImportContext(SvXMLImport
& rImport
,
749 XMLTextImportHelper
& rHlp
);
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)
773 XMLMacroFieldImportContext(SvXMLImport
& rImport
,
774 XMLTextImportHelper
& rHlp
);
777 /// for <office:events> children
778 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(
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
796 sal_Int32 nElementToken
;
806 XMLReferenceFieldImportContext(SvXMLImport
& rImport
,
807 XMLTextImportHelper
& rHlp
,
812 virtual void SAL_CALL
startFastElement(
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
830 XMLDdeFieldDeclsImportContext(SvXMLImport
& rImport
);
832 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(
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
842 XMLDdeFieldDeclImportContext(SvXMLImport
& rImport
);
844 // create fieldmaster
845 virtual void SAL_CALL
startFastElement(
847 const css::uno::Reference
<css::xml::sax::XFastAttributeList
> & xAttrList
) override
;
850 /** import dde fields (<text:dde-connection>) */
851 class XMLDdeFieldImportContext final
: public XMLTextFieldImportContext
854 OUString sPropertyContent
;
858 XMLDdeFieldImportContext(SvXMLImport
& rImport
,
859 XMLTextImportHelper
& rHlp
);
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
;
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
880 XMLSheetNameImportContext(SvXMLImport
& rImport
,
881 XMLTextImportHelper
& rHlp
);
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
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
920 XMLUrlFieldImportContext(SvXMLImport
& rImport
,
921 XMLTextImportHelper
& rHlp
);
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
;
940 XMLBibliographyFieldImportContext(SvXMLImport
& rImport
,
941 XMLTextImportHelper
& rHlp
);
944 /// process attributes (fill aValues)
945 virtual void SAL_CALL
startFastElement(
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
;
966 OUString aParentName
;
967 OUStringBuffer aTextBuffer
;
968 OUStringBuffer aDateBuffer
;
971 css::uno::Reference
< css::beans::XPropertySet
> mxField
;
972 css::uno::Reference
< css::text::XTextCursor
> mxCursor
;
973 css::uno::Reference
< css::text::XTextCursor
> mxOldCursor
;
979 XMLAnnotationImportContext(SvXMLImport
& rImport
,
980 XMLTextImportHelper
& rHlp
,
984 /// process attributes
985 virtual void ProcessAttribute( sal_Int32 nAttrToken
,
986 std::string_view sAttrValue
) override
;
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(
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
1002 OUString sScriptType
;
1008 XMLScriptImportContext(SvXMLImport
& rImport
,
1009 XMLTextImportHelper
& rHlp
);
1012 /// process attributes
1013 virtual void ProcessAttribute( sal_Int32 nAttrToken
,
1014 std::string_view sAttrValue
) override
;
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
1028 XMLMeasureFieldImportContext(SvXMLImport
& rImport
,
1029 XMLTextImportHelper
& rHlp
);
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
;
1048 sal_Int32 nSelected
;
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
;
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
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
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
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: */