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