LibreOffice Module xmloff (master)  1
txtflde.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 
26 #include <txtflde.hxx>
28 #include <xmloff/families.hxx>
29 #include <xmloff/namespacemap.hxx>
30 #include <xmloff/numehelp.hxx>
31 #include <xmloff/xmlement.hxx>
32 #include <xmloff/xmlexp.hxx>
33 #include <xmloff/xmltoken.hxx>
34 #include <xmloff/xmluconv.hxx>
35 #include <xmloff/maptype.hxx>
36 
38 #include <sax/tools/converter.hxx>
39 #include <com/sun/star/frame/XModel.hpp>
40 #include <com/sun/star/util/DateTime.hpp>
41 #include <com/sun/star/lang/XServiceInfo.hpp>
42 #include <com/sun/star/text/UserDataPart.hpp>
43 #include <com/sun/star/text/PageNumberType.hpp>
44 #include <com/sun/star/style/NumberingType.hpp>
45 #include <com/sun/star/text/ReferenceFieldPart.hpp>
46 #include <com/sun/star/text/ReferenceFieldSource.hpp>
47 #include <com/sun/star/beans/XPropertySet.hpp>
48 #include <com/sun/star/beans/XPropertyState.hpp>
49 #include <com/sun/star/text/XTextField.hpp>
50 #include <com/sun/star/text/XDependentTextField.hpp>
51 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
52 
53 #include <com/sun/star/text/SetVariableType.hpp>
54 #include <com/sun/star/text/PlaceholderType.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/container/XNameReplace.hpp>
59 #include <com/sun/star/uno/Sequence.h>
60 #include <com/sun/star/text/BibliographyDataType.hpp>
61 #include <com/sun/star/sdb/CommandType.hpp>
62 #include <com/sun/star/rdf/XMetadatable.hpp>
63 #include <comphelper/sequence.hxx>
64 #include <o3tl/any.hxx>
65 #include <o3tl/safeint.hxx>
66 #include <rtl/ustrbuf.hxx>
67 #include <tools/debug.hxx>
68 #include <rtl/math.hxx>
69 #include <sal/log.hxx>
70 
71 #include <vector>
72 
73 
74 using namespace ::std;
75 using namespace ::com::sun::star;
76 using namespace ::com::sun::star::uno;
77 using namespace ::com::sun::star::text;
78 using namespace ::com::sun::star::lang;
79 using namespace ::com::sun::star::beans;
80 using namespace ::com::sun::star::util;
81 using namespace ::com::sun::star::style;
82 using namespace ::com::sun::star::document;
83 using namespace ::com::sun::star::container;
84 using namespace ::xmloff::token;
85 
86 
87 char const FIELD_SERVICE_SENDER[] = "ExtendedUser";
88 char const FIELD_SERVICE_AUTHOR[] = "Author";
89 char const FIELD_SERVICE_JUMPEDIT[] = "JumpEdit";
90 char const FIELD_SERVICE_GETEXP[] = "GetExpression";
91 char const FIELD_SERVICE_SETEXP[] = "SetExpression";
92 char const FIELD_SERVICE_USER[] = "User";
93 char const FIELD_SERVICE_INPUT[] = "Input";
94 char const FIELD_SERVICE_USERINPUT[] = "InputUser";
95 char const FIELD_SERVICE_DATETIME[] = "DateTime";
96 char const FIELD_SERVICE_PAGENUMBER[] = "PageNumber";
97 char const FIELD_SERVICE_DB_NEXT[] = "DatabaseNextSet";
98 char const FIELD_SERVICE_DB_SELECT[] = "DatabaseNumberOfSet";
99 char const FIELD_SERVICE_DB_NUMBER[] = "DatabaseSetNumber";
100 char const FIELD_SERVICE_DB_DISPLAY[] = "Database";
101 char const FIELD_SERVICE_DB_NAME[] = "DatabaseName";
102 char const FIELD_SERVICE_CONDITIONAL_TEXT[] = "ConditionalText";
103 char const FIELD_SERVICE_HIDDEN_TEXT[] = "HiddenText";
104 char const FIELD_SERVICE_HIDDEN_PARAGRAPH[] = "HiddenParagraph";
105 char const FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR[] = "DocInfo.ChangeAuthor";
106 char const FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR2[] = "docinfo.ChangeAuthor";
107 char const FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME[] = "DocInfo.ChangeDateTime";
108 char const FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME2[] = "docinfo.ChangeDateTime";
109 char const FIELD_SERVICE_DOC_INFO_EDIT_TIME[] = "DocInfo.EditTime";
110 char const FIELD_SERVICE_DOC_INFO_EDIT_TIME2[] = "docinfo.EditTime";
111 char const FIELD_SERVICE_DOC_INFO_DESCRIPTION[] = "DocInfo.Description";
112 char const FIELD_SERVICE_DOC_INFO_DESCRIPTION2[] = "docinfo.Description";
113 char const FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR[] = "DocInfo.CreateAuthor";
114 char const FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR2[] = "docinfo.CreateAuthor";
115 char const FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME[] = "DocInfo.CreateDateTime";
116 char const FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME2[] = "docinfo.CreateDateTime";
117 char const FIELD_SERVICE_DOC_INFO_CUSTOM[] = "DocInfo.Custom";
118 char const FIELD_SERVICE_DOC_INFO_CUSTOM2[] = "docinfo.Custom";
119 char const FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR[] = "DocInfo.PrintAuthor";
120 char const FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR2[] = "docinfo.PrintAuthor";
121 char const FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME[] = "DocInfo.PrintDateTime";
122 char const FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME2[] = "docinfo.PrintDateTime";
123 char const FIELD_SERVICE_DOC_INFO_KEY_WORDS[] = "DocInfo.KeyWords";
124 char const FIELD_SERVICE_DOC_INFO_KEY_WORDS2[] = "docinfo.KeyWords";
125 char const FIELD_SERVICE_DOC_INFO_SUBJECT[] = "DocInfo.Subject";
126 char const FIELD_SERVICE_DOC_INFO_SUBJECT2[] = "docinfo.Subject";
127 char const FIELD_SERVICE_DOC_INFO_TITLE[] = "DocInfo.Title";
128 char const FIELD_SERVICE_DOC_INFO_TITLE2[] = "docinfo.Title";
129 char const FIELD_SERVICE_DOC_INFO_REVISION[] = "DocInfo.Revision";
130 char const FIELD_SERVICE_DOC_INFO_REVISION2[] = "docinfo.Revision";
131 char const FIELD_SERVICE_FILE_NAME[] = "FileName";
132 char const FIELD_SERVICE_CHAPTER[] = "Chapter";
133 char const FIELD_SERVICE_TEMPLATE_NAME[] = "TemplateName";
134 char const FIELD_SERVICE_PAGE_COUNT[] = "PageCount";
135 char const FIELD_SERVICE_PARAGRAPH_COUNT[] = "ParagraphCount";
136 char const FIELD_SERVICE_WORD_COUNT[] = "WordCount";
137 char const FIELD_SERVICE_CHARACTER_COUNT[] = "CharacterCount";
138 char const FIELD_SERVICE_TABLE_COUNT[] = "TableCount";
139 char const FIELD_SERVICE_GRAPHIC_COUNT[] = "GraphicObjectCount";
140 char const FIELD_SERVICE_OBJECT_COUNT[] = "EmbeddedObjectCount";
141 char const FIELD_SERVICE_REFERENCE_PAGE_SET[] = "ReferencePageSet";
142 char const FIELD_SERVICE_REFERENCE_PAGE_GET[] = "ReferencePageGet";
143 char const FIELD_SERVICE_SHEET_NAME[] = "SheetName";
144 char const FIELD_SERVICE_PAGE_NAME[] = "PageName";
145 char const FIELD_SERVICE_MACRO[] = "Macro";
146 char const FIELD_SERVICE_GET_REFERENCE[] = "GetReference";
147 char const FIELD_SERVICE_DDE[] = "DDE";
148 char const FIELD_SERVICE_URL[] = "URL";
149 char const FIELD_SERVICE_BIBLIOGRAPHY[] = "Bibliography";
150 char const FIELD_SERVICE_SCRIPT[] = "Script";
151 char const FIELD_SERVICE_ANNOTATION[] = "Annotation";
152 char const FIELD_SERVICE_COMBINED_CHARACTERS[] = "CombinedCharacters";
153 char const FIELD_SERVICE_META[] = "MetadataField";
154 char const FIELD_SERVICE_MEASURE[] = "Measure";
155 char const FIELD_SERVICE_TABLE_FORMULA[] = "TableFormula";
156 char const FIELD_SERVICE_DROP_DOWN[] = "DropDown";
157 
158 namespace
159 {
161 uno::Reference<text::XText> GetToplevelText(const uno::Reference<text::XText>& xText)
162 {
163  uno::Reference<text::XText> xRet = xText;
164  while (true)
165  {
166  uno::Reference<beans::XPropertySet> xPropertySet(xRet, uno::UNO_QUERY);
167  if (!xPropertySet.is())
168  return xRet;
169 
170  if (!xPropertySet->getPropertySetInfo()->hasPropertyByName("ParentText"))
171  return xRet;
172 
173  uno::Reference<text::XText> xParent;
174  if (xPropertySet->getPropertyValue("ParentText") >>= xParent)
175  xRet = xParent;
176  else
177  return xRet;
178  }
179  return xRet;
180 }
181 }
182 
184 {
197 
202  // workaround for #no-bug#: Database/DataBase
205 
232 
236 
240 
248 
252 
254 
257 
260 
261  // non-writer fields
266 
267  // deprecated fields
270 
271  { nullptr, 0, FieldIdEnum(0) }
272 };
273 
274 
275 // property accessor helper functions
276 static bool GetBoolProperty(const OUString&,
277  const Reference<XPropertySet> &);
278 static bool GetOptionalBoolProperty(const OUString&,
279  const Reference<XPropertySet> &,
280  const Reference<XPropertySetInfo> &,
281  bool bDefault);
282 static double GetDoubleProperty(const OUString&,
283  const Reference<XPropertySet> &);
284 static OUString GetStringProperty(const OUString&,
285  const Reference<XPropertySet> &);
286 static sal_Int32 GetIntProperty(const OUString&,
287  const Reference<XPropertySet> &);
288 static sal_Int16 GetInt16Property(const OUString&,
289  const Reference<XPropertySet> &);
290 static sal_Int8 GetInt8Property(const OUString&,
291  const Reference<XPropertySet> &);
292 static util::DateTime GetDateTimeProperty( const OUString& sPropName,
293  const Reference<XPropertySet> & xPropSet);
295  const OUString& sPropName,
296  const Reference<XPropertySet> & xPropSet);
297 
298 
299  // service names
300 constexpr OUStringLiteral gsServicePrefix(u"com.sun.star.text.textfield.");
301 constexpr OUStringLiteral gsFieldMasterPrefix(u"com.sun.star.text.FieldMaster.");
302 constexpr OUStringLiteral gsPresentationServicePrefix(u"com.sun.star.presentation.TextField.");
303 
304  // property names
305 constexpr OUStringLiteral gsPropertyAdjust(u"Adjust");
306 constexpr OUStringLiteral gsPropertyAuthor(u"Author");
307 constexpr OUStringLiteral gsPropertyChapterFormat(u"ChapterFormat");
308 constexpr OUStringLiteral gsPropertyChapterNumberingLevel(u"ChapterNumberingLevel");
309 constexpr OUStringLiteral gsPropertyCharStyleNames(u"CharStyleNames");
310 constexpr OUStringLiteral gsPropertyCondition(u"Condition");
311 constexpr OUStringLiteral gsPropertyContent(u"Content");
312 constexpr OUStringLiteral gsPropertyDataBaseName(u"DataBaseName");
313 constexpr OUStringLiteral gsPropertyDataBaseURL(u"DataBaseURL");
314 constexpr OUStringLiteral gsPropertyDataColumnName(u"DataColumnName");
315 constexpr OUStringLiteral gsPropertyDataCommandType(u"DataCommandType");
316 constexpr OUStringLiteral gsPropertyDataTableName(u"DataTableName");
317 constexpr OUStringLiteral gsPropertyDateTime(u"DateTime");
318 constexpr OUStringLiteral gsPropertyDateTimeValue(u"DateTimeValue");
319 constexpr OUStringLiteral gsPropertyDDECommandElement(u"DDECommandElement");
320 constexpr OUStringLiteral gsPropertyDDECommandFile(u"DDECommandFile");
321 constexpr OUStringLiteral gsPropertyDDECommandType(u"DDECommandType");
322 constexpr OUStringLiteral gsPropertyDependentTextFields(u"DependentTextFields");
323 constexpr OUStringLiteral gsPropertyFalseContent(u"FalseContent");
324 constexpr OUStringLiteral gsPropertyFields(u"Fields");
325 constexpr OUStringLiteral gsPropertyFieldSubType(u"UserDataType");
326 constexpr OUStringLiteral gsPropertyFileFormat(u"FileFormat");
327 constexpr OUStringLiteral gsPropertyFullName(u"FullName");
328 constexpr OUStringLiteral gsPropertyHint(u"Hint");
329 constexpr OUStringLiteral gsPropertyInitials(u"Initials");
330 constexpr OUStringLiteral gsPropertyInstanceName(u"InstanceName");
331 constexpr OUStringLiteral gsPropertyIsAutomaticUpdate(u"IsAutomaticUpdate");
332 constexpr OUStringLiteral gsPropertyIsConditionTrue(u"IsConditionTrue");
333 constexpr OUStringLiteral gsPropertyIsDataBaseFormat(u"DataBaseFormat");
334 constexpr OUStringLiteral gsPropertyIsDate(u"IsDate");
335 constexpr OUStringLiteral gsPropertyIsExpression(u"IsExpression");
336 constexpr OUStringLiteral gsPropertyIsFixed(u"IsFixed");
337 constexpr OUStringLiteral gsPropertyIsFixedLanguage(u"IsFixedLanguage");
338 constexpr OUStringLiteral gsPropertyIsHidden(u"IsHidden");
339 constexpr OUStringLiteral gsPropertyIsInput(u"Input");
340 constexpr OUStringLiteral gsPropertyIsShowFormula(u"IsShowFormula");
341 constexpr OUStringLiteral gsPropertyIsVisible(u"IsVisible");
342 constexpr OUStringLiteral gsPropertyItems(u"Items");
343 constexpr OUStringLiteral gsPropertyLevel(u"Level");
344 constexpr OUStringLiteral gsPropertyMeasureKind(u"Kind");
345 constexpr OUStringLiteral gsPropertyName(u"Name");
346 constexpr OUStringLiteral gsPropertyNumberFormat(u"NumberFormat");
347 constexpr OUStringLiteral gsPropertyNumberingSeparator(u"NumberingSeparator");
348 constexpr OUStringLiteral gsPropertyNumberingType(u"NumberingType");
349 constexpr OUStringLiteral gsPropertyOffset(u"Offset");
350 constexpr OUStringLiteral gsPropertyOn(u"On");
351 constexpr OUStringLiteral gsPropertyPlaceholderType(u"PlaceHolderType");
352 constexpr OUStringLiteral gsPropertyReferenceFieldPart(u"ReferenceFieldPart");
353 constexpr OUStringLiteral gsPropertyReferenceFieldSource(u"ReferenceFieldSource");
354 constexpr OUStringLiteral gsPropertyReferenceFieldLanguage(u"ReferenceFieldLanguage");
355 constexpr OUStringLiteral gsPropertyScriptType(u"ScriptType");
356 constexpr OUStringLiteral gsPropertySelectedItem(u"SelectedItem");
357 constexpr OUStringLiteral gsPropertySequenceNumber(u"SequenceNumber");
358 constexpr OUStringLiteral gsPropertySequenceValue(u"SequenceValue");
359 constexpr OUStringLiteral gsPropertySetNumber(u"SetNumber");
360 constexpr OUStringLiteral gsPropertySourceName(u"SourceName");
361 constexpr OUStringLiteral gsPropertySubType(u"SubType");
362 constexpr OUStringLiteral gsPropertyTargetFrame(u"TargetFrame");
363 constexpr OUStringLiteral gsPropertyTrueContent(u"TrueContent");
364 constexpr OUStringLiteral gsPropertyURL(u"URL");
365 constexpr OUStringLiteral gsPropertyURLContent(u"URLContent");
366 constexpr OUStringLiteral gsPropertyUserText(u"UserText");
367 constexpr OUStringLiteral gsPropertyValue(u"Value");
368 constexpr OUStringLiteral gsPropertyVariableName(u"VariableName");
369 constexpr OUStringLiteral gsPropertyHelp(u"Help");
370 constexpr OUStringLiteral gsPropertyTooltip(u"Tooltip");
371 constexpr OUStringLiteral gsPropertyTextRange(u"TextRange");
372 
374  std::unique_ptr<XMLPropertyState> pCombinedCharState)
375  : rExport(rExp),
376  pCombinedCharactersPropertyState(std::move(pCombinedCharState))
377 {
379 }
380 
382 {
383 }
384 
387  const Reference<XTextField> & rTextField,
388  const Reference<XPropertySet> & xPropSet)
389 {
390  // get service names for rTextField (via XServiceInfo service)
391  Reference<XServiceInfo> xService(rTextField, UNO_QUERY);
392  const Sequence<OUString> aServices = xService->getSupportedServiceNames();
393 
394  OUString sFieldName; // service name postfix of current field
395 
396  // search for TextField service name
397  const OUString* pNames = std::find_if(aServices.begin(), aServices.end(),
398  [](const OUString& rName) { return rName.matchIgnoreAsciiCase(gsServicePrefix); });
399  if (pNames != aServices.end())
400  {
401  // TextField found => postfix is field type!
402  sFieldName = pNames->copy(gsServicePrefix.getLength());
403  }
404 
405  // if this is not a normal text field, check if it's a presentation text field
406  if( sFieldName.isEmpty() )
407  {
408  // search for TextField service name
409  pNames = std::find_if(aServices.begin(), aServices.end(),
410  [](const OUString& rName) { return rName.startsWith(gsPresentationServicePrefix); });
411  if (pNames != aServices.end())
412  {
413  // TextField found => postfix is field type!
414  sFieldName = pNames->copy(gsPresentationServicePrefix.getLength());
415  }
416 
417  if( !sFieldName.isEmpty() )
418  {
419  if( sFieldName == "Header" )
420  {
421  return FIELD_ID_DRAW_HEADER;
422  }
423  else if( sFieldName == "Footer" )
424  {
425  return FIELD_ID_DRAW_FOOTER;
426  }
427  else if( sFieldName == "DateTime" )
428  {
430  }
431  }
432  }
433 
434  // map postfix of service name to field ID
435  DBG_ASSERT(!sFieldName.isEmpty(), "no TextField service found!");
436  return MapFieldName(sFieldName, xPropSet);
437 }
438 
440  std::u16string_view sFieldName, // field (master) name
441  const Reference<XPropertySet> & xPropSet) // for subtype
442 {
443  // we'll proceed in 2 steps:
444  // a) map service name to preliminary FIELD_ID
445  // b) map those prelim. FIELD_IDs that correspond to several field types
446  // (in our (XML) world) to final FIELD IDs
447 
448 
449  // a) find prelim. FIELD_ID via aFieldServiceMapping
450 
451  // check for non-empty service name
452  DBG_ASSERT(!sFieldName.empty(), "no valid service name!");
454  if (!sFieldName.empty())
455  {
456  // map name to prelim. ID
458  nToken, sFieldName, aFieldServiceNameMapping);
459 
460  // check return
461  DBG_ASSERT(bRet, "Unknown field service name encountered!");
462  }
463 
464  // b) map prelim. to final FIELD_IDs
465  switch (nToken) {
467  if (GetBoolProperty(gsPropertyIsInput, xPropSet))
468  {
469  nToken = FIELD_ID_VARIABLE_INPUT;
470  }
471  else
472  {
473  switch (GetIntProperty(gsPropertySubType, xPropSet))
474  {
475  case SetVariableType::STRING: // text field
476  case SetVariableType::VAR: // num field
477  nToken = FIELD_ID_VARIABLE_SET;
478  break;
479  case SetVariableType::SEQUENCE:
480  nToken = FIELD_ID_SEQUENCE;
481  break;
482  case SetVariableType::FORMULA:
483  default:
484  nToken = FIELD_ID_UNKNOWN;
485  break;
486  }
487  }
488  break;
489 
491  switch (GetIntProperty(gsPropertySubType, xPropSet))
492  {
493  case SetVariableType::STRING: // text field
494  case SetVariableType::VAR: // num field
495  nToken = FIELD_ID_VARIABLE_GET;
496  break;
497  case SetVariableType::FORMULA:
498  nToken = FIELD_ID_EXPRESSION;
499  break;
500  case SetVariableType::SEQUENCE:
501  default:
502  nToken = FIELD_ID_UNKNOWN;
503  break;
504  }
505  break;
506 
507  case FIELD_ID_TIME:
508  if (GetBoolProperty(gsPropertyIsDate, xPropSet))
509  {
510  nToken = FIELD_ID_DATE;
511  }
512  break;
513 
514  case FIELD_ID_PAGENUMBER:
515  // NumberingType not available in non-Writer apps
516  if (xPropSet->getPropertySetInfo()->
517  hasPropertyByName(gsPropertyNumberingType))
518  {
519  if (NumberingType::CHAR_SPECIAL == GetIntProperty(
520  gsPropertyNumberingType, xPropSet))
521  {
522  nToken = FIELD_ID_PAGESTRING;
523  }
524  }
525  break;
526 
528  if (GetBoolProperty(gsPropertyIsDate, xPropSet))
529  {
531  }
532  break;
533 
535  if (GetBoolProperty(gsPropertyIsDate, xPropSet))
536  {
538  }
539  break;
540 
542  if (GetBoolProperty(gsPropertyIsDate, xPropSet))
543  {
545  }
546  break;
547 
550  {
551  case ReferenceFieldSource::REFERENCE_MARK:
552  nToken = FIELD_ID_REF_REFERENCE;
553  break;
554  case ReferenceFieldSource::SEQUENCE_FIELD:
555  nToken = FIELD_ID_REF_SEQUENCE;
556  break;
557  case ReferenceFieldSource::BOOKMARK:
558  nToken = FIELD_ID_REF_BOOKMARK;
559  break;
560  case ReferenceFieldSource::FOOTNOTE:
561  nToken = FIELD_ID_REF_FOOTNOTE;
562  break;
563  case ReferenceFieldSource::ENDNOTE:
564  nToken = FIELD_ID_REF_ENDNOTE;
565  break;
566  default:
567  nToken = FIELD_ID_UNKNOWN;
568  break;
569  }
570  break;
571 
573  case FIELD_ID_SCRIPT:
574  case FIELD_ID_ANNOTATION:
576  case FIELD_ID_DDE:
577  case FIELD_ID_MACRO:
600  case FIELD_ID_TEXT_INPUT:
601  case FIELD_ID_USER_INPUT:
602  case FIELD_ID_AUTHOR:
603  case FIELD_ID_SENDER:
605  case FIELD_ID_USER_GET:
612  case FIELD_ID_CHAPTER:
613  case FIELD_ID_FILE_NAME:
614  case FIELD_ID_META:
615  case FIELD_ID_SHEET_NAME:
616  case FIELD_ID_PAGENAME:
617  case FIELD_ID_MEASURE:
618  case FIELD_ID_URL:
620  case FIELD_ID_DROP_DOWN:
621  ; // these field IDs are final
622  break;
623 
624  default:
625  nToken = FIELD_ID_UNKNOWN;
626  }
627 
628  // ... and return final FIELD_ID
629  return nToken;
630 }
631 
632 // is string or numeric field?
634  FieldIdEnum nFieldType,
635  const Reference<XPropertySet> & xPropSet)
636 {
637  switch (nFieldType) {
638 
642  {
643  // depends on field sub type
644  return ( GetIntProperty(gsPropertySubType, xPropSet) ==
645  SetVariableType::STRING );
646  }
647 
648  case FIELD_ID_USER_GET:
649  case FIELD_ID_USER_INPUT:
650  {
651  Reference<XTextField> xTextField(xPropSet, UNO_QUERY);
652  DBG_ASSERT(xTextField.is(), "field is no XTextField!");
654  GetMasterPropertySet(xTextField));
655  return !bRet;
656  }
657 
658  case FIELD_ID_META:
659  return 0 > GetIntProperty(gsPropertyNumberFormat, xPropSet);
660 
662  // TODO: depends on... ???
663  // workaround #no-bug#: no data type
664  return 5100 == GetIntProperty(gsPropertyNumberFormat, xPropSet);
665 
667  // legacy field: always a number field (because it always has
668  // a number format)
669  return false;
670 
687  case FIELD_ID_EXPRESSION:
688  case FIELD_ID_SEQUENCE:
689  case FIELD_ID_DATE:
690  case FIELD_ID_TIME:
691  case FIELD_ID_PAGENUMBER:
695  // always number
696  return false;
697 
700  case FIELD_ID_DDE:
706  case FIELD_ID_MACRO:
708  case FIELD_ID_CHAPTER:
709  case FIELD_ID_FILE_NAME:
721  case FIELD_ID_TEXT_INPUT:
722  case FIELD_ID_SENDER:
723  case FIELD_ID_AUTHOR:
724  case FIELD_ID_PAGENAME:
725  case FIELD_ID_PAGESTRING:
726  case FIELD_ID_SHEET_NAME:
727  case FIELD_ID_MEASURE:
728  case FIELD_ID_URL:
729  case FIELD_ID_DROP_DOWN:
730  // always string:
731  return true;
732 
733  case FIELD_ID_SCRIPT:
734  case FIELD_ID_ANNOTATION:
738  case FIELD_ID_UNKNOWN:
742  default:
743  OSL_FAIL("unknown field type/field has no content");
744  return true; // invalid info; string in case of doubt
745  }
746 }
747 
751  const Reference<XTextField> & rTextField, const bool bProgress,
752  const bool bRecursive )
753 {
754  // get property set
755  Reference<XPropertySet> xPropSet(rTextField, UNO_QUERY);
756 
757  // add field master to list of used field masters (if desired)
758  if (nullptr != pUsedMasters)
759  {
760  Reference<XDependentTextField> xDepField(rTextField, UNO_QUERY);
761  if (xDepField.is())
762  {
763  // The direct parent may be just the table cell, while we want the topmost parent, e.g.
764  // a header text.
765  Reference<XText> xOurText = GetToplevelText(rTextField->getAnchor()->getText());
766 
767  map<Reference<XText>, set<OUString> >::iterator aMapIter =
768  pUsedMasters->find(xOurText);
769 
770  // insert a list for our XText (if necessary)
771  if (aMapIter == pUsedMasters->end())
772  {
773  set<OUString> aSet;
774  (*pUsedMasters)[xOurText] = aSet;
775  aMapIter = pUsedMasters->find(xOurText);
776  }
777 
778  // insert this text field master
779  OUString sFieldMasterName = GetStringProperty(
780  gsPropertyInstanceName, xDepField->getTextFieldMaster());
781  if (!sFieldMasterName.isEmpty())
782  aMapIter->second.insert( sFieldMasterName );
783  }
784  // else: no dependent field -> no master -> ignore
785  }
786 
787  // get Field ID
788  FieldIdEnum nToken = GetFieldID(rTextField, xPropSet);
789 
790  // export the character style for all fields
791  // with one exception: combined character fields export their own
792  // text style below
793  Reference <XPropertySet> xRangePropSet(rTextField->getAnchor(), UNO_QUERY);
794  if (FIELD_ID_COMBINED_CHARACTERS != nToken)
795  {
797  XmlStyleFamily::TEXT_TEXT, xRangePropSet);
798  }
799 
800  // process special styles for each field (e.g. data styles)
801  switch (nToken) {
802 
804  {
805  sal_Int32 nFormat = GetIntProperty(gsPropertyNumberFormat, xPropSet);
806  // workaround: #no-bug#; see IsStringField(...)
807  if ( (5100 != nFormat) &&
809  {
810  GetExport().addDataStyle(nFormat);
811  }
812  break;
813  }
814 
815  case FIELD_ID_DATE:
816  case FIELD_ID_TIME:
817  {
818  // date and time fields are always number fields, but the
819  // NumberFormat property is optional (e.g. Calc doesn't
820  // support it)
821  Reference<XPropertySetInfo> xPropSetInfo(
822  xPropSet->getPropertySetInfo() );
823  if ( xPropSetInfo->hasPropertyByName( gsPropertyNumberFormat ) )
824  {
825  sal_Int32 nFormat =
827 
828  // nFormat may be -1 for numeric fields that display their
829  // variable name. (Maybe this should be a field type, then?)
830  if (nFormat != -1)
831  {
834  xPropSet, xPropSetInfo, false ) )
835  {
836  nFormat =
838  }
839 
840  GetExport().addDataStyle( nFormat,
841  nToken == FIELD_ID_TIME );
842  }
843  }
844  }
845  break;
846 
847  case FIELD_ID_META:
848  // recurse into content (does not export element, so can be done first)
849  if (bRecursive)
850  {
851  bool dummy_for_autostyles(true);
852  ExportMetaField(xPropSet, true, bProgress, dummy_for_autostyles);
853  }
854  [[fallthrough]];
865  case FIELD_ID_USER_GET:
866  case FIELD_ID_EXPRESSION:
869  // register number format, if this is a numeric field
870  if (! IsStringField(nToken, xPropSet)) {
871 
872  sal_Int32 nFormat =
874 
875  // nFormat may be -1 for numeric fields that display their
876  // variable name. (Maybe this should be a field type, then?)
877  if (nFormat != -1)
878  {
879  // handle formats for fixed language fields
880  // for all these fields (except table formula)
881  if( ( nToken != FIELD_ID_TABLE_FORMULA ) &&
884  xPropSet, xPropSet->getPropertySetInfo(),
885  false ) )
886  {
887  nFormat =
889  }
890 
891  GetExport().addDataStyle(nFormat);
892  }
893  }
894  break;
895 
897  {
898  // export text style with the addition of the combined characters
900  "need proper PropertyState for combined characters");
903  XmlStyleFamily::TEXT_TEXT, xRangePropSet,
904  aStates);
905  break;
906  }
907 
908  case FIELD_ID_SCRIPT:
909  case FIELD_ID_ANNOTATION:
911  case FIELD_ID_DDE:
917  case FIELD_ID_MACRO:
938  case FIELD_ID_SEQUENCE:
939  case FIELD_ID_PAGENAME:
940  case FIELD_ID_PAGENUMBER:
941  case FIELD_ID_PAGESTRING:
942  case FIELD_ID_AUTHOR:
943  case FIELD_ID_SENDER:
945  case FIELD_ID_USER_INPUT:
946  case FIELD_ID_TEXT_INPUT:
952  case FIELD_ID_CHAPTER:
953  case FIELD_ID_FILE_NAME:
954  case FIELD_ID_SHEET_NAME:
955  case FIELD_ID_MEASURE:
956  case FIELD_ID_URL:
957  case FIELD_ID_DROP_DOWN:
961  ; // no formats for these fields!
962  break;
963 
964  case FIELD_ID_UNKNOWN:
965  default:
966  OSL_FAIL("unknown field type!");
967  // ignore -> no format for unknown
968  break;
969  }
970 }
971 
974  const Reference<XTextField> & rTextField, bool bProgress,
975  bool & rPrevCharIsSpace)
976 {
977  // get property set
978  Reference<XPropertySet> xPropSet(rTextField, UNO_QUERY);
979 
980  // get property set of range (for the attributes)
981  Reference <XPropertySet> xRangePropSet(rTextField->getAnchor(), UNO_QUERY);
982 
983  // get Field ID
984  enum FieldIdEnum nToken = GetFieldID(rTextField, xPropSet);
985 
986  // special treatment for combined characters field, because it is
987  // exported as a style
988  const XMLPropertyState* aStates[] = { pCombinedCharactersPropertyState.get(), nullptr };
989  const XMLPropertyState **pStates =
991  ? aStates
992  : nullptr;
993 
994  // find out whether we need to set the style or hyperlink
995  bool bHasHyperlink;
996  bool bIsUICharStyle;
997  bool bHasAutoStyle;
998  OUString sStyle = GetExport().GetTextParagraphExport()->
999  FindTextStyleAndHyperlink( xRangePropSet, bHasHyperlink, bIsUICharStyle,
1000  bHasAutoStyle, pStates );
1001  bool bHasStyle = !sStyle.isEmpty();
1002 
1003  // export hyperlink (if we have one)
1004  Reference < XPropertySetInfo > xRangePropSetInfo;
1005  if( bHasHyperlink )
1006  {
1007  Reference<XPropertyState> xRangePropState( xRangePropSet, UNO_QUERY );
1008  xRangePropSetInfo = xRangePropSet->getPropertySetInfo();
1009  bHasHyperlink =
1010  GetExport().GetTextParagraphExport()->addHyperlinkAttributes(
1011  xRangePropSet, xRangePropState,
1012  xRangePropSetInfo );
1013  }
1014  SvXMLElementExport aHyperlink( GetExport(), bHasHyperlink,
1016  false, false );
1017 
1018  if( bHasHyperlink )
1019  {
1020  // export events (if supported)
1021  OUString sHyperLinkEvents("HyperLinkEvents");
1022  if (xRangePropSetInfo->hasPropertyByName(sHyperLinkEvents))
1023  {
1024  Any aAny = xRangePropSet->getPropertyValue(sHyperLinkEvents);
1025  Reference<XNameReplace> xName;
1026  aAny >>= xName;
1027  GetExport().GetEventExport().Export(xName, false);
1028  }
1029  }
1030 
1031  {
1032  XMLTextCharStyleNamesElementExport aCharStylesExport(
1033  GetExport(), bIsUICharStyle &&
1034  GetExport().GetTextParagraphExport()
1035  ->GetCharStyleNamesPropInfoCache().hasProperty(
1036  xRangePropSet, xRangePropSetInfo ), bHasAutoStyle,
1037  xRangePropSet, gsPropertyCharStyleNames );
1038 
1039  // export span with style (if necessary)
1040  // (except for combined characters field)
1041  if( bHasStyle )
1042  {
1043  // export <text:span> element
1045  GetExport().EncodeStyleName( sStyle ) );
1046  }
1047  SvXMLElementExport aSpan( GetExport(), bHasStyle,
1049  false, false);
1050 
1051  // finally, export the field itself
1052  ExportFieldHelper( rTextField, xPropSet, xRangePropSet, nToken,
1053  bProgress, rPrevCharIsSpace);
1054  }
1055 }
1056 
1059  const Reference<XTextField> & rTextField,
1060  const Reference<XPropertySet> & rPropSet,
1061  const Reference<XPropertySet> &,
1062  enum FieldIdEnum nToken,
1063  bool bProgress,
1064  bool & rPrevCharIsSpace)
1065 {
1066  // get property set info (because some attributes are not support
1067  // in all implementations)
1068  Reference<XPropertySetInfo> xPropSetInfo(rPropSet->getPropertySetInfo());
1069 
1070  OUString sPresentation = rTextField->getPresentation(false);
1071 
1072  // process each field type
1073  switch (nToken) {
1074  case FIELD_ID_AUTHOR:
1075  // author field: fixed, field (sub-)type
1076  if (xPropSetInfo->hasPropertyByName(gsPropertyIsFixed))
1077  {
1080  }
1081  ExportElement(MapAuthorFieldName(rPropSet), sPresentation);
1082  break;
1083 
1084  case FIELD_ID_SENDER:
1085  // sender field: fixed, field (sub-)type
1087  GetBoolProperty(gsPropertyIsFixed, rPropSet), true);
1088  ExportElement(MapSenderFieldName(rPropSet), sPresentation);
1089  break;
1090 
1091  case FIELD_ID_PLACEHOLDER:
1092  // placeholder field: type, name, description
1097  GetStringProperty(gsPropertyHint,rPropSet), true);
1098  ExportElement(XML_PLACEHOLDER, sPresentation);
1099  break;
1100 
1101  case FIELD_ID_VARIABLE_SET:
1102  {
1103  // variable set field: name, visible, format&value
1107  false);
1110  sPresentation);
1111  ProcessValueAndType(IsStringField(nToken, rPropSet),
1114  sPresentation,
1116  true, true, true,
1119  rPropSet, xPropSetInfo, false ) );
1120  ExportElement(XML_VARIABLE_SET, sPresentation);
1121  break;
1122  }
1123  case FIELD_ID_VARIABLE_GET:
1124  {
1125  // variable get field: name, format&value
1128  bool bCmd = GetBoolProperty(gsPropertyIsShowFormula, rPropSet);
1129  ProcessDisplay(true, bCmd);
1130  // show style, unless name will be shown
1131  ProcessValueAndType(IsStringField(nToken, rPropSet),
1133  "", u"", 0.0, // values not used
1134  false,
1135  false,
1136  !bCmd,
1139  rPropSet, xPropSetInfo, false ) );
1140  ExportElement(XML_VARIABLE_GET, sPresentation);
1141  break;
1142  }
1144  // variable input field: name, description, format&value
1148  GetStringProperty(gsPropertyHint , rPropSet));
1150  false);
1153  sPresentation);
1154  ProcessValueAndType(IsStringField(nToken, rPropSet),
1157  sPresentation,
1159  true, true, true,
1162  rPropSet, xPropSetInfo, false ) );
1163  ExportElement(XML_VARIABLE_INPUT, sPresentation);
1164  break;
1165 
1166  case FIELD_ID_USER_GET:
1167  // user field: name, hidden, style
1168  {
1169  bool bCmd = GetBoolProperty(gsPropertyIsShowFormula, rPropSet);
1171  bCmd);
1172  ProcessValueAndType(IsStringField(nToken, rPropSet),
1174  "", u"", 0.0, // values not used
1175  false, false, !bCmd,
1178  rPropSet, xPropSetInfo, false ) );
1179 
1180  // name from FieldMaster
1183  GetMasterPropertySet(rTextField)));
1184  ExportElement(XML_USER_FIELD_GET, sPresentation);
1185  break;
1186  }
1187 
1188  case FIELD_ID_USER_INPUT:
1189  // user input field: name (from FieldMaster), description
1190 // ProcessString(XML_NAME,
1191 // GetStringProperty(sPropertyName,
1192 // GetMasterPropertySet(rTextField)));
1196  GetStringProperty(gsPropertyHint, rPropSet));
1197  ExportElement(XML_USER_FIELD_INPUT, sPresentation);
1198  break;
1199 
1200  case FIELD_ID_SEQUENCE:
1201  {
1202  // sequence field: name, formula, seq-format
1203  OUString sName = GetStringProperty(gsPropertyVariableName, rPropSet);
1204  // TODO: use reference name only if actually being referenced.
1208  sName));
1209  ProcessString(XML_NAME, sName);
1212  sPresentation);
1214  rPropSet));
1215  ExportElement(XML_SEQUENCE, sPresentation);
1216  break;
1217  }
1218 
1219  case FIELD_ID_EXPRESSION:
1220  {
1221  // formula field: formula, format&value
1222  bool bCmd = GetBoolProperty(gsPropertyIsShowFormula, rPropSet);
1225  sPresentation);
1226  ProcessDisplay(true, bCmd);
1227  ProcessValueAndType(IsStringField(nToken, rPropSet),
1230  sPresentation,
1232  !bCmd, !bCmd, !bCmd,
1235  rPropSet, xPropSetInfo, false ) );
1236  ExportElement(XML_EXPRESSION, sPresentation);
1237  break;
1238  }
1239 
1240  case FIELD_ID_TEXT_INPUT:
1241  // text input field: description and string-value
1243  GetStringProperty(gsPropertyHint, rPropSet));
1245  GetStringProperty(gsPropertyHelp, rPropSet), true);
1247  GetStringProperty(gsPropertyTooltip, rPropSet), true);
1248  ExportElement(XML_TEXT_INPUT, sPresentation);
1249  break;
1250 
1251  case FIELD_ID_TIME:
1252  // all properties (except IsDate) are optional!
1253  if (xPropSetInfo->hasPropertyByName(gsPropertyNumberFormat))
1254  {
1255  ProcessValueAndType(false,
1257  "", u"", 0.0, // not used
1258  false, false, true,
1261  rPropSet, xPropSetInfo, false ),
1262  true);
1263  }
1264  if (xPropSetInfo->hasPropertyByName(gsPropertyDateTimeValue))
1265  {
1266  // no value -> current time
1269  rPropSet));
1270  }
1271  if (xPropSetInfo->hasPropertyByName(gsPropertyDateTime))
1272  {
1273  // no value -> current time
1276  }
1277  if (xPropSetInfo->hasPropertyByName(gsPropertyIsFixed))
1278  {
1281  false);
1282  }
1283  if (xPropSetInfo->hasPropertyByName(gsPropertyAdjust))
1284  {
1285  // adjust value given as integer in minutes
1287  GetIntProperty(gsPropertyAdjust, rPropSet),
1288  false, true);
1289  }
1290  ExportElement(XML_TIME, sPresentation);
1291  break;
1292 
1293  case FIELD_ID_DATE:
1294  // all properties (except IsDate) are optional!
1295  if (xPropSetInfo->hasPropertyByName(gsPropertyNumberFormat))
1296  {
1297  ProcessValueAndType(false,
1299  "", u"", 0.0, // not used
1300  false, false, true,
1303  rPropSet, xPropSetInfo, false ) );
1304  }
1305  if (xPropSetInfo->hasPropertyByName(gsPropertyDateTimeValue))
1306  {
1307  // no value -> current date
1310  rPropSet));
1311  }
1312  // TODO: remove double-handling after SRC614
1313  else if (xPropSetInfo->hasPropertyByName(gsPropertyDateTime))
1314  {
1317  }
1318  if (xPropSetInfo->hasPropertyByName(gsPropertyIsFixed))
1319  {
1322  false);
1323  }
1324  if (xPropSetInfo->hasPropertyByName(gsPropertyAdjust))
1325  {
1326  // adjust value given as number of days
1328  GetIntProperty(gsPropertyAdjust, rPropSet),
1329  true, true);
1330  }
1331  ExportElement(XML_DATE, sPresentation);
1332  break;
1333 
1334  case FIELD_ID_PAGENUMBER:
1335  // all properties are optional
1336  if (xPropSetInfo->hasPropertyByName(gsPropertyNumberingType))
1337  {
1339  rPropSet));
1340  }
1341  if (xPropSetInfo->hasPropertyByName(gsPropertyOffset))
1342  {
1343  sal_Int32 nAdjust = GetIntProperty(gsPropertyOffset, rPropSet);
1344 
1345  if (xPropSetInfo->hasPropertyByName(gsPropertySubType))
1346  {
1347  // property SubType used in MapPageNumberName
1349  MapPageNumberName(rPropSet, nAdjust));
1350  }
1351  ProcessIntegerDef(XML_PAGE_ADJUST, nAdjust, 0);
1352  }
1353  ExportElement(XML_PAGE_NUMBER, sPresentation);
1354  break;
1355 
1356  case FIELD_ID_PAGESTRING:
1357  {
1360  sPresentation);
1361  sal_Int32 nDummy = 0; // MapPageNumberName need int
1362  ProcessString(XML_SELECT_PAGE, MapPageNumberName(rPropSet, nDummy));
1363  ExportElement(XML_PAGE_CONTINUATION, sPresentation);
1364  break;
1365  }
1366 
1372  false);
1374  rPropSet, xPropSetInfo);
1375  break;
1376 
1384  GetIntProperty(gsPropertySetNumber, rPropSet));
1386  false);
1388  rPropSet, xPropSetInfo);
1389  break;
1390 
1397  DBG_ASSERT(sPresentation.isEmpty(),
1398  "Unexpected presentation for database next field");
1400  rPropSet, xPropSetInfo);
1401  break;
1402 
1410  GetIntProperty(gsPropertySetNumber, rPropSet));
1411  DBG_ASSERT(sPresentation.isEmpty(),
1412  "Unexpected presentation for database select field");
1414  rPropSet, xPropSetInfo);
1415  break;
1416 
1418  {
1419  // get database, table and column name from field master
1420  const Reference<XPropertySet> & xMaster = GetMasterPropertySet(rTextField);
1426  // export number format if available (happens only for numbers!)
1428  {
1429  ProcessValueAndType(false, // doesn't happen for text
1431  "", u"", 0.0, // not used
1432  false, false, true, false);
1433  }
1435  false);
1437  xMaster, xMaster->getPropertySetInfo());
1438  break;
1439  }
1440 
1443  GetBoolProperty(gsPropertyIsFixed, rPropSet), false);
1444  ExportElement(MapDocInfoFieldName(nToken), sPresentation);
1445  break;
1446 
1454  ProcessValueAndType(false,
1456  "", u"", 0.0,
1457  false, false, true,
1460  rPropSet, xPropSetInfo, false ) );
1461 
1462  // todo: export date/time value, but values not available -> core bug
1464  GetBoolProperty(gsPropertyIsFixed, rPropSet), false);
1465  ExportElement(MapDocInfoFieldName(nToken), sPresentation);
1466  break;
1467 
1475  if (xPropSetInfo->hasPropertyByName(gsPropertyIsFixed))
1476  {
1478  GetBoolProperty(gsPropertyIsFixed, rPropSet), false);
1479  }
1480  ExportElement(MapDocInfoFieldName(nToken), sPresentation);
1481  break;
1482 
1484  {
1485  ProcessValueAndType(false, // doesn't happen for text
1487  "", u"", 0.0, // not used
1488  false, false, true,
1491  rPropSet, xPropSetInfo, false ));
1492  uno::Any aAny = rPropSet->getPropertyValue( gsPropertyName );
1493  OUString sName;
1494  aAny >>= sName;
1495  ProcessString(XML_NAME, sName);
1497  ExportElement(XML_USER_DEFINED, sPresentation);
1498  break;
1499  }
1500 
1501  case FIELD_ID_COUNT_PAGES:
1503  case FIELD_ID_COUNT_WORDS:
1505  case FIELD_ID_COUNT_TABLES:
1508  // all properties optional (applies to pages only, but I'll do
1509  // it for all for sake of common implementation)
1510  if (xPropSetInfo->hasPropertyByName(gsPropertyNumberingType))
1511  {
1513  rPropSet));
1514  }
1515  ExportElement(MapCountFieldName(nToken), sPresentation);
1516  break;
1517 
1527  false);
1528  ExportElement(XML_CONDITIONAL_TEXT, sPresentation);
1529  break;
1530 
1531  case FIELD_ID_HIDDEN_TEXT:
1538  false);
1539  ExportElement(XML_HIDDEN_TEXT, sPresentation);
1540  break;
1541 
1547  false);
1548  DBG_ASSERT(sPresentation.isEmpty(),
1549  "Unexpected presentation for hidden paragraph field");
1551  break;
1552 
1557  ExportElement(XML_TEMPLATE_NAME, sPresentation);
1558  break;
1559 
1560  case FIELD_ID_CHAPTER:
1564  // API numbers 0..9, we number 1..10
1566  GetInt8Property(gsPropertyLevel, rPropSet) + 1);
1567  ExportElement(XML_CHAPTER, sPresentation);
1568  break;
1569 
1570  case FIELD_ID_FILE_NAME:
1571  // all properties are optional
1572  if (xPropSetInfo->hasPropertyByName(gsPropertyFileFormat))
1573  {
1577  }
1578  if (xPropSetInfo->hasPropertyByName(gsPropertyIsFixed))
1579  {
1582  false);
1583  }
1584  ExportElement(XML_FILE_NAME, sPresentation);
1585  break;
1586 
1587  case FIELD_ID_REFPAGE_SET:
1589  GetBoolProperty(gsPropertyOn, rPropSet), true);
1591  GetInt16Property(gsPropertyOffset, rPropSet), 0);
1592  DBG_ASSERT(sPresentation.isEmpty(),
1593  "Unexpected presentation page variable field");
1595  break;
1596 
1597  case FIELD_ID_REFPAGE_GET:
1600  ExportElement(XML_PAGE_VARIABLE_GET, sPresentation);
1601  break;
1602 
1603  case FIELD_ID_MACRO:
1604  ExportMacro( rPropSet, sPresentation );
1605  break;
1606 
1607  case FIELD_ID_REF_SEQUENCE:
1608  // reference to sequence: format, name, find value (and element)
1609  // was: if (nSeqNumber != -1) ...
1612  gsPropertyReferenceFieldPart, rPropSet)),
1613  XML_TEMPLATE);
1617  GetStringProperty(gsPropertySourceName, rPropSet) ) );
1618  if (xPropSetInfo->hasPropertyByName(gsPropertyReferenceFieldLanguage) &&
1620  {
1621  // export text:reference-language attribute, if not empty
1624  }
1625  ExportElement(
1628  sPresentation);
1629  break;
1630 
1632  case FIELD_ID_REF_BOOKMARK:
1633  // reference to bookmarks, references: format, name (and element)
1636  gsPropertyReferenceFieldPart, rPropSet)),
1637  XML_TEMPLATE);
1640  if (xPropSetInfo->hasPropertyByName(gsPropertyReferenceFieldLanguage) &&
1642  {
1643  // export text:reference-language attribute, if not empty
1646  }
1647  ExportElement(
1649  gsPropertyReferenceFieldSource, rPropSet)),
1650  sPresentation);
1651  break;
1652 
1653  case FIELD_ID_REF_FOOTNOTE:
1654  case FIELD_ID_REF_ENDNOTE:
1655  // reference to end-/footnote: format, generate name, (and element)
1660  gsPropertyReferenceFieldPart, rPropSet)),
1661  XML_TEMPLATE);
1664  gsPropertySequenceNumber, rPropSet)));
1665  if (xPropSetInfo->hasPropertyByName(gsPropertyReferenceFieldLanguage) &&
1667  {
1668  // export text:reference-language attribute, if not empty
1671  }
1672  ExportElement(
1674  gsPropertyReferenceFieldSource, rPropSet)),
1675  sPresentation);
1676  break;
1677 
1678  case FIELD_ID_DDE:
1679  // name from field master
1681 
1683  GetMasterPropertySet(rTextField)));
1684  ExportElement(XML_DDE_CONNECTION, sPresentation);
1685  break;
1686 
1687  case FIELD_ID_SHEET_NAME:
1688  // name of spreadsheet (Calc only)
1689  ExportElement(XML_SHEET_NAME, sPresentation);
1690  break;
1691 
1692  case FIELD_ID_PAGENAME:
1693  {
1694  if (GetExport().getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
1695  {
1697  GetExport().Characters( sPresentation );
1698  }
1699  break;
1700  }
1701 
1702  case FIELD_ID_URL:
1703  {
1704  // this field is a special case because it gets mapped onto a
1705  // hyperlink, rather than one of the regular text field.
1706  ProcessString(XML_HREF, GetExport().GetRelativeReference(GetStringProperty(gsPropertyURL, rPropSet)),
1707  false, XML_NAMESPACE_XLINK);
1710  true, XML_NAMESPACE_OFFICE);
1713  false, false);
1714  GetExport().Characters(sPresentation);
1715  break;
1716  }
1717 
1718  case FIELD_ID_BIBLIOGRAPHY:
1719  {
1720  ProcessBibliographyData(rPropSet);
1721  ExportElement(XML_BIBLIOGRAPHY_MARK, sPresentation);
1722  break;
1723  }
1724 
1725  case FIELD_ID_SCRIPT:
1728  true, XML_NAMESPACE_SCRIPT);
1729  DBG_ASSERT(sPresentation.isEmpty(),
1730  "Unexpected presentation for script field");
1731  if (GetBoolProperty(gsPropertyURLContent, rPropSet))
1732  {
1734  GetExport().GetRelativeReference(GetStringProperty(gsPropertyContent, rPropSet)),
1735  false, XML_NAMESPACE_XLINK);
1737  }
1738  else
1739  {
1742  }
1743  break;
1744 
1745  case FIELD_ID_ANNOTATION:
1746  {
1747  // check for empty presentation (just in case)
1748  DBG_ASSERT(sPresentation.isEmpty(),
1749  "Unexpected presentation for annotation field");
1750 
1751  bool bRemovePersonalInfo = SvtSecurityOptions::IsOptionSet(
1753 
1754  // annotation element + content
1755  OUString aName;
1756  rPropSet->getPropertyValue(gsPropertyName) >>= aName;
1757  if (!aName.isEmpty())
1758  {
1760  }
1762  if (eVersion & SvtSaveOptions::ODFSVER_EXTENDED)
1763  {
1764  bool b = GetBoolProperty("Resolved", rPropSet);
1765  OUString aResolvedText;
1766  OUStringBuffer aResolvedTextBuffer;
1767  ::sax::Converter::convertBool(aResolvedTextBuffer, b);
1768  aResolvedText = aResolvedTextBuffer.makeStringAndClear();
1769 
1771  }
1773  XML_ANNOTATION, false, true);
1774 
1775  // author
1776  OUString aAuthor( GetStringProperty(gsPropertyAuthor, rPropSet) );
1777  if( !aAuthor.isEmpty() )
1778  {
1780  XML_CREATOR, true,
1781  false );
1782  GetExport().Characters( bRemovePersonalInfo
1783  ? "Author" + OUString::number( rExport.GetInfoID(aAuthor) )
1784  : aAuthor );
1785  }
1786 
1787  // date time
1788  util::DateTime aDate( GetDateTimeProperty(gsPropertyDateTimeValue, rPropSet) );
1789  if ( !bRemovePersonalInfo )
1790  {
1791  OUStringBuffer aBuffer;
1792  ::sax::Converter::convertDateTime(aBuffer, aDate, nullptr, true);
1794  XML_DATE, true,
1795  false );
1796  GetExport().Characters(aBuffer.makeStringAndClear());
1797  }
1798 
1800  {
1801  // initials
1802  OUString aInitials( GetStringProperty(gsPropertyInitials, rPropSet) );
1803  if( !aInitials.isEmpty() )
1804  {
1805  // ODF 1.3 OFFICE-3776 export meta:creator-initials for ODF 1.3
1806  SvXMLElementExport aCreatorElem( GetExport(),
1807  (SvtSaveOptions::ODFSVER_013 <= GetExport().getSaneDefaultVersion())
1810 
1811  (SvtSaveOptions::ODFSVER_013 <= GetExport().getSaneDefaultVersion())
1814  true, false );
1815  GetExport().Characters( bRemovePersonalInfo
1816  ? OUString::number( rExport.GetInfoID(aInitials) )
1817  : aInitials);
1818  }
1819  }
1820 
1821  css::uno::Reference < css::text::XText > xText;
1822  try
1823  {
1824  css::uno::Any aRet = rPropSet->getPropertyValue(gsPropertyTextRange);
1825  aRet >>= xText;
1826  }
1827  catch ( css::uno::Exception& )
1828  {}
1829 
1830  if ( xText.is() )
1831  GetExport().GetTextParagraphExport()->exportText( xText );
1832  else
1834  break;
1835  }
1836 
1838  {
1839  // The style with the combined characters attribute has
1840  // already been handled in the ExportField method. So all that
1841  // is left to do now is to export the characters.
1842  GetExport().Characters(sPresentation);
1843  break;
1844  }
1845 
1846  case FIELD_ID_META:
1847  {
1848  ExportMetaField(rPropSet, false, bProgress, rPrevCharIsSpace);
1849  break;
1850  }
1851 
1852  case FIELD_ID_MEASURE:
1853  {
1855  ExportElement( XML_MEASURE, sPresentation );
1856  break;
1857  }
1858 
1861  GetStringProperty(gsPropertyContent, rPropSet) );
1862  ProcessDisplay( true,
1864  ProcessValueAndType( false,
1866  "", u"", 0.0f,
1867  false, false, true,
1868  false );
1869  ExportElement( XML_TABLE_FORMULA, sPresentation );
1870  break;
1871 
1872  case FIELD_ID_DROP_DOWN:
1873  {
1874  // tdf#133555 don't export in strict ODF versions that don't have it
1875  if (GetExport().getSaneDefaultVersion() <= SvtSaveOptions::ODFSVER_012)
1876  {
1877  break;
1878  }
1881  GetStringProperty(gsPropertyHelp, rPropSet), true);
1883  GetStringProperty(gsPropertyTooltip, rPropSet), true);
1884  SvXMLElementExport aElem( GetExport(),
1886  false, false );
1890 
1891  GetExport().Characters( sPresentation );
1892  }
1893  break;
1894 
1895  case FIELD_ID_DRAW_HEADER:
1896  {
1898  }
1899  break;
1900 
1901  case FIELD_ID_DRAW_FOOTER:
1902  {
1904  }
1905  break;
1906 
1908  {
1910  }
1911  break;
1912 
1913 
1914  case FIELD_ID_UNKNOWN:
1915  default:
1916  OSL_FAIL("unknown field type encountered!");
1917  // always export content
1918  GetExport().Characters(sPresentation);
1919  }
1920 }
1921 
1922 
1925 {
1926  Reference<XText> xEmptyText;
1927  ExportFieldDeclarations(xEmptyText);
1928 }
1929 
1932  const Reference<XText> & rText )
1933 {
1934  // store lists for decl elements
1935  vector<OUString> aVarName;
1936  vector<OUString> aUserName;
1937  vector<OUString> aSeqName;
1938  vector<OUString> aDdeName;
1939 
1940  // get text fields supplier and field master name access
1941  Reference<XTextFieldsSupplier> xTextFieldsSupp(GetExport().GetModel(),
1942  UNO_QUERY);
1943  if( !xTextFieldsSupp.is() )
1944  return;
1945 
1946  Reference<container::XNameAccess> xFieldMasterNameAccess =
1947  xTextFieldsSupp->getTextFieldMasters();
1948 
1949  // where to get the text field masters from?
1950  // a) we get a specific XText: then use pUsedMasters
1951  // b) the XText is empty: then export all text fields
1952  Sequence<OUString> aFieldMasters;
1953  if (rText.is())
1954  {
1955  // export only used masters
1956  DBG_ASSERT(nullptr != pUsedMasters,
1957  "field masters must be recorded in order to be "
1958  "written out separately" );
1959  if (nullptr != pUsedMasters)
1960  {
1961  map<Reference<XText>, set<OUString> > ::iterator aMapIter =
1962  pUsedMasters->find(rText);
1963  if (aMapIter != pUsedMasters->end())
1964  {
1965  // found the set of used field masters
1966  aFieldMasters = comphelper::containerToSequence(aMapIter->second);
1967  pUsedMasters->erase(rText);
1968  }
1969  // else: XText not found -> ignore
1970  }
1971  // else: no field masters have been recorded -> ignore
1972  }
1973  else
1974  {
1975  // no XText: export all!
1976  aFieldMasters = xFieldMasterNameAccess->getElementNames();
1977  }
1978 
1979  for(const OUString& sFieldMaster : std::as_const(aFieldMasters)) {
1980 
1981  // workaround for #no-bug#
1982  if ( sFieldMaster.startsWithIgnoreAsciiCase(
1983  "com.sun.star.text.FieldMaster.DataBase.") )
1984  {
1985  continue;
1986  }
1987 
1988 
1989  OUString sFieldMasterType;
1990  OUString sVarName;
1991  ExplodeFieldMasterName(sFieldMaster, sFieldMasterType, sVarName);
1992 
1993  // get XPropertySet of this field master
1994  Reference<XPropertySet> xPropSet;
1995  Any aAny = xFieldMasterNameAccess->getByName(sFieldMaster);
1996  aAny >>= xPropSet;
1997 
1998  // save interesting field masters
1999  if (sFieldMasterType == FIELD_SERVICE_SETEXP)
2000  {
2001  sal_Int32 nType = GetIntProperty(gsPropertySubType, xPropSet);
2002 
2003  // sequence or variable?
2004  if ( SetVariableType::SEQUENCE == nType )
2005  {
2006  aSeqName.push_back( sFieldMaster );
2007  }
2008  else
2009  {
2010  aVarName.push_back( sFieldMaster );
2011  }
2012  }
2013  else if (sFieldMasterType == FIELD_SERVICE_USER)
2014  {
2015  aUserName.push_back( sFieldMaster );
2016  }
2017  else if (sFieldMasterType == FIELD_SERVICE_DDE)
2018  {
2019  aDdeName.push_back( sFieldMaster );
2020  }
2021  else
2022  {
2023  ; // ignore
2024  }
2025  }
2026 
2027  // now process fields:
2028 
2029  // variable field masters:
2030  if ( !aVarName.empty() )
2031  {
2032  SvXMLElementExport aElem( GetExport(),
2035  true, true );
2036 
2037  for (const auto& sName : aVarName)
2038  {
2039  // get field master property set
2040  Reference<XPropertySet> xPropSet;
2041  Any aAny = xFieldMasterNameAccess->getByName(sName);
2042  aAny >>= xPropSet;
2043 
2044  // field name and type
2045  OUString sFieldMasterType;
2046  OUString sVarName;
2047  ExplodeFieldMasterName(sName, sFieldMasterType, sVarName);
2048 
2049  // determine string/numeric field
2050  bool bIsString = ( GetIntProperty(gsPropertySubType, xPropSet)
2051  == SetVariableType::STRING );
2052 
2053  // get dependent field property set
2054  Reference<XPropertySet> xFieldPropSet;
2055  if (GetDependentFieldPropertySet(xPropSet, xFieldPropSet))
2056  {
2057  // process value and type.
2059  bIsString,
2060  GetIntProperty(gsPropertyNumberFormat, xFieldPropSet),
2061  "", u"", 0.0,
2062  false, true, false, false);
2063  }
2064  else
2065  {
2066  // If no dependent field is found, only string and
2067  // float types can be supported
2068 
2069  // number format: 0 is default number format for 1st
2070  // language. should be: getDefaultNumberFormat(Locale)
2071  // from NumberFormats
2073  bIsString,
2074  0, "", u"", 0.0,
2075  false, true, false, false);
2076  }
2077 
2078  ProcessString(XML_NAME, sVarName);
2080  }
2081  }
2082  // else: no declarations element
2083 
2084  // sequence field masters:
2085  if ( !aSeqName.empty() )
2086  {
2087  SvXMLElementExport aElem( GetExport(),
2090  true, true );
2091 
2092  for (const auto& sName : aSeqName)
2093  {
2094  // get field master property set
2095  Reference<XPropertySet> xPropSet;
2096  Any aAny = xFieldMasterNameAccess->getByName(sName);
2097  aAny >>= xPropSet;
2098 
2099  // field name and type
2100  OUString sFieldMasterType;
2101  OUString sVarName;
2102  ExplodeFieldMasterName(sName, sFieldMasterType, sVarName);
2103 
2104  // outline level
2105  sal_Int32 nLevel = 1 + GetIntProperty(
2107  DBG_ASSERT(nLevel >= 0, "illegal outline level");
2108  DBG_ASSERT(nLevel < 127, "possible illegal outline level");
2110 
2111  // separation character
2112  if (nLevel > 0) {
2114  gsPropertyNumberingSeparator, xPropSet));
2115  }
2116  ProcessString(XML_NAME, sVarName);
2118  }
2119  }
2120  // else: no declarations element
2121 
2122  // user field masters:
2123  if ( !aUserName.empty() )
2124  {
2125  SvXMLElementExport aElem( GetExport(),
2128  true, true );
2129 
2130  for (const auto& sName : aUserName)
2131  {
2132  // get field master property set
2133  Reference<XPropertySet> xPropSet;
2134  Any aAny = xFieldMasterNameAccess->getByName(sName);
2135  aAny >>= xPropSet;
2136 
2137  // field name and type
2138  OUString sFieldMasterType;
2139  OUString sVarName;
2140  ExplodeFieldMasterName(sName, sFieldMasterType, sVarName);
2141 
2142  if (GetBoolProperty(gsPropertyIsExpression, xPropSet))
2143  {
2144  // expression:
2146  false,
2147  0, "", u"",
2149  true,
2150  true,
2151  false,
2152  false);
2153  }
2154  else
2155  {
2156  // string: write regardless of default
2161  false, XML_NAMESPACE_OFFICE );
2162  }
2163  ProcessString(XML_NAME, sVarName);
2165  }
2166  }
2167  // else: no declarations element
2168 
2169  // DDE field masters:
2170  if ( aDdeName.empty() )
2171  return;
2172 
2173  SvXMLElementExport aElem( GetExport(),
2176  true, true );
2177 
2178  for (const auto& sName : aDdeName)
2179  {
2180  // get field master property set
2181  Reference<XPropertySet> xPropSet;
2182  Any aAny = xFieldMasterNameAccess->getByName(sName);
2183  aAny >>= xPropSet;
2184 
2185  // check if this connection is being used by a field
2186  Reference<XPropertySet> xDummy;
2187  if (GetDependentFieldPropertySet(xPropSet, xDummy))
2188  {
2189 
2191  GetStringProperty(gsPropertyName, xPropSet),
2192  false, XML_NAMESPACE_OFFICE);
2193 
2194  // export elements; can't use ProcessString because
2195  // elements are in office namespace
2198  xPropSet),
2199  false, XML_NAMESPACE_OFFICE);
2202  xPropSet),
2203  false, XML_NAMESPACE_OFFICE);
2206  xPropSet),
2207  false, XML_NAMESPACE_OFFICE);
2208  bool bIsAutomaticUpdate = GetBoolProperty(
2209  gsPropertyIsAutomaticUpdate, xPropSet);
2210  if (bIsAutomaticUpdate)
2211  {
2214  XML_TRUE);
2215  }
2216 
2218  }
2219  // else: no dependent field -> no export of field declaration
2220  }
2221  // else: no declarations element
2222 }
2223 
2225  bool bExportOnlyUsed)
2226 {
2227  pUsedMasters.reset();
2228 
2229  // create used masters set (if none is used)
2230  if (bExportOnlyUsed)
2231  pUsedMasters.reset( new map<Reference<XText>, set<OUString> > );
2232 }
2233 
2234 void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName,
2235  bool bAddSpace)
2236 {
2237  // can't call ExportElement(eElementName, const OUString&) with empty
2238  // string because xmlprinter only uses empty tags if no content
2239  // (not even empty content) was written.
2240 
2241  DBG_ASSERT(XML_TOKEN_INVALID != eElementName, "invalid element name!");
2242  if (XML_TOKEN_INVALID != eElementName)
2243  {
2244  // Element
2246  eElementName, bAddSpace, bAddSpace );
2247  } // else: ignore
2248 }
2249 
2250 void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName,
2251  const OUString& sContent)
2252 {
2253  DBG_ASSERT(eElementName != XML_TOKEN_INVALID, "invalid element name!");
2254  if (eElementName != XML_TOKEN_INVALID)
2255  {
2256  // Element
2258  eElementName, false, false );
2259  // export content
2260  GetExport().Characters(sContent);
2261  } else {
2262  // always export content
2263  GetExport().Characters(sContent);
2264  }
2265 }
2266 
2268  const Reference<XPropertySet> & rPropSet,
2269  const OUString& rContent )
2270 {
2271  // some strings we'll need
2272  OUString sEventType( "EventType" );
2273 
2274 
2275  // the description attribute
2277  GetStringProperty(gsPropertyHint, rPropSet),
2278  rContent);
2279 
2280  // the element
2282  XML_EXECUTE_MACRO, false, false );
2283 
2284  // the <office:events>-macro:
2285 
2286  // 1) build sequence of PropertyValues
2287  Sequence<PropertyValue> aSeq;
2288  OUString sName;
2289  rPropSet->getPropertyValue("ScriptURL") >>= sName;
2290 
2291  // if the ScriptURL property is not empty then this is a Scripting
2292  // Framework URL, otherwise treat it as a Basic Macro
2293  if (!sName.isEmpty())
2294  {
2295  OUString sScript( "Script" );
2296  aSeq = Sequence<PropertyValue>
2297  {
2298  comphelper::makePropertyValue(sEventType, sScript),
2299  comphelper::makePropertyValue(sScript, sName)
2300  };
2301  }
2302  else
2303  {
2304  aSeq = Sequence<PropertyValue>
2305  {
2306  comphelper::makePropertyValue(sEventType, OUString("StarBasic")),
2307  comphelper::makePropertyValue("Library", rPropSet->getPropertyValue( "MacroLibrary" )),
2308  comphelper::makePropertyValue("MacroName", rPropSet->getPropertyValue( "MacroName" ))
2309  };
2310  }
2311 
2312  // 2) export the sequence
2313  GetExport().GetEventExport().ExportSingleEvent( aSeq, "OnClick", false );
2314 
2315  // and finally, the field presentation
2316  GetExport().Characters(rContent);
2317 }
2318 
2320  const Reference<XPropertySet> & i_xMeta,
2321  bool i_bAutoStyles, bool i_bProgress,
2322  bool & rPrevCharIsSpace)
2323 {
2324  bool doExport(!i_bAutoStyles); // do not export element if autostyles
2325  // check version >= 1.2
2326  switch (GetExport().getSaneDefaultVersion()) {
2327  case SvtSaveOptions::ODFSVER_011: // fall through
2328  case SvtSaveOptions::ODFSVER_010: doExport = false; break;
2329  default: break;
2330  }
2331 
2332  const Reference < XEnumerationAccess > xEA( i_xMeta, UNO_QUERY_THROW );
2333  const Reference < XEnumeration > xTextEnum( xEA->createEnumeration() );
2334 
2335  if (doExport)
2336  {
2337  const Reference<rdf::XMetadatable> xMeta( i_xMeta, UNO_QUERY_THROW );
2338 
2339  // style:data-style-name
2340  ProcessValueAndType(false,
2342  "", u"", 0.0, false, false, true,
2343  false );
2344 
2345  // text:meta-field without xml:id is invalid
2346  xMeta->ensureMetadataReference();
2347 
2348  // xml:id for RDF metadata
2349  GetExport().AddAttributeXmlId(xMeta);
2350  }
2351 
2352  SvXMLElementExport aElem( GetExport(), doExport,
2353  XML_NAMESPACE_TEXT, XML_META_FIELD, false, false );
2354 
2355  // recurse to export content
2357  exportTextRangeEnumeration(xTextEnum, i_bAutoStyles, i_bProgress, rPrevCharIsSpace);
2358 }
2359 
2362  bool bIsString,
2363  sal_Int32 nFormatKey,
2364  const OUString& sContent,
2365  std::u16string_view sDefault,
2366  double fValue,
2367  bool bExportValue,
2368  bool bExportValueType,
2369  bool bExportStyle,
2370  bool bForceSystemLanguage,
2371  bool bTimeStyle) // exporting a time style?
2372 {
2373  // String or number?
2374  if (bIsString)
2375  {
2376 
2377  // string: attributes value-type=string, string-value=...
2378 
2379  if (bExportValue || bExportValueType)
2380  {
2382  GetExport(), sContent, sDefault, bExportValue);
2383  }
2384 
2385  }
2386  else
2387  {
2388 
2389  // number: value-type=..., value...=..., data-style-name=...
2390 
2391  DBG_ASSERT(bExportValueType || !bExportValue, "value w/o value type not supported!");
2392 
2393  // take care of illegal formats
2394  // (shouldn't happen, but does if document is corrupted)
2395  if (-1 != nFormatKey)
2396  {
2397  if (bExportValue || bExportValueType)
2398  {
2401  GetExport(), nFormatKey, fValue, bExportValue);
2402  }
2403 
2404  if (bExportStyle)
2405  {
2406  // don't export language (if desired)
2407  if( bForceSystemLanguage )
2408  nFormatKey =
2409  GetExport().dataStyleForceSystemLanguage( nFormatKey );
2410 
2411  OUString sDataStyleName =
2412  GetExport().getDataStyleName(nFormatKey, bTimeStyle);
2413  if( !sDataStyleName.isEmpty() )
2414  {
2417  sDataStyleName );
2418  } // else: ignore (no valid number format)
2419  } // else: ignore (no number format)
2420  }
2421  }
2422 }
2423 
2424 
2427  bool bIsCommand)
2428 {
2429  enum XMLTokenEnum eValue;
2430 
2431  if (bIsVisible)
2432  {
2433  eValue = bIsCommand ? XML_FORMULA : XML_VALUE;
2434  }
2435  else
2436  {
2437  eValue = XML_NONE;
2438  }
2439 
2440  // omit attribute if default
2441  if (eValue != XML_VALUE)
2442  {
2444  }
2445 }
2446 
2447 
2450  bool bBool, bool bDefault)
2451 {
2452  SAL_WARN_IF( eName == XML_TOKEN_INVALID, "xmloff.text", "invalid element token");
2453  if ( XML_TOKEN_INVALID == eName )
2454  return;
2455 
2456  // write attribute (if different than default)
2457  // negate to force 0/1 values (and make sal_Bool comparable)
2458  if ((!bBool) != (!bDefault)) {
2460  (bBool ? XML_TRUE : XML_FALSE) );
2461  }
2462 }
2463 
2464 
2467  const OUString& sValue,
2468  bool bOmitEmpty,
2469  sal_uInt16 nPrefix)
2470 {
2471  SAL_WARN_IF( eName == XML_TOKEN_INVALID, "xmloff.text", "invalid element token");
2472  if ( XML_TOKEN_INVALID == eName )
2473  return;
2474 
2475  // check for empty string, if applicable
2476  if ( bOmitEmpty && sValue.isEmpty() )
2477  return;
2478 
2479  // write attribute
2480  GetExport().AddAttribute(nPrefix, eName, sValue);
2481 }
2482 
2484  sal_uInt16 nValuePrefix,
2485  const OUString& sValue)
2486 {
2487  OUString sQValue =
2488  GetExport().GetNamespaceMap().GetQNameByKey( nValuePrefix, sValue, false );
2489  ProcessString( eName, sQValue );
2490 }
2491 
2494  const OUString& sValue,
2495  std::u16string_view sDefault)
2496 {
2497  if (sValue != sDefault)
2498  {
2499  ProcessString(eName, sValue);
2500  }
2501 }
2502 
2505  sal_uInt16 nValuePrefix,
2506  const OUString& sValue,
2507  std::u16string_view sDefault)
2508 {
2509  if (sValue != sDefault)
2510  {
2511  ProcessString(eName, nValuePrefix, sValue);
2512  }
2513 }
2514 
2515 
2518  enum XMLTokenEnum eName,
2519  enum XMLTokenEnum eValue,
2520  sal_uInt16 nPrefix)
2521 {
2522  SAL_WARN_IF( eName == XML_TOKEN_INVALID, "xmloff.text", "invalid element token" );
2523  SAL_WARN_IF( eValue == XML_TOKEN_INVALID, "xmloff.text", "invalid value token" );
2524  if ( XML_TOKEN_INVALID == eName )
2525  return;
2526 
2527  GetExport().AddAttribute(nPrefix, eName, eValue);
2528 }
2529 
2532  enum XMLTokenEnum eName,
2533  enum XMLTokenEnum eValue,
2534  enum XMLTokenEnum eDefault)
2535 {
2536  if ( eValue != eDefault )
2537  ProcessString( eName, eValue);
2538 }
2539 
2540 
2543  std::u16string_view sParagraphSequence)
2544 {
2545  // iterate over all string-pieces separated by return (0x0a) and
2546  // put each inside a paragraph element.
2547  SvXMLTokenEnumerator aEnumerator(sParagraphSequence, char(0x0a));
2548  std::u16string_view aSubString;
2549  while (aEnumerator.getNextToken(aSubString))
2550  {
2551  SvXMLElementExport aParagraph(
2552  GetExport(), XML_NAMESPACE_TEXT, XML_P, true, false);
2553  GetExport().Characters(OUString(aSubString));
2554  }
2555 }
2556 
2557 // export an integer attribute
2559  sal_Int32 nNum)
2560 {
2561  SAL_WARN_IF( eName == XML_TOKEN_INVALID, "xmloff.text", "invalid element token");
2562  if ( XML_TOKEN_INVALID == eName )
2563  return;
2564 
2566  OUString::number(nNum));
2567 }
2568 
2571  sal_Int32 nNum, sal_Int32 nDefault)
2572 {
2573  if (nNum != nDefault)
2574  ProcessInteger(eName, nNum);
2575 }
2576 
2577 
2579 void XMLTextFieldExport::ProcessNumberingType(sal_Int16 nNumberingType)
2580 {
2581  // process only if real format (not: like page descriptor)
2582  if (NumberingType::PAGE_DESCRIPTOR == nNumberingType)
2583  return;
2584 
2585  OUStringBuffer sTmp( 10 );
2586  // number type: num format
2588  nNumberingType );
2590  sTmp.makeStringAndClear() );
2591  // and letter sync, if applicable
2592  SvXMLUnitConverter::convertNumLetterSync( sTmp, nNumberingType );
2593 
2594  if (!sTmp.isEmpty())
2595  {
2597  sTmp.makeStringAndClear() );
2598  }
2599  // else: like page descriptor => ignore
2600 }
2601 
2602 
2605  double dValue,
2606  bool bIsDate,
2607  bool bIsDuration,
2608  bool bOmitDurationIfZero,
2609  sal_uInt16 nPrefix)
2610 {
2611  // truncate for date granularity
2612  if (bIsDate)
2613  {
2614  dValue = ::rtl::math::approxFloor(dValue);
2615  }
2616 
2617  OUStringBuffer aBuffer;
2618  if (bIsDuration)
2619  {
2620  // date/time duration handle bOmitDurationIfZero
2621  if (!bOmitDurationIfZero || dValue != 0.0)
2622  {
2623  ::sax::Converter::convertDuration(aBuffer, dValue);
2624  }
2625  }
2626  else
2627  {
2628  // date/time value
2629  rExport.GetMM100UnitConverter().convertDateTime(aBuffer, dValue);
2630  }
2631 
2632  // output attribute
2633  ProcessString(eName, aBuffer.makeStringAndClear(), true, nPrefix);
2634 }
2635 
2638  const util::DateTime& rTime)
2639 {
2640  OUStringBuffer aBuffer;
2641 
2642  util::DateTime aDateTime(rTime);
2643 
2644  // date/time value
2645  ::sax::Converter::convertDateTime(aBuffer, aDateTime, nullptr);
2646 
2647  // output attribute
2648  ProcessString(eName, aBuffer.makeStringAndClear(), true);
2649 }
2650 
2653  sal_Int32 nMinutes,
2654  bool bIsDate,
2655  bool bIsDuration)
2656 {
2657  // handle bOmitDurationIfZero here, because we can precisely compare ints
2658  if (!(bIsDuration && (nMinutes==0)))
2659  {
2660  ProcessDateTime(eName, static_cast<double>(nMinutes) / double(24*60),
2661  bIsDate, bIsDuration);
2662  }
2663 }
2664 
2667  const util::DateTime& rTime)
2668 {
2669  OUStringBuffer aBuffer;
2670 
2671  // date/time value
2673 
2674  // output attribute
2675  ProcessString(eName, aBuffer.makeStringAndClear(), true);
2676 }
2677 
2678 
2680 {
2681  { XML_ARTICLE, BibliographyDataType::ARTICLE },
2682  { XML_BOOK, BibliographyDataType::BOOK },
2683  { XML_BOOKLET, BibliographyDataType::BOOKLET },
2684  { XML_CONFERENCE, BibliographyDataType::CONFERENCE },
2685  { XML_CUSTOM1, BibliographyDataType::CUSTOM1 },
2686  { XML_CUSTOM2, BibliographyDataType::CUSTOM2 },
2687  { XML_CUSTOM3, BibliographyDataType::CUSTOM3 },
2688  { XML_CUSTOM4, BibliographyDataType::CUSTOM4 },
2689  { XML_CUSTOM5, BibliographyDataType::CUSTOM5 },
2690  { XML_EMAIL, BibliographyDataType::EMAIL },
2691  { XML_INBOOK, BibliographyDataType::INBOOK },
2692  { XML_INCOLLECTION, BibliographyDataType::INCOLLECTION },
2693  { XML_INPROCEEDINGS, BibliographyDataType::INPROCEEDINGS },
2694  { XML_JOURNAL, BibliographyDataType::JOURNAL },
2695  { XML_MANUAL, BibliographyDataType::MANUAL },
2696  { XML_MASTERSTHESIS, BibliographyDataType::MASTERSTHESIS },
2697  { XML_MISC, BibliographyDataType::MISC },
2698  { XML_PHDTHESIS, BibliographyDataType::PHDTHESIS },
2699  { XML_PROCEEDINGS, BibliographyDataType::PROCEEDINGS },
2700  { XML_TECHREPORT, BibliographyDataType::TECHREPORT },
2701  { XML_UNPUBLISHED, BibliographyDataType::UNPUBLISHED },
2702  { XML_WWW, BibliographyDataType::WWW },
2703  { XML_TOKEN_INVALID, 0 }
2704 };
2705 
2706 
2708  const Reference<XPropertySet>& rPropSet)
2709 {
2710  // get the values
2711  Any aAny = rPropSet->getPropertyValue(gsPropertyFields);
2712  Sequence<PropertyValue> aValues;
2713  aAny >>= aValues;
2714 
2715  // one attribute per value (unless empty)
2716  for (const auto& rProp : std::as_const(aValues))
2717  {
2718  if( rProp.Name == "BibiliographicType" )
2719  {
2720  sal_Int16 nTypeId = 0;
2721  rProp.Value >>= nTypeId;
2722  OUStringBuffer sBuf;
2723 
2724  if (SvXMLUnitConverter::convertEnum(sBuf, nTypeId,
2725  aBibliographyDataTypeMap))
2726  {
2729  sBuf.makeStringAndClear());
2730  }
2731  // else: ignore this argument
2732  }
2733  else
2734  {
2735  OUString sStr;
2736  rProp.Value >>= sStr;
2737 
2738  if (!sStr.isEmpty())
2739  {
2740  XMLTokenEnum eElement = MapBibliographyFieldName(rProp.Name);
2741  if (eElement == XML_URL || eElement == XML_LOCAL_URL)
2742  {
2743  sStr = GetExport().GetRelativeReference(sStr);
2744  }
2745  sal_uInt16 nPrefix = XML_NAMESPACE_TEXT;
2746  if (eElement == XML_LOCAL_URL)
2747  {
2748  nPrefix = XML_NAMESPACE_LO_EXT;
2749  }
2750  rExport.AddAttribute(nPrefix, eElement, sStr);
2751  }
2752  }
2753  }
2754 }
2755 
2758  sal_Int32 nCommandType)
2759 {
2761  switch( nCommandType )
2762  {
2763  case sdb::CommandType::TABLE: eToken = XML_TABLE; break;
2764  case sdb::CommandType::QUERY: eToken = XML_QUERY; break;
2765  case sdb::CommandType::COMMAND: eToken = XML_COMMAND; break;
2766  }
2767 
2768  if( eToken != XML_TOKEN_INVALID )
2770 }
2771 
2772 
2774  const Sequence<OUString>& rSequence,
2775  const OUString& sSelected )
2776 {
2777  // find selected element
2778  sal_Int32 nSelected = comphelper::findValue(rSequence, sSelected);
2779 
2780  // delegate to ProcessStringSequence(OUString,sal_Int32)
2781  ProcessStringSequence( rSequence, nSelected );
2782 }
2783 
2785  const Sequence<OUString>& rSequence,
2786  sal_Int32 nSelected )
2787 {
2788  sal_Int32 nLength = rSequence.getLength();
2789  const OUString* pSequence = rSequence.getConstArray();
2790  for( sal_Int32 i = 0; i < nLength; i++ )
2791  {
2792  if( i == nSelected )
2797  false, false );
2798  }
2799 }
2800 
2802  enum XMLTokenEnum eElementName,
2803  const OUString& sPresentation,
2804  const Reference<XPropertySet>& rPropertySet,
2805  const Reference<XPropertySetInfo>& rPropertySetInfo )
2806 {
2807  SAL_WARN_IF( eElementName == XML_TOKEN_INVALID, "xmloff.text", "need token" );
2808  SAL_WARN_IF( !rPropertySet.is(), "xmloff.text", "need property set" );
2809  SAL_WARN_IF( !rPropertySetInfo.is(), "xmloff.text", "need property set info" );
2810 
2811  // get database properties
2812  OUString sDataBaseName;
2813  OUString sDataBaseURL;
2814  OUString sStr;
2815  if( ( rPropertySet->getPropertyValue( gsPropertyDataBaseName ) >>= sStr )
2816  && !sStr.isEmpty() )
2817  {
2818  sDataBaseName = sStr;
2819  }
2820  else if( rPropertySetInfo->hasPropertyByName( gsPropertyDataBaseURL ) &&
2821  (rPropertySet->getPropertyValue( gsPropertyDataBaseURL ) >>= sStr) &&
2822  !sStr.isEmpty() )
2823  {
2824  sDataBaseURL = sStr;
2825  }
2826 
2827  // add database name property (if present)
2828  if( !sDataBaseName.isEmpty() )
2830  sDataBaseName );
2831  SvXMLElementExport aDataBaseElement( GetExport(),
2832  XML_NAMESPACE_TEXT, eElementName,
2833  false, false );
2834 
2835  // write URL as children
2836  if( !sDataBaseURL.isEmpty() )
2837  {
2839  SvXMLElementExport aDataSourceElement(
2841  false, false );
2842  }
2843 
2844  // write presentation
2845  rExport.Characters( sPresentation );
2846 }
2847 
2848 
2849 // explode a field master name into field type and field name
2851  std::u16string_view sMasterName, OUString& sFieldType, OUString& sVarName)
2852 {
2853  sal_Int32 nLength = gsFieldMasterPrefix.getLength();
2854  size_t nSeparator = sMasterName.find('.', nLength);
2855 
2856  // '.' found?
2857  if (nSeparator == o3tl::make_unsigned(nLength) || nSeparator == std::u16string_view::npos) {
2858  SAL_WARN("xmloff.text", "no field var name!");
2859  }
2860  else
2861  {
2862  sFieldType = sMasterName.substr(nLength, nSeparator-nLength);
2863  sVarName = sMasterName.substr(nSeparator+1);
2864  }
2865 }
2866 
2867 
2868 // for XDependentTextFields, get PropertySet of FieldMaster
2870  const Reference<XTextField> & rTextField)
2871 {
2872  // name, value => get Property set of TextFieldMaster
2873  Reference<XDependentTextField> xDep(rTextField, UNO_QUERY);
2874  return xDep->getTextFieldMaster();
2875 }
2876 
2877 // get PropertySet of (any; the first) dependent field
2879  const Reference<XPropertySet> & xMaster,
2880  Reference<XPropertySet> & xField)
2881 {
2882  Any aAny;
2883  Sequence<Reference<XDependentTextField> > aFields;
2884  aAny = xMaster->getPropertyValue(gsPropertyDependentTextFields);
2885  aAny >>= aFields;
2886 
2887  // any fields?
2888  if (aFields.hasElements())
2889  {
2890  // get first one and return
2891  Reference<XDependentTextField> xTField = aFields[0];
2892  xField.set(xTField, UNO_QUERY);
2893  DBG_ASSERT(xField.is(),
2894  "Surprisingly, this TextField refuses to be a PropertySet!");
2895  return true;
2896  }
2897  else
2898  {
2899  return false;
2900  }
2901 }
2902 
2903 
2906 {
2907  enum XMLTokenEnum eType = XML_TEXT;
2908 
2909  switch (nType)
2910  {
2911  case PlaceholderType::TEXT:
2912  eType = XML_TEXT;
2913  break;
2914 
2915  case PlaceholderType::TABLE:
2916  eType = XML_TABLE;
2917  break;
2918 
2919  case PlaceholderType::TEXTFRAME:
2920  eType = XML_TEXT_BOX;
2921  break;
2922 
2923  case PlaceholderType::GRAPHIC:
2924  eType = XML_IMAGE;
2925  break;
2926 
2927  case PlaceholderType::OBJECT:
2928  eType = XML_OBJECT;
2929  break;
2930 
2931  default:
2932  // unknown placeholder: XML_TEXT
2933  OSL_FAIL("unknown placeholder type");
2934  }
2935 
2936  return eType;
2937 }
2938 
2939 
2942  const Reference<XPropertySet> & xPropSet)
2943 {
2944  // Initials or full name?
2945  return GetBoolProperty(gsPropertyFullName, xPropSet)
2947 }
2948 
2950  const Reference<XPropertySet> & xPropSet,
2951  sal_Int32& nOffset)
2952 {
2953  enum XMLTokenEnum eName = XML_TOKEN_INVALID;
2954  PageNumberType ePage;
2955  Any aAny = xPropSet->getPropertyValue(gsPropertySubType);
2956  ePage = *o3tl::doAccess<PageNumberType>(aAny);
2957 
2958  switch (ePage)
2959  {
2960  case PageNumberType_PREV:
2961  eName = XML_PREVIOUS;
2962  nOffset += 1;
2963  break;
2964  case PageNumberType_CURRENT:
2965  eName = XML_CURRENT;
2966  break;
2967  case PageNumberType_NEXT:
2968  eName = XML_NEXT;
2969  nOffset -= 1;
2970  break;
2971  default:
2972  OSL_FAIL("unknown page number type");
2973  eName = XML_TOKEN_INVALID;
2974  break;
2975  }
2976 
2977  return eName;
2978 }
2979 
2982 {
2983  enum XMLTokenEnum eName = XML_TOKEN_INVALID;
2984 
2985  switch (nFormat)
2986  {
2987  case TemplateDisplayFormat::FULL:
2988  eName = XML_FULL;
2989  break;
2990  case TemplateDisplayFormat::PATH:
2991  eName = XML_PATH;
2992  break;
2993  case TemplateDisplayFormat::NAME:
2994  eName = XML_NAME;
2995  break;
2996  case TemplateDisplayFormat::NAME_AND_EXT:
2997  eName = XML_NAME_AND_EXTENSION;
2998  break;
2999  case TemplateDisplayFormat::AREA:
3000  eName = XML_AREA;
3001  break;
3002  case TemplateDisplayFormat::TITLE:
3003  eName = XML_TITLE;
3004  break;
3005  default:
3006  OSL_FAIL("unknown template display format");
3007  eName = XML_TOKEN_INVALID;
3008  break;
3009  }
3010 
3011  return eName;
3012 }
3013 
3016 {
3017  enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
3018 
3019  switch (nToken)
3020  {
3021  case FIELD_ID_COUNT_PAGES:
3022  eElement = XML_PAGE_COUNT;
3023  break;
3025  eElement = XML_PARAGRAPH_COUNT;
3026  break;
3027  case FIELD_ID_COUNT_WORDS:
3028  eElement = XML_WORD_COUNT;
3029  break;
3031  eElement = XML_CHARACTER_COUNT;
3032  break;
3033  case FIELD_ID_COUNT_TABLES:
3034  eElement = XML_TABLE_COUNT;
3035  break;
3037  eElement = XML_IMAGE_COUNT;
3038  break;
3040  eElement = XML_OBJECT_COUNT;
3041  break;
3042  default:
3043  OSL_FAIL("no count field token");
3044  eElement = XML_TOKEN_INVALID;
3045  break;
3046  }
3047 
3048  return eElement;
3049 }
3050 
3053 {
3054  enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3055 
3056  switch (nFormat)
3057  {
3058  case ChapterFormat::NAME:
3059  eName = XML_NAME;
3060  break;
3061  case ChapterFormat::NUMBER:
3062  eName = XML_NUMBER;
3063  break;
3064  case ChapterFormat::NAME_NUMBER:
3065  eName = XML_NUMBER_AND_NAME;
3066  break;
3067  case ChapterFormat::NO_PREFIX_SUFFIX:
3068  eName = XML_PLAIN_NUMBER_AND_NAME;
3069  break;
3070  case ChapterFormat::DIGIT:
3071  eName = XML_PLAIN_NUMBER;
3072  break;
3073  default:
3074  OSL_FAIL("unknown chapter display format");
3075  eName = XML_TOKEN_INVALID;
3076  break;
3077  }
3078 
3079  return eName;
3080 }
3081 
3082 
3085 {
3086  enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3087 
3088  switch (nFormat)
3089  {
3090  case FilenameDisplayFormat::FULL:
3091  eName = XML_FULL;
3092  break;
3093  case FilenameDisplayFormat::PATH:
3094  eName = XML_PATH;
3095  break;
3096  case FilenameDisplayFormat::NAME:
3097  eName = XML_NAME;
3098  break;
3099  case FilenameDisplayFormat::NAME_AND_EXT:
3100  eName = XML_NAME_AND_EXTENSION;
3101  break;
3102  default:
3103  OSL_FAIL("unknown filename display format");
3104  }
3105 
3106  return eName;
3107 }
3108 
3109 
3112 {
3113  enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
3114 
3115  switch (nType)
3116  {
3117  case ReferenceFieldPart::PAGE:
3118  eElement = XML_PAGE;
3119  break;
3120  case ReferenceFieldPart::CHAPTER:
3121  eElement = XML_CHAPTER;
3122  break;
3123  case ReferenceFieldPart::TEXT:
3124  eElement = XML_TEXT;
3125  break;
3126  case ReferenceFieldPart::UP_DOWN:
3127  eElement = XML_DIRECTION;
3128  break;
3129  case ReferenceFieldPart::CATEGORY_AND_NUMBER:
3130  eElement = XML_CATEGORY_AND_VALUE;
3131  break;
3132  case ReferenceFieldPart::ONLY_CAPTION:
3133  eElement = XML_CAPTION;
3134  break;
3135  case ReferenceFieldPart::ONLY_SEQUENCE_NUMBER:
3136  eElement = XML_VALUE;
3137  break;
3138  case ReferenceFieldPart::PAGE_DESC:
3139  // small hack: this value never gets written, because
3140  // XML_TEMPLATE is default
3141  eElement = XML_TEMPLATE;
3142  break;
3143  // Core implementation for direct cross-references (#i81002#)
3144  case ReferenceFieldPart::NUMBER:
3145  eElement = XML_NUMBER;
3146  break;
3147  case ReferenceFieldPart::NUMBER_NO_CONTEXT:
3148  eElement = XML_NUMBER_NO_SUPERIOR;
3149  break;
3150  case ReferenceFieldPart::NUMBER_FULL_CONTEXT:
3151  eElement = XML_NUMBER_ALL_SUPERIOR;
3152  break;
3153  default:
3154  OSL_FAIL("unknown reference type");
3155  eElement = XML_TEMPLATE;
3156  break;
3157  }
3158 
3159  return eElement;
3160 }
3161 
3164 {
3165  enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
3166 
3167  switch (nType)
3168  {
3169  case ReferenceFieldSource::REFERENCE_MARK:
3170  eElement = XML_REFERENCE_REF;
3171  break;
3172  case ReferenceFieldSource::SEQUENCE_FIELD:
3173  eElement = XML_SEQUENCE_REF;
3174  break;
3175  case ReferenceFieldSource::BOOKMARK:
3176  eElement = XML_BOOKMARK_REF;
3177  break;
3178  case ReferenceFieldSource::FOOTNOTE:
3179  case ReferenceFieldSource::ENDNOTE:
3180  eElement = XML_NOTE_REF;
3181  break;
3182  default:
3183  OSL_FAIL("unknown reference source");
3184  break;
3185  }
3186 
3187  return eElement;
3188 }
3189 
3190 
3193  const Reference<XPropertySet> & xPropSet)
3194 {
3195  enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3196 
3197  // sub-field type
3198  switch (GetInt16Property(gsPropertyFieldSubType, xPropSet))
3199  {
3200  case UserDataPart::COMPANY :
3201  eName = XML_SENDER_COMPANY;
3202  break;
3203  case UserDataPart::FIRSTNAME :
3204  eName = XML_SENDER_FIRSTNAME;
3205  break;
3206  case UserDataPart::NAME :
3207  eName = XML_SENDER_LASTNAME;
3208  break;
3209  case UserDataPart::SHORTCUT :
3210  eName = XML_SENDER_INITIALS;
3211  break;
3212  case UserDataPart::STREET :
3213  eName = XML_SENDER_STREET;
3214  break;
3215  case UserDataPart::COUNTRY :
3216  eName = XML_SENDER_COUNTRY;
3217  break;
3218  case UserDataPart::ZIP :
3219  eName = XML_SENDER_POSTAL_CODE;
3220  break;
3221  case UserDataPart::CITY :
3222  eName = XML_SENDER_CITY;
3223  break;
3224  case UserDataPart::TITLE :
3225  eName = XML_SENDER_TITLE;
3226  break;
3227  case UserDataPart::POSITION :
3228  eName = XML_SENDER_POSITION;
3229  break;
3230  case UserDataPart::PHONE_PRIVATE :
3231  eName = XML_SENDER_PHONE_PRIVATE;
3232  break;
3233  case UserDataPart::PHONE_COMPANY :
3234  eName = XML_SENDER_PHONE_WORK;
3235  break;
3236  case UserDataPart::FAX :
3237  eName = XML_SENDER_FAX;
3238  break;
3239  case UserDataPart::EMAIL :
3240  eName = XML_SENDER_EMAIL;
3241  break;
3242  case UserDataPart::STATE :
3244  break;
3245  default:
3246  SAL_WARN("xmloff.text", "unknown sender type");
3247  eName = XML_TOKEN_INVALID;
3248  break;
3249  }
3250 
3251  return eName;
3252 }
3253 
3255  enum FieldIdEnum nToken)
3256 {
3257  enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
3258 
3259  switch (nToken)
3260  {
3262  eElement = XML_INITIAL_CREATOR;
3263  break;
3265  eElement = XML_CREATION_DATE;
3266  break;
3268  eElement = XML_CREATION_TIME;
3269  break;
3271  eElement = XML_DESCRIPTION;
3272  break;
3274  eElement = XML_PRINT_TIME;
3275  break;
3277  eElement = XML_PRINT_DATE;
3278  break;
3280  eElement = XML_PRINTED_BY;
3281  break;
3283  eElement = XML_TITLE;
3284  break;
3286  eElement = XML_SUBJECT;
3287  break;
3289  eElement = XML_KEYWORDS;
3290  break;
3292  eElement = XML_EDITING_CYCLES;
3293  break;
3295  eElement = XML_EDITING_DURATION;
3296  break;
3298  eElement = XML_MODIFICATION_TIME;
3299  break;
3301  eElement = XML_MODIFICATION_DATE;
3302  break;
3304  eElement = XML_CREATOR;
3305  break;
3306  default:
3307  SAL_WARN("xmloff.text", "unknown docinfo field type!");
3308  eElement = XML_TOKEN_INVALID;
3309  break;
3310  }
3311 
3312  return eElement;
3313 }
3314 
3316 {
3317  enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3318 
3319  if( sName == u"Identifier" )
3320  {
3321  eName = XML_IDENTIFIER;
3322  }
3323  else if( sName == u"BibiliographicType" )
3324  {
3325  eName = XML_BIBLIOGRAPHY_TYPE;
3326  }
3327  else if( sName == u"Address" )
3328  {
3329  eName = XML_ADDRESS;
3330  }
3331  else if( sName == u"Annote" )
3332  {
3333  eName = XML_ANNOTE;
3334  }
3335  else if( sName == u"Author" )
3336  {
3337  eName = XML_AUTHOR;
3338  }
3339  else if( sName == u"Booktitle" )
3340  {
3341  eName = XML_BOOKTITLE;
3342  }
3343  else if( sName == u"Chapter" )
3344  {
3345  eName = XML_CHAPTER;
3346  }
3347  else if( sName == u"Edition" )
3348  {
3349  eName = XML_EDITION;
3350  }
3351  else if( sName == u"Editor" )
3352  {
3353  eName = XML_EDITOR;
3354  }
3355  else if( sName == u"Howpublished" )
3356  {
3357  eName = XML_HOWPUBLISHED;
3358  }
3359  else if( sName == u"Institution" )
3360  {
3361  eName = XML_INSTITUTION;
3362  }
3363  else if( sName == u"Journal" )
3364  {
3365  eName = XML_JOURNAL;
3366  }
3367  else if( sName == u"Month" )
3368  {
3369  eName = XML_MONTH;
3370  }
3371  else if( sName == u"Note" )
3372  {
3373  eName = XML_NOTE;
3374  }
3375  else if( sName == u"Number" )
3376  {
3377  eName = XML_NUMBER;
3378  }
3379  else if( sName == u"Organizations" )
3380  {
3381  eName = XML_ORGANIZATIONS;
3382  }
3383  else if( sName == u"Pages" )
3384  {
3385  eName = XML_PAGES;
3386  }
3387  else if( sName == u"Publisher" )
3388  {
3389  eName = XML_PUBLISHER;
3390  }
3391  else if( sName == u"School" )
3392  {
3393  eName = XML_SCHOOL;
3394  }
3395  else if( sName == u"Series" )
3396  {
3397  eName = XML_SERIES;
3398  }
3399  else if( sName == u"Title" )
3400  {
3401  eName = XML_TITLE;
3402  }
3403  else if( sName == u"Report_Type" )
3404  {
3405  eName = XML_REPORT_TYPE;
3406  }
3407  else if( sName == u"Volume" )
3408  {
3409  eName = XML_VOLUME;
3410  }
3411  else if( sName == u"Year" )
3412  {
3413  eName = XML_YEAR;
3414  }
3415  else if( sName == u"URL" )
3416  {
3417  eName = XML_URL;
3418  }
3419  else if( sName == u"Custom1" )
3420  {
3421  eName = XML_CUSTOM1;
3422  }
3423  else if( sName == u"Custom2" )
3424  {
3425  eName = XML_CUSTOM2;
3426  }
3427  else if( sName == u"Custom3" )
3428  {
3429  eName = XML_CUSTOM3;
3430  }
3431  else if( sName == u"Custom4" )
3432  {
3433  eName = XML_CUSTOM4;
3434  }
3435  else if( sName == u"Custom5" )
3436  {
3437  eName = XML_CUSTOM5;
3438  }
3439  else if( sName == u"ISBN" )
3440  {
3441  eName = XML_ISBN;
3442  }
3443  else if (sName == u"LocalURL")
3444  {
3445  eName = XML_LOCAL_URL;
3446  }
3447  else
3448  {
3449  SAL_WARN("xmloff.text", "Unknown bibliography info data");
3450  eName = XML_TOKEN_INVALID;
3451  }
3452 
3453  return eName;
3454 }
3455 
3457 {
3458  switch( nKind )
3459  {
3460  case 0:
3461  return XML_VALUE;
3462  case 1:
3463  return XML_UNIT;
3464  }
3465  return XML_GAP;
3466 }
3467 
3469  sal_Int16 nSeqNo)
3470 {
3471  // generate foot-/endnote ID
3472  return "ftn" + OUString::number(static_cast<sal_Int32>(nSeqNo));
3473 }
3474 
3476  sal_Int16 nSeqNo,
3477  std::u16string_view rSeqName)
3478 {
3479  // generate foot-/endnote ID
3480  return OUString::Concat("ref") +rSeqName + OUString::number(static_cast<sal_Int32>(nSeqNo));
3481 }
3482 
3483 
3484 // Property accessor helper functions
3485 
3486 
3487 // to be relegated (does that word exist?) to a more appropriate place
3488 
3489 
3491  const OUString& sPropName,
3492  const Reference<XPropertySet> & xPropSet)
3493 {
3494  Any aAny = xPropSet->getPropertyValue(sPropName);
3495  bool bBool = *o3tl::doAccess<bool>(aAny);
3496  return bBool;
3497 }
3498 
3500  const OUString& sPropName,
3501  const Reference<XPropertySet> & xPropSet,
3502  const Reference<XPropertySetInfo> & xPropSetInfo,
3503  bool bDefault)
3504 {
3505  return xPropSetInfo->hasPropertyByName( sPropName )
3506  ? GetBoolProperty( sPropName, xPropSet ) : bDefault;
3507 }
3508 
3510  const OUString& sPropName,
3511  const Reference<XPropertySet> & xPropSet)
3512 {
3513  Any aAny = xPropSet->getPropertyValue(sPropName);
3514  double fDouble = 0.0;
3515  aAny >>= fDouble;
3516  return fDouble;
3517 }
3518 
3520  const OUString& sPropName,
3521  const Reference<XPropertySet> & xPropSet)
3522 {
3523  Any aAny = xPropSet->getPropertyValue(sPropName);
3524  OUString sString;
3525  aAny >>= sString;
3526  return sString;
3527 }
3528 
3529 sal_Int32 GetIntProperty(
3530  const OUString& sPropName,
3531  const Reference<XPropertySet> & xPropSet)
3532 {
3533  Any aAny = xPropSet->getPropertyValue(sPropName);
3534  sal_Int32 nInt = 0;
3535  aAny >>= nInt;
3536  return nInt;
3537 }
3538 
3540  const OUString& sPropName,
3541  const Reference<XPropertySet> & xPropSet)
3542 {
3543  Any aAny = xPropSet->getPropertyValue(sPropName);
3544  sal_Int16 nInt = 0;
3545  aAny >>= nInt;
3546  return nInt;
3547 }
3548 
3550  const OUString& sPropName,
3551  const Reference<XPropertySet> & xPropSet)
3552 {
3553  Any aAny = xPropSet->getPropertyValue(sPropName);
3554  sal_Int8 nInt = 0;
3555  aAny >>= nInt;
3556  return nInt;
3557 }
3558 
3559 util::DateTime GetDateTimeProperty(
3560  const OUString& sPropName,
3561  const Reference<XPropertySet> & xPropSet)
3562 {
3563  Any aAny = xPropSet->getPropertyValue(sPropName);
3564  util::DateTime aTime;
3565  aAny >>= aTime;
3566  return aTime;
3567 }
3568 
3570  const OUString& sPropName,
3571  const Reference<XPropertySet> & xPropSet)
3572 {
3573  Any aAny = xPropSet->getPropertyValue(sPropName);
3574  Sequence<OUString> aSequence;
3575  aAny >>= aSequence;
3576  return aSequence;
3577 }
3578 
3579 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
char const FIELD_SERVICE_HIDDEN_TEXT[]
Definition: txtflde.cxx:103
constexpr OUStringLiteral gsPropertyVariableName(u"VariableName")
SvXMLExport & rExport
Definition: txtflde.hxx:151
static bool IsStringField(FieldIdEnum nFieldType, const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
determine, whether field has string or numeric content
Definition: txtflde.cxx:633
char const FIELD_SERVICE_REFERENCE_PAGE_GET[]
Definition: txtflde.cxx:142
bool IsOptionSet(EOption eOption)
void ProcessStringSequence(const css::uno::Sequence< OUString > &rSequence, const OUString &sSelected)
css::sdb::CommandType
constexpr OUStringLiteral gsPropertyIsDate(u"IsDate")
constexpr sal_uInt16 XML_NAMESPACE_OFFICE
static enum::xmloff::token::XMLTokenEnum MapFilenameDisplayFormat(sal_Int16 nType)
map FilenameDisplayFormat to XML attribute names
Definition: txtflde.cxx:3084
constexpr OUStringLiteral gsPropertyReferenceFieldPart(u"ReferenceFieldPart")
char const FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR2[]
Definition: txtflde.cxx:106
void ExportElement(enum::xmloff::token::XMLTokenEnum eElement, bool bAddSpace=false)
export an empty element
constexpr OUStringLiteral gsPropertyLevel(u"Level")
constexpr OUStringLiteral gsPropertyNumberingType(u"NumberingType")
static bool GetBoolProperty(const OUString &, const Reference< XPropertySet > &)
Definition: txtflde.cxx:3490
void ExportMetaField(const css::uno::Reference< css::beans::XPropertySet > &i_xMeta, bool i_bAutoStyles, bool i_bProgress, bool &rPrevCharIsSpace)
export text:meta-field (RDF metadata)
Definition: txtflde.cxx:2319
constexpr OUStringLiteral gsPropertyInstanceName(u"InstanceName")
constexpr OUStringLiteral gsPropertyNumberFormat(u"NumberFormat")
constexpr OUStringLiteral gsPropertyName(u"Name")
char const FIELD_SERVICE_DB_NEXT[]
Definition: txtflde.cxx:97
char const FIELD_SERVICE_DOC_INFO_EDIT_TIME2[]
Definition: txtflde.cxx:110
void ExportFieldAutoStyle(const css::uno::Reference< css::text::XTextField > &rTextField, const bool bProgress, const bool bRecursive)
collect styles (character styles, data styles, ...) for this field (if appropriate).
Definition: txtflde.cxx:750
constexpr sal_uInt16 XML_NAMESPACE_SCRIPT
signed char sal_Int8
char const FIELD_SERVICE_DROP_DOWN[]
Definition: txtflde.cxx:156
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
char const FIELD_SERVICE_PARAGRAPH_COUNT[]
Definition: txtflde.cxx:135
static Sequence< OUString > GetStringSequenceProperty(const OUString &sPropName, const Reference< XPropertySet > &xPropSet)
Definition: txtflde.cxx:3569
size_t GetInfoID(const OUString sPersonalInfo) const
Definition: xmlexp.hxx:393
rtl::Reference< XMLTextParagraphExport > const & GetTextParagraphExport()
Definition: xmlexp.hxx:562
static OUString MakeSequenceRefName(sal_Int16 nSeqNo, std::u16string_view rSeqName)
make reference name for a sequence field
Definition: txtflde.cxx:3475
char const FIELD_SERVICE_DOC_INFO_KEY_WORDS2[]
Definition: txtflde.cxx:124
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlexp.hxx:396
char const FIELD_SERVICE_DATETIME[]
Definition: txtflde.cxx:95
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
constexpr OUStringLiteral gsPropertyTooltip(u"Tooltip")
void ProcessInteger(enum::xmloff::token::XMLTokenEnum eXmlName, sal_Int32 nNum)
attribute default; omit, if attribute differs
Definition: txtflde.cxx:2558
constexpr OUStringLiteral gsPropertyValue(u"Value")
static enum::xmloff::token::XMLTokenEnum MapCountFieldName(FieldIdEnum nToken)
map count/statistics field token to XML name
Definition: txtflde.cxx:3015
char const FIELD_SERVICE_PAGE_COUNT[]
Definition: txtflde.cxx:134
static enum::xmloff::token::XMLTokenEnum MapReferenceType(sal_Int16 nType)
map ReferenceFieldPart to XML string
Definition: txtflde.cxx:3111
void ExportFieldDeclarations()
export field declarations.
Definition: txtflde.cxx:1924
static double GetDoubleProperty(const OUString &, const Reference< XPropertySet > &)
Definition: txtflde.cxx:3509
constexpr sal_uInt16 XML_NAMESPACE_XLINK
constexpr OUStringLiteral gsPropertyContent(u"Content")
constexpr OUStringLiteral gsPropertyChapterNumberingLevel(u"ChapterNumberingLevel")
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
std::unique_ptr< ::std::map< css::uno::Reference< css::text::XText >,::std::set< OUString > > > pUsedMasters
store used text field master names (NULL means: don't collect)
Definition: txtflde.hxx:157
void ExportField(const css::uno::Reference< css::text::XTextField > &rTextField, bool bProgress, bool &rPrevCharIsSpace)
Export this field and the surrounding span element with the formatting.
Definition: txtflde.cxx:973
char const FIELD_SERVICE_MEASURE[]
Definition: txtflde.cxx:154
void ProcessParagraphSequence(std::u16string_view sParagraphSequence)
default value token
Definition: txtflde.cxx:2542
void ProcessDisplay(bool bIsVisible, bool bIsCommand)
numbering type key
Definition: txtflde.cxx:2426
constexpr OUStringLiteral gsPropertyDataCommandType(u"DataCommandType")
constexpr OUStringLiteral gsPropertyDDECommandElement(u"DDECommandElement")
SvXMLExport & GetExport()
Definition: txtflde.hxx:212
constexpr OUStringLiteral gsPropertySequenceValue(u"SequenceValue")
SvXMLEnumMapEntry< sal_Int16 > const aBibliographyDataTypeMap[]
Definition: txtflde.cxx:2679
static enum FieldIdEnum GetFieldID(const css::uno::Reference< css::text::XTextField > &rTextField, const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
get field ID from XTextField (and it's Property-Set)
Definition: txtflde.cxx:386
constexpr OUStringLiteral gsPropertyInitials(u"Initials")
constexpr OUStringLiteral gsPropertyIsHidden(u"IsHidden")
char const FIELD_SERVICE_TEMPLATE_NAME[]
Definition: txtflde.cxx:133
constexpr OUStringLiteral gsPropertyHelp(u"Help")
constexpr OUStringLiteral gsPropertyDependentTextFields(u"DependentTextFields")
constexpr OUStringLiteral gsPropertyDDECommandType(u"DDECommandType")
char const FIELD_SERVICE_HIDDEN_PARAGRAPH[]
Definition: txtflde.cxx:104
constexpr OUStringLiteral gsPropertySelectedItem(u"SelectedItem")
char const FIELD_SERVICE_DOC_INFO_KEY_WORDS[]
Definition: txtflde.cxx:123
char const FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR[]
Definition: txtflde.cxx:105
char const FIELD_SERVICE_CHAPTER[]
Definition: txtflde.cxx:132
void ExportSingleEvent(const css::uno::Sequence< css::beans::PropertyValue > &rEventValues, const OUString &rApiEventName, bool bUseWhitespace=true)
export a single event (writes element)
static enum::xmloff::token::XMLTokenEnum MapChapterDisplayFormat(sal_Int16 nType)
map ChapterDisplayFormat to XML string
Definition: txtflde.cxx:3052
constexpr OUStringLiteral gsPropertyIsExpression(u"IsExpression")
static sal_Int16 GetInt16Property(const OUString &, const Reference< XPropertySet > &)
Definition: txtflde.cxx:3539
char const FIELD_SERVICE_DB_NAME[]
Definition: txtflde.cxx:101
char const FIELD_SERVICE_DDE[]
Definition: txtflde.cxx:147
char const FIELD_SERVICE_DOC_INFO_SUBJECT2[]
Definition: txtflde.cxx:126
char const FIELD_SERVICE_REFERENCE_PAGE_SET[]
Definition: txtflde.cxx:141
char const FIELD_SERVICE_TABLE_FORMULA[]
Definition: txtflde.cxx:155
XMLTextFieldExport(SvXMLExport &rExp, std::unique_ptr< XMLPropertyState > pCombinedCharState)
Definition: txtflde.cxx:373
constexpr OUStringLiteral gsPropertyDateTime(u"DateTime")
constexpr OUStringLiteral gsPropertyFalseContent(u"FalseContent")
constexpr OUStringLiteral gsPropertyIsConditionTrue(u"IsConditionTrue")
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
Definition: xmlexp.cxx:911
SvXMLEnumStringMapEntry< FieldIdEnum > const aFieldServiceNameMapping[]
Definition: txtflde.cxx:183
constexpr sal_uInt16 XML_NAMESPACE_FORM
void ProcessString(enum::xmloff::token::XMLTokenEnum eXmlName, const OUString &sValue, bool bOmitEmpty=false, sal_uInt16 nPrefix=XML_NAMESPACE_TEXT)
default value
constexpr OUStringLiteral gsPropertyURLContent(u"URLContent")
char const FIELD_SERVICE_COMBINED_CHARACTERS[]
Definition: txtflde.cxx:152
constexpr OUStringLiteral gsPropertyAdjust(u"Adjust")
char const FIELD_SERVICE_DOC_INFO_SUBJECT[]
Definition: txtflde.cxx:125
char const FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR[]
Definition: txtflde.cxx:119
static bool GetOptionalBoolProperty(const OUString &, const Reference< XPropertySet > &, const Reference< XPropertySetInfo > &, bool bDefault)
Definition: txtflde.cxx:3499
char const FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR[]
Definition: txtflde.cxx:113
OUString GetRelativeReference(const OUString &rValue)
Definition: xmlexp.cxx:2064
char const FIELD_SERVICE_TABLE_COUNT[]
Definition: txtflde.cxx:138
virtual OUString getDataStyleName(const sal_Int32 nNumberFormat, bool bTimeFormat=false) const
Definition: xmlexp.cxx:1824
constexpr OUStringLiteral gsPropertyOffset(u"Offset")
constexpr OUStringLiteral sEventType
const char * sName
void ProcessTimeOrDateTime(enum::xmloff::token::XMLTokenEnum eXMLName, const css::util::DateTime &rTime)
date/time value
Definition: txtflde.cxx:2666
constexpr OUStringLiteral gsPropertyNumberingSeparator(u"NumberingSeparator")
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
constexpr OUStringLiteral gsPropertyPlaceholderType(u"PlaceHolderType")
DocumentType eType
SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const
returns the deterministic version for odf export
Definition: xmlexp.cxx:2271
char const FIELD_SERVICE_CHARACTER_COUNT[]
Definition: txtflde.cxx:137
static util::DateTime GetDateTimeProperty(const OUString &sPropName, const Reference< XPropertySet > &xPropSet)
Definition: txtflde.cxx:3559
constexpr OUStringLiteral gsFieldMasterPrefix(u"com.sun.star.text.FieldMaster.")
constexpr OUStringLiteral gsPropertySetNumber(u"SetNumber")
constexpr OUStringLiteral gsPropertyTextRange(u"TextRange")
static enum::xmloff::token::XMLTokenEnum MapMeasureKind(sal_Int16 nKind)
Definition: txtflde.cxx:3456
Map a const char* (with length) to a sal_uInt16 value.
Definition: xmlement.hxx:70
char const FIELD_SERVICE_META[]
Definition: txtflde.cxx:153
char const FIELD_SERVICE_SCRIPT[]
Definition: txtflde.cxx:150
void ProcessValueAndType(bool bIsString, sal_Int32 nFormatKey, const OUString &sContent, std::u16string_view sDefault, double fValue, bool bExportValue, bool bExportValueType, bool bExportStyle, bool bForceSystemLanguage, bool bTimeStyle=false)
is show command/show name?
Definition: txtflde.cxx:2361
void ProcessBoolean(enum::xmloff::token::XMLTokenEnum eXmlName, bool bBool, bool bDefault)
export a boolean attribute
Definition: txtflde.cxx:2449
char const FIELD_SERVICE_SETEXP[]
Definition: txtflde.cxx:91
void ExportDataBaseElement(enum::xmloff::token::XMLTokenEnum eElement, const OUString &sContent, const css::uno::Reference< css::beans::XPropertySet > &rPropertySet, const css::uno::Reference< css::beans::XPropertySetInfo > &rPropertySetInfo)
export attributes that describe a data source
Definition: txtflde.cxx:2801
char const FIELD_SERVICE_AUTHOR[]
Definition: txtflde.cxx:88
#define DBG_ASSERT(sCon, aError)
char const FIELD_SERVICE_GET_REFERENCE[]
Definition: txtflde.cxx:146
int i
char const FIELD_SERVICE_OBJECT_COUNT[]
Definition: txtflde.cxx:140
char const FIELD_SERVICE_DOC_INFO_REVISION2[]
Definition: txtflde.cxx:130
XMLEventExport & GetEventExport()
get Event export, with handlers for script types "None" and "StarBasic" already registered; other han...
Definition: xmlexp.cxx:1993
bool getNextToken(std::u16string_view &rToken)
Definition: xmluconv.cxx:527
constexpr sal_uInt16 XML_NAMESPACE_TEXT
char const FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME[]
Definition: txtflde.cxx:115
char const FIELD_SERVICE_USER[]
Definition: txtflde.cxx:92
char const FIELD_SERVICE_DOC_INFO_TITLE2[]
Definition: txtflde.cxx:128
void ProcessDateTime(enum::xmloff::token::XMLTokenEnum eXMLName, double dValue, bool bIsDate, bool bIsDuration, bool bOmitDurationIfZero=true, sal_uInt16 nPrefix=XML_NAMESPACE_TEXT)
exporting a time style?
char const FIELD_SERVICE_USERINPUT[]
Definition: txtflde.cxx:94
constexpr OUStringLiteral gsPropertyDateTimeValue(u"DateTimeValue")
static enum::xmloff::token::XMLTokenEnum MapReferenceSource(sal_Int16 nType)
map ReferenceFieldPart to XML string
Definition: txtflde.cxx:3163
char const FIELD_SERVICE_PAGE_NAME[]
Definition: txtflde.cxx:144
char const FIELD_SERVICE_MACRO[]
Definition: txtflde.cxx:145
void convertDateTime(OUStringBuffer &rBuffer, const double &fDateTime, bool const bAddTimeIf0AM=false)
convert double to ISO Date Time String
Definition: xmluconv.cxx:375
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
constexpr OUStringLiteral gsPropertySubType(u"SubType")
char const FIELD_SERVICE_DOC_INFO_CUSTOM[]
Definition: txtflde.cxx:117
float u
char const FIELD_SERVICE_WORD_COUNT[]
Definition: txtflde.cxx:136
static void convertDateTime(OUStringBuffer &rBuffer, const css::util::DateTime &rDateTime, sal_Int16 const *pTimeZoneOffset, bool bAddTimeIf0AM=false)
static OUString MakeFootnoteRefName(sal_Int16 nSeqNo)
out: variable name
Definition: txtflde.cxx:3468
static void SetNumberFormatAttributes(SvXMLExport &rXMLExport, const sal_Int32 nNumberFormat, const double &rValue, bool bExportValue=true)
Definition: numehelp.cxx:273
constexpr OUStringLiteral gsPresentationServicePrefix(u"com.sun.star.presentation.TextField.")
void ProcessCommandType(sal_Int32 nCommandType)
export CommandTypeAttribute
Definition: txtflde.cxx:2757
static void convertDuration(OUStringBuffer &rBuffer, const double fTime)
void ExportFieldHelper(const css::uno::Reference< css::text::XTextField > &rTextField, const css::uno::Reference< css::beans::XPropertySet > &rPropSet, const css::uno::Reference< css::beans::XPropertySet > &rRangePropSet, enum FieldIdEnum nToken, bool bProgress, bool &rPrevCharIsSpace)
export a field after is already written
Definition: txtflde.cxx:1058
constexpr OUStringLiteral gsPropertyIsVisible(u"IsVisible")
constexpr OUStringLiteral gsPropertyCondition(u"Condition")
char const FIELD_SERVICE_FILE_NAME[]
Definition: txtflde.cxx:131
constexpr OUStringLiteral gsPropertySourceName(u"SourceName")
constexpr OUStringLiteral gsPropertyReferenceFieldLanguage(u"ReferenceFieldLanguage")
static void convertTimeOrDateTime(OUStringBuffer &rBuffer, const css::util::DateTime &rDateTime)
char const FIELD_SERVICE_DOC_INFO_CUSTOM2[]
Definition: txtflde.cxx:118
OUString GetQNameByKey(sal_uInt16 nKey, const OUString &rLocalName, bool bCache=true) const
constexpr OUStringLiteral gsPropertyTrueContent(u"TrueContent")
constexpr sal_uInt16 XML_NAMESPACE_DC
char const FIELD_SERVICE_DB_NUMBER[]
Definition: txtflde.cxx:99
char const FIELD_SERVICE_GETEXP[]
Definition: txtflde.cxx:90
static enum::xmloff::token::XMLTokenEnum MapSenderFieldName(const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
element name for sender fields
Definition: txtflde.cxx:3192
void SetExportOnlyUsedFieldDeclarations(bool bExportOnlyUsed=true)
export all field declarations, or only those that have been used? Calling this method will reset the ...
Definition: txtflde.cxx:2224
const SvXMLNamespaceMap & GetNamespaceMap() const
Definition: xmlexp.hxx:390
static css::uno::Reference< css::beans::XPropertySet > GetMasterPropertySet(const css::uno::Reference< css::text::XTextField > &rTextField)
for XDependentTextFields, get PropertySet of FieldMaster
Definition: txtflde.cxx:2869
static bool convertBool(bool &rBool, std::u16string_view rString)
static OUString GetStringProperty(const OUString &, const Reference< XPropertySet > &)
Definition: txtflde.cxx:3519
constexpr OUStringLiteral gsPropertyFields(u"Fields")
char const FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR2[]
Definition: txtflde.cxx:114
constexpr OUStringLiteral gsPropertyFullName(u"FullName")
constexpr OUStringLiteral gsPropertyFieldSubType(u"UserDataType")
constexpr OUStringLiteral gsPropertyHint(u"Hint")
static enum::xmloff::token::XMLTokenEnum MapTemplateDisplayFormat(sal_Int16 nType)
map TemplateDisplayFormat to XML
Definition: txtflde.cxx:2981
void ProcessBibliographyData(const css::uno::Reference< css::beans::XPropertySet > &rPropertySet)
date/time value
Definition: txtflde.cxx:2707
static bool GetDependentFieldPropertySet(const css::uno::Reference< css::beans::XPropertySet > &xmaster, css::uno::Reference< css::beans::XPropertySet > &xField)
get PropertySet of (any) DependentTextField for this FieldMaster
Definition: txtflde.cxx:2878
std::unique_ptr< XMLPropertyState > pCombinedCharactersPropertyState
Definition: txtflde.hxx:409
FieldIdEnum
field IDs,
Definition: txtflde.hxx:55
constexpr OUStringLiteral gsPropertyDataBaseName(u"DataBaseName")
Map an XMLTokenEnum to an enum value.
Definition: ximpshap.hxx:39
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION
static void convertNumLetterSync(OUStringBuffer &rBuffer, sal_Int16 nType)
Definition: xmluconv.cxx:750
DefTokenId nToken
std::unique_ptr< char[]> aBuffer
char const FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR2[]
Definition: txtflde.cxx:120
constexpr OUStringLiteral gsPropertyURL(u"URL")
char const FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME[]
Definition: txtflde.cxx:121
char const FIELD_SERVICE_DOC_INFO_REVISION[]
Definition: txtflde.cxx:129
constexpr OUStringLiteral gsPropertyDataColumnName(u"DataColumnName")
char const FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME[]
Definition: txtflde.cxx:107
char const FIELD_SERVICE_ANNOTATION[]
Definition: txtflde.cxx:151
char const FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME2[]
Definition: txtflde.cxx:122
#define SAL_WARN_IF(condition, area, stream)
char const FIELD_SERVICE_DOC_INFO_TITLE[]
Definition: txtflde.cxx:127
static sal_Int32 GetIntProperty(const OUString &, const Reference< XPropertySet > &)
Definition: txtflde.cxx:3529
constexpr OUStringLiteral sScript
char const FIELD_SERVICE_DOC_INFO_DESCRIPTION[]
Definition: txtflde.cxx:111
constexpr OUStringLiteral gsPropertyReferenceFieldSource(u"ReferenceFieldSource")
constexpr OUStringLiteral gsPropertyChapterFormat(u"ChapterFormat")
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
char const FIELD_SERVICE_CONDITIONAL_TEXT[]
Definition: txtflde.cxx:102
Handling of tokens in XML:
OUString aName
void Characters(const OUString &rChars)
Definition: xmlexp.cxx:2133
char const FIELD_SERVICE_BIBLIOGRAPHY[]
Definition: txtflde.cxx:149
std::map< OUString, rtl::Reference< Entity > > map
constexpr OUStringLiteral gsPropertyIsInput(u"Input")
void ProcessNumberingType(sal_Int16 nNumberingType)
export a numbering format (numeric, roman, alphabetic, etc.)
Definition: txtflde.cxx:2579
Smart struct to transport an Any with an index to the appropriate property-name.
Definition: maptype.hxx:139
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
char const FIELD_SERVICE_JUMPEDIT[]
Definition: txtflde.cxx:89
QPRO_FUNC_TYPE nType
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:49
constexpr OUStringLiteral gsPropertyTargetFrame(u"TargetFrame")
Sequence< sal_Int8 > aSeq
static enum::xmloff::token::XMLTokenEnum MapBibliographyFieldName(std::u16string_view sName)
Definition: txtflde.cxx:3315
char const FIELD_SERVICE_SHEET_NAME[]
Definition: txtflde.cxx:143
char const FIELD_SERVICE_DB_DISPLAY[]
Definition: txtflde.cxx:100
static enum::xmloff::token::XMLTokenEnum MapDocInfoFieldName(enum FieldIdEnum nToken)
Definition: txtflde.cxx:3254
sal_Int32 dataStyleForceSystemLanguage(sal_Int32 nFormat) const
Definition: xmlexp.cxx:1836
constexpr OUStringLiteral gsPropertyFileFormat(u"FileFormat")
static enum::xmloff::token::XMLTokenEnum MapPageNumberName(const css::uno::Reference< css::beans::XPropertySet > &xPropSet, sal_Int32 &nOffset)
Definition: txtflde.cxx:2949
static sal_Int8 GetInt8Property(const OUString &, const Reference< XPropertySet > &)
Definition: txtflde.cxx:3549
constexpr OUStringLiteral gsPropertyMeasureKind(u"Kind")
char const FIELD_SERVICE_DOC_INFO_EDIT_TIME[]
Definition: txtflde.cxx:109
char const FIELD_SERVICE_GRAPHIC_COUNT[]
Definition: txtflde.cxx:139
bool hasProperty(const OUString &_rName, const Reference< XPropertySet > &_rxSet)
char const FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME2[]
Definition: txtflde.cxx:116
#define SAL_WARN(area, stream)
char const FIELD_SERVICE_DOC_INFO_DESCRIPTION2[]
Definition: txtflde.cxx:112
void(* f)(TrueTypeTable *)
constexpr OUStringLiteral gsPropertyScriptType(u"ScriptType")
constexpr OUStringLiteral gsPropertyOn(u"On")
sal_Int32 nLength
Definition: xmltoken.cxx:38
char const FIELD_SERVICE_PAGENUMBER[]
Definition: txtflde.cxx:96
char const FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME2[]
Definition: txtflde.cxx:108
void AddAttributeXmlId(css::uno::Reference< css::uno::XInterface > const &i_xIfc)
add xml:id attribute (for RDF metadata)
Definition: xmlexp.cxx:2297
XMLTokenEnum eToken
Definition: xmltoken.cxx:40
constexpr sal_uInt16 XML_NAMESPACE_META
constexpr OUStringLiteral gsPropertyItems(u"Items")
void ExportMacro(const css::uno::Reference< css::beans::XPropertySet > &rPropSet, const OUString &rContent)
element content
Definition: txtflde.cxx:2267
constexpr OUStringLiteral gsPropertyDataTableName(u"DataTableName")
char const FIELD_SERVICE_SENDER[]
Definition: txtflde.cxx:87
virtual void addDataStyle(const sal_Int32 nNumberFormat, bool bTimeFormat=false)
Definition: xmlexp.cxx:1803
constexpr OUStringLiteral gsPropertyDataBaseURL(u"DataBaseURL")
constexpr OUStringLiteral gsPropertyUserText(u"UserText")
constexpr sal_uInt16 XML_NAMESPACE_OOOW
char const FIELD_SERVICE_INPUT[]
Definition: txtflde.cxx:93
char const FIELD_SERVICE_URL[]
Definition: txtflde.cxx:148
static enum FieldIdEnum MapFieldName(std::u16string_view sFieldName, const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
get field ID from XTextField service name (and it's PropertySet)
Definition: txtflde.cxx:439
void ProcessIntegerDef(enum::xmloff::token::XMLTokenEnum eXmlName, sal_Int32 nNum, sal_Int32 nDefault)
attribute value
Definition: txtflde.cxx:2570
constexpr OUStringLiteral gsPropertyIsShowFormula(u"IsShowFormula")
constexpr OUStringLiteral gsServicePrefix(u"com.sun.star.text.textfield.")
constexpr OUStringLiteral gsPropertyIsAutomaticUpdate(u"IsAutomaticUpdate")
constexpr OUStringLiteral gsPropertyAuthor(u"Author")
static void ExplodeFieldMasterName(std::u16string_view sMasterName, OUString &sFieldType, OUString &sVarName)
explode a field master name into field type and field name
Definition: txtflde.cxx:2850
constexpr OUStringLiteral gsPropertyIsFixedLanguage(u"IsFixedLanguage")
constexpr sal_uInt16 XML_NAMESPACE_STYLE
constexpr OUStringLiteral gsPropertySequenceNumber(u"SequenceNumber")
constexpr OUStringLiteral gsPropertyDDECommandFile(u"DDECommandFile")
constexpr OUStringLiteral gsPropertyIsDataBaseFormat(u"DataBaseFormat")
constexpr OUStringLiteral gsPropertyCharStyleNames(u"CharStyleNames")
constexpr OUStringLiteral gsPropertyIsFixed(u"IsFixed")
bool m_bDetectedRangeSegmentation false
void Export(css::uno::Reference< css::document::XEventsSupplier > const &xAccess, bool bUseWhitespace=true)
export the events (calls EventExport::Export(Reference) )
static enum::xmloff::token::XMLTokenEnum MapAuthorFieldName(const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
also adjust page offset
Definition: txtflde.cxx:2941
char const FIELD_SERVICE_DB_SELECT[]
Definition: txtflde.cxx:98
static enum::xmloff::token::XMLTokenEnum MapPlaceholderType(sal_uInt16 nType)
map placeholder type
Definition: txtflde.cxx:2905
#define ENUM_STRING_MAP_ENTRY(name, tok)
Definition: xmlement.hxx:62