LibreOffice Module xmloff (master) 1
txtfldi.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
27#include <sal/config.h>
28
29#include <cassert>
30
31#include <txtfldi.hxx>
32#include <txtvfldi.hxx>
33#include <xmloff/xmlimp.hxx>
34#include <xmloff/txtimp.hxx>
37#include <xmloff/xmltoken.hxx>
38#include <xmloff/xmluconv.hxx>
39#include <xmloff/xmlement.hxx>
42#include <com/sun/star/frame/XModel.hpp>
43#include <com/sun/star/xml/sax/XAttributeList.hpp>
44#include <com/sun/star/text/UserDataPart.hpp>
45#include <com/sun/star/style/NumberingType.hpp>
46#include <com/sun/star/text/PlaceholderType.hpp>
47#include <com/sun/star/text/ReferenceFieldPart.hpp>
48#include <com/sun/star/text/ReferenceFieldSource.hpp>
49#include <com/sun/star/text/XTextContent.hpp>
50#include <com/sun/star/beans/XPropertySet.hpp>
51#include <com/sun/star/beans/XPropertySetInfo.hpp>
52#include <com/sun/star/lang/XMultiServiceFactory.hpp>
53#include <com/sun/star/text/XTextFieldsSupplier.hpp>
54#include <com/sun/star/text/XDependentTextField.hpp>
55#include <com/sun/star/text/FilenameDisplayFormat.hpp>
56#include <com/sun/star/text/ChapterFormat.hpp>
57#include <com/sun/star/text/TemplateDisplayFormat.hpp>
58#include <com/sun/star/beans/PropertyValue.hpp>
59#include <com/sun/star/text/BibliographyDataType.hpp>
60#include <com/sun/star/util/XUpdatable.hpp>
61#include <com/sun/star/sdb/CommandType.hpp>
62#include <com/sun/star/container/XIndexReplace.hpp>
63
65
66#include <rtl/ustring.hxx>
67#include <rtl/ustrbuf.hxx>
68#include <sal/log.hxx>
69#include <rtl/math.hxx>
70#include <tools/debug.hxx>
71#include <osl/diagnose.h>
72#include <tools/diagnose_ex.h>
73
74using namespace ::com::sun::star;
75using namespace ::com::sun::star::uno;
76using namespace ::com::sun::star::text;
77using namespace ::com::sun::star::lang;
78using namespace ::com::sun::star::beans;
79using namespace ::com::sun::star::document;
80using namespace ::com::sun::star::util;
81using namespace ::com::sun::star::xml::sax;
82using namespace ::xmloff::token;
83
84
85// SO API string constants
86
87
88// service prefix and service names
89constexpr OUStringLiteral sAPI_textfield_prefix = u"com.sun.star.text.TextField.";
90constexpr char16_t sAPI_fieldmaster_prefix[] = u"com.sun.star.text.FieldMaster.";
91constexpr OUStringLiteral sAPI_presentation_prefix = u"com.sun.star.presentation.TextField.";
92
93constexpr OUStringLiteral sAPI_date_time = u"DateTime";
94constexpr OUStringLiteral sAPI_page_number = u"PageNumber";
95constexpr OUStringLiteral sAPI_docinfo_change_date_time = u"DocInfo.ChangeDateTime";
96constexpr OUStringLiteral sAPI_docinfo_create_date_time = u"DocInfo.CreateDateTime";
97constexpr OUStringLiteral sAPI_docinfo_custom = u"DocInfo.Custom";
98constexpr OUStringLiteral sAPI_docinfo_print_date_time = u"DocInfo.PrintDateTime";
99constexpr OUStringLiteral sAPI_dde = u"DDE";
100constexpr OUStringLiteral sAPI_url = u"URL";
101
102// property names
103constexpr OUStringLiteral sAPI_is_fixed = u"IsFixed";
104constexpr OUStringLiteral sAPI_content = u"Content";
105constexpr OUStringLiteral sAPI_author = u"Author";
106constexpr OUStringLiteral sAPI_hint = u"Hint";
107constexpr OUStringLiteral sAPI_name = u"Name";
108constexpr OUStringLiteral sAPI_sub_type = u"SubType";
109constexpr OUStringLiteral sAPI_date_time_value = u"DateTimeValue";
110constexpr OUStringLiteral sAPI_number_format = u"NumberFormat";
111constexpr OUStringLiteral sAPI_numbering_type = u"NumberingType";
112constexpr OUStringLiteral sAPI_offset = u"Offset";
113constexpr OUStringLiteral sAPI_condition = u"Condition";
114constexpr OUStringLiteral sAPI_set_number = u"SetNumber";
115constexpr OUStringLiteral sAPI_file_format = u"FileFormat";
116constexpr OUStringLiteral sAPI_is_date = u"IsDate";
117constexpr OUStringLiteral sAPI_current_presentation = u"CurrentPresentation";
118constexpr OUStringLiteral sAPI_is_hidden = u"IsHidden";
119constexpr OUStringLiteral sAPI_is_fixed_language = u"IsFixedLanguage";
120
121constexpr OUStringLiteral sAPI_true = u"TRUE";
122
123
125 SvXMLImport& rImport, XMLTextImportHelper& rHlp,
126 const OUString& pService)
127: SvXMLImportContext( rImport )
128, sServiceName(pService)
129, rTextImportHelper(rHlp)
130, sServicePrefix(sAPI_textfield_prefix)
131, bValid(false)
132{
133}
134
136 sal_Int32 /*nElement*/,
137 const Reference<XFastAttributeList> & xAttrList)
138{
139 // process attributes
140 for( auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ) )
141 ProcessAttribute(aIter.getToken(), aIter.toView() );
142}
143
145{
146 if (sContent.isEmpty())
147 {
148 sContent = sContentBuffer.makeStringAndClear();
149 }
150
151 return sContent;
152}
153
155{
156 if (bValid)
157 {
158
159 // create field/Service
160 Reference<XPropertySet> xPropSet;
161 if (CreateField(xPropSet, sServicePrefix + GetServiceName()))
162 {
163 // set field properties
164 PrepareField(xPropSet);
165
166 // attach field to document
167 Reference<XTextContent> xTextContent(xPropSet, UNO_QUERY);
168
169 // workaround for #80606#
170 try
171 {
173 }
174 catch (const lang::IllegalArgumentException&)
175 {
176 // ignore
177 }
178 return;
179 }
180 }
181
182 // in case of error: write element content
184}
185
186void XMLTextFieldImportContext::characters(const OUString& rContent)
187{
188 sContentBuffer.append(rContent);
189}
190
192 Reference<XPropertySet> & xField,
193 const OUString& rServiceName)
194{
195 // instantiate new XTextField:
196 // ask import for model, model is factory, ask factory to create service
197
198 Reference<XMultiServiceFactory> xFactory(GetImport().GetModel(),UNO_QUERY);
199 if( xFactory.is() )
200 {
201 Reference<XInterface> xIfc = xFactory->createInstance(rServiceName);
202 if( xIfc.is() )
203 {
204 Reference<XPropertySet> xTmp( xIfc, UNO_QUERY );
205
206 xField = xTmp;
207 } else {
208 return false; // can't create instance
209 }
210 } else {
211 return false; // can't get MultiServiceFactory
212 }
213
214 return true;
215}
216
220 SvXMLImport& rImport,
222 sal_Int32 nToken)
223{
224 XMLTextFieldImportContext* pContext = nullptr;
225
226 switch (nToken)
227 {
230 case XML_ELEMENT(LO_EXT, XML_SENDER_INITIALS):
236
245 pContext =
246 new XMLSenderFieldImportContext( rImport, rHlp );
247 break;
248
251 pContext =
252 new XMLAuthorFieldImportContext( rImport, rHlp );
253 break;
254
256 pContext =
257 new XMLPlaceholderFieldImportContext( rImport, rHlp);
258 break;
260 pContext =
261 new XMLSequenceFieldImportContext( rImport, rHlp );
262 break;
264 pContext =
265 new XMLTextInputFieldImportContext( rImport, rHlp );
266 break;
268 pContext =
269 new XMLExpressionFieldImportContext( rImport, rHlp );
270 break;
272 pContext =
273 new XMLVariableSetFieldImportContext( rImport, rHlp );
274 break;
276 pContext =
277 new XMLVariableInputFieldImportContext( rImport, rHlp );
278 break;
280 pContext =
281 new XMLVariableGetFieldImportContext( rImport, rHlp );
282 break;
284 pContext = new XMLUserFieldImportContext( rImport, rHlp );
285 break;
287 pContext = new XMLUserFieldInputImportContext( rImport, rHlp );
288 break;
290 pContext = new XMLTimeFieldImportContext( rImport, rHlp );
291 break;
294 pContext = new XMLPageContinuationImportContext( rImport, rHlp );
295 break;
296
298 pContext = new XMLPageNumberImportContext( rImport, rHlp );
299 break;
300
302 pContext = new XMLDateFieldImportContext( rImport, rHlp );
303 break;
304
306 pContext = new XMLDatabaseNameImportContext( rImport, rHlp );
307 break;
309 pContext = new XMLDatabaseNextImportContext( rImport, rHlp );
310 break;
312 pContext = new XMLDatabaseSelectImportContext( rImport, rHlp );
313 break;
315 pContext = new XMLDatabaseNumberImportContext( rImport, rHlp );
316 break;
318 pContext = new XMLDatabaseDisplayImportContext( rImport, rHlp );
319 break;
321 pContext = new XMLConditionalTextImportContext( rImport, rHlp );
322 break;
324 pContext = new XMLHiddenTextImportContext( rImport, rHlp );
325 break;
327 pContext = new XMLHiddenParagraphImportContext( rImport, rHlp );
328 break;
333 pContext = new XMLSimpleDocInfoImportContext( rImport, rHlp,
334 nToken, true,
335 false );
336 break;
340 pContext = new XMLSimpleDocInfoImportContext( rImport, rHlp,
341 nToken, false,
342 true );
343 break;
344
352 pContext = new XMLDateTimeDocInfoImportContext( rImport, rHlp,
353 nToken );
354 break;
355
357 pContext = new XMLRevisionDocInfoImportContext( rImport, rHlp,
358 nToken );
359 break;
360
362 pContext = new XMLUserDocInfoImportContext( rImport, rHlp,
363 nToken );
364 break;
365
367 pContext = new XMLFileNameImportContext( rImport, rHlp );
368 break;
369
371 pContext = new XMLChapterImportContext( rImport, rHlp );
372 break;
373
375 pContext = new XMLTemplateNameImportContext( rImport, rHlp );
376 break;
377
385 pContext = new XMLCountFieldImportContext( rImport, rHlp, nToken);
386 break;
387
389 pContext = new XMLPageVarGetFieldImportContext( rImport, rHlp );
390 break;
391
393 pContext = new XMLPageVarSetFieldImportContext( rImport, rHlp );
394 break;
395
397 pContext = new XMLMacroFieldImportContext( rImport, rHlp );
398 break;
399
401 pContext = new XMLDdeFieldImportContext( rImport, rHlp );
402 break;
403
408 pContext = new XMLReferenceFieldImportContext( rImport, rHlp, nToken );
409 break;
410
412 pContext = new XMLSheetNameImportContext( rImport, rHlp );
413 break;
414
416 case XML_ELEMENT(LO_EXT, XML_PAGE_NAME):
417 pContext = new XMLPageNameFieldImportContext( rImport, rHlp );
418 break;
419
421 pContext = new XMLBibliographyFieldImportContext( rImport, rHlp );
422 break;
423
426 pContext = new XMLAnnotationImportContext( rImport, rHlp, nToken);
427 break;
428
430 pContext = new XMLScriptImportContext( rImport, rHlp);
431 break;
432
434 pContext = new XMLMeasureFieldImportContext( rImport, rHlp );
435 break;
436
438 pContext = new XMLTableFormulaImportContext( rImport, rHlp );
439 break;
441 pContext = new XMLDropDownFieldImportContext( rImport, rHlp );
442 break;
443 case XML_ELEMENT(PRESENTATION, XML_HEADER):
444 pContext = new XMLHeaderFieldImportContext( rImport, rHlp );
445 break;
446 case XML_ELEMENT(PRESENTATION, XML_FOOTER):
447 pContext = new XMLFooterFieldImportContext( rImport, rHlp );
448 break;
449 case XML_ELEMENT(PRESENTATION, XML_DATE_TIME):
450 pContext = new XMLDateTimeFieldImportContext( rImport, rHlp );
451 break;
452
453 default:
454 // ignore! May not even be a textfield.
455 // (Reminder: This method is called inside default:-branch)
456 pContext = nullptr;
457 break;
458 }
459
460 return pContext;
461}
462
463
465 const Reference<XPropertySet> & rPropertySet)
466{
467 // force update
468 Reference<XUpdatable> xUpdate(rPropertySet, UNO_QUERY);
469 if (xUpdate.is())
470 {
471 xUpdate->update();
472 }
473 else
474 {
475 OSL_FAIL("Expected XUpdatable support!");
476 }
477}
478
479
480// XMLSenderFieldImportContext
481
482
483constexpr OUStringLiteral gsPropertyFieldSubType(u"UserDataType");
484
486 SvXMLImport& rImport, XMLTextImportHelper& rHlp)
487 : XMLTextFieldImportContext(rImport, rHlp, "ExtendedUser")
488 , nSubType(0)
489 , sPropertyFixed(sAPI_is_fixed)
490 , sPropertyContent(sAPI_content)
491 , bFixed(true)
492{
493}
494
496 sal_Int32 nElement,
497 const Reference<XFastAttributeList> & xAttrList)
498{
499 bValid = true;
500 switch (nElement) {
502 nSubType = UserDataPart::FIRSTNAME;
503 break;
505 nSubType = UserDataPart::NAME;
506 break;
507 case XML_ELEMENT(LO_EXT, XML_SENDER_INITIALS):
509 nSubType = UserDataPart::SHORTCUT;
510 break;
512 nSubType = UserDataPart::TITLE;
513 break;
515 nSubType = UserDataPart::POSITION;
516 break;
518 nSubType = UserDataPart::EMAIL;
519 break;
521 nSubType = UserDataPart::PHONE_PRIVATE;
522 break;
524 nSubType = UserDataPart::FAX;
525 break;
527 nSubType = UserDataPart::COMPANY;
528 break;
530 nSubType = UserDataPart::PHONE_COMPANY;
531 break;
533 nSubType = UserDataPart::STREET;
534 break;
536 nSubType = UserDataPart::CITY;
537 break;
539 nSubType = UserDataPart::ZIP;
540 break;
542 nSubType = UserDataPart::COUNTRY;
543 break;
545 nSubType = UserDataPart::STATE;
546 break;
547 default:
548 bValid = false;
549 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
550 break;
551 }
552
553 // process Attributes
555}
556
558 sal_Int32 nAttrToken,
559 std::string_view sAttrValue)
560{
561 if (XML_ELEMENT(TEXT, XML_FIXED) == nAttrToken) {
562
563 // set bVal
564 bool bVal(false);
565 bool const bRet = ::sax::Converter::convertBool(bVal, sAttrValue);
566
567 // set bFixed if successful
568 if (bRet) {
569 bFixed = bVal;
570 }
571 }
572 else
573 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
574}
575
577 const Reference<XPropertySet> & rPropSet)
578{
579 // set members
580 rPropSet->setPropertyValue(gsPropertyFieldSubType, Any(nSubType));
581
582 // set fixed
583 rPropSet->setPropertyValue(sPropertyFixed, Any(bFixed));
584
585 // set content if fixed
586 if (!bFixed)
587 return;
588
589 // in organizer or styles-only mode: force update
590 if (GetImport().GetTextImport()->IsOrganizerMode() ||
591 GetImport().GetTextImport()->IsStylesOnlyMode() )
592 {
593 ForceUpdate(rPropSet);
594 }
595 else
596 {
597 rPropSet->setPropertyValue(sPropertyContent, Any(GetContent()));
598 }
599}
600
601
602// XMLAuthorFieldImportContext
603
604constexpr OUStringLiteral gsPropertyAuthorFullName(u"FullName");
605
607 SvXMLImport& rImport, XMLTextImportHelper& rHlp)
608: XMLSenderFieldImportContext(rImport, rHlp)
609, bAuthorFullName(true)
610, sPropertyFixed(sAPI_is_fixed)
611, sPropertyContent(sAPI_content)
612{
613 // overwrite service name from XMLSenderFieldImportContext
615}
616
618 sal_Int32 nElement,
619 const Reference<XFastAttributeList> & xAttrList)
620{
622 bValid = true;
623
624 // process Attributes
626}
627
628void XMLAuthorFieldImportContext::ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue)
629{
630 if(nAttrToken == XML_ELEMENT(TEXT, XML_FIXED))
631 {
632 bool bTmp(false);
633 if (::sax::Converter::convertBool(bTmp, sAttrValue))
634 bFixed = bTmp;
635 }
636 else
637 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
638}
639
641 const Reference<XPropertySet> & rPropSet)
642{
643 // set members
644 Any aAny;
645 rPropSet->setPropertyValue(gsPropertyAuthorFullName, Any(bAuthorFullName));
646
647 rPropSet->setPropertyValue(sPropertyFixed, Any(bFixed));
648
649 // set content if fixed
650 if (!bFixed)
651 return;
652
653 // organizer or styles-only mode: force update
654 if (GetImport().GetTextImport()->IsOrganizerMode() ||
655 GetImport().GetTextImport()->IsStylesOnlyMode() )
656 {
657 ForceUpdate(rPropSet);
658 }
659 else
660 {
661 aAny <<= GetContent();
662 rPropSet->setPropertyValue(sPropertyContent, aAny);
663 }
664}
665
666
667// page continuation string
668
669
671{
672 { XML_PREVIOUS, PageNumberType_PREV },
673 { XML_CURRENT, PageNumberType_CURRENT },
674 { XML_NEXT, PageNumberType_NEXT },
675 { XML_TOKEN_INVALID, PageNumberType(0) },
676};
677
678constexpr OUStringLiteral gsPropertyUserText(u"UserText");
679
681 SvXMLImport& rImport, XMLTextImportHelper& rHlp)
683, sPropertySubType(sAPI_sub_type)
684, sPropertyNumberingType(sAPI_numbering_type)
685, eSelectPage(PageNumberType_CURRENT)
686, sStringOK(false)
687{
688 bValid = true;
689}
690
692 sal_Int32 nAttrToken, std::string_view sAttrValue )
693{
694 switch(nAttrToken)
695 {
697 {
698 PageNumberType nTmp;
699 if (SvXMLUnitConverter::convertEnum(nTmp, sAttrValue,
701 && (PageNumberType_CURRENT != nTmp) )
702 {
703 eSelectPage = nTmp;
704 }
705 break;
706 }
709 sString = OUString::fromUtf8(sAttrValue);
710 sStringOK = true;
711 break;
712 default:
713 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
714 }
715}
716
718 const Reference<XPropertySet> & xPropertySet)
719{
720 Any aAny;
721
722 xPropertySet->setPropertyValue(sPropertySubType, Any(eSelectPage));
723
724 aAny <<= (sStringOK ? sString : GetContent());
725 xPropertySet->setPropertyValue(gsPropertyUserText, aAny);
726
727 aAny <<= style::NumberingType::CHAR_SPECIAL;
728 xPropertySet->setPropertyValue(sPropertyNumberingType, aAny);
729}
730
731
732// page number field
733
734
736 SvXMLImport& rImport, XMLTextImportHelper& rHlp)
738, sPropertySubType(sAPI_sub_type)
739, sPropertyNumberingType(sAPI_numbering_type)
740, sPropertyOffset(sAPI_offset)
741, sNumberSync(GetXMLToken(XML_FALSE))
742, nPageAdjust(0)
743, eSelectPage(PageNumberType_CURRENT)
744, sNumberFormatOK(false)
745{
746 bValid = true;
747}
748
750 sal_Int32 nAttrToken,
751 std::string_view sAttrValue )
752{
753 switch (nAttrToken)
754 {
756 sNumberFormat = OUString::fromUtf8(sAttrValue);
757 sNumberFormatOK = true;
758 break;
760 sNumberSync = OUString::fromUtf8(sAttrValue);
761 break;
765 break;
767 {
768 sal_Int32 nTmp;
769 if (::sax::Converter::convertNumber(nTmp, sAttrValue))
770 {
771 nPageAdjust = static_cast<sal_Int16>(nTmp);
772 }
773 break;
774 }
775 default:
776 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
777 }
778}
779
781 const Reference<XPropertySet> & xPropertySet)
782{
783 // all properties are optional
784 Reference<XPropertySetInfo> xPropertySetInfo(
785 xPropertySet->getPropertySetInfo());
786
787 if (xPropertySetInfo->hasPropertyByName(sPropertyNumberingType))
788 {
789 sal_Int16 nNumType;
790 if( sNumberFormatOK )
791 {
792 nNumType= style::NumberingType::ARABIC;
795 sNumberSync );
796 }
797 else
798 nNumType = style::NumberingType::PAGE_DESCRIPTOR;
799
800 xPropertySet->setPropertyValue(sPropertyNumberingType, Any(nNumType));
801 }
802
803 if (xPropertySetInfo->hasPropertyByName(sPropertyOffset))
804 {
805 // adjust offset
806 switch (eSelectPage)
807 {
808 case PageNumberType_PREV:
809 nPageAdjust--;
810 break;
811 case PageNumberType_CURRENT:
812 break;
813 case PageNumberType_NEXT:
814 nPageAdjust++;
815 break;
816 default:
817 SAL_WARN("xmloff.text", "unknown page number type");
818 }
819 xPropertySet->setPropertyValue(sPropertyOffset, Any(nPageAdjust));
820 }
821
822 if (xPropertySetInfo->hasPropertyByName(sPropertySubType))
823 {
824 xPropertySet->setPropertyValue(sPropertySubType, Any(eSelectPage));
825 }
826}
827
828
829// Placeholder
830
831
832constexpr OUStringLiteral gsPropertyPlaceholderType(u"PlaceHolderType");
833constexpr OUStringLiteral gsPropertyPlaceholder(u"PlaceHolder");
834
836 SvXMLImport& rImport, XMLTextImportHelper& rHlp)
837: XMLTextFieldImportContext(rImport, rHlp, "JumpEdit")
838, sPropertyHint(sAPI_hint)
839, nPlaceholderType(PlaceholderType::TEXT)
840{
841}
842
845 sal_Int32 nAttrToken, std::string_view sAttrValue )
846{
847 switch (nAttrToken) {
849 sDescription = OUString::fromUtf8(sAttrValue);
850 break;
851
853 bValid = true;
854 if (IsXMLToken(sAttrValue, XML_TABLE))
855 {
856 nPlaceholderType = PlaceholderType::TABLE;
857 }
858 else if (IsXMLToken(sAttrValue, XML_TEXT))
859 {
860 nPlaceholderType = PlaceholderType::TEXT;
861 }
862 else if (IsXMLToken(sAttrValue, XML_TEXT_BOX))
863 {
864 nPlaceholderType = PlaceholderType::TEXTFRAME;
865 }
866 else if (IsXMLToken(sAttrValue, XML_IMAGE))
867 {
868 nPlaceholderType = PlaceholderType::GRAPHIC;
869 }
870 else if (IsXMLToken(sAttrValue, XML_OBJECT))
871 {
872 nPlaceholderType = PlaceholderType::OBJECT;
873 }
874 else
875 {
876 bValid = false;
877 }
878 break;
879
880 default:
881 // ignore
882 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
883 }
884}
885
887 const Reference<XPropertySet> & xPropertySet) {
888
889 Any aAny;
890 xPropertySet->setPropertyValue(sPropertyHint, Any(sDescription));
891
892 // remove <...> around content (if present)
893 OUString aContent = GetContent();
894 sal_Int32 nStart = 0;
895 sal_Int32 nLength = aContent.getLength();
896 if (aContent.startsWith("<"))
897 {
898 --nLength;
899 ++nStart;
900 }
901 if (aContent.endsWith(">"))
902 {
903 --nLength;
904 }
905 aAny <<= aContent.copy(nStart, nLength);
906 xPropertySet->setPropertyValue(gsPropertyPlaceholder, aAny);
907
908 xPropertySet->setPropertyValue(gsPropertyPlaceholderType, Any(nPlaceholderType));
909}
910
911
912// time field
913
914constexpr OUStringLiteral gsPropertyAdjust(u"Adjust");
915
917 SvXMLImport& rImport, XMLTextImportHelper& rHlp)
919, sPropertyNumberFormat(sAPI_number_format)
920, sPropertyFixed(sAPI_is_fixed)
921, sPropertyDateTimeValue(sAPI_date_time_value)
922, sPropertyDateTime(sAPI_date_time)
923, sPropertyIsDate(sAPI_is_date)
924, sPropertyIsFixedLanguage(sAPI_is_fixed_language)
925, nAdjust(0)
926, nFormatKey(0)
927, bTimeOK(false)
928, bFormatOK(false)
929, bFixed(false)
930, bIsDate(false)
931, bIsDefaultLanguage( true )
932{
933 bValid = true; // always valid!
934}
935
937 sal_Int32 nAttrToken, std::string_view sAttrValue )
938{
939 switch (nAttrToken)
940 {
943 {
945 {
946 bTimeOK = true;
947 }
948 break;
949 }
951 {
952 bool bTmp(false);
953 if (::sax::Converter::convertBool(bTmp, sAttrValue))
954 {
955 bFixed = bTmp;
956 }
957 break;
958 }
960 {
961 sal_Int32 nKey = GetImportHelper().GetDataStyleKey(
962 OUString::fromUtf8(sAttrValue), &bIsDefaultLanguage);
963 if (-1 != nKey)
964 {
965 nFormatKey = nKey;
966 bFormatOK = true;
967 }
968 break;
969 }
971 {
972 double fTmp;
973
974 if (::sax::Converter::convertDuration(fTmp, sAttrValue))
975 {
976 // convert to minutes
977 nAdjust = static_cast<sal_Int32>(::rtl::math::approxFloor(fTmp * 60 * 24));
978 }
979 break;
980 }
981 default:
982 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
983 }
984}
985
987 const Reference<XPropertySet> & rPropertySet)
988{
989 // all properties are optional (except IsDate)
990 Reference<XPropertySetInfo> xPropertySetInfo(
991 rPropertySet->getPropertySetInfo());
992
993 if (xPropertySetInfo->hasPropertyByName(sPropertyFixed))
994 {
995 rPropertySet->setPropertyValue(sPropertyFixed, Any(bFixed));
996 }
997
998 rPropertySet->setPropertyValue(sPropertyIsDate, Any(bIsDate));
999
1000 if (xPropertySetInfo->hasPropertyByName(gsPropertyAdjust))
1001 {
1002 rPropertySet->setPropertyValue(gsPropertyAdjust, Any(nAdjust));
1003 }
1004
1005 // set value
1006 if (bFixed)
1007 {
1008 // organizer or styles-only mode: force update
1009 if (GetImport().GetTextImport()->IsOrganizerMode() ||
1010 GetImport().GetTextImport()->IsStylesOnlyMode() )
1011 {
1012 ForceUpdate(rPropertySet);
1013 }
1014 else
1015 {
1016 // normal mode: set value (if present)
1017 if (bTimeOK)
1018 {
1019 if (xPropertySetInfo->hasPropertyByName(sPropertyDateTimeValue))
1020 {
1021 rPropertySet->setPropertyValue(sPropertyDateTimeValue, Any(aDateTimeValue));
1022 }
1023 else if (xPropertySetInfo->hasPropertyByName(sPropertyDateTime))
1024 {
1025 rPropertySet->setPropertyValue(sPropertyDateTime, Any(aDateTimeValue));
1026 }
1027 }
1028 }
1029 }
1030
1031 if (bFormatOK &&
1032 xPropertySetInfo->hasPropertyByName(sPropertyNumberFormat))
1033 {
1034 rPropertySet->setPropertyValue(sPropertyNumberFormat, Any(nFormatKey));
1035
1036 if( xPropertySetInfo->hasPropertyByName( sPropertyIsFixedLanguage ) )
1037 {
1038 bool bIsFixedLanguage = ! bIsDefaultLanguage;
1039 rPropertySet->setPropertyValue( sPropertyIsFixedLanguage, Any(bIsFixedLanguage) );
1040 }
1041 }
1042}
1043
1044
1045// date field
1046
1047
1049 SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
1050 XMLTimeFieldImportContext(rImport, rHlp)
1051{
1052 bIsDate = true; // always a date!
1053}
1054
1056 sal_Int32 nAttrToken,
1057 std::string_view sAttrValue )
1058{
1059 switch (nAttrToken)
1060 {
1063 {
1065 {
1066 bTimeOK = true;
1067 }
1068 break;
1069 }
1071 // delegate to superclass, pretending it was a time-adjust attr.
1074 sAttrValue);
1075 break;
1079 ; // ignore time-adjust and time-value attributes
1080 break;
1081 default:
1082 // all others: delegate to super-class
1084 sAttrValue);
1085 break;
1086 }
1087}
1088
1089
1090// database field superclass
1091
1092
1093constexpr OUStringLiteral gsPropertyDataBaseName(u"DataBaseName");
1094constexpr OUStringLiteral gsPropertyDataBaseURL(u"DataBaseURL");
1095constexpr OUStringLiteral gsPropertyTableName(u"DataTableName");
1096constexpr OUStringLiteral gsPropertyDataCommandType(u"DataCommandType");
1097constexpr OUStringLiteral gsPropertyIsVisible(u"IsVisible");
1098
1100 SvXMLImport& rImport, XMLTextImportHelper& rHlp,
1101 const OUString& pServiceName, bool bUseDisplay)
1102: XMLTextFieldImportContext(rImport, rHlp, pServiceName)
1104, m_bCommandTypeOK(false)
1105, m_bDisplay( true )
1106, m_bDisplayOK( false )
1107, m_bUseDisplay( bUseDisplay )
1108, m_bDatabaseOK(false)
1109, m_bDatabaseNameOK(false)
1110, m_bDatabaseURLOK(false)
1111, m_bTableOK(false)
1112{
1113}
1114
1116 sal_Int32 nAttrToken, std::string_view sAttrValue )
1117{
1118 switch (nAttrToken)
1119 {
1121 m_sDatabaseName = OUString::fromUtf8(sAttrValue);
1122 m_bDatabaseOK = true;
1123 m_bDatabaseNameOK = true;
1124 break;
1126 m_sTableName = OUString::fromUtf8(sAttrValue);
1127 m_bTableOK = true;
1128 break;
1130 if( IsXMLToken( sAttrValue, XML_TABLE ) )
1131 {
1132 m_nCommandType = sdb::CommandType::TABLE;
1133 m_bCommandTypeOK = true;
1134 }
1135 else if( IsXMLToken( sAttrValue, XML_QUERY ) )
1136 {
1137 m_nCommandType = sdb::CommandType::QUERY;
1138 m_bCommandTypeOK = true;
1139 }
1140 else if( IsXMLToken( sAttrValue, XML_COMMAND ) )
1141 {
1142 m_nCommandType = sdb::CommandType::COMMAND;
1143 m_bCommandTypeOK = true;
1144 }
1145 break;
1147 if( IsXMLToken( sAttrValue, XML_NONE ) )
1148 {
1149 m_bDisplay = false;
1150 m_bDisplayOK = true;
1151 }
1152 else if( IsXMLToken( sAttrValue, XML_VALUE ) )
1153 {
1154 m_bDisplay = true;
1155 m_bDisplayOK = true;
1156 }
1157 break;
1158 default:
1159 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
1160 }
1161}
1162
1163css::uno::Reference< css::xml::sax::XFastContextHandler > XMLDatabaseFieldImportContext::createFastChildContext(
1164 sal_Int32 nElement,
1165 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
1166{
1167 if (nElement == XML_ELEMENT(FORM, XML_CONNECTION_RESOURCE) )
1168 {
1169 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
1170 {
1171 switch (aIter.getToken())
1172 {
1173 case XML_ELEMENT(XLINK, XML_HREF):
1174 {
1175 m_sDatabaseURL = aIter.toString();
1176 m_bDatabaseOK = true;
1177 m_bDatabaseURLOK = true;
1178 }
1179 break;
1180 default:;
1181 }
1182 }
1183
1184 // we call ProcessAttribute in order to set bValid appropriately
1186 }
1187 else
1188 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
1189
1190 return nullptr;
1191}
1192
1193
1195 const Reference<XPropertySet> & xPropertySet)
1196{
1197 xPropertySet->setPropertyValue(gsPropertyTableName, Any(m_sTableName));
1198
1199 if( m_bDatabaseNameOK )
1200 {
1201 xPropertySet->setPropertyValue(gsPropertyDataBaseName, Any(m_sDatabaseName));
1202 }
1203 else if( m_bDatabaseURLOK )
1204 {
1205 xPropertySet->setPropertyValue(gsPropertyDataBaseURL, Any(m_sDatabaseURL));
1206 }
1207
1208 // #99980# load/save command type for all fields; also load
1209 // old documents without command type
1210 if( m_bCommandTypeOK )
1211 {
1212 xPropertySet->setPropertyValue( gsPropertyDataCommandType, Any(m_nCommandType) );
1213 }
1214
1216 {
1217 xPropertySet->setPropertyValue( gsPropertyIsVisible, Any(m_bDisplay) );
1218 }
1219}
1220
1221
1222// database name field
1223
1224
1226 SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
1227 XMLDatabaseFieldImportContext(rImport, rHlp, "DatabaseName", true)
1228{
1229}
1230
1232 sal_Int32 nAttrToken, std::string_view sAttrValue )
1233{
1234 // delegate to superclass and check for success
1237}
1238
1239
1240// database next field
1241
1242
1244 SvXMLImport& rImport, XMLTextImportHelper& rHlp,
1245 const OUString& pServiceName) :
1246 XMLDatabaseFieldImportContext(rImport, rHlp, pServiceName, false),
1247 sPropertyCondition(sAPI_condition),
1248 sTrue(sAPI_true),
1249 bConditionOK(false)
1250{
1251}
1252
1254 SvXMLImport& rImport, XMLTextImportHelper& rHlp)
1255: XMLDatabaseFieldImportContext(rImport, rHlp, "DatabaseNextSet", false)
1256, sPropertyCondition(sAPI_condition)
1257, sTrue(sAPI_true)
1258, bConditionOK(false)
1259{
1260}
1261
1263 sal_Int32 nAttrToken, std::string_view sAttrValue )
1264{
1265 if (XML_ELEMENT(TEXT, XML_CONDITION) == nAttrToken)
1266 {
1267 OUString sTmp;
1268 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrValueQName(
1269 OUString::fromUtf8(sAttrValue), &sTmp );
1270 if( XML_NAMESPACE_OOOW == nPrefix )
1271 {
1272 sCondition = sTmp;
1273 bConditionOK = true;
1274 }
1275 else
1276 sCondition = OUString::fromUtf8(sAttrValue);
1277 }
1278 else
1279 {
1281 sAttrValue);
1282 }
1283
1285}
1286
1288 const Reference<XPropertySet> & xPropertySet)
1289{
1290 Any aAny;
1291
1292 aAny <<= bConditionOK ? sCondition : sTrue;
1293 xPropertySet->setPropertyValue(sPropertyCondition, aAny);
1294
1296}
1297
1298
1299// database select field
1300
1301
1303 SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
1304 XMLDatabaseNextImportContext(rImport, rHlp, "DatabaseNumberOfSet"),
1305 sPropertySetNumber(sAPI_set_number),
1306 nNumber(0),
1307 bNumberOK(false)
1308{
1309}
1310
1312 sal_Int32 nAttrToken,
1313 std::string_view sAttrValue )
1314{
1315 if (XML_ELEMENT(TEXT, XML_ROW_NUMBER) == nAttrToken)
1316 {
1317 sal_Int32 nTmp;
1318 if (::sax::Converter::convertNumber( nTmp, sAttrValue
1319 /* , nMin, nMax ??? */ ))
1320 {
1321 nNumber = nTmp;
1322 bNumberOK = true;
1323 }
1324 }
1325 else
1326 {
1327 XMLDatabaseNextImportContext::ProcessAttribute(nAttrToken, sAttrValue);
1328 }
1329
1331}
1332
1334 const Reference<XPropertySet> & xPropertySet)
1335{
1336 xPropertySet->setPropertyValue(sPropertySetNumber, Any(nNumber));
1337
1339}
1340
1341
1342// database display row number field
1343
1344
1346 SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
1347 XMLDatabaseFieldImportContext(rImport, rHlp, "DatabaseSetNumber", true),
1348 sPropertyNumberingType(
1350 sPropertySetNumber(sAPI_set_number),
1351 sNumberFormat("1"),
1352 sNumberSync(GetXMLToken(XML_FALSE)),
1353 nValue(0),
1354 bValueOK(false)
1355{
1356}
1357
1359 sal_Int32 nAttrToken,
1360 std::string_view sAttrValue )
1361{
1362 switch (nAttrToken)
1363 {
1365 sNumberFormat = OUString::fromUtf8(sAttrValue);
1366 break;
1368 sNumberSync = OUString::fromUtf8(sAttrValue);
1369 break;
1372 {
1373 sal_Int32 nTmp;
1374 if (::sax::Converter::convertNumber( nTmp, sAttrValue ))
1375 {
1376 nValue = nTmp;
1377 bValueOK = true;
1378 }
1379 break;
1380 }
1381 default:
1383 sAttrValue);
1384 break;
1385 }
1386
1388}
1389
1391 const Reference<XPropertySet> & xPropertySet)
1392{
1393 sal_Int16 nNumType = style::NumberingType::ARABIC;
1396 sNumberSync );
1397 xPropertySet->setPropertyValue(sPropertyNumberingType, Any(nNumType));
1398
1399 if (bValueOK)
1400 {
1401 xPropertySet->setPropertyValue(sPropertySetNumber, Any(nValue));
1402 }
1403
1405}
1406
1407
1408// Simple doc info fields
1409
1410
1412 SvXMLImport& rImport, XMLTextImportHelper& rHlp,
1413 sal_Int32 nElementToken,
1414 bool bContent, bool bAuthor)
1415: XMLTextFieldImportContext(rImport, rHlp, MapTokenToServiceName(nElementToken) )
1416, sPropertyFixed(sAPI_is_fixed)
1417, sPropertyContent(sAPI_content)
1418, sPropertyAuthor(sAPI_author)
1419, sPropertyCurrentPresentation(sAPI_current_presentation)
1420, bFixed(false)
1421, bHasAuthor(bAuthor)
1422, bHasContent(bContent)
1423{
1424 bValid = true;
1425}
1426
1428 sal_Int32 nAttrToken,
1429 std::string_view sAttrValue )
1430{
1431 if (XML_ELEMENT(TEXT, XML_FIXED) == nAttrToken)
1432 {
1433 bool bTmp(false);
1434 if (::sax::Converter::convertBool(bTmp, sAttrValue))
1435 {
1436 bFixed = bTmp;
1437 }
1438 }
1439 else
1440 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
1441}
1442
1444 const Reference<XPropertySet> & rPropertySet)
1445{
1446 // title field in Calc has no Fixed property
1447 Reference<XPropertySetInfo> xPropertySetInfo(rPropertySet->getPropertySetInfo());
1448 if (!xPropertySetInfo->hasPropertyByName(sPropertyFixed))
1449 return;
1450
1451 Any aAny;
1452 rPropertySet->setPropertyValue(sPropertyFixed, Any(bFixed));
1453
1454 // set Content and CurrentPresentation (if fixed)
1455 if (!bFixed)
1456 return;
1457
1458 // in organizer-mode or styles-only-mode, only force update
1459 if (GetImport().GetTextImport()->IsOrganizerMode() ||
1460 GetImport().GetTextImport()->IsStylesOnlyMode() )
1461 {
1462 ForceUpdate(rPropertySet);
1463 }
1464 else
1465 {
1466 // set content (author, if that's the name) and current
1467 // presentation
1468 aAny <<= GetContent();
1469
1470 if (bFixed && bHasAuthor)
1471 {
1472 rPropertySet->setPropertyValue(sPropertyAuthor, aAny);
1473 }
1474
1475 if (bFixed && bHasContent)
1476 {
1477 rPropertySet->setPropertyValue(sPropertyContent, aAny);
1478 }
1479
1480 rPropertySet->setPropertyValue(sPropertyCurrentPresentation, aAny);
1481 }
1482}
1483
1485 sal_Int32 nElementToken)
1486{
1487 OUString pServiceName;
1488
1489 switch(nElementToken)
1490 {
1492 pServiceName = "DocInfo.CreateAuthor";
1493 break;
1495 pServiceName = sAPI_docinfo_create_date_time;
1496 break;
1498 pServiceName = sAPI_docinfo_create_date_time;
1499 break;
1501 pServiceName = "DocInfo.Description";
1502 break;
1504 pServiceName = "DocInfo.EditTime";
1505 break;
1507 pServiceName = sAPI_docinfo_custom;
1508 break;
1510 pServiceName = "DocInfo.PrintAuthor";
1511 break;
1513 pServiceName = sAPI_docinfo_print_date_time;
1514 break;
1516 pServiceName = sAPI_docinfo_print_date_time;
1517 break;
1519 pServiceName = "DocInfo.KeyWords";
1520 break;
1522 pServiceName = "DocInfo.Subject";
1523 break;
1525 pServiceName = "DocInfo.Revision";
1526 break;
1528 pServiceName = "DocInfo.ChangeAuthor";
1529 break;
1531 pServiceName = sAPI_docinfo_change_date_time;
1532 break;
1534 pServiceName = sAPI_docinfo_change_date_time;
1535 break;
1536 case XML_ELEMENT(TEXT, XML_TITLE):
1537 pServiceName = "DocInfo.Title";
1538 break;
1539 default:
1540 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElementToken);
1541 assert(false);
1542 }
1543
1544 return pServiceName;
1545}
1546
1547
1548// revision field
1549
1550constexpr OUStringLiteral sPropertyRevision(u"Revision");
1551
1553 SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_Int32 nElement) :
1554 XMLSimpleDocInfoImportContext(rImport, rHlp, nElement, false, false)
1555{
1556 bValid = true;
1557}
1558
1560 const Reference<XPropertySet> & rPropertySet)
1561{
1563
1564 // set revision number
1565 // if fixed, if not in organizer-mode, if not in styles-only-mode
1566 if (!bFixed)
1567 return;
1568
1569 if ( GetImport().GetTextImport()->IsOrganizerMode() ||
1570 GetImport().GetTextImport()->IsStylesOnlyMode() )
1571 {
1572 ForceUpdate(rPropertySet);
1573 }
1574 else
1575 {
1576 sal_Int32 nTmp;
1578 {
1579 rPropertySet->setPropertyValue(sPropertyRevision, Any(nTmp));
1580 }
1581 }
1582}
1583
1584
1585// DocInfo fields with date/time attributes
1586
1587
1589 SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_Int32 nElement)
1590 : XMLSimpleDocInfoImportContext(rImport, rHlp, nElement, false, false)
1591 , sPropertyNumberFormat(sAPI_number_format)
1592 , sPropertyIsDate(sAPI_is_date)
1593 , sPropertyIsFixedLanguage(sAPI_is_fixed_language)
1594 , nFormat(0)
1595 , bFormatOK(false)
1596 , bIsDate(false)
1597 , bHasDateTime(false)
1598 , bIsDefaultLanguage(true)
1599{
1600 // we allow processing of EDIT_DURATION here, because import of actual
1601 // is not supported anyway. If it was, we'd need an extra import class
1602 // because times and time durations are presented differently!
1603
1604 bValid = true;
1605 switch (nElement)
1606 {
1610 bIsDate = true;
1611 bHasDateTime = true;
1612 break;
1616 bIsDate = false;
1617 bHasDateTime = true;
1618 break;
1620 bIsDate = false;
1621 bHasDateTime = false;
1622 break;
1623 default:
1624 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
1625 OSL_FAIL("XMLDateTimeDocInfoImportContext needs date/time doc. fields");
1626 bValid = false;
1627 break;
1628 }
1629}
1630
1632 sal_Int32 nAttrToken,
1633 std::string_view sAttrValue )
1634{
1635 switch (nAttrToken)
1636 {
1638 {
1639 sal_Int32 nKey = GetImportHelper().GetDataStyleKey(
1640 OUString::fromUtf8(sAttrValue), &bIsDefaultLanguage);
1641 if (-1 != nKey)
1642 {
1643 nFormat = nKey;
1644 bFormatOK = true;
1645 }
1646 break;
1647 }
1648 case XML_ELEMENT(TEXT, XML_FIXED):
1650 sAttrValue);
1651 break;
1652 default:
1653 // ignore -> we can't set date/time value anyway!
1654 break;
1655 }
1656}
1657
1659 const Reference<XPropertySet> & xPropertySet)
1660{
1661 // process fixed and presentation
1663
1664 if (bHasDateTime)
1665 {
1666 xPropertySet->setPropertyValue(sPropertyIsDate, Any(bIsDate));
1667 }
1668
1669 if (bFormatOK)
1670 {
1671 xPropertySet->setPropertyValue(sPropertyNumberFormat, Any(nFormat));
1672
1673 if( xPropertySet->getPropertySetInfo()->
1674 hasPropertyByName( sPropertyIsFixedLanguage ) )
1675 {
1676 bool bIsFixedLanguage = ! bIsDefaultLanguage;
1677 xPropertySet->setPropertyValue( sPropertyIsFixedLanguage, Any(bIsFixedLanguage) );
1678 }
1679 }
1680
1681 // can't set date/time/duration value! Sorry.
1682}
1683
1684
1685// user defined docinfo fields
1686
1687
1689 SvXMLImport& rImport, XMLTextImportHelper& rHlp,
1690 sal_Int32 nElement) :
1691 XMLSimpleDocInfoImportContext(rImport, rHlp, nElement, false, false)
1692 , sPropertyName(sAPI_name)
1693 , sPropertyNumberFormat(sAPI_number_format)
1694 , sPropertyIsFixedLanguage(sAPI_is_fixed_language)
1695 , nFormat(0)
1696 , bFormatOK(false)
1697 , bIsDefaultLanguage( true )
1698{
1699 bValid = false;
1700}
1701
1703 sal_Int32 nAttrToken,
1704 std::string_view sAttrValue )
1705{
1706 switch (nAttrToken)
1707 {
1709 {
1710 sal_Int32 nKey = GetImportHelper().GetDataStyleKey(
1711 OUString::fromUtf8(sAttrValue), &bIsDefaultLanguage);
1712 if (-1 != nKey)
1713 {
1714 nFormat = nKey;
1715 bFormatOK = true;
1716 }
1717 break;
1718 }
1719 case XML_ELEMENT(TEXT, XML_NAME):
1720 {
1721 if (!bValid)
1722 {
1724 aName = OUString::fromUtf8(sAttrValue);
1725 bValid = true;
1726 }
1727 break;
1728 }
1729
1730 default:
1732 sAttrValue);
1733 break;
1734 }
1735}
1736
1738 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet)
1739{
1740 if ( !aName.isEmpty() )
1741 {
1742 xPropertySet->setPropertyValue(sPropertyName, Any(aName));
1743 }
1744 Reference<XPropertySetInfo> xPropertySetInfo(
1745 xPropertySet->getPropertySetInfo());
1746 if (bFormatOK &&
1747 xPropertySetInfo->hasPropertyByName(sPropertyNumberFormat))
1748 {
1749 xPropertySet->setPropertyValue(sPropertyNumberFormat, Any(nFormat));
1750
1751 if( xPropertySetInfo->hasPropertyByName( sPropertyIsFixedLanguage ) )
1752 {
1753 bool bIsFixedLanguage = ! bIsDefaultLanguage;
1754 xPropertySet->setPropertyValue( sPropertyIsFixedLanguage, Any(bIsFixedLanguage) );
1755 }
1756 }
1757
1758 // call superclass to handle "fixed"
1760}
1761
1762
1763// import hidden paragraph fields
1764
1765
1767 SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
1768 XMLTextFieldImportContext(rImport, rHlp, "HiddenParagraph"),
1769 sPropertyCondition(sAPI_condition),
1770 sPropertyIsHidden(sAPI_is_hidden),
1771 bIsHidden(false)
1772{
1773}
1774
1776 sal_Int32 nAttrToken,
1777 std::string_view sAttrValue )
1778{
1779 if ( XML_ELEMENT(TEXT, XML_CONDITION) == nAttrToken)
1780 {
1781 OUString sTmp;
1782 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrValueQName(
1783 OUString::fromUtf8(sAttrValue), &sTmp );
1784 if( XML_NAMESPACE_OOOW == nPrefix )
1785 {
1786 sCondition = sTmp;
1787 bValid = true;
1788 }
1789 else
1790 sCondition = OUString::fromUtf8(sAttrValue);
1791 }
1792 else if ( XML_ELEMENT(TEXT, XML_IS_HIDDEN) == nAttrToken)
1793 {
1794 bool bTmp(false);
1795 if (::sax::Converter::convertBool(bTmp, sAttrValue))
1796 {
1797 bIsHidden = bTmp;
1798 }
1799 }
1800 else
1801 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
1802}
1803
1805 const Reference<XPropertySet> & xPropertySet)
1806{
1807 xPropertySet->setPropertyValue(sPropertyCondition, Any(sCondition));
1808 xPropertySet->setPropertyValue(sPropertyIsHidden, Any(bIsHidden));
1809}
1810
1811
1812// import conditional text (<text:conditional-text>)
1813
1814constexpr OUStringLiteral gsPropertyTrueContent(u"TrueContent");
1815constexpr OUStringLiteral gsPropertyFalseContent(u"FalseContent");
1816constexpr OUStringLiteral gsPropertyIsConditionTrue(u"IsConditionTrue");
1817
1819 SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
1820 XMLTextFieldImportContext(rImport, rHlp, "ConditionalText"),
1821 sPropertyCondition(sAPI_condition),
1822 sPropertyCurrentPresentation(sAPI_current_presentation),
1823 bConditionOK(false),
1824 bTrueOK(false),
1825 bFalseOK(false),
1826 bCurrentValue(false)
1827{
1828}
1829
1831 sal_Int32 nAttrToken,
1832 std::string_view sAttrValue )
1833{
1834 switch (nAttrToken)
1835 {
1837 {
1838 OUString sTmp;
1839 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
1840 GetKeyByAttrValueQName(OUString::fromUtf8(sAttrValue), &sTmp);
1841 if( XML_NAMESPACE_OOOW == nPrefix )
1842 {
1843 sCondition = sTmp;
1844 bConditionOK = true;
1845 }
1846 else
1847 sCondition = OUString::fromUtf8(sAttrValue);
1848 }
1849 break;
1851 sFalseContent = OUString::fromUtf8(sAttrValue);
1852 bFalseOK = true;
1853 break;
1855 sTrueContent = OUString::fromUtf8(sAttrValue);
1856 bTrueOK = true;
1857 break;
1859 {
1860 bool bTmp(false);
1861 if (::sax::Converter::convertBool(bTmp, sAttrValue))
1862 {
1863 bCurrentValue = bTmp;
1864 }
1865 break;
1866 }
1867 default:
1868 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
1869 }
1870
1872}
1873
1875 const Reference<XPropertySet> & xPropertySet)
1876{
1877 xPropertySet->setPropertyValue(sPropertyCondition, Any(sCondition));
1878 xPropertySet->setPropertyValue(gsPropertyFalseContent, Any(sFalseContent));
1879 xPropertySet->setPropertyValue(gsPropertyTrueContent, Any(sTrueContent));
1880 xPropertySet->setPropertyValue(gsPropertyIsConditionTrue, Any(bCurrentValue));
1881 xPropertySet->setPropertyValue(sPropertyCurrentPresentation, Any(GetContent()));
1882}
1883
1884
1885// hidden text
1886
1887
1889 SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
1890 XMLTextFieldImportContext(rImport, rHlp, "HiddenText"),
1891 sPropertyCondition(sAPI_condition),
1892 sPropertyContent(sAPI_content),
1893 sPropertyIsHidden(sAPI_is_hidden),
1894 bConditionOK(false),
1895 bStringOK(false),
1896 bIsHidden(false)
1897{
1898}
1899
1901 sal_Int32 nAttrToken,
1902 std::string_view sAttrValue )
1903{
1904 switch (nAttrToken)
1905 {
1907 {
1908 OUString sTmp;
1909 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
1910 GetKeyByAttrValueQName(OUString::fromUtf8(sAttrValue), &sTmp);
1911 if( XML_NAMESPACE_OOOW == nPrefix )
1912 {
1913 sCondition = sTmp;
1914 bConditionOK = true;
1915 }
1916 else
1917 sCondition = OUString::fromUtf8(sAttrValue);
1918 }
1919 break;
1922 sString = OUString::fromUtf8(sAttrValue);
1923 bStringOK = true;
1924 break;
1926 {
1927 bool bTmp(false);
1928 if (::sax::Converter::convertBool(bTmp, sAttrValue))
1929 {
1930 bIsHidden = bTmp;
1931 }
1932 break;
1933 }
1934 default:
1935 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
1936 }
1937
1939}
1940
1942 const Reference<XPropertySet> & xPropertySet)
1943{
1944 xPropertySet->setPropertyValue(sPropertyCondition, Any(sCondition));
1945 xPropertySet->setPropertyValue(sPropertyContent, Any(sString));
1946 xPropertySet->setPropertyValue(sPropertyIsHidden, Any(bIsHidden));
1947}
1948
1949
1950// file name fields
1951
1952
1954{
1955 { XML_PATH, FilenameDisplayFormat::PATH },
1956 { XML_NAME, FilenameDisplayFormat::NAME },
1957 { XML_NAME_AND_EXTENSION, FilenameDisplayFormat::NAME_AND_EXT },
1958 { XML_FULL, FilenameDisplayFormat::FULL },
1959 { XML_TOKEN_INVALID, 0 }
1960};
1961
1963 SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
1964 XMLTextFieldImportContext(rImport, rHlp, "FileName"),
1965 sPropertyFixed(sAPI_is_fixed),
1966 sPropertyFileFormat(sAPI_file_format),
1967 sPropertyCurrentPresentation(
1969 nFormat(FilenameDisplayFormat::FULL),
1970 bFixed(false)
1971{
1972 bValid = true;
1973}
1974
1976 sal_Int32 nAttrToken,
1977 std::string_view sAttrValue )
1978{
1979 switch (nAttrToken)
1980 {
1981 case XML_ELEMENT(TEXT, XML_FIXED):
1982 {
1983 bool bTmp(false);
1984 if (::sax::Converter::convertBool(bTmp, sAttrValue))
1985 {
1986 bFixed = bTmp;
1987 }
1988 break;
1989 }
1991 {
1992 sal_uInt16 nTmp;
1993 if (SvXMLUnitConverter::convertEnum(nTmp, sAttrValue,
1995 {
1996 nFormat = nTmp;
1997 }
1998 break;
1999 }
2000 default:
2001 // unknown attribute: ignore
2002 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
2003 break;
2004 }
2005}
2006
2008 const Reference<XPropertySet> & xPropertySet)
2009{
2010 // properties are optional
2011 Reference<XPropertySetInfo> xPropertySetInfo(
2012 xPropertySet->getPropertySetInfo());
2013
2014 if (xPropertySetInfo->hasPropertyByName(sPropertyFixed))
2015 {
2016 xPropertySet->setPropertyValue(sPropertyFixed, Any(bFixed));
2017 }
2018
2019 if (xPropertySetInfo->hasPropertyByName(sPropertyFileFormat))
2020 {
2021 xPropertySet->setPropertyValue(sPropertyFileFormat, Any(nFormat));
2022 }
2023
2024 if (xPropertySetInfo->hasPropertyByName(sPropertyCurrentPresentation))
2025 {
2026 xPropertySet->setPropertyValue(sPropertyCurrentPresentation, Any(GetContent()));
2027 }
2028}
2029
2030
2031// template name field
2032
2033
2035{
2036 { XML_FULL, TemplateDisplayFormat::FULL },
2037 { XML_PATH, TemplateDisplayFormat::PATH },
2038 { XML_NAME, TemplateDisplayFormat::NAME },
2039 { XML_NAME_AND_EXTENSION, TemplateDisplayFormat::NAME_AND_EXT },
2040 { XML_AREA, TemplateDisplayFormat::AREA },
2041 { XML_TITLE, TemplateDisplayFormat::TITLE },
2042 { XML_TOKEN_INVALID, 0 }
2043};
2044
2045
2047 SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
2048 XMLTextFieldImportContext(rImport, rHlp, "TemplateName"),
2049 sPropertyFileFormat(sAPI_file_format),
2050 nFormat(TemplateDisplayFormat::FULL)
2051{
2052 bValid = true;
2053}
2054
2056 sal_Int32 nAttrToken,
2057 std::string_view sAttrValue )
2058{
2059 switch (nAttrToken)
2060 {
2062 {
2063 sal_uInt16 nTmp;
2064 if (SvXMLUnitConverter::convertEnum(nTmp, sAttrValue,
2066 {
2067 nFormat = nTmp;
2068 }
2069 break;
2070 }
2071 default:
2072 // unknown attribute: ignore
2073 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
2074 break;
2075 }
2076}
2077
2079 const Reference<XPropertySet> & xPropertySet)
2080{
2081 xPropertySet->setPropertyValue(sPropertyFileFormat, Any(nFormat));
2082}
2083
2084
2085// import chapter fields
2086
2087
2089{
2090 { XML_NAME, ChapterFormat::NAME },
2091 { XML_NUMBER, ChapterFormat::NUMBER },
2092 { XML_NUMBER_AND_NAME, ChapterFormat::NAME_NUMBER },
2093 { XML_PLAIN_NUMBER_AND_NAME, ChapterFormat::NO_PREFIX_SUFFIX },
2094 { XML_PLAIN_NUMBER, ChapterFormat::DIGIT },
2095 { XML_TOKEN_INVALID, 0 }
2096};
2097
2098constexpr OUStringLiteral gsPropertyChapterFormat(u"ChapterFormat");
2099constexpr OUStringLiteral gsPropertyLevel(u"Level");
2100
2102 SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
2103 XMLTextFieldImportContext(rImport, rHlp, "Chapter"),
2104 nFormat(ChapterFormat::NAME_NUMBER),
2105 nLevel(0)
2106{
2107 bValid = true;
2108}
2109
2111 sal_Int32 nAttrToken,
2112 std::string_view sAttrValue )
2113{
2114 switch (nAttrToken)
2115 {
2117 {
2118 sal_uInt16 nTmp;
2119 if (SvXMLUnitConverter::convertEnum(nTmp, sAttrValue,
2121 {
2122 nFormat = static_cast<sal_Int16>(nTmp);
2123 }
2124 break;
2125 }
2127 {
2128 sal_Int32 nTmp;
2130 nTmp, sAttrValue, 1,
2131 GetImport().GetTextImport()->GetChapterNumbering()->getCount()
2132 ))
2133 {
2134 // API numbers 0..9, we number 1..10
2135 nLevel = static_cast<sal_Int8>(nTmp);
2136 nLevel--;
2137 }
2138 break;
2139 }
2140 default:
2141 // unknown attribute: ignore
2142 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
2143 break;
2144 }
2145}
2146
2148 const Reference<XPropertySet> & xPropertySet)
2149{
2150 xPropertySet->setPropertyValue(gsPropertyChapterFormat, Any(nFormat));
2151 xPropertySet->setPropertyValue(gsPropertyLevel, Any(nLevel));
2152}
2153
2154
2155// counting fields
2156
2157
2159 SvXMLImport& rImport, XMLTextImportHelper& rHlp,
2160 sal_Int32 nElement) :
2161 XMLTextFieldImportContext(rImport, rHlp, MapTokenToServiceName(nElement)),
2162 sPropertyNumberingType(
2164 bNumberFormatOK(false)
2165{
2166 bValid = true;
2167}
2168
2170 sal_Int32 nAttrToken,
2171 std::string_view sAttrValue )
2172{
2173 switch (nAttrToken)
2174 {
2176 sNumberFormat = OUString::fromUtf8(sAttrValue);
2177 bNumberFormatOK = true;
2178 break;
2180 sLetterSync = OUString::fromUtf8(sAttrValue);
2181 break;
2182 default:
2183 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
2184 }
2185}
2186
2188 const Reference<XPropertySet> & xPropertySet)
2189{
2190 // properties optional
2191 // (only page count, but do for all to save common implementation)
2192
2193 if (!xPropertySet->getPropertySetInfo()->
2194 hasPropertyByName(sPropertyNumberingType))
2195 return;
2196
2197 sal_Int16 nNumType;
2198 if( bNumberFormatOK )
2199 {
2200 nNumType= style::NumberingType::ARABIC;
2203 sLetterSync );
2204 }
2205 else
2206 nNumType = style::NumberingType::PAGE_DESCRIPTOR;
2207 xPropertySet->setPropertyValue(sPropertyNumberingType, Any(nNumType));
2208}
2209
2211 sal_Int32 nElement)
2212{
2213 OUString pServiceName;
2214
2215 switch (nElement)
2216 {
2218 pServiceName = "WordCount";
2219 break;
2221 pServiceName = "ParagraphCount";
2222 break;
2224 pServiceName = "TableCount";
2225 break;
2227 pServiceName = "CharacterCount";
2228 break;
2230 pServiceName = "GraphicObjectCount";
2231 break;
2233 pServiceName = "EmbeddedObjectCount";
2234 break;
2236 pServiceName = "PageCount";
2237 break;
2238 default:
2239 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
2240 assert(false);
2241 }
2242
2243 return pServiceName;
2244}
2245
2246
2247// page variable import
2248
2249
2251 SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
2252 XMLTextFieldImportContext(rImport, rHlp, "ReferencePageGet"),
2253 bNumberFormatOK(false)
2254{
2255 bValid = true;
2256}
2257
2259 sal_Int32 nAttrToken,
2260 std::string_view sAttrValue )
2261{
2262 switch (nAttrToken)
2263 {
2265 sNumberFormat = OUString::fromUtf8(sAttrValue);
2266 bNumberFormatOK = true;
2267 break;
2269 sLetterSync = OUString::fromUtf8(sAttrValue);
2270 break;
2271 default:
2272 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
2273 }
2274}
2275
2277 const Reference<XPropertySet> & xPropertySet)
2278{
2279 sal_Int16 nNumType;
2280 if( bNumberFormatOK )
2281 {
2282 nNumType= style::NumberingType::ARABIC;
2285 sLetterSync );
2286 }
2287 else
2288 nNumType = style::NumberingType::PAGE_DESCRIPTOR;
2289 xPropertySet->setPropertyValue(sAPI_numbering_type, Any(nNumType));
2290
2291 // display old content (#96657#)
2292 xPropertySet->setPropertyValue( sAPI_current_presentation, Any(GetContent()) );
2293}
2294
2295
2296// page variable set fields
2297
2298
2300 SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
2301 XMLTextFieldImportContext(rImport, rHlp, "ReferencePageSet"),
2302 nAdjust(0),
2303 bActive(true)
2304{
2305 bValid = true;
2306}
2307
2309 sal_Int32 nAttrToken,
2310 std::string_view sAttrValue )
2311{
2312 switch (nAttrToken)
2313 {
2315 {
2316 bool bTmp(false);
2317 if (::sax::Converter::convertBool(bTmp, sAttrValue))
2318 {
2319 bActive = bTmp;
2320 }
2321 break;
2322 }
2324 {
2325 sal_Int32 nTmp(0);
2326 if (::sax::Converter::convertNumber(nTmp, sAttrValue))
2327 {
2328 nAdjust = static_cast<sal_Int16>(nTmp);
2329 }
2330 break;
2331 }
2332 default:
2333 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
2334 break;
2335 }
2336}
2337
2339 const Reference<XPropertySet> & xPropertySet)
2340{
2341 xPropertySet->setPropertyValue("On", Any(bActive));
2342 xPropertySet->setPropertyValue(sAPI_offset, Any(nAdjust));
2343}
2344
2345
2346// macro fields
2347
2348
2350 SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
2351 XMLTextFieldImportContext(rImport, rHlp, "Macro"),
2352 bDescriptionOK(false)
2353{
2354}
2355
2356css::uno::Reference< css::xml::sax::XFastContextHandler > XMLMacroFieldImportContext::createFastChildContext(
2357 sal_Int32 nElement,
2358 const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
2359{
2360 if ( nElement == XML_ELEMENT(OFFICE, XML_EVENT_LISTENERS) )
2361 {
2362 // create events context and remember it!
2364 bValid = true;
2365 return xEventContext;
2366 }
2367 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
2368
2369 return nullptr;
2370}
2371
2373 sal_Int32 nAttrToken,
2374 std::string_view sAttrValue )
2375{
2376 switch (nAttrToken)
2377 {
2379 sDescription = OUString::fromUtf8(sAttrValue);
2380 bDescriptionOK = true;
2381 break;
2382 case XML_ELEMENT(TEXT, XML_NAME):
2383 sMacro = OUString::fromUtf8(sAttrValue);
2384 bValid = true;
2385 break;
2386 default:
2387 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
2388 }
2389}
2390
2392 const Reference<XPropertySet> & xPropertySet)
2393{
2394 Any aAny;
2395 aAny <<= (bDescriptionOK ? sDescription : GetContent());
2396 xPropertySet->setPropertyValue(sAPI_hint, aAny);
2397
2398 // if we have an events child element, we'll look for the OnClick
2399 // event if not, it may be an old (pre-638i) document. Then, we'll
2400 // have to look at the name attribute.
2401 OUString sMacroName;
2402 OUString sLibraryName;
2403 OUString sScriptURL;
2404
2405 if ( xEventContext.is() )
2406 {
2407 // get event sequence
2408 XMLEventsImportContext* pEvents = xEventContext.get();
2409 Sequence<PropertyValue> aValues;
2410 pEvents->GetEventSequence( "OnClick", aValues );
2411
2412 for( const auto& rValue : std::as_const(aValues) )
2413 {
2414 if ( rValue.Name == "ScriptType" )
2415 {
2416 // ignore ScriptType
2417 }
2418 else if ( rValue.Name == "Library" )
2419 {
2420 rValue.Value >>= sLibraryName;
2421 }
2422 else if ( rValue.Name == "MacroName" )
2423 {
2424 rValue.Value >>= sMacroName;
2425 }
2426 if ( rValue.Name == "Script" )
2427 {
2428 rValue.Value >>= sScriptURL;
2429 }
2430 }
2431 }
2432 else
2433 {
2434 // disassemble old-style macro-name: Everything before the
2435 // third-last dot is the library
2436 sal_Int32 nPos = sMacro.getLength() + 1; // the loop starts with nPos--
2437 const sal_Unicode* pBuf = sMacro.getStr();
2438 for( sal_Int32 i = 0; (i < 3) && (nPos > 0); i++ )
2439 {
2440 nPos--;
2441 while ( (pBuf[nPos] != '.') && (nPos > 0) )
2442 nPos--;
2443 }
2444
2445 if (nPos > 0)
2446 {
2447 sLibraryName = sMacro.copy(0, nPos);
2448 sMacroName = sMacro.copy(nPos+1);
2449 }
2450 else
2452 }
2453
2454 xPropertySet->setPropertyValue("ScriptURL", Any(sScriptURL));
2455 xPropertySet->setPropertyValue("MacroName", Any(sMacroName));
2456 xPropertySet->setPropertyValue("MacroLibrary", Any(sLibraryName));
2457}
2458
2459
2460// reference field import
2461
2462
2464 SvXMLImport& rImport, XMLTextImportHelper& rHlp,
2465 sal_Int32 nToken)
2466: XMLTextFieldImportContext(rImport, rHlp, "GetReference")
2467, nElementToken(nToken)
2468, nSource(0)
2469, nType(ReferenceFieldPart::PAGE_DESC)
2470, bNameOK(false)
2471, bTypeOK(false)
2472{
2473}
2474
2476{
2477 { XML_PAGE, ReferenceFieldPart::PAGE},
2478 { XML_CHAPTER, ReferenceFieldPart::CHAPTER },
2479 { XML_TEXT, ReferenceFieldPart::TEXT },
2480 { XML_DIRECTION, ReferenceFieldPart::UP_DOWN },
2481 { XML_CATEGORY_AND_VALUE, ReferenceFieldPart::CATEGORY_AND_NUMBER },
2482 { XML_CAPTION, ReferenceFieldPart::ONLY_CAPTION },
2483 { XML_VALUE, ReferenceFieldPart::ONLY_SEQUENCE_NUMBER },
2484 // Core implementation for direct cross-references (#i81002#)
2485 { XML_NUMBER, ReferenceFieldPart::NUMBER },
2486 { XML_NUMBER_NO_SUPERIOR, ReferenceFieldPart::NUMBER_NO_CONTEXT },
2487 { XML_NUMBER_ALL_SUPERIOR, ReferenceFieldPart::NUMBER_FULL_CONTEXT },
2488 { XML_TOKEN_INVALID, 0 }
2489};
2490
2492 sal_Int32 nElement,
2493 const Reference<XFastAttributeList> & xAttrList)
2494{
2495 bTypeOK = true;
2496 switch (nElementToken)
2497 {
2499 nSource = ReferenceFieldSource::REFERENCE_MARK;
2500 break;
2502 nSource = ReferenceFieldSource::BOOKMARK;
2503 break;
2505 nSource = ReferenceFieldSource::FOOTNOTE;
2506 break;
2508 nSource = ReferenceFieldSource::SEQUENCE_FIELD;
2509 break;
2510 default:
2512 bTypeOK = false;
2513 break;
2514 }
2515
2517}
2518
2519
2521 sal_Int32 nAttrToken,
2522 std::string_view sAttrValue )
2523{
2524 switch (nAttrToken)
2525 {
2527 if( IsXMLToken( sAttrValue, XML_ENDNOTE ) )
2528 nSource = ReferenceFieldSource::ENDNOTE;
2529 break;
2531 sName = OUString::fromUtf8(sAttrValue);
2532 bNameOK = true;
2533 break;
2535 {
2536 sal_uInt16 nToken;
2539 {
2540 nType = nToken;
2541 }
2542
2543 // check for sequence-only-attributes
2545 ( (nType == ReferenceFieldPart::CATEGORY_AND_NUMBER) ||
2546 (nType == ReferenceFieldPart::ONLY_CAPTION) ||
2547 (nType == ReferenceFieldPart::ONLY_SEQUENCE_NUMBER) ) )
2548 {
2549 nType = ReferenceFieldPart::PAGE_DESC;
2550 }
2551
2552 break;
2553 }
2554 case XML_ELEMENT(LO_EXT, XML_REFERENCE_LANGUAGE):
2556 sLanguage = OUString::fromUtf8(sAttrValue);
2557 break;
2558 default:
2559 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
2560 }
2561
2562 // bValid: we need proper element type and name
2563 bValid = bTypeOK && bNameOK;
2564}
2565
2567 const Reference<XPropertySet> & xPropertySet)
2568{
2569 xPropertySet->setPropertyValue("ReferenceFieldPart", Any(nType));
2570
2571 xPropertySet->setPropertyValue("ReferenceFieldSource", Any(nSource));
2572
2573 xPropertySet->setPropertyValue("ReferenceFieldLanguage", Any(sLanguage));
2574 switch (nElementToken)
2575 {
2578 xPropertySet->setPropertyValue("SourceName", Any(sName));
2579 break;
2580
2583 break;
2584
2587 break;
2588 }
2589
2590 xPropertySet->setPropertyValue(sAPI_current_presentation, Any(GetContent()));
2591}
2592
2593
2594// field declarations container
2595
2597 SvXMLImportContext(rImport)
2598{
2599}
2600
2601css::uno::Reference< css::xml::sax::XFastContextHandler > XMLDdeFieldDeclsImportContext::createFastChildContext(
2602 sal_Int32 nElement,
2603 const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
2604{
2605 if ( nElement == XML_ELEMENT(TEXT, XML_DDE_CONNECTION_DECL) )
2606 {
2608 }
2609 else
2610 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
2611 return nullptr;
2612}
2613
2614
2615// import dde field declaration
2616
2617
2619: SvXMLImportContext(rImport)
2620{
2621}
2622
2624 sal_Int32 /*nElement*/,
2625 const Reference<XFastAttributeList> & xAttrList)
2626{
2627 OUString sName;
2628 OUString sCommandApplication;
2629 OUString sCommandTopic;
2630 OUString sCommandItem;
2631
2632 bool bUpdate = false;
2633 bool bNameOK = false;
2634 bool bCommandApplicationOK = false;
2635 bool bCommandTopicOK = false;
2636 bool bCommandItemOK = false;
2637
2638 // process attributes
2639 for( auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ) )
2640 {
2641 switch (aIter.getToken())
2642 {
2644 sName = aIter.toString();
2645 bNameOK = true;
2646 break;
2648 sCommandApplication = aIter.toString();
2649 bCommandApplicationOK = true;
2650 break;
2652 sCommandTopic = aIter.toString();
2653 bCommandTopicOK = true;
2654 break;
2656 sCommandItem = aIter.toString();
2657 bCommandItemOK = true;
2658 break;
2660 {
2661 bool bTmp(false);
2662 if (::sax::Converter::convertBool(bTmp, aIter.toView()) )
2663 {
2664 bUpdate = bTmp;
2665 }
2666 break;
2667 }
2668 default:
2669 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
2670 }
2671 }
2672
2673 // valid data?
2674 if (!(bNameOK && bCommandApplicationOK && bCommandTopicOK && bCommandItemOK))
2675 return;
2676
2677 // create DDE TextFieldMaster
2678 Reference<XMultiServiceFactory> xFactory(GetImport().GetModel(),
2679 UNO_QUERY);
2680 if( !xFactory.is() )
2681 return;
2682
2683 /* #i6432# There might be multiple occurrences of one DDE
2684 declaration if it is used in more than one of
2685 header/footer/body. createInstance will throw an exception if we
2686 try to create the second, third, etc. instance of such a
2687 declaration. Thus we ignore the exception. Otherwise this will
2688 lead to an unloadable document. */
2689 try
2690 {
2691 Reference<XInterface> xIfc =
2692 xFactory->createInstance(OUString::Concat(sAPI_fieldmaster_prefix) + sAPI_dde);
2693 if( xIfc.is() )
2694 {
2695 Reference<XPropertySet> xPropSet( xIfc, UNO_QUERY );
2696 if (xPropSet.is() &&
2697 xPropSet->getPropertySetInfo()->hasPropertyByName(
2698 "DDECommandType"))
2699 {
2700 xPropSet->setPropertyValue(sAPI_name, Any(sName));
2701
2702 xPropSet->setPropertyValue("DDECommandType", Any(sCommandApplication));
2703
2704 xPropSet->setPropertyValue("DDECommandFile", Any(sCommandTopic));
2705
2706 xPropSet->setPropertyValue("DDECommandElement",
2707 Any(sCommandItem));
2708
2709 xPropSet->setPropertyValue("IsAutomaticUpdate",
2710 Any(bUpdate));
2711 }
2712 // else: ignore (can't get XPropertySet, or DDE
2713 // properties are not supported)
2714 }
2715 // else: ignore
2716 }
2717 catch (const Exception&)
2718 {
2719 //ignore
2720 }
2721 // else: ignore
2722 // else: ignore
2723}
2724
2725
2726// DDE field import
2727
2728
2730 SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
2731 XMLTextFieldImportContext(rImport, rHlp, sAPI_dde),
2732 sPropertyContent(sAPI_content)
2733{
2734}
2735
2737 sal_Int32 nAttrToken,
2738 std::string_view sAttrValue )
2739{
2740 if ( XML_ELEMENT(TEXT, XML_CONNECTION_NAME) == nAttrToken)
2741 {
2742 sName = OUString::fromUtf8(sAttrValue);
2743 bValid = true;
2744 }
2745 else
2746 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
2747}
2748
2749
2751{
2752 if (!bValid)
2753 return;
2754
2755 // find master
2756 OUString sMasterName = OUString::Concat(sAPI_fieldmaster_prefix) + sAPI_dde + "." + sName;
2757
2758 Reference<XTextFieldsSupplier> xTextFieldsSupp(GetImport().GetModel(),
2759 UNO_QUERY);
2760 Reference<container::XNameAccess> xFieldMasterNameAccess =
2761 xTextFieldsSupp->getTextFieldMasters();
2762
2763 if (!xFieldMasterNameAccess->hasByName(sMasterName))
2764 return;
2765
2766 Reference<XPropertySet> xMaster;
2767 Any aAny = xFieldMasterNameAccess->getByName(sMasterName);
2768 aAny >>= xMaster;
2769 //apply the content to the master
2770 xMaster->setPropertyValue( sPropertyContent, uno::Any( GetContent()));
2771 // master exists: create text field and attach
2772 Reference<XPropertySet> xField;
2773 OUString sFieldName = OUString::Concat(sAPI_textfield_prefix) + sAPI_dde;
2774 if (!CreateField(xField, sFieldName))
2775 return;
2776
2777 Reference<XDependentTextField> xDepTextField(xField,UNO_QUERY);
2778 xDepTextField->attachTextFieldMaster(xMaster);
2779
2780 // attach field to document
2781 Reference<XTextContent> xTextContent(xField, UNO_QUERY);
2782 if (xTextContent.is())
2783 {
2784 GetImportHelper().InsertTextContent(xTextContent);
2785
2786 // we're lucky. nothing else to prepare.
2787 }
2788 // else: fail, because text content could not be created
2789 // else: fail, because field could not be created
2790 // else: fail, because no master was found (faulty document?!)
2791 // not valid: ignore
2792}
2793
2795 const Reference<XPropertySet> &)
2796{
2797 // empty, since not needed.
2798}
2799
2800
2801// sheet name fields
2802
2803
2805 SvXMLImport& rImport,
2806 XMLTextImportHelper& rHlp) :
2807 XMLTextFieldImportContext(rImport, rHlp, "SheetName")
2808{
2809 bValid = true; // always valid!
2810}
2811
2813 sal_Int32 nAttrToken,
2814 std::string_view sAttrValue)
2815{
2816 // no attributes -> nothing to be done
2817 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
2818}
2819
2821 const Reference<XPropertySet> &)
2822{
2823 // no attributes -> nothing to be done
2824}
2825
2829 SvXMLImport& rImport,
2830 XMLTextImportHelper& rHlp)
2831: XMLTextFieldImportContext(rImport, rHlp, "PageName" )
2832{
2833 bValid = true;
2834}
2835
2838 std::string_view sAttrValue )
2839{
2840 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
2841}
2842
2845 const css::uno::Reference<css::beans::XPropertySet> &)
2846{
2847}
2848
2849
2850// URL fields (Calc, Impress, Draw)
2851
2852
2854 SvXMLImport& rImport,
2855 XMLTextImportHelper& rHlp) :
2856 XMLTextFieldImportContext(rImport, rHlp, sAPI_url),
2857 bFrameOK(false)
2858{
2859}
2860
2862 sal_Int32 nAttrToken,
2863 std::string_view sAttrValue )
2864{
2865 switch (nAttrToken)
2866 {
2867 case XML_ELEMENT(XLINK, XML_HREF):
2868 sURL = GetImport().GetAbsoluteReference( OUString::fromUtf8(sAttrValue) );
2869 bValid = true;
2870 break;
2872 sFrame = OUString::fromUtf8(sAttrValue);
2873 bFrameOK = true;
2874 break;
2875 default:
2876 // ignore
2877 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
2878 break;
2879 }
2880}
2881
2883 const Reference<XPropertySet> & xPropertySet)
2884{
2885 xPropertySet->setPropertyValue(sAPI_url, Any(sURL));
2886
2887 if (bFrameOK)
2888 {
2889 xPropertySet->setPropertyValue("TargetFrame", Any(sFrame));
2890 }
2891
2892 xPropertySet->setPropertyValue("Representation", Any(GetContent()));
2893}
2894
2895
2897 SvXMLImport& rImport,
2898 XMLTextImportHelper& rHlp) :
2899 XMLTextFieldImportContext(rImport, rHlp, "Bibliography")
2900{
2901 bValid = true;
2902}
2903
2904// TODO: this is the same map as is used in the text field export
2906{
2907 { XML_ARTICLE, BibliographyDataType::ARTICLE },
2908 { XML_BOOK, BibliographyDataType::BOOK },
2909 { XML_BOOKLET, BibliographyDataType::BOOKLET },
2910 { XML_CONFERENCE, BibliographyDataType::CONFERENCE },
2911 { XML_CUSTOM1, BibliographyDataType::CUSTOM1 },
2912 { XML_CUSTOM2, BibliographyDataType::CUSTOM2 },
2913 { XML_CUSTOM3, BibliographyDataType::CUSTOM3 },
2914 { XML_CUSTOM4, BibliographyDataType::CUSTOM4 },
2915 { XML_CUSTOM5, BibliographyDataType::CUSTOM5 },
2916 { XML_EMAIL, BibliographyDataType::EMAIL },
2917 { XML_INBOOK, BibliographyDataType::INBOOK },
2918 { XML_INCOLLECTION, BibliographyDataType::INCOLLECTION },
2919 { XML_INPROCEEDINGS, BibliographyDataType::INPROCEEDINGS },
2920 { XML_JOURNAL, BibliographyDataType::JOURNAL },
2921 { XML_MANUAL, BibliographyDataType::MANUAL },
2922 { XML_MASTERSTHESIS, BibliographyDataType::MASTERSTHESIS },
2923 { XML_MISC, BibliographyDataType::MISC },
2924 { XML_PHDTHESIS, BibliographyDataType::PHDTHESIS },
2925 { XML_PROCEEDINGS, BibliographyDataType::PROCEEDINGS },
2926 { XML_TECHREPORT, BibliographyDataType::TECHREPORT },
2927 { XML_UNPUBLISHED, BibliographyDataType::UNPUBLISHED },
2928 { XML_WWW, BibliographyDataType::WWW },
2929 { XML_TOKEN_INVALID, 0 }
2930};
2931
2932
2933// we'll process attributes on our own and for fit the standard
2934// textfield mechanism, because our attributes have zero overlap with
2935// all the other textfields.
2937 sal_Int32 /*nElement*/,
2938 const Reference<XFastAttributeList> & xAttrList)
2939{
2940 // iterate over attributes
2941 for( auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ) )
2942 {
2943 if (IsTokenInNamespace(aIter.getToken(), XML_NAMESPACE_TEXT)
2944 || IsTokenInNamespace(aIter.getToken(), XML_NAMESPACE_LO_EXT))
2945 {
2946 auto nToken = aIter.getToken() & TOKEN_MASK;
2947 PropertyValue aValue;
2948 aValue.Name = OUString::createFromAscii(
2950 Any aAny;
2951
2952 // special treatment for bibliography type
2953 // biblio vs bibilio: #96658#; also read old documents
2956 {
2957 sal_uInt16 nTmp;
2959 nTmp, aIter.toView(),
2961 {
2962 aAny <<= static_cast<sal_Int16>(nTmp);
2963 aValue.Value = aAny;
2964
2965 aValues.push_back(aValue);
2966 }
2967 }
2968 else
2969 {
2970 OUString aStringValue = aIter.toString();
2971 if (nToken == XML_URL || nToken == XML_LOCAL_URL)
2972 {
2973 aStringValue = GetImport().GetAbsoluteReference(aStringValue);
2974 }
2975 aAny <<= aStringValue;
2976 aValue.Value = aAny;
2977
2978 aValues.push_back(aValue);
2979 }
2980 }
2981 // else: unknown namespace -> ignore
2982 }
2983}
2984
2986 sal_Int32 ,
2987 std::string_view )
2988{
2989 // attributes are handled in StartElement
2990 assert(false && "This should not have happened.");
2991}
2992
2993
2995 const Reference<XPropertySet> & xPropertySet)
2996{
2997 // convert vector into sequence
2998 sal_Int32 nCount = aValues.size();
2999 Sequence<PropertyValue> aValueSequence(nCount);
3000 auto aValueSequenceRange = asNonConstRange(aValueSequence);
3001 for(sal_Int32 i = 0; i < nCount; i++)
3002 {
3003 aValueSequenceRange[i] = aValues[i];
3004 }
3005
3006 // set sequence
3007 xPropertySet->setPropertyValue("Fields", Any(aValueSequence));
3008}
3009
3011 sal_Int32 nElement)
3012{
3013 const char* pName = nullptr;
3014
3015 switch (nElement & TOKEN_MASK)
3016 {
3017 case XML_IDENTIFIER:
3018 pName = "Identifier";
3019 break;
3022 // biblio... vs bibilio...: #96658#: also read old documents
3023 pName = "BibiliographicType";
3024 break;
3025 case XML_ADDRESS:
3026 pName = "Address";
3027 break;
3028 case XML_ANNOTE:
3029 pName = "Annote";
3030 break;
3031 case XML_AUTHOR:
3032 pName = "Author";
3033 break;
3034 case XML_BOOKTITLE:
3035 pName = "Booktitle";
3036 break;
3037 case XML_CHAPTER:
3038 pName = "Chapter";
3039 break;
3040 case XML_EDITION:
3041 pName = "Edition";
3042 break;
3043 case XML_EDITOR:
3044 pName = "Editor";
3045 break;
3046 case XML_HOWPUBLISHED:
3047 pName = "Howpublished";
3048 break;
3049 case XML_INSTITUTION:
3050 pName = "Institution";
3051 break;
3052 case XML_JOURNAL:
3053 pName = "Journal";
3054 break;
3055 case XML_MONTH:
3056 pName = "Month";
3057 break;
3058 case XML_NOTE:
3059 pName = "Note";
3060 break;
3061 case XML_NUMBER:
3062 pName = "Number";
3063 break;
3064 case XML_ORGANIZATIONS:
3065 pName = "Organizations";
3066 break;
3067 case XML_PAGES:
3068 pName = "Pages";
3069 break;
3070 case XML_PUBLISHER:
3071 pName = "Publisher";
3072 break;
3073 case XML_SCHOOL:
3074 pName = "School";
3075 break;
3076 case XML_SERIES:
3077 pName = "Series";
3078 break;
3079 case XML_TITLE:
3080 pName = "Title";
3081 break;
3082 case XML_REPORT_TYPE:
3083 pName = "Report_Type";
3084 break;
3085 case XML_VOLUME:
3086 pName = "Volume";
3087 break;
3088 case XML_YEAR:
3089 pName = "Year";
3090 break;
3091 case XML_URL:
3092 pName = "URL";
3093 break;
3094 case XML_CUSTOM1:
3095 pName = "Custom1";
3096 break;
3097 case XML_CUSTOM2:
3098 pName = "Custom2";
3099 break;
3100 case XML_CUSTOM3:
3101 pName = "Custom3";
3102 break;
3103 case XML_CUSTOM4:
3104 pName = "Custom4";
3105 break;
3106 case XML_CUSTOM5:
3107 pName = "Custom5";
3108 break;
3109 case XML_ISBN:
3110 pName = "ISBN";
3111 break;
3112 case XML_LOCAL_URL:
3113 pName = "LocalURL";
3114 break;
3115 default:
3116 assert(false && "Unknown bibliography info data");
3117 pName = nullptr;
3118 }
3119 return pName;
3120}
3121
3122// Annotation Field
3123
3124
3126 SvXMLImport& rImport,
3127 XMLTextImportHelper& rHlp,
3128 sal_Int32 nElement) :
3129 XMLTextFieldImportContext(rImport, rHlp, "Annotation"),
3130 mnElement(nElement)
3131{
3132 bValid = true;
3133
3134 // remember old list item and block (#91964#) and reset them
3135 // for the text frame
3136 // do this in the constructor, not in CreateChildContext (#i93392#)
3137 GetImport().GetTextImport()->PushListContext();
3138}
3139
3141 sal_Int32 nAttrToken,
3142 std::string_view sAttrValue )
3143{
3144 if (nAttrToken == XML_ELEMENT(OFFICE, XML_NAME))
3145 aName = OUString::fromUtf8(sAttrValue);
3146 else if (nAttrToken == XML_ELEMENT(LO_EXT, XML_RESOLVED))
3147 aResolved = OUString::fromUtf8(sAttrValue);
3148 else
3149 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
3150}
3151
3152css::uno::Reference< css::xml::sax::XFastContextHandler > XMLAnnotationImportContext::createFastChildContext(
3153 sal_Int32 nElement,
3154 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
3155{
3156 if( nElement == XML_ELEMENT(DC, XML_CREATOR) )
3158 else if( nElement == XML_ELEMENT(DC, XML_DATE) )
3160 else if (nElement == XML_ELEMENT(TEXT,XML_SENDER_INITIALS) ||
3161 nElement == XML_ELEMENT(LO_EXT, XML_SENDER_INITIALS) ||
3164
3165 try
3166 {
3167 bool bOK = true;
3168 if ( !mxField.is() )
3170 if (bOK)
3171 {
3172 Any aAny = mxField->getPropertyValue( "TextRange" );
3173 Reference< XText > xText;
3174 aAny >>= xText;
3175 if( xText.is() )
3176 {
3178 if( !mxCursor.is() )
3179 {
3180 mxOldCursor = xTxtImport->GetCursor();
3181 mxCursor = xText->createTextCursor();
3182 }
3183
3184 if( mxCursor.is() )
3185 {
3186 xTxtImport->SetCursor( mxCursor );
3187 return xTxtImport->CreateTextChildContext( GetImport(), nElement, xAttrList );
3188 }
3189 }
3190 }
3191 }
3192 catch (const Exception&)
3193 {
3194 }
3195
3197}
3198
3200{
3201 DBG_ASSERT(!GetServiceName().isEmpty(), "no service name for element!");
3202 if( mxCursor.is() )
3203 {
3204 // delete addition newline
3205 mxCursor->gotoEnd( false );
3206 mxCursor->goLeft( 1, true );
3207 mxCursor->setString( "" );
3208
3209 // reset cursor
3210 GetImport().GetTextImport()->ResetCursor();
3211 }
3212
3213 if( mxOldCursor.is() )
3214 GetImport().GetTextImport()->SetCursor( mxOldCursor );
3215
3216 // reinstall old list item #91964#
3217 GetImport().GetTextImport()->PopListContext();
3218
3219 if ( bValid )
3220 {
3222 {
3223 // Search for a previous annotation with the same name.
3224 uno::Reference< text::XTextContent > xPrevField;
3225 {
3226 Reference<XTextFieldsSupplier> xTextFieldsSupplier(GetImport().GetModel(), UNO_QUERY);
3227 uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
3228 uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
3229 while (xFields->hasMoreElements())
3230 {
3231 uno::Reference<beans::XPropertySet> xCurrField(xFields->nextElement(), uno::UNO_QUERY);
3232 uno::Reference<beans::XPropertySetInfo> const xInfo(
3233 xCurrField->getPropertySetInfo());
3234 if (xInfo->hasPropertyByName(sAPI_name))
3235 {
3236 OUString aFieldName;
3237 xCurrField->getPropertyValue(sAPI_name) >>= aFieldName;
3238 if (aFieldName == aName)
3239 {
3240 xPrevField.set( xCurrField, uno::UNO_QUERY );
3241 break;
3242 }
3243 }
3244 }
3245 }
3246 if ( xPrevField.is() )
3247 {
3248 // So we are ending a previous annotation,
3249 // let's create a text range covering the old and the current position.
3250 uno::Reference<text::XText> xText = GetImportHelper().GetText();
3251 uno::Reference<text::XTextCursor> xCursor =
3252 xText->createTextCursorByRange(GetImportHelper().GetCursorAsRange());
3253 try
3254 {
3255 xCursor->gotoRange(xPrevField->getAnchor(), true);
3256 }
3257 catch (const uno::RuntimeException&)
3258 {
3259 // Losing the start of the anchor is better than not opening the document at
3260 // all.
3262 "xmloff.text",
3263 "XMLAnnotationImportContext::endFastElement: gotoRange() failed: ");
3264 }
3265
3266 xText->insertTextContent(xCursor, xPrevField, !xCursor->isCollapsed());
3267 }
3268 }
3269 else
3270 {
3272 {
3273 // set field properties
3275
3276 // attach field to document
3277 Reference < XTextContent > xTextContent( mxField, UNO_QUERY );
3278
3279 // workaround for #80606#
3280 try
3281 {
3282 GetImportHelper().InsertTextContent( xTextContent );
3283 }
3284 catch (const lang::IllegalArgumentException&)
3285 {
3286 // ignore
3287 }
3288 }
3289 }
3290 }
3291 else
3293}
3294
3296 const Reference<XPropertySet> & xPropertySet )
3297{
3298 // import (possibly empty) author
3299 OUString sAuthor( aAuthorBuffer.makeStringAndClear() );
3300 xPropertySet->setPropertyValue(sAPI_author, Any(sAuthor));
3301
3302 // import (possibly empty) initials
3303 OUString sInitials( aInitialsBuffer.makeStringAndClear() );
3304 xPropertySet->setPropertyValue("Initials", Any(sInitials));
3305
3306 //import resolved flag
3307 bool bTmp(false);
3309 xPropertySet->setPropertyValue("Resolved", Any(bTmp));
3310
3311 util::DateTime aDateTime;
3313 {
3314 /*
3315 Date aDate;
3316 aDate.Year = aDateTime.Year;
3317 aDate.Month = aDateTime.Month;
3318 aDate.Day = aDateTime.Day;
3319 xPropertySet->setPropertyValue(sPropertyDate, makeAny(aDate));
3320 */
3321 // why is there no UNO_NAME_DATE_TIME, but only UNO_NAME_DATE_TIME_VALUE?
3322 xPropertySet->setPropertyValue(sAPI_date_time_value, Any(aDateTime));
3323 }
3324 aDateBuffer.setLength(0);
3325
3326 OUString sBuffer = aTextBuffer.makeStringAndClear();
3327 if ( sBuffer.getLength() )
3328 {
3329 // delete last paragraph mark (if necessary)
3330 if (char(0x0a) == sBuffer[sBuffer.getLength()-1])
3331 sBuffer = sBuffer.copy(0, sBuffer.getLength()-1);
3332 xPropertySet->setPropertyValue(sAPI_content, Any(sBuffer));
3333 }
3334
3335 if (!aName.isEmpty())
3336 xPropertySet->setPropertyValue(sAPI_name, Any(aName));
3337}
3338
3339
3340// script field
3341
3342
3344 SvXMLImport& rImport,
3345 XMLTextImportHelper& rHlp)
3346: XMLTextFieldImportContext(rImport, rHlp, "Script")
3347, bContentOK(false)
3348{
3349}
3350
3352 sal_Int32 nAttrToken,
3353 std::string_view sAttrValue )
3354{
3355 switch (nAttrToken)
3356 {
3357 case XML_ELEMENT(XLINK, XML_HREF):
3358 sContent = GetImport().GetAbsoluteReference( OUString::fromUtf8(sAttrValue) );
3359 bContentOK = true;
3360 break;
3361
3363 sScriptType = OUString::fromUtf8(sAttrValue);
3364 break;
3365
3366 default:
3367 // ignore
3368 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
3369 break;
3370 }
3371
3372 // always valid (even without ScriptType; cf- #96531#)
3373 bValid = true;
3374}
3375
3377 const Reference<XPropertySet> & xPropertySet)
3378{
3379 // if href attribute was present, we use it. Else we use element content
3380 if (! bContentOK)
3381 {
3382 sContent = GetContent();
3383 }
3384 xPropertySet->setPropertyValue(sAPI_content, Any(sContent));
3385
3386 // URL or script text? We use URL if we have an href-attribute
3387 xPropertySet->setPropertyValue("URLContent", Any(bContentOK));
3388
3389 xPropertySet->setPropertyValue("ScriptType", Any(sScriptType));
3390}
3391
3392
3393// measure field
3394
3395
3397 SvXMLImport& rImport,
3398 XMLTextImportHelper& rHlp) :
3399 XMLTextFieldImportContext(rImport, rHlp, "Measure"),
3400 mnKind( 0 )
3401{
3402}
3403
3405 sal_Int32 nAttrToken,
3406 std::string_view sAttrValue )
3407{
3408 switch (nAttrToken)
3409 {
3410 case XML_ELEMENT(TEXT, XML_KIND):
3411 if( IsXMLToken( sAttrValue, XML_VALUE ) )
3412 {
3413 mnKind = 0; bValid = true;
3414 }
3415 else if( IsXMLToken( sAttrValue, XML_UNIT ) )
3416 {
3417 mnKind = 1; bValid = true;
3418 }
3419 else if( IsXMLToken( sAttrValue, XML_GAP ) )
3420 {
3421 mnKind = 2; bValid = true;
3422 }
3423 break;
3424 default:
3425 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
3426 }
3427}
3428
3430 const Reference<XPropertySet> & xPropertySet)
3431{
3432 xPropertySet->setPropertyValue("Kind", Any(mnKind));
3433}
3434
3435
3436// dropdown field
3437
3438
3440 SvXMLImport& rImport,
3441 XMLTextImportHelper& rHlp) :
3442 XMLTextFieldImportContext( rImport, rHlp, "DropDown" ),
3443 nSelected( -1 ),
3444 bNameOK( false ),
3445 bHelpOK(false),
3446 bHintOK(false)
3447{
3448 bValid = true;
3449}
3450
3452 const Reference<XFastAttributeList>& xAttrList,
3453 OUString& rLabel,
3454 bool& rIsSelected )
3455{
3456 bool bValid = false;
3457 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
3458 {
3459 switch (aIter.getToken())
3460 {
3461 case XML_ELEMENT(TEXT, XML_VALUE):
3462 {
3463 rLabel = aIter.toString();
3464 bValid = true;
3465 break;
3466 }
3468 {
3469 bool bTmp(false);
3470 if (::sax::Converter::convertBool( bTmp, aIter.toView() ))
3471 rIsSelected = bTmp;
3472 break;
3473 }
3474 default:
3475 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
3476 }
3477 }
3478 return bValid;
3479}
3480
3481css::uno::Reference< css::xml::sax::XFastContextHandler > XMLDropDownFieldImportContext::createFastChildContext(
3482 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
3483{
3484 if( nElement == XML_ELEMENT(TEXT, XML_LABEL) )
3485 {
3486 OUString sLabel;
3487 bool bIsSelected = false;
3488 if( lcl_ProcessLabel( xAttrList, sLabel, bIsSelected ) )
3489 {
3490 if( bIsSelected )
3491 nSelected = static_cast<sal_Int32>( aLabels.size() );
3492 aLabels.push_back( sLabel );
3493 }
3494 }
3495 return new SvXMLImportContext( GetImport() );
3496}
3497
3499 sal_Int32 nAttrToken,
3500 std::string_view sAttrValue )
3501{
3502 if( nAttrToken == XML_ELEMENT(TEXT, XML_NAME))
3503 {
3504 sName = OUString::fromUtf8(sAttrValue);
3505 bNameOK = true;
3506 }
3507 else if (nAttrToken == XML_ELEMENT(TEXT, XML_HELP))
3508 {
3509 sHelp = OUString::fromUtf8(sAttrValue);
3510 bHelpOK = true;
3511 }
3512 else if (nAttrToken == XML_ELEMENT(TEXT, XML_HINT))
3513 {
3514 sHint = OUString::fromUtf8(sAttrValue);
3515 bHintOK = true;
3516 }
3517 else
3518 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
3519}
3520
3522 const Reference<XPropertySet>& xPropertySet)
3523{
3524 // create sequence
3525 sal_Int32 nLength = static_cast<sal_Int32>( aLabels.size() );
3526 Sequence<OUString> aSequence( nLength );
3527 OUString* pSequence = aSequence.getArray();
3528 for( sal_Int32 n = 0; n < nLength; n++ )
3529 pSequence[n] = aLabels[n];
3530
3531 // now set values:
3532
3533 xPropertySet->setPropertyValue( "Items", Any(aSequence) );
3534
3535 if( nSelected >= 0 && nSelected < nLength )
3536 {
3537 xPropertySet->setPropertyValue( "SelectedItem", Any(pSequence[nSelected]) );
3538 }
3539
3540 // set name
3541 if( bNameOK )
3542 {
3543 xPropertySet->setPropertyValue( "Name", Any(sName) );
3544 }
3545 // set help
3546 if( bHelpOK )
3547 {
3548 xPropertySet->setPropertyValue( "Help", Any(sHelp) );
3549 }
3550 // set hint
3551 if( bHintOK )
3552 {
3553 xPropertySet->setPropertyValue( "Tooltip", Any(sHint) );
3554 }
3555
3556}
3557
3561 SvXMLImport& rImport,
3562 XMLTextImportHelper& rHlp)
3563: XMLTextFieldImportContext(rImport, rHlp, "Header" )
3564{
3566 bValid = true;
3567}
3568
3570void XMLHeaderFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken, std::string_view sAttrValue )
3571{
3572 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
3573}
3574
3576void XMLHeaderFieldImportContext::PrepareField(const Reference<XPropertySet> &)
3577{
3578}
3579
3583 SvXMLImport& rImport,
3584 XMLTextImportHelper& rHlp)
3585: XMLTextFieldImportContext(rImport, rHlp, "Footer" )
3586{
3588 bValid = true;
3589}
3590
3592void XMLFooterFieldImportContext::ProcessAttribute( sal_Int32 nAttrToken, std::string_view sAttrValue)
3593{
3594 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
3595}
3596
3598void XMLFooterFieldImportContext::PrepareField(const Reference<XPropertySet> &)
3599{
3600}
3601
3602
3606 SvXMLImport& rImport,
3607 XMLTextImportHelper& rHlp)
3608: XMLTextFieldImportContext(rImport, rHlp, "DateTime" )
3609{
3611 bValid = true;
3612}
3613
3616 std::string_view sAttrValue )
3617{
3618 XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
3619}
3620
3623 const css::uno::Reference<
3624 css::beans::XPropertySet> &)
3625{
3626}
3627
3628/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define FULL
const char * pName
constexpr OUStringLiteral sServiceName
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition: xmlictxt.hxx:48
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:60
SvXMLImportContext(SvXMLImport &rImport)
A contexts constructor does anything that is required if an element starts.
Definition: xmlictxt.cxx:30
OUString GetAbsoluteReference(const OUString &rValue) const
Definition: xmlimp.cxx:1618
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlimp.hxx:400
SvXMLNamespaceMap & GetNamespaceMap()
Definition: xmlimp.hxx:398
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
Definition: xmlimp.hxx:601
sal_uInt16 GetKeyByAttrValueQName(const OUString &rAttrName, OUString *pLocalName) const
static bool convertEnum(EnumT &rEnum, std::u16string_view rValue, const SvXMLEnumMapEntry< EnumT > *pMap)
convert string to enum using given enum map, if the enum is not found in the map, this method will re...
Definition: xmluconv.hxx:145
bool convertNumFormat(sal_Int16 &rType, const OUString &rNumFormat, std::u16string_view rNumLetterSync, bool bNumberNone=false) const
convert num-format and num-letter-sync values to NumberingType
Definition: xmluconv.cxx:653
Import an annotation field (<text:annotation>)
Definition: txtfldi.hxx:960
OUStringBuffer aInitialsBuffer
Definition: txtfldi.hxx:962
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attributes
Definition: txtfldi.cxx:3140
OUStringBuffer aTextBuffer
Definition: txtfldi.hxx:964
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
set properties
Definition: txtfldi.cxx:3295
XMLAnnotationImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp, sal_Int32 nElement)
Definition: txtfldi.cxx:3125
css::uno::Reference< css::text::XTextCursor > mxCursor
Definition: txtfldi.hxx:969
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
create XTextField and insert into document; calls PrepareTextField
Definition: txtfldi.cxx:3199
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
Definition: txtfldi.cxx:3152
css::uno::Reference< css::text::XTextCursor > mxOldCursor
Definition: txtfldi.hxx:970
OUStringBuffer aAuthorBuffer
Definition: txtfldi.hxx:961
css::uno::Reference< css::beans::XPropertySet > mxField
Definition: txtfldi.hxx:968
OUStringBuffer aDateBuffer
Definition: txtfldi.hxx:965
inherit sender field because of fixed attribute in ProcessAttributes
Definition: txtfldi.hxx:150
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Text import helper.
Definition: txtfldi.cxx:617
const OUString sPropertyFixed
Definition: txtfldi.hxx:152
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:628
XMLAuthorFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:606
const OUString sPropertyContent
Definition: txtfldi.hxx:153
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:640
import bibliography info fields (<text:bibliography-mark>)
Definition: txtfldi.hxx:933
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
empty method; all attributes are handled in StartElement
Definition: txtfldi.cxx:2985
static const char * MapBibliographyFieldName(sal_Int32 nElement)
Definition: txtfldi.cxx:3010
::std::vector< css::beans::PropertyValue > aValues
Definition: txtfldi.hxx:934
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
process attributes (fill aValues)
Definition: txtfldi.cxx:2936
XMLBibliographyFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:2896
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
convert aValues into sequence and set property
Definition: txtfldi.cxx:2994
import chapter fields (<text:chapter>)
Definition: txtfldi.hxx:669
XMLChapterImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:2101
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:2147
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:2110
import conditional text fields (<text:conditional-text>)
Definition: txtfldi.hxx:563
XMLConditionalTextImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:1818
const OUString sPropertyCondition
Definition: txtfldi.hxx:564
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:1830
const OUString sPropertyCurrentPresentation
Definition: txtfldi.hxx:565
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:1874
import count fields (<text:[XXX]-count>)
Definition: txtfldi.hxx:690
const OUString sPropertyNumberingType
Definition: txtfldi.hxx:691
static OUString MapTokenToServiceName(sal_Int32 nElement)
Definition: txtfldi.cxx:2210
XMLCountFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp, sal_Int32 nElement)
Definition: txtfldi.cxx:2158
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:2187
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:2169
import database display fields (<text:database-display>)
Definition: txtvfldi.hxx:426
superclass for database fields: handle database and table names
Definition: txtfldi.hxx:308
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
handle database-location children
Definition: txtfldi.cxx:1163
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:1115
XMLDatabaseFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp, const OUString &pServiceName, bool bUseDisplay)
protected constructor: only for subclasses
Definition: txtfldi.cxx:1099
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:1194
import database name fields (<text:database-name>)
Definition: txtfldi.hxx:350
XMLDatabaseNameImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:1225
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:1231
import database next fields (<text:database-next>)
Definition: txtfldi.hxx:363
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:1262
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:1287
XMLDatabaseNextImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp, const OUString &pServiceName)
Definition: txtfldi.cxx:1243
const OUString sPropertyCondition
Definition: txtfldi.hxx:364
import database display number fields (<text:database-row-number>)
Definition: txtfldi.hxx:413
XMLDatabaseNumberImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:1345
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:1358
const OUString sPropertyNumberingType
Definition: txtfldi.hxx:414
const OUString sPropertySetNumber
Definition: txtfldi.hxx:415
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:1390
import database select fields (<text:database-select>)
Definition: txtfldi.hxx:391
const OUString sPropertySetNumber
Definition: txtfldi.hxx:392
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:1311
XMLDatabaseSelectImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:1302
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:1333
import date fields (<text:date>); inherit from TimeField to reuse implementation
Definition: txtfldi.hxx:238
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
Text import helper.
Definition: txtfldi.cxx:1055
XMLDateFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:1048
import docinfo fields with date or time attributes and numberformats
Definition: txtfldi.hxx:470
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:1658
XMLDateTimeDocInfoImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp, sal_Int32 nElement)
Definition: txtfldi.cxx:1588
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:1631
const OUString sPropertyIsDate
Definition: txtfldi.hxx:472
const OUString sPropertyIsFixedLanguage
Definition: txtfldi.hxx:473
const OUString sPropertyNumberFormat
Definition: txtfldi.hxx:471
import footer fields (<draw:date-and-time>)
Definition: txtfldi.hxx:1106
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:3622
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
Text import helper.
Definition: txtfldi.cxx:3615
XMLDateTimeFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
import footer fields (<draw:date-and-time>)
Definition: txtfldi.cxx:3605
import dde field declaration (<text:dde-connection-decl>)
Definition: txtfldi.hxx:837
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: txtfldi.cxx:2623
XMLDdeFieldDeclImportContext(SvXMLImport &rImport)
Definition: txtfldi.cxx:2618
XMLDdeFieldDeclsImportContext(SvXMLImport &rImport)
Definition: txtfldi.cxx:2596
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
Definition: txtfldi.cxx:2601
import dde fields (<text:dde-connection>)
Definition: txtfldi.hxx:850
XMLDdeFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:2729
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
create textfield, attach master, and insert into document
Definition: txtfldi.cxx:2750
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
empty method
Definition: txtfldi.cxx:2794
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:2736
dropdown field (filter legacy)
Definition: txtfldi.hxx:1040
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:3498
std::vector< OUString > aLabels
Definition: txtfldi.hxx:1041
XMLDropDownFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:3439
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:3521
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
Definition: txtfldi.cxx:3481
Import <script:events> element.
void GetEventSequence(const OUString &rName, css::uno::Sequence< css::beans::PropertyValue > &rSequence)
if the import operates in delayed mode, you can use this method to obtain the value sequence for a sp...
import expression fields (<text:expression>)
Definition: txtvfldi.hxx:190
import file name fields (<text:file-name>)
Definition: txtfldi.hxx:622
const OUString sPropertyFileFormat
Definition: txtfldi.hxx:624
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:1975
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:2007
const OUString sPropertyCurrentPresentation
Definition: txtfldi.hxx:625
const OUString sPropertyFixed
Definition: txtfldi.hxx:623
XMLFileNameImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:1962
import footer fields (<draw:footer>)
Definition: txtfldi.hxx:1088
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:3598
XMLFooterFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
import footer fields (<draw:footer>)
Definition: txtfldi.cxx:3582
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
Text import helper.
Definition: txtfldi.cxx:3592
import header fields (<draw:header>)
Definition: txtfldi.hxx:1070
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
Text import helper.
Definition: txtfldi.cxx:3570
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:3576
XMLHeaderFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
import header fields (<draw:header>)
Definition: txtfldi.cxx:3560
import hidden paragraph fields (<text:hidden-paragraph>)
Definition: txtfldi.hxx:539
XMLHiddenParagraphImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:1766
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:1775
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:1804
const OUString sPropertyIsHidden
Definition: txtfldi.hxx:541
const OUString sPropertyCondition
Definition: txtfldi.hxx:540
import conditional text fields (<text:hidden-text>)
Definition: txtfldi.hxx:593
XMLHiddenTextImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:1888
const OUString sPropertyCondition
Definition: txtfldi.hxx:594
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:1941
const OUString sPropertyIsHidden
Definition: txtfldi.hxx:596
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:1900
const OUString sPropertyContent
Definition: txtfldi.hxx:595
import macro fields (<text:execute-macro>)
Definition: txtfldi.hxx:762
XMLMacroFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:2349
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:2372
rtl::Reference< XMLEventsImportContext > xEventContext
Definition: txtfldi.hxx:764
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:2391
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
for <office:events> children
Definition: txtfldi.cxx:2356
import measure fields (<text:measure>)
Definition: txtfldi.hxx:1020
XMLMeasureFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:3396
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:3404
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:3429
import page continuation fields (<text:page-continuation-string>)
Definition: txtfldi.hxx:252
const OUString sPropertyNumberingType
Definition: txtfldi.hxx:254
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
Text import helper.
Definition: txtfldi.cxx:691
XMLPageContinuationImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
continuation string encountered?
Definition: txtfldi.cxx:680
css::text::PageNumberType eSelectPage
continuation string
Definition: txtfldi.hxx:257
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:717
bool sStringOK
previous, current
Definition: txtfldi.hxx:259
import page|slide name fields (<text:page-name>)
Definition: txtfldi.hxx:893
XMLPageNameFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
import page|slide name fields (<text:page-name>)
Definition: txtfldi.cxx:2828
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
Text import helper.
Definition: txtfldi.cxx:2837
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:2844
import page number fields (<text:page-number>)
Definition: txtfldi.hxx:278
const OUString sPropertyOffset
Definition: txtfldi.hxx:281
const OUString sPropertyNumberingType
Definition: txtfldi.hxx:280
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
Text import helper.
Definition: txtfldi.cxx:749
XMLPageNumberImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:735
css::text::PageNumberType eSelectPage
Definition: txtfldi.hxx:286
const OUString sPropertySubType
Definition: txtfldi.hxx:279
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:780
bool sNumberFormatOK
previous, current
Definition: txtfldi.hxx:288
import page variable fields (<text:get-page-variable>)
Definition: txtfldi.hxx:718
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:2276
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:2258
XMLPageVarGetFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:2250
import page variable fields (<text:get-page-variable>)
Definition: txtfldi.hxx:741
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:2308
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:2338
XMLPageVarSetFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:2299
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
Text import helper.
Definition: txtfldi.cxx:844
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:886
XMLPlaceholderFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:835
import reference fields (<text:reference-get>)
Definition: txtfldi.hxx:792
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:2520
XMLReferenceFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp, sal_Int32 nToken)
Definition: txtfldi.cxx:2463
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:2566
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
start element
Definition: txtfldi.cxx:2491
import revision field (<text:editing-cycles>)
Definition: txtfldi.hxx:499
XMLRevisionDocInfoImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp, sal_Int32 nElement)
Definition: txtfldi.cxx:1552
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:1559
Import a script field (<text:script>)
Definition: txtfldi.hxx:997
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
set properties
Definition: txtfldi.cxx:3376
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attributes
Definition: txtfldi.cxx:3351
XMLScriptImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:3343
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:576
const OUString sPropertyFixed
API subtype for ExtUser field.
Definition: txtfldi.hxx:120
const OUString sPropertyContent
Definition: txtfldi.hxx:121
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:557
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Text import helper.
Definition: txtfldi.cxx:495
XMLSenderFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:485
sequence fields (<text:sequence>)
Definition: txtvfldi.hxx:327
import sheet name fields (Calc) dde fields (<text:sheet-name>)
Definition: txtfldi.hxx:874
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
no attributes -> empty method
Definition: txtfldi.cxx:2812
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
no attributes -> empty method
Definition: txtfldi.cxx:2820
XMLSheetNameImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:2804
import docinfo fields with only fixed attribute
Definition: txtfldi.hxx:437
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:1443
XMLSimpleDocInfoImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp, sal_Int32 nElementToken, bool bContent, bool bAuthor)
Definition: txtfldi.cxx:1411
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:1427
const OUString sPropertyCurrentPresentation
Definition: txtfldi.hxx:441
static OUString MapTokenToServiceName(sal_Int32 nElementToken)
Definition: txtfldi.cxx:1484
const OUString sPropertyContent
Definition: txtfldi.hxx:439
const OUString sPropertyAuthor
Definition: txtfldi.hxx:440
const OUString sPropertyFixed
Definition: txtfldi.hxx:438
Import all text into a string buffer.
import table formula fields (deprecated; for Writer 2.0 compatibility)
Definition: txtvfldi.hxx:401
import document template name fields (<text:template-name>)
Definition: txtfldi.hxx:647
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:2078
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:2055
const OUString sPropertyFileFormat
Definition: txtfldi.hxx:648
XMLTemplateNameImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:2046
abstract class for text field import
Definition: txtfldi.hxx:50
void SetServiceName(const OUString &sStr)
Definition: txtfldi.hxx:93
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
parses attributes and calls ProcessAttribute
Definition: txtfldi.cxx:135
virtual void SAL_CALL characters(const OUString &sContent) override
name of SO API service
Definition: txtfldi.cxx:186
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
create XTextField and insert into document; calls PrepareTextField
Definition: txtfldi.cxx:154
OUString sContent
collect character data
Definition: txtfldi.hxx:53
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet)=0
prepare XTextField for insertion into document
XMLTextImportHelper & GetImportHelper()
get helper
Definition: txtfldi.hxx:90
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue)=0
process attribute values
OUString sServicePrefix
the import helper
Definition: txtfldi.hxx:58
XMLTextImportHelper & rTextImportHelper
service name for text field
Definition: txtfldi.hxx:55
XMLTextFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp, const OUString &pService)
whether this field is valid ?
Definition: txtfldi.cxx:124
OUStringBuffer sContentBuffer
Definition: txtfldi.hxx:52
static XMLTextFieldImportContext * CreateTextFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp, sal_Int32 nElement)
create the appropriate field context from (for use in paragraph import)
Definition: txtfldi.cxx:219
const OUString & GetServiceName() const
Definition: txtfldi.hxx:92
OUString const & GetContent()
Definition: txtfldi.cxx:144
bool CreateField(css::uno::Reference< css::beans::XPropertySet > &xField, const OUString &sServiceName)
create field from ServiceName
Definition: txtfldi.cxx:191
static void ForceUpdate(const css::uno::Reference< css::beans::XPropertySet > &rPropertySet)
force an update of the field's value call update on optional XUpdatable interface; (disable Fixed pro...
Definition: txtfldi.cxx:464
void InsertTextContent(css::uno::Reference< css::text::XTextContent > const &xContent)
Definition: txtimp.cxx:758
css::uno::Reference< css::text::XText > & GetText()
Definition: txtimp.cxx:212
void ProcessFootnoteReference(const OUString &sXMLId, const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
set the proper footnote reference ID, or put into backpatch list if ID is unknown
sal_Int32 GetDataStyleKey(const OUString &sStyleName, bool *pIsSystemLanguage=nullptr)
return key appropriate for use with NumberFormat property return -1 if style is not found (may return...
Definition: txtimp.cxx:1938
void ProcessSequenceReference(const OUString &sXMLId, const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
set sequence ID or insert into backpatch list
void InsertString(const OUString &rChars)
Definition: txtimp.cxx:702
const OUString sPropertyDateTime
Definition: txtfldi.hxx:206
const OUString sPropertyFixed
Definition: txtfldi.hxx:204
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:986
css::util::DateTime aDateTimeValue
Definition: txtfldi.hxx:210
const OUString sPropertyNumberFormat
Definition: txtfldi.hxx:203
const OUString sPropertyIsFixedLanguage
Definition: txtfldi.hxx:208
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
Text import helper.
Definition: txtfldi.cxx:936
const OUString sPropertyIsDate
Definition: txtfldi.hxx:207
XMLTimeFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:916
const OUString sPropertyDateTimeValue
Definition: txtfldi.hxx:205
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
no attributes -> empty method
Definition: txtfldi.cxx:2882
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
no attributes -> empty method
Definition: txtfldi.cxx:2861
XMLUrlFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
Definition: txtfldi.cxx:2853
import user docinfo field (<text:user-defined>)
Definition: txtfldi.hxx:514
XMLUserDocInfoImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp, sal_Int32 nElement)
Definition: txtfldi.cxx:1688
const OUString sPropertyIsFixedLanguage
Definition: txtfldi.hxx:518
const OUString sPropertyNumberFormat
Definition: txtfldi.hxx:517
const OUString sPropertyName
Definition: txtfldi.hxx:516
virtual void PrepareField(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet) override
prepare XTextField for insertion into document
Definition: txtfldi.cxx:1737
virtual void ProcessAttribute(sal_Int32 nAttrToken, std::string_view sAttrValue) override
process attribute values
Definition: txtfldi.cxx:1702
user fields (<text:user-field-get>)
Definition: txtvfldi.hxx:299
user input fields (<text:user-field-input>)
Definition: txtvfldi.hxx:311
import variable get fields (<text:variable-get>)
Definition: txtvfldi.hxx:171
variable input fields (<text:variable-input>)
Definition: txtvfldi.hxx:281
import variable set fields (<text:variable-set>)
Definition: txtvfldi.hxx:265
static bool parseTimeOrDateTime(css::util::DateTime &rDateTime, std::u16string_view rString)
static void convertDuration(OUStringBuffer &rBuffer, const double fTime)
static bool parseDateTime(css::util::DateTime &rDateTime, std::u16string_view rString)
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
static bool convertBool(bool &rBool, std::u16string_view rString)
sal_Int32 m_nCommandType
int nCount
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
float u
Reference< XSingleServiceFactory > xFactory
sal_Int16 nValue
sal_Int64 n
sal_uInt16 nPos
sal_Int16 nNumType
#define SAL_WARN(area, stream)
const char * sName
@ Exception
FORM
int i
PlaceholderType
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Handling of tokens in XML:
@ XML_NAME_AND_EXTENSION
Definition: xmltoken.hxx:1365
@ XML_REFERENCE_LANGUAGE
Definition: xmltoken.hxx:3442
@ XML_SENDER_PHONE_PRIVATE
Definition: xmltoken.hxx:1703
@ XML_STRING_VALUE_IF_TRUE
Definition: xmltoken.hxx:1864
@ XML_AUTOMATIC_UPDATE
Definition: xmltoken.hxx:303
@ XML_BIBLIOGRAPHY_MARK
Definition: xmltoken.hxx:329
@ XML_DDE_CONNECTION_DECL
Definition: xmltoken.hxx:634
@ XML_CONDITIONAL_TEXT
Definition: xmltoken.hxx:485
@ XML_DATABASE_ROW_SELECT
Definition: xmltoken.hxx:2734
@ XML_SENDER_POSTAL_CODE
Definition: xmltoken.hxx:1706
@ XML_DATABASE_ROW_NUMBER
Definition: xmltoken.hxx:614
@ XML_CATEGORY_AND_VALUE
Definition: xmltoken.hxx:404
@ XML_NUMBER_NO_SUPERIOR
Definition: xmltoken.hxx:3272
@ XML_PLAIN_NUMBER_AND_NAME
Definition: xmltoken.hxx:1520
@ XML_EDITING_DURATION
Definition: xmltoken.hxx:728
@ XML_CONNECTION_RESOURCE
Definition: xmltoken.hxx:2368
@ XML_BIBLIOGRAPHY_TYPE
Definition: xmltoken.hxx:331
@ XML_PAGE_CONTINUATION_STRING
Definition: xmltoken.hxx:1469
@ XML_NUMBER_ALL_SUPERIOR
Definition: xmltoken.hxx:3273
@ XML_BIBILIOGRAPHIC_TYPE
Definition: xmltoken.hxx:324
@ XML_DATABASE_DISPLAY
Definition: xmltoken.hxx:609
@ XML_SENDER_STATE_OR_PROVINCE
Definition: xmltoken.hxx:1707
@ XML_STRING_VALUE_IF_FALSE
Definition: xmltoken.hxx:1863
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3573
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3517
DefTokenId nToken
QPRO_FUNC_TYPE nType