1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
23 * export of all text fields
25 #include <comphelper/propertyvalue.hxx>
26 #include <txtflde.hxx>
27 #include <xmloff/XMLEventExport.hxx>
28 #include <xmloff/families.hxx>
29 #include <xmloff/namespacemap.hxx>
30 #include <xmloff/numehelp.hxx>
31 #include <xmloff/xmlement.hxx>
32 #include <xmloff/xmlexp.hxx>
33 #include <xmloff/xmltoken.hxx>
34 #include <xmloff/xmluconv.hxx>
35 #include <xmloff/maptype.hxx>
37 #include "XMLTextCharStyleNamesElementExport.hxx"
38 #include <sax/tools/converter.hxx>
39 #include <com/sun/star/frame/XModel.hpp>
40 #include <com/sun/star/util/DateTime.hpp>
41 #include <com/sun/star/lang/XServiceInfo.hpp>
42 #include <com/sun/star/text/UserDataPart.hpp>
43 #include <com/sun/star/text/PageNumberType.hpp>
44 #include <com/sun/star/style/NumberingType.hpp>
45 #include <com/sun/star/text/ReferenceFieldPart.hpp>
46 #include <com/sun/star/text/ReferenceFieldSource.hpp>
47 #include <com/sun/star/beans/XPropertySet.hpp>
48 #include <com/sun/star/beans/XPropertyState.hpp>
49 #include <com/sun/star/text/XTextField.hpp>
50 #include <com/sun/star/text/XDependentTextField.hpp>
51 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
53 #include <com/sun/star/text/SetVariableType.hpp>
54 #include <com/sun/star/text/PlaceholderType.hpp>
55 #include <com/sun/star/text/FilenameDisplayFormat.hpp>
56 #include <com/sun/star/text/ChapterFormat.hpp>
57 #include <com/sun/star/text/TemplateDisplayFormat.hpp>
58 #include <com/sun/star/container/XNameReplace.hpp>
59 #include <com/sun/star/uno/Sequence.h>
60 #include <com/sun/star/text/BibliographyDataType.hpp>
61 #include <com/sun/star/sdb/CommandType.hpp>
62 #include <com/sun/star/rdf/XMetadatable.hpp>
63 #include <comphelper/sequence.hxx>
64 #include <o3tl/any.hxx>
65 #include <o3tl/safeint.hxx>
66 #include <rtl/ustrbuf.hxx>
67 #include <tools/debug.hxx>
68 #include <rtl/math.hxx>
69 #include <sal/log.hxx>
74 using namespace ::com::sun::star
;
75 using namespace ::com::sun::star::uno
;
76 using namespace ::com::sun::star::text
;
77 using namespace ::com::sun::star::lang
;
78 using namespace ::com::sun::star::beans
;
79 using namespace ::com::sun::star::util
;
80 using namespace ::com::sun::star::style
;
81 using namespace ::com::sun::star::document
;
82 using namespace ::com::sun::star::container
;
83 using namespace ::xmloff::token
;
86 char const FIELD_SERVICE_SENDER
[] = "ExtendedUser";
87 char const FIELD_SERVICE_AUTHOR
[] = "Author";
88 char const FIELD_SERVICE_JUMPEDIT
[] = "JumpEdit";
89 char const FIELD_SERVICE_GETEXP
[] = "GetExpression";
90 char const FIELD_SERVICE_SETEXP
[] = "SetExpression";
91 char const FIELD_SERVICE_USER
[] = "User";
92 char const FIELD_SERVICE_INPUT
[] = "Input";
93 char const FIELD_SERVICE_USERINPUT
[] = "InputUser";
94 char const FIELD_SERVICE_DATETIME
[] = "DateTime";
95 char const FIELD_SERVICE_PAGENUMBER
[] = "PageNumber";
96 char const FIELD_SERVICE_DB_NEXT
[] = "DatabaseNextSet";
97 char const FIELD_SERVICE_DB_SELECT
[] = "DatabaseNumberOfSet";
98 char const FIELD_SERVICE_DB_NUMBER
[] = "DatabaseSetNumber";
99 char const FIELD_SERVICE_DB_DISPLAY
[] = "Database";
100 char const FIELD_SERVICE_DB_NAME
[] = "DatabaseName";
101 char const FIELD_SERVICE_CONDITIONAL_TEXT
[] = "ConditionalText";
102 char const FIELD_SERVICE_HIDDEN_TEXT
[] = "HiddenText";
103 char const FIELD_SERVICE_HIDDEN_PARAGRAPH
[] = "HiddenParagraph";
104 char const FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR
[] = "DocInfo.ChangeAuthor";
105 char const FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR2
[] = "docinfo.ChangeAuthor";
106 char const FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME
[] = "DocInfo.ChangeDateTime";
107 char const FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME2
[] = "docinfo.ChangeDateTime";
108 char const FIELD_SERVICE_DOC_INFO_EDIT_TIME
[] = "DocInfo.EditTime";
109 char const FIELD_SERVICE_DOC_INFO_EDIT_TIME2
[] = "docinfo.EditTime";
110 char const FIELD_SERVICE_DOC_INFO_DESCRIPTION
[] = "DocInfo.Description";
111 char const FIELD_SERVICE_DOC_INFO_DESCRIPTION2
[] = "docinfo.Description";
112 char const FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR
[] = "DocInfo.CreateAuthor";
113 char const FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR2
[] = "docinfo.CreateAuthor";
114 char const FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME
[] = "DocInfo.CreateDateTime";
115 char const FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME2
[] = "docinfo.CreateDateTime";
116 char const FIELD_SERVICE_DOC_INFO_CUSTOM
[] = "DocInfo.Custom";
117 char const FIELD_SERVICE_DOC_INFO_CUSTOM2
[] = "docinfo.Custom";
118 char const FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR
[] = "DocInfo.PrintAuthor";
119 char const FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR2
[] = "docinfo.PrintAuthor";
120 char const FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME
[] = "DocInfo.PrintDateTime";
121 char const FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME2
[] = "docinfo.PrintDateTime";
122 char const FIELD_SERVICE_DOC_INFO_KEY_WORDS
[] = "DocInfo.KeyWords";
123 char const FIELD_SERVICE_DOC_INFO_KEY_WORDS2
[] = "docinfo.KeyWords";
124 char const FIELD_SERVICE_DOC_INFO_SUBJECT
[] = "DocInfo.Subject";
125 char const FIELD_SERVICE_DOC_INFO_SUBJECT2
[] = "docinfo.Subject";
126 char const FIELD_SERVICE_DOC_INFO_TITLE
[] = "DocInfo.Title";
127 char const FIELD_SERVICE_DOC_INFO_TITLE2
[] = "docinfo.Title";
128 char const FIELD_SERVICE_DOC_INFO_REVISION
[] = "DocInfo.Revision";
129 char const FIELD_SERVICE_DOC_INFO_REVISION2
[] = "docinfo.Revision";
130 char const FIELD_SERVICE_FILE_NAME
[] = "FileName";
131 char const FIELD_SERVICE_CHAPTER
[] = "Chapter";
132 char const FIELD_SERVICE_TEMPLATE_NAME
[] = "TemplateName";
133 char const FIELD_SERVICE_PAGE_COUNT
[] = "PageCount";
134 char const FIELD_SERVICE_PARAGRAPH_COUNT
[] = "ParagraphCount";
135 char const FIELD_SERVICE_WORD_COUNT
[] = "WordCount";
136 char const FIELD_SERVICE_CHARACTER_COUNT
[] = "CharacterCount";
137 char const FIELD_SERVICE_TABLE_COUNT
[] = "TableCount";
138 char const FIELD_SERVICE_GRAPHIC_COUNT
[] = "GraphicObjectCount";
139 char const FIELD_SERVICE_OBJECT_COUNT
[] = "EmbeddedObjectCount";
140 char const FIELD_SERVICE_REFERENCE_PAGE_SET
[] = "ReferencePageSet";
141 char const FIELD_SERVICE_REFERENCE_PAGE_GET
[] = "ReferencePageGet";
142 char const FIELD_SERVICE_SHEET_NAME
[] = "SheetName";
143 char const FIELD_SERVICE_PAGE_NAME
[] = "PageName";
144 char const FIELD_SERVICE_MACRO
[] = "Macro";
145 char const FIELD_SERVICE_GET_REFERENCE
[] = "GetReference";
146 char const FIELD_SERVICE_DDE
[] = "DDE";
147 char const FIELD_SERVICE_URL
[] = "URL";
148 char const FIELD_SERVICE_BIBLIOGRAPHY
[] = "Bibliography";
149 char const FIELD_SERVICE_SCRIPT
[] = "Script";
150 char const FIELD_SERVICE_ANNOTATION
[] = "Annotation";
151 char const FIELD_SERVICE_COMBINED_CHARACTERS
[] = "CombinedCharacters";
152 char const FIELD_SERVICE_META
[] = "MetadataField";
153 char const FIELD_SERVICE_MEASURE
[] = "Measure";
154 char const FIELD_SERVICE_TABLE_FORMULA
[] = "TableFormula";
155 char const FIELD_SERVICE_DROP_DOWN
[] = "DropDown";
159 /// Walks up the parent chain of xText and returns the topmost text.
160 uno::Reference
<text::XText
> GetToplevelText(const uno::Reference
<text::XText
>& xText
)
162 uno::Reference
<text::XText
> xRet
= xText
;
165 uno::Reference
<beans::XPropertySet
> xPropertySet(xRet
, uno::UNO_QUERY
);
166 if (!xPropertySet
.is())
169 if (!xPropertySet
->getPropertySetInfo()->hasPropertyByName("ParentText"))
172 uno::Reference
<text::XText
> xParent
;
173 if (xPropertySet
->getPropertyValue("ParentText") >>= xParent
)
182 SvXMLEnumStringMapEntry
<FieldIdEnum
> const aFieldServiceNameMapping
[] =
184 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SENDER
, FIELD_ID_SENDER
),
185 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_AUTHOR
, FIELD_ID_AUTHOR
),
186 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_JUMPEDIT
, FIELD_ID_PLACEHOLDER
),
187 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GETEXP
, FIELD_ID_VARIABLE_GET
),
188 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SETEXP
, FIELD_ID_VARIABLE_SET
),
189 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_USER
, FIELD_ID_USER_GET
),
190 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_INPUT
, FIELD_ID_TEXT_INPUT
),
191 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_USERINPUT
, FIELD_ID_USER_INPUT
),
192 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DATETIME
, FIELD_ID_TIME
),
193 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PAGENUMBER
, FIELD_ID_PAGENUMBER
),
194 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_REFERENCE_PAGE_SET
, FIELD_ID_REFPAGE_SET
),
195 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_REFERENCE_PAGE_GET
, FIELD_ID_REFPAGE_GET
),
197 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NEXT
, FIELD_ID_DATABASE_NEXT
),
198 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_SELECT
, FIELD_ID_DATABASE_SELECT
),
199 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NUMBER
, FIELD_ID_DATABASE_NUMBER
),
200 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_DISPLAY
, FIELD_ID_DATABASE_DISPLAY
),
201 // workaround for #no-bug#: Database/DataBase
202 ENUM_STRING_MAP_ENTRY( "DataBase", FIELD_ID_DATABASE_DISPLAY
),
203 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NAME
, FIELD_ID_DATABASE_NAME
),
205 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR
, FIELD_ID_DOCINFO_CREATION_AUTHOR
),
206 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR2
, FIELD_ID_DOCINFO_CREATION_AUTHOR
),
207 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME
, FIELD_ID_DOCINFO_CREATION_TIME
),
208 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME2
, FIELD_ID_DOCINFO_CREATION_TIME
),
209 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR
, FIELD_ID_DOCINFO_SAVE_AUTHOR
),
210 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR2
, FIELD_ID_DOCINFO_SAVE_AUTHOR
),
211 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME
, FIELD_ID_DOCINFO_SAVE_TIME
),
212 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME2
, FIELD_ID_DOCINFO_SAVE_TIME
),
213 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_EDIT_TIME
, FIELD_ID_DOCINFO_EDIT_DURATION
),
214 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_EDIT_TIME2
, FIELD_ID_DOCINFO_EDIT_DURATION
),
215 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_DESCRIPTION
, FIELD_ID_DOCINFO_DESCRIPTION
),
216 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_DESCRIPTION2
, FIELD_ID_DOCINFO_DESCRIPTION
),
217 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CUSTOM
, FIELD_ID_DOCINFO_CUSTOM
),
218 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CUSTOM2
, FIELD_ID_DOCINFO_CUSTOM
),
219 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR
, FIELD_ID_DOCINFO_PRINT_AUTHOR
),
220 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR2
, FIELD_ID_DOCINFO_PRINT_AUTHOR
),
221 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME
, FIELD_ID_DOCINFO_PRINT_TIME
),
222 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME2
, FIELD_ID_DOCINFO_PRINT_TIME
),
223 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_KEY_WORDS
, FIELD_ID_DOCINFO_KEYWORDS
),
224 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_KEY_WORDS2
, FIELD_ID_DOCINFO_KEYWORDS
),
225 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_SUBJECT
, FIELD_ID_DOCINFO_SUBJECT
),
226 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_SUBJECT2
, FIELD_ID_DOCINFO_SUBJECT
),
227 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_TITLE
, FIELD_ID_DOCINFO_TITLE
),
228 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_TITLE2
, FIELD_ID_DOCINFO_TITLE
),
229 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_REVISION
, FIELD_ID_DOCINFO_REVISION
),
230 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_REVISION2
, FIELD_ID_DOCINFO_REVISION
),
232 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CONDITIONAL_TEXT
, FIELD_ID_CONDITIONAL_TEXT
),
233 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_HIDDEN_TEXT
, FIELD_ID_HIDDEN_TEXT
),
234 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_HIDDEN_PARAGRAPH
, FIELD_ID_HIDDEN_PARAGRAPH
),
236 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_FILE_NAME
, FIELD_ID_FILE_NAME
),
237 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CHAPTER
, FIELD_ID_CHAPTER
),
238 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TEMPLATE_NAME
, FIELD_ID_TEMPLATE_NAME
),
240 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PAGE_COUNT
, FIELD_ID_COUNT_PAGES
),
241 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PARAGRAPH_COUNT
, FIELD_ID_COUNT_PARAGRAPHS
),
242 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_WORD_COUNT
, FIELD_ID_COUNT_WORDS
),
243 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CHARACTER_COUNT
, FIELD_ID_COUNT_CHARACTERS
),
244 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TABLE_COUNT
, FIELD_ID_COUNT_TABLES
),
245 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GRAPHIC_COUNT
, FIELD_ID_COUNT_GRAPHICS
),
246 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_OBJECT_COUNT
, FIELD_ID_COUNT_OBJECTS
),
248 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_MACRO
, FIELD_ID_MACRO
),
249 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GET_REFERENCE
, FIELD_ID_REF_REFERENCE
),
250 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DDE
, FIELD_ID_DDE
),
252 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_BIBLIOGRAPHY
, FIELD_ID_BIBLIOGRAPHY
),
254 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SCRIPT
, FIELD_ID_SCRIPT
),
255 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_ANNOTATION
, FIELD_ID_ANNOTATION
),
257 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_COMBINED_CHARACTERS
, FIELD_ID_COMBINED_CHARACTERS
),
258 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_META
, FIELD_ID_META
),
261 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SHEET_NAME
, FIELD_ID_SHEET_NAME
),
262 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PAGE_NAME
, FIELD_ID_PAGENAME
),
263 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_URL
, FIELD_ID_URL
),
264 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_MEASURE
, FIELD_ID_MEASURE
),
267 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TABLE_FORMULA
, FIELD_ID_TABLE_FORMULA
),
268 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DROP_DOWN
, FIELD_ID_DROP_DOWN
),
270 { nullptr, 0, FieldIdEnum(0) }
274 // property accessor helper functions
275 static bool GetBoolProperty(const OUString
&,
276 const Reference
<XPropertySet
> &);
277 static bool GetOptionalBoolProperty(const OUString
&,
278 const Reference
<XPropertySet
> &,
279 const Reference
<XPropertySetInfo
> &,
281 static double GetDoubleProperty(const OUString
&,
282 const Reference
<XPropertySet
> &);
283 static OUString
GetStringProperty(const OUString
&,
284 const Reference
<XPropertySet
> &);
285 static sal_Int32
GetIntProperty(const OUString
&,
286 const Reference
<XPropertySet
> &);
287 static sal_Int16
GetInt16Property(const OUString
&,
288 const Reference
<XPropertySet
> &);
289 static sal_Int8
GetInt8Property(const OUString
&,
290 const Reference
<XPropertySet
> &);
291 static util::DateTime
GetDateTimeProperty( const OUString
& sPropName
,
292 const Reference
<XPropertySet
> & xPropSet
);
293 static Sequence
<OUString
> GetStringSequenceProperty(
294 const OUString
& sPropName
,
295 const Reference
<XPropertySet
> & xPropSet
);
299 constexpr OUStringLiteral
gsServicePrefix(u
"com.sun.star.text.textfield.");
300 constexpr OUStringLiteral
gsFieldMasterPrefix(u
"com.sun.star.text.FieldMaster.");
301 constexpr OUStringLiteral
gsPresentationServicePrefix(u
"com.sun.star.presentation.TextField.");
304 constexpr OUStringLiteral
gsPropertyAdjust(u
"Adjust");
305 constexpr OUStringLiteral
gsPropertyAuthor(u
"Author");
306 constexpr OUStringLiteral
gsPropertyChapterFormat(u
"ChapterFormat");
307 constexpr OUStringLiteral
gsPropertyChapterNumberingLevel(u
"ChapterNumberingLevel");
308 constexpr OUStringLiteral
gsPropertyCharStyleNames(u
"CharStyleNames");
309 constexpr OUStringLiteral
gsPropertyCondition(u
"Condition");
310 constexpr OUStringLiteral
gsPropertyContent(u
"Content");
311 constexpr OUStringLiteral
gsPropertyDataBaseName(u
"DataBaseName");
312 constexpr OUStringLiteral
gsPropertyDataBaseURL(u
"DataBaseURL");
313 constexpr OUStringLiteral
gsPropertyDataColumnName(u
"DataColumnName");
314 constexpr OUStringLiteral
gsPropertyDataCommandType(u
"DataCommandType");
315 constexpr OUStringLiteral
gsPropertyDataTableName(u
"DataTableName");
316 constexpr OUStringLiteral
gsPropertyDateTime(u
"DateTime");
317 constexpr OUStringLiteral
gsPropertyDateTimeValue(u
"DateTimeValue");
318 constexpr OUStringLiteral
gsPropertyDDECommandElement(u
"DDECommandElement");
319 constexpr OUStringLiteral
gsPropertyDDECommandFile(u
"DDECommandFile");
320 constexpr OUStringLiteral
gsPropertyDDECommandType(u
"DDECommandType");
321 constexpr OUStringLiteral
gsPropertyDependentTextFields(u
"DependentTextFields");
322 constexpr OUStringLiteral
gsPropertyFalseContent(u
"FalseContent");
323 constexpr OUStringLiteral
gsPropertyFields(u
"Fields");
324 constexpr OUStringLiteral
gsPropertyFieldSubType(u
"UserDataType");
325 constexpr OUStringLiteral
gsPropertyFileFormat(u
"FileFormat");
326 constexpr OUStringLiteral
gsPropertyFullName(u
"FullName");
327 constexpr OUStringLiteral
gsPropertyHint(u
"Hint");
328 constexpr OUStringLiteral
gsPropertyInitials(u
"Initials");
329 constexpr OUStringLiteral
gsPropertyInstanceName(u
"InstanceName");
330 constexpr OUStringLiteral
gsPropertyIsAutomaticUpdate(u
"IsAutomaticUpdate");
331 constexpr OUStringLiteral
gsPropertyIsConditionTrue(u
"IsConditionTrue");
332 constexpr OUStringLiteral
gsPropertyIsDataBaseFormat(u
"DataBaseFormat");
333 constexpr OUStringLiteral
gsPropertyIsDate(u
"IsDate");
334 constexpr OUStringLiteral
gsPropertyIsExpression(u
"IsExpression");
335 constexpr OUStringLiteral
gsPropertyIsFixed(u
"IsFixed");
336 constexpr OUStringLiteral
gsPropertyIsFixedLanguage(u
"IsFixedLanguage");
337 constexpr OUStringLiteral
gsPropertyIsHidden(u
"IsHidden");
338 constexpr OUStringLiteral
gsPropertyIsInput(u
"Input");
339 constexpr OUStringLiteral
gsPropertyIsShowFormula(u
"IsShowFormula");
340 constexpr OUStringLiteral
gsPropertyIsVisible(u
"IsVisible");
341 constexpr OUStringLiteral
gsPropertyItems(u
"Items");
342 constexpr OUStringLiteral
gsPropertyLevel(u
"Level");
343 constexpr OUStringLiteral
gsPropertyMeasureKind(u
"Kind");
344 constexpr OUStringLiteral
gsPropertyName(u
"Name");
345 constexpr OUStringLiteral
gsPropertyNumberFormat(u
"NumberFormat");
346 constexpr OUStringLiteral
gsPropertyNumberingSeparator(u
"NumberingSeparator");
347 constexpr OUStringLiteral
gsPropertyNumberingType(u
"NumberingType");
348 constexpr OUStringLiteral
gsPropertyOffset(u
"Offset");
349 constexpr OUStringLiteral
gsPropertyOn(u
"On");
350 constexpr OUStringLiteral
gsPropertyPlaceholderType(u
"PlaceHolderType");
351 constexpr OUStringLiteral
gsPropertyReferenceFieldPart(u
"ReferenceFieldPart");
352 constexpr OUStringLiteral
gsPropertyReferenceFieldSource(u
"ReferenceFieldSource");
353 constexpr OUStringLiteral
gsPropertyReferenceFieldLanguage(u
"ReferenceFieldLanguage");
354 constexpr OUStringLiteral
gsPropertyScriptType(u
"ScriptType");
355 constexpr OUStringLiteral
gsPropertySelectedItem(u
"SelectedItem");
356 constexpr OUStringLiteral
gsPropertySequenceNumber(u
"SequenceNumber");
357 constexpr OUStringLiteral
gsPropertySequenceValue(u
"SequenceValue");
358 constexpr OUStringLiteral
gsPropertySetNumber(u
"SetNumber");
359 constexpr OUStringLiteral
gsPropertySourceName(u
"SourceName");
360 constexpr OUStringLiteral
gsPropertySubType(u
"SubType");
361 constexpr OUStringLiteral
gsPropertyTargetFrame(u
"TargetFrame");
362 constexpr OUStringLiteral
gsPropertyTrueContent(u
"TrueContent");
363 constexpr OUStringLiteral
gsPropertyURL(u
"URL");
364 constexpr OUStringLiteral
gsPropertyURLContent(u
"URLContent");
365 constexpr OUStringLiteral
gsPropertyUserText(u
"UserText");
366 constexpr OUStringLiteral
gsPropertyValue(u
"Value");
367 constexpr OUStringLiteral
gsPropertyVariableName(u
"VariableName");
368 constexpr OUStringLiteral
gsPropertyHelp(u
"Help");
369 constexpr OUStringLiteral
gsPropertyTooltip(u
"Tooltip");
370 constexpr OUStringLiteral
gsPropertyTextRange(u
"TextRange");
372 XMLTextFieldExport::XMLTextFieldExport( SvXMLExport
& rExp
,
373 std::unique_ptr
<XMLPropertyState
> pCombinedCharState
)
375 pCombinedCharactersPropertyState(std::move(pCombinedCharState
))
377 SetExportOnlyUsedFieldDeclarations();
380 XMLTextFieldExport::~XMLTextFieldExport()
384 /// get the field ID (as in FieldIDEnum) from XTextField
385 enum FieldIdEnum
XMLTextFieldExport::GetFieldID(
386 const Reference
<XTextField
> & rTextField
,
387 const Reference
<XPropertySet
> & xPropSet
)
389 // get service names for rTextField (via XServiceInfo service)
390 Reference
<XServiceInfo
> xService(rTextField
, UNO_QUERY
);
391 const Sequence
<OUString
> aServices
= xService
->getSupportedServiceNames();
393 OUString sFieldName
; // service name postfix of current field
395 // search for TextField service name
396 const OUString
* pNames
= std::find_if(aServices
.begin(), aServices
.end(),
397 [](const OUString
& rName
) { return rName
.matchIgnoreAsciiCase(gsServicePrefix
); });
398 if (pNames
!= aServices
.end())
400 // TextField found => postfix is field type!
401 sFieldName
= pNames
->copy(gsServicePrefix
.getLength());
404 // if this is not a normal text field, check if it's a presentation text field
405 if( sFieldName
.isEmpty() )
407 // search for TextField service name
408 pNames
= std::find_if(aServices
.begin(), aServices
.end(),
409 [](const OUString
& rName
) { return rName
.startsWith(gsPresentationServicePrefix
); });
410 if (pNames
!= aServices
.end())
412 // TextField found => postfix is field type!
413 sFieldName
= pNames
->copy(gsPresentationServicePrefix
.getLength());
416 if( !sFieldName
.isEmpty() )
418 if( sFieldName
== "Header" )
420 return FIELD_ID_DRAW_HEADER
;
422 else if( sFieldName
== "Footer" )
424 return FIELD_ID_DRAW_FOOTER
;
426 else if( sFieldName
== "DateTime" )
428 return FIELD_ID_DRAW_DATE_TIME
;
433 // map postfix of service name to field ID
434 DBG_ASSERT(!sFieldName
.isEmpty(), "no TextField service found!");
435 return MapFieldName(sFieldName
, xPropSet
);
438 enum FieldIdEnum
XMLTextFieldExport::MapFieldName(
439 std::u16string_view sFieldName
, // field (master) name
440 const Reference
<XPropertySet
> & xPropSet
) // for subtype
442 // we'll proceed in 2 steps:
443 // a) map service name to preliminary FIELD_ID
444 // b) map those prelim. FIELD_IDs that correspond to several field types
445 // (in our (XML) world) to final FIELD IDs
448 // a) find prelim. FIELD_ID via aFieldServiceMapping
450 // check for non-empty service name
451 DBG_ASSERT(!sFieldName
.empty(), "no valid service name!");
452 enum FieldIdEnum nToken
= FIELD_ID_UNKNOWN
;
453 if (!sFieldName
.empty())
455 // map name to prelim. ID
456 bool bRet
= SvXMLUnitConverter::convertEnum(
457 nToken
, sFieldName
, aFieldServiceNameMapping
);
460 DBG_ASSERT(bRet
, "Unknown field service name encountered!");
463 // b) map prelim. to final FIELD_IDs
465 case FIELD_ID_VARIABLE_SET
:
466 if (GetBoolProperty(gsPropertyIsInput
, xPropSet
))
468 nToken
= FIELD_ID_VARIABLE_INPUT
;
472 switch (GetIntProperty(gsPropertySubType
, xPropSet
))
474 case SetVariableType::STRING
: // text field
475 case SetVariableType::VAR
: // num field
476 nToken
= FIELD_ID_VARIABLE_SET
;
478 case SetVariableType::SEQUENCE
:
479 nToken
= FIELD_ID_SEQUENCE
;
481 case SetVariableType::FORMULA
:
483 nToken
= FIELD_ID_UNKNOWN
;
489 case FIELD_ID_VARIABLE_GET
:
490 switch (GetIntProperty(gsPropertySubType
, xPropSet
))
492 case SetVariableType::STRING
: // text field
493 case SetVariableType::VAR
: // num field
494 nToken
= FIELD_ID_VARIABLE_GET
;
496 case SetVariableType::FORMULA
:
497 nToken
= FIELD_ID_EXPRESSION
;
499 case SetVariableType::SEQUENCE
:
501 nToken
= FIELD_ID_UNKNOWN
;
507 if (GetBoolProperty(gsPropertyIsDate
, xPropSet
))
509 nToken
= FIELD_ID_DATE
;
513 case FIELD_ID_PAGENUMBER
:
514 // NumberingType not available in non-Writer apps
515 if (xPropSet
->getPropertySetInfo()->
516 hasPropertyByName(gsPropertyNumberingType
))
518 if (NumberingType::CHAR_SPECIAL
== GetIntProperty(
519 gsPropertyNumberingType
, xPropSet
))
521 nToken
= FIELD_ID_PAGESTRING
;
526 case FIELD_ID_DOCINFO_CREATION_TIME
:
527 if (GetBoolProperty(gsPropertyIsDate
, xPropSet
))
529 nToken
= FIELD_ID_DOCINFO_CREATION_DATE
;
533 case FIELD_ID_DOCINFO_PRINT_TIME
:
534 if (GetBoolProperty(gsPropertyIsDate
, xPropSet
))
536 nToken
= FIELD_ID_DOCINFO_PRINT_DATE
;
540 case FIELD_ID_DOCINFO_SAVE_TIME
:
541 if (GetBoolProperty(gsPropertyIsDate
, xPropSet
))
543 nToken
= FIELD_ID_DOCINFO_SAVE_DATE
;
547 case FIELD_ID_REF_REFERENCE
:
548 switch (GetInt16Property(gsPropertyReferenceFieldSource
, xPropSet
))
550 case ReferenceFieldSource::REFERENCE_MARK
:
551 nToken
= FIELD_ID_REF_REFERENCE
;
553 case ReferenceFieldSource::SEQUENCE_FIELD
:
554 nToken
= FIELD_ID_REF_SEQUENCE
;
556 case ReferenceFieldSource::BOOKMARK
:
557 nToken
= FIELD_ID_REF_BOOKMARK
;
559 case ReferenceFieldSource::FOOTNOTE
:
560 nToken
= FIELD_ID_REF_FOOTNOTE
;
562 case ReferenceFieldSource::ENDNOTE
:
563 nToken
= FIELD_ID_REF_ENDNOTE
;
566 nToken
= FIELD_ID_UNKNOWN
;
571 case FIELD_ID_COMBINED_CHARACTERS
:
572 case FIELD_ID_SCRIPT
:
573 case FIELD_ID_ANNOTATION
:
574 case FIELD_ID_BIBLIOGRAPHY
:
577 case FIELD_ID_REFPAGE_SET
:
578 case FIELD_ID_REFPAGE_GET
:
579 case FIELD_ID_COUNT_PAGES
:
580 case FIELD_ID_COUNT_PARAGRAPHS
:
581 case FIELD_ID_COUNT_WORDS
:
582 case FIELD_ID_COUNT_CHARACTERS
:
583 case FIELD_ID_COUNT_TABLES
:
584 case FIELD_ID_COUNT_GRAPHICS
:
585 case FIELD_ID_COUNT_OBJECTS
:
586 case FIELD_ID_CONDITIONAL_TEXT
:
587 case FIELD_ID_HIDDEN_TEXT
:
588 case FIELD_ID_HIDDEN_PARAGRAPH
:
589 case FIELD_ID_DOCINFO_CREATION_AUTHOR
:
590 case FIELD_ID_DOCINFO_DESCRIPTION
:
591 case FIELD_ID_DOCINFO_CUSTOM
:
592 case FIELD_ID_DOCINFO_PRINT_AUTHOR
:
593 case FIELD_ID_DOCINFO_TITLE
:
594 case FIELD_ID_DOCINFO_SUBJECT
:
595 case FIELD_ID_DOCINFO_KEYWORDS
:
596 case FIELD_ID_DOCINFO_REVISION
:
597 case FIELD_ID_DOCINFO_EDIT_DURATION
:
598 case FIELD_ID_DOCINFO_SAVE_AUTHOR
:
599 case FIELD_ID_TEXT_INPUT
:
600 case FIELD_ID_USER_INPUT
:
601 case FIELD_ID_AUTHOR
:
602 case FIELD_ID_SENDER
:
603 case FIELD_ID_PLACEHOLDER
:
604 case FIELD_ID_USER_GET
:
605 case FIELD_ID_DATABASE_NEXT
:
606 case FIELD_ID_DATABASE_SELECT
:
607 case FIELD_ID_DATABASE_DISPLAY
:
608 case FIELD_ID_DATABASE_NAME
:
609 case FIELD_ID_DATABASE_NUMBER
:
610 case FIELD_ID_TEMPLATE_NAME
:
611 case FIELD_ID_CHAPTER
:
612 case FIELD_ID_FILE_NAME
:
614 case FIELD_ID_SHEET_NAME
:
615 case FIELD_ID_PAGENAME
:
616 case FIELD_ID_MEASURE
:
618 case FIELD_ID_TABLE_FORMULA
:
619 case FIELD_ID_DROP_DOWN
:
620 ; // these field IDs are final
624 nToken
= FIELD_ID_UNKNOWN
;
627 // ... and return final FIELD_ID
631 // is string or numeric field?
632 bool XMLTextFieldExport::IsStringField(
633 FieldIdEnum nFieldType
,
634 const Reference
<XPropertySet
> & xPropSet
)
636 switch (nFieldType
) {
638 case FIELD_ID_VARIABLE_GET
:
639 case FIELD_ID_VARIABLE_SET
:
640 case FIELD_ID_VARIABLE_INPUT
:
642 // depends on field sub type
643 return ( GetIntProperty(gsPropertySubType
, xPropSet
) ==
644 SetVariableType::STRING
);
647 case FIELD_ID_USER_GET
:
648 case FIELD_ID_USER_INPUT
:
650 Reference
<XTextField
> xTextField(xPropSet
, UNO_QUERY
);
651 DBG_ASSERT(xTextField
.is(), "field is no XTextField!");
652 bool bRet
= GetBoolProperty(gsPropertyIsExpression
,
653 GetMasterPropertySet(xTextField
));
658 return 0 > GetIntProperty(gsPropertyNumberFormat
, xPropSet
);
660 case FIELD_ID_DATABASE_DISPLAY
:
661 // TODO: depends on... ???
662 // workaround #no-bug#: no data type
663 return 5100 == GetIntProperty(gsPropertyNumberFormat
, xPropSet
);
665 case FIELD_ID_TABLE_FORMULA
:
666 // legacy field: always a number field (because it always has
670 case FIELD_ID_COUNT_PAGES
:
671 case FIELD_ID_COUNT_PARAGRAPHS
:
672 case FIELD_ID_COUNT_WORDS
:
673 case FIELD_ID_COUNT_CHARACTERS
:
674 case FIELD_ID_COUNT_TABLES
:
675 case FIELD_ID_COUNT_GRAPHICS
:
676 case FIELD_ID_COUNT_OBJECTS
:
677 case FIELD_ID_DOCINFO_SAVE_TIME
:
678 case FIELD_ID_DOCINFO_SAVE_DATE
:
679 case FIELD_ID_DOCINFO_CREATION_DATE
:
680 case FIELD_ID_DOCINFO_CREATION_TIME
:
681 case FIELD_ID_DOCINFO_PRINT_TIME
:
682 case FIELD_ID_DOCINFO_PRINT_DATE
:
683 case FIELD_ID_DOCINFO_EDIT_DURATION
:
684 case FIELD_ID_DOCINFO_REVISION
:
685 case FIELD_ID_DATABASE_NUMBER
:
686 case FIELD_ID_EXPRESSION
:
687 case FIELD_ID_SEQUENCE
:
690 case FIELD_ID_PAGENUMBER
:
691 case FIELD_ID_REFPAGE_SET
:
692 case FIELD_ID_REFPAGE_GET
:
693 case FIELD_ID_DOCINFO_CUSTOM
:
697 case FIELD_ID_COMBINED_CHARACTERS
:
698 case FIELD_ID_BIBLIOGRAPHY
:
700 case FIELD_ID_REF_REFERENCE
:
701 case FIELD_ID_REF_SEQUENCE
:
702 case FIELD_ID_REF_BOOKMARK
:
703 case FIELD_ID_REF_FOOTNOTE
:
704 case FIELD_ID_REF_ENDNOTE
:
706 case FIELD_ID_TEMPLATE_NAME
:
707 case FIELD_ID_CHAPTER
:
708 case FIELD_ID_FILE_NAME
:
709 case FIELD_ID_CONDITIONAL_TEXT
:
710 case FIELD_ID_HIDDEN_TEXT
:
711 case FIELD_ID_HIDDEN_PARAGRAPH
:
712 case FIELD_ID_DOCINFO_CREATION_AUTHOR
:
713 case FIELD_ID_DOCINFO_DESCRIPTION
:
714 case FIELD_ID_DOCINFO_PRINT_AUTHOR
:
715 case FIELD_ID_DOCINFO_TITLE
:
716 case FIELD_ID_DOCINFO_SUBJECT
:
717 case FIELD_ID_DOCINFO_KEYWORDS
:
718 case FIELD_ID_DOCINFO_SAVE_AUTHOR
:
719 case FIELD_ID_DATABASE_NAME
:
720 case FIELD_ID_TEXT_INPUT
:
721 case FIELD_ID_SENDER
:
722 case FIELD_ID_AUTHOR
:
723 case FIELD_ID_PAGENAME
:
724 case FIELD_ID_PAGESTRING
:
725 case FIELD_ID_SHEET_NAME
:
726 case FIELD_ID_MEASURE
:
728 case FIELD_ID_DROP_DOWN
:
732 case FIELD_ID_SCRIPT
:
733 case FIELD_ID_ANNOTATION
:
734 case FIELD_ID_DATABASE_NEXT
:
735 case FIELD_ID_DATABASE_SELECT
:
736 case FIELD_ID_PLACEHOLDER
:
737 case FIELD_ID_UNKNOWN
:
738 case FIELD_ID_DRAW_HEADER
:
739 case FIELD_ID_DRAW_FOOTER
:
740 case FIELD_ID_DRAW_DATE_TIME
:
742 OSL_FAIL("unknown field type/field has no content");
743 return true; // invalid info; string in case of doubt
747 /// export the styles needed by the given field. Called on first pass
749 void XMLTextFieldExport::ExportFieldAutoStyle(
750 const Reference
<XTextField
> & rTextField
, const bool bProgress
,
751 const bool bRecursive
)
754 Reference
<XPropertySet
> xPropSet(rTextField
, UNO_QUERY
);
756 // add field master to list of used field masters (if desired)
757 if (nullptr != pUsedMasters
)
759 Reference
<XDependentTextField
> xDepField(rTextField
, UNO_QUERY
);
762 // The direct parent may be just the table cell, while we want the topmost parent, e.g.
764 Reference
<XText
> xOurText
= GetToplevelText(rTextField
->getAnchor()->getText());
766 std::map
<Reference
<XText
>, std::set
<OUString
> >::iterator aMapIter
=
767 pUsedMasters
->find(xOurText
);
769 // insert a list for our XText (if necessary)
770 if (aMapIter
== pUsedMasters
->end())
772 std::set
<OUString
> aSet
;
773 (*pUsedMasters
)[xOurText
] = aSet
;
774 aMapIter
= pUsedMasters
->find(xOurText
);
777 // insert this text field master
778 OUString sFieldMasterName
= GetStringProperty(
779 gsPropertyInstanceName
, xDepField
->getTextFieldMaster());
780 if (!sFieldMasterName
.isEmpty())
781 aMapIter
->second
.insert( sFieldMasterName
);
783 // else: no dependent field -> no master -> ignore
787 FieldIdEnum nToken
= GetFieldID(rTextField
, xPropSet
);
789 // export the character style for all fields
790 // with one exception: combined character fields export their own
792 Reference
<XPropertySet
> xRangePropSet(rTextField
->getAnchor(), UNO_QUERY
);
793 if (FIELD_ID_COMBINED_CHARACTERS
!= nToken
)
795 GetExport().GetTextParagraphExport()->Add(
796 XmlStyleFamily::TEXT_TEXT
, xRangePropSet
);
799 // process special styles for each field (e.g. data styles)
802 case FIELD_ID_DATABASE_DISPLAY
:
804 sal_Int32 nFormat
= GetIntProperty(gsPropertyNumberFormat
, xPropSet
);
805 // workaround: #no-bug#; see IsStringField(...)
806 if ( (5100 != nFormat
) &&
807 !GetBoolProperty(gsPropertyIsDataBaseFormat
, xPropSet
) )
809 GetExport().addDataStyle(nFormat
);
817 // date and time fields are always number fields, but the
818 // NumberFormat property is optional (e.g. Calc doesn't
820 Reference
<XPropertySetInfo
> xPropSetInfo(
821 xPropSet
->getPropertySetInfo() );
822 if ( xPropSetInfo
->hasPropertyByName( gsPropertyNumberFormat
) )
825 GetIntProperty(gsPropertyNumberFormat
, xPropSet
);
827 // nFormat may be -1 for numeric fields that display their
828 // variable name. (Maybe this should be a field type, then?)
831 if( ! GetOptionalBoolProperty(
832 gsPropertyIsFixedLanguage
,
833 xPropSet
, xPropSetInfo
, false ) )
836 GetExport().dataStyleForceSystemLanguage(nFormat
);
839 GetExport().addDataStyle( nFormat
,
840 nToken
== FIELD_ID_TIME
);
847 // recurse into content (does not export element, so can be done first)
850 bool dummy_for_autostyles(true);
851 ExportMetaField(xPropSet
, true, bProgress
, dummy_for_autostyles
);
854 case FIELD_ID_DOCINFO_PRINT_TIME
:
855 case FIELD_ID_DOCINFO_PRINT_DATE
:
856 case FIELD_ID_DOCINFO_CREATION_DATE
:
857 case FIELD_ID_DOCINFO_CREATION_TIME
:
858 case FIELD_ID_DOCINFO_SAVE_TIME
:
859 case FIELD_ID_DOCINFO_SAVE_DATE
:
860 case FIELD_ID_DOCINFO_EDIT_DURATION
:
861 case FIELD_ID_VARIABLE_SET
:
862 case FIELD_ID_VARIABLE_GET
:
863 case FIELD_ID_VARIABLE_INPUT
:
864 case FIELD_ID_USER_GET
:
865 case FIELD_ID_EXPRESSION
:
866 case FIELD_ID_TABLE_FORMULA
:
867 case FIELD_ID_DOCINFO_CUSTOM
:
868 // register number format, if this is a numeric field
869 if (! IsStringField(nToken
, xPropSet
)) {
872 GetIntProperty(gsPropertyNumberFormat
, xPropSet
);
874 // nFormat may be -1 for numeric fields that display their
875 // variable name. (Maybe this should be a field type, then?)
878 // handle formats for fixed language fields
879 // for all these fields (except table formula)
880 if( ( nToken
!= FIELD_ID_TABLE_FORMULA
) &&
881 ! GetOptionalBoolProperty(
882 gsPropertyIsFixedLanguage
,
883 xPropSet
, xPropSet
->getPropertySetInfo(),
887 GetExport().dataStyleForceSystemLanguage(nFormat
);
890 GetExport().addDataStyle(nFormat
);
895 case FIELD_ID_COMBINED_CHARACTERS
:
897 // export text style with the addition of the combined characters
898 DBG_ASSERT(nullptr != pCombinedCharactersPropertyState
,
899 "need proper PropertyState for combined characters");
900 o3tl::span
<XMLPropertyState
> aStates( pCombinedCharactersPropertyState
.get(), 1 );
901 GetExport().GetTextParagraphExport()->Add(
902 XmlStyleFamily::TEXT_TEXT
, xRangePropSet
,
907 case FIELD_ID_SCRIPT
:
908 case FIELD_ID_ANNOTATION
:
909 case FIELD_ID_BIBLIOGRAPHY
:
911 case FIELD_ID_REF_REFERENCE
:
912 case FIELD_ID_REF_SEQUENCE
:
913 case FIELD_ID_REF_BOOKMARK
:
914 case FIELD_ID_REF_FOOTNOTE
:
915 case FIELD_ID_REF_ENDNOTE
:
917 case FIELD_ID_REFPAGE_SET
:
918 case FIELD_ID_REFPAGE_GET
:
919 case FIELD_ID_COUNT_PAGES
:
920 case FIELD_ID_COUNT_PARAGRAPHS
:
921 case FIELD_ID_COUNT_WORDS
:
922 case FIELD_ID_COUNT_CHARACTERS
:
923 case FIELD_ID_COUNT_TABLES
:
924 case FIELD_ID_COUNT_GRAPHICS
:
925 case FIELD_ID_COUNT_OBJECTS
:
926 case FIELD_ID_CONDITIONAL_TEXT
:
927 case FIELD_ID_HIDDEN_TEXT
:
928 case FIELD_ID_HIDDEN_PARAGRAPH
:
929 case FIELD_ID_DOCINFO_CREATION_AUTHOR
:
930 case FIELD_ID_DOCINFO_DESCRIPTION
:
931 case FIELD_ID_DOCINFO_PRINT_AUTHOR
:
932 case FIELD_ID_DOCINFO_TITLE
:
933 case FIELD_ID_DOCINFO_SUBJECT
:
934 case FIELD_ID_DOCINFO_KEYWORDS
:
935 case FIELD_ID_DOCINFO_REVISION
:
936 case FIELD_ID_DOCINFO_SAVE_AUTHOR
:
937 case FIELD_ID_SEQUENCE
:
938 case FIELD_ID_PAGENAME
:
939 case FIELD_ID_PAGENUMBER
:
940 case FIELD_ID_PAGESTRING
:
941 case FIELD_ID_AUTHOR
:
942 case FIELD_ID_SENDER
:
943 case FIELD_ID_PLACEHOLDER
:
944 case FIELD_ID_USER_INPUT
:
945 case FIELD_ID_TEXT_INPUT
:
946 case FIELD_ID_DATABASE_NEXT
:
947 case FIELD_ID_DATABASE_SELECT
:
948 case FIELD_ID_DATABASE_NAME
:
949 case FIELD_ID_DATABASE_NUMBER
:
950 case FIELD_ID_TEMPLATE_NAME
:
951 case FIELD_ID_CHAPTER
:
952 case FIELD_ID_FILE_NAME
:
953 case FIELD_ID_SHEET_NAME
:
954 case FIELD_ID_MEASURE
:
956 case FIELD_ID_DROP_DOWN
:
957 case FIELD_ID_DRAW_DATE_TIME
:
958 case FIELD_ID_DRAW_FOOTER
:
959 case FIELD_ID_DRAW_HEADER
:
960 ; // no formats for these fields!
963 case FIELD_ID_UNKNOWN
:
965 OSL_FAIL("unknown field type!");
966 // ignore -> no format for unknown
971 /// export the given field to XML. Called on second pass through document
972 void XMLTextFieldExport::ExportField(
973 const Reference
<XTextField
> & rTextField
, bool bProgress
,
974 bool & rPrevCharIsSpace
)
977 Reference
<XPropertySet
> xPropSet(rTextField
, UNO_QUERY
);
979 // get property set of range (for the attributes)
980 Reference
<XPropertySet
> xRangePropSet(rTextField
->getAnchor(), UNO_QUERY
);
983 enum FieldIdEnum nToken
= GetFieldID(rTextField
, xPropSet
);
985 // special treatment for combined characters field, because it is
986 // exported as a style
987 const XMLPropertyState
* aStates
[] = { pCombinedCharactersPropertyState
.get(), nullptr };
988 const XMLPropertyState
**pStates
=
989 FIELD_ID_COMBINED_CHARACTERS
== nToken
993 // find out whether we need to set the style
996 OUString sStyle
= GetExport().GetTextParagraphExport()->
997 FindTextStyle( xRangePropSet
, bIsUICharStyle
, bHasAutoStyle
, pStates
);
998 bool bHasStyle
= !sStyle
.isEmpty();
1001 Reference
<XPropertySetInfo
> xRangePropSetInfo
;
1002 XMLTextCharStyleNamesElementExport
aCharStylesExport(
1003 GetExport(), bIsUICharStyle
&&
1004 GetExport().GetTextParagraphExport()
1005 ->GetCharStyleNamesPropInfoCache().hasProperty(
1006 xRangePropSet
, xRangePropSetInfo
), bHasAutoStyle
,
1007 xRangePropSet
, gsPropertyCharStyleNames
);
1009 // export span with style (if necessary)
1010 // (except for combined characters field)
1013 // export <text:span> element
1014 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
1015 GetExport().EncodeStyleName( sStyle
) );
1017 SvXMLElementExport
aSpan( GetExport(), bHasStyle
,
1018 XML_NAMESPACE_TEXT
, XML_SPAN
,
1021 // finally, export the field itself
1022 ExportFieldHelper( rTextField
, xPropSet
, xRangePropSet
, nToken
,
1023 bProgress
, rPrevCharIsSpace
);
1027 /// export the given field to XML. Called on second pass through document
1028 void XMLTextFieldExport::ExportFieldHelper(
1029 const Reference
<XTextField
> & rTextField
,
1030 const Reference
<XPropertySet
> & rPropSet
,
1031 const Reference
<XPropertySet
> &,
1032 enum FieldIdEnum nToken
,
1034 bool & rPrevCharIsSpace
)
1036 // get property set info (because some attributes are not support
1037 // in all implementations)
1038 Reference
<XPropertySetInfo
> xPropSetInfo(rPropSet
->getPropertySetInfo());
1040 OUString sPresentation
= rTextField
->getPresentation(false);
1042 // process each field type
1044 case FIELD_ID_AUTHOR
:
1045 // author field: fixed, field (sub-)type
1046 if (xPropSetInfo
->hasPropertyByName(gsPropertyIsFixed
))
1048 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_FIXED
,
1049 (GetBoolProperty(gsPropertyIsFixed
, rPropSet
) ? XML_TRUE
: XML_FALSE
) );
1051 ExportElement(MapAuthorFieldName(rPropSet
), sPresentation
);
1054 case FIELD_ID_SENDER
:
1055 // sender field: fixed, field (sub-)type
1056 ProcessBoolean(XML_FIXED
,
1057 GetBoolProperty(gsPropertyIsFixed
, rPropSet
), true);
1058 ExportElement(MapSenderFieldName(rPropSet
), sPresentation
);
1061 case FIELD_ID_PLACEHOLDER
:
1062 // placeholder field: type, name, description
1063 ProcessString(XML_PLACEHOLDER_TYPE
,
1065 GetInt16Property(gsPropertyPlaceholderType
, rPropSet
)));
1066 ProcessString(XML_DESCRIPTION
,
1067 GetStringProperty(gsPropertyHint
,rPropSet
), true);
1068 ExportElement(XML_PLACEHOLDER
, sPresentation
);
1071 case FIELD_ID_VARIABLE_SET
:
1073 // variable set field: name, visible, format&value
1074 ProcessString(XML_NAME
,
1075 GetStringProperty(gsPropertyVariableName
, rPropSet
));
1076 ProcessDisplay(GetBoolProperty(gsPropertyIsVisible
, rPropSet
),
1078 ProcessString(XML_FORMULA
, XML_NAMESPACE_OOOW
,
1079 GetStringProperty(gsPropertyContent
, rPropSet
),
1081 ProcessValueAndType(IsStringField(nToken
, rPropSet
),
1082 GetIntProperty(gsPropertyNumberFormat
, rPropSet
),
1083 GetStringProperty(gsPropertyContent
, rPropSet
),
1085 GetDoubleProperty(gsPropertyValue
, rPropSet
),
1087 ! GetOptionalBoolProperty(
1088 gsPropertyIsFixedLanguage
,
1089 rPropSet
, xPropSetInfo
, false ) );
1090 ExportElement(XML_VARIABLE_SET
, sPresentation
);
1093 case FIELD_ID_VARIABLE_GET
:
1095 // variable get field: name, format&value
1096 ProcessString(XML_NAME
,
1097 GetStringProperty(gsPropertyContent
, rPropSet
));
1098 bool bCmd
= GetBoolProperty(gsPropertyIsShowFormula
, rPropSet
);
1099 ProcessDisplay(true, bCmd
);
1100 // show style, unless name will be shown
1101 ProcessValueAndType(IsStringField(nToken
, rPropSet
),
1102 GetIntProperty(gsPropertyNumberFormat
, rPropSet
),
1103 "", u
"", 0.0, // values not used
1107 ! GetOptionalBoolProperty(
1108 gsPropertyIsFixedLanguage
,
1109 rPropSet
, xPropSetInfo
, false ) );
1110 ExportElement(XML_VARIABLE_GET
, sPresentation
);
1113 case FIELD_ID_VARIABLE_INPUT
:
1114 // variable input field: name, description, format&value
1115 ProcessString(XML_NAME
,
1116 GetStringProperty(gsPropertyVariableName
, rPropSet
));
1117 ProcessString(XML_DESCRIPTION
,
1118 GetStringProperty(gsPropertyHint
, rPropSet
));
1119 ProcessDisplay(GetBoolProperty(gsPropertyIsVisible
, rPropSet
),
1121 ProcessString(XML_FORMULA
, XML_NAMESPACE_OOOW
,
1122 GetStringProperty(gsPropertyContent
, rPropSet
),
1124 ProcessValueAndType(IsStringField(nToken
, rPropSet
),
1125 GetIntProperty(gsPropertyNumberFormat
, rPropSet
),
1126 GetStringProperty(gsPropertyContent
, rPropSet
),
1128 GetDoubleProperty(gsPropertyValue
, rPropSet
),
1130 ! GetOptionalBoolProperty(
1131 gsPropertyIsFixedLanguage
,
1132 rPropSet
, xPropSetInfo
, false ) );
1133 ExportElement(XML_VARIABLE_INPUT
, sPresentation
);
1136 case FIELD_ID_USER_GET
:
1137 // user field: name, hidden, style
1139 bool bCmd
= GetBoolProperty(gsPropertyIsShowFormula
, rPropSet
);
1140 ProcessDisplay(GetBoolProperty(gsPropertyIsVisible
, rPropSet
),
1142 ProcessValueAndType(IsStringField(nToken
, rPropSet
),
1143 GetIntProperty(gsPropertyNumberFormat
, rPropSet
),
1144 "", u
"", 0.0, // values not used
1145 false, false, !bCmd
,
1146 ! GetOptionalBoolProperty(
1147 gsPropertyIsFixedLanguage
,
1148 rPropSet
, xPropSetInfo
, false ) );
1150 // name from FieldMaster
1151 ProcessString(XML_NAME
,
1152 GetStringProperty(gsPropertyName
,
1153 GetMasterPropertySet(rTextField
)));
1154 ExportElement(XML_USER_FIELD_GET
, sPresentation
);
1158 case FIELD_ID_USER_INPUT
:
1159 // user input field: name (from FieldMaster), description
1160 // ProcessString(XML_NAME,
1161 // GetStringProperty(sPropertyName,
1162 // GetMasterPropertySet(rTextField)));
1163 ProcessString(XML_NAME
,
1164 GetStringProperty(gsPropertyContent
, rPropSet
));
1165 ProcessString(XML_DESCRIPTION
,
1166 GetStringProperty(gsPropertyHint
, rPropSet
));
1167 ExportElement(XML_USER_FIELD_INPUT
, sPresentation
);
1170 case FIELD_ID_SEQUENCE
:
1172 // sequence field: name, formula, seq-format
1173 OUString sName
= GetStringProperty(gsPropertyVariableName
, rPropSet
);
1174 // TODO: use reference name only if actually being referenced.
1175 ProcessString(XML_REF_NAME
,
1176 MakeSequenceRefName(
1177 GetInt16Property(gsPropertySequenceValue
, rPropSet
),
1179 ProcessString(XML_NAME
, sName
);
1180 ProcessString(XML_FORMULA
, XML_NAMESPACE_OOOW
,
1181 GetStringProperty(gsPropertyContent
, rPropSet
),
1183 ProcessNumberingType(GetInt16Property(gsPropertyNumberingType
,
1185 ExportElement(XML_SEQUENCE
, sPresentation
);
1189 case FIELD_ID_EXPRESSION
:
1191 // formula field: formula, format&value
1192 bool bCmd
= GetBoolProperty(gsPropertyIsShowFormula
, rPropSet
);
1193 ProcessString(XML_FORMULA
, XML_NAMESPACE_OOOW
,
1194 GetStringProperty(gsPropertyContent
, rPropSet
),
1196 ProcessDisplay(true, bCmd
);
1197 ProcessValueAndType(IsStringField(nToken
, rPropSet
),
1198 GetIntProperty(gsPropertyNumberFormat
, rPropSet
),
1199 GetStringProperty(gsPropertyContent
, rPropSet
),
1201 GetDoubleProperty(gsPropertyValue
, rPropSet
),
1202 !bCmd
, !bCmd
, !bCmd
,
1203 ! GetOptionalBoolProperty(
1204 gsPropertyIsFixedLanguage
,
1205 rPropSet
, xPropSetInfo
, false ) );
1206 ExportElement(XML_EXPRESSION
, sPresentation
);
1210 case FIELD_ID_TEXT_INPUT
:
1211 // text input field: description and string-value
1212 ProcessString(XML_DESCRIPTION
,
1213 GetStringProperty(gsPropertyHint
, rPropSet
));
1214 ProcessString(XML_HELP
,
1215 GetStringProperty(gsPropertyHelp
, rPropSet
), true);
1216 ProcessString(XML_HINT
,
1217 GetStringProperty(gsPropertyTooltip
, rPropSet
), true);
1218 ExportElement(XML_TEXT_INPUT
, sPresentation
);
1222 // all properties (except IsDate) are optional!
1223 if (xPropSetInfo
->hasPropertyByName(gsPropertyNumberFormat
))
1225 ProcessValueAndType(false,
1226 GetIntProperty(gsPropertyNumberFormat
,rPropSet
),
1227 "", u
"", 0.0, // not used
1229 ! GetOptionalBoolProperty(
1230 gsPropertyIsFixedLanguage
,
1231 rPropSet
, xPropSetInfo
, false ),
1234 if (xPropSetInfo
->hasPropertyByName(gsPropertyDateTimeValue
))
1236 // no value -> current time
1237 ProcessTimeOrDateTime(XML_TIME_VALUE
,
1238 GetDateTimeProperty(gsPropertyDateTimeValue
,
1241 if (xPropSetInfo
->hasPropertyByName(gsPropertyDateTime
))
1243 // no value -> current time
1244 ProcessTimeOrDateTime(XML_TIME_VALUE
,
1245 GetDateTimeProperty(gsPropertyDateTime
,rPropSet
));
1247 if (xPropSetInfo
->hasPropertyByName(gsPropertyIsFixed
))
1249 ProcessBoolean(XML_FIXED
,
1250 GetBoolProperty(gsPropertyIsFixed
, rPropSet
),
1253 if (xPropSetInfo
->hasPropertyByName(gsPropertyAdjust
))
1255 // adjust value given as integer in minutes
1256 ProcessDateTime(XML_TIME_ADJUST
,
1257 GetIntProperty(gsPropertyAdjust
, rPropSet
),
1260 ExportElement(XML_TIME
, sPresentation
);
1264 // all properties (except IsDate) are optional!
1265 if (xPropSetInfo
->hasPropertyByName(gsPropertyNumberFormat
))
1267 ProcessValueAndType(false,
1268 GetIntProperty(gsPropertyNumberFormat
,rPropSet
),
1269 "", u
"", 0.0, // not used
1271 ! GetOptionalBoolProperty(
1272 gsPropertyIsFixedLanguage
,
1273 rPropSet
, xPropSetInfo
, false ) );
1275 if (xPropSetInfo
->hasPropertyByName(gsPropertyDateTimeValue
))
1277 // no value -> current date
1278 ProcessDateTime(XML_DATE_VALUE
,
1279 GetDateTimeProperty(gsPropertyDateTimeValue
,
1282 // TODO: remove double-handling after SRC614
1283 else if (xPropSetInfo
->hasPropertyByName(gsPropertyDateTime
))
1285 ProcessDateTime(XML_DATE_VALUE
,
1286 GetDateTimeProperty(gsPropertyDateTime
,rPropSet
));
1288 if (xPropSetInfo
->hasPropertyByName(gsPropertyIsFixed
))
1290 ProcessBoolean(XML_FIXED
,
1291 GetBoolProperty(gsPropertyIsFixed
, rPropSet
),
1294 if (xPropSetInfo
->hasPropertyByName(gsPropertyAdjust
))
1296 // adjust value given as number of days
1297 ProcessDateTime(XML_DATE_ADJUST
,
1298 GetIntProperty(gsPropertyAdjust
, rPropSet
),
1301 ExportElement(XML_DATE
, sPresentation
);
1304 case FIELD_ID_PAGENUMBER
:
1305 // all properties are optional
1306 if (xPropSetInfo
->hasPropertyByName(gsPropertyNumberingType
))
1308 ProcessNumberingType(GetInt16Property(gsPropertyNumberingType
,
1311 if (xPropSetInfo
->hasPropertyByName(gsPropertyOffset
))
1313 sal_Int32 nAdjust
= GetIntProperty(gsPropertyOffset
, rPropSet
);
1315 if (xPropSetInfo
->hasPropertyByName(gsPropertySubType
))
1317 // property SubType used in MapPageNumberName
1318 ProcessString(XML_SELECT_PAGE
,
1319 MapPageNumberName(rPropSet
, nAdjust
));
1321 ProcessIntegerDef(XML_PAGE_ADJUST
, nAdjust
, 0);
1323 ExportElement(XML_PAGE_NUMBER
, sPresentation
);
1326 case FIELD_ID_PAGESTRING
:
1328 ProcessString(XML_STRING_VALUE
,
1329 GetStringProperty(gsPropertyUserText
, rPropSet
),
1331 sal_Int32 nDummy
= 0; // MapPageNumberName need int
1332 ProcessString(XML_SELECT_PAGE
, MapPageNumberName(rPropSet
, nDummy
));
1333 ExportElement(XML_PAGE_CONTINUATION
, sPresentation
);
1337 case FIELD_ID_DATABASE_NAME
:
1338 ProcessString(XML_TABLE_NAME
,
1339 GetStringProperty(gsPropertyDataTableName
, rPropSet
));
1340 ProcessCommandType(GetIntProperty(gsPropertyDataCommandType
, rPropSet
));
1341 ProcessDisplay(GetBoolProperty(gsPropertyIsVisible
, rPropSet
),
1343 ExportDataBaseElement(XML_DATABASE_NAME
, sPresentation
,
1344 rPropSet
, xPropSetInfo
);
1347 case FIELD_ID_DATABASE_NUMBER
:
1348 ProcessString(XML_TABLE_NAME
,
1349 GetStringProperty(gsPropertyDataTableName
, rPropSet
));
1350 ProcessCommandType(GetIntProperty(gsPropertyDataCommandType
, rPropSet
));
1351 ProcessNumberingType(
1352 GetInt16Property(gsPropertyNumberingType
,rPropSet
));
1353 ProcessInteger(XML_VALUE
,
1354 GetIntProperty(gsPropertySetNumber
, rPropSet
));
1355 ProcessDisplay(GetBoolProperty(gsPropertyIsVisible
, rPropSet
),
1357 ExportDataBaseElement(XML_DATABASE_ROW_NUMBER
, sPresentation
,
1358 rPropSet
, xPropSetInfo
);
1361 case FIELD_ID_DATABASE_NEXT
:
1362 ProcessString(XML_TABLE_NAME
,
1363 GetStringProperty(gsPropertyDataTableName
, rPropSet
));
1364 ProcessCommandType(GetIntProperty(gsPropertyDataCommandType
, rPropSet
));
1365 ProcessString(XML_CONDITION
, XML_NAMESPACE_OOOW
,
1366 GetStringProperty(gsPropertyCondition
, rPropSet
));
1367 DBG_ASSERT(sPresentation
.isEmpty(),
1368 "Unexpected presentation for database next field");
1369 ExportDataBaseElement(XML_DATABASE_NEXT
, OUString(),
1370 rPropSet
, xPropSetInfo
);
1373 case FIELD_ID_DATABASE_SELECT
:
1374 ProcessString(XML_TABLE_NAME
,
1375 GetStringProperty(gsPropertyDataTableName
, rPropSet
));
1376 ProcessCommandType(GetIntProperty(gsPropertyDataCommandType
, rPropSet
));
1377 ProcessString(XML_CONDITION
, XML_NAMESPACE_OOOW
,
1378 GetStringProperty(gsPropertyCondition
, rPropSet
));
1379 ProcessInteger(XML_ROW_NUMBER
,
1380 GetIntProperty(gsPropertySetNumber
, rPropSet
));
1381 DBG_ASSERT(sPresentation
.isEmpty(),
1382 "Unexpected presentation for database select field");
1383 ExportDataBaseElement(XML_DATABASE_ROW_SELECT
, OUString(),
1384 rPropSet
, xPropSetInfo
);
1387 case FIELD_ID_DATABASE_DISPLAY
:
1389 // get database, table and column name from field master
1390 const Reference
<XPropertySet
> & xMaster
= GetMasterPropertySet(rTextField
);
1391 ProcessString(XML_TABLE_NAME
,
1392 GetStringProperty(gsPropertyDataTableName
, xMaster
));
1393 ProcessCommandType(GetIntProperty(gsPropertyDataCommandType
, xMaster
));
1394 ProcessString(XML_COLUMN_NAME
,
1395 GetStringProperty(gsPropertyDataColumnName
, xMaster
));
1396 // export number format if available (happens only for numbers!)
1397 if (!GetBoolProperty(gsPropertyIsDataBaseFormat
, rPropSet
))
1399 ProcessValueAndType(false, // doesn't happen for text
1400 GetIntProperty(gsPropertyNumberFormat
,rPropSet
),
1401 "", u
"", 0.0, // not used
1402 false, false, true, false);
1404 ProcessDisplay(GetBoolProperty(gsPropertyIsVisible
, rPropSet
),
1406 ExportDataBaseElement(XML_DATABASE_DISPLAY
, sPresentation
,
1407 xMaster
, xMaster
->getPropertySetInfo());
1411 case FIELD_ID_DOCINFO_REVISION
:
1412 ProcessBoolean(XML_FIXED
,
1413 GetBoolProperty(gsPropertyIsFixed
, rPropSet
), false);
1414 ExportElement(MapDocInfoFieldName(nToken
), sPresentation
);
1417 case FIELD_ID_DOCINFO_EDIT_DURATION
:
1418 case FIELD_ID_DOCINFO_SAVE_TIME
:
1419 case FIELD_ID_DOCINFO_CREATION_TIME
:
1420 case FIELD_ID_DOCINFO_PRINT_TIME
:
1421 case FIELD_ID_DOCINFO_SAVE_DATE
:
1422 case FIELD_ID_DOCINFO_CREATION_DATE
:
1423 case FIELD_ID_DOCINFO_PRINT_DATE
:
1424 ProcessValueAndType(false,
1425 GetIntProperty(gsPropertyNumberFormat
, rPropSet
),
1428 ! GetOptionalBoolProperty(
1429 gsPropertyIsFixedLanguage
,
1430 rPropSet
, xPropSetInfo
, false ) );
1432 // todo: export date/time value, but values not available -> core bug
1433 ProcessBoolean(XML_FIXED
,
1434 GetBoolProperty(gsPropertyIsFixed
, rPropSet
), false);
1435 ExportElement(MapDocInfoFieldName(nToken
), sPresentation
);
1438 case FIELD_ID_DOCINFO_CREATION_AUTHOR
:
1439 case FIELD_ID_DOCINFO_DESCRIPTION
:
1440 case FIELD_ID_DOCINFO_PRINT_AUTHOR
:
1441 case FIELD_ID_DOCINFO_TITLE
:
1442 case FIELD_ID_DOCINFO_SUBJECT
:
1443 case FIELD_ID_DOCINFO_KEYWORDS
:
1444 case FIELD_ID_DOCINFO_SAVE_AUTHOR
:
1445 if (xPropSetInfo
->hasPropertyByName(gsPropertyIsFixed
))
1447 ProcessBoolean(XML_FIXED
,
1448 GetBoolProperty(gsPropertyIsFixed
, rPropSet
), false);
1450 ExportElement(MapDocInfoFieldName(nToken
), sPresentation
);
1453 case FIELD_ID_DOCINFO_CUSTOM
:
1455 ProcessValueAndType(false, // doesn't happen for text
1456 GetIntProperty(gsPropertyNumberFormat
,rPropSet
),
1457 "", u
"", 0.0, // not used
1459 ! GetOptionalBoolProperty(
1460 gsPropertyIsFixedLanguage
,
1461 rPropSet
, xPropSetInfo
, false ));
1462 uno::Any aAny
= rPropSet
->getPropertyValue( gsPropertyName
);
1465 ProcessString(XML_NAME
, sName
);
1466 ProcessBoolean(XML_FIXED
, GetBoolProperty(gsPropertyIsFixed
, rPropSet
), false);
1467 ExportElement(XML_USER_DEFINED
, sPresentation
);
1471 case FIELD_ID_COUNT_PAGES
:
1472 case FIELD_ID_COUNT_PARAGRAPHS
:
1473 case FIELD_ID_COUNT_WORDS
:
1474 case FIELD_ID_COUNT_CHARACTERS
:
1475 case FIELD_ID_COUNT_TABLES
:
1476 case FIELD_ID_COUNT_GRAPHICS
:
1477 case FIELD_ID_COUNT_OBJECTS
:
1478 // all properties optional (applies to pages only, but I'll do
1479 // it for all for sake of common implementation)
1480 if (xPropSetInfo
->hasPropertyByName(gsPropertyNumberingType
))
1482 ProcessNumberingType(GetInt16Property(gsPropertyNumberingType
,
1485 ExportElement(MapCountFieldName(nToken
), sPresentation
);
1488 case FIELD_ID_CONDITIONAL_TEXT
:
1489 ProcessString(XML_CONDITION
, XML_NAMESPACE_OOOW
,
1490 GetStringProperty(gsPropertyCondition
, rPropSet
));
1491 ProcessString(XML_STRING_VALUE_IF_TRUE
,
1492 GetStringProperty(gsPropertyTrueContent
, rPropSet
));
1493 ProcessString(XML_STRING_VALUE_IF_FALSE
,
1494 GetStringProperty(gsPropertyFalseContent
, rPropSet
));
1495 ProcessBoolean(XML_CURRENT_VALUE
,
1496 GetBoolProperty(gsPropertyIsConditionTrue
, rPropSet
),
1498 ExportElement(XML_CONDITIONAL_TEXT
, sPresentation
);
1501 case FIELD_ID_HIDDEN_TEXT
:
1502 ProcessString(XML_CONDITION
, XML_NAMESPACE_OOOW
,
1503 GetStringProperty(gsPropertyCondition
, rPropSet
));
1504 ProcessString(XML_STRING_VALUE
,
1505 GetStringProperty(gsPropertyContent
, rPropSet
));
1506 ProcessBoolean(XML_IS_HIDDEN
,
1507 GetBoolProperty(gsPropertyIsHidden
, rPropSet
),
1509 ExportElement(XML_HIDDEN_TEXT
, sPresentation
);
1512 case FIELD_ID_HIDDEN_PARAGRAPH
:
1513 ProcessString(XML_CONDITION
, XML_NAMESPACE_OOOW
,
1514 GetStringProperty(gsPropertyCondition
, rPropSet
));
1515 ProcessBoolean(XML_IS_HIDDEN
,
1516 GetBoolProperty(gsPropertyIsHidden
, rPropSet
),
1518 DBG_ASSERT(sPresentation
.isEmpty(),
1519 "Unexpected presentation for hidden paragraph field");
1520 ExportElement(XML_HIDDEN_PARAGRAPH
);
1523 case FIELD_ID_TEMPLATE_NAME
:
1524 ProcessString(XML_DISPLAY
,
1525 MapTemplateDisplayFormat(
1526 GetInt16Property(gsPropertyFileFormat
, rPropSet
)));
1527 ExportElement(XML_TEMPLATE_NAME
, sPresentation
);
1530 case FIELD_ID_CHAPTER
:
1531 ProcessString(XML_DISPLAY
,
1532 MapChapterDisplayFormat(
1533 GetInt16Property(gsPropertyChapterFormat
, rPropSet
)));
1534 // API numbers 0..9, we number 1..10
1535 ProcessInteger(XML_OUTLINE_LEVEL
,
1536 GetInt8Property(gsPropertyLevel
, rPropSet
) + 1);
1537 ExportElement(XML_CHAPTER
, sPresentation
);
1540 case FIELD_ID_FILE_NAME
:
1541 // all properties are optional
1542 if (xPropSetInfo
->hasPropertyByName(gsPropertyFileFormat
))
1544 ProcessString(XML_DISPLAY
,
1545 MapFilenameDisplayFormat(
1546 GetInt16Property(gsPropertyFileFormat
, rPropSet
)));
1548 if (xPropSetInfo
->hasPropertyByName(gsPropertyIsFixed
))
1550 ProcessBoolean(XML_FIXED
,
1551 GetBoolProperty(gsPropertyIsFixed
, rPropSet
),
1554 ExportElement(XML_FILE_NAME
, sPresentation
);
1557 case FIELD_ID_REFPAGE_SET
:
1558 ProcessBoolean(XML_ACTIVE
,
1559 GetBoolProperty(gsPropertyOn
, rPropSet
), true);
1560 ProcessIntegerDef(XML_PAGE_ADJUST
,
1561 GetInt16Property(gsPropertyOffset
, rPropSet
), 0);
1562 DBG_ASSERT(sPresentation
.isEmpty(),
1563 "Unexpected presentation page variable field");
1564 ExportElement(XML_PAGE_VARIABLE_SET
);
1567 case FIELD_ID_REFPAGE_GET
:
1568 ProcessNumberingType(
1569 GetInt16Property(gsPropertyNumberingType
, rPropSet
));
1570 ExportElement(XML_PAGE_VARIABLE_GET
, sPresentation
);
1573 case FIELD_ID_MACRO
:
1574 ExportMacro( rPropSet
, sPresentation
);
1577 case FIELD_ID_REF_SEQUENCE
:
1578 // reference to sequence: format, name, find value (and element)
1579 // was: if (nSeqNumber != -1) ...
1580 ProcessString(XML_REFERENCE_FORMAT
,
1581 MapReferenceType(GetInt16Property(
1582 gsPropertyReferenceFieldPart
, rPropSet
)),
1584 ProcessString(XML_REF_NAME
,
1585 MakeSequenceRefName(
1586 GetInt16Property(gsPropertySequenceNumber
, rPropSet
),
1587 GetStringProperty(gsPropertySourceName
, rPropSet
) ) );
1588 if (xPropSetInfo
->hasPropertyByName(gsPropertyReferenceFieldLanguage
) &&
1589 GetExport().getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED
)
1591 // export text:reference-language attribute, if not empty
1592 ProcessString(XML_REFERENCE_LANGUAGE
,
1593 GetStringProperty(gsPropertyReferenceFieldLanguage
, rPropSet
), true, XML_NAMESPACE_LO_EXT
);
1597 GetInt16Property(gsPropertyReferenceFieldSource
, rPropSet
)),
1601 case FIELD_ID_REF_REFERENCE
:
1602 case FIELD_ID_REF_BOOKMARK
:
1603 // reference to bookmarks, references: format, name (and element)
1604 ProcessString(XML_REFERENCE_FORMAT
,
1605 MapReferenceType(GetInt16Property(
1606 gsPropertyReferenceFieldPart
, rPropSet
)),
1608 ProcessString(XML_REF_NAME
,
1609 GetStringProperty(gsPropertySourceName
, rPropSet
));
1610 if (xPropSetInfo
->hasPropertyByName(gsPropertyReferenceFieldLanguage
) &&
1611 GetExport().getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED
)
1613 // export text:reference-language attribute, if not empty
1614 ProcessString(XML_REFERENCE_LANGUAGE
,
1615 GetStringProperty(gsPropertyReferenceFieldLanguage
, rPropSet
), true, XML_NAMESPACE_LO_EXT
);
1618 MapReferenceSource(GetInt16Property(
1619 gsPropertyReferenceFieldSource
, rPropSet
)),
1623 case FIELD_ID_REF_FOOTNOTE
:
1624 case FIELD_ID_REF_ENDNOTE
:
1625 // reference to end-/footnote: format, generate name, (and element)
1626 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_NOTE_CLASS
,
1627 FIELD_ID_REF_ENDNOTE
==nToken
? XML_ENDNOTE
: XML_FOOTNOTE
);
1628 ProcessString(XML_REFERENCE_FORMAT
,
1629 MapReferenceType(GetInt16Property(
1630 gsPropertyReferenceFieldPart
, rPropSet
)),
1632 ProcessString(XML_REF_NAME
,
1633 MakeFootnoteRefName(GetInt16Property(
1634 gsPropertySequenceNumber
, rPropSet
)));
1635 if (xPropSetInfo
->hasPropertyByName(gsPropertyReferenceFieldLanguage
) &&
1636 GetExport().getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED
)
1638 // export text:reference-language attribute, if not empty
1639 ProcessString(XML_REFERENCE_LANGUAGE
,
1640 GetStringProperty(gsPropertyReferenceFieldLanguage
, rPropSet
), true, XML_NAMESPACE_LO_EXT
);
1643 MapReferenceSource(GetInt16Property(
1644 gsPropertyReferenceFieldSource
, rPropSet
)),
1649 // name from field master
1650 ProcessString(XML_CONNECTION_NAME
,
1652 GetStringProperty(gsPropertyName
,
1653 GetMasterPropertySet(rTextField
)));
1654 ExportElement(XML_DDE_CONNECTION
, sPresentation
);
1657 case FIELD_ID_SHEET_NAME
:
1658 // name of spreadsheet (Calc only)
1659 ExportElement(XML_SHEET_NAME
, sPresentation
);
1662 case FIELD_ID_PAGENAME
:
1664 if (GetExport().getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED
)
1666 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_LO_EXT
, XML_PAGE_NAME
, false, false );
1667 GetExport().Characters( sPresentation
);
1674 // this field is a special case because it gets mapped onto a
1675 // hyperlink, rather than one of the regular text field.
1676 ProcessString(XML_HREF
, GetExport().GetRelativeReference(GetStringProperty(gsPropertyURL
, rPropSet
)),
1677 false, XML_NAMESPACE_XLINK
);
1678 ProcessString(XML_TARGET_FRAME_NAME
,
1679 GetStringProperty(gsPropertyTargetFrame
,rPropSet
),
1680 true, XML_NAMESPACE_OFFICE
);
1681 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_TYPE
, XML_SIMPLE
);
1682 SvXMLElementExport
aUrlField(rExport
, XML_NAMESPACE_TEXT
, XML_A
,
1684 GetExport().Characters(sPresentation
);
1688 case FIELD_ID_BIBLIOGRAPHY
:
1690 ProcessBibliographyData(rPropSet
);
1691 ExportElement(XML_BIBLIOGRAPHY_MARK
, sPresentation
);
1695 case FIELD_ID_SCRIPT
:
1696 ProcessString(XML_LANGUAGE
,
1697 GetStringProperty(gsPropertyScriptType
, rPropSet
),
1698 true, XML_NAMESPACE_SCRIPT
);
1699 DBG_ASSERT(sPresentation
.isEmpty(),
1700 "Unexpected presentation for script field");
1701 if (GetBoolProperty(gsPropertyURLContent
, rPropSet
))
1703 ProcessString(XML_HREF
,
1704 GetExport().GetRelativeReference(GetStringProperty(gsPropertyContent
, rPropSet
)),
1705 false, XML_NAMESPACE_XLINK
);
1706 ExportElement(XML_SCRIPT
);
1710 ExportElement(XML_SCRIPT
,
1711 GetStringProperty(gsPropertyContent
, rPropSet
));
1715 case FIELD_ID_ANNOTATION
:
1717 // check for empty presentation (just in case)
1718 DBG_ASSERT(sPresentation
.isEmpty(),
1719 "Unexpected presentation for annotation field");
1721 bool bRemovePersonalInfo
= SvtSecurityOptions::IsOptionSet(
1722 SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo
);
1724 // annotation element + content
1726 rPropSet
->getPropertyValue(gsPropertyName
) >>= aName
;
1727 if (!aName
.isEmpty())
1729 GetExport().AddAttribute(XML_NAMESPACE_OFFICE
, XML_NAME
, aName
);
1731 SvtSaveOptions::ODFSaneDefaultVersion eVersion
= rExport
.getSaneDefaultVersion();
1732 if (eVersion
& SvtSaveOptions::ODFSVER_EXTENDED
)
1734 bool b
= GetBoolProperty("Resolved", rPropSet
);
1735 OUString aResolvedText
;
1736 OUStringBuffer aResolvedTextBuffer
;
1737 ::sax::Converter::convertBool(aResolvedTextBuffer
, b
);
1738 aResolvedText
= aResolvedTextBuffer
.makeStringAndClear();
1740 GetExport().AddAttribute(XML_NAMESPACE_LO_EXT
, XML_RESOLVED
, aResolvedText
);
1742 SvXMLElementExport
aElem(GetExport(), XML_NAMESPACE_OFFICE
,
1743 XML_ANNOTATION
, false, true);
1746 OUString
aAuthor( GetStringProperty(gsPropertyAuthor
, rPropSet
) );
1747 if( !aAuthor
.isEmpty() )
1749 SvXMLElementExport
aCreatorElem( GetExport(), XML_NAMESPACE_DC
,
1752 GetExport().Characters( bRemovePersonalInfo
1753 ? "Author" + OUString::number( rExport
.GetInfoID(aAuthor
) )
1758 util::DateTime
aDate( GetDateTimeProperty(gsPropertyDateTimeValue
, rPropSet
) );
1759 if ( !bRemovePersonalInfo
)
1761 OUStringBuffer aBuffer
;
1762 ::sax::Converter::convertDateTime(aBuffer
, aDate
, nullptr, true);
1763 SvXMLElementExport
aDateElem( GetExport(), XML_NAMESPACE_DC
,
1766 GetExport().Characters(aBuffer
.makeStringAndClear());
1769 if (GetExport().getSaneDefaultVersion() > SvtSaveOptions::ODFSVER_012
)
1772 OUString
aInitials( GetStringProperty(gsPropertyInitials
, rPropSet
) );
1773 if( !aInitials
.isEmpty() )
1775 // ODF 1.3 OFFICE-3776 export meta:creator-initials for ODF 1.3
1776 SvXMLElementExport
aCreatorElem( GetExport(),
1777 (SvtSaveOptions::ODFSVER_013
<= GetExport().getSaneDefaultVersion())
1778 ? XML_NAMESPACE_META
1779 : XML_NAMESPACE_LO_EXT
,
1781 (SvtSaveOptions::ODFSVER_013
<= GetExport().getSaneDefaultVersion())
1782 ? XML_CREATOR_INITIALS
1783 : XML_SENDER_INITIALS
,
1785 GetExport().Characters( bRemovePersonalInfo
1786 ? OUString::number( rExport
.GetInfoID(aInitials
) )
1791 css::uno::Reference
< css::text::XText
> xText
;
1794 css::uno::Any aRet
= rPropSet
->getPropertyValue(gsPropertyTextRange
);
1797 catch ( css::uno::Exception
& )
1801 GetExport().GetTextParagraphExport()->exportText( xText
);
1803 ProcessParagraphSequence(GetStringProperty(gsPropertyContent
,rPropSet
));
1807 case FIELD_ID_COMBINED_CHARACTERS
:
1809 // The style with the combined characters attribute has
1810 // already been handled in the ExportField method. So all that
1811 // is left to do now is to export the characters.
1812 GetExport().Characters(sPresentation
);
1818 ExportMetaField(rPropSet
, false, bProgress
, rPrevCharIsSpace
);
1822 case FIELD_ID_MEASURE
:
1824 ProcessString(XML_KIND
, MapMeasureKind(GetInt16Property(gsPropertyMeasureKind
, rPropSet
)));
1825 ExportElement( XML_MEASURE
, sPresentation
);
1829 case FIELD_ID_TABLE_FORMULA
:
1830 ProcessString( XML_FORMULA
, XML_NAMESPACE_OOOW
,
1831 GetStringProperty(gsPropertyContent
, rPropSet
) );
1832 ProcessDisplay( true,
1833 GetBoolProperty(gsPropertyIsShowFormula
, rPropSet
) );
1834 ProcessValueAndType( false,
1835 GetIntProperty(gsPropertyNumberFormat
, rPropSet
),
1839 ExportElement( XML_TABLE_FORMULA
, sPresentation
);
1842 case FIELD_ID_DROP_DOWN
:
1844 // tdf#133555 don't export in strict ODF versions that don't have it
1845 if (GetExport().getSaneDefaultVersion() <= SvtSaveOptions::ODFSVER_012
)
1849 ProcessString(XML_NAME
, GetStringProperty(gsPropertyName
, rPropSet
));
1850 ProcessString(XML_HELP
,
1851 GetStringProperty(gsPropertyHelp
, rPropSet
), true);
1852 ProcessString(XML_HINT
,
1853 GetStringProperty(gsPropertyTooltip
, rPropSet
), true);
1854 SvXMLElementExport
aElem( GetExport(),
1855 XML_NAMESPACE_TEXT
, XML_DROP_DOWN
,
1857 ProcessStringSequence
1858 (GetStringSequenceProperty( gsPropertyItems
, rPropSet
),
1859 GetStringProperty( gsPropertySelectedItem
, rPropSet
) );
1861 GetExport().Characters( sPresentation
);
1865 case FIELD_ID_DRAW_HEADER
:
1867 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_PRESENTATION
, XML_HEADER
, false, false );
1871 case FIELD_ID_DRAW_FOOTER
:
1873 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_PRESENTATION
, XML_FOOTER
, false, false );
1877 case FIELD_ID_DRAW_DATE_TIME
:
1879 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_PRESENTATION
, XML_DATE_TIME
, false, false );
1884 case FIELD_ID_UNKNOWN
:
1886 OSL_FAIL("unknown field type encountered!");
1887 // always export content
1888 GetExport().Characters(sPresentation
);
1893 /// export field declarations / field masters
1894 void XMLTextFieldExport::ExportFieldDeclarations()
1896 Reference
<XText
> xEmptyText
;
1897 ExportFieldDeclarations(xEmptyText
);
1900 /// export field declarations / field masters
1901 void XMLTextFieldExport::ExportFieldDeclarations(
1902 const Reference
<XText
> & rText
)
1904 // store lists for decl elements
1905 std::vector
<OUString
> aVarName
;
1906 std::vector
<OUString
> aUserName
;
1907 std::vector
<OUString
> aSeqName
;
1908 std::vector
<OUString
> aDdeName
;
1910 // get text fields supplier and field master name access
1911 Reference
<XTextFieldsSupplier
> xTextFieldsSupp(GetExport().GetModel(),
1913 if( !xTextFieldsSupp
.is() )
1916 Reference
<container::XNameAccess
> xFieldMasterNameAccess
=
1917 xTextFieldsSupp
->getTextFieldMasters();
1919 // where to get the text field masters from?
1920 // a) we get a specific XText: then use pUsedMasters
1921 // b) the XText is empty: then export all text fields
1922 Sequence
<OUString
> aFieldMasters
;
1925 // export only used masters
1926 DBG_ASSERT(nullptr != pUsedMasters
,
1927 "field masters must be recorded in order to be "
1928 "written out separately" );
1929 if (nullptr != pUsedMasters
)
1931 std::map
<Reference
<XText
>, std::set
<OUString
> > ::iterator aMapIter
=
1932 pUsedMasters
->find(rText
);
1933 if (aMapIter
!= pUsedMasters
->end())
1935 // found the set of used field masters
1936 aFieldMasters
= comphelper::containerToSequence(aMapIter
->second
);
1937 pUsedMasters
->erase(rText
);
1939 // else: XText not found -> ignore
1941 // else: no field masters have been recorded -> ignore
1945 // no XText: export all!
1946 aFieldMasters
= xFieldMasterNameAccess
->getElementNames();
1949 for(const OUString
& sFieldMaster
: std::as_const(aFieldMasters
)) {
1951 // workaround for #no-bug#
1952 if ( sFieldMaster
.startsWithIgnoreAsciiCase(
1953 "com.sun.star.text.FieldMaster.DataBase.") )
1959 OUString sFieldMasterType
;
1961 ExplodeFieldMasterName(sFieldMaster
, sFieldMasterType
, sVarName
);
1963 // get XPropertySet of this field master
1964 Reference
<XPropertySet
> xPropSet
;
1965 Any aAny
= xFieldMasterNameAccess
->getByName(sFieldMaster
);
1968 // save interesting field masters
1969 if (sFieldMasterType
== FIELD_SERVICE_SETEXP
)
1971 sal_Int32 nType
= GetIntProperty(gsPropertySubType
, xPropSet
);
1973 // sequence or variable?
1974 if ( SetVariableType::SEQUENCE
== nType
)
1976 aSeqName
.push_back( sFieldMaster
);
1980 aVarName
.push_back( sFieldMaster
);
1983 else if (sFieldMasterType
== FIELD_SERVICE_USER
)
1985 aUserName
.push_back( sFieldMaster
);
1987 else if (sFieldMasterType
== FIELD_SERVICE_DDE
)
1989 aDdeName
.push_back( sFieldMaster
);
1997 // now process fields:
1999 // variable field masters:
2000 if ( !aVarName
.empty() )
2002 SvXMLElementExport
aElem( GetExport(),
2007 for (const auto& sName
: aVarName
)
2009 // get field master property set
2010 Reference
<XPropertySet
> xPropSet
;
2011 Any aAny
= xFieldMasterNameAccess
->getByName(sName
);
2014 // field name and type
2015 OUString sFieldMasterType
;
2017 ExplodeFieldMasterName(sName
, sFieldMasterType
, sVarName
);
2019 // determine string/numeric field
2020 bool bIsString
= ( GetIntProperty(gsPropertySubType
, xPropSet
)
2021 == SetVariableType::STRING
);
2023 // get dependent field property set
2024 Reference
<XPropertySet
> xFieldPropSet
;
2025 if (GetDependentFieldPropertySet(xPropSet
, xFieldPropSet
))
2027 // process value and type.
2028 ProcessValueAndType(
2030 GetIntProperty(gsPropertyNumberFormat
, xFieldPropSet
),
2032 false, true, false, false);
2036 // If no dependent field is found, only string and
2037 // float types can be supported
2039 // number format: 0 is default number format for 1st
2040 // language. should be: getDefaultNumberFormat(Locale)
2041 // from NumberFormats
2042 ProcessValueAndType(
2045 false, true, false, false);
2048 ProcessString(XML_NAME
, sVarName
);
2049 ExportElement(XML_VARIABLE_DECL
, true);
2052 // else: no declarations element
2054 // sequence field masters:
2055 if ( !aSeqName
.empty() )
2057 SvXMLElementExport
aElem( GetExport(),
2062 for (const auto& sName
: aSeqName
)
2064 // get field master property set
2065 Reference
<XPropertySet
> xPropSet
;
2066 Any aAny
= xFieldMasterNameAccess
->getByName(sName
);
2069 // field name and type
2070 OUString sFieldMasterType
;
2072 ExplodeFieldMasterName(sName
, sFieldMasterType
, sVarName
);
2075 sal_Int32 nLevel
= 1 + GetIntProperty(
2076 gsPropertyChapterNumberingLevel
, xPropSet
);
2077 DBG_ASSERT(nLevel
>= 0, "illegal outline level");
2078 DBG_ASSERT(nLevel
< 127, "possible illegal outline level");
2079 ProcessInteger(XML_DISPLAY_OUTLINE_LEVEL
, nLevel
);
2081 // separation character
2083 ProcessString(XML_SEPARATION_CHARACTER
, GetStringProperty(
2084 gsPropertyNumberingSeparator
, xPropSet
));
2086 ProcessString(XML_NAME
, sVarName
);
2087 ExportElement(XML_SEQUENCE_DECL
, true);
2090 // else: no declarations element
2092 // user field masters:
2093 if ( !aUserName
.empty() )
2095 SvXMLElementExport
aElem( GetExport(),
2097 XML_USER_FIELD_DECLS
,
2100 for (const auto& sName
: aUserName
)
2102 // get field master property set
2103 Reference
<XPropertySet
> xPropSet
;
2104 Any aAny
= xFieldMasterNameAccess
->getByName(sName
);
2107 // field name and type
2108 OUString sFieldMasterType
;
2110 ExplodeFieldMasterName(sName
, sFieldMasterType
, sVarName
);
2112 if (GetBoolProperty(gsPropertyIsExpression
, xPropSet
))
2115 ProcessValueAndType(
2118 GetDoubleProperty(gsPropertyValue
, xPropSet
),
2126 // string: write regardless of default
2127 ProcessString(XML_VALUE_TYPE
, XML_STRING
,
2128 XML_NAMESPACE_OFFICE
);
2129 ProcessString(XML_STRING_VALUE
,
2130 GetStringProperty(gsPropertyContent
, xPropSet
),
2131 false, XML_NAMESPACE_OFFICE
);
2133 ProcessString(XML_NAME
, sVarName
);
2134 ExportElement(XML_USER_FIELD_DECL
, true);
2137 // else: no declarations element
2139 // DDE field masters:
2140 if ( aDdeName
.empty() )
2143 SvXMLElementExport
aElem( GetExport(),
2145 XML_DDE_CONNECTION_DECLS
,
2148 for (const auto& sName
: aDdeName
)
2150 // get field master property set
2151 Reference
<XPropertySet
> xPropSet
;
2152 Any aAny
= xFieldMasterNameAccess
->getByName(sName
);
2155 // check if this connection is being used by a field
2156 Reference
<XPropertySet
> xDummy
;
2157 if (GetDependentFieldPropertySet(xPropSet
, xDummy
))
2160 ProcessString(XML_NAME
,
2161 GetStringProperty(gsPropertyName
, xPropSet
),
2162 false, XML_NAMESPACE_OFFICE
);
2164 // export elements; can't use ProcessString because
2165 // elements are in office namespace
2166 ProcessString(XML_DDE_APPLICATION
,
2167 GetStringProperty(gsPropertyDDECommandType
,
2169 false, XML_NAMESPACE_OFFICE
);
2170 ProcessString(XML_DDE_TOPIC
,
2171 GetStringProperty(gsPropertyDDECommandFile
,
2173 false, XML_NAMESPACE_OFFICE
);
2174 ProcessString(XML_DDE_ITEM
,
2175 GetStringProperty(gsPropertyDDECommandElement
,
2177 false, XML_NAMESPACE_OFFICE
);
2178 bool bIsAutomaticUpdate
= GetBoolProperty(
2179 gsPropertyIsAutomaticUpdate
, xPropSet
);
2180 if (bIsAutomaticUpdate
)
2182 GetExport().AddAttribute(XML_NAMESPACE_OFFICE
,
2183 XML_AUTOMATIC_UPDATE
,
2187 ExportElement(XML_DDE_CONNECTION_DECL
, true);
2189 // else: no dependent field -> no export of field declaration
2191 // else: no declarations element
2194 void XMLTextFieldExport::SetExportOnlyUsedFieldDeclarations(
2195 bool bExportOnlyUsed
)
2197 pUsedMasters
.reset();
2199 // create used masters set (if none is used)
2200 if (bExportOnlyUsed
)
2201 pUsedMasters
.reset( new std::map
<Reference
<XText
>, std::set
<OUString
> > );
2204 void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName
,
2207 // can't call ExportElement(eElementName, const OUString&) with empty
2208 // string because xmlprinter only uses empty tags if no content
2209 // (not even empty content) was written.
2211 DBG_ASSERT(XML_TOKEN_INVALID
!= eElementName
, "invalid element name!");
2212 if (XML_TOKEN_INVALID
!= eElementName
)
2215 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
2216 eElementName
, bAddSpace
, bAddSpace
);
2220 void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName
,
2221 const OUString
& sContent
)
2223 DBG_ASSERT(eElementName
!= XML_TOKEN_INVALID
, "invalid element name!");
2224 if (eElementName
!= XML_TOKEN_INVALID
)
2227 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
2228 eElementName
, false, false );
2230 GetExport().Characters(sContent
);
2232 // always export content
2233 GetExport().Characters(sContent
);
2237 void XMLTextFieldExport::ExportMacro(
2238 const Reference
<XPropertySet
> & rPropSet
,
2239 const OUString
& rContent
)
2241 // some strings we'll need
2242 OUString
sEventType( "EventType" );
2245 // the description attribute
2246 ProcessString(XML_DESCRIPTION
,
2247 GetStringProperty(gsPropertyHint
, rPropSet
),
2251 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
2252 XML_EXECUTE_MACRO
, false, false );
2254 // the <office:events>-macro:
2256 // 1) build sequence of PropertyValues
2257 Sequence
<PropertyValue
> aSeq
;
2259 rPropSet
->getPropertyValue("ScriptURL") >>= sName
;
2261 // if the ScriptURL property is not empty then this is a Scripting
2262 // Framework URL, otherwise treat it as a Basic Macro
2263 if (!sName
.isEmpty())
2265 OUString
sScript( "Script" );
2266 aSeq
= Sequence
<PropertyValue
>
2268 comphelper::makePropertyValue(sEventType
, sScript
),
2269 comphelper::makePropertyValue(sScript
, sName
)
2274 aSeq
= Sequence
<PropertyValue
>
2276 comphelper::makePropertyValue(sEventType
, OUString("StarBasic")),
2277 comphelper::makePropertyValue("Library", rPropSet
->getPropertyValue( "MacroLibrary" )),
2278 comphelper::makePropertyValue("MacroName", rPropSet
->getPropertyValue( "MacroName" ))
2282 // 2) export the sequence
2283 GetExport().GetEventExport().ExportSingleEvent( aSeq
, "OnClick", false );
2285 // and finally, the field presentation
2286 GetExport().Characters(rContent
);
2289 void XMLTextFieldExport::ExportMetaField(
2290 const Reference
<XPropertySet
> & i_xMeta
,
2291 bool i_bAutoStyles
, bool i_bProgress
,
2292 bool & rPrevCharIsSpace
)
2294 bool doExport(!i_bAutoStyles
); // do not export element if autostyles
2295 // check version >= 1.2
2296 switch (GetExport().getSaneDefaultVersion()) {
2297 case SvtSaveOptions::ODFSVER_011
: // fall through
2298 case SvtSaveOptions::ODFSVER_010
: doExport
= false; break;
2302 const Reference
< XEnumerationAccess
> xEA( i_xMeta
, UNO_QUERY_THROW
);
2303 const Reference
< XEnumeration
> xTextEnum( xEA
->createEnumeration() );
2307 const Reference
<rdf::XMetadatable
> xMeta( i_xMeta
, UNO_QUERY_THROW
);
2309 // style:data-style-name
2310 ProcessValueAndType(false,
2311 GetIntProperty(gsPropertyNumberFormat
, i_xMeta
),
2312 "", u
"", 0.0, false, false, true,
2315 // text:meta-field without xml:id is invalid
2316 xMeta
->ensureMetadataReference();
2318 // xml:id for RDF metadata
2319 GetExport().AddAttributeXmlId(xMeta
);
2322 SvXMLElementExport
aElem( GetExport(), doExport
,
2323 XML_NAMESPACE_TEXT
, XML_META_FIELD
, false, false );
2325 // recurse to export content
2326 GetExport().GetTextParagraphExport()->
2327 exportTextRangeEnumeration(xTextEnum
, i_bAutoStyles
, i_bProgress
, rPrevCharIsSpace
);
2330 /// export all data-style related attributes
2331 void XMLTextFieldExport::ProcessValueAndType(
2332 bool bIsString
, /// do we process a string or a number?
2333 sal_Int32 nFormatKey
, /// format key for NumberFormatter; inv. if string
2334 const OUString
& sContent
, /// string content; possibly invalid
2335 std::u16string_view sDefault
, /// default string
2336 double fValue
, /// float content; possibly invalid
2337 bool bExportValue
, /// export value attribute?
2338 bool bExportValueType
, /// export value-type attribute?
2339 bool bExportStyle
, /// export style-attribute?
2340 bool bForceSystemLanguage
, /// export language attributes?
2341 bool bTimeStyle
) // exporting a time style?
2343 // String or number?
2347 // string: attributes value-type=string, string-value=...
2349 if (bExportValue
|| bExportValueType
)
2351 XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes(
2352 GetExport(), sContent
, sDefault
, bExportValue
);
2359 // number: value-type=..., value...=..., data-style-name=...
2361 DBG_ASSERT(bExportValueType
|| !bExportValue
, "value w/o value type not supported!");
2363 // take care of illegal formats
2364 // (shouldn't happen, but does if document is corrupted)
2365 if (-1 != nFormatKey
)
2367 if (bExportValue
|| bExportValueType
)
2369 XMLNumberFormatAttributesExportHelper::
2370 SetNumberFormatAttributes(
2371 GetExport(), nFormatKey
, fValue
, bExportValue
);
2376 // don't export language (if desired)
2377 if( bForceSystemLanguage
)
2379 GetExport().dataStyleForceSystemLanguage( nFormatKey
);
2381 OUString sDataStyleName
=
2382 GetExport().getDataStyleName(nFormatKey
, bTimeStyle
);
2383 if( !sDataStyleName
.isEmpty() )
2385 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
2386 XML_DATA_STYLE_NAME
,
2388 } // else: ignore (no valid number format)
2389 } // else: ignore (no number format)
2395 /// process display related properties
2396 void XMLTextFieldExport::ProcessDisplay(bool bIsVisible
,
2399 enum XMLTokenEnum eValue
;
2403 eValue
= bIsCommand
? XML_FORMULA
: XML_VALUE
;
2410 // omit attribute if default
2411 if (eValue
!= XML_VALUE
)
2413 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_DISPLAY
, eValue
);
2418 /// export boolean property
2419 void XMLTextFieldExport::ProcessBoolean(enum XMLTokenEnum eName
,
2420 bool bBool
, bool bDefault
)
2422 SAL_WARN_IF( eName
== XML_TOKEN_INVALID
, "xmloff.text", "invalid element token");
2423 if ( XML_TOKEN_INVALID
== eName
)
2426 // write attribute (if different than default)
2427 // negate to force 0/1 values (and make sal_Bool comparable)
2428 if ((!bBool
) != (!bDefault
)) {
2429 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, eName
,
2430 (bBool
? XML_TRUE
: XML_FALSE
) );
2435 /// export string attribute
2436 void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName
,
2437 const OUString
& sValue
,
2441 SAL_WARN_IF( eName
== XML_TOKEN_INVALID
, "xmloff.text", "invalid element token");
2442 if ( XML_TOKEN_INVALID
== eName
)
2445 // check for empty string, if applicable
2446 if ( bOmitEmpty
&& sValue
.isEmpty() )
2450 GetExport().AddAttribute(nPrefix
, eName
, sValue
);
2453 void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName
,
2454 sal_uInt16 nValuePrefix
,
2455 const OUString
& sValue
)
2458 GetExport().GetNamespaceMap().GetQNameByKey( nValuePrefix
, sValue
, false );
2459 ProcessString( eName
, sQValue
);
2462 /// export a string attribute
2463 void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName
,
2464 const OUString
& sValue
,
2465 std::u16string_view sDefault
)
2467 if (sValue
!= sDefault
)
2469 ProcessString(eName
, sValue
);
2473 /// export a string attribute
2474 void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName
,
2475 sal_uInt16 nValuePrefix
,
2476 const OUString
& sValue
,
2477 std::u16string_view sDefault
)
2479 if (sValue
!= sDefault
)
2481 ProcessString(eName
, nValuePrefix
, sValue
);
2486 /// export string attribute
2487 void XMLTextFieldExport::ProcessString(
2488 enum XMLTokenEnum eName
,
2489 enum XMLTokenEnum eValue
,
2492 SAL_WARN_IF( eName
== XML_TOKEN_INVALID
, "xmloff.text", "invalid element token" );
2493 SAL_WARN_IF( eValue
== XML_TOKEN_INVALID
, "xmloff.text", "invalid value token" );
2494 if ( XML_TOKEN_INVALID
== eName
)
2497 GetExport().AddAttribute(nPrefix
, eName
, eValue
);
2500 /// export a string attribute
2501 void XMLTextFieldExport::ProcessString(
2502 enum XMLTokenEnum eName
,
2503 enum XMLTokenEnum eValue
,
2504 enum XMLTokenEnum eDefault
)
2506 if ( eValue
!= eDefault
)
2507 ProcessString( eName
, eValue
);
2511 /// export a string as a sequence of paragraphs
2512 void XMLTextFieldExport::ProcessParagraphSequence(
2513 std::u16string_view sParagraphSequence
)
2515 // iterate over all string-pieces separated by return (0x0a) and
2516 // put each inside a paragraph element.
2517 SvXMLTokenEnumerator
aEnumerator(sParagraphSequence
, char(0x0a));
2518 std::u16string_view aSubString
;
2519 while (aEnumerator
.getNextToken(aSubString
))
2521 SvXMLElementExport
aParagraph(
2522 GetExport(), XML_NAMESPACE_TEXT
, XML_P
, true, false);
2523 GetExport().Characters(OUString(aSubString
));
2527 // export an integer attribute
2528 void XMLTextFieldExport::ProcessInteger(enum XMLTokenEnum eName
,
2531 SAL_WARN_IF( eName
== XML_TOKEN_INVALID
, "xmloff.text", "invalid element token");
2532 if ( XML_TOKEN_INVALID
== eName
)
2535 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, eName
,
2536 OUString::number(nNum
));
2539 /// export an integer attribute, omit if default
2540 void XMLTextFieldExport::ProcessIntegerDef(enum XMLTokenEnum eName
,
2541 sal_Int32 nNum
, sal_Int32 nDefault
)
2543 if (nNum
!= nDefault
)
2544 ProcessInteger(eName
, nNum
);
2548 /// export a numbering type
2549 void XMLTextFieldExport::ProcessNumberingType(sal_Int16 nNumberingType
)
2551 // process only if real format (not: like page descriptor)
2552 if (NumberingType::PAGE_DESCRIPTOR
== nNumberingType
)
2555 OUStringBuffer
sTmp( 10 );
2556 // number type: num format
2557 GetExport().GetMM100UnitConverter().convertNumFormat( sTmp
,
2559 GetExport().AddAttribute(XML_NAMESPACE_STYLE
, XML_NUM_FORMAT
,
2560 sTmp
.makeStringAndClear() );
2561 // and letter sync, if applicable
2562 SvXMLUnitConverter::convertNumLetterSync( sTmp
, nNumberingType
);
2564 if (!sTmp
.isEmpty())
2566 GetExport().AddAttribute(XML_NAMESPACE_STYLE
, XML_NUM_LETTER_SYNC
,
2567 sTmp
.makeStringAndClear() );
2569 // else: like page descriptor => ignore
2573 /// export a date, time, or duration
2574 void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName
,
2578 bool bOmitDurationIfZero
,
2581 // truncate for date granularity
2584 dValue
= ::rtl::math::approxFloor(dValue
);
2587 OUStringBuffer aBuffer
;
2590 // date/time duration handle bOmitDurationIfZero
2591 if (!bOmitDurationIfZero
|| dValue
!= 0.0)
2593 ::sax::Converter::convertDuration(aBuffer
, dValue
);
2599 rExport
.GetMM100UnitConverter().convertDateTime(aBuffer
, dValue
);
2603 ProcessString(eName
, aBuffer
.makeStringAndClear(), true, nPrefix
);
2606 /// export a date or time
2607 void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName
,
2608 const util::DateTime
& rTime
)
2610 OUStringBuffer aBuffer
;
2612 util::DateTime
aDateTime(rTime
);
2615 ::sax::Converter::convertDateTime(aBuffer
, aDateTime
, nullptr);
2618 ProcessString(eName
, aBuffer
.makeStringAndClear(), true);
2621 /// export a date, time, or duration
2622 void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName
,
2627 // handle bOmitDurationIfZero here, because we can precisely compare ints
2628 if (!(bIsDuration
&& (nMinutes
==0)))
2630 ProcessDateTime(eName
, static_cast<double>(nMinutes
) / double(24*60),
2631 bIsDate
, bIsDuration
);
2635 /// export a time or dateTime
2636 void XMLTextFieldExport::ProcessTimeOrDateTime(enum XMLTokenEnum eName
,
2637 const util::DateTime
& rTime
)
2639 OUStringBuffer aBuffer
;
2642 ::sax::Converter::convertTimeOrDateTime(aBuffer
, rTime
);
2645 ProcessString(eName
, aBuffer
.makeStringAndClear(), true);
2649 SvXMLEnumMapEntry
<sal_Int16
> const aBibliographyDataTypeMap
[] =
2651 { XML_ARTICLE
, BibliographyDataType::ARTICLE
},
2652 { XML_BOOK
, BibliographyDataType::BOOK
},
2653 { XML_BOOKLET
, BibliographyDataType::BOOKLET
},
2654 { XML_CONFERENCE
, BibliographyDataType::CONFERENCE
},
2655 { XML_CUSTOM1
, BibliographyDataType::CUSTOM1
},
2656 { XML_CUSTOM2
, BibliographyDataType::CUSTOM2
},
2657 { XML_CUSTOM3
, BibliographyDataType::CUSTOM3
},
2658 { XML_CUSTOM4
, BibliographyDataType::CUSTOM4
},
2659 { XML_CUSTOM5
, BibliographyDataType::CUSTOM5
},
2660 { XML_EMAIL
, BibliographyDataType::EMAIL
},
2661 { XML_INBOOK
, BibliographyDataType::INBOOK
},
2662 { XML_INCOLLECTION
, BibliographyDataType::INCOLLECTION
},
2663 { XML_INPROCEEDINGS
, BibliographyDataType::INPROCEEDINGS
},
2664 { XML_JOURNAL
, BibliographyDataType::JOURNAL
},
2665 { XML_MANUAL
, BibliographyDataType::MANUAL
},
2666 { XML_MASTERSTHESIS
, BibliographyDataType::MASTERSTHESIS
},
2667 { XML_MISC
, BibliographyDataType::MISC
},
2668 { XML_PHDTHESIS
, BibliographyDataType::PHDTHESIS
},
2669 { XML_PROCEEDINGS
, BibliographyDataType::PROCEEDINGS
},
2670 { XML_TECHREPORT
, BibliographyDataType::TECHREPORT
},
2671 { XML_UNPUBLISHED
, BibliographyDataType::UNPUBLISHED
},
2672 { XML_WWW
, BibliographyDataType::WWW
},
2673 { XML_TOKEN_INVALID
, 0 }
2677 void XMLTextFieldExport::ProcessBibliographyData(
2678 const Reference
<XPropertySet
>& rPropSet
)
2681 Any aAny
= rPropSet
->getPropertyValue(gsPropertyFields
);
2682 Sequence
<PropertyValue
> aValues
;
2685 // one attribute per value (unless empty)
2686 for (const auto& rProp
: std::as_const(aValues
))
2688 if( rProp
.Name
== "BibiliographicType" )
2690 sal_Int16 nTypeId
= 0;
2691 rProp
.Value
>>= nTypeId
;
2692 OUStringBuffer sBuf
;
2694 if (SvXMLUnitConverter::convertEnum(sBuf
, nTypeId
,
2695 aBibliographyDataTypeMap
))
2697 rExport
.AddAttribute(XML_NAMESPACE_TEXT
,
2698 XML_BIBLIOGRAPHY_TYPE
,
2699 sBuf
.makeStringAndClear());
2701 // else: ignore this argument
2706 rProp
.Value
>>= sStr
;
2708 if (!sStr
.isEmpty())
2710 XMLTokenEnum eElement
= MapBibliographyFieldName(rProp
.Name
);
2711 if (eElement
== XML_URL
|| eElement
== XML_LOCAL_URL
|| eElement
== XML_TARGET_URL
)
2713 sStr
= GetExport().GetRelativeReference(sStr
);
2715 sal_uInt16 nPrefix
= XML_NAMESPACE_TEXT
;
2716 if (eElement
== XML_LOCAL_URL
|| eElement
== XML_TARGET_TYPE
2717 || eElement
== XML_TARGET_URL
)
2719 nPrefix
= XML_NAMESPACE_LO_EXT
;
2721 rExport
.AddAttribute(nPrefix
, eElement
, sStr
);
2727 /// export CommandTypeAttribute
2728 void XMLTextFieldExport::ProcessCommandType(
2729 sal_Int32 nCommandType
)
2731 enum XMLTokenEnum eToken
= XML_TOKEN_INVALID
;
2732 switch( nCommandType
)
2734 case sdb::CommandType::TABLE
: eToken
= XML_TABLE
; break;
2735 case sdb::CommandType::QUERY
: eToken
= XML_QUERY
; break;
2736 case sdb::CommandType::COMMAND
: eToken
= XML_COMMAND
; break;
2739 if( eToken
!= XML_TOKEN_INVALID
)
2740 rExport
.AddAttribute( XML_NAMESPACE_TEXT
, XML_TABLE_TYPE
, eToken
);
2744 void XMLTextFieldExport::ProcessStringSequence(
2745 const Sequence
<OUString
>& rSequence
,
2746 const OUString
& sSelected
)
2748 // find selected element
2749 sal_Int32 nSelected
= comphelper::findValue(rSequence
, sSelected
);
2751 // delegate to ProcessStringSequence(OUString,sal_Int32)
2752 ProcessStringSequence( rSequence
, nSelected
);
2755 void XMLTextFieldExport::ProcessStringSequence(
2756 const Sequence
<OUString
>& rSequence
,
2757 sal_Int32 nSelected
)
2759 sal_Int32 nLength
= rSequence
.getLength();
2760 const OUString
* pSequence
= rSequence
.getConstArray();
2761 for( sal_Int32 i
= 0; i
< nLength
; i
++ )
2763 if( i
== nSelected
)
2764 rExport
.AddAttribute( XML_NAMESPACE_TEXT
,
2765 XML_CURRENT_SELECTED
, XML_TRUE
);
2766 rExport
.AddAttribute( XML_NAMESPACE_TEXT
, XML_VALUE
, pSequence
[i
] );
2767 SvXMLElementExport
aElement( rExport
, XML_NAMESPACE_TEXT
, XML_LABEL
,
2772 void XMLTextFieldExport::ExportDataBaseElement(
2773 enum XMLTokenEnum eElementName
,
2774 const OUString
& sPresentation
,
2775 const Reference
<XPropertySet
>& rPropertySet
,
2776 const Reference
<XPropertySetInfo
>& rPropertySetInfo
)
2778 SAL_WARN_IF( eElementName
== XML_TOKEN_INVALID
, "xmloff.text", "need token" );
2779 SAL_WARN_IF( !rPropertySet
.is(), "xmloff.text", "need property set" );
2780 SAL_WARN_IF( !rPropertySetInfo
.is(), "xmloff.text", "need property set info" );
2782 // get database properties
2783 OUString sDataBaseName
;
2784 OUString sDataBaseURL
;
2786 if( ( rPropertySet
->getPropertyValue( gsPropertyDataBaseName
) >>= sStr
)
2787 && !sStr
.isEmpty() )
2789 sDataBaseName
= sStr
;
2791 else if( rPropertySetInfo
->hasPropertyByName( gsPropertyDataBaseURL
) &&
2792 (rPropertySet
->getPropertyValue( gsPropertyDataBaseURL
) >>= sStr
) &&
2795 sDataBaseURL
= sStr
;
2798 // add database name property (if present)
2799 if( !sDataBaseName
.isEmpty() )
2800 rExport
.AddAttribute( XML_NAMESPACE_TEXT
, XML_DATABASE_NAME
,
2802 SvXMLElementExport
aDataBaseElement( GetExport(),
2803 XML_NAMESPACE_TEXT
, eElementName
,
2806 // write URL as children
2807 if( !sDataBaseURL
.isEmpty() )
2809 rExport
.AddAttribute( XML_NAMESPACE_XLINK
, XML_HREF
, sDataBaseURL
);
2810 SvXMLElementExport
aDataSourceElement(
2811 GetExport(), XML_NAMESPACE_FORM
, XML_CONNECTION_RESOURCE
,
2815 // write presentation
2816 rExport
.Characters( sPresentation
);
2820 // explode a field master name into field type and field name
2821 void XMLTextFieldExport::ExplodeFieldMasterName(
2822 std::u16string_view sMasterName
, OUString
& sFieldType
, OUString
& sVarName
)
2824 sal_Int32 nLength
= gsFieldMasterPrefix
.getLength();
2825 size_t nSeparator
= sMasterName
.find('.', nLength
);
2828 if (nSeparator
== o3tl::make_unsigned(nLength
) || nSeparator
== std::u16string_view::npos
) {
2829 SAL_WARN("xmloff.text", "no field var name!");
2833 sFieldType
= sMasterName
.substr(nLength
, nSeparator
-nLength
);
2834 sVarName
= sMasterName
.substr(nSeparator
+1);
2839 // for XDependentTextFields, get PropertySet of FieldMaster
2840 Reference
<XPropertySet
> XMLTextFieldExport::GetMasterPropertySet(
2841 const Reference
<XTextField
> & rTextField
)
2843 // name, value => get Property set of TextFieldMaster
2844 Reference
<XDependentTextField
> xDep(rTextField
, UNO_QUERY
);
2845 return xDep
->getTextFieldMaster();
2848 // get PropertySet of (any; the first) dependent field
2849 bool XMLTextFieldExport::GetDependentFieldPropertySet(
2850 const Reference
<XPropertySet
> & xMaster
,
2851 Reference
<XPropertySet
> & xField
)
2854 Sequence
<Reference
<XDependentTextField
> > aFields
;
2855 aAny
= xMaster
->getPropertyValue(gsPropertyDependentTextFields
);
2859 if (aFields
.hasElements())
2861 // get first one and return
2862 Reference
<XDependentTextField
> xTField
= aFields
[0];
2863 xField
.set(xTField
, UNO_QUERY
);
2864 DBG_ASSERT(xField
.is(),
2865 "Surprisingly, this TextField refuses to be a PropertySet!");
2875 /// map placeholder type
2876 enum XMLTokenEnum
XMLTextFieldExport::MapPlaceholderType(sal_uInt16 nType
)
2878 enum XMLTokenEnum eType
= XML_TEXT
;
2882 case PlaceholderType::TEXT
:
2886 case PlaceholderType::TABLE
:
2890 case PlaceholderType::TEXTFRAME
:
2891 eType
= XML_TEXT_BOX
;
2894 case PlaceholderType::GRAPHIC
:
2898 case PlaceholderType::OBJECT
:
2903 // unknown placeholder: XML_TEXT
2904 OSL_FAIL("unknown placeholder type");
2911 /// element name for author fields
2912 enum XMLTokenEnum
XMLTextFieldExport::MapAuthorFieldName(
2913 const Reference
<XPropertySet
> & xPropSet
)
2915 // Initials or full name?
2916 return GetBoolProperty(gsPropertyFullName
, xPropSet
)
2917 ? XML_AUTHOR_NAME
: XML_AUTHOR_INITIALS
;
2920 enum XMLTokenEnum
XMLTextFieldExport::MapPageNumberName(
2921 const Reference
<XPropertySet
> & xPropSet
,
2924 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
2925 PageNumberType ePage
;
2926 Any aAny
= xPropSet
->getPropertyValue(gsPropertySubType
);
2927 ePage
= *o3tl::doAccess
<PageNumberType
>(aAny
);
2931 case PageNumberType_PREV
:
2932 eName
= XML_PREVIOUS
;
2935 case PageNumberType_CURRENT
:
2936 eName
= XML_CURRENT
;
2938 case PageNumberType_NEXT
:
2943 OSL_FAIL("unknown page number type");
2944 eName
= XML_TOKEN_INVALID
;
2951 /// map TemplateDisplayFormat to XML
2952 enum XMLTokenEnum
XMLTextFieldExport::MapTemplateDisplayFormat(sal_Int16 nFormat
)
2954 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
2958 case TemplateDisplayFormat::FULL
:
2961 case TemplateDisplayFormat::PATH
:
2964 case TemplateDisplayFormat::NAME
:
2967 case TemplateDisplayFormat::NAME_AND_EXT
:
2968 eName
= XML_NAME_AND_EXTENSION
;
2970 case TemplateDisplayFormat::AREA
:
2973 case TemplateDisplayFormat::TITLE
:
2977 OSL_FAIL("unknown template display format");
2978 eName
= XML_TOKEN_INVALID
;
2985 /// map count/statistics field token to XML name
2986 enum XMLTokenEnum
XMLTextFieldExport::MapCountFieldName(FieldIdEnum nToken
)
2988 enum XMLTokenEnum eElement
= XML_TOKEN_INVALID
;
2992 case FIELD_ID_COUNT_PAGES
:
2993 eElement
= XML_PAGE_COUNT
;
2995 case FIELD_ID_COUNT_PARAGRAPHS
:
2996 eElement
= XML_PARAGRAPH_COUNT
;
2998 case FIELD_ID_COUNT_WORDS
:
2999 eElement
= XML_WORD_COUNT
;
3001 case FIELD_ID_COUNT_CHARACTERS
:
3002 eElement
= XML_CHARACTER_COUNT
;
3004 case FIELD_ID_COUNT_TABLES
:
3005 eElement
= XML_TABLE_COUNT
;
3007 case FIELD_ID_COUNT_GRAPHICS
:
3008 eElement
= XML_IMAGE_COUNT
;
3010 case FIELD_ID_COUNT_OBJECTS
:
3011 eElement
= XML_OBJECT_COUNT
;
3014 OSL_FAIL("no count field token");
3015 eElement
= XML_TOKEN_INVALID
;
3022 /// map ChapterDisplayFormat to XML string
3023 enum XMLTokenEnum
XMLTextFieldExport::MapChapterDisplayFormat(sal_Int16 nFormat
)
3025 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
3029 case ChapterFormat::NAME
:
3032 case ChapterFormat::NUMBER
:
3035 case ChapterFormat::NAME_NUMBER
:
3036 eName
= XML_NUMBER_AND_NAME
;
3038 case ChapterFormat::NO_PREFIX_SUFFIX
:
3039 eName
= XML_PLAIN_NUMBER_AND_NAME
;
3041 case ChapterFormat::DIGIT
:
3042 eName
= XML_PLAIN_NUMBER
;
3045 OSL_FAIL("unknown chapter display format");
3046 eName
= XML_TOKEN_INVALID
;
3054 /// map FilenameDisplayFormat to XML attribute names
3055 enum XMLTokenEnum
XMLTextFieldExport::MapFilenameDisplayFormat(sal_Int16 nFormat
)
3057 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
3061 case FilenameDisplayFormat::FULL
:
3064 case FilenameDisplayFormat::PATH
:
3067 case FilenameDisplayFormat::NAME
:
3070 case FilenameDisplayFormat::NAME_AND_EXT
:
3071 eName
= XML_NAME_AND_EXTENSION
;
3074 OSL_FAIL("unknown filename display format");
3081 /// map ReferenceFieldPart to XML string
3082 enum XMLTokenEnum
XMLTextFieldExport::MapReferenceType(sal_Int16 nType
)
3084 enum XMLTokenEnum eElement
= XML_TOKEN_INVALID
;
3088 case ReferenceFieldPart::PAGE
:
3089 eElement
= XML_PAGE
;
3091 case ReferenceFieldPart::CHAPTER
:
3092 eElement
= XML_CHAPTER
;
3094 case ReferenceFieldPart::TEXT
:
3095 eElement
= XML_TEXT
;
3097 case ReferenceFieldPart::UP_DOWN
:
3098 eElement
= XML_DIRECTION
;
3100 case ReferenceFieldPart::CATEGORY_AND_NUMBER
:
3101 eElement
= XML_CATEGORY_AND_VALUE
;
3103 case ReferenceFieldPart::ONLY_CAPTION
:
3104 eElement
= XML_CAPTION
;
3106 case ReferenceFieldPart::ONLY_SEQUENCE_NUMBER
:
3107 eElement
= XML_VALUE
;
3109 case ReferenceFieldPart::PAGE_DESC
:
3110 // small hack: this value never gets written, because
3111 // XML_TEMPLATE is default
3112 eElement
= XML_TEMPLATE
;
3114 // Core implementation for direct cross-references (#i81002#)
3115 case ReferenceFieldPart::NUMBER
:
3116 eElement
= XML_NUMBER
;
3118 case ReferenceFieldPart::NUMBER_NO_CONTEXT
:
3119 eElement
= XML_NUMBER_NO_SUPERIOR
;
3121 case ReferenceFieldPart::NUMBER_FULL_CONTEXT
:
3122 eElement
= XML_NUMBER_ALL_SUPERIOR
;
3125 OSL_FAIL("unknown reference type");
3126 eElement
= XML_TEMPLATE
;
3133 /// map ReferenceFieldPart to XML string
3134 enum XMLTokenEnum
XMLTextFieldExport::MapReferenceSource(sal_Int16 nType
)
3136 enum XMLTokenEnum eElement
= XML_TOKEN_INVALID
;
3140 case ReferenceFieldSource::REFERENCE_MARK
:
3141 eElement
= XML_REFERENCE_REF
;
3143 case ReferenceFieldSource::SEQUENCE_FIELD
:
3144 eElement
= XML_SEQUENCE_REF
;
3146 case ReferenceFieldSource::BOOKMARK
:
3147 eElement
= XML_BOOKMARK_REF
;
3149 case ReferenceFieldSource::FOOTNOTE
:
3150 case ReferenceFieldSource::ENDNOTE
:
3151 eElement
= XML_NOTE_REF
;
3154 OSL_FAIL("unknown reference source");
3162 /// element name for sender fields
3163 enum XMLTokenEnum
XMLTextFieldExport::MapSenderFieldName(
3164 const Reference
<XPropertySet
> & xPropSet
)
3166 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
3169 switch (GetInt16Property(gsPropertyFieldSubType
, xPropSet
))
3171 case UserDataPart::COMPANY
:
3172 eName
= XML_SENDER_COMPANY
;
3174 case UserDataPart::FIRSTNAME
:
3175 eName
= XML_SENDER_FIRSTNAME
;
3177 case UserDataPart::NAME
:
3178 eName
= XML_SENDER_LASTNAME
;
3180 case UserDataPart::SHORTCUT
:
3181 eName
= XML_SENDER_INITIALS
;
3183 case UserDataPart::STREET
:
3184 eName
= XML_SENDER_STREET
;
3186 case UserDataPart::COUNTRY
:
3187 eName
= XML_SENDER_COUNTRY
;
3189 case UserDataPart::ZIP
:
3190 eName
= XML_SENDER_POSTAL_CODE
;
3192 case UserDataPart::CITY
:
3193 eName
= XML_SENDER_CITY
;
3195 case UserDataPart::TITLE
:
3196 eName
= XML_SENDER_TITLE
;
3198 case UserDataPart::POSITION
:
3199 eName
= XML_SENDER_POSITION
;
3201 case UserDataPart::PHONE_PRIVATE
:
3202 eName
= XML_SENDER_PHONE_PRIVATE
;
3204 case UserDataPart::PHONE_COMPANY
:
3205 eName
= XML_SENDER_PHONE_WORK
;
3207 case UserDataPart::FAX
:
3208 eName
= XML_SENDER_FAX
;
3210 case UserDataPart::EMAIL
:
3211 eName
= XML_SENDER_EMAIL
;
3213 case UserDataPart::STATE
:
3214 eName
= XML_SENDER_STATE_OR_PROVINCE
;
3217 SAL_WARN("xmloff.text", "unknown sender type");
3218 eName
= XML_TOKEN_INVALID
;
3225 enum XMLTokenEnum
XMLTextFieldExport::MapDocInfoFieldName(
3226 enum FieldIdEnum nToken
)
3228 enum XMLTokenEnum eElement
= XML_TOKEN_INVALID
;
3232 case FIELD_ID_DOCINFO_CREATION_AUTHOR
:
3233 eElement
= XML_INITIAL_CREATOR
;
3235 case FIELD_ID_DOCINFO_CREATION_DATE
:
3236 eElement
= XML_CREATION_DATE
;
3238 case FIELD_ID_DOCINFO_CREATION_TIME
:
3239 eElement
= XML_CREATION_TIME
;
3241 case FIELD_ID_DOCINFO_DESCRIPTION
:
3242 eElement
= XML_DESCRIPTION
;
3244 case FIELD_ID_DOCINFO_PRINT_TIME
:
3245 eElement
= XML_PRINT_TIME
;
3247 case FIELD_ID_DOCINFO_PRINT_DATE
:
3248 eElement
= XML_PRINT_DATE
;
3250 case FIELD_ID_DOCINFO_PRINT_AUTHOR
:
3251 eElement
= XML_PRINTED_BY
;
3253 case FIELD_ID_DOCINFO_TITLE
:
3254 eElement
= XML_TITLE
;
3256 case FIELD_ID_DOCINFO_SUBJECT
:
3257 eElement
= XML_SUBJECT
;
3259 case FIELD_ID_DOCINFO_KEYWORDS
:
3260 eElement
= XML_KEYWORDS
;
3262 case FIELD_ID_DOCINFO_REVISION
:
3263 eElement
= XML_EDITING_CYCLES
;
3265 case FIELD_ID_DOCINFO_EDIT_DURATION
:
3266 eElement
= XML_EDITING_DURATION
;
3268 case FIELD_ID_DOCINFO_SAVE_TIME
:
3269 eElement
= XML_MODIFICATION_TIME
;
3271 case FIELD_ID_DOCINFO_SAVE_DATE
:
3272 eElement
= XML_MODIFICATION_DATE
;
3274 case FIELD_ID_DOCINFO_SAVE_AUTHOR
:
3275 eElement
= XML_CREATOR
;
3278 SAL_WARN("xmloff.text", "unknown docinfo field type!");
3279 eElement
= XML_TOKEN_INVALID
;
3286 enum XMLTokenEnum
XMLTextFieldExport::MapBibliographyFieldName(std::u16string_view sName
)
3288 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
3290 if( sName
== u
"Identifier" )
3292 eName
= XML_IDENTIFIER
;
3294 else if( sName
== u
"BibiliographicType" )
3296 eName
= XML_BIBLIOGRAPHY_TYPE
;
3298 else if( sName
== u
"Address" )
3300 eName
= XML_ADDRESS
;
3302 else if( sName
== u
"Annote" )
3306 else if( sName
== u
"Author" )
3310 else if( sName
== u
"Booktitle" )
3312 eName
= XML_BOOKTITLE
;
3314 else if( sName
== u
"Chapter" )
3316 eName
= XML_CHAPTER
;
3318 else if( sName
== u
"Edition" )
3320 eName
= XML_EDITION
;
3322 else if( sName
== u
"Editor" )
3326 else if( sName
== u
"Howpublished" )
3328 eName
= XML_HOWPUBLISHED
;
3330 else if( sName
== u
"Institution" )
3332 eName
= XML_INSTITUTION
;
3334 else if( sName
== u
"Journal" )
3336 eName
= XML_JOURNAL
;
3338 else if( sName
== u
"Month" )
3342 else if( sName
== u
"Note" )
3346 else if( sName
== u
"Number" )
3350 else if( sName
== u
"Organizations" )
3352 eName
= XML_ORGANIZATIONS
;
3354 else if( sName
== u
"Pages" )
3358 else if( sName
== u
"Publisher" )
3360 eName
= XML_PUBLISHER
;
3362 else if( sName
== u
"School" )
3366 else if( sName
== u
"Series" )
3370 else if( sName
== u
"Title" )
3374 else if( sName
== u
"Report_Type" )
3376 eName
= XML_REPORT_TYPE
;
3378 else if( sName
== u
"Volume" )
3382 else if( sName
== u
"Year" )
3386 else if( sName
== u
"URL" )
3390 else if( sName
== u
"Custom1" )
3392 eName
= XML_CUSTOM1
;
3394 else if( sName
== u
"Custom2" )
3396 eName
= XML_CUSTOM2
;
3398 else if( sName
== u
"Custom3" )
3400 eName
= XML_CUSTOM3
;
3402 else if( sName
== u
"Custom4" )
3404 eName
= XML_CUSTOM4
;
3406 else if( sName
== u
"Custom5" )
3408 eName
= XML_CUSTOM5
;
3410 else if( sName
== u
"ISBN" )
3414 else if (sName
== u
"LocalURL")
3416 eName
= XML_LOCAL_URL
;
3418 else if (sName
== u
"TargetType")
3420 eName
= XML_TARGET_TYPE
;
3422 else if (sName
== u
"TargetURL")
3424 eName
= XML_TARGET_URL
;
3428 SAL_WARN("xmloff.text", "Unknown bibliography info data");
3429 eName
= XML_TOKEN_INVALID
;
3435 enum XMLTokenEnum
XMLTextFieldExport::MapMeasureKind(sal_Int16 nKind
)
3447 OUString
XMLTextFieldExport::MakeFootnoteRefName(
3450 // generate foot-/endnote ID
3451 return "ftn" + OUString::number(static_cast<sal_Int32
>(nSeqNo
));
3454 OUString
XMLTextFieldExport::MakeSequenceRefName(
3456 std::u16string_view rSeqName
)
3458 // generate foot-/endnote ID
3459 return OUString::Concat("ref") +rSeqName
+ OUString::number(static_cast<sal_Int32
>(nSeqNo
));
3463 // Property accessor helper functions
3466 // to be relegated (does that word exist?) to a more appropriate place
3469 bool GetBoolProperty(
3470 const OUString
& sPropName
,
3471 const Reference
<XPropertySet
> & xPropSet
)
3473 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3474 bool bBool
= *o3tl::doAccess
<bool>(aAny
);
3478 bool GetOptionalBoolProperty(
3479 const OUString
& sPropName
,
3480 const Reference
<XPropertySet
> & xPropSet
,
3481 const Reference
<XPropertySetInfo
> & xPropSetInfo
,
3484 return xPropSetInfo
->hasPropertyByName( sPropName
)
3485 ? GetBoolProperty( sPropName
, xPropSet
) : bDefault
;
3488 double GetDoubleProperty(
3489 const OUString
& sPropName
,
3490 const Reference
<XPropertySet
> & xPropSet
)
3492 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3493 double fDouble
= 0.0;
3498 OUString
GetStringProperty(
3499 const OUString
& sPropName
,
3500 const Reference
<XPropertySet
> & xPropSet
)
3502 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3508 sal_Int32
GetIntProperty(
3509 const OUString
& sPropName
,
3510 const Reference
<XPropertySet
> & xPropSet
)
3512 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3518 sal_Int16
GetInt16Property(
3519 const OUString
& sPropName
,
3520 const Reference
<XPropertySet
> & xPropSet
)
3522 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3528 sal_Int8
GetInt8Property(
3529 const OUString
& sPropName
,
3530 const Reference
<XPropertySet
> & xPropSet
)
3532 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3538 util::DateTime
GetDateTimeProperty(
3539 const OUString
& sPropName
,
3540 const Reference
<XPropertySet
> & xPropSet
)
3542 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3543 util::DateTime aTime
;
3548 Sequence
<OUString
> GetStringSequenceProperty(
3549 const OUString
& sPropName
,
3550 const Reference
<XPropertySet
> & xPropSet
)
3552 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3553 Sequence
<OUString
> aSequence
;
3558 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */