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 .
23 * Import of all text fields except those from txtvfldi.cxx
24 * (variable related text fields and database display fields)
27 #include <sal/config.h>
32 #include <txtfldi.hxx>
33 #include <txtvfldi.hxx>
35 #include <xmloff/xmlimp.hxx>
36 #include <xmloff/txtimp.hxx>
37 #include <xmloff/xmlnamespace.hxx>
38 #include <xmloff/namespacemap.hxx>
39 #include <xmloff/xmltoken.hxx>
40 #include <xmloff/xmluconv.hxx>
41 #include <xmloff/xmlement.hxx>
42 #include <XMLStringBufferImportContext.hxx>
43 #include <xmloff/XMLEventsImportContext.hxx>
44 #include <com/sun/star/frame/XModel.hpp>
45 #include <com/sun/star/text/UserDataPart.hpp>
46 #include <com/sun/star/style/NumberingType.hpp>
47 #include <com/sun/star/text/PlaceholderType.hpp>
48 #include <com/sun/star/text/ReferenceFieldPart.hpp>
49 #include <com/sun/star/text/ReferenceFieldSource.hpp>
50 #include <com/sun/star/text/XTextContent.hpp>
51 #include <com/sun/star/beans/XPropertySet.hpp>
52 #include <com/sun/star/beans/XPropertySetInfo.hpp>
53 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
54 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
55 #include <com/sun/star/text/XDependentTextField.hpp>
56 #include <com/sun/star/text/FilenameDisplayFormat.hpp>
57 #include <com/sun/star/text/ChapterFormat.hpp>
58 #include <com/sun/star/text/TemplateDisplayFormat.hpp>
59 #include <com/sun/star/beans/PropertyValue.hpp>
60 #include <com/sun/star/text/BibliographyDataType.hpp>
61 #include <com/sun/star/util/XUpdatable.hpp>
62 #include <com/sun/star/sdb/CommandType.hpp>
63 #include <com/sun/star/container/XIndexReplace.hpp>
64 #include <com/sun/star/container/XUniqueIDAccess.hpp>
66 #include <sax/tools/converter.hxx>
68 #include <rtl/ustring.hxx>
69 #include <rtl/ustrbuf.hxx>
70 #include <sal/log.hxx>
71 #include <rtl/math.hxx>
72 #include <tools/debug.hxx>
73 #include <osl/diagnose.h>
74 #include <comphelper/diagnose_ex.hxx>
76 using namespace ::com::sun::star
;
77 using namespace ::com::sun::star::uno
;
78 using namespace ::com::sun::star::text
;
79 using namespace ::com::sun::star::lang
;
80 using namespace ::com::sun::star::beans
;
81 using namespace ::com::sun::star::document
;
82 using namespace ::com::sun::star::util
;
83 using namespace ::com::sun::star::xml::sax
;
84 using namespace ::xmloff::token
;
87 // SO API string constants
90 // service prefix and service names
91 constexpr OUString sAPI_textfield_prefix
= u
"com.sun.star.text.TextField."_ustr
;
92 constexpr char16_t sAPI_fieldmaster_prefix
[] = u
"com.sun.star.text.FieldMaster.";
93 constexpr OUString sAPI_presentation_prefix
= u
"com.sun.star.presentation.TextField."_ustr
;
95 constexpr OUString sAPI_date_time
= u
"DateTime"_ustr
;
96 constexpr OUString sAPI_page_number
= u
"PageNumber"_ustr
;
97 constexpr OUString sAPI_docinfo_change_date_time
= u
"DocInfo.ChangeDateTime"_ustr
;
98 constexpr OUString sAPI_docinfo_create_date_time
= u
"DocInfo.CreateDateTime"_ustr
;
99 constexpr OUString sAPI_docinfo_custom
= u
"DocInfo.Custom"_ustr
;
100 constexpr OUString sAPI_docinfo_print_date_time
= u
"DocInfo.PrintDateTime"_ustr
;
101 constexpr OUString sAPI_dde
= u
"DDE"_ustr
;
102 constexpr OUString sAPI_url
= u
"URL"_ustr
;
105 constexpr OUString sAPI_is_fixed
= u
"IsFixed"_ustr
;
106 constexpr OUString sAPI_content
= u
"Content"_ustr
;
107 constexpr OUString sAPI_author
= u
"Author"_ustr
;
108 constexpr OUString sAPI_hint
= u
"Hint"_ustr
;
109 constexpr OUString sAPI_name
= u
"Name"_ustr
;
110 constexpr OUStringLiteral sAPI_parent_name
= u
"ParentName";
111 constexpr OUString sAPI_sub_type
= u
"SubType"_ustr
;
112 constexpr OUString sAPI_date_time_value
= u
"DateTimeValue"_ustr
;
113 constexpr OUString sAPI_number_format
= u
"NumberFormat"_ustr
;
114 constexpr OUString sAPI_numbering_type
= u
"NumberingType"_ustr
;
115 constexpr OUString sAPI_offset
= u
"Offset"_ustr
;
116 constexpr OUString sAPI_condition
= u
"Condition"_ustr
;
117 constexpr OUString sAPI_set_number
= u
"SetNumber"_ustr
;
118 constexpr OUString sAPI_file_format
= u
"FileFormat"_ustr
;
119 constexpr OUString sAPI_is_date
= u
"IsDate"_ustr
;
120 constexpr OUString sAPI_current_presentation
= u
"CurrentPresentation"_ustr
;
121 constexpr OUString sAPI_is_hidden
= u
"IsHidden"_ustr
;
122 constexpr OUString sAPI_is_fixed_language
= u
"IsFixedLanguage"_ustr
;
124 constexpr OUString sAPI_true
= u
"TRUE"_ustr
;
127 XMLTextFieldImportContext::XMLTextFieldImportContext(
128 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
130 : SvXMLImportContext( rImport
)
131 , sServiceName(std::move(aService
))
132 , rTextImportHelper(rHlp
)
133 , sServicePrefix(sAPI_textfield_prefix
)
138 void XMLTextFieldImportContext::startFastElement(
139 sal_Int32
/*nElement*/,
140 const Reference
<XFastAttributeList
> & xAttrList
)
142 // process attributes
143 for( auto &aIter
: sax_fastparser::castToFastAttributeList( xAttrList
) )
144 ProcessAttribute(aIter
.getToken(), aIter
.toView() );
147 OUString
const & XMLTextFieldImportContext::GetContent()
149 if (sContent
.isEmpty())
151 sContent
= sContentBuffer
.makeStringAndClear();
157 void XMLTextFieldImportContext::endFastElement(sal_Int32
)
162 // create field/Service
163 Reference
<XPropertySet
> xPropSet
;
164 if (CreateField(xPropSet
, sServicePrefix
+ GetServiceName()))
166 // set field properties
167 PrepareField(xPropSet
);
169 // attach field to document
170 Reference
<XTextContent
> xTextContent(xPropSet
, UNO_QUERY
);
172 // workaround for #80606#
175 rTextImportHelper
.InsertTextContent(xTextContent
);
177 catch (const lang::IllegalArgumentException
&)
185 // in case of error: write element content
186 rTextImportHelper
.InsertString(GetContent());
189 void XMLTextFieldImportContext::characters(const OUString
& rContent
)
191 sContentBuffer
.append(rContent
);
194 bool XMLTextFieldImportContext::CreateField(
195 Reference
<XPropertySet
> & xField
,
196 const OUString
& rServiceName
)
198 // instantiate new XTextField:
199 // ask import for model, model is factory, ask factory to create service
201 Reference
<XMultiServiceFactory
> xFactory(GetImport().GetModel(),UNO_QUERY
);
204 Reference
<XInterface
> xIfc
= xFactory
->createInstance(rServiceName
);
207 xField
.set(xIfc
, UNO_QUERY
);
209 return false; // can't create instance
212 return false; // can't get MultiServiceFactory
218 /// create the appropriate field context from
219 XMLTextFieldImportContext
*
220 XMLTextFieldImportContext::CreateTextFieldImportContext(
221 SvXMLImport
& rImport
,
222 XMLTextImportHelper
& rHlp
,
225 XMLTextFieldImportContext
* pContext
= nullptr;
229 case XML_ELEMENT(TEXT
, XML_SENDER_FIRSTNAME
):
230 case XML_ELEMENT(TEXT
, XML_SENDER_LASTNAME
):
231 case XML_ELEMENT(LO_EXT
, XML_SENDER_INITIALS
):
232 case XML_ELEMENT(TEXT
, XML_SENDER_INITIALS
):
233 case XML_ELEMENT(TEXT
, XML_SENDER_TITLE
):
234 case XML_ELEMENT(TEXT
, XML_SENDER_POSITION
):
235 case XML_ELEMENT(TEXT
, XML_SENDER_EMAIL
):
236 case XML_ELEMENT(TEXT
, XML_SENDER_PHONE_PRIVATE
):
238 case XML_ELEMENT(TEXT
, XML_SENDER_FAX
):
239 case XML_ELEMENT(TEXT
, XML_SENDER_COMPANY
):
240 case XML_ELEMENT(TEXT
, XML_SENDER_PHONE_WORK
):
241 case XML_ELEMENT(TEXT
, XML_SENDER_STREET
):
242 case XML_ELEMENT(TEXT
, XML_SENDER_CITY
):
243 case XML_ELEMENT(TEXT
, XML_SENDER_POSTAL_CODE
):
244 case XML_ELEMENT(TEXT
, XML_SENDER_COUNTRY
):
245 case XML_ELEMENT(TEXT
, XML_SENDER_STATE_OR_PROVINCE
):
247 new XMLSenderFieldImportContext( rImport
, rHlp
);
250 case XML_ELEMENT(TEXT
, XML_AUTHOR_NAME
):
251 case XML_ELEMENT(TEXT
, XML_AUTHOR_INITIALS
):
253 new XMLAuthorFieldImportContext( rImport
, rHlp
);
256 case XML_ELEMENT(TEXT
, XML_PLACEHOLDER
):
258 new XMLPlaceholderFieldImportContext( rImport
, rHlp
);
260 case XML_ELEMENT(TEXT
, XML_SEQUENCE
):
262 new XMLSequenceFieldImportContext( rImport
, rHlp
);
264 case XML_ELEMENT(TEXT
, XML_TEXT_INPUT
):
266 new XMLTextInputFieldImportContext( rImport
, rHlp
);
268 case XML_ELEMENT(TEXT
, XML_EXPRESSION
):
270 new XMLExpressionFieldImportContext( rImport
, rHlp
);
272 case XML_ELEMENT(TEXT
, XML_VARIABLE_SET
):
274 new XMLVariableSetFieldImportContext( rImport
, rHlp
);
276 case XML_ELEMENT(TEXT
, XML_VARIABLE_INPUT
):
278 new XMLVariableInputFieldImportContext( rImport
, rHlp
);
280 case XML_ELEMENT(TEXT
, XML_VARIABLE_GET
):
282 new XMLVariableGetFieldImportContext( rImport
, rHlp
);
284 case XML_ELEMENT(TEXT
, XML_USER_FIELD_GET
):
285 pContext
= new XMLUserFieldImportContext( rImport
, rHlp
);
287 case XML_ELEMENT(TEXT
, XML_USER_FIELD_INPUT
):
288 pContext
= new XMLUserFieldInputImportContext( rImport
, rHlp
);
290 case XML_ELEMENT(TEXT
, XML_TIME
):
291 pContext
= new XMLTimeFieldImportContext( rImport
, rHlp
);
293 case XML_ELEMENT(TEXT
, XML_PAGE_CONTINUATION_STRING
):
294 case XML_ELEMENT(TEXT
, XML_PAGE_CONTINUATION
):
295 pContext
= new XMLPageContinuationImportContext( rImport
, rHlp
);
298 case XML_ELEMENT(TEXT
, XML_PAGE_NUMBER
):
299 pContext
= new XMLPageNumberImportContext( rImport
, rHlp
);
302 case XML_ELEMENT(TEXT
, XML_DATE
):
303 pContext
= new XMLDateFieldImportContext( rImport
, rHlp
);
306 case XML_ELEMENT(TEXT
, XML_DATABASE_NAME
):
307 pContext
= new XMLDatabaseNameImportContext( rImport
, rHlp
);
309 case XML_ELEMENT(TEXT
, XML_DATABASE_NEXT
):
310 pContext
= new XMLDatabaseNextImportContext( rImport
, rHlp
);
312 case XML_ELEMENT(TEXT
, XML_DATABASE_ROW_SELECT
):
313 pContext
= new XMLDatabaseSelectImportContext( rImport
, rHlp
);
315 case XML_ELEMENT(TEXT
, XML_DATABASE_ROW_NUMBER
):
316 pContext
= new XMLDatabaseNumberImportContext( rImport
, rHlp
);
318 case XML_ELEMENT(TEXT
, XML_DATABASE_DISPLAY
):
319 pContext
= new XMLDatabaseDisplayImportContext( rImport
, rHlp
);
321 case XML_ELEMENT(TEXT
, XML_CONDITIONAL_TEXT
):
322 pContext
= new XMLConditionalTextImportContext( rImport
, rHlp
);
324 case XML_ELEMENT(TEXT
, XML_HIDDEN_TEXT
):
325 pContext
= new XMLHiddenTextImportContext( rImport
, rHlp
);
327 case XML_ELEMENT(TEXT
, XML_HIDDEN_PARAGRAPH
):
328 pContext
= new XMLHiddenParagraphImportContext( rImport
, rHlp
);
330 case XML_ELEMENT(TEXT
, XML_DESCRIPTION
):
331 case XML_ELEMENT(TEXT
, XML_TITLE
):
332 case XML_ELEMENT(TEXT
, XML_SUBJECT
):
333 case XML_ELEMENT(TEXT
, XML_KEYWORDS
):
334 pContext
= new XMLSimpleDocInfoImportContext( rImport
, rHlp
,
338 case XML_ELEMENT(TEXT
, XML_INITIAL_CREATOR
):
339 case XML_ELEMENT(TEXT
, XML_PRINTED_BY
):
340 case XML_ELEMENT(TEXT
, XML_CREATOR
):
341 pContext
= new XMLSimpleDocInfoImportContext( rImport
, rHlp
,
346 case XML_ELEMENT(TEXT
, XML_CREATION_DATE
):
347 case XML_ELEMENT(TEXT
, XML_CREATION_TIME
):
348 case XML_ELEMENT(TEXT
, XML_PRINT_DATE
):
349 case XML_ELEMENT(TEXT
, XML_PRINT_TIME
):
350 case XML_ELEMENT(TEXT
, XML_MODIFICATION_DATE
):
351 case XML_ELEMENT(TEXT
, XML_MODIFICATION_TIME
):
352 case XML_ELEMENT(TEXT
, XML_EDITING_DURATION
):
353 pContext
= new XMLDateTimeDocInfoImportContext( rImport
, rHlp
,
357 case XML_ELEMENT(TEXT
, XML_EDITING_CYCLES
):
358 pContext
= new XMLRevisionDocInfoImportContext( rImport
, rHlp
,
362 case XML_ELEMENT(TEXT
, XML_USER_DEFINED
):
363 pContext
= new XMLUserDocInfoImportContext( rImport
, rHlp
,
367 case XML_ELEMENT(TEXT
, XML_FILE_NAME
):
368 pContext
= new XMLFileNameImportContext( rImport
, rHlp
);
371 case XML_ELEMENT(TEXT
, XML_CHAPTER
):
372 pContext
= new XMLChapterImportContext( rImport
, rHlp
);
375 case XML_ELEMENT(TEXT
, XML_TEMPLATE_NAME
):
376 pContext
= new XMLTemplateNameImportContext( rImport
, rHlp
);
379 case XML_ELEMENT(TEXT
, XML_WORD_COUNT
):
380 case XML_ELEMENT(TEXT
, XML_PARAGRAPH_COUNT
):
381 case XML_ELEMENT(TEXT
, XML_TABLE_COUNT
):
382 case XML_ELEMENT(TEXT
, XML_CHARACTER_COUNT
):
383 case XML_ELEMENT(TEXT
, XML_IMAGE_COUNT
):
384 case XML_ELEMENT(TEXT
, XML_OBJECT_COUNT
):
385 case XML_ELEMENT(TEXT
, XML_PAGE_COUNT
):
386 pContext
= new XMLCountFieldImportContext( rImport
, rHlp
, nToken
);
389 case XML_ELEMENT(TEXT
, XML_PAGE_VARIABLE_GET
):
390 pContext
= new XMLPageVarGetFieldImportContext( rImport
, rHlp
);
393 case XML_ELEMENT(TEXT
, XML_PAGE_VARIABLE_SET
):
394 pContext
= new XMLPageVarSetFieldImportContext( rImport
, rHlp
);
397 case XML_ELEMENT(TEXT
, XML_EXECUTE_MACRO
):
398 pContext
= new XMLMacroFieldImportContext( rImport
, rHlp
);
401 case XML_ELEMENT(TEXT
, XML_DDE_CONNECTION
):
402 pContext
= new XMLDdeFieldImportContext( rImport
, rHlp
);
405 case XML_ELEMENT(TEXT
, XML_REFERENCE_REF
):
406 case XML_ELEMENT(TEXT
, XML_BOOKMARK_REF
):
407 case XML_ELEMENT(TEXT
, XML_NOTE_REF
):
408 case XML_ELEMENT(TEXT
, XML_SEQUENCE_REF
):
409 case XML_ELEMENT(TEXT
, XML_STYLE_REF
):
410 case XML_ELEMENT(LO_EXT
, XML_STYLE_REF
):
411 pContext
= new XMLReferenceFieldImportContext( rImport
, rHlp
, nToken
);
414 case XML_ELEMENT(TEXT
, XML_SHEET_NAME
):
415 pContext
= new XMLSheetNameImportContext( rImport
, rHlp
);
418 case XML_ELEMENT(TEXT
, XML_PAGE_NAME
):
419 case XML_ELEMENT(LO_EXT
, XML_PAGE_NAME
):
420 pContext
= new XMLPageNameFieldImportContext( rImport
, rHlp
);
423 case XML_ELEMENT(TEXT
, XML_BIBLIOGRAPHY_MARK
):
424 pContext
= new XMLBibliographyFieldImportContext( rImport
, rHlp
);
427 case XML_ELEMENT(OFFICE
, XML_ANNOTATION
):
428 case XML_ELEMENT(OFFICE
, XML_ANNOTATION_END
):
429 pContext
= new XMLAnnotationImportContext( rImport
, rHlp
, nToken
);
432 case XML_ELEMENT(TEXT
, XML_SCRIPT
):
433 pContext
= new XMLScriptImportContext( rImport
, rHlp
);
436 case XML_ELEMENT(TEXT
, XML_MEASURE
):
437 pContext
= new XMLMeasureFieldImportContext( rImport
, rHlp
);
440 case XML_ELEMENT(TEXT
, XML_TABLE_FORMULA
):
441 pContext
= new XMLTableFormulaImportContext( rImport
, rHlp
);
443 case XML_ELEMENT(TEXT
, XML_DROP_DOWN
):
444 pContext
= new XMLDropDownFieldImportContext( rImport
, rHlp
);
446 case XML_ELEMENT(PRESENTATION
, XML_HEADER
):
447 pContext
= new XMLHeaderFieldImportContext( rImport
, rHlp
);
449 case XML_ELEMENT(PRESENTATION
, XML_FOOTER
):
450 pContext
= new XMLFooterFieldImportContext( rImport
, rHlp
);
452 case XML_ELEMENT(PRESENTATION
, XML_DATE_TIME
):
453 pContext
= new XMLDateTimeFieldImportContext( rImport
, rHlp
);
457 // ignore! May not even be a textfield.
458 // (Reminder: This method is called inside default:-branch)
467 void XMLTextFieldImportContext::ForceUpdate(
468 const Reference
<XPropertySet
> & rPropertySet
)
471 Reference
<XUpdatable
> xUpdate(rPropertySet
, UNO_QUERY
);
478 OSL_FAIL("Expected XUpdatable support!");
483 // XMLSenderFieldImportContext
486 constexpr OUStringLiteral
gsPropertyFieldSubType(u
"UserDataType");
488 XMLSenderFieldImportContext::XMLSenderFieldImportContext(
489 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
)
490 : XMLTextFieldImportContext(rImport
, rHlp
, u
"ExtendedUser"_ustr
)
492 , sPropertyFixed(sAPI_is_fixed
)
493 , sPropertyContent(sAPI_content
)
498 void XMLSenderFieldImportContext::startFastElement(
500 const Reference
<XFastAttributeList
> & xAttrList
)
504 case XML_ELEMENT(TEXT
, XML_SENDER_FIRSTNAME
):
505 nSubType
= UserDataPart::FIRSTNAME
;
507 case XML_ELEMENT(TEXT
, XML_SENDER_LASTNAME
):
508 nSubType
= UserDataPart::NAME
;
510 case XML_ELEMENT(LO_EXT
, XML_SENDER_INITIALS
):
511 case XML_ELEMENT(TEXT
, XML_SENDER_INITIALS
):
512 nSubType
= UserDataPart::SHORTCUT
;
514 case XML_ELEMENT(TEXT
, XML_SENDER_TITLE
):
515 nSubType
= UserDataPart::TITLE
;
517 case XML_ELEMENT(TEXT
, XML_SENDER_POSITION
):
518 nSubType
= UserDataPart::POSITION
;
520 case XML_ELEMENT(TEXT
, XML_SENDER_EMAIL
):
521 nSubType
= UserDataPart::EMAIL
;
523 case XML_ELEMENT(TEXT
, XML_SENDER_PHONE_PRIVATE
):
524 nSubType
= UserDataPart::PHONE_PRIVATE
;
526 case XML_ELEMENT(TEXT
, XML_SENDER_FAX
):
527 nSubType
= UserDataPart::FAX
;
529 case XML_ELEMENT(TEXT
, XML_SENDER_COMPANY
):
530 nSubType
= UserDataPart::COMPANY
;
532 case XML_ELEMENT(TEXT
, XML_SENDER_PHONE_WORK
):
533 nSubType
= UserDataPart::PHONE_COMPANY
;
535 case XML_ELEMENT(TEXT
, XML_SENDER_STREET
):
536 nSubType
= UserDataPart::STREET
;
538 case XML_ELEMENT(TEXT
, XML_SENDER_CITY
):
539 nSubType
= UserDataPart::CITY
;
541 case XML_ELEMENT(TEXT
, XML_SENDER_POSTAL_CODE
):
542 nSubType
= UserDataPart::ZIP
;
544 case XML_ELEMENT(TEXT
, XML_SENDER_COUNTRY
):
545 nSubType
= UserDataPart::COUNTRY
;
547 case XML_ELEMENT(TEXT
, XML_SENDER_STATE_OR_PROVINCE
):
548 nSubType
= UserDataPart::STATE
;
552 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement
);
556 // process Attributes
557 XMLTextFieldImportContext::startFastElement(nElement
, xAttrList
);
560 void XMLSenderFieldImportContext::ProcessAttribute(
561 sal_Int32 nAttrToken
,
562 std::string_view sAttrValue
)
564 if (XML_ELEMENT(TEXT
, XML_FIXED
) == nAttrToken
) {
568 bool const bRet
= ::sax::Converter::convertBool(bVal
, sAttrValue
);
570 // set bFixed if successful
576 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
579 void XMLSenderFieldImportContext::PrepareField(
580 const Reference
<XPropertySet
> & rPropSet
)
583 rPropSet
->setPropertyValue(gsPropertyFieldSubType
, Any(nSubType
));
586 rPropSet
->setPropertyValue(sPropertyFixed
, Any(bFixed
));
588 // set content if fixed
592 // in organizer or styles-only mode: force update
593 if (GetImport().GetTextImport()->IsOrganizerMode() ||
594 GetImport().GetTextImport()->IsStylesOnlyMode() )
596 ForceUpdate(rPropSet
);
600 rPropSet
->setPropertyValue(sPropertyContent
, Any(GetContent()));
605 // XMLAuthorFieldImportContext
607 constexpr OUStringLiteral
gsPropertyAuthorFullName(u
"FullName");
609 XMLAuthorFieldImportContext::XMLAuthorFieldImportContext(
610 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
)
611 : XMLSenderFieldImportContext(rImport
, rHlp
)
612 , bAuthorFullName(true)
613 , sPropertyFixed(sAPI_is_fixed
)
614 , sPropertyContent(sAPI_content
)
616 // overwrite service name from XMLSenderFieldImportContext
617 SetServiceName(sAPI_author
);
620 void XMLAuthorFieldImportContext::startFastElement(
622 const Reference
<XFastAttributeList
> & xAttrList
)
624 bAuthorFullName
= ( XML_ELEMENT(TEXT
, XML_AUTHOR_INITIALS
) != nElement
);
627 // process Attributes
628 XMLTextFieldImportContext::startFastElement(nElement
, xAttrList
);
631 void XMLAuthorFieldImportContext::ProcessAttribute(sal_Int32 nAttrToken
, std::string_view sAttrValue
)
633 if(nAttrToken
== XML_ELEMENT(TEXT
, XML_FIXED
))
636 if (::sax::Converter::convertBool(bTmp
, sAttrValue
))
640 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
643 void XMLAuthorFieldImportContext::PrepareField(
644 const Reference
<XPropertySet
> & rPropSet
)
648 rPropSet
->setPropertyValue(gsPropertyAuthorFullName
, Any(bAuthorFullName
));
650 rPropSet
->setPropertyValue(sPropertyFixed
, Any(bFixed
));
652 // set content if fixed
656 // organizer or styles-only mode: force update
657 if (GetImport().GetTextImport()->IsOrganizerMode() ||
658 GetImport().GetTextImport()->IsStylesOnlyMode() )
660 ForceUpdate(rPropSet
);
664 aAny
<<= GetContent();
665 rPropSet
->setPropertyValue(sPropertyContent
, aAny
);
670 // page continuation string
673 SvXMLEnumMapEntry
<PageNumberType
> const lcl_aSelectPageAttrMap
[] =
675 { XML_PREVIOUS
, PageNumberType_PREV
},
676 { XML_CURRENT
, PageNumberType_CURRENT
},
677 { XML_NEXT
, PageNumberType_NEXT
},
678 { XML_TOKEN_INVALID
, PageNumberType(0) },
681 constexpr OUStringLiteral
gsPropertyUserText(u
"UserText");
683 XMLPageContinuationImportContext::XMLPageContinuationImportContext(
684 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
)
685 : XMLTextFieldImportContext(rImport
, rHlp
, sAPI_page_number
)
686 , sPropertySubType(sAPI_sub_type
)
687 , sPropertyNumberingType(sAPI_numbering_type
)
688 , eSelectPage(PageNumberType_CURRENT
)
694 void XMLPageContinuationImportContext::ProcessAttribute(
695 sal_Int32 nAttrToken
, std::string_view sAttrValue
)
699 case XML_ELEMENT(TEXT
, XML_SELECT_PAGE
):
702 if (SvXMLUnitConverter::convertEnum(nTmp
, sAttrValue
,
703 lcl_aSelectPageAttrMap
)
704 && (PageNumberType_CURRENT
!= nTmp
) )
710 case XML_ELEMENT(TEXT
, XML_STRING_VALUE
):
711 case XML_ELEMENT(OFFICE
, XML_STRING_VALUE
):
712 sString
= OUString::fromUtf8(sAttrValue
);
716 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
720 void XMLPageContinuationImportContext::PrepareField(
721 const Reference
<XPropertySet
> & xPropertySet
)
725 xPropertySet
->setPropertyValue(sPropertySubType
, Any(eSelectPage
));
727 aAny
<<= (sStringOK
? sString
: GetContent());
728 xPropertySet
->setPropertyValue(gsPropertyUserText
, aAny
);
730 aAny
<<= style::NumberingType::CHAR_SPECIAL
;
731 xPropertySet
->setPropertyValue(sPropertyNumberingType
, aAny
);
738 XMLPageNumberImportContext::XMLPageNumberImportContext(
739 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
)
740 : XMLTextFieldImportContext(rImport
, rHlp
, sAPI_page_number
)
741 , sPropertySubType(sAPI_sub_type
)
742 , sPropertyNumberingType(sAPI_numbering_type
)
743 , sPropertyOffset(sAPI_offset
)
744 , sNumberSync(GetXMLToken(XML_FALSE
))
746 , eSelectPage(PageNumberType_CURRENT
)
747 , sNumberFormatOK(false)
752 void XMLPageNumberImportContext::ProcessAttribute(
753 sal_Int32 nAttrToken
,
754 std::string_view sAttrValue
)
758 case XML_ELEMENT(STYLE
, XML_NUM_FORMAT
):
759 sNumberFormat
= OUString::fromUtf8(sAttrValue
);
760 sNumberFormatOK
= true;
762 case XML_ELEMENT(STYLE
, XML_NUM_LETTER_SYNC
):
763 sNumberSync
= OUString::fromUtf8(sAttrValue
);
765 case XML_ELEMENT(TEXT
, XML_SELECT_PAGE
):
766 SvXMLUnitConverter::convertEnum(eSelectPage
, sAttrValue
,
767 lcl_aSelectPageAttrMap
);
769 case XML_ELEMENT(TEXT
, XML_PAGE_ADJUST
):
772 if (::sax::Converter::convertNumber(nTmp
, sAttrValue
))
774 nPageAdjust
= static_cast<sal_Int16
>(nTmp
);
779 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
783 void XMLPageNumberImportContext::PrepareField(
784 const Reference
<XPropertySet
> & xPropertySet
)
786 // all properties are optional
787 Reference
<XPropertySetInfo
> xPropertySetInfo(
788 xPropertySet
->getPropertySetInfo());
790 if (xPropertySetInfo
->hasPropertyByName(sPropertyNumberingType
))
793 if( sNumberFormatOK
)
795 nNumType
= style::NumberingType::ARABIC
;
796 GetImport().GetMM100UnitConverter().convertNumFormat( nNumType
,
801 nNumType
= style::NumberingType::PAGE_DESCRIPTOR
;
803 xPropertySet
->setPropertyValue(sPropertyNumberingType
, Any(nNumType
));
806 if (xPropertySetInfo
->hasPropertyByName(sPropertyOffset
))
811 case PageNumberType_PREV
:
814 case PageNumberType_CURRENT
:
816 case PageNumberType_NEXT
:
820 SAL_WARN("xmloff.text", "unknown page number type");
822 xPropertySet
->setPropertyValue(sPropertyOffset
, Any(nPageAdjust
));
825 if (xPropertySetInfo
->hasPropertyByName(sPropertySubType
))
827 xPropertySet
->setPropertyValue(sPropertySubType
, Any(eSelectPage
));
835 constexpr OUStringLiteral
gsPropertyPlaceholderType(u
"PlaceHolderType");
836 constexpr OUStringLiteral
gsPropertyPlaceholder(u
"PlaceHolder");
838 XMLPlaceholderFieldImportContext::XMLPlaceholderFieldImportContext(
839 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
)
840 : XMLTextFieldImportContext(rImport
, rHlp
, u
"JumpEdit"_ustr
)
841 , sPropertyHint(sAPI_hint
)
842 , nPlaceholderType(PlaceholderType::TEXT
)
846 /// process attribute values
847 void XMLPlaceholderFieldImportContext::ProcessAttribute(
848 sal_Int32 nAttrToken
, std::string_view sAttrValue
)
850 switch (nAttrToken
) {
851 case XML_ELEMENT(TEXT
, XML_DESCRIPTION
):
852 sDescription
= OUString::fromUtf8(sAttrValue
);
855 case XML_ELEMENT(TEXT
, XML_PLACEHOLDER_TYPE
):
857 if (IsXMLToken(sAttrValue
, XML_TABLE
))
859 nPlaceholderType
= PlaceholderType::TABLE
;
861 else if (IsXMLToken(sAttrValue
, XML_TEXT
))
863 nPlaceholderType
= PlaceholderType::TEXT
;
865 else if (IsXMLToken(sAttrValue
, XML_TEXT_BOX
))
867 nPlaceholderType
= PlaceholderType::TEXTFRAME
;
869 else if (IsXMLToken(sAttrValue
, XML_IMAGE
))
871 nPlaceholderType
= PlaceholderType::GRAPHIC
;
873 else if (IsXMLToken(sAttrValue
, XML_OBJECT
))
875 nPlaceholderType
= PlaceholderType::OBJECT
;
885 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
889 void XMLPlaceholderFieldImportContext::PrepareField(
890 const Reference
<XPropertySet
> & xPropertySet
) {
893 xPropertySet
->setPropertyValue(sPropertyHint
, Any(sDescription
));
895 // remove <...> around content (if present)
896 OUString aContent
= GetContent();
897 sal_Int32 nStart
= 0;
898 sal_Int32 nLength
= aContent
.getLength();
899 if (aContent
.startsWith("<"))
904 if (aContent
.endsWith(">"))
908 aAny
<<= aContent
.copy(nStart
, nLength
);
909 xPropertySet
->setPropertyValue(gsPropertyPlaceholder
, aAny
);
911 xPropertySet
->setPropertyValue(gsPropertyPlaceholderType
, Any(nPlaceholderType
));
917 constexpr OUString
gsPropertyAdjust(u
"Adjust"_ustr
);
919 XMLTimeFieldImportContext::XMLTimeFieldImportContext(
920 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
)
921 : XMLTextFieldImportContext(rImport
, rHlp
, sAPI_date_time
)
922 , sPropertyNumberFormat(sAPI_number_format
)
923 , sPropertyFixed(sAPI_is_fixed
)
924 , sPropertyDateTimeValue(sAPI_date_time_value
)
925 , sPropertyDateTime(sAPI_date_time
)
926 , sPropertyIsDate(sAPI_is_date
)
927 , sPropertyIsFixedLanguage(sAPI_is_fixed_language
)
934 , bIsDefaultLanguage( true )
936 bValid
= true; // always valid!
939 void XMLTimeFieldImportContext::ProcessAttribute(
940 sal_Int32 nAttrToken
, std::string_view sAttrValue
)
944 case XML_ELEMENT(TEXT
, XML_TIME_VALUE
):
945 case XML_ELEMENT(OFFICE
, XML_TIME_VALUE
):
947 if (::sax::Converter::parseTimeOrDateTime(aDateTimeValue
, sAttrValue
))
953 case XML_ELEMENT(TEXT
, XML_FIXED
):
956 if (::sax::Converter::convertBool(bTmp
, sAttrValue
))
962 case XML_ELEMENT(STYLE
, XML_DATA_STYLE_NAME
):
964 sal_Int32 nKey
= GetImportHelper().GetDataStyleKey(
965 OUString::fromUtf8(sAttrValue
), &bIsDefaultLanguage
);
973 case XML_ELEMENT(TEXT
, XML_TIME_ADJUST
):
977 if (::sax::Converter::convertDuration(fTmp
, sAttrValue
))
979 // convert to minutes
980 nAdjust
= static_cast<sal_Int32
>(::rtl::math::approxFloor(fTmp
* 60 * 24));
985 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
989 void XMLTimeFieldImportContext::PrepareField(
990 const Reference
<XPropertySet
> & rPropertySet
)
992 // all properties are optional (except IsDate)
993 Reference
<XPropertySetInfo
> xPropertySetInfo(
994 rPropertySet
->getPropertySetInfo());
996 if (xPropertySetInfo
->hasPropertyByName(sPropertyFixed
))
998 rPropertySet
->setPropertyValue(sPropertyFixed
, Any(bFixed
));
1001 rPropertySet
->setPropertyValue(sPropertyIsDate
, Any(bIsDate
));
1003 if (xPropertySetInfo
->hasPropertyByName(gsPropertyAdjust
))
1005 rPropertySet
->setPropertyValue(gsPropertyAdjust
, Any(nAdjust
));
1011 // organizer or styles-only mode: force update
1012 if (GetImport().GetTextImport()->IsOrganizerMode() ||
1013 GetImport().GetTextImport()->IsStylesOnlyMode() )
1015 ForceUpdate(rPropertySet
);
1019 // normal mode: set value (if present)
1022 if (xPropertySetInfo
->hasPropertyByName(sPropertyDateTimeValue
))
1024 rPropertySet
->setPropertyValue(sPropertyDateTimeValue
, Any(aDateTimeValue
));
1026 else if (xPropertySetInfo
->hasPropertyByName(sPropertyDateTime
))
1028 rPropertySet
->setPropertyValue(sPropertyDateTime
, Any(aDateTimeValue
));
1035 xPropertySetInfo
->hasPropertyByName(sPropertyNumberFormat
))
1037 rPropertySet
->setPropertyValue(sPropertyNumberFormat
, Any(nFormatKey
));
1039 if( xPropertySetInfo
->hasPropertyByName( sPropertyIsFixedLanguage
) )
1041 bool bIsFixedLanguage
= ! bIsDefaultLanguage
;
1042 rPropertySet
->setPropertyValue( sPropertyIsFixedLanguage
, Any(bIsFixedLanguage
) );
1051 XMLDateFieldImportContext::XMLDateFieldImportContext(
1052 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
) :
1053 XMLTimeFieldImportContext(rImport
, rHlp
)
1055 bIsDate
= true; // always a date!
1058 void XMLDateFieldImportContext::ProcessAttribute(
1059 sal_Int32 nAttrToken
,
1060 std::string_view sAttrValue
)
1064 case XML_ELEMENT(TEXT
, XML_DATE_VALUE
):
1065 case XML_ELEMENT(OFFICE
, XML_DATE_VALUE
):
1067 if (::sax::Converter::parseDateTime(aDateTimeValue
, sAttrValue
))
1073 case XML_ELEMENT(TEXT
, XML_DATE_ADJUST
):
1074 // delegate to superclass, pretending it was a time-adjust attr.
1075 XMLTimeFieldImportContext::ProcessAttribute(
1076 XML_ELEMENT(TEXT
, XML_TIME_ADJUST
),
1079 case XML_ELEMENT(TEXT
, XML_TIME_VALUE
):
1080 case XML_ELEMENT(OFFICE
, XML_TIME_VALUE
):
1081 case XML_ELEMENT(TEXT
, XML_TIME_ADJUST
):
1082 ; // ignore time-adjust and time-value attributes
1085 // all others: delegate to super-class
1086 return XMLTimeFieldImportContext::ProcessAttribute(nAttrToken
,
1093 // database field superclass
1096 constexpr OUStringLiteral
gsPropertyDataBaseName(u
"DataBaseName");
1097 constexpr OUStringLiteral
gsPropertyDataBaseURL(u
"DataBaseURL");
1098 constexpr OUStringLiteral
gsPropertyTableName(u
"DataTableName");
1099 constexpr OUStringLiteral
gsPropertyDataCommandType(u
"DataCommandType");
1100 constexpr OUStringLiteral
gsPropertyIsVisible(u
"IsVisible");
1102 XMLDatabaseFieldImportContext::XMLDatabaseFieldImportContext(
1103 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
1104 const OUString
& pServiceName
, bool bUseDisplay
)
1105 : XMLTextFieldImportContext(rImport
, rHlp
, pServiceName
)
1106 , m_nCommandType( sdb::CommandType::TABLE
)
1107 , m_bCommandTypeOK(false)
1108 , m_bDisplay( true )
1109 , m_bDisplayOK( false )
1110 , m_bUseDisplay( bUseDisplay
)
1111 , m_bDatabaseOK(false)
1112 , m_bDatabaseNameOK(false)
1113 , m_bDatabaseURLOK(false)
1118 void XMLDatabaseFieldImportContext::ProcessAttribute(
1119 sal_Int32 nAttrToken
, std::string_view sAttrValue
)
1123 case XML_ELEMENT(TEXT
, XML_DATABASE_NAME
):
1124 m_sDatabaseName
= OUString::fromUtf8(sAttrValue
);
1125 m_bDatabaseOK
= true;
1126 m_bDatabaseNameOK
= true;
1128 case XML_ELEMENT(TEXT
, XML_TABLE_NAME
):
1129 m_sTableName
= OUString::fromUtf8(sAttrValue
);
1132 case XML_ELEMENT(TEXT
, XML_TABLE_TYPE
):
1133 if( IsXMLToken( sAttrValue
, XML_TABLE
) )
1135 m_nCommandType
= sdb::CommandType::TABLE
;
1136 m_bCommandTypeOK
= true;
1138 else if( IsXMLToken( sAttrValue
, XML_QUERY
) )
1140 m_nCommandType
= sdb::CommandType::QUERY
;
1141 m_bCommandTypeOK
= true;
1143 else if( IsXMLToken( sAttrValue
, XML_COMMAND
) )
1145 m_nCommandType
= sdb::CommandType::COMMAND
;
1146 m_bCommandTypeOK
= true;
1149 case XML_ELEMENT(TEXT
, XML_DISPLAY
):
1150 if( IsXMLToken( sAttrValue
, XML_NONE
) )
1153 m_bDisplayOK
= true;
1155 else if( IsXMLToken( sAttrValue
, XML_VALUE
) )
1158 m_bDisplayOK
= true;
1162 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
1166 css::uno::Reference
< css::xml::sax::XFastContextHandler
> XMLDatabaseFieldImportContext::createFastChildContext(
1168 const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
)
1170 if (nElement
== XML_ELEMENT(FORM
, XML_CONNECTION_RESOURCE
) )
1172 for( auto& aIter
: sax_fastparser::castToFastAttributeList(xAttrList
) )
1174 switch (aIter
.getToken())
1176 case XML_ELEMENT(XLINK
, XML_HREF
):
1178 m_sDatabaseURL
= aIter
.toString();
1179 m_bDatabaseOK
= true;
1180 m_bDatabaseURLOK
= true;
1187 // we call ProcessAttribute in order to set bValid appropriately
1188 ProcessAttribute( XML_TOKEN_INVALID
, "" );
1191 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement
);
1197 void XMLDatabaseFieldImportContext::PrepareField(
1198 const Reference
<XPropertySet
> & xPropertySet
)
1200 xPropertySet
->setPropertyValue(gsPropertyTableName
, Any(m_sTableName
));
1202 if( m_bDatabaseNameOK
)
1204 xPropertySet
->setPropertyValue(gsPropertyDataBaseName
, Any(m_sDatabaseName
));
1206 else if( m_bDatabaseURLOK
)
1208 xPropertySet
->setPropertyValue(gsPropertyDataBaseURL
, Any(m_sDatabaseURL
));
1211 // #99980# load/save command type for all fields; also load
1212 // old documents without command type
1213 if( m_bCommandTypeOK
)
1215 xPropertySet
->setPropertyValue( gsPropertyDataCommandType
, Any(m_nCommandType
) );
1218 if( m_bUseDisplay
&& m_bDisplayOK
)
1220 xPropertySet
->setPropertyValue( gsPropertyIsVisible
, Any(m_bDisplay
) );
1225 // database name field
1228 XMLDatabaseNameImportContext::XMLDatabaseNameImportContext(
1229 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
) :
1230 XMLDatabaseFieldImportContext(rImport
, rHlp
, u
"DatabaseName"_ustr
, true)
1234 void XMLDatabaseNameImportContext::ProcessAttribute(
1235 sal_Int32 nAttrToken
, std::string_view sAttrValue
)
1237 // delegate to superclass and check for success
1238 XMLDatabaseFieldImportContext::ProcessAttribute(nAttrToken
, sAttrValue
);
1239 bValid
= m_bDatabaseOK
&& m_bTableOK
;
1243 // database next field
1246 XMLDatabaseNextImportContext::XMLDatabaseNextImportContext(
1247 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
1248 const OUString
& pServiceName
) :
1249 XMLDatabaseFieldImportContext(rImport
, rHlp
, pServiceName
, false),
1250 sPropertyCondition(sAPI_condition
),
1256 XMLDatabaseNextImportContext::XMLDatabaseNextImportContext(
1257 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
)
1258 : XMLDatabaseFieldImportContext(rImport
, rHlp
, u
"DatabaseNextSet"_ustr
, false)
1259 , sPropertyCondition(sAPI_condition
)
1261 , bConditionOK(false)
1265 void XMLDatabaseNextImportContext::ProcessAttribute(
1266 sal_Int32 nAttrToken
, std::string_view sAttrValue
)
1268 if (XML_ELEMENT(TEXT
, XML_CONDITION
) == nAttrToken
)
1271 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrValueQName(
1272 OUString::fromUtf8(sAttrValue
), &sTmp
);
1273 if( XML_NAMESPACE_OOOW
== nPrefix
)
1276 bConditionOK
= true;
1279 sCondition
= OUString::fromUtf8(sAttrValue
);
1283 XMLDatabaseFieldImportContext::ProcessAttribute(nAttrToken
,
1287 bValid
= m_bDatabaseOK
&& m_bTableOK
;
1290 void XMLDatabaseNextImportContext::PrepareField(
1291 const Reference
<XPropertySet
> & xPropertySet
)
1295 aAny
<<= bConditionOK
? sCondition
: sTrue
;
1296 xPropertySet
->setPropertyValue(sPropertyCondition
, aAny
);
1298 XMLDatabaseFieldImportContext::PrepareField(xPropertySet
);
1302 // database select field
1305 XMLDatabaseSelectImportContext::XMLDatabaseSelectImportContext(
1306 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
) :
1307 XMLDatabaseNextImportContext(rImport
, rHlp
, u
"DatabaseNumberOfSet"_ustr
),
1308 sPropertySetNumber(sAPI_set_number
),
1314 void XMLDatabaseSelectImportContext::ProcessAttribute(
1315 sal_Int32 nAttrToken
,
1316 std::string_view sAttrValue
)
1318 if (XML_ELEMENT(TEXT
, XML_ROW_NUMBER
) == nAttrToken
)
1321 if (::sax::Converter::convertNumber( nTmp
, sAttrValue
1322 /* , nMin, nMax ??? */ ))
1330 XMLDatabaseNextImportContext::ProcessAttribute(nAttrToken
, sAttrValue
);
1333 bValid
= m_bTableOK
&& m_bDatabaseOK
&& bNumberOK
;
1336 void XMLDatabaseSelectImportContext::PrepareField(
1337 const Reference
<XPropertySet
> & xPropertySet
)
1339 xPropertySet
->setPropertyValue(sPropertySetNumber
, Any(nNumber
));
1341 XMLDatabaseNextImportContext::PrepareField(xPropertySet
);
1345 // database display row number field
1348 XMLDatabaseNumberImportContext::XMLDatabaseNumberImportContext(
1349 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
) :
1350 XMLDatabaseFieldImportContext(rImport
, rHlp
, u
"DatabaseSetNumber"_ustr
, true),
1351 sPropertyNumberingType(
1352 sAPI_numbering_type
),
1353 sPropertySetNumber(sAPI_set_number
),
1354 sNumberFormat(u
"1"_ustr
),
1355 sNumberSync(GetXMLToken(XML_FALSE
)),
1361 void XMLDatabaseNumberImportContext::ProcessAttribute(
1362 sal_Int32 nAttrToken
,
1363 std::string_view sAttrValue
)
1367 case XML_ELEMENT(STYLE
, XML_NUM_FORMAT
):
1368 sNumberFormat
= OUString::fromUtf8(sAttrValue
);
1370 case XML_ELEMENT(STYLE
, XML_NUM_LETTER_SYNC
):
1371 sNumberSync
= OUString::fromUtf8(sAttrValue
);
1373 case XML_ELEMENT(TEXT
, XML_VALUE_TYPE
):
1374 case XML_ELEMENT(OFFICE
, XML_VALUE_TYPE
):
1377 if (::sax::Converter::convertNumber( nTmp
, sAttrValue
))
1385 XMLDatabaseFieldImportContext::ProcessAttribute(nAttrToken
,
1390 bValid
= m_bTableOK
&& m_bDatabaseOK
;
1393 void XMLDatabaseNumberImportContext::PrepareField(
1394 const Reference
<XPropertySet
> & xPropertySet
)
1396 sal_Int16 nNumType
= style::NumberingType::ARABIC
;
1397 GetImport().GetMM100UnitConverter().convertNumFormat( nNumType
,
1400 xPropertySet
->setPropertyValue(sPropertyNumberingType
, Any(nNumType
));
1404 xPropertySet
->setPropertyValue(sPropertySetNumber
, Any(nValue
));
1407 XMLDatabaseFieldImportContext::PrepareField(xPropertySet
);
1411 // Simple doc info fields
1414 XMLSimpleDocInfoImportContext::XMLSimpleDocInfoImportContext(
1415 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
1416 sal_Int32 nElementToken
,
1417 bool bContent
, bool bAuthor
)
1418 : XMLTextFieldImportContext(rImport
, rHlp
, MapTokenToServiceName(nElementToken
) )
1419 , sPropertyFixed(sAPI_is_fixed
)
1420 , sPropertyContent(sAPI_content
)
1421 , sPropertyAuthor(sAPI_author
)
1422 , sPropertyCurrentPresentation(sAPI_current_presentation
)
1424 , bHasAuthor(bAuthor
)
1425 , bHasContent(bContent
)
1430 void XMLSimpleDocInfoImportContext::ProcessAttribute(
1431 sal_Int32 nAttrToken
,
1432 std::string_view sAttrValue
)
1434 if (XML_ELEMENT(TEXT
, XML_FIXED
) == nAttrToken
)
1437 if (::sax::Converter::convertBool(bTmp
, sAttrValue
))
1443 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
1446 void XMLSimpleDocInfoImportContext::PrepareField(
1447 const Reference
<XPropertySet
> & rPropertySet
)
1449 // title field in Calc has no Fixed property
1450 Reference
<XPropertySetInfo
> xPropertySetInfo(rPropertySet
->getPropertySetInfo());
1451 if (!xPropertySetInfo
->hasPropertyByName(sPropertyFixed
))
1455 rPropertySet
->setPropertyValue(sPropertyFixed
, Any(bFixed
));
1457 // set Content and CurrentPresentation (if fixed)
1461 // in organizer-mode or styles-only-mode, only force update
1462 if (GetImport().GetTextImport()->IsOrganizerMode() ||
1463 GetImport().GetTextImport()->IsStylesOnlyMode() )
1465 ForceUpdate(rPropertySet
);
1469 // set content (author, if that's the name) and current
1471 aAny
<<= GetContent();
1473 if (bFixed
&& bHasAuthor
)
1475 rPropertySet
->setPropertyValue(sPropertyAuthor
, aAny
);
1478 if (bFixed
&& bHasContent
)
1480 rPropertySet
->setPropertyValue(sPropertyContent
, aAny
);
1483 rPropertySet
->setPropertyValue(sPropertyCurrentPresentation
, aAny
);
1487 OUString
XMLSimpleDocInfoImportContext::MapTokenToServiceName(
1488 sal_Int32 nElementToken
)
1490 OUString pServiceName
;
1492 switch(nElementToken
)
1494 case XML_ELEMENT(TEXT
, XML_INITIAL_CREATOR
):
1495 pServiceName
= "DocInfo.CreateAuthor";
1497 case XML_ELEMENT(TEXT
, XML_CREATION_DATE
):
1498 pServiceName
= sAPI_docinfo_create_date_time
;
1500 case XML_ELEMENT(TEXT
, XML_CREATION_TIME
):
1501 pServiceName
= sAPI_docinfo_create_date_time
;
1503 case XML_ELEMENT(TEXT
, XML_DESCRIPTION
):
1504 pServiceName
= "DocInfo.Description";
1506 case XML_ELEMENT(TEXT
, XML_EDITING_DURATION
):
1507 pServiceName
= "DocInfo.EditTime";
1509 case XML_ELEMENT(TEXT
, XML_USER_DEFINED
):
1510 pServiceName
= sAPI_docinfo_custom
;
1512 case XML_ELEMENT(TEXT
, XML_PRINTED_BY
):
1513 pServiceName
= "DocInfo.PrintAuthor";
1515 case XML_ELEMENT(TEXT
, XML_PRINT_DATE
):
1516 pServiceName
= sAPI_docinfo_print_date_time
;
1518 case XML_ELEMENT(TEXT
, XML_PRINT_TIME
):
1519 pServiceName
= sAPI_docinfo_print_date_time
;
1521 case XML_ELEMENT(TEXT
, XML_KEYWORDS
):
1522 pServiceName
= "DocInfo.KeyWords";
1524 case XML_ELEMENT(TEXT
, XML_SUBJECT
):
1525 pServiceName
= "DocInfo.Subject";
1527 case XML_ELEMENT(TEXT
, XML_EDITING_CYCLES
):
1528 pServiceName
= "DocInfo.Revision";
1530 case XML_ELEMENT(TEXT
, XML_CREATOR
):
1531 pServiceName
= "DocInfo.ChangeAuthor";
1533 case XML_ELEMENT(TEXT
, XML_MODIFICATION_DATE
):
1534 pServiceName
= sAPI_docinfo_change_date_time
;
1536 case XML_ELEMENT(TEXT
, XML_MODIFICATION_TIME
):
1537 pServiceName
= sAPI_docinfo_change_date_time
;
1539 case XML_ELEMENT(TEXT
, XML_TITLE
):
1540 pServiceName
= "DocInfo.Title";
1543 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElementToken
);
1547 return pServiceName
;
1553 constexpr OUStringLiteral
sPropertyRevision(u
"Revision");
1555 XMLRevisionDocInfoImportContext::XMLRevisionDocInfoImportContext(
1556 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
, sal_Int32 nElement
) :
1557 XMLSimpleDocInfoImportContext(rImport
, rHlp
, nElement
, false, false)
1562 void XMLRevisionDocInfoImportContext::PrepareField(
1563 const Reference
<XPropertySet
> & rPropertySet
)
1565 XMLSimpleDocInfoImportContext::PrepareField(rPropertySet
);
1567 // set revision number
1568 // if fixed, if not in organizer-mode, if not in styles-only-mode
1572 if ( GetImport().GetTextImport()->IsOrganizerMode() ||
1573 GetImport().GetTextImport()->IsStylesOnlyMode() )
1575 ForceUpdate(rPropertySet
);
1580 if (::sax::Converter::convertNumber(nTmp
, GetContent()))
1582 rPropertySet
->setPropertyValue(sPropertyRevision
, Any(nTmp
));
1588 // DocInfo fields with date/time attributes
1591 XMLDateTimeDocInfoImportContext::XMLDateTimeDocInfoImportContext(
1592 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
, sal_Int32 nElement
)
1593 : XMLSimpleDocInfoImportContext(rImport
, rHlp
, nElement
, false, false)
1594 , sPropertyNumberFormat(sAPI_number_format
)
1595 , sPropertyIsDate(sAPI_is_date
)
1596 , sPropertyIsFixedLanguage(sAPI_is_fixed_language
)
1600 , bHasDateTime(false)
1601 , bIsDefaultLanguage(true)
1603 // we allow processing of EDIT_DURATION here, because import of actual
1604 // is not supported anyway. If it was, we'd need an extra import class
1605 // because times and time durations are presented differently!
1610 case XML_ELEMENT(TEXT
, XML_CREATION_DATE
):
1611 case XML_ELEMENT(TEXT
, XML_PRINT_DATE
):
1612 case XML_ELEMENT(TEXT
, XML_MODIFICATION_DATE
):
1614 bHasDateTime
= true;
1616 case XML_ELEMENT(TEXT
, XML_CREATION_TIME
):
1617 case XML_ELEMENT(TEXT
, XML_PRINT_TIME
):
1618 case XML_ELEMENT(TEXT
, XML_MODIFICATION_TIME
):
1620 bHasDateTime
= true;
1622 case XML_ELEMENT(TEXT
, XML_EDITING_DURATION
):
1624 bHasDateTime
= false;
1627 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement
);
1628 OSL_FAIL("XMLDateTimeDocInfoImportContext needs date/time doc. fields");
1634 void XMLDateTimeDocInfoImportContext::ProcessAttribute(
1635 sal_Int32 nAttrToken
,
1636 std::string_view sAttrValue
)
1640 case XML_ELEMENT(STYLE
, XML_DATA_STYLE_NAME
):
1642 sal_Int32 nKey
= GetImportHelper().GetDataStyleKey(
1643 OUString::fromUtf8(sAttrValue
), &bIsDefaultLanguage
);
1651 case XML_ELEMENT(TEXT
, XML_FIXED
):
1652 XMLSimpleDocInfoImportContext::ProcessAttribute(nAttrToken
,
1656 // ignore -> we can't set date/time value anyway!
1661 void XMLDateTimeDocInfoImportContext::PrepareField(
1662 const Reference
<XPropertySet
> & xPropertySet
)
1664 // process fixed and presentation
1665 XMLSimpleDocInfoImportContext::PrepareField(xPropertySet
);
1669 xPropertySet
->setPropertyValue(sPropertyIsDate
, Any(bIsDate
));
1674 xPropertySet
->setPropertyValue(sPropertyNumberFormat
, Any(nFormat
));
1676 if( xPropertySet
->getPropertySetInfo()->
1677 hasPropertyByName( sPropertyIsFixedLanguage
) )
1679 bool bIsFixedLanguage
= ! bIsDefaultLanguage
;
1680 xPropertySet
->setPropertyValue( sPropertyIsFixedLanguage
, Any(bIsFixedLanguage
) );
1684 // can't set date/time/duration value! Sorry.
1688 // user defined docinfo fields
1691 XMLUserDocInfoImportContext::XMLUserDocInfoImportContext(
1692 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
1693 sal_Int32 nElement
) :
1694 XMLSimpleDocInfoImportContext(rImport
, rHlp
, nElement
, false, false)
1695 , sPropertyName(sAPI_name
)
1696 , sPropertyNumberFormat(sAPI_number_format
)
1697 , sPropertyIsFixedLanguage(sAPI_is_fixed_language
)
1700 , bIsDefaultLanguage( true )
1705 void XMLUserDocInfoImportContext::ProcessAttribute(
1706 sal_Int32 nAttrToken
,
1707 std::string_view sAttrValue
)
1711 case XML_ELEMENT(STYLE
, XML_DATA_STYLE_NAME
):
1713 sal_Int32 nKey
= GetImportHelper().GetDataStyleKey(
1714 OUString::fromUtf8(sAttrValue
), &bIsDefaultLanguage
);
1722 case XML_ELEMENT(TEXT
, XML_NAME
):
1726 SetServiceName(sAPI_docinfo_custom
);
1727 aName
= OUString::fromUtf8(sAttrValue
);
1734 XMLSimpleDocInfoImportContext::ProcessAttribute(nAttrToken
,
1740 void XMLUserDocInfoImportContext::PrepareField(
1741 const css::uno::Reference
<css::beans::XPropertySet
> & xPropertySet
)
1743 if ( !aName
.isEmpty() )
1745 xPropertySet
->setPropertyValue(sPropertyName
, Any(aName
));
1747 Reference
<XPropertySetInfo
> xPropertySetInfo(
1748 xPropertySet
->getPropertySetInfo());
1750 xPropertySetInfo
->hasPropertyByName(sPropertyNumberFormat
))
1752 xPropertySet
->setPropertyValue(sPropertyNumberFormat
, Any(nFormat
));
1754 if( xPropertySetInfo
->hasPropertyByName( sPropertyIsFixedLanguage
) )
1756 bool bIsFixedLanguage
= ! bIsDefaultLanguage
;
1757 xPropertySet
->setPropertyValue( sPropertyIsFixedLanguage
, Any(bIsFixedLanguage
) );
1761 // call superclass to handle "fixed"
1762 XMLSimpleDocInfoImportContext::PrepareField(xPropertySet
);
1766 // import hidden paragraph fields
1769 XMLHiddenParagraphImportContext::XMLHiddenParagraphImportContext(
1770 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
) :
1771 XMLTextFieldImportContext(rImport
, rHlp
, u
"HiddenParagraph"_ustr
),
1772 sPropertyCondition(sAPI_condition
),
1773 sPropertyIsHidden(sAPI_is_hidden
),
1778 void XMLHiddenParagraphImportContext::ProcessAttribute(
1779 sal_Int32 nAttrToken
,
1780 std::string_view sAttrValue
)
1782 if ( XML_ELEMENT(TEXT
, XML_CONDITION
) == nAttrToken
)
1785 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrValueQName(
1786 OUString::fromUtf8(sAttrValue
), &sTmp
);
1787 if( XML_NAMESPACE_OOOW
== nPrefix
)
1793 sCondition
= OUString::fromUtf8(sAttrValue
);
1795 else if ( XML_ELEMENT(TEXT
, XML_IS_HIDDEN
) == nAttrToken
)
1798 if (::sax::Converter::convertBool(bTmp
, sAttrValue
))
1804 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
1807 void XMLHiddenParagraphImportContext::PrepareField(
1808 const Reference
<XPropertySet
> & xPropertySet
)
1810 xPropertySet
->setPropertyValue(sPropertyCondition
, Any(sCondition
));
1811 xPropertySet
->setPropertyValue(sPropertyIsHidden
, Any(bIsHidden
));
1815 // import conditional text (<text:conditional-text>)
1817 constexpr OUStringLiteral
gsPropertyTrueContent(u
"TrueContent");
1818 constexpr OUStringLiteral
gsPropertyFalseContent(u
"FalseContent");
1819 constexpr OUStringLiteral
gsPropertyIsConditionTrue(u
"IsConditionTrue");
1821 XMLConditionalTextImportContext::XMLConditionalTextImportContext(
1822 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
) :
1823 XMLTextFieldImportContext(rImport
, rHlp
, u
"ConditionalText"_ustr
),
1824 sPropertyCondition(sAPI_condition
),
1825 sPropertyCurrentPresentation(sAPI_current_presentation
),
1826 bConditionOK(false),
1829 bCurrentValue(false)
1833 void XMLConditionalTextImportContext::ProcessAttribute(
1834 sal_Int32 nAttrToken
,
1835 std::string_view sAttrValue
)
1839 case XML_ELEMENT(TEXT
, XML_CONDITION
):
1842 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().
1843 GetKeyByAttrValueQName(OUString::fromUtf8(sAttrValue
), &sTmp
);
1844 if( XML_NAMESPACE_OOOW
== nPrefix
)
1847 bConditionOK
= true;
1850 sCondition
= OUString::fromUtf8(sAttrValue
);
1853 case XML_ELEMENT(TEXT
, XML_STRING_VALUE_IF_FALSE
):
1854 sFalseContent
= OUString::fromUtf8(sAttrValue
);
1857 case XML_ELEMENT(TEXT
, XML_STRING_VALUE_IF_TRUE
):
1858 sTrueContent
= OUString::fromUtf8(sAttrValue
);
1861 case XML_ELEMENT(TEXT
, XML_CURRENT_VALUE
):
1864 if (::sax::Converter::convertBool(bTmp
, sAttrValue
))
1866 bCurrentValue
= bTmp
;
1871 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
1874 bValid
= bConditionOK
&& bFalseOK
&& bTrueOK
;
1877 void XMLConditionalTextImportContext::PrepareField(
1878 const Reference
<XPropertySet
> & xPropertySet
)
1880 xPropertySet
->setPropertyValue(sPropertyCondition
, Any(sCondition
));
1881 xPropertySet
->setPropertyValue(gsPropertyFalseContent
, Any(sFalseContent
));
1882 xPropertySet
->setPropertyValue(gsPropertyTrueContent
, Any(sTrueContent
));
1883 xPropertySet
->setPropertyValue(gsPropertyIsConditionTrue
, Any(bCurrentValue
));
1884 xPropertySet
->setPropertyValue(sPropertyCurrentPresentation
, Any(GetContent()));
1891 XMLHiddenTextImportContext::XMLHiddenTextImportContext(
1892 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
) :
1893 XMLTextFieldImportContext(rImport
, rHlp
, u
"HiddenText"_ustr
),
1894 sPropertyCondition(sAPI_condition
),
1895 sPropertyContent(sAPI_content
),
1896 sPropertyIsHidden(sAPI_is_hidden
),
1897 bConditionOK(false),
1903 void XMLHiddenTextImportContext::ProcessAttribute(
1904 sal_Int32 nAttrToken
,
1905 std::string_view sAttrValue
)
1909 case XML_ELEMENT(TEXT
, XML_CONDITION
):
1912 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().
1913 GetKeyByAttrValueQName(OUString::fromUtf8(sAttrValue
), &sTmp
);
1914 if( XML_NAMESPACE_OOOW
== nPrefix
)
1917 bConditionOK
= true;
1920 sCondition
= OUString::fromUtf8(sAttrValue
);
1923 case XML_ELEMENT(TEXT
, XML_STRING_VALUE
):
1924 case XML_ELEMENT(OFFICE
, XML_STRING_VALUE
):
1925 sString
= OUString::fromUtf8(sAttrValue
);
1928 case XML_ELEMENT(TEXT
, XML_IS_HIDDEN
):
1931 if (::sax::Converter::convertBool(bTmp
, sAttrValue
))
1938 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
1941 bValid
= bConditionOK
&& bStringOK
;
1944 void XMLHiddenTextImportContext::PrepareField(
1945 const Reference
<XPropertySet
> & xPropertySet
)
1947 xPropertySet
->setPropertyValue(sPropertyCondition
, Any(sCondition
));
1948 xPropertySet
->setPropertyValue(sPropertyContent
, Any(sString
));
1949 xPropertySet
->setPropertyValue(sPropertyIsHidden
, Any(bIsHidden
));
1956 const SvXMLEnumMapEntry
<sal_uInt16
> aFilenameDisplayMap
[] =
1958 { XML_PATH
, FilenameDisplayFormat::PATH
},
1959 { XML_NAME
, FilenameDisplayFormat::NAME
},
1960 { XML_NAME_AND_EXTENSION
, FilenameDisplayFormat::NAME_AND_EXT
},
1961 { XML_FULL
, FilenameDisplayFormat::FULL
},
1962 { XML_TOKEN_INVALID
, 0 }
1965 XMLFileNameImportContext::XMLFileNameImportContext(
1966 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
) :
1967 XMLTextFieldImportContext(rImport
, rHlp
, u
"FileName"_ustr
),
1968 sPropertyFixed(sAPI_is_fixed
),
1969 sPropertyFileFormat(sAPI_file_format
),
1970 sPropertyCurrentPresentation(
1971 sAPI_current_presentation
),
1972 nFormat(FilenameDisplayFormat::FULL
),
1978 void XMLFileNameImportContext::ProcessAttribute(
1979 sal_Int32 nAttrToken
,
1980 std::string_view sAttrValue
)
1984 case XML_ELEMENT(TEXT
, XML_FIXED
):
1987 if (::sax::Converter::convertBool(bTmp
, sAttrValue
))
1993 case XML_ELEMENT(TEXT
, XML_DISPLAY
):
1996 if (SvXMLUnitConverter::convertEnum(nTmp
, sAttrValue
,
1997 aFilenameDisplayMap
))
2004 // unknown attribute: ignore
2005 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
2010 void XMLFileNameImportContext::PrepareField(
2011 const Reference
<XPropertySet
> & xPropertySet
)
2013 // properties are optional
2014 Reference
<XPropertySetInfo
> xPropertySetInfo(
2015 xPropertySet
->getPropertySetInfo());
2017 if (xPropertySetInfo
->hasPropertyByName(sPropertyFixed
))
2019 xPropertySet
->setPropertyValue(sPropertyFixed
, Any(bFixed
));
2022 if (xPropertySetInfo
->hasPropertyByName(sPropertyFileFormat
))
2024 xPropertySet
->setPropertyValue(sPropertyFileFormat
, Any(nFormat
));
2027 if (xPropertySetInfo
->hasPropertyByName(sPropertyCurrentPresentation
))
2029 xPropertySet
->setPropertyValue(sPropertyCurrentPresentation
, Any(GetContent()));
2034 // template name field
2037 const SvXMLEnumMapEntry
<sal_uInt16
> aTemplateDisplayMap
[] =
2039 { XML_FULL
, TemplateDisplayFormat::FULL
},
2040 { XML_PATH
, TemplateDisplayFormat::PATH
},
2041 { XML_NAME
, TemplateDisplayFormat::NAME
},
2042 { XML_NAME_AND_EXTENSION
, TemplateDisplayFormat::NAME_AND_EXT
},
2043 { XML_AREA
, TemplateDisplayFormat::AREA
},
2044 { XML_TITLE
, TemplateDisplayFormat::TITLE
},
2045 { XML_TOKEN_INVALID
, 0 }
2049 XMLTemplateNameImportContext::XMLTemplateNameImportContext(
2050 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
) :
2051 XMLTextFieldImportContext(rImport
, rHlp
, u
"TemplateName"_ustr
),
2052 sPropertyFileFormat(sAPI_file_format
),
2053 nFormat(TemplateDisplayFormat::FULL
)
2058 void XMLTemplateNameImportContext::ProcessAttribute(
2059 sal_Int32 nAttrToken
,
2060 std::string_view sAttrValue
)
2064 case XML_ELEMENT(TEXT
, XML_DISPLAY
):
2067 if (SvXMLUnitConverter::convertEnum(nTmp
, sAttrValue
,
2068 aTemplateDisplayMap
))
2075 // unknown attribute: ignore
2076 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
2081 void XMLTemplateNameImportContext::PrepareField(
2082 const Reference
<XPropertySet
> & xPropertySet
)
2084 xPropertySet
->setPropertyValue(sPropertyFileFormat
, Any(nFormat
));
2088 // import chapter fields
2091 const SvXMLEnumMapEntry
<sal_uInt16
> aChapterDisplayMap
[] =
2093 { XML_NAME
, ChapterFormat::NAME
},
2094 { XML_NUMBER
, ChapterFormat::NUMBER
},
2095 { XML_NUMBER_AND_NAME
, ChapterFormat::NAME_NUMBER
},
2096 { XML_PLAIN_NUMBER_AND_NAME
, ChapterFormat::NO_PREFIX_SUFFIX
},
2097 { XML_PLAIN_NUMBER
, ChapterFormat::DIGIT
},
2098 { XML_TOKEN_INVALID
, 0 }
2101 constexpr OUStringLiteral
gsPropertyChapterFormat(u
"ChapterFormat");
2102 constexpr OUStringLiteral
gsPropertyLevel(u
"Level");
2104 XMLChapterImportContext::XMLChapterImportContext(
2105 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
) :
2106 XMLTextFieldImportContext(rImport
, rHlp
, u
"Chapter"_ustr
),
2107 nFormat(ChapterFormat::NAME_NUMBER
),
2113 void XMLChapterImportContext::ProcessAttribute(
2114 sal_Int32 nAttrToken
,
2115 std::string_view sAttrValue
)
2119 case XML_ELEMENT(TEXT
, XML_DISPLAY
):
2122 if (SvXMLUnitConverter::convertEnum(nTmp
, sAttrValue
,
2123 aChapterDisplayMap
))
2125 nFormat
= static_cast<sal_Int16
>(nTmp
);
2129 case XML_ELEMENT(TEXT
, XML_OUTLINE_LEVEL
):
2132 if (::sax::Converter::convertNumber(
2133 nTmp
, sAttrValue
, 1,
2134 GetImport().GetTextImport()->GetChapterNumbering()->getCount()
2137 // API numbers 0..9, we number 1..10
2138 nLevel
= static_cast<sal_Int8
>(nTmp
);
2144 // unknown attribute: ignore
2145 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
2150 void XMLChapterImportContext::PrepareField(
2151 const Reference
<XPropertySet
> & xPropertySet
)
2153 xPropertySet
->setPropertyValue(gsPropertyChapterFormat
, Any(nFormat
));
2154 xPropertySet
->setPropertyValue(gsPropertyLevel
, Any(nLevel
));
2161 XMLCountFieldImportContext::XMLCountFieldImportContext(
2162 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
2163 sal_Int32 nElement
) :
2164 XMLTextFieldImportContext(rImport
, rHlp
, MapTokenToServiceName(nElement
)),
2165 sPropertyNumberingType(
2166 sAPI_numbering_type
),
2167 bNumberFormatOK(false)
2172 void XMLCountFieldImportContext::ProcessAttribute(
2173 sal_Int32 nAttrToken
,
2174 std::string_view sAttrValue
)
2178 case XML_ELEMENT(STYLE
, XML_NUM_FORMAT
):
2179 sNumberFormat
= OUString::fromUtf8(sAttrValue
);
2180 bNumberFormatOK
= true;
2182 case XML_ELEMENT(STYLE
, XML_NUM_LETTER_SYNC
):
2183 sLetterSync
= OUString::fromUtf8(sAttrValue
);
2186 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
2190 void XMLCountFieldImportContext::PrepareField(
2191 const Reference
<XPropertySet
> & xPropertySet
)
2193 // properties optional
2194 // (only page count, but do for all to save common implementation)
2196 if (!xPropertySet
->getPropertySetInfo()->
2197 hasPropertyByName(sPropertyNumberingType
))
2201 if( bNumberFormatOK
)
2203 nNumType
= style::NumberingType::ARABIC
;
2204 GetImport().GetMM100UnitConverter().convertNumFormat( nNumType
,
2209 nNumType
= style::NumberingType::PAGE_DESCRIPTOR
;
2210 xPropertySet
->setPropertyValue(sPropertyNumberingType
, Any(nNumType
));
2213 OUString
XMLCountFieldImportContext::MapTokenToServiceName(
2216 OUString pServiceName
;
2220 case XML_ELEMENT(TEXT
, XML_WORD_COUNT
):
2221 pServiceName
= "WordCount";
2223 case XML_ELEMENT(TEXT
, XML_PARAGRAPH_COUNT
):
2224 pServiceName
= "ParagraphCount";
2226 case XML_ELEMENT(TEXT
, XML_TABLE_COUNT
):
2227 pServiceName
= "TableCount";
2229 case XML_ELEMENT(TEXT
, XML_CHARACTER_COUNT
):
2230 pServiceName
= "CharacterCount";
2232 case XML_ELEMENT(TEXT
, XML_IMAGE_COUNT
):
2233 pServiceName
= "GraphicObjectCount";
2235 case XML_ELEMENT(TEXT
, XML_OBJECT_COUNT
):
2236 pServiceName
= "EmbeddedObjectCount";
2238 case XML_ELEMENT(TEXT
, XML_PAGE_COUNT
):
2239 pServiceName
= "PageCount";
2242 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement
);
2246 return pServiceName
;
2250 // page variable import
2253 XMLPageVarGetFieldImportContext::XMLPageVarGetFieldImportContext(
2254 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
) :
2255 XMLTextFieldImportContext(rImport
, rHlp
, u
"ReferencePageGet"_ustr
),
2256 bNumberFormatOK(false)
2261 void XMLPageVarGetFieldImportContext::ProcessAttribute(
2262 sal_Int32 nAttrToken
,
2263 std::string_view sAttrValue
)
2267 case XML_ELEMENT(STYLE
, XML_NUM_FORMAT
):
2268 sNumberFormat
= OUString::fromUtf8(sAttrValue
);
2269 bNumberFormatOK
= true;
2271 case XML_ELEMENT(STYLE
, XML_NUM_LETTER_SYNC
):
2272 sLetterSync
= OUString::fromUtf8(sAttrValue
);
2275 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
2279 void XMLPageVarGetFieldImportContext::PrepareField(
2280 const Reference
<XPropertySet
> & xPropertySet
)
2283 if( bNumberFormatOK
)
2285 nNumType
= style::NumberingType::ARABIC
;
2286 GetImport().GetMM100UnitConverter().convertNumFormat( nNumType
,
2291 nNumType
= style::NumberingType::PAGE_DESCRIPTOR
;
2292 xPropertySet
->setPropertyValue(sAPI_numbering_type
, Any(nNumType
));
2294 // display old content (#96657#)
2295 xPropertySet
->setPropertyValue( sAPI_current_presentation
, Any(GetContent()) );
2299 // page variable set fields
2302 XMLPageVarSetFieldImportContext::XMLPageVarSetFieldImportContext(
2303 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
) :
2304 XMLTextFieldImportContext(rImport
, rHlp
, u
"ReferencePageSet"_ustr
),
2311 void XMLPageVarSetFieldImportContext::ProcessAttribute(
2312 sal_Int32 nAttrToken
,
2313 std::string_view sAttrValue
)
2317 case XML_ELEMENT(TEXT
, XML_ACTIVE
):
2320 if (::sax::Converter::convertBool(bTmp
, sAttrValue
))
2326 case XML_ELEMENT(TEXT
, XML_PAGE_ADJUST
):
2329 if (::sax::Converter::convertNumber(nTmp
, sAttrValue
))
2331 nAdjust
= static_cast<sal_Int16
>(nTmp
);
2336 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
2341 void XMLPageVarSetFieldImportContext::PrepareField(
2342 const Reference
<XPropertySet
> & xPropertySet
)
2344 xPropertySet
->setPropertyValue(u
"On"_ustr
, Any(bActive
));
2345 xPropertySet
->setPropertyValue(sAPI_offset
, Any(nAdjust
));
2352 XMLMacroFieldImportContext::XMLMacroFieldImportContext(
2353 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
) :
2354 XMLTextFieldImportContext(rImport
, rHlp
, u
"Macro"_ustr
),
2355 bDescriptionOK(false)
2359 css::uno::Reference
< css::xml::sax::XFastContextHandler
> XMLMacroFieldImportContext::createFastChildContext(
2361 const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& )
2363 if ( nElement
== XML_ELEMENT(OFFICE
, XML_EVENT_LISTENERS
) )
2365 // create events context and remember it!
2366 xEventContext
= new XMLEventsImportContext( GetImport() );
2368 return xEventContext
;
2370 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement
);
2375 void XMLMacroFieldImportContext::ProcessAttribute(
2376 sal_Int32 nAttrToken
,
2377 std::string_view sAttrValue
)
2381 case XML_ELEMENT(TEXT
, XML_DESCRIPTION
):
2382 sDescription
= OUString::fromUtf8(sAttrValue
);
2383 bDescriptionOK
= true;
2385 case XML_ELEMENT(TEXT
, XML_NAME
):
2386 sMacro
= OUString::fromUtf8(sAttrValue
);
2390 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
2394 void XMLMacroFieldImportContext::PrepareField(
2395 const Reference
<XPropertySet
> & xPropertySet
)
2398 aAny
<<= (bDescriptionOK
? sDescription
: GetContent());
2399 xPropertySet
->setPropertyValue(sAPI_hint
, aAny
);
2401 // if we have an events child element, we'll look for the OnClick
2402 // event if not, it may be an old (pre-638i) document. Then, we'll
2403 // have to look at the name attribute.
2404 OUString sMacroName
;
2405 OUString sLibraryName
;
2406 OUString sScriptURL
;
2408 if ( xEventContext
.is() )
2410 // get event sequence
2411 XMLEventsImportContext
* pEvents
= xEventContext
.get();
2412 Sequence
<PropertyValue
> aValues
;
2413 pEvents
->GetEventSequence( u
"OnClick"_ustr
, aValues
);
2415 for (const auto& rValue
: aValues
)
2417 if ( rValue
.Name
== "ScriptType" )
2419 // ignore ScriptType
2421 else if ( rValue
.Name
== "Library" )
2423 rValue
.Value
>>= sLibraryName
;
2425 else if ( rValue
.Name
== "MacroName" )
2427 rValue
.Value
>>= sMacroName
;
2429 if ( rValue
.Name
== "Script" )
2431 rValue
.Value
>>= sScriptURL
;
2437 // disassemble old-style macro-name: Everything before the
2438 // third-last dot is the library
2439 sal_Int32 nPos
= sMacro
.getLength() + 1; // the loop starts with nPos--
2440 const sal_Unicode
* pBuf
= sMacro
.getStr();
2441 for( sal_Int32 i
= 0; (i
< 3) && (nPos
> 0); i
++ )
2444 while ( (pBuf
[nPos
] != '.') && (nPos
> 0) )
2450 sLibraryName
= sMacro
.copy(0, nPos
);
2451 sMacroName
= sMacro
.copy(nPos
+1);
2454 sMacroName
= sMacro
;
2457 xPropertySet
->setPropertyValue(u
"ScriptURL"_ustr
, Any(sScriptURL
));
2458 xPropertySet
->setPropertyValue(u
"MacroName"_ustr
, Any(sMacroName
));
2459 xPropertySet
->setPropertyValue(u
"MacroLibrary"_ustr
, Any(sLibraryName
));
2463 // reference field import
2466 XMLReferenceFieldImportContext::XMLReferenceFieldImportContext(
2467 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
2469 : XMLTextFieldImportContext(rImport
, rHlp
, u
"GetReference"_ustr
)
2470 , nElementToken(nToken
)
2472 , nType(ReferenceFieldPart::PAGE_DESC
)
2479 SvXMLEnumMapEntry
<sal_uInt16
> const lcl_aReferenceTypeTokenMap
[] =
2481 { XML_PAGE
, ReferenceFieldPart::PAGE
},
2482 { XML_CHAPTER
, ReferenceFieldPart::CHAPTER
},
2483 { XML_TEXT
, ReferenceFieldPart::TEXT
},
2484 { XML_DIRECTION
, ReferenceFieldPart::UP_DOWN
},
2485 { XML_CATEGORY_AND_VALUE
, ReferenceFieldPart::CATEGORY_AND_NUMBER
},
2486 { XML_CAPTION
, ReferenceFieldPart::ONLY_CAPTION
},
2487 { XML_VALUE
, ReferenceFieldPart::ONLY_SEQUENCE_NUMBER
},
2488 // Core implementation for direct cross-references (#i81002#)
2489 { XML_NUMBER
, ReferenceFieldPart::NUMBER
},
2490 { XML_NUMBER_NO_SUPERIOR
, ReferenceFieldPart::NUMBER_NO_CONTEXT
},
2491 { XML_NUMBER_ALL_SUPERIOR
, ReferenceFieldPart::NUMBER_FULL_CONTEXT
},
2492 { XML_TOKEN_INVALID
, 0 }
2495 void XMLReferenceFieldImportContext::startFastElement(
2497 const Reference
<XFastAttributeList
> & xAttrList
)
2500 switch (nElementToken
)
2502 case XML_ELEMENT(TEXT
, XML_REFERENCE_REF
):
2503 nSource
= ReferenceFieldSource::REFERENCE_MARK
;
2505 case XML_ELEMENT(TEXT
, XML_BOOKMARK_REF
):
2506 nSource
= ReferenceFieldSource::BOOKMARK
;
2508 case XML_ELEMENT(TEXT
, XML_NOTE_REF
):
2509 nSource
= ReferenceFieldSource::FOOTNOTE
;
2511 case XML_ELEMENT(TEXT
, XML_SEQUENCE_REF
):
2512 nSource
= ReferenceFieldSource::SEQUENCE_FIELD
;
2514 case XML_ELEMENT(TEXT
, XML_STYLE_REF
):
2515 case XML_ELEMENT(LO_EXT
, XML_STYLE_REF
):
2516 nSource
= ReferenceFieldSource::STYLE
;
2519 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElementToken
);
2524 XMLTextFieldImportContext::startFastElement(nElement
, xAttrList
);
2528 void XMLReferenceFieldImportContext::ProcessAttribute(
2529 sal_Int32 nAttrToken
,
2530 std::string_view sAttrValue
)
2534 case XML_ELEMENT(TEXT
, XML_NOTE_CLASS
):
2535 if( IsXMLToken( sAttrValue
, XML_ENDNOTE
) )
2536 nSource
= ReferenceFieldSource::ENDNOTE
;
2538 case XML_ELEMENT(TEXT
, XML_REF_NAME
):
2539 sName
= OUString::fromUtf8(sAttrValue
);
2542 case XML_ELEMENT(TEXT
, XML_REFERENCE_FORMAT
):
2545 if (SvXMLUnitConverter::convertEnum(nToken
, sAttrValue
,
2546 lcl_aReferenceTypeTokenMap
))
2551 // check for sequence-only-attributes
2552 if ( (XML_ELEMENT(TEXT
, XML_SEQUENCE_REF
) != nElementToken
) &&
2553 ( (nType
== ReferenceFieldPart::CATEGORY_AND_NUMBER
) ||
2554 (nType
== ReferenceFieldPart::ONLY_CAPTION
) ||
2555 (nType
== ReferenceFieldPart::ONLY_SEQUENCE_NUMBER
) ) )
2557 nType
= ReferenceFieldPart::PAGE_DESC
;
2562 case XML_ELEMENT(LO_EXT
, XML_REFERENCE_LANGUAGE
):
2563 case XML_ELEMENT(TEXT
, XML_REFERENCE_LANGUAGE
):
2564 sLanguage
= OUString::fromUtf8(sAttrValue
);
2566 case XML_ELEMENT(LO_EXT
, XML_REFERENCE_HIDE_NON_NUMERICAL
):
2567 case XML_ELEMENT(TEXT
, XML_REFERENCE_HIDE_NON_NUMERICAL
):
2568 if (OUString::fromUtf8(sAttrValue
).toBoolean())
2569 nFlags
|= REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL
;
2571 case XML_ELEMENT(LO_EXT
, XML_REFERENCE_FROM_BOTTOM
):
2572 case XML_ELEMENT(TEXT
, XML_REFERENCE_FROM_BOTTOM
):
2573 if (OUString::fromUtf8(sAttrValue
).toBoolean())
2574 nFlags
|= REFFLDFLAG_STYLE_FROM_BOTTOM
;
2577 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
2580 // bValid: we need proper element type and name
2581 bValid
= bTypeOK
&& bNameOK
;
2584 void XMLReferenceFieldImportContext::PrepareField(
2585 const Reference
<XPropertySet
> & xPropertySet
)
2587 xPropertySet
->setPropertyValue(u
"ReferenceFieldPart"_ustr
, Any(nType
));
2589 xPropertySet
->setPropertyValue(u
"ReferenceFieldSource"_ustr
, Any(nSource
));
2591 xPropertySet
->setPropertyValue(u
"ReferenceFieldLanguage"_ustr
, Any(sLanguage
));
2592 switch (nElementToken
)
2594 case XML_ELEMENT(TEXT
, XML_REFERENCE_REF
):
2595 case XML_ELEMENT(TEXT
, XML_BOOKMARK_REF
):
2596 case XML_ELEMENT(TEXT
, XML_STYLE_REF
):
2597 case XML_ELEMENT(LO_EXT
, XML_STYLE_REF
):
2598 xPropertySet
->setPropertyValue(u
"SourceName"_ustr
, Any(sName
));
2599 xPropertySet
->setPropertyValue(u
"ReferenceFieldFlags"_ustr
, Any(nFlags
));
2602 case XML_ELEMENT(TEXT
, XML_NOTE_REF
):
2603 GetImportHelper().ProcessFootnoteReference(sName
, xPropertySet
);
2606 case XML_ELEMENT(TEXT
, XML_SEQUENCE_REF
):
2607 GetImportHelper().ProcessSequenceReference(sName
, xPropertySet
);
2611 xPropertySet
->setPropertyValue(sAPI_current_presentation
, Any(GetContent()));
2615 // field declarations container
2617 XMLDdeFieldDeclsImportContext::XMLDdeFieldDeclsImportContext(SvXMLImport
& rImport
) :
2618 SvXMLImportContext(rImport
)
2622 css::uno::Reference
< css::xml::sax::XFastContextHandler
> XMLDdeFieldDeclsImportContext::createFastChildContext(
2624 const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& )
2626 if ( nElement
== XML_ELEMENT(TEXT
, XML_DDE_CONNECTION_DECL
) )
2628 return new XMLDdeFieldDeclImportContext(GetImport());
2631 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement
);
2636 // import dde field declaration
2639 XMLDdeFieldDeclImportContext::XMLDdeFieldDeclImportContext(SvXMLImport
& rImport
)
2640 : SvXMLImportContext(rImport
)
2644 void XMLDdeFieldDeclImportContext::startFastElement(
2645 sal_Int32
/*nElement*/,
2646 const Reference
<XFastAttributeList
> & xAttrList
)
2649 OUString sCommandApplication
;
2650 OUString sCommandTopic
;
2651 OUString sCommandItem
;
2653 bool bUpdate
= false;
2654 bool bNameOK
= false;
2655 bool bCommandApplicationOK
= false;
2656 bool bCommandTopicOK
= false;
2657 bool bCommandItemOK
= false;
2659 // process attributes
2660 for( auto &aIter
: sax_fastparser::castToFastAttributeList( xAttrList
) )
2662 switch (aIter
.getToken())
2664 case XML_ELEMENT(OFFICE
, XML_NAME
):
2665 sName
= aIter
.toString();
2668 case XML_ELEMENT(OFFICE
, XML_DDE_APPLICATION
):
2669 sCommandApplication
= aIter
.toString();
2670 bCommandApplicationOK
= true;
2672 case XML_ELEMENT(OFFICE
, XML_DDE_TOPIC
):
2673 sCommandTopic
= aIter
.toString();
2674 bCommandTopicOK
= true;
2676 case XML_ELEMENT(OFFICE
, XML_DDE_ITEM
):
2677 sCommandItem
= aIter
.toString();
2678 bCommandItemOK
= true;
2680 case XML_ELEMENT(OFFICE
, XML_AUTOMATIC_UPDATE
):
2683 if (::sax::Converter::convertBool(bTmp
, aIter
.toView()) )
2690 XMLOFF_WARN_UNKNOWN("xmloff", aIter
);
2695 if (!(bNameOK
&& bCommandApplicationOK
&& bCommandTopicOK
&& bCommandItemOK
))
2698 // create DDE TextFieldMaster
2699 Reference
<XMultiServiceFactory
> xFactory(GetImport().GetModel(),
2701 if( !xFactory
.is() )
2704 /* #i6432# There might be multiple occurrences of one DDE
2705 declaration if it is used in more than one of
2706 header/footer/body. createInstance will throw an exception if we
2707 try to create the second, third, etc. instance of such a
2708 declaration. Thus we ignore the exception. Otherwise this will
2709 lead to an unloadable document. */
2712 Reference
<XInterface
> xIfc
=
2713 xFactory
->createInstance(OUString::Concat(sAPI_fieldmaster_prefix
) + sAPI_dde
);
2716 Reference
<XPropertySet
> xPropSet( xIfc
, UNO_QUERY
);
2717 if (xPropSet
.is() &&
2718 xPropSet
->getPropertySetInfo()->hasPropertyByName(
2719 u
"DDECommandType"_ustr
))
2721 xPropSet
->setPropertyValue(sAPI_name
, Any(sName
));
2723 xPropSet
->setPropertyValue(u
"DDECommandType"_ustr
, Any(sCommandApplication
));
2725 xPropSet
->setPropertyValue(u
"DDECommandFile"_ustr
, Any(sCommandTopic
));
2727 xPropSet
->setPropertyValue(u
"DDECommandElement"_ustr
,
2730 xPropSet
->setPropertyValue(u
"IsAutomaticUpdate"_ustr
,
2733 // else: ignore (can't get XPropertySet, or DDE
2734 // properties are not supported)
2738 catch (const Exception
&)
2750 XMLDdeFieldImportContext::XMLDdeFieldImportContext(
2751 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
) :
2752 XMLTextFieldImportContext(rImport
, rHlp
, sAPI_dde
),
2753 sPropertyContent(sAPI_content
)
2757 void XMLDdeFieldImportContext::ProcessAttribute(
2758 sal_Int32 nAttrToken
,
2759 std::string_view sAttrValue
)
2761 if ( XML_ELEMENT(TEXT
, XML_CONNECTION_NAME
) == nAttrToken
)
2763 sName
= OUString::fromUtf8(sAttrValue
);
2767 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
2771 void XMLDdeFieldImportContext::endFastElement(sal_Int32
)
2777 OUString sMasterName
= OUString::Concat(sAPI_fieldmaster_prefix
) + sAPI_dde
+ "." + sName
;
2779 Reference
<XTextFieldsSupplier
> xTextFieldsSupp(GetImport().GetModel(),
2781 Reference
<container::XNameAccess
> xFieldMasterNameAccess
=
2782 xTextFieldsSupp
->getTextFieldMasters();
2784 if (!xFieldMasterNameAccess
->hasByName(sMasterName
))
2787 Reference
<XPropertySet
> xMaster
;
2788 Any aAny
= xFieldMasterNameAccess
->getByName(sMasterName
);
2790 //apply the content to the master
2791 xMaster
->setPropertyValue( sPropertyContent
, uno::Any( GetContent()));
2792 // master exists: create text field and attach
2793 Reference
<XPropertySet
> xField
;
2794 OUString sFieldName
= OUString::Concat(sAPI_textfield_prefix
) + sAPI_dde
;
2795 if (!CreateField(xField
, sFieldName
))
2798 Reference
<XDependentTextField
> xDepTextField(xField
,UNO_QUERY
);
2799 xDepTextField
->attachTextFieldMaster(xMaster
);
2801 // attach field to document
2802 Reference
<XTextContent
> xTextContent(xField
, UNO_QUERY
);
2803 if (xTextContent
.is())
2805 GetImportHelper().InsertTextContent(xTextContent
);
2807 // we're lucky. nothing else to prepare.
2809 // else: fail, because text content could not be created
2810 // else: fail, because field could not be created
2811 // else: fail, because no master was found (faulty document?!)
2812 // not valid: ignore
2815 void XMLDdeFieldImportContext::PrepareField(
2816 const Reference
<XPropertySet
> &)
2818 // empty, since not needed.
2822 // sheet name fields
2825 XMLSheetNameImportContext::XMLSheetNameImportContext(
2826 SvXMLImport
& rImport
,
2827 XMLTextImportHelper
& rHlp
) :
2828 XMLTextFieldImportContext(rImport
, rHlp
, u
"SheetName"_ustr
)
2830 bValid
= true; // always valid!
2833 void XMLSheetNameImportContext::ProcessAttribute(
2834 sal_Int32 nAttrToken
,
2835 std::string_view sAttrValue
)
2837 // no attributes -> nothing to be done
2838 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
2841 void XMLSheetNameImportContext::PrepareField(
2842 const Reference
<XPropertySet
> &)
2844 // no attributes -> nothing to be done
2847 /** import page|slide name fields (<text:page-name>) */
2849 XMLPageNameFieldImportContext::XMLPageNameFieldImportContext(
2850 SvXMLImport
& rImport
, /// XML Import
2851 XMLTextImportHelper
& rHlp
) /// Text import helper
2852 : XMLTextFieldImportContext(rImport
, rHlp
, u
"PageName"_ustr
)
2857 /// process attribute values
2858 void XMLPageNameFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken
,
2859 std::string_view sAttrValue
)
2861 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
2864 /// prepare XTextField for insertion into document
2865 void XMLPageNameFieldImportContext::PrepareField(
2866 const css::uno::Reference
<css::beans::XPropertySet
> &)
2871 // URL fields (Calc, Impress, Draw)
2874 XMLUrlFieldImportContext::XMLUrlFieldImportContext(
2875 SvXMLImport
& rImport
,
2876 XMLTextImportHelper
& rHlp
) :
2877 XMLTextFieldImportContext(rImport
, rHlp
, sAPI_url
),
2882 void XMLUrlFieldImportContext::ProcessAttribute(
2883 sal_Int32 nAttrToken
,
2884 std::string_view sAttrValue
)
2888 case XML_ELEMENT(XLINK
, XML_HREF
):
2889 sURL
= GetImport().GetAbsoluteReference( OUString::fromUtf8(sAttrValue
) );
2892 case XML_ELEMENT(OFFICE
, XML_TARGET_FRAME_NAME
):
2893 sFrame
= OUString::fromUtf8(sAttrValue
);
2898 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
2903 void XMLUrlFieldImportContext::PrepareField(
2904 const Reference
<XPropertySet
> & xPropertySet
)
2906 xPropertySet
->setPropertyValue(sAPI_url
, Any(sURL
));
2910 xPropertySet
->setPropertyValue(u
"TargetFrame"_ustr
, Any(sFrame
));
2913 xPropertySet
->setPropertyValue(u
"Representation"_ustr
, Any(GetContent()));
2917 XMLBibliographyFieldImportContext::XMLBibliographyFieldImportContext(
2918 SvXMLImport
& rImport
,
2919 XMLTextImportHelper
& rHlp
) :
2920 XMLTextFieldImportContext(rImport
, rHlp
, u
"Bibliography"_ustr
)
2925 // TODO: this is the same map as is used in the text field export
2926 SvXMLEnumMapEntry
<sal_uInt16
> const aBibliographyDataTypeMap
[] =
2928 { XML_ARTICLE
, BibliographyDataType::ARTICLE
},
2929 { XML_BOOK
, BibliographyDataType::BOOK
},
2930 { XML_BOOKLET
, BibliographyDataType::BOOKLET
},
2931 { XML_CONFERENCE
, BibliographyDataType::CONFERENCE
},
2932 { XML_CUSTOM1
, BibliographyDataType::CUSTOM1
},
2933 { XML_CUSTOM2
, BibliographyDataType::CUSTOM2
},
2934 { XML_CUSTOM3
, BibliographyDataType::CUSTOM3
},
2935 { XML_CUSTOM4
, BibliographyDataType::CUSTOM4
},
2936 { XML_CUSTOM5
, BibliographyDataType::CUSTOM5
},
2937 { XML_EMAIL
, BibliographyDataType::EMAIL
},
2938 { XML_INBOOK
, BibliographyDataType::INBOOK
},
2939 { XML_INCOLLECTION
, BibliographyDataType::INCOLLECTION
},
2940 { XML_INPROCEEDINGS
, BibliographyDataType::INPROCEEDINGS
},
2941 { XML_JOURNAL
, BibliographyDataType::JOURNAL
},
2942 { XML_MANUAL
, BibliographyDataType::MANUAL
},
2943 { XML_MASTERSTHESIS
, BibliographyDataType::MASTERSTHESIS
},
2944 { XML_MISC
, BibliographyDataType::MISC
},
2945 { XML_PHDTHESIS
, BibliographyDataType::PHDTHESIS
},
2946 { XML_PROCEEDINGS
, BibliographyDataType::PROCEEDINGS
},
2947 { XML_TECHREPORT
, BibliographyDataType::TECHREPORT
},
2948 { XML_UNPUBLISHED
, BibliographyDataType::UNPUBLISHED
},
2949 { XML_WWW
, BibliographyDataType::WWW
},
2950 { XML_TOKEN_INVALID
, 0 }
2954 // we'll process attributes on our own and for fit the standard
2955 // textfield mechanism, because our attributes have zero overlap with
2956 // all the other textfields.
2957 void XMLBibliographyFieldImportContext::startFastElement(
2958 sal_Int32
/*nElement*/,
2959 const Reference
<XFastAttributeList
> & xAttrList
)
2961 // iterate over attributes
2962 for( auto &aIter
: sax_fastparser::castToFastAttributeList( xAttrList
) )
2964 if (IsTokenInNamespace(aIter
.getToken(), XML_NAMESPACE_TEXT
)
2965 || IsTokenInNamespace(aIter
.getToken(), XML_NAMESPACE_LO_EXT
))
2967 auto nToken
= aIter
.getToken() & TOKEN_MASK
;
2968 PropertyValue aValue
;
2969 aValue
.Name
= MapBibliographyFieldName(nToken
);
2971 // special treatment for bibliography type
2972 // biblio vs bibilio: #96658#; also read old documents
2973 if (nToken
== XML_BIBILIOGRAPHIC_TYPE
||
2974 nToken
== XML_BIBLIOGRAPHY_TYPE
)
2977 if (SvXMLUnitConverter::convertEnum(
2978 nTmp
, aIter
.toView(),
2979 aBibliographyDataTypeMap
))
2981 aValue
.Value
<<= static_cast<sal_Int16
>(nTmp
);
2983 aValues
.push_back(aValue
);
2988 OUString aStringValue
= aIter
.toString();
2989 if (nToken
== XML_URL
|| nToken
== XML_LOCAL_URL
|| nToken
== XML_TARGET_URL
)
2991 aStringValue
= GetImport().GetAbsoluteReference(aStringValue
);
2993 aValue
.Value
<<= aStringValue
;
2995 aValues
.push_back(aValue
);
2998 // else: unknown namespace -> ignore
3002 void XMLBibliographyFieldImportContext::ProcessAttribute(
3006 // attributes are handled in StartElement
3007 assert(false && "This should not have happened.");
3011 void XMLBibliographyFieldImportContext::PrepareField(
3012 const Reference
<XPropertySet
> & xPropertySet
)
3014 // convert vector into sequence
3015 sal_Int32 nCount
= aValues
.size();
3016 Sequence
<PropertyValue
> aValueSequence(nCount
);
3017 auto aValueSequenceRange
= asNonConstRange(aValueSequence
);
3018 for(sal_Int32 i
= 0; i
< nCount
; i
++)
3020 aValueSequenceRange
[i
] = aValues
[i
];
3024 xPropertySet
->setPropertyValue(u
"Fields"_ustr
, Any(aValueSequence
));
3027 OUString
XMLBibliographyFieldImportContext::MapBibliographyFieldName(
3032 switch (nElement
& TOKEN_MASK
)
3034 case XML_IDENTIFIER
:
3035 pName
= u
"Identifier"_ustr
;
3037 case XML_BIBILIOGRAPHIC_TYPE
:
3038 case XML_BIBLIOGRAPHY_TYPE
:
3039 // biblio... vs bibilio...: #96658#: also read old documents
3040 pName
= u
"BibiliographicType"_ustr
;
3043 pName
= u
"Address"_ustr
;
3046 pName
= u
"Annote"_ustr
;
3049 pName
= u
"Author"_ustr
;
3052 pName
= u
"Booktitle"_ustr
;
3055 pName
= u
"Chapter"_ustr
;
3058 pName
= u
"Edition"_ustr
;
3061 pName
= u
"Editor"_ustr
;
3063 case XML_HOWPUBLISHED
:
3064 pName
= u
"Howpublished"_ustr
;
3066 case XML_INSTITUTION
:
3067 pName
= u
"Institution"_ustr
;
3070 pName
= u
"Journal"_ustr
;
3073 pName
= u
"Month"_ustr
;
3076 pName
= u
"Note"_ustr
;
3079 pName
= u
"Number"_ustr
;
3081 case XML_ORGANIZATIONS
:
3082 pName
= u
"Organizations"_ustr
;
3085 pName
= u
"Pages"_ustr
;
3088 pName
= u
"Publisher"_ustr
;
3091 pName
= u
"School"_ustr
;
3094 pName
= u
"Series"_ustr
;
3097 pName
= u
"Title"_ustr
;
3099 case XML_REPORT_TYPE
:
3100 pName
= u
"Report_Type"_ustr
;
3103 pName
= u
"Volume"_ustr
;
3106 pName
= u
"Year"_ustr
;
3109 pName
= u
"URL"_ustr
;
3112 pName
= u
"Custom1"_ustr
;
3115 pName
= u
"Custom2"_ustr
;
3118 pName
= u
"Custom3"_ustr
;
3121 pName
= u
"Custom4"_ustr
;
3124 pName
= u
"Custom5"_ustr
;
3127 pName
= u
"ISBN"_ustr
;
3130 pName
= u
"LocalURL"_ustr
;
3132 case XML_TARGET_TYPE
:
3133 pName
= u
"TargetType"_ustr
;
3135 case XML_TARGET_URL
:
3136 pName
= u
"TargetURL"_ustr
;
3139 assert(false && "Unknown bibliography info data");
3147 XMLAnnotationImportContext::XMLAnnotationImportContext(
3148 SvXMLImport
& rImport
,
3149 XMLTextImportHelper
& rHlp
,
3150 sal_Int32 nElement
) :
3151 XMLTextFieldImportContext(rImport
, rHlp
, u
"Annotation"_ustr
),
3156 // remember old list item and block (#91964#) and reset them
3157 // for the text frame
3158 // do this in the constructor, not in CreateChildContext (#i93392#)
3159 GetImport().GetTextImport()->PushListContext();
3162 void XMLAnnotationImportContext::ProcessAttribute(
3163 sal_Int32 nAttrToken
,
3164 std::string_view sAttrValue
)
3166 if (nAttrToken
== XML_ELEMENT(OFFICE
, XML_NAME
))
3167 aName
= OUString::fromUtf8(sAttrValue
);
3168 else if (nAttrToken
== XML_ELEMENT(LO_EXT
, XML_RESOLVED
))
3169 aResolved
= OUString::fromUtf8(sAttrValue
);
3170 else if (nAttrToken
== XML_ELEMENT(LO_EXT
, XML_PARENT_NAME
))
3171 aParentName
= OUString::fromUtf8(sAttrValue
);
3173 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
3176 css::uno::Reference
< css::xml::sax::XFastContextHandler
> XMLAnnotationImportContext::createFastChildContext(
3178 const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
3180 if( nElement
== XML_ELEMENT(DC
, XML_CREATOR
) )
3181 return new XMLStringBufferImportContext(GetImport(), aAuthorBuffer
);
3182 else if( nElement
== XML_ELEMENT(DC
, XML_DATE
) )
3183 return new XMLStringBufferImportContext(GetImport(), aDateBuffer
);
3184 else if (nElement
== XML_ELEMENT(TEXT
,XML_SENDER_INITIALS
) ||
3185 nElement
== XML_ELEMENT(LO_EXT
, XML_SENDER_INITIALS
) ||
3186 nElement
== XML_ELEMENT(META
, XML_CREATOR_INITIALS
))
3187 return new XMLStringBufferImportContext(GetImport(), aInitialsBuffer
);
3192 if ( !mxField
.is() )
3193 bOK
= CreateField( mxField
, sServicePrefix
+ GetServiceName() );
3196 Any aAny
= mxField
->getPropertyValue( u
"TextRange"_ustr
);
3197 Reference
< XText
> xText
;
3201 rtl::Reference
< XMLTextImportHelper
> xTxtImport
= GetImport().GetTextImport();
3202 if( !mxCursor
.is() )
3204 mxOldCursor
= xTxtImport
->GetCursor();
3205 mxCursor
= xText
->createTextCursor();
3210 xTxtImport
->SetCursor( mxCursor
);
3211 return xTxtImport
->CreateTextChildContext( GetImport(), nElement
, xAttrList
);
3216 catch (const Exception
&)
3220 return new XMLStringBufferImportContext(GetImport(), aTextBuffer
);
3223 void XMLAnnotationImportContext::endFastElement(sal_Int32
/*nElement*/)
3225 DBG_ASSERT(!GetServiceName().isEmpty(), "no service name for element!");
3228 // delete addition newline
3229 mxCursor
->gotoEnd( false );
3230 mxCursor
->goLeft( 1, true );
3231 mxCursor
->setString( u
""_ustr
);
3234 GetImport().GetTextImport()->ResetCursor();
3237 if( mxOldCursor
.is() )
3238 GetImport().GetTextImport()->SetCursor( mxOldCursor
);
3240 // reinstall old list item #91964#
3241 GetImport().GetTextImport()->PopListContext();
3245 GetImportHelper().InsertString(GetContent());
3249 if ( mnElement
== XML_ELEMENT(OFFICE
, XML_ANNOTATION_END
) )
3251 // Search for a previous annotation with the same name.
3252 uno::Reference
< text::XTextContent
> xPrevField
;
3254 Reference
<XTextFieldsSupplier
> xTextFieldsSupplier(GetImport().GetModel(), UNO_QUERY
);
3255 if (!xTextFieldsSupplier
)
3257 uno::Reference
<container::XUniqueIDAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields(), UNO_QUERY_THROW
);
3258 uno::Any aAny
= xFieldsAccess
->getByUniqueID(aName
);
3259 aAny
>>= xPrevField
;
3261 if ( xPrevField
.is() )
3263 // So we are ending a previous annotation,
3264 // let's create a text range covering the old and the current position.
3265 uno::Reference
<text::XText
> xText
= GetImportHelper().GetText();
3266 uno::Reference
<text::XTextCursor
> xCursor
=
3267 xText
->createTextCursorByRange(GetImportHelper().GetCursorAsRange());
3270 xCursor
->gotoRange(xPrevField
->getAnchor(), true);
3272 catch (const uno::RuntimeException
&)
3274 // Losing the start of the anchor is better than not opening the document at
3276 TOOLS_WARN_EXCEPTION(
3278 "XMLAnnotationImportContext::endFastElement: gotoRange() failed: ");
3281 xText
->insertTextContent(xCursor
, xPrevField
, !xCursor
->isCollapsed());
3286 if ( mxField
.is() || CreateField( mxField
, sServicePrefix
+ GetServiceName() ) )
3288 // set field properties
3289 PrepareField( mxField
);
3291 // attach field to document
3292 Reference
< XTextContent
> xTextContent( mxField
, UNO_QUERY
);
3294 // workaround for #80606#
3297 GetImportHelper().InsertTextContent( xTextContent
);
3299 catch (const lang::IllegalArgumentException
&)
3306 void XMLAnnotationImportContext::PrepareField(
3307 const Reference
<XPropertySet
> & xPropertySet
)
3309 // import (possibly empty) author
3310 OUString
sAuthor( aAuthorBuffer
.makeStringAndClear() );
3311 xPropertySet
->setPropertyValue(sAPI_author
, Any(sAuthor
));
3313 // import (possibly empty) initials
3314 OUString
sInitials( aInitialsBuffer
.makeStringAndClear() );
3315 xPropertySet
->setPropertyValue(u
"Initials"_ustr
, Any(sInitials
));
3317 //import resolved flag
3319 (void)::sax::Converter::convertBool(bTmp
, aResolved
);
3320 xPropertySet
->setPropertyValue(u
"Resolved"_ustr
, Any(bTmp
));
3322 util::DateTime aDateTime
;
3323 if (::sax::Converter::parseDateTime(aDateTime
, aDateBuffer
))
3327 aDate.Year = aDateTime.Year;
3328 aDate.Month = aDateTime.Month;
3329 aDate.Day = aDateTime.Day;
3330 xPropertySet->setPropertyValue(sPropertyDate, makeAny(aDate));
3332 // why is there no UNO_NAME_DATE_TIME, but only UNO_NAME_DATE_TIME_VALUE?
3333 xPropertySet
->setPropertyValue(sAPI_date_time_value
, Any(aDateTime
));
3335 aDateBuffer
.setLength(0);
3337 if ( aTextBuffer
.getLength() )
3339 // delete last paragraph mark (if necessary)
3340 if (char(0x0a) == aTextBuffer
[aTextBuffer
.getLength()-1])
3341 aTextBuffer
.setLength(aTextBuffer
.getLength()-1);
3342 xPropertySet
->setPropertyValue(sAPI_content
, Any(aTextBuffer
.makeStringAndClear()));
3345 if (!aName
.isEmpty())
3346 xPropertySet
->setPropertyValue(sAPI_name
, Any(aName
));
3348 if (!aParentName
.isEmpty())
3349 xPropertySet
->setPropertyValue(sAPI_parent_name
, Any(aParentName
));
3356 XMLScriptImportContext::XMLScriptImportContext(
3357 SvXMLImport
& rImport
,
3358 XMLTextImportHelper
& rHlp
)
3359 : XMLTextFieldImportContext(rImport
, rHlp
, u
"Script"_ustr
)
3364 void XMLScriptImportContext::ProcessAttribute(
3365 sal_Int32 nAttrToken
,
3366 std::string_view sAttrValue
)
3370 case XML_ELEMENT(XLINK
, XML_HREF
):
3371 sContent
= GetImport().GetAbsoluteReference( OUString::fromUtf8(sAttrValue
) );
3375 case XML_ELEMENT(SCRIPT
, XML_LANGUAGE
):
3376 sScriptType
= OUString::fromUtf8(sAttrValue
);
3381 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
3385 // always valid (even without ScriptType; cf- #96531#)
3389 void XMLScriptImportContext::PrepareField(
3390 const Reference
<XPropertySet
> & xPropertySet
)
3392 // if href attribute was present, we use it. Else we use element content
3395 sContent
= GetContent();
3397 xPropertySet
->setPropertyValue(sAPI_content
, Any(sContent
));
3399 // URL or script text? We use URL if we have an href-attribute
3400 xPropertySet
->setPropertyValue(u
"URLContent"_ustr
, Any(bContentOK
));
3402 xPropertySet
->setPropertyValue(u
"ScriptType"_ustr
, Any(sScriptType
));
3409 XMLMeasureFieldImportContext::XMLMeasureFieldImportContext(
3410 SvXMLImport
& rImport
,
3411 XMLTextImportHelper
& rHlp
) :
3412 XMLTextFieldImportContext(rImport
, rHlp
, u
"Measure"_ustr
),
3417 void XMLMeasureFieldImportContext::ProcessAttribute(
3418 sal_Int32 nAttrToken
,
3419 std::string_view sAttrValue
)
3423 case XML_ELEMENT(TEXT
, XML_KIND
):
3424 if( IsXMLToken( sAttrValue
, XML_VALUE
) )
3426 mnKind
= 0; bValid
= true;
3428 else if( IsXMLToken( sAttrValue
, XML_UNIT
) )
3430 mnKind
= 1; bValid
= true;
3432 else if( IsXMLToken( sAttrValue
, XML_GAP
) )
3434 mnKind
= 2; bValid
= true;
3438 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
3442 void XMLMeasureFieldImportContext::PrepareField(
3443 const Reference
<XPropertySet
> & xPropertySet
)
3445 xPropertySet
->setPropertyValue(u
"Kind"_ustr
, Any(mnKind
));
3452 XMLDropDownFieldImportContext::XMLDropDownFieldImportContext(
3453 SvXMLImport
& rImport
,
3454 XMLTextImportHelper
& rHlp
) :
3455 XMLTextFieldImportContext( rImport
, rHlp
, u
"DropDown"_ustr
),
3464 static bool lcl_ProcessLabel(
3465 const Reference
<XFastAttributeList
>& xAttrList
,
3469 bool bValid
= false;
3470 for( auto& aIter
: sax_fastparser::castToFastAttributeList(xAttrList
) )
3472 switch (aIter
.getToken())
3474 case XML_ELEMENT(TEXT
, XML_VALUE
):
3476 rLabel
= aIter
.toString();
3480 case XML_ELEMENT(TEXT
, XML_CURRENT_SELECTED
):
3483 if (::sax::Converter::convertBool( bTmp
, aIter
.toView() ))
3488 XMLOFF_WARN_UNKNOWN("xmloff", aIter
);
3494 css::uno::Reference
< css::xml::sax::XFastContextHandler
> XMLDropDownFieldImportContext::createFastChildContext(
3495 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
)
3497 if( nElement
== XML_ELEMENT(TEXT
, XML_LABEL
) )
3500 bool bIsSelected
= false;
3501 if( lcl_ProcessLabel( xAttrList
, sLabel
, bIsSelected
) )
3504 nSelected
= static_cast<sal_Int32
>( aLabels
.size() );
3505 aLabels
.push_back( sLabel
);
3508 return new SvXMLImportContext( GetImport() );
3511 void XMLDropDownFieldImportContext::ProcessAttribute(
3512 sal_Int32 nAttrToken
,
3513 std::string_view sAttrValue
)
3515 if( nAttrToken
== XML_ELEMENT(TEXT
, XML_NAME
))
3517 sName
= OUString::fromUtf8(sAttrValue
);
3520 else if (nAttrToken
== XML_ELEMENT(TEXT
, XML_HELP
))
3522 sHelp
= OUString::fromUtf8(sAttrValue
);
3525 else if (nAttrToken
== XML_ELEMENT(TEXT
, XML_HINT
))
3527 sHint
= OUString::fromUtf8(sAttrValue
);
3531 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
3534 void XMLDropDownFieldImportContext::PrepareField(
3535 const Reference
<XPropertySet
>& xPropertySet
)
3538 sal_Int32 nLength
= static_cast<sal_Int32
>( aLabels
.size() );
3539 Sequence
<OUString
> aSequence( nLength
);
3540 OUString
* pSequence
= aSequence
.getArray();
3541 for( sal_Int32 n
= 0; n
< nLength
; n
++ )
3542 pSequence
[n
] = aLabels
[n
];
3546 xPropertySet
->setPropertyValue( u
"Items"_ustr
, Any(aSequence
) );
3548 if( nSelected
>= 0 && nSelected
< nLength
)
3550 xPropertySet
->setPropertyValue( u
"SelectedItem"_ustr
, Any(pSequence
[nSelected
]) );
3556 xPropertySet
->setPropertyValue( u
"Name"_ustr
, Any(sName
) );
3561 xPropertySet
->setPropertyValue( u
"Help"_ustr
, Any(sHelp
) );
3566 xPropertySet
->setPropertyValue( u
"Tooltip"_ustr
, Any(sHint
) );
3571 /** import header fields (<draw:header>) */
3573 XMLHeaderFieldImportContext::XMLHeaderFieldImportContext(
3574 SvXMLImport
& rImport
, /// XML Import
3575 XMLTextImportHelper
& rHlp
) /// Text import helper
3576 : XMLTextFieldImportContext(rImport
, rHlp
, u
"Header"_ustr
)
3578 sServicePrefix
= sAPI_presentation_prefix
;
3582 /// process attribute values
3583 void XMLHeaderFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken
, std::string_view sAttrValue
)
3585 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
3588 /// prepare XTextField for insertion into document
3589 void XMLHeaderFieldImportContext::PrepareField(const Reference
<XPropertySet
> &)
3593 /** import footer fields (<draw:footer>) */
3595 XMLFooterFieldImportContext::XMLFooterFieldImportContext(
3596 SvXMLImport
& rImport
, /// XML Import
3597 XMLTextImportHelper
& rHlp
) /// Text import helper
3598 : XMLTextFieldImportContext(rImport
, rHlp
, u
"Footer"_ustr
)
3600 sServicePrefix
= sAPI_presentation_prefix
;
3604 /// process attribute values
3605 void XMLFooterFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken
, std::string_view sAttrValue
)
3607 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
3610 /// prepare XTextField for insertion into document
3611 void XMLFooterFieldImportContext::PrepareField(const Reference
<XPropertySet
> &)
3616 /** import footer fields (<draw:date-and-time>) */
3618 XMLDateTimeFieldImportContext::XMLDateTimeFieldImportContext(
3619 SvXMLImport
& rImport
, /// XML Import
3620 XMLTextImportHelper
& rHlp
) /// Text import helper
3621 : XMLTextFieldImportContext(rImport
, rHlp
, u
"DateTime"_ustr
)
3623 sServicePrefix
= sAPI_presentation_prefix
;
3627 /// process attribute values
3628 void XMLDateTimeFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken
,
3629 std::string_view sAttrValue
)
3631 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken
, sAttrValue
);
3634 /// prepare XTextField for insertion into document
3635 void XMLDateTimeFieldImportContext::PrepareField(
3636 const css::uno::Reference
<
3637 css::beans::XPropertySet
> &)
3641 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */