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