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/nmspmap.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 const OUStringLiteral gsServicePrefix("com.sun.star.text.textfield.");
299 const OUStringLiteral gsFieldMasterPrefix("com.sun.star.text.FieldMaster.");
300 const OUStringLiteral gsPresentationServicePrefix("com.sun.star.presentation.TextField.");
301 
302  // property names
303 const OUStringLiteral gsPropertyAdjust("Adjust");
304 const OUStringLiteral gsPropertyAuthor("Author");
305 const OUStringLiteral gsPropertyChapterFormat("ChapterFormat");
306 const OUStringLiteral gsPropertyChapterNumberingLevel("ChapterNumberingLevel");
307 const OUStringLiteral gsPropertyCharStyleNames("CharStyleNames");
308 const OUStringLiteral gsPropertyCondition("Condition");
309 const OUStringLiteral gsPropertyContent("Content");
310 const OUStringLiteral gsPropertyDataBaseName("DataBaseName");
311 const OUStringLiteral gsPropertyDataBaseURL("DataBaseURL");
312 const OUStringLiteral gsPropertyDataColumnName("DataColumnName");
313 const OUStringLiteral gsPropertyDataCommandType("DataCommandType");
314 const OUStringLiteral gsPropertyDataTableName("DataTableName");
315 const OUStringLiteral gsPropertyDateTime("DateTime");
316 const OUStringLiteral gsPropertyDateTimeValue("DateTimeValue");
317 const OUStringLiteral gsPropertyDDECommandElement("DDECommandElement");
318 const OUStringLiteral gsPropertyDDECommandFile("DDECommandFile");
319 const OUStringLiteral gsPropertyDDECommandType("DDECommandType");
320 const OUStringLiteral gsPropertyDependentTextFields("DependentTextFields");
321 const OUStringLiteral gsPropertyFalseContent("FalseContent");
322 const OUStringLiteral gsPropertyFields("Fields");
323 const OUStringLiteral gsPropertyFieldSubType("UserDataType");
324 const OUStringLiteral gsPropertyFileFormat("FileFormat");
325 const OUStringLiteral gsPropertyFullName("FullName");
326 const OUStringLiteral gsPropertyHint("Hint");
327 const OUStringLiteral gsPropertyInitials("Initials");
328 const OUStringLiteral gsPropertyInstanceName("InstanceName");
329 const OUStringLiteral gsPropertyIsAutomaticUpdate("IsAutomaticUpdate");
330 const OUStringLiteral gsPropertyIsConditionTrue("IsConditionTrue");
331 const OUStringLiteral gsPropertyIsDataBaseFormat("DataBaseFormat");
332 const OUStringLiteral gsPropertyIsDate("IsDate");
333 const OUStringLiteral gsPropertyIsExpression("IsExpression");
334 const OUStringLiteral gsPropertyIsFixed("IsFixed");
335 const OUStringLiteral gsPropertyIsFixedLanguage("IsFixedLanguage");
336 const OUStringLiteral gsPropertyIsHidden("IsHidden");
337 const OUStringLiteral gsPropertyIsInput("Input");
338 const OUStringLiteral gsPropertyIsShowFormula("IsShowFormula");
339 const OUStringLiteral gsPropertyIsVisible("IsVisible");
340 const OUStringLiteral gsPropertyItems("Items");
341 const OUStringLiteral gsPropertyLevel("Level");
342 const OUStringLiteral gsPropertyMeasureKind("Kind");
343 const OUStringLiteral gsPropertyName("Name");
344 const OUStringLiteral gsPropertyNumberFormat("NumberFormat");
345 const OUStringLiteral gsPropertyNumberingSeparator("NumberingSeparator");
346 const OUStringLiteral gsPropertyNumberingType("NumberingType");
347 const OUStringLiteral gsPropertyOffset("Offset");
348 const OUStringLiteral gsPropertyOn("On");
349 const OUStringLiteral gsPropertyPlaceholderType("PlaceHolderType");
350 const OUStringLiteral gsPropertyReferenceFieldPart("ReferenceFieldPart");
351 const OUStringLiteral gsPropertyReferenceFieldSource("ReferenceFieldSource");
352 const OUStringLiteral gsPropertyReferenceFieldLanguage("ReferenceFieldLanguage");
353 const OUStringLiteral gsPropertyScriptType("ScriptType");
354 const OUStringLiteral gsPropertySelectedItem("SelectedItem");
355 const OUStringLiteral gsPropertySequenceNumber("SequenceNumber");
356 const OUStringLiteral gsPropertySequenceValue("SequenceValue");
357 const OUStringLiteral gsPropertySetNumber("SetNumber");
358 const OUStringLiteral gsPropertySourceName("SourceName");
359 const OUStringLiteral gsPropertySubType("SubType");
360 const OUStringLiteral gsPropertyTargetFrame("TargetFrame");
361 const OUStringLiteral gsPropertyTrueContent("TrueContent");
362 const OUStringLiteral gsPropertyURL("URL");
363 const OUStringLiteral gsPropertyURLContent("URLContent");
364 const OUStringLiteral gsPropertyUserText("UserText");
365 const OUStringLiteral gsPropertyValue("Value");
366 const OUStringLiteral gsPropertyVariableName("VariableName");
367 const OUStringLiteral gsPropertyHelp("Help");
368 const OUStringLiteral gsPropertyTooltip("Tooltip");
369 const OUStringLiteral gsPropertyTextRange("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  const OUString& 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.isEmpty(), "no valid service name!");
452  if (!sFieldName.isEmpty())
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");
899  const XMLPropertyState *aStates[] = { pCombinedCharactersPropertyState.get(), nullptr };
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  "", "", 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  "", "", 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  "", "", 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  "", "", 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 MapPageNumebrName
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  "", "", 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  "", "", 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  "", "", 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  // annotation element + content
1750  OUString aName;
1751  rPropSet->getPropertyValue(gsPropertyName) >>= aName;
1752  if (!aName.isEmpty())
1753  {
1756  if (eVersion & SvtSaveOptions::ODFSVER_EXTENDED)
1757  {
1758  bool b = GetBoolProperty("Resolved", rPropSet);
1759  OUString aResolvedText;
1760  OUStringBuffer aResolvedTextBuffer;
1761  ::sax::Converter::convertBool(aResolvedTextBuffer, b);
1762  aResolvedText = aResolvedTextBuffer.makeStringAndClear();
1763 
1765  aResolvedText);
1766  }
1767  }
1769  XML_ANNOTATION, false, true);
1770 
1771  // author
1772  OUString aAuthor( GetStringProperty(gsPropertyAuthor, rPropSet) );
1773  if( !aAuthor.isEmpty() )
1774  {
1776  XML_CREATOR, true,
1777  false );
1778  GetExport().Characters(aAuthor);
1779  }
1780 
1781  // date time
1782  util::DateTime aDate( GetDateTimeProperty(gsPropertyDateTimeValue, rPropSet) );
1783  {
1784  OUStringBuffer aBuffer;
1785  ::sax::Converter::convertDateTime(aBuffer, aDate, nullptr, true);
1787  XML_DATE, true,
1788  false );
1789  GetExport().Characters(aBuffer.makeStringAndClear());
1790  }
1791 
1793  {
1794  // initials
1795  OUString aInitials( GetStringProperty(gsPropertyInitials, rPropSet) );
1796  if( !aInitials.isEmpty() )
1797  {
1798  // ODF 1.3 OFFICE-3776 export meta:creator-initials for ODF 1.3
1799  SvXMLElementExport aCreatorElem( GetExport(),
1800  (SvtSaveOptions::ODFSVER_013 <= GetExport().getSaneDefaultVersion())
1803 
1804  (SvtSaveOptions::ODFSVER_013 <= GetExport().getSaneDefaultVersion())
1807  true, false );
1808  GetExport().Characters(aInitials);
1809  }
1810  }
1811 
1812  css::uno::Reference < css::text::XText > xText;
1813  try
1814  {
1815  css::uno::Any aRet = rPropSet->getPropertyValue(gsPropertyTextRange);
1816  aRet >>= xText;
1817  }
1818  catch ( css::uno::Exception& )
1819  {}
1820 
1821  if ( xText.is() )
1822  GetExport().GetTextParagraphExport()->exportText( xText );
1823  else
1825  break;
1826  }
1827 
1829  {
1830  // The style with the combined characters attribute has
1831  // already been handled in the ExportField method. So all that
1832  // is left to do now is to export the characters.
1833  GetExport().Characters(sPresentation);
1834  break;
1835  }
1836 
1837  case FIELD_ID_META:
1838  {
1839  ExportMetaField(rPropSet, false, bProgress, rPrevCharIsSpace);
1840  break;
1841  }
1842 
1843  case FIELD_ID_MEASURE:
1844  {
1846  ExportElement( XML_MEASURE, sPresentation );
1847  break;
1848  }
1849 
1852  GetStringProperty(gsPropertyContent, rPropSet) );
1853  ProcessDisplay( true,
1855  ProcessValueAndType( false,
1857  "", "", 0.0f,
1858  false, false, true,
1859  false );
1860  ExportElement( XML_TABLE_FORMULA, sPresentation );
1861  break;
1862 
1863  case FIELD_ID_DROP_DOWN:
1864  {
1865  // tdf#133555 don't export in strict ODF versions that don't have it
1866  if (GetExport().getSaneDefaultVersion() <= SvtSaveOptions::ODFSVER_012)
1867  {
1868  break;
1869  }
1872  GetStringProperty(gsPropertyHelp, rPropSet), true);
1874  GetStringProperty(gsPropertyTooltip, rPropSet), true);
1875  SvXMLElementExport aElem( GetExport(),
1877  false, false );
1881 
1882  GetExport().Characters( sPresentation );
1883  }
1884  break;
1885 
1886  case FIELD_ID_DRAW_HEADER:
1887  {
1889  }
1890  break;
1891 
1892  case FIELD_ID_DRAW_FOOTER:
1893  {
1895  }
1896  break;
1897 
1899  {
1901  }
1902  break;
1903 
1904 
1905  case FIELD_ID_UNKNOWN:
1906  default:
1907  OSL_FAIL("unknown field type encountered!");
1908  // always export content
1909  GetExport().Characters(sPresentation);
1910  }
1911 }
1912 
1913 
1916 {
1917  Reference<XText> xEmptyText;
1918  ExportFieldDeclarations(xEmptyText);
1919 }
1920 
1923  const Reference<XText> & rText )
1924 {
1925  // store lists for decl elements
1926  vector<OUString> aVarName;
1927  vector<OUString> aUserName;
1928  vector<OUString> aSeqName;
1929  vector<OUString> aDdeName;
1930 
1931  // get text fields supplier and field master name access
1932  Reference<XTextFieldsSupplier> xTextFieldsSupp(GetExport().GetModel(),
1933  UNO_QUERY);
1934  if( !xTextFieldsSupp.is() )
1935  return;
1936 
1937  Reference<container::XNameAccess> xFieldMasterNameAccess =
1938  xTextFieldsSupp->getTextFieldMasters();
1939 
1940  // where to get the text field masters from?
1941  // a) we get a specific XText: then use pUsedMasters
1942  // b) the XText is empty: then export all text fields
1943  Sequence<OUString> aFieldMasters;
1944  if (rText.is())
1945  {
1946  // export only used masters
1947  DBG_ASSERT(nullptr != pUsedMasters,
1948  "field masters must be recorded in order to be "
1949  "written out separately" );
1950  if (nullptr != pUsedMasters)
1951  {
1952  map<Reference<XText>, set<OUString> > ::iterator aMapIter =
1953  pUsedMasters->find(rText);
1954  if (aMapIter != pUsedMasters->end())
1955  {
1956  // found the set of used field masters
1957  aFieldMasters = comphelper::containerToSequence(aMapIter->second);
1958  pUsedMasters->erase(rText);
1959  }
1960  // else: XText not found -> ignore
1961  }
1962  // else: no field masters have been recorded -> ignore
1963  }
1964  else
1965  {
1966  // no XText: export all!
1967  aFieldMasters = xFieldMasterNameAccess->getElementNames();
1968  }
1969 
1970  for(const OUString& sFieldMaster : std::as_const(aFieldMasters)) {
1971 
1972  // workaround for #no-bug#
1973  if ( sFieldMaster.startsWithIgnoreAsciiCase(
1974  "com.sun.star.text.FieldMaster.DataBase.") )
1975  {
1976  continue;
1977  }
1978 
1979 
1980  OUString sFieldMasterType;
1981  OUString sVarName;
1982  ExplodeFieldMasterName(sFieldMaster, sFieldMasterType, sVarName);
1983 
1984  // get XPropertySet of this field master
1985  Reference<XPropertySet> xPropSet;
1986  Any aAny = xFieldMasterNameAccess->getByName(sFieldMaster);
1987  aAny >>= xPropSet;
1988 
1989  // save interesting field masters
1990  if (sFieldMasterType == FIELD_SERVICE_SETEXP)
1991  {
1992  sal_Int32 nType = GetIntProperty(gsPropertySubType, xPropSet);
1993 
1994  // sequence or variable?
1995  if ( SetVariableType::SEQUENCE == nType )
1996  {
1997  aSeqName.push_back( sFieldMaster );
1998  }
1999  else
2000  {
2001  aVarName.push_back( sFieldMaster );
2002  }
2003  }
2004  else if (sFieldMasterType == FIELD_SERVICE_USER)
2005  {
2006  aUserName.push_back( sFieldMaster );
2007  }
2008  else if (sFieldMasterType == FIELD_SERVICE_DDE)
2009  {
2010  aDdeName.push_back( sFieldMaster );
2011  }
2012  else
2013  {
2014  ; // ignore
2015  }
2016  }
2017 
2018  // now process fields:
2019 
2020  // variable field masters:
2021  if ( !aVarName.empty() )
2022  {
2023  SvXMLElementExport aElem( GetExport(),
2026  true, true );
2027 
2028  for (const auto& sName : aVarName)
2029  {
2030  // get field master property set
2031  Reference<XPropertySet> xPropSet;
2032  Any aAny = xFieldMasterNameAccess->getByName(sName);
2033  aAny >>= xPropSet;
2034 
2035  // field name and type
2036  OUString sFieldMasterType;
2037  OUString sVarName;
2038  ExplodeFieldMasterName(sName, sFieldMasterType, sVarName);
2039 
2040  // determine string/numeric field
2041  bool bIsString = ( GetIntProperty(gsPropertySubType, xPropSet)
2042  == SetVariableType::STRING );
2043 
2044  // get dependent field property set
2045  Reference<XPropertySet> xFieldPropSet;
2046  if (GetDependentFieldPropertySet(xPropSet, xFieldPropSet))
2047  {
2048  // process value and type.
2050  bIsString,
2051  GetIntProperty(gsPropertyNumberFormat, xFieldPropSet),
2052  "", "", 0.0,
2053  false, true, false, false);
2054  }
2055  else
2056  {
2057  // If no dependent field is found, only string and
2058  // float types can be supported
2059 
2060  // number format: 0 is default number format for 1st
2061  // language. should be: getDefaultNumberFormat(Locale)
2062  // from NumberFormats
2064  bIsString,
2065  0, "", "", 0.0,
2066  false, true, false, false);
2067  }
2068 
2069  ProcessString(XML_NAME, sVarName);
2071  }
2072  }
2073  // else: no declarations element
2074 
2075  // sequence field masters:
2076  if ( !aSeqName.empty() )
2077  {
2078  SvXMLElementExport aElem( GetExport(),
2081  true, true );
2082 
2083  for (const auto& sName : aSeqName)
2084  {
2085  // get field master property set
2086  Reference<XPropertySet> xPropSet;
2087  Any aAny = xFieldMasterNameAccess->getByName(sName);
2088  aAny >>= xPropSet;
2089 
2090  // field name and type
2091  OUString sFieldMasterType;
2092  OUString sVarName;
2093  ExplodeFieldMasterName(sName, sFieldMasterType, sVarName);
2094 
2095  // outline level
2096  sal_Int32 nLevel = 1 + GetIntProperty(
2098  DBG_ASSERT(nLevel >= 0, "illegal outline level");
2099  DBG_ASSERT(nLevel < 127, "possible illegal outline level");
2101 
2102  // separation character
2103  if (nLevel > 0) {
2105  gsPropertyNumberingSeparator, xPropSet));
2106  }
2107  ProcessString(XML_NAME, sVarName);
2109  }
2110  }
2111  // else: no declarations element
2112 
2113  // user field masters:
2114  if ( !aUserName.empty() )
2115  {
2116  SvXMLElementExport aElem( GetExport(),
2119  true, true );
2120 
2121  for (const auto& sName : aUserName)
2122  {
2123  // get field master property set
2124  Reference<XPropertySet> xPropSet;
2125  Any aAny = xFieldMasterNameAccess->getByName(sName);
2126  aAny >>= xPropSet;
2127 
2128  // field name and type
2129  OUString sFieldMasterType;
2130  OUString sVarName;
2131  ExplodeFieldMasterName(sName, sFieldMasterType, sVarName);
2132 
2133  if (GetBoolProperty(gsPropertyIsExpression, xPropSet))
2134  {
2135  // expression:
2137  false,
2138  0, "", "",
2140  true,
2141  true,
2142  false,
2143  false);
2144  }
2145  else
2146  {
2147  // string: write regardless of default
2152  false, XML_NAMESPACE_OFFICE );
2153  }
2154  ProcessString(XML_NAME, sVarName);
2156  }
2157  }
2158  // else: no declarations element
2159 
2160  // DDE field masters:
2161  if ( aDdeName.empty() )
2162  return;
2163 
2164  SvXMLElementExport aElem( GetExport(),
2167  true, true );
2168 
2169  for (const auto& sName : aDdeName)
2170  {
2171  // get field master property set
2172  Reference<XPropertySet> xPropSet;
2173  Any aAny = xFieldMasterNameAccess->getByName(sName);
2174  aAny >>= xPropSet;
2175 
2176  // check if this connection is being used by a field
2177  Reference<XPropertySet> xDummy;
2178  if (GetDependentFieldPropertySet(xPropSet, xDummy))
2179  {
2180 
2182  GetStringProperty(gsPropertyName, xPropSet),
2183  false, XML_NAMESPACE_OFFICE);
2184 
2185  // export elements; can't use ProcessString because
2186  // elements are in office namespace
2189  xPropSet),
2190  false, XML_NAMESPACE_OFFICE);
2193  xPropSet),
2194  false, XML_NAMESPACE_OFFICE);
2197  xPropSet),
2198  false, XML_NAMESPACE_OFFICE);
2199  bool bIsAutomaticUpdate = GetBoolProperty(
2200  gsPropertyIsAutomaticUpdate, xPropSet);
2201  if (bIsAutomaticUpdate)
2202  {
2205  XML_TRUE);
2206  }
2207 
2209  }
2210  // else: no dependent field -> no export of field declaration
2211  }
2212  // else: no declarations element
2213 }
2214 
2216  bool bExportOnlyUsed)
2217 {
2218  pUsedMasters.reset();
2219 
2220  // create used masters set (if none is used)
2221  if (bExportOnlyUsed)
2222  pUsedMasters.reset( new map<Reference<XText>, set<OUString> > );
2223 }
2224 
2225 void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName,
2226  bool bAddSpace)
2227 {
2228  // can't call ExportElement(eElementName, const OUString&) with empty
2229  // string because xmlprinter only uses empty tags if no content
2230  // (not even empty content) was written.
2231 
2232  DBG_ASSERT(XML_TOKEN_INVALID != eElementName, "invalid element name!");
2233  if (XML_TOKEN_INVALID != eElementName)
2234  {
2235  // Element
2237  eElementName, bAddSpace, bAddSpace );
2238  } // else: ignore
2239 }
2240 
2241 void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName,
2242  const OUString& sContent)
2243 {
2244  DBG_ASSERT(eElementName != XML_TOKEN_INVALID, "invalid element name!");
2245  if (eElementName != XML_TOKEN_INVALID)
2246  {
2247  // Element
2249  eElementName, false, false );
2250  // export content
2251  GetExport().Characters(sContent);
2252  } else {
2253  // always export content
2254  GetExport().Characters(sContent);
2255  }
2256 }
2257 
2259  const Reference<XPropertySet> & rPropSet,
2260  const OUString& rContent )
2261 {
2262  // some strings we'll need
2263  OUString sEventType( "EventType" );
2264  OUString sScript( "Script" );
2265  OUString sPropertyScriptURL( "ScriptURL" );
2266 
2267 
2268  // the description attribute
2270  GetStringProperty(gsPropertyHint, rPropSet),
2271  rContent);
2272 
2273  // the element
2275  XML_EXECUTE_MACRO, false, false );
2276 
2277  // the <office:events>-macro:
2278 
2279  // 1) build sequence of PropertyValues
2280  Sequence<PropertyValue> aSeq;
2281  OUString sName;
2282  rPropSet->getPropertyValue( sPropertyScriptURL ) >>= sName;
2283 
2284  // if the ScriptURL property is not empty then this is a Scripting
2285  // Framework URL, otherwise treat it as a Basic Macro
2286  if (!sName.isEmpty())
2287  {
2288  aSeq = Sequence<PropertyValue> (2);
2289  PropertyValue* pArr = aSeq.getArray();
2290  pArr[0].Name = sEventType;
2291  pArr[0].Value <<= sScript;
2292  pArr[1].Name = sScript;
2293  pArr[1].Value = rPropSet->getPropertyValue( sPropertyScriptURL );
2294  }
2295  else
2296  {
2297  aSeq = Sequence<PropertyValue> (3);
2298  PropertyValue* pArr = aSeq.getArray();
2299  pArr[0].Name = sEventType;
2300  pArr[0].Value <<= OUString("StarBasic");
2301  pArr[1].Name = "Library";
2302  pArr[1].Value = rPropSet->getPropertyValue( "MacroLibrary" );
2303  pArr[2].Name = "MacroName";
2304  pArr[2].Value = rPropSet->getPropertyValue( "MacroName" );
2305  }
2306 
2307  // 2) export the sequence
2308  GetExport().GetEventExport().ExportSingleEvent( aSeq, "OnClick", false );
2309 
2310  // and finally, the field presentation
2311  GetExport().Characters(rContent);
2312 }
2313 
2315  const Reference<XPropertySet> & i_xMeta,
2316  bool i_bAutoStyles, bool i_bProgress,
2317  bool & rPrevCharIsSpace)
2318 {
2319  bool doExport(!i_bAutoStyles); // do not export element if autostyles
2320  // check version >= 1.2
2321  switch (GetExport().getSaneDefaultVersion()) {
2322  case SvtSaveOptions::ODFSVER_011: // fall through
2323  case SvtSaveOptions::ODFSVER_010: doExport = false; break;
2324  default: break;
2325  }
2326 
2327  const Reference < XEnumerationAccess > xEA( i_xMeta, UNO_QUERY_THROW );
2328  const Reference < XEnumeration > xTextEnum( xEA->createEnumeration() );
2329 
2330  if (doExport)
2331  {
2332  const Reference<rdf::XMetadatable> xMeta( i_xMeta, UNO_QUERY_THROW );
2333 
2334  // style:data-style-name
2335  ProcessValueAndType(false,
2337  "", "", 0.0, false, false, true,
2338  false );
2339 
2340  // text:meta-field without xml:id is invalid
2341  xMeta->ensureMetadataReference();
2342 
2343  // xml:id for RDF metadata
2344  GetExport().AddAttributeXmlId(xMeta);
2345  }
2346 
2347  SvXMLElementExport aElem( GetExport(), doExport,
2348  XML_NAMESPACE_TEXT, XML_META_FIELD, false, false );
2349 
2350  // recurse to export content
2352  exportTextRangeEnumeration(xTextEnum, i_bAutoStyles, i_bProgress, rPrevCharIsSpace);
2353 }
2354 
2357  bool bIsString,
2358  sal_Int32 nFormatKey,
2359  const OUString& sContent,
2360  const OUString& sDefault,
2361  double fValue,
2362  bool bExportValue,
2363  bool bExportValueType,
2364  bool bExportStyle,
2365  bool bForceSystemLanguage,
2366  bool bTimeStyle) // exporting a time style?
2367 {
2368  // String or number?
2369  if (bIsString)
2370  {
2371 
2372  // string: attributes value-type=string, string-value=...
2373 
2374  if (bExportValue || bExportValueType)
2375  {
2377  GetExport(), sContent, sDefault, bExportValue);
2378  }
2379 
2380  }
2381  else
2382  {
2383 
2384  // number: value-type=..., value...=..., data-style-name=...
2385 
2386  DBG_ASSERT(bExportValueType || !bExportValue, "value w/o value type not supported!");
2387 
2388  // take care of illegal formats
2389  // (shouldn't happen, but does if document is corrupted)
2390  if (-1 != nFormatKey)
2391  {
2392  if (bExportValue || bExportValueType)
2393  {
2396  GetExport(), nFormatKey, fValue, bExportValue);
2397  }
2398 
2399  if (bExportStyle)
2400  {
2401  // don't export language (if desired)
2402  if( bForceSystemLanguage )
2403  nFormatKey =
2404  GetExport().dataStyleForceSystemLanguage( nFormatKey );
2405 
2406  OUString sDataStyleName =
2407  GetExport().getDataStyleName(nFormatKey, bTimeStyle);
2408  if( !sDataStyleName.isEmpty() )
2409  {
2412  sDataStyleName );
2413  } // else: ignore (no valid number format)
2414  } // else: ignore (no number format)
2415  }
2416  }
2417 }
2418 
2419 
2422  bool bIsCommand)
2423 {
2424  enum XMLTokenEnum eValue;
2425 
2426  if (bIsVisible)
2427  {
2428  eValue = bIsCommand ? XML_FORMULA : XML_VALUE;
2429  }
2430  else
2431  {
2432  eValue = XML_NONE;
2433  }
2434 
2435  // omit attribute if default
2436  if (eValue != XML_VALUE)
2437  {
2439  }
2440 }
2441 
2442 
2445  bool bBool, bool bDefault)
2446 {
2447  SAL_WARN_IF( eName == XML_TOKEN_INVALID, "xmloff.text", "invalid element token");
2448  if ( XML_TOKEN_INVALID == eName )
2449  return;
2450 
2451  // write attribute (if different than default)
2452  // negate to force 0/1 values (and make sal_Bool comparable)
2453  if ((!bBool) != (!bDefault)) {
2455  (bBool ? XML_TRUE : XML_FALSE) );
2456  }
2457 }
2458 
2459 
2462  const OUString& sValue,
2463  bool bOmitEmpty,
2464  sal_uInt16 nPrefix)
2465 {
2466  SAL_WARN_IF( eName == XML_TOKEN_INVALID, "xmloff.text", "invalid element token");
2467  if ( XML_TOKEN_INVALID == eName )
2468  return;
2469 
2470  // check for empty string, if applicable
2471  if ( bOmitEmpty && sValue.isEmpty() )
2472  return;
2473 
2474  // write attribute
2475  GetExport().AddAttribute(nPrefix, eName, sValue);
2476 }
2477 
2479  sal_uInt16 nValuePrefix,
2480  const OUString& sValue)
2481 {
2482  OUString sQValue =
2483  GetExport().GetNamespaceMap().GetQNameByKey( nValuePrefix, sValue, false );
2484  ProcessString( eName, sQValue );
2485 }
2486 
2489  const OUString& sValue,
2490  const OUString& sDefault)
2491 {
2492  if (sValue != sDefault)
2493  {
2494  ProcessString(eName, sValue);
2495  }
2496 }
2497 
2500  sal_uInt16 nValuePrefix,
2501  const OUString& sValue,
2502  const OUString& sDefault)
2503 {
2504  if (sValue != sDefault)
2505  {
2506  ProcessString(eName, nValuePrefix, sValue);
2507  }
2508 }
2509 
2510 
2513  enum XMLTokenEnum eName,
2514  enum XMLTokenEnum eValue,
2515  sal_uInt16 nPrefix)
2516 {
2517  SAL_WARN_IF( eName == XML_TOKEN_INVALID, "xmloff.text", "invalid element token" );
2518  SAL_WARN_IF( eValue == XML_TOKEN_INVALID, "xmloff.text", "invalid value token" );
2519  if ( XML_TOKEN_INVALID == eName )
2520  return;
2521 
2522  GetExport().AddAttribute(nPrefix, eName, eValue);
2523 }
2524 
2527  enum XMLTokenEnum eName,
2528  enum XMLTokenEnum eValue,
2529  enum XMLTokenEnum eDefault)
2530 {
2531  if ( eValue != eDefault )
2532  ProcessString( eName, eValue);
2533 }
2534 
2535 
2538  const OUString& sParagraphSequence)
2539 {
2540  // iterate over all string-pieces separated by return (0x0a) and
2541  // put each inside a paragraph element.
2542  SvXMLTokenEnumerator aEnumerator(sParagraphSequence, char(0x0a));
2543  OUString aSubString;
2544  while (aEnumerator.getNextToken(aSubString))
2545  {
2546  SvXMLElementExport aParagraph(
2547  GetExport(), XML_NAMESPACE_TEXT, XML_P, true, false);
2548  GetExport().Characters(aSubString);
2549  }
2550 }
2551 
2552 // export an integer attribute
2554  sal_Int32 nNum)
2555 {
2556  SAL_WARN_IF( eName == XML_TOKEN_INVALID, "xmloff.text", "invalid element token");
2557  if ( XML_TOKEN_INVALID == eName )
2558  return;
2559 
2561  OUString::number(nNum));
2562 }
2563 
2566  sal_Int32 nNum, sal_Int32 nDefault)
2567 {
2568  if (nNum != nDefault)
2569  ProcessInteger(eName, nNum);
2570 }
2571 
2572 
2574 void XMLTextFieldExport::ProcessNumberingType(sal_Int16 nNumberingType)
2575 {
2576  // process only if real format (not: like page descriptor)
2577  if (NumberingType::PAGE_DESCRIPTOR == nNumberingType)
2578  return;
2579 
2580  OUStringBuffer sTmp( 10 );
2581  // number type: num format
2583  nNumberingType );
2585  sTmp.makeStringAndClear() );
2586  // and letter sync, if applicable
2587  SvXMLUnitConverter::convertNumLetterSync( sTmp, nNumberingType );
2588 
2589  if (!sTmp.isEmpty())
2590  {
2592  sTmp.makeStringAndClear() );
2593  }
2594  // else: like page descriptor => ignore
2595 }
2596 
2597 
2600  double dValue,
2601  bool bIsDate,
2602  bool bIsDuration,
2603  bool bOmitDurationIfZero,
2604  sal_uInt16 nPrefix)
2605 {
2606  // truncate for date granularity
2607  if (bIsDate)
2608  {
2609  dValue = ::rtl::math::approxFloor(dValue);
2610  }
2611 
2612  OUStringBuffer aBuffer;
2613  if (bIsDuration)
2614  {
2615  // date/time duration handle bOmitDurationIfZero
2616  if (!bOmitDurationIfZero || dValue != 0.0)
2617  {
2618  ::sax::Converter::convertDuration(aBuffer, dValue);
2619  }
2620  }
2621  else
2622  {
2623  // date/time value
2624  rExport.GetMM100UnitConverter().convertDateTime(aBuffer, dValue);
2625  }
2626 
2627  // output attribute
2628  ProcessString(eName, aBuffer.makeStringAndClear(), true, nPrefix);
2629 }
2630 
2633  const util::DateTime& rTime)
2634 {
2635  OUStringBuffer aBuffer;
2636 
2637  util::DateTime aDateTime(rTime);
2638 
2639  // date/time value
2640  ::sax::Converter::convertDateTime(aBuffer, aDateTime, nullptr);
2641 
2642  // output attribute
2643  ProcessString(eName, aBuffer.makeStringAndClear(), true);
2644 }
2645 
2648  sal_Int32 nMinutes,
2649  bool bIsDate,
2650  bool bIsDuration)
2651 {
2652  // handle bOmitDurationIfZero here, because we can precisely compare ints
2653  if (!(bIsDuration && (nMinutes==0)))
2654  {
2655  ProcessDateTime(eName, static_cast<double>(nMinutes) / double(24*60),
2656  bIsDate, bIsDuration);
2657  }
2658 }
2659 
2662  const util::DateTime& rTime)
2663 {
2664  OUStringBuffer aBuffer;
2665 
2666  // date/time value
2668 
2669  // output attribute
2670  ProcessString(eName, aBuffer.makeStringAndClear(), true);
2671 }
2672 
2673 
2675 {
2676  { XML_ARTICLE, BibliographyDataType::ARTICLE },
2677  { XML_BOOK, BibliographyDataType::BOOK },
2678  { XML_BOOKLET, BibliographyDataType::BOOKLET },
2679  { XML_CONFERENCE, BibliographyDataType::CONFERENCE },
2680  { XML_CUSTOM1, BibliographyDataType::CUSTOM1 },
2681  { XML_CUSTOM2, BibliographyDataType::CUSTOM2 },
2682  { XML_CUSTOM3, BibliographyDataType::CUSTOM3 },
2683  { XML_CUSTOM4, BibliographyDataType::CUSTOM4 },
2684  { XML_CUSTOM5, BibliographyDataType::CUSTOM5 },
2685  { XML_EMAIL, BibliographyDataType::EMAIL },
2686  { XML_INBOOK, BibliographyDataType::INBOOK },
2687  { XML_INCOLLECTION, BibliographyDataType::INCOLLECTION },
2688  { XML_INPROCEEDINGS, BibliographyDataType::INPROCEEDINGS },
2689  { XML_JOURNAL, BibliographyDataType::JOURNAL },
2690  { XML_MANUAL, BibliographyDataType::MANUAL },
2691  { XML_MASTERSTHESIS, BibliographyDataType::MASTERSTHESIS },
2692  { XML_MISC, BibliographyDataType::MISC },
2693  { XML_PHDTHESIS, BibliographyDataType::PHDTHESIS },
2694  { XML_PROCEEDINGS, BibliographyDataType::PROCEEDINGS },
2695  { XML_TECHREPORT, BibliographyDataType::TECHREPORT },
2696  { XML_UNPUBLISHED, BibliographyDataType::UNPUBLISHED },
2697  { XML_WWW, BibliographyDataType::WWW },
2698  { XML_TOKEN_INVALID, 0 }
2699 };
2700 
2701 
2703  const Reference<XPropertySet>& rPropSet)
2704 {
2705  // get the values
2706  Any aAny = rPropSet->getPropertyValue(gsPropertyFields);
2707  Sequence<PropertyValue> aValues;
2708  aAny >>= aValues;
2709 
2710  // one attribute per value (unless empty)
2711  for (const auto& rProp : std::as_const(aValues))
2712  {
2713  if( rProp.Name == "BibiliographicType" )
2714  {
2715  sal_Int16 nTypeId = 0;
2716  rProp.Value >>= nTypeId;
2717  OUStringBuffer sBuf;
2718 
2719  if (SvXMLUnitConverter::convertEnum(sBuf, nTypeId,
2720  aBibliographyDataTypeMap))
2721  {
2724  sBuf.makeStringAndClear());
2725  }
2726  // else: ignore this argument
2727  }
2728  else
2729  {
2730  OUString sStr;
2731  rProp.Value >>= sStr;
2732 
2733  if (!sStr.isEmpty())
2734  {
2736  MapBibliographyFieldName(rProp.Name),
2737  sStr);
2738  }
2739  }
2740  }
2741 }
2742 
2745  sal_Int32 nCommandType)
2746 {
2748  switch( nCommandType )
2749  {
2750  case sdb::CommandType::TABLE: eToken = XML_TABLE; break;
2751  case sdb::CommandType::QUERY: eToken = XML_QUERY; break;
2752  case sdb::CommandType::COMMAND: eToken = XML_COMMAND; break;
2753  }
2754 
2755  if( eToken != XML_TOKEN_INVALID )
2757 }
2758 
2759 
2761  const Sequence<OUString>& rSequence,
2762  const OUString& sSelected )
2763 {
2764  // find selected element
2765  sal_Int32 nSelected = comphelper::findValue(rSequence, sSelected);
2766 
2767  // delegate to ProcessStringSequence(OUString,sal_Int32)
2768  ProcessStringSequence( rSequence, nSelected );
2769 }
2770 
2772  const Sequence<OUString>& rSequence,
2773  sal_Int32 nSelected )
2774 {
2775  sal_Int32 nLength = rSequence.getLength();
2776  const OUString* pSequence = rSequence.getConstArray();
2777  for( sal_Int32 i = 0; i < nLength; i++ )
2778  {
2779  if( i == nSelected )
2784  false, false );
2785  }
2786 }
2787 
2789  enum XMLTokenEnum eElementName,
2790  const OUString& sPresentation,
2791  const Reference<XPropertySet>& rPropertySet,
2792  const Reference<XPropertySetInfo>& rPropertySetInfo )
2793 {
2794  SAL_WARN_IF( eElementName == XML_TOKEN_INVALID, "xmloff.text", "need token" );
2795  SAL_WARN_IF( !rPropertySet.is(), "xmloff.text", "need property set" );
2796  SAL_WARN_IF( !rPropertySetInfo.is(), "xmloff.text", "need property set info" );
2797 
2798  // get database properties
2799  OUString sDataBaseName;
2800  OUString sDataBaseURL;
2801  OUString sStr;
2802  if( ( rPropertySet->getPropertyValue( gsPropertyDataBaseName ) >>= sStr )
2803  && !sStr.isEmpty() )
2804  {
2805  sDataBaseName = sStr;
2806  }
2807  else if( rPropertySetInfo->hasPropertyByName( gsPropertyDataBaseURL ) &&
2808  (rPropertySet->getPropertyValue( gsPropertyDataBaseURL ) >>= sStr) &&
2809  !sStr.isEmpty() )
2810  {
2811  sDataBaseURL = sStr;
2812  }
2813 
2814  // add database name property (if present)
2815  if( !sDataBaseName.isEmpty() )
2817  sDataBaseName );
2818  SvXMLElementExport aDataBaseElement( GetExport(),
2819  XML_NAMESPACE_TEXT, eElementName,
2820  false, false );
2821 
2822  // write URL as children
2823  if( !sDataBaseURL.isEmpty() )
2824  {
2826  SvXMLElementExport aDataSourceElement(
2828  false, false );
2829  }
2830 
2831  // write presentation
2832  rExport.Characters( sPresentation );
2833 }
2834 
2835 
2836 // explode a field master name into field type and field name
2838  const OUString& sMasterName, OUString& sFieldType, OUString& sVarName)
2839 {
2840  sal_Int32 nLength = gsFieldMasterPrefix.getLength();
2841  sal_Int32 nSeparator = sMasterName.indexOf('.', nLength);
2842 
2843  // '.' found?
2844  if (nSeparator <= nLength) {
2845  SAL_WARN("xmloff.text", "no field var name!");
2846  }
2847  else
2848  {
2849  sFieldType = sMasterName.copy(nLength, nSeparator-nLength);
2850  sVarName = sMasterName.copy(nSeparator+1);
2851  }
2852 }
2853 
2854 
2855 // for XDependentTextFields, get PropertySet of FieldMaster
2857  const Reference<XTextField> & rTextField)
2858 {
2859  // name, value => get Property set of TextFieldMaster
2860  Reference<XDependentTextField> xDep(rTextField, UNO_QUERY);
2861  return xDep->getTextFieldMaster();
2862 }
2863 
2864 // get PropertySet of (any; the first) dependent field
2866  const Reference<XPropertySet> & xMaster,
2867  Reference<XPropertySet> & xField)
2868 {
2869  Any aAny;
2870  Sequence<Reference<XDependentTextField> > aFields;
2871  aAny = xMaster->getPropertyValue(gsPropertyDependentTextFields);
2872  aAny >>= aFields;
2873 
2874  // any fields?
2875  if (aFields.hasElements())
2876  {
2877  // get first one and return
2878  Reference<XDependentTextField> xTField = aFields[0];
2879  xField.set(xTField, UNO_QUERY);
2880  DBG_ASSERT(xField.is(),
2881  "Surprisingly, this TextField refuses to be a PropertySet!");
2882  return true;
2883  }
2884  else
2885  {
2886  return false;
2887  }
2888 }
2889 
2890 
2893 {
2894  enum XMLTokenEnum eType = XML_TEXT;
2895 
2896  switch (nType)
2897  {
2898  case PlaceholderType::TEXT:
2899  eType = XML_TEXT;
2900  break;
2901 
2902  case PlaceholderType::TABLE:
2903  eType = XML_TABLE;
2904  break;
2905 
2906  case PlaceholderType::TEXTFRAME:
2907  eType = XML_TEXT_BOX;
2908  break;
2909 
2910  case PlaceholderType::GRAPHIC:
2911  eType = XML_IMAGE;
2912  break;
2913 
2914  case PlaceholderType::OBJECT:
2915  eType = XML_OBJECT;
2916  break;
2917 
2918  default:
2919  // unknown placeholder: XML_TEXT
2920  OSL_FAIL("unknown placeholder type");
2921  }
2922 
2923  return eType;
2924 }
2925 
2926 
2929  const Reference<XPropertySet> & xPropSet)
2930 {
2931  // Initials or full name?
2932  return GetBoolProperty(gsPropertyFullName, xPropSet)
2934 }
2935 
2937  const Reference<XPropertySet> & xPropSet,
2938  sal_Int32& nOffset)
2939 {
2940  enum XMLTokenEnum eName = XML_TOKEN_INVALID;
2941  PageNumberType ePage;
2942  Any aAny = xPropSet->getPropertyValue(gsPropertySubType);
2943  ePage = *o3tl::doAccess<PageNumberType>(aAny);
2944 
2945  switch (ePage)
2946  {
2947  case PageNumberType_PREV:
2948  eName = XML_PREVIOUS;
2949  nOffset += 1;
2950  break;
2951  case PageNumberType_CURRENT:
2952  eName = XML_CURRENT;
2953  break;
2954  case PageNumberType_NEXT:
2955  eName = XML_NEXT;
2956  nOffset -= 1;
2957  break;
2958  default:
2959  OSL_FAIL("unknown page number type");
2960  eName = XML_TOKEN_INVALID;
2961  break;
2962  }
2963 
2964  return eName;
2965 }
2966 
2969 {
2970  enum XMLTokenEnum eName = XML_TOKEN_INVALID;
2971 
2972  switch (nFormat)
2973  {
2974  case TemplateDisplayFormat::FULL:
2975  eName = XML_FULL;
2976  break;
2977  case TemplateDisplayFormat::PATH:
2978  eName = XML_PATH;
2979  break;
2980  case TemplateDisplayFormat::NAME:
2981  eName = XML_NAME;
2982  break;
2983  case TemplateDisplayFormat::NAME_AND_EXT:
2984  eName = XML_NAME_AND_EXTENSION;
2985  break;
2986  case TemplateDisplayFormat::AREA:
2987  eName = XML_AREA;
2988  break;
2989  case TemplateDisplayFormat::TITLE:
2990  eName = XML_TITLE;
2991  break;
2992  default:
2993  OSL_FAIL("unknown template display format");
2994  eName = XML_TOKEN_INVALID;
2995  break;
2996  }
2997 
2998  return eName;
2999 }
3000 
3003 {
3004  enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
3005 
3006  switch (nToken)
3007  {
3008  case FIELD_ID_COUNT_PAGES:
3009  eElement = XML_PAGE_COUNT;
3010  break;
3012  eElement = XML_PARAGRAPH_COUNT;
3013  break;
3014  case FIELD_ID_COUNT_WORDS:
3015  eElement = XML_WORD_COUNT;
3016  break;
3018  eElement = XML_CHARACTER_COUNT;
3019  break;
3020  case FIELD_ID_COUNT_TABLES:
3021  eElement = XML_TABLE_COUNT;
3022  break;
3024  eElement = XML_IMAGE_COUNT;
3025  break;
3027  eElement = XML_OBJECT_COUNT;
3028  break;
3029  default:
3030  OSL_FAIL("no count field token");
3031  eElement = XML_TOKEN_INVALID;
3032  break;
3033  }
3034 
3035  return eElement;
3036 }
3037 
3040 {
3041  enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3042 
3043  switch (nFormat)
3044  {
3045  case ChapterFormat::NAME:
3046  eName = XML_NAME;
3047  break;
3048  case ChapterFormat::NUMBER:
3049  eName = XML_NUMBER;
3050  break;
3051  case ChapterFormat::NAME_NUMBER:
3052  eName = XML_NUMBER_AND_NAME;
3053  break;
3054  case ChapterFormat::NO_PREFIX_SUFFIX:
3055  eName = XML_PLAIN_NUMBER_AND_NAME;
3056  break;
3057  case ChapterFormat::DIGIT:
3058  eName = XML_PLAIN_NUMBER;
3059  break;
3060  default:
3061  OSL_FAIL("unknown chapter display format");
3062  eName = XML_TOKEN_INVALID;
3063  break;
3064  }
3065 
3066  return eName;
3067 }
3068 
3069 
3072 {
3073  enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3074 
3075  switch (nFormat)
3076  {
3077  case FilenameDisplayFormat::FULL:
3078  eName = XML_FULL;
3079  break;
3080  case FilenameDisplayFormat::PATH:
3081  eName = XML_PATH;
3082  break;
3083  case FilenameDisplayFormat::NAME:
3084  eName = XML_NAME;
3085  break;
3086  case FilenameDisplayFormat::NAME_AND_EXT:
3087  eName = XML_NAME_AND_EXTENSION;
3088  break;
3089  default:
3090  OSL_FAIL("unknown filename display format");
3091  }
3092 
3093  return eName;
3094 }
3095 
3096 
3099 {
3100  enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
3101 
3102  switch (nType)
3103  {
3104  case ReferenceFieldPart::PAGE:
3105  eElement = XML_PAGE;
3106  break;
3107  case ReferenceFieldPart::CHAPTER:
3108  eElement = XML_CHAPTER;
3109  break;
3110  case ReferenceFieldPart::TEXT:
3111  eElement = XML_TEXT;
3112  break;
3113  case ReferenceFieldPart::UP_DOWN:
3114  eElement = XML_DIRECTION;
3115  break;
3116  case ReferenceFieldPart::CATEGORY_AND_NUMBER:
3117  eElement = XML_CATEGORY_AND_VALUE;
3118  break;
3119  case ReferenceFieldPart::ONLY_CAPTION:
3120  eElement = XML_CAPTION;
3121  break;
3122  case ReferenceFieldPart::ONLY_SEQUENCE_NUMBER:
3123  eElement = XML_VALUE;
3124  break;
3125  case ReferenceFieldPart::PAGE_DESC:
3126  // small hack: this value never gets written, because
3127  // XML_TEMPLATE is default
3128  eElement = XML_TEMPLATE;
3129  break;
3130  // Core implementation for direct cross-references (#i81002#)
3131  case ReferenceFieldPart::NUMBER:
3132  eElement = XML_NUMBER;
3133  break;
3134  case ReferenceFieldPart::NUMBER_NO_CONTEXT:
3135  eElement = XML_NUMBER_NO_SUPERIOR;
3136  break;
3137  case ReferenceFieldPart::NUMBER_FULL_CONTEXT:
3138  eElement = XML_NUMBER_ALL_SUPERIOR;
3139  break;
3140  default:
3141  OSL_FAIL("unknown reference type");
3142  eElement = XML_TEMPLATE;
3143  break;
3144  }
3145 
3146  return eElement;
3147 }
3148 
3151 {
3152  enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
3153 
3154  switch (nType)
3155  {
3156  case ReferenceFieldSource::REFERENCE_MARK:
3157  eElement = XML_REFERENCE_REF;
3158  break;
3159  case ReferenceFieldSource::SEQUENCE_FIELD:
3160  eElement = XML_SEQUENCE_REF;
3161  break;
3162  case ReferenceFieldSource::BOOKMARK:
3163  eElement = XML_BOOKMARK_REF;
3164  break;
3165  case ReferenceFieldSource::FOOTNOTE:
3166  case ReferenceFieldSource::ENDNOTE:
3167  eElement = XML_NOTE_REF;
3168  break;
3169  default:
3170  OSL_FAIL("unknown reference source");
3171  break;
3172  }
3173 
3174  return eElement;
3175 }
3176 
3177 
3180  const Reference<XPropertySet> & xPropSet)
3181 {
3182  enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3183 
3184  // sub-field type
3185  switch (GetInt16Property(gsPropertyFieldSubType, xPropSet))
3186  {
3187  case UserDataPart::COMPANY :
3188  eName = XML_SENDER_COMPANY;
3189  break;
3190  case UserDataPart::FIRSTNAME :
3191  eName = XML_SENDER_FIRSTNAME;
3192  break;
3193  case UserDataPart::NAME :
3194  eName = XML_SENDER_LASTNAME;
3195  break;
3196  case UserDataPart::SHORTCUT :
3197  eName = XML_SENDER_INITIALS;
3198  break;
3199  case UserDataPart::STREET :
3200  eName = XML_SENDER_STREET;
3201  break;
3202  case UserDataPart::COUNTRY :
3203  eName = XML_SENDER_COUNTRY;
3204  break;
3205  case UserDataPart::ZIP :
3206  eName = XML_SENDER_POSTAL_CODE;
3207  break;
3208  case UserDataPart::CITY :
3209  eName = XML_SENDER_CITY;
3210  break;
3211  case UserDataPart::TITLE :
3212  eName = XML_SENDER_TITLE;
3213  break;
3214  case UserDataPart::POSITION :
3215  eName = XML_SENDER_POSITION;
3216  break;
3217  case UserDataPart::PHONE_PRIVATE :
3218  eName = XML_SENDER_PHONE_PRIVATE;
3219  break;
3220  case UserDataPart::PHONE_COMPANY :
3221  eName = XML_SENDER_PHONE_WORK;
3222  break;
3223  case UserDataPart::FAX :
3224  eName = XML_SENDER_FAX;
3225  break;
3226  case UserDataPart::EMAIL :
3227  eName = XML_SENDER_EMAIL;
3228  break;
3229  case UserDataPart::STATE :
3231  break;
3232  default:
3233  SAL_WARN("xmloff.text", "unknown sender type");
3234  eName = XML_TOKEN_INVALID;
3235  break;
3236  }
3237 
3238  return eName;
3239 }
3240 
3242  enum FieldIdEnum nToken)
3243 {
3244  enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
3245 
3246  switch (nToken)
3247  {
3249  eElement = XML_INITIAL_CREATOR;
3250  break;
3252  eElement = XML_CREATION_DATE;
3253  break;
3255  eElement = XML_CREATION_TIME;
3256  break;
3258  eElement = XML_DESCRIPTION;
3259  break;
3261  eElement = XML_PRINT_TIME;
3262  break;
3264  eElement = XML_PRINT_DATE;
3265  break;
3267  eElement = XML_PRINTED_BY;
3268  break;
3270  eElement = XML_TITLE;
3271  break;
3273  eElement = XML_SUBJECT;
3274  break;
3276  eElement = XML_KEYWORDS;
3277  break;
3279  eElement = XML_EDITING_CYCLES;
3280  break;
3282  eElement = XML_EDITING_DURATION;
3283  break;
3285  eElement = XML_MODIFICATION_TIME;
3286  break;
3288  eElement = XML_MODIFICATION_DATE;
3289  break;
3291  eElement = XML_CREATOR;
3292  break;
3293  default:
3294  SAL_WARN("xmloff.text", "unknown docinfo field type!");
3295  eElement = XML_TOKEN_INVALID;
3296  break;
3297  }
3298 
3299  return eElement;
3300 }
3301 
3303 {
3304  enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3305 
3306  if( sName == "Identifier" )
3307  {
3308  eName = XML_IDENTIFIER;
3309  }
3310  else if( sName == "BibiliographicType" )
3311  {
3312  eName = XML_BIBLIOGRAPHY_TYPE;
3313  }
3314  else if( sName == "Address" )
3315  {
3316  eName = XML_ADDRESS;
3317  }
3318  else if( sName == "Annote" )
3319  {
3320  eName = XML_ANNOTE;
3321  }
3322  else if( sName == "Author" )
3323  {
3324  eName = XML_AUTHOR;
3325  }
3326  else if( sName == "Booktitle" )
3327  {
3328  eName = XML_BOOKTITLE;
3329  }
3330  else if( sName == "Chapter" )
3331  {
3332  eName = XML_CHAPTER;
3333  }
3334  else if( sName == "Edition" )
3335  {
3336  eName = XML_EDITION;
3337  }
3338  else if( sName == "Editor" )
3339  {
3340  eName = XML_EDITOR;
3341  }
3342  else if( sName == "Howpublished" )
3343  {
3344  eName = XML_HOWPUBLISHED;
3345  }
3346  else if( sName == "Institution" )
3347  {
3348  eName = XML_INSTITUTION;
3349  }
3350  else if( sName == "Journal" )
3351  {
3352  eName = XML_JOURNAL;
3353  }
3354  else if( sName =="Month" )
3355  {
3356  eName = XML_MONTH;
3357  }
3358  else if( sName == "Note" )
3359  {
3360  eName = XML_NOTE;
3361  }
3362  else if( sName == "Number" )
3363  {
3364  eName = XML_NUMBER;
3365  }
3366  else if( sName == "Organizations" )
3367  {
3368  eName = XML_ORGANIZATIONS;
3369  }
3370  else if( sName == "Pages" )
3371  {
3372  eName = XML_PAGES;
3373  }
3374  else if( sName == "Publisher" )
3375  {
3376  eName = XML_PUBLISHER;
3377  }
3378  else if( sName == "School" )
3379  {
3380  eName = XML_SCHOOL;
3381  }
3382  else if( sName == "Series" )
3383  {
3384  eName = XML_SERIES;
3385  }
3386  else if( sName == "Title" )
3387  {
3388  eName = XML_TITLE;
3389  }
3390  else if( sName == "Report_Type" )
3391  {
3392  eName = XML_REPORT_TYPE;
3393  }
3394  else if( sName == "Volume" )
3395  {
3396  eName = XML_VOLUME;
3397  }
3398  else if( sName == "Year" )
3399  {
3400  eName = XML_YEAR;
3401  }
3402  else if( sName == "URL" )
3403  {
3404  eName = XML_URL;
3405  }
3406  else if( sName == "Custom1" )
3407  {
3408  eName = XML_CUSTOM1;
3409  }
3410  else if( sName == "Custom2" )
3411  {
3412  eName = XML_CUSTOM2;
3413  }
3414  else if( sName == "Custom3" )
3415  {
3416  eName = XML_CUSTOM3;
3417  }
3418  else if( sName == "Custom4" )
3419  {
3420  eName = XML_CUSTOM4;
3421  }
3422  else if( sName == "Custom5" )
3423  {
3424  eName = XML_CUSTOM5;
3425  }
3426  else if( sName == "ISBN" )
3427  {
3428  eName = XML_ISBN;
3429  }
3430  else
3431  {
3432  OSL_FAIL("Unknown bibliography info data");
3433  eName = XML_TOKEN_INVALID;
3434  }
3435 
3436  return eName;
3437 }
3438 
3440 {
3441  switch( nKind )
3442  {
3443  case 0:
3444  return XML_VALUE;
3445  case 1:
3446  return XML_UNIT;
3447  }
3448  return XML_GAP;
3449 }
3450 
3452  sal_Int16 nSeqNo)
3453 {
3454  // generate foot-/endnote ID
3455  return "ftn" + OUString::number(static_cast<sal_Int32>(nSeqNo));
3456 }
3457 
3459  sal_Int16 nSeqNo,
3460  const OUString& rSeqName)
3461 {
3462  // generate foot-/endnote ID
3463  return "ref" +rSeqName + OUString::number(static_cast<sal_Int32>(nSeqNo));
3464 }
3465 
3466 
3467 // Property accessor helper functions
3468 
3469 
3470 // to be relegated (does that word exist?) to a more appropriate place
3471 
3472 
3474  const OUString& sPropName,
3475  const Reference<XPropertySet> & xPropSet)
3476 {
3477  Any aAny = xPropSet->getPropertyValue(sPropName);
3478  bool bBool = *o3tl::doAccess<bool>(aAny);
3479  return bBool;
3480 }
3481 
3483  const OUString& sPropName,
3484  const Reference<XPropertySet> & xPropSet,
3485  const Reference<XPropertySetInfo> & xPropSetInfo,
3486  bool bDefault)
3487 {
3488  return xPropSetInfo->hasPropertyByName( sPropName )
3489  ? GetBoolProperty( sPropName, xPropSet ) : bDefault;
3490 }
3491 
3493  const OUString& sPropName,
3494  const Reference<XPropertySet> & xPropSet)
3495 {
3496  Any aAny = xPropSet->getPropertyValue(sPropName);
3497  double fDouble = 0.0;
3498  aAny >>= fDouble;
3499  return fDouble;
3500 }
3501 
3503  const OUString& sPropName,
3504  const Reference<XPropertySet> & xPropSet)
3505 {
3506  Any aAny = xPropSet->getPropertyValue(sPropName);
3507  OUString sString;
3508  aAny >>= sString;
3509  return sString;
3510 }
3511 
3512 sal_Int32 GetIntProperty(
3513  const OUString& sPropName,
3514  const Reference<XPropertySet> & xPropSet)
3515 {
3516  Any aAny = xPropSet->getPropertyValue(sPropName);
3517  sal_Int32 nInt = 0;
3518  aAny >>= nInt;
3519  return nInt;
3520 }
3521 
3523  const OUString& sPropName,
3524  const Reference<XPropertySet> & xPropSet)
3525 {
3526  Any aAny = xPropSet->getPropertyValue(sPropName);
3527  sal_Int16 nInt = 0;
3528  aAny >>= nInt;
3529  return nInt;
3530 }
3531 
3533  const OUString& sPropName,
3534  const Reference<XPropertySet> & xPropSet)
3535 {
3536  Any aAny = xPropSet->getPropertyValue(sPropName);
3537  sal_Int8 nInt = 0;
3538  aAny >>= nInt;
3539  return nInt;
3540 }
3541 
3542 util::DateTime GetDateTimeProperty(
3543  const OUString& sPropName,
3544  const Reference<XPropertySet> & xPropSet)
3545 {
3546  Any aAny = xPropSet->getPropertyValue(sPropName);
3547  util::DateTime aTime;
3548  aAny >>= aTime;
3549  return aTime;
3550 }
3551 
3553  const OUString& sPropName,
3554  const Reference<XPropertySet> & xPropSet)
3555 {
3556  Any aAny = xPropSet->getPropertyValue(sPropName);
3557  Sequence<OUString> aSequence;
3558  aAny >>= aSequence;
3559  return aSequence;
3560 }
3561 
3562 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const OUStringLiteral gsPropertySequenceNumber("SequenceNumber")
char const FIELD_SERVICE_HIDDEN_TEXT[]
Definition: txtflde.cxx:101
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
Definition: xmlnmspe.hxx:80
SvXMLExport & rExport
Definition: txtflde.hxx:152
const OUStringLiteral gsPropertyTrueContent("TrueContent")
static OUString MakeSequenceRefName(sal_Int16 nSeqNo, const OUString &rSeqName)
make reference name for a sequence field
Definition: txtflde.cxx:3458
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
constexpr sal_uInt16 XML_NAMESPACE_STYLE
Definition: xmlnmspe.hxx:30
void ProcessStringSequence(const css::uno::Sequence< OUString > &rSequence, const OUString &sSelected)
css::sdb::CommandType
const OUStringLiteral gsPropertyItems("Items")
const OUStringLiteral gsPropertyReferenceFieldPart("ReferenceFieldPart")
static enum::xmloff::token::XMLTokenEnum MapFilenameDisplayFormat(sal_Int16 nType)
map FilenameDisplayFormat to XML attribute names
Definition: txtflde.cxx:3071
static bool convertEnum(EnumT &rEnum, const OUString &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:128
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
const OUStringLiteral gsPropertyDateTime("DateTime")
const char sScript[]
static bool convertBool(bool &rBool, const OUString &rString)
static bool GetBoolProperty(const OUString &, const Reference< XPropertySet > &)
Definition: txtflde.cxx:3473
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:2314
char const FIELD_SERVICE_DB_NEXT[]
Definition: txtflde.cxx:95
char const FIELD_SERVICE_DOC_INFO_EDIT_TIME2[]
Definition: txtflde.cxx:108
bool convertNumFormat(sal_Int16 &rType, const OUString &rNumFormat, const OUString &rNumLetterSync, bool bNumberNone=false) const
convert num-format and num-letter-sync values to NumberingType
Definition: xmluconv.cxx:574
const OUStringLiteral gsPropertyTooltip("Tooltip")
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
signed char sal_Int8
char const FIELD_SERVICE_DROP_DOWN[]
Definition: txtflde.cxx:154
const OUStringLiteral gsPropertyIsExpression("IsExpression")
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:3552
rtl::Reference< XMLTextParagraphExport > const & GetTextParagraphExport()
Definition: xmlexp.hxx:560
char const FIELD_SERVICE_DOC_INFO_KEY_WORDS2[]
Definition: txtflde.cxx:122
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlexp.hxx:394
char const FIELD_SERVICE_DATETIME[]
Definition: txtflde.cxx:93
void ProcessInteger(enum::xmloff::token::XMLTokenEnum eXmlName, sal_Int32 nNum)
attribute default; omit, if attribute differs
Definition: txtflde.cxx:2553
const OUStringLiteral gsPropertyDataBaseURL("DataBaseURL")
static enum::xmloff::token::XMLTokenEnum MapCountFieldName(FieldIdEnum nToken)
map count/statistics field token to XML name
Definition: txtflde.cxx:3002
static enum FieldIdEnum MapFieldName(const OUString &sFieldName, const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
get field ID from XTextField service name (and it's PropertySet)
Definition: txtflde.cxx:437
const OUStringLiteral gsFieldMasterPrefix("com.sun.star.text.FieldMaster.")
const OUStringLiteral gsPropertyVariableName("VariableName")
void ProcessValueAndType(bool bIsString, sal_Int32 nFormatKey, const OUString &sContent, const OUString &sDefault, double fValue, bool bExportValue, bool bExportValueType, bool bExportStyle, bool bForceSystemLanguage, bool bTimeStyle=false)
is show command/show name?
Definition: txtflde.cxx:2356
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:3098
const OUStringLiteral gsPropertySourceName("SourceName")
void ExportFieldDeclarations()
export field declarations.
Definition: txtflde.cxx:1915
const OUStringLiteral gsPropertyChapterFormat("ChapterFormat")
static double GetDoubleProperty(const OUString &, const Reference< XPropertySet > &)
Definition: txtflde.cxx:3492
const OUStringLiteral gsPropertyAdjust("Adjust")
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:158
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 ProcessDisplay(bool bIsVisible, bool bIsCommand)
numbering type key
Definition: txtflde.cxx:2421
constexpr sal_uInt16 XML_NAMESPACE_TEXT
Definition: xmlnmspe.hxx:31
const OUStringLiteral gsPropertySubType("SubType")
const OUStringLiteral gsPropertyFalseContent("FalseContent")
SvXMLExport & GetExport()
Definition: txtflde.hxx:213
constexpr sal_uInt16 XML_NAMESPACE_DC
Definition: xmlnmspe.hxx:36
bool getNextToken(OUString &rToken)
Definition: xmluconv.cxx:449
SvXMLEnumMapEntry< sal_Int16 > const aBibliographyDataTypeMap[]
Definition: txtflde.cxx:2674
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
const OUStringLiteral gsPropertyNumberingSeparator("NumberingSeparator")
char const FIELD_SERVICE_TEMPLATE_NAME[]
Definition: txtflde.cxx:131
char const FIELD_SERVICE_HIDDEN_PARAGRAPH[]
Definition: txtflde.cxx:102
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
const OUStringLiteral gsPropertyIsConditionTrue("IsConditionTrue")
static enum::xmloff::token::XMLTokenEnum MapChapterDisplayFormat(sal_Int16 nType)
map ChapterDisplayFormat to XML string
Definition: txtflde.cxx:3039
const OUStringLiteral gsPropertyIsInput("Input")
static sal_Int16 GetInt16Property(const OUString &, const Reference< XPropertySet > &)
Definition: txtflde.cxx:3522
const OUStringLiteral gsPropertyDataCommandType("DataCommandType")
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
const OUStringLiteral gsPropertyDDECommandType("DDECommandType")
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
const OUStringLiteral gsPropertyIsDate("IsDate")
const OUStringLiteral gsPropertyDependentTextFields("DependentTextFields")
const OUStringLiteral gsPropertyDataTableName("DataTableName")
const OUStringLiteral gsPropertyIsHidden("IsHidden")
void AddAttribute(sal_uInt16 nPrefix, const char *pName, const OUString &rValue)
Definition: xmlexp.cxx:909
SvXMLEnumStringMapEntry< FieldIdEnum > const aFieldServiceNameMapping[]
Definition: txtflde.cxx:181
const OUStringLiteral gsPropertySequenceValue("SequenceValue")
void ProcessString(enum::xmloff::token::XMLTokenEnum eXmlName, const OUString &sValue, bool bOmitEmpty=false, sal_uInt16 nPrefix=XML_NAMESPACE_TEXT)
default value
const OUStringLiteral gsPropertyInstanceName("InstanceName")
const OUStringLiteral gsPropertyFileFormat("FileFormat")
char const FIELD_SERVICE_COMBINED_CHARACTERS[]
Definition: txtflde.cxx:150
const OUStringLiteral gsPropertyNumberingType("NumberingType")
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:3482
char const FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR[]
Definition: txtflde.cxx:111
const OUStringLiteral gsPropertyOn("On")
char const FIELD_SERVICE_TABLE_COUNT[]
Definition: txtflde.cxx:136
virtual OUString getDataStyleName(const sal_Int32 nNumberFormat, bool bTimeFormat=false) const
Definition: xmlexp.cxx:1840
const char * sName
void ProcessTimeOrDateTime(enum::xmloff::token::XMLTokenEnum eXMLName, const css::util::DateTime &rTime)
date/time value
Definition: txtflde.cxx:2661
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:49
const OUStringLiteral gsPropertyDDECommandFile("DDECommandFile")
DocumentType eType
const OUStringLiteral gsServicePrefix("com.sun.star.text.textfield.")
const OUStringLiteral gsPropertyPlaceholderType("PlaceHolderType")
SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const
returns the deterministic version for odf export
Definition: xmlexp.cxx:2297
const OUStringLiteral gsPropertyURL("URL")
char const FIELD_SERVICE_CHARACTER_COUNT[]
Definition: txtflde.cxx:135
static util::DateTime GetDateTimeProperty(const OUString &sPropName, const Reference< XPropertySet > &xPropSet)
Definition: txtflde.cxx:3542
static enum::xmloff::token::XMLTokenEnum MapMeasureKind(sal_Int16 nKind)
Definition: txtflde.cxx:3439
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 ProcessBoolean(enum::xmloff::token::XMLTokenEnum eXmlName, bool bBool, bool bDefault)
export a boolean attribute
Definition: txtflde.cxx:2444
const OUStringLiteral gsPropertyLevel("Level")
const OUStringLiteral gsPresentationServicePrefix("com.sun.star.presentation.TextField.")
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:2788
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
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION
Definition: xmlnmspe.hxx:39
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:2009
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
const OUStringLiteral gsPropertyHelp("Help")
const OUStringLiteral gsPropertyOffset("Offset")
const OUStringLiteral gsPropertySelectedItem("SelectedItem")
static enum::xmloff::token::XMLTokenEnum MapReferenceSource(sal_Int16 nType)
map ReferenceFieldPart to XML string
Definition: txtflde.cxx:3150
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:317
char const FIELD_SERVICE_DOC_INFO_CUSTOM[]
Definition: txtflde.cxx:115
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:3451
static void SetNumberFormatAttributes(SvXMLExport &rXMLExport, const sal_Int32 nNumberFormat, const double &rValue, bool bExportValue=true)
Definition: numehelp.cxx:275
const OUStringLiteral gsPropertyScriptType("ScriptType")
const OUStringLiteral gsPropertySetNumber("SetNumber")
const OUStringLiteral gsPropertyTargetFrame("TargetFrame")
const OUStringLiteral gsPropertyDataColumnName("DataColumnName")
static void ExplodeFieldMasterName(const OUString &sMasterName, OUString &sFieldType, OUString &sVarName)
explode a field master name into field type and field name
Definition: txtflde.cxx:2837
const char sEventType[]
void ProcessCommandType(sal_Int32 nCommandType)
export CommandTypeAttribute
Definition: txtflde.cxx:2744
const OUStringLiteral gsPropertyIsAutomaticUpdate("IsAutomaticUpdate")
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
char const FIELD_SERVICE_FILE_NAME[]
Definition: txtflde.cxx:129
const OUStringLiteral gsPropertyIsVisible("IsVisible")
const OUStringLiteral gsPropertyIsDataBaseFormat("DataBaseFormat")
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
Definition: nmspmap.cxx:187
char const FIELD_SERVICE_DB_NUMBER[]
Definition: txtflde.cxx:97
const OUStringLiteral gsPropertyValue("Value")
void ProcessParagraphSequence(const OUString &sParagraphSequence)
default value token
Definition: txtflde.cxx:2537
constexpr sal_uInt16 XML_NAMESPACE_FORM
Definition: xmlnmspe.hxx:44
const OUStringLiteral gsPropertyChapterNumberingLevel("ChapterNumberingLevel")
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:3179
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:2215
const SvXMLNamespaceMap & GetNamespaceMap() const
Definition: xmlexp.hxx:391
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:2856
const OUStringLiteral gsPropertyUserText("UserText")
const OUStringLiteral gsPropertyReferenceFieldLanguage("ReferenceFieldLanguage")
const OUStringLiteral gsPropertyReferenceFieldSource("ReferenceFieldSource")
static OUString GetStringProperty(const OUString &, const Reference< XPropertySet > &)
Definition: txtflde.cxx:3502
const OUStringLiteral gsPropertyAuthor("Author")
char const FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR2[]
Definition: txtflde.cxx:112
const OUStringLiteral gsPropertyFields("Fields")
constexpr sal_uInt16 XML_NAMESPACE_OOOW
Definition: xmlnmspe.hxx:63
static enum::xmloff::token::XMLTokenEnum MapBibliographyFieldName(const OUString &sName)
Definition: txtflde.cxx:3302
static enum::xmloff::token::XMLTokenEnum MapTemplateDisplayFormat(sal_Int16 nType)
map TemplateDisplayFormat to XML
Definition: txtflde.cxx:2968
constexpr sal_uInt16 XML_NAMESPACE_XLINK
Definition: xmlnmspe.hxx:35
const OUStringLiteral gsPropertyURLContent("URLContent")
void ProcessBibliographyData(const css::uno::Reference< css::beans::XPropertySet > &rPropertySet)
date/time value
Definition: txtflde.cxx:2702
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:2865
std::unique_ptr< XMLPropertyState > pCombinedCharactersPropertyState
Definition: txtflde.hxx:410
FieldIdEnum
field IDs,
Definition: txtflde.hxx:56
Map an XMLTokenEnum to an enum value.
Definition: ximpshap.hxx:40
static void convertNumLetterSync(OUStringBuffer &rBuffer, sal_Int16 nType)
Definition: xmluconv.cxx:671
const OUStringLiteral gsPropertyTextRange("TextRange")
DefTokenId nToken
std::unique_ptr< char[]> aBuffer
char const FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR2[]
Definition: txtflde.cxx:118
char const FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME[]
Definition: txtflde.cxx:119
char const FIELD_SERVICE_DOC_INFO_REVISION[]
Definition: txtflde.cxx:127
const OUStringLiteral gsPropertyDateTimeValue("DateTimeValue")
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:3512
char const FIELD_SERVICE_DOC_INFO_DESCRIPTION[]
Definition: txtflde.cxx:109
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:2158
char const FIELD_SERVICE_BIBLIOGRAPHY[]
Definition: txtflde.cxx:147
const OUStringLiteral gsPropertyIsFixedLanguage("IsFixedLanguage")
const OUStringLiteral gsPropertyFullName("FullName")
std::map< OUString, rtl::Reference< Entity > > map
const OUStringLiteral gsPropertyInitials("Initials")
const OUStringLiteral gsPropertyFieldSubType("UserDataType")
void ProcessNumberingType(sal_Int16 nNumberingType)
export a numbering format (numeric, roman, alphabetic, etc.)
Definition: txtflde.cxx:2574
Smart struct to transport an Any with an index to the appropriate property-name.
Definition: maptype.hxx:122
char const FIELD_SERVICE_JUMPEDIT[]
Definition: txtflde.cxx:87
QPRO_FUNC_TYPE nType
Sequence< sal_Int8 > aSeq
char const FIELD_SERVICE_SHEET_NAME[]
Definition: txtflde.cxx:141
char const FIELD_SERVICE_DB_DISPLAY[]
Definition: txtflde.cxx:98
constexpr sal_uInt16 XML_NAMESPACE_META
Definition: xmlnmspe.hxx:37
static enum::xmloff::token::XMLTokenEnum MapDocInfoFieldName(enum FieldIdEnum nToken)
Definition: txtflde.cxx:3241
sal_Int32 dataStyleForceSystemLanguage(sal_Int32 nFormat) const
Definition: xmlexp.cxx:1852
const OUStringLiteral gsPropertyDDECommandElement("DDECommandElement")
const OUStringLiteral gsPropertyCharStyleNames("CharStyleNames")
static enum::xmloff::token::XMLTokenEnum MapPageNumberName(const css::uno::Reference< css::beans::XPropertySet > &xPropSet, sal_Int32 &nOffset)
Definition: txtflde.cxx:2936
const OUStringLiteral gsPropertyHint("Hint")
static sal_Int8 GetInt8Property(const OUString &, const Reference< XPropertySet > &)
Definition: txtflde.cxx:3532
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)
const OUStringLiteral gsPropertyCondition("Condition")
const OUStringLiteral gsPropertyNumberFormat("NumberFormat")
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 *)
sal_Int32 nLength
Definition: xmltoken.cxx:36
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:2323
XMLTokenEnum eToken
Definition: xmltoken.cxx:40
const OUStringLiteral gsPropertyContent("Content")
void ExportMacro(const css::uno::Reference< css::beans::XPropertySet > &rPropSet, const OUString &rContent)
element content
Definition: txtflde.cxx:2258
char const FIELD_SERVICE_SENDER[]
Definition: txtflde.cxx:85
virtual void addDataStyle(const sal_Int32 nNumberFormat, bool bTimeFormat=false)
Definition: xmlexp.cxx:1819
constexpr sal_uInt16 XML_NAMESPACE_SCRIPT
Definition: xmlnmspe.hxx:45
const OUStringLiteral gsPropertyName("Name")
const OUStringLiteral gsPropertyMeasureKind("Kind")
css::uno::Any const SvXMLExport & rExport
Definition: ImageStyle.hxx:38
char const FIELD_SERVICE_INPUT[]
Definition: txtflde.cxx:91
char const FIELD_SERVICE_URL[]
Definition: txtflde.cxx:146
void ProcessIntegerDef(enum::xmloff::token::XMLTokenEnum eXmlName, sal_Int32 nNum, sal_Int32 nDefault)
attribute value
Definition: txtflde.cxx:2565
const OUStringLiteral gsPropertyDataBaseName("DataBaseName")
const OUStringLiteral gsPropertyIsFixed("IsFixed")
constexpr sal_uInt16 XML_NAMESPACE_OFFICE
Definition: xmlnmspe.hxx:29
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:2928
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:2892
const OUStringLiteral gsPropertyIsShowFormula("IsShowFormula")
#define ENUM_STRING_MAP_ENTRY(name, tok)
Definition: xmlement.hxx:62