nss: upgrade to release 3.73
[LibreOffice.git] / xmloff / source / text / txtflde.cxx
blob892c92b82ee716ac780f5c3f1ab232ef81d8ed8c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 /** @#file
23 * export of all text fields
25 #include <txtflde.hxx>
26 #include <xmloff/XMLEventExport.hxx>
27 #include <xmloff/families.hxx>
28 #include <xmloff/namespacemap.hxx>
29 #include <xmloff/numehelp.hxx>
30 #include <xmloff/xmlement.hxx>
31 #include <xmloff/xmlexp.hxx>
32 #include <xmloff/xmltoken.hxx>
33 #include <xmloff/xmluconv.hxx>
34 #include <xmloff/maptype.hxx>
36 #include "XMLTextCharStyleNamesElementExport.hxx"
37 #include <sax/tools/converter.hxx>
38 #include <com/sun/star/frame/XModel.hpp>
39 #include <com/sun/star/util/DateTime.hpp>
40 #include <com/sun/star/lang/XServiceInfo.hpp>
41 #include <com/sun/star/text/UserDataPart.hpp>
42 #include <com/sun/star/text/PageNumberType.hpp>
43 #include <com/sun/star/style/NumberingType.hpp>
44 #include <com/sun/star/text/ReferenceFieldPart.hpp>
45 #include <com/sun/star/text/ReferenceFieldSource.hpp>
46 #include <com/sun/star/beans/XPropertySet.hpp>
47 #include <com/sun/star/beans/XPropertyState.hpp>
48 #include <com/sun/star/text/XTextField.hpp>
49 #include <com/sun/star/text/XDependentTextField.hpp>
50 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
52 #include <com/sun/star/text/SetVariableType.hpp>
53 #include <com/sun/star/text/PlaceholderType.hpp>
54 #include <com/sun/star/text/FilenameDisplayFormat.hpp>
55 #include <com/sun/star/text/ChapterFormat.hpp>
56 #include <com/sun/star/text/TemplateDisplayFormat.hpp>
57 #include <com/sun/star/container/XNameReplace.hpp>
58 #include <com/sun/star/uno/Sequence.h>
59 #include <com/sun/star/text/BibliographyDataType.hpp>
60 #include <com/sun/star/sdb/CommandType.hpp>
61 #include <com/sun/star/rdf/XMetadatable.hpp>
62 #include <comphelper/sequence.hxx>
63 #include <o3tl/any.hxx>
64 #include <rtl/ustrbuf.hxx>
65 #include <tools/debug.hxx>
66 #include <rtl/math.hxx>
67 #include <sal/log.hxx>
69 #include <vector>
72 using namespace ::std;
73 using namespace ::com::sun::star;
74 using namespace ::com::sun::star::uno;
75 using namespace ::com::sun::star::text;
76 using namespace ::com::sun::star::lang;
77 using namespace ::com::sun::star::beans;
78 using namespace ::com::sun::star::util;
79 using namespace ::com::sun::star::style;
80 using namespace ::com::sun::star::document;
81 using namespace ::com::sun::star::container;
82 using namespace ::xmloff::token;
85 char const FIELD_SERVICE_SENDER[] = "ExtendedUser";
86 char const FIELD_SERVICE_AUTHOR[] = "Author";
87 char const FIELD_SERVICE_JUMPEDIT[] = "JumpEdit";
88 char const FIELD_SERVICE_GETEXP[] = "GetExpression";
89 char const FIELD_SERVICE_SETEXP[] = "SetExpression";
90 char const FIELD_SERVICE_USER[] = "User";
91 char const FIELD_SERVICE_INPUT[] = "Input";
92 char const FIELD_SERVICE_USERINPUT[] = "InputUser";
93 char const FIELD_SERVICE_DATETIME[] = "DateTime";
94 char const FIELD_SERVICE_PAGENUMBER[] = "PageNumber";
95 char const FIELD_SERVICE_DB_NEXT[] = "DatabaseNextSet";
96 char const FIELD_SERVICE_DB_SELECT[] = "DatabaseNumberOfSet";
97 char const FIELD_SERVICE_DB_NUMBER[] = "DatabaseSetNumber";
98 char const FIELD_SERVICE_DB_DISPLAY[] = "Database";
99 char const FIELD_SERVICE_DB_NAME[] = "DatabaseName";
100 char const FIELD_SERVICE_CONDITIONAL_TEXT[] = "ConditionalText";
101 char const FIELD_SERVICE_HIDDEN_TEXT[] = "HiddenText";
102 char const FIELD_SERVICE_HIDDEN_PARAGRAPH[] = "HiddenParagraph";
103 char const FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR[] = "DocInfo.ChangeAuthor";
104 char const FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR2[] = "docinfo.ChangeAuthor";
105 char const FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME[] = "DocInfo.ChangeDateTime";
106 char const FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME2[] = "docinfo.ChangeDateTime";
107 char const FIELD_SERVICE_DOC_INFO_EDIT_TIME[] = "DocInfo.EditTime";
108 char const FIELD_SERVICE_DOC_INFO_EDIT_TIME2[] = "docinfo.EditTime";
109 char const FIELD_SERVICE_DOC_INFO_DESCRIPTION[] = "DocInfo.Description";
110 char const FIELD_SERVICE_DOC_INFO_DESCRIPTION2[] = "docinfo.Description";
111 char const FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR[] = "DocInfo.CreateAuthor";
112 char const FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR2[] = "docinfo.CreateAuthor";
113 char const FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME[] = "DocInfo.CreateDateTime";
114 char const FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME2[] = "docinfo.CreateDateTime";
115 char const FIELD_SERVICE_DOC_INFO_CUSTOM[] = "DocInfo.Custom";
116 char const FIELD_SERVICE_DOC_INFO_CUSTOM2[] = "docinfo.Custom";
117 char const FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR[] = "DocInfo.PrintAuthor";
118 char const FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR2[] = "docinfo.PrintAuthor";
119 char const FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME[] = "DocInfo.PrintDateTime";
120 char const FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME2[] = "docinfo.PrintDateTime";
121 char const FIELD_SERVICE_DOC_INFO_KEY_WORDS[] = "DocInfo.KeyWords";
122 char const FIELD_SERVICE_DOC_INFO_KEY_WORDS2[] = "docinfo.KeyWords";
123 char const FIELD_SERVICE_DOC_INFO_SUBJECT[] = "DocInfo.Subject";
124 char const FIELD_SERVICE_DOC_INFO_SUBJECT2[] = "docinfo.Subject";
125 char const FIELD_SERVICE_DOC_INFO_TITLE[] = "DocInfo.Title";
126 char const FIELD_SERVICE_DOC_INFO_TITLE2[] = "docinfo.Title";
127 char const FIELD_SERVICE_DOC_INFO_REVISION[] = "DocInfo.Revision";
128 char const FIELD_SERVICE_DOC_INFO_REVISION2[] = "docinfo.Revision";
129 char const FIELD_SERVICE_FILE_NAME[] = "FileName";
130 char const FIELD_SERVICE_CHAPTER[] = "Chapter";
131 char const FIELD_SERVICE_TEMPLATE_NAME[] = "TemplateName";
132 char const FIELD_SERVICE_PAGE_COUNT[] = "PageCount";
133 char const FIELD_SERVICE_PARAGRAPH_COUNT[] = "ParagraphCount";
134 char const FIELD_SERVICE_WORD_COUNT[] = "WordCount";
135 char const FIELD_SERVICE_CHARACTER_COUNT[] = "CharacterCount";
136 char const FIELD_SERVICE_TABLE_COUNT[] = "TableCount";
137 char const FIELD_SERVICE_GRAPHIC_COUNT[] = "GraphicObjectCount";
138 char const FIELD_SERVICE_OBJECT_COUNT[] = "EmbeddedObjectCount";
139 char const FIELD_SERVICE_REFERENCE_PAGE_SET[] = "ReferencePageSet";
140 char const FIELD_SERVICE_REFERENCE_PAGE_GET[] = "ReferencePageGet";
141 char const FIELD_SERVICE_SHEET_NAME[] = "SheetName";
142 char const FIELD_SERVICE_PAGE_NAME[] = "PageName";
143 char const FIELD_SERVICE_MACRO[] = "Macro";
144 char const FIELD_SERVICE_GET_REFERENCE[] = "GetReference";
145 char const FIELD_SERVICE_DDE[] = "DDE";
146 char const FIELD_SERVICE_URL[] = "URL";
147 char const FIELD_SERVICE_BIBLIOGRAPHY[] = "Bibliography";
148 char const FIELD_SERVICE_SCRIPT[] = "Script";
149 char const FIELD_SERVICE_ANNOTATION[] = "Annotation";
150 char const FIELD_SERVICE_COMBINED_CHARACTERS[] = "CombinedCharacters";
151 char const FIELD_SERVICE_META[] = "MetadataField";
152 char const FIELD_SERVICE_MEASURE[] = "Measure";
153 char const FIELD_SERVICE_TABLE_FORMULA[] = "TableFormula";
154 char const FIELD_SERVICE_DROP_DOWN[] = "DropDown";
156 namespace
158 /// Walks up the parent chain of xText and returns the topmost text.
159 uno::Reference<text::XText> GetToplevelText(const uno::Reference<text::XText>& xText)
161 uno::Reference<text::XText> xRet = xText;
162 while (true)
164 uno::Reference<beans::XPropertySet> xPropertySet(xRet, uno::UNO_QUERY);
165 if (!xPropertySet.is())
166 return xRet;
168 if (!xPropertySet->getPropertySetInfo()->hasPropertyByName("ParentText"))
169 return xRet;
171 uno::Reference<text::XText> xParent;
172 if (xPropertySet->getPropertyValue("ParentText") >>= xParent)
173 xRet = xParent;
174 else
175 return xRet;
177 return xRet;
181 SvXMLEnumStringMapEntry<FieldIdEnum> const aFieldServiceNameMapping[] =
183 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SENDER, FIELD_ID_SENDER ),
184 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_AUTHOR, FIELD_ID_AUTHOR ),
185 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_JUMPEDIT, FIELD_ID_PLACEHOLDER ),
186 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GETEXP, FIELD_ID_VARIABLE_GET ),
187 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SETEXP, FIELD_ID_VARIABLE_SET ),
188 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_USER, FIELD_ID_USER_GET ),
189 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_INPUT, FIELD_ID_TEXT_INPUT ),
190 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_USERINPUT, FIELD_ID_USER_INPUT ),
191 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DATETIME, FIELD_ID_TIME ),
192 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PAGENUMBER, FIELD_ID_PAGENUMBER ),
193 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_REFERENCE_PAGE_SET, FIELD_ID_REFPAGE_SET ),
194 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_REFERENCE_PAGE_GET, FIELD_ID_REFPAGE_GET ),
196 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NEXT, FIELD_ID_DATABASE_NEXT ),
197 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_SELECT, FIELD_ID_DATABASE_SELECT ),
198 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NUMBER, FIELD_ID_DATABASE_NUMBER ),
199 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_DISPLAY, FIELD_ID_DATABASE_DISPLAY ),
200 // workaround for #no-bug#: Database/DataBase
201 ENUM_STRING_MAP_ENTRY( "DataBase", FIELD_ID_DATABASE_DISPLAY ),
202 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NAME, FIELD_ID_DATABASE_NAME ),
204 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR, FIELD_ID_DOCINFO_CREATION_AUTHOR ),
205 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR2, FIELD_ID_DOCINFO_CREATION_AUTHOR ),
206 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME, FIELD_ID_DOCINFO_CREATION_TIME),
207 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME2, FIELD_ID_DOCINFO_CREATION_TIME),
208 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR, FIELD_ID_DOCINFO_SAVE_AUTHOR ),
209 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR2, FIELD_ID_DOCINFO_SAVE_AUTHOR ),
210 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME, FIELD_ID_DOCINFO_SAVE_TIME ),
211 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME2, FIELD_ID_DOCINFO_SAVE_TIME ),
212 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_EDIT_TIME, FIELD_ID_DOCINFO_EDIT_DURATION ),
213 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_EDIT_TIME2, FIELD_ID_DOCINFO_EDIT_DURATION ),
214 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_DESCRIPTION, FIELD_ID_DOCINFO_DESCRIPTION ),
215 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_DESCRIPTION2, FIELD_ID_DOCINFO_DESCRIPTION ),
216 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CUSTOM, FIELD_ID_DOCINFO_CUSTOM ),
217 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CUSTOM2, FIELD_ID_DOCINFO_CUSTOM ),
218 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR, FIELD_ID_DOCINFO_PRINT_AUTHOR ),
219 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR2, FIELD_ID_DOCINFO_PRINT_AUTHOR ),
220 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME, FIELD_ID_DOCINFO_PRINT_TIME ),
221 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME2, FIELD_ID_DOCINFO_PRINT_TIME ),
222 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_KEY_WORDS, FIELD_ID_DOCINFO_KEYWORDS ),
223 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_KEY_WORDS2, FIELD_ID_DOCINFO_KEYWORDS ),
224 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_SUBJECT, FIELD_ID_DOCINFO_SUBJECT ),
225 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_SUBJECT2, FIELD_ID_DOCINFO_SUBJECT ),
226 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_TITLE, FIELD_ID_DOCINFO_TITLE ),
227 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_TITLE2, FIELD_ID_DOCINFO_TITLE ),
228 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_REVISION, FIELD_ID_DOCINFO_REVISION ),
229 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_REVISION2, FIELD_ID_DOCINFO_REVISION ),
231 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CONDITIONAL_TEXT, FIELD_ID_CONDITIONAL_TEXT ),
232 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_HIDDEN_TEXT, FIELD_ID_HIDDEN_TEXT ),
233 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_HIDDEN_PARAGRAPH, FIELD_ID_HIDDEN_PARAGRAPH ),
235 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_FILE_NAME, FIELD_ID_FILE_NAME ),
236 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CHAPTER, FIELD_ID_CHAPTER ),
237 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TEMPLATE_NAME, FIELD_ID_TEMPLATE_NAME ),
239 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PAGE_COUNT, FIELD_ID_COUNT_PAGES ),
240 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PARAGRAPH_COUNT, FIELD_ID_COUNT_PARAGRAPHS ),
241 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_WORD_COUNT, FIELD_ID_COUNT_WORDS ),
242 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CHARACTER_COUNT, FIELD_ID_COUNT_CHARACTERS ),
243 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TABLE_COUNT, FIELD_ID_COUNT_TABLES ),
244 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GRAPHIC_COUNT, FIELD_ID_COUNT_GRAPHICS ),
245 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_OBJECT_COUNT, FIELD_ID_COUNT_OBJECTS ),
247 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_MACRO, FIELD_ID_MACRO ),
248 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GET_REFERENCE, FIELD_ID_REF_REFERENCE ),
249 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DDE, FIELD_ID_DDE ),
251 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_BIBLIOGRAPHY, FIELD_ID_BIBLIOGRAPHY ),
253 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SCRIPT, FIELD_ID_SCRIPT ),
254 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_ANNOTATION, FIELD_ID_ANNOTATION ),
256 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_COMBINED_CHARACTERS, FIELD_ID_COMBINED_CHARACTERS ),
257 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_META, FIELD_ID_META ),
259 // non-writer fields
260 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SHEET_NAME, FIELD_ID_SHEET_NAME ),
261 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PAGE_NAME, FIELD_ID_PAGENAME ),
262 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_URL, FIELD_ID_URL ),
263 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_MEASURE, FIELD_ID_MEASURE ),
265 // deprecated fields
266 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TABLE_FORMULA, FIELD_ID_TABLE_FORMULA ),
267 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DROP_DOWN, FIELD_ID_DROP_DOWN ),
269 { nullptr, 0, FieldIdEnum(0) }
273 // property accessor helper functions
274 static bool GetBoolProperty(const OUString&,
275 const Reference<XPropertySet> &);
276 static bool GetOptionalBoolProperty(const OUString&,
277 const Reference<XPropertySet> &,
278 const Reference<XPropertySetInfo> &,
279 bool bDefault);
280 static double GetDoubleProperty(const OUString&,
281 const Reference<XPropertySet> &);
282 static OUString GetStringProperty(const OUString&,
283 const Reference<XPropertySet> &);
284 static sal_Int32 GetIntProperty(const OUString&,
285 const Reference<XPropertySet> &);
286 static sal_Int16 GetInt16Property(const OUString&,
287 const Reference<XPropertySet> &);
288 static sal_Int8 GetInt8Property(const OUString&,
289 const Reference<XPropertySet> &);
290 static util::DateTime GetDateTimeProperty( const OUString& sPropName,
291 const Reference<XPropertySet> & xPropSet);
292 static Sequence<OUString> GetStringSequenceProperty(
293 const OUString& sPropName,
294 const Reference<XPropertySet> & xPropSet);
297 // service names
298 constexpr OUStringLiteral gsServicePrefix(u"com.sun.star.text.textfield.");
299 constexpr OUStringLiteral gsFieldMasterPrefix(u"com.sun.star.text.FieldMaster.");
300 constexpr OUStringLiteral gsPresentationServicePrefix(u"com.sun.star.presentation.TextField.");
302 // property names
303 constexpr OUStringLiteral gsPropertyAdjust(u"Adjust");
304 constexpr OUStringLiteral gsPropertyAuthor(u"Author");
305 constexpr OUStringLiteral gsPropertyChapterFormat(u"ChapterFormat");
306 constexpr OUStringLiteral gsPropertyChapterNumberingLevel(u"ChapterNumberingLevel");
307 constexpr OUStringLiteral gsPropertyCharStyleNames(u"CharStyleNames");
308 constexpr OUStringLiteral gsPropertyCondition(u"Condition");
309 constexpr OUStringLiteral gsPropertyContent(u"Content");
310 constexpr OUStringLiteral gsPropertyDataBaseName(u"DataBaseName");
311 constexpr OUStringLiteral gsPropertyDataBaseURL(u"DataBaseURL");
312 constexpr OUStringLiteral gsPropertyDataColumnName(u"DataColumnName");
313 constexpr OUStringLiteral gsPropertyDataCommandType(u"DataCommandType");
314 constexpr OUStringLiteral gsPropertyDataTableName(u"DataTableName");
315 constexpr OUStringLiteral gsPropertyDateTime(u"DateTime");
316 constexpr OUStringLiteral gsPropertyDateTimeValue(u"DateTimeValue");
317 constexpr OUStringLiteral gsPropertyDDECommandElement(u"DDECommandElement");
318 constexpr OUStringLiteral gsPropertyDDECommandFile(u"DDECommandFile");
319 constexpr OUStringLiteral gsPropertyDDECommandType(u"DDECommandType");
320 constexpr OUStringLiteral gsPropertyDependentTextFields(u"DependentTextFields");
321 constexpr OUStringLiteral gsPropertyFalseContent(u"FalseContent");
322 constexpr OUStringLiteral gsPropertyFields(u"Fields");
323 constexpr OUStringLiteral gsPropertyFieldSubType(u"UserDataType");
324 constexpr OUStringLiteral gsPropertyFileFormat(u"FileFormat");
325 constexpr OUStringLiteral gsPropertyFullName(u"FullName");
326 constexpr OUStringLiteral gsPropertyHint(u"Hint");
327 constexpr OUStringLiteral gsPropertyInitials(u"Initials");
328 constexpr OUStringLiteral gsPropertyInstanceName(u"InstanceName");
329 constexpr OUStringLiteral gsPropertyIsAutomaticUpdate(u"IsAutomaticUpdate");
330 constexpr OUStringLiteral gsPropertyIsConditionTrue(u"IsConditionTrue");
331 constexpr OUStringLiteral gsPropertyIsDataBaseFormat(u"DataBaseFormat");
332 constexpr OUStringLiteral gsPropertyIsDate(u"IsDate");
333 constexpr OUStringLiteral gsPropertyIsExpression(u"IsExpression");
334 constexpr OUStringLiteral gsPropertyIsFixed(u"IsFixed");
335 constexpr OUStringLiteral gsPropertyIsFixedLanguage(u"IsFixedLanguage");
336 constexpr OUStringLiteral gsPropertyIsHidden(u"IsHidden");
337 constexpr OUStringLiteral gsPropertyIsInput(u"Input");
338 constexpr OUStringLiteral gsPropertyIsShowFormula(u"IsShowFormula");
339 constexpr OUStringLiteral gsPropertyIsVisible(u"IsVisible");
340 constexpr OUStringLiteral gsPropertyItems(u"Items");
341 constexpr OUStringLiteral gsPropertyLevel(u"Level");
342 constexpr OUStringLiteral gsPropertyMeasureKind(u"Kind");
343 constexpr OUStringLiteral gsPropertyName(u"Name");
344 constexpr OUStringLiteral gsPropertyNumberFormat(u"NumberFormat");
345 constexpr OUStringLiteral gsPropertyNumberingSeparator(u"NumberingSeparator");
346 constexpr OUStringLiteral gsPropertyNumberingType(u"NumberingType");
347 constexpr OUStringLiteral gsPropertyOffset(u"Offset");
348 constexpr OUStringLiteral gsPropertyOn(u"On");
349 constexpr OUStringLiteral gsPropertyPlaceholderType(u"PlaceHolderType");
350 constexpr OUStringLiteral gsPropertyReferenceFieldPart(u"ReferenceFieldPart");
351 constexpr OUStringLiteral gsPropertyReferenceFieldSource(u"ReferenceFieldSource");
352 constexpr OUStringLiteral gsPropertyReferenceFieldLanguage(u"ReferenceFieldLanguage");
353 constexpr OUStringLiteral gsPropertyScriptType(u"ScriptType");
354 constexpr OUStringLiteral gsPropertySelectedItem(u"SelectedItem");
355 constexpr OUStringLiteral gsPropertySequenceNumber(u"SequenceNumber");
356 constexpr OUStringLiteral gsPropertySequenceValue(u"SequenceValue");
357 constexpr OUStringLiteral gsPropertySetNumber(u"SetNumber");
358 constexpr OUStringLiteral gsPropertySourceName(u"SourceName");
359 constexpr OUStringLiteral gsPropertySubType(u"SubType");
360 constexpr OUStringLiteral gsPropertyTargetFrame(u"TargetFrame");
361 constexpr OUStringLiteral gsPropertyTrueContent(u"TrueContent");
362 constexpr OUStringLiteral gsPropertyURL(u"URL");
363 constexpr OUStringLiteral gsPropertyURLContent(u"URLContent");
364 constexpr OUStringLiteral gsPropertyUserText(u"UserText");
365 constexpr OUStringLiteral gsPropertyValue(u"Value");
366 constexpr OUStringLiteral gsPropertyVariableName(u"VariableName");
367 constexpr OUStringLiteral gsPropertyHelp(u"Help");
368 constexpr OUStringLiteral gsPropertyTooltip(u"Tooltip");
369 constexpr OUStringLiteral gsPropertyTextRange(u"TextRange");
371 XMLTextFieldExport::XMLTextFieldExport( SvXMLExport& rExp,
372 std::unique_ptr<XMLPropertyState> pCombinedCharState)
373 : rExport(rExp),
374 pCombinedCharactersPropertyState(std::move(pCombinedCharState))
376 SetExportOnlyUsedFieldDeclarations();
379 XMLTextFieldExport::~XMLTextFieldExport()
383 /// get the field ID (as in FieldIDEnum) from XTextField
384 enum FieldIdEnum XMLTextFieldExport::GetFieldID(
385 const Reference<XTextField> & rTextField,
386 const Reference<XPropertySet> & xPropSet)
388 // get service names for rTextField (via XServiceInfo service)
389 Reference<XServiceInfo> xService(rTextField, UNO_QUERY);
390 const Sequence<OUString> aServices = xService->getSupportedServiceNames();
392 OUString sFieldName; // service name postfix of current field
394 // search for TextField service name
395 const OUString* pNames = std::find_if(aServices.begin(), aServices.end(),
396 [](const OUString& rName) { return rName.matchIgnoreAsciiCase(gsServicePrefix); });
397 if (pNames != aServices.end())
399 // TextField found => postfix is field type!
400 sFieldName = pNames->copy(gsServicePrefix.getLength());
403 // if this is not a normal text field, check if it's a presentation text field
404 if( sFieldName.isEmpty() )
406 // search for TextField service name
407 pNames = std::find_if(aServices.begin(), aServices.end(),
408 [](const OUString& rName) { return rName.startsWith(gsPresentationServicePrefix); });
409 if (pNames != aServices.end())
411 // TextField found => postfix is field type!
412 sFieldName = pNames->copy(gsPresentationServicePrefix.getLength());
415 if( !sFieldName.isEmpty() )
417 if( sFieldName == "Header" )
419 return FIELD_ID_DRAW_HEADER;
421 else if( sFieldName == "Footer" )
423 return FIELD_ID_DRAW_FOOTER;
425 else if( sFieldName == "DateTime" )
427 return FIELD_ID_DRAW_DATE_TIME;
432 // map postfix of service name to field ID
433 DBG_ASSERT(!sFieldName.isEmpty(), "no TextField service found!");
434 return MapFieldName(sFieldName, xPropSet);
437 enum FieldIdEnum XMLTextFieldExport::MapFieldName(
438 const OUString& sFieldName, // field (master) name
439 const Reference<XPropertySet> & xPropSet) // for subtype
441 // we'll proceed in 2 steps:
442 // a) map service name to preliminary FIELD_ID
443 // b) map those prelim. FIELD_IDs that correspond to several field types
444 // (in our (XML) world) to final FIELD IDs
447 // a) find prelim. FIELD_ID via aFieldServiceMapping
449 // check for non-empty service name
450 DBG_ASSERT(!sFieldName.isEmpty(), "no valid service name!");
451 enum FieldIdEnum nToken = FIELD_ID_UNKNOWN;
452 if (!sFieldName.isEmpty())
454 // map name to prelim. ID
455 bool bRet = SvXMLUnitConverter::convertEnum(
456 nToken, sFieldName, aFieldServiceNameMapping);
458 // check return
459 DBG_ASSERT(bRet, "Unknown field service name encountered!");
462 // b) map prelim. to final FIELD_IDs
463 switch (nToken) {
464 case FIELD_ID_VARIABLE_SET:
465 if (GetBoolProperty(gsPropertyIsInput, xPropSet))
467 nToken = FIELD_ID_VARIABLE_INPUT;
469 else
471 switch (GetIntProperty(gsPropertySubType, xPropSet))
473 case SetVariableType::STRING: // text field
474 case SetVariableType::VAR: // num field
475 nToken = FIELD_ID_VARIABLE_SET;
476 break;
477 case SetVariableType::SEQUENCE:
478 nToken = FIELD_ID_SEQUENCE;
479 break;
480 case SetVariableType::FORMULA:
481 default:
482 nToken = FIELD_ID_UNKNOWN;
483 break;
486 break;
488 case FIELD_ID_VARIABLE_GET:
489 switch (GetIntProperty(gsPropertySubType, xPropSet))
491 case SetVariableType::STRING: // text field
492 case SetVariableType::VAR: // num field
493 nToken = FIELD_ID_VARIABLE_GET;
494 break;
495 case SetVariableType::FORMULA:
496 nToken = FIELD_ID_EXPRESSION;
497 break;
498 case SetVariableType::SEQUENCE:
499 default:
500 nToken = FIELD_ID_UNKNOWN;
501 break;
503 break;
505 case FIELD_ID_TIME:
506 if (GetBoolProperty(gsPropertyIsDate, xPropSet))
508 nToken = FIELD_ID_DATE;
510 break;
512 case FIELD_ID_PAGENUMBER:
513 // NumberingType not available in non-Writer apps
514 if (xPropSet->getPropertySetInfo()->
515 hasPropertyByName(gsPropertyNumberingType))
517 if (NumberingType::CHAR_SPECIAL == GetIntProperty(
518 gsPropertyNumberingType, xPropSet))
520 nToken = FIELD_ID_PAGESTRING;
523 break;
525 case FIELD_ID_DOCINFO_CREATION_TIME:
526 if (GetBoolProperty(gsPropertyIsDate, xPropSet))
528 nToken = FIELD_ID_DOCINFO_CREATION_DATE;
530 break;
532 case FIELD_ID_DOCINFO_PRINT_TIME:
533 if (GetBoolProperty(gsPropertyIsDate, xPropSet))
535 nToken = FIELD_ID_DOCINFO_PRINT_DATE;
537 break;
539 case FIELD_ID_DOCINFO_SAVE_TIME:
540 if (GetBoolProperty(gsPropertyIsDate, xPropSet))
542 nToken = FIELD_ID_DOCINFO_SAVE_DATE;
544 break;
546 case FIELD_ID_REF_REFERENCE:
547 switch (GetInt16Property(gsPropertyReferenceFieldSource, xPropSet))
549 case ReferenceFieldSource::REFERENCE_MARK:
550 nToken = FIELD_ID_REF_REFERENCE;
551 break;
552 case ReferenceFieldSource::SEQUENCE_FIELD:
553 nToken = FIELD_ID_REF_SEQUENCE;
554 break;
555 case ReferenceFieldSource::BOOKMARK:
556 nToken = FIELD_ID_REF_BOOKMARK;
557 break;
558 case ReferenceFieldSource::FOOTNOTE:
559 nToken = FIELD_ID_REF_FOOTNOTE;
560 break;
561 case ReferenceFieldSource::ENDNOTE:
562 nToken = FIELD_ID_REF_ENDNOTE;
563 break;
564 default:
565 nToken = FIELD_ID_UNKNOWN;
566 break;
568 break;
570 case FIELD_ID_COMBINED_CHARACTERS:
571 case FIELD_ID_SCRIPT:
572 case FIELD_ID_ANNOTATION:
573 case FIELD_ID_BIBLIOGRAPHY:
574 case FIELD_ID_DDE:
575 case FIELD_ID_MACRO:
576 case FIELD_ID_REFPAGE_SET:
577 case FIELD_ID_REFPAGE_GET:
578 case FIELD_ID_COUNT_PAGES:
579 case FIELD_ID_COUNT_PARAGRAPHS:
580 case FIELD_ID_COUNT_WORDS:
581 case FIELD_ID_COUNT_CHARACTERS:
582 case FIELD_ID_COUNT_TABLES:
583 case FIELD_ID_COUNT_GRAPHICS:
584 case FIELD_ID_COUNT_OBJECTS:
585 case FIELD_ID_CONDITIONAL_TEXT:
586 case FIELD_ID_HIDDEN_TEXT:
587 case FIELD_ID_HIDDEN_PARAGRAPH:
588 case FIELD_ID_DOCINFO_CREATION_AUTHOR:
589 case FIELD_ID_DOCINFO_DESCRIPTION:
590 case FIELD_ID_DOCINFO_CUSTOM:
591 case FIELD_ID_DOCINFO_PRINT_AUTHOR:
592 case FIELD_ID_DOCINFO_TITLE:
593 case FIELD_ID_DOCINFO_SUBJECT:
594 case FIELD_ID_DOCINFO_KEYWORDS:
595 case FIELD_ID_DOCINFO_REVISION:
596 case FIELD_ID_DOCINFO_EDIT_DURATION:
597 case FIELD_ID_DOCINFO_SAVE_AUTHOR:
598 case FIELD_ID_TEXT_INPUT:
599 case FIELD_ID_USER_INPUT:
600 case FIELD_ID_AUTHOR:
601 case FIELD_ID_SENDER:
602 case FIELD_ID_PLACEHOLDER:
603 case FIELD_ID_USER_GET:
604 case FIELD_ID_DATABASE_NEXT:
605 case FIELD_ID_DATABASE_SELECT:
606 case FIELD_ID_DATABASE_DISPLAY:
607 case FIELD_ID_DATABASE_NAME:
608 case FIELD_ID_DATABASE_NUMBER:
609 case FIELD_ID_TEMPLATE_NAME:
610 case FIELD_ID_CHAPTER:
611 case FIELD_ID_FILE_NAME:
612 case FIELD_ID_META:
613 case FIELD_ID_SHEET_NAME:
614 case FIELD_ID_PAGENAME:
615 case FIELD_ID_MEASURE:
616 case FIELD_ID_URL:
617 case FIELD_ID_TABLE_FORMULA:
618 case FIELD_ID_DROP_DOWN:
619 ; // these field IDs are final
620 break;
622 default:
623 nToken = FIELD_ID_UNKNOWN;
626 // ... and return final FIELD_ID
627 return nToken;
630 // is string or numeric field?
631 bool XMLTextFieldExport::IsStringField(
632 FieldIdEnum nFieldType,
633 const Reference<XPropertySet> & xPropSet)
635 switch (nFieldType) {
637 case FIELD_ID_VARIABLE_GET:
638 case FIELD_ID_VARIABLE_SET:
639 case FIELD_ID_VARIABLE_INPUT:
641 // depends on field sub type
642 return ( GetIntProperty(gsPropertySubType, xPropSet) ==
643 SetVariableType::STRING );
646 case FIELD_ID_USER_GET:
647 case FIELD_ID_USER_INPUT:
649 Reference<XTextField> xTextField(xPropSet, UNO_QUERY);
650 DBG_ASSERT(xTextField.is(), "field is no XTextField!");
651 bool bRet = GetBoolProperty(gsPropertyIsExpression,
652 GetMasterPropertySet(xTextField));
653 return !bRet;
656 case FIELD_ID_META:
657 return 0 > GetIntProperty(gsPropertyNumberFormat, xPropSet);
659 case FIELD_ID_DATABASE_DISPLAY:
660 // TODO: depends on... ???
661 // workaround #no-bug#: no data type
662 return 5100 == GetIntProperty(gsPropertyNumberFormat, xPropSet);
664 case FIELD_ID_TABLE_FORMULA:
665 // legacy field: always a number field (because it always has
666 // a number format)
667 return false;
669 case FIELD_ID_COUNT_PAGES:
670 case FIELD_ID_COUNT_PARAGRAPHS:
671 case FIELD_ID_COUNT_WORDS:
672 case FIELD_ID_COUNT_CHARACTERS:
673 case FIELD_ID_COUNT_TABLES:
674 case FIELD_ID_COUNT_GRAPHICS:
675 case FIELD_ID_COUNT_OBJECTS:
676 case FIELD_ID_DOCINFO_SAVE_TIME:
677 case FIELD_ID_DOCINFO_SAVE_DATE:
678 case FIELD_ID_DOCINFO_CREATION_DATE:
679 case FIELD_ID_DOCINFO_CREATION_TIME:
680 case FIELD_ID_DOCINFO_PRINT_TIME:
681 case FIELD_ID_DOCINFO_PRINT_DATE:
682 case FIELD_ID_DOCINFO_EDIT_DURATION:
683 case FIELD_ID_DOCINFO_REVISION:
684 case FIELD_ID_DATABASE_NUMBER:
685 case FIELD_ID_EXPRESSION:
686 case FIELD_ID_SEQUENCE:
687 case FIELD_ID_DATE:
688 case FIELD_ID_TIME:
689 case FIELD_ID_PAGENUMBER:
690 case FIELD_ID_REFPAGE_SET:
691 case FIELD_ID_REFPAGE_GET:
692 case FIELD_ID_DOCINFO_CUSTOM:
693 // always number
694 return false;
696 case FIELD_ID_COMBINED_CHARACTERS:
697 case FIELD_ID_BIBLIOGRAPHY:
698 case FIELD_ID_DDE:
699 case FIELD_ID_REF_REFERENCE:
700 case FIELD_ID_REF_SEQUENCE:
701 case FIELD_ID_REF_BOOKMARK:
702 case FIELD_ID_REF_FOOTNOTE:
703 case FIELD_ID_REF_ENDNOTE:
704 case FIELD_ID_MACRO:
705 case FIELD_ID_TEMPLATE_NAME:
706 case FIELD_ID_CHAPTER:
707 case FIELD_ID_FILE_NAME:
708 case FIELD_ID_CONDITIONAL_TEXT:
709 case FIELD_ID_HIDDEN_TEXT:
710 case FIELD_ID_HIDDEN_PARAGRAPH:
711 case FIELD_ID_DOCINFO_CREATION_AUTHOR:
712 case FIELD_ID_DOCINFO_DESCRIPTION:
713 case FIELD_ID_DOCINFO_PRINT_AUTHOR:
714 case FIELD_ID_DOCINFO_TITLE:
715 case FIELD_ID_DOCINFO_SUBJECT:
716 case FIELD_ID_DOCINFO_KEYWORDS:
717 case FIELD_ID_DOCINFO_SAVE_AUTHOR:
718 case FIELD_ID_DATABASE_NAME:
719 case FIELD_ID_TEXT_INPUT:
720 case FIELD_ID_SENDER:
721 case FIELD_ID_AUTHOR:
722 case FIELD_ID_PAGENAME:
723 case FIELD_ID_PAGESTRING:
724 case FIELD_ID_SHEET_NAME:
725 case FIELD_ID_MEASURE:
726 case FIELD_ID_URL:
727 case FIELD_ID_DROP_DOWN:
728 // always string:
729 return true;
731 case FIELD_ID_SCRIPT:
732 case FIELD_ID_ANNOTATION:
733 case FIELD_ID_DATABASE_NEXT:
734 case FIELD_ID_DATABASE_SELECT:
735 case FIELD_ID_PLACEHOLDER:
736 case FIELD_ID_UNKNOWN:
737 case FIELD_ID_DRAW_HEADER:
738 case FIELD_ID_DRAW_FOOTER:
739 case FIELD_ID_DRAW_DATE_TIME:
740 default:
741 OSL_FAIL("unknown field type/field has no content");
742 return true; // invalid info; string in case of doubt
746 /// export the styles needed by the given field. Called on first pass
747 /// through document
748 void XMLTextFieldExport::ExportFieldAutoStyle(
749 const Reference<XTextField> & rTextField, const bool bProgress,
750 const bool bRecursive )
752 // get property set
753 Reference<XPropertySet> xPropSet(rTextField, UNO_QUERY);
755 // add field master to list of used field masters (if desired)
756 if (nullptr != pUsedMasters)
758 Reference<XDependentTextField> xDepField(rTextField, UNO_QUERY);
759 if (xDepField.is())
761 // The direct parent may be just the table cell, while we want the topmost parent, e.g.
762 // a header text.
763 Reference<XText> xOurText = GetToplevelText(rTextField->getAnchor()->getText());
765 map<Reference<XText>, set<OUString> >::iterator aMapIter =
766 pUsedMasters->find(xOurText);
768 // insert a list for our XText (if necessary)
769 if (aMapIter == pUsedMasters->end())
771 set<OUString> aSet;
772 (*pUsedMasters)[xOurText] = aSet;
773 aMapIter = pUsedMasters->find(xOurText);
776 // insert this text field master
777 OUString sFieldMasterName = GetStringProperty(
778 gsPropertyInstanceName, xDepField->getTextFieldMaster());
779 if (!sFieldMasterName.isEmpty())
780 aMapIter->second.insert( sFieldMasterName );
782 // else: no dependent field -> no master -> ignore
785 // get Field ID
786 FieldIdEnum nToken = GetFieldID(rTextField, xPropSet);
788 // export the character style for all fields
789 // with one exception: combined character fields export their own
790 // text style below
791 Reference <XPropertySet> xRangePropSet(rTextField->getAnchor(), UNO_QUERY);
792 if (FIELD_ID_COMBINED_CHARACTERS != nToken)
794 GetExport().GetTextParagraphExport()->Add(
795 XmlStyleFamily::TEXT_TEXT, xRangePropSet);
798 // process special styles for each field (e.g. data styles)
799 switch (nToken) {
801 case FIELD_ID_DATABASE_DISPLAY:
803 sal_Int32 nFormat = GetIntProperty(gsPropertyNumberFormat, xPropSet);
804 // workaround: #no-bug#; see IsStringField(...)
805 if ( (5100 != nFormat) &&
806 !GetBoolProperty(gsPropertyIsDataBaseFormat, xPropSet) )
808 GetExport().addDataStyle(nFormat);
810 break;
813 case FIELD_ID_DATE:
814 case FIELD_ID_TIME:
816 // date and time fields are always number fields, but the
817 // NumberFormat property is optional (e.g. Calc doesn't
818 // support it)
819 Reference<XPropertySetInfo> xPropSetInfo(
820 xPropSet->getPropertySetInfo() );
821 if ( xPropSetInfo->hasPropertyByName( gsPropertyNumberFormat ) )
823 sal_Int32 nFormat =
824 GetIntProperty(gsPropertyNumberFormat, xPropSet);
826 // nFormat may be -1 for numeric fields that display their
827 // variable name. (Maybe this should be a field type, then?)
828 if (nFormat != -1)
830 if( ! GetOptionalBoolProperty(
831 gsPropertyIsFixedLanguage,
832 xPropSet, xPropSetInfo, false ) )
834 nFormat =
835 GetExport().dataStyleForceSystemLanguage(nFormat);
838 GetExport().addDataStyle( nFormat,
839 nToken == FIELD_ID_TIME );
843 break;
845 case FIELD_ID_META:
846 // recurse into content (does not export element, so can be done first)
847 if (bRecursive)
849 bool dummy_for_autostyles(true);
850 ExportMetaField(xPropSet, true, bProgress, dummy_for_autostyles);
852 [[fallthrough]];
853 case FIELD_ID_DOCINFO_PRINT_TIME:
854 case FIELD_ID_DOCINFO_PRINT_DATE:
855 case FIELD_ID_DOCINFO_CREATION_DATE:
856 case FIELD_ID_DOCINFO_CREATION_TIME:
857 case FIELD_ID_DOCINFO_SAVE_TIME:
858 case FIELD_ID_DOCINFO_SAVE_DATE:
859 case FIELD_ID_DOCINFO_EDIT_DURATION:
860 case FIELD_ID_VARIABLE_SET:
861 case FIELD_ID_VARIABLE_GET:
862 case FIELD_ID_VARIABLE_INPUT:
863 case FIELD_ID_USER_GET:
864 case FIELD_ID_EXPRESSION:
865 case FIELD_ID_TABLE_FORMULA:
866 case FIELD_ID_DOCINFO_CUSTOM:
867 // register number format, if this is a numeric field
868 if (! IsStringField(nToken, xPropSet)) {
870 sal_Int32 nFormat =
871 GetIntProperty(gsPropertyNumberFormat, xPropSet);
873 // nFormat may be -1 for numeric fields that display their
874 // variable name. (Maybe this should be a field type, then?)
875 if (nFormat != -1)
877 // handle formats for fixed language fields
878 // for all these fields (except table formula)
879 if( ( nToken != FIELD_ID_TABLE_FORMULA ) &&
880 ! GetOptionalBoolProperty(
881 gsPropertyIsFixedLanguage,
882 xPropSet, xPropSet->getPropertySetInfo(),
883 false ) )
885 nFormat =
886 GetExport().dataStyleForceSystemLanguage(nFormat);
889 GetExport().addDataStyle(nFormat);
892 break;
894 case FIELD_ID_COMBINED_CHARACTERS:
896 // export text style with the addition of the combined characters
897 DBG_ASSERT(nullptr != pCombinedCharactersPropertyState,
898 "need proper PropertyState for combined characters");
899 const XMLPropertyState *aStates[] = { pCombinedCharactersPropertyState.get(), nullptr };
900 GetExport().GetTextParagraphExport()->Add(
901 XmlStyleFamily::TEXT_TEXT, xRangePropSet,
902 aStates);
903 break;
906 case FIELD_ID_SCRIPT:
907 case FIELD_ID_ANNOTATION:
908 case FIELD_ID_BIBLIOGRAPHY:
909 case FIELD_ID_DDE:
910 case FIELD_ID_REF_REFERENCE:
911 case FIELD_ID_REF_SEQUENCE:
912 case FIELD_ID_REF_BOOKMARK:
913 case FIELD_ID_REF_FOOTNOTE:
914 case FIELD_ID_REF_ENDNOTE:
915 case FIELD_ID_MACRO:
916 case FIELD_ID_REFPAGE_SET:
917 case FIELD_ID_REFPAGE_GET:
918 case FIELD_ID_COUNT_PAGES:
919 case FIELD_ID_COUNT_PARAGRAPHS:
920 case FIELD_ID_COUNT_WORDS:
921 case FIELD_ID_COUNT_CHARACTERS:
922 case FIELD_ID_COUNT_TABLES:
923 case FIELD_ID_COUNT_GRAPHICS:
924 case FIELD_ID_COUNT_OBJECTS:
925 case FIELD_ID_CONDITIONAL_TEXT:
926 case FIELD_ID_HIDDEN_TEXT:
927 case FIELD_ID_HIDDEN_PARAGRAPH:
928 case FIELD_ID_DOCINFO_CREATION_AUTHOR:
929 case FIELD_ID_DOCINFO_DESCRIPTION:
930 case FIELD_ID_DOCINFO_PRINT_AUTHOR:
931 case FIELD_ID_DOCINFO_TITLE:
932 case FIELD_ID_DOCINFO_SUBJECT:
933 case FIELD_ID_DOCINFO_KEYWORDS:
934 case FIELD_ID_DOCINFO_REVISION:
935 case FIELD_ID_DOCINFO_SAVE_AUTHOR:
936 case FIELD_ID_SEQUENCE:
937 case FIELD_ID_PAGENAME:
938 case FIELD_ID_PAGENUMBER:
939 case FIELD_ID_PAGESTRING:
940 case FIELD_ID_AUTHOR:
941 case FIELD_ID_SENDER:
942 case FIELD_ID_PLACEHOLDER:
943 case FIELD_ID_USER_INPUT:
944 case FIELD_ID_TEXT_INPUT:
945 case FIELD_ID_DATABASE_NEXT:
946 case FIELD_ID_DATABASE_SELECT:
947 case FIELD_ID_DATABASE_NAME:
948 case FIELD_ID_DATABASE_NUMBER:
949 case FIELD_ID_TEMPLATE_NAME:
950 case FIELD_ID_CHAPTER:
951 case FIELD_ID_FILE_NAME:
952 case FIELD_ID_SHEET_NAME:
953 case FIELD_ID_MEASURE:
954 case FIELD_ID_URL:
955 case FIELD_ID_DROP_DOWN:
956 case FIELD_ID_DRAW_DATE_TIME:
957 case FIELD_ID_DRAW_FOOTER:
958 case FIELD_ID_DRAW_HEADER:
959 ; // no formats for these fields!
960 break;
962 case FIELD_ID_UNKNOWN:
963 default:
964 OSL_FAIL("unknown field type!");
965 // ignore -> no format for unknown
966 break;
970 /// export the given field to XML. Called on second pass through document
971 void XMLTextFieldExport::ExportField(
972 const Reference<XTextField> & rTextField, bool bProgress,
973 bool & rPrevCharIsSpace)
975 // get property set
976 Reference<XPropertySet> xPropSet(rTextField, UNO_QUERY);
978 // get property set of range (for the attributes)
979 Reference <XPropertySet> xRangePropSet(rTextField->getAnchor(), UNO_QUERY);
981 // get Field ID
982 enum FieldIdEnum nToken = GetFieldID(rTextField, xPropSet);
984 // special treatment for combined characters field, because it is
985 // exported as a style
986 const XMLPropertyState* aStates[] = { pCombinedCharactersPropertyState.get(), nullptr };
987 const XMLPropertyState **pStates =
988 FIELD_ID_COMBINED_CHARACTERS == nToken
989 ? aStates
990 : nullptr;
992 // find out whether we need to set the style or hyperlink
993 bool bHasHyperlink;
994 bool bIsUICharStyle;
995 bool bHasAutoStyle;
996 OUString sStyle = GetExport().GetTextParagraphExport()->
997 FindTextStyleAndHyperlink( xRangePropSet, bHasHyperlink, bIsUICharStyle,
998 bHasAutoStyle, pStates );
999 bool bHasStyle = !sStyle.isEmpty();
1001 // export hyperlink (if we have one)
1002 Reference < XPropertySetInfo > xRangePropSetInfo;
1003 if( bHasHyperlink )
1005 Reference<XPropertyState> xRangePropState( xRangePropSet, UNO_QUERY );
1006 xRangePropSetInfo = xRangePropSet->getPropertySetInfo();
1007 bHasHyperlink =
1008 GetExport().GetTextParagraphExport()->addHyperlinkAttributes(
1009 xRangePropSet, xRangePropState,
1010 xRangePropSetInfo );
1012 SvXMLElementExport aHyperlink( GetExport(), bHasHyperlink,
1013 XML_NAMESPACE_TEXT, XML_A,
1014 false, false );
1016 if( bHasHyperlink )
1018 // export events (if supported)
1019 OUString sHyperLinkEvents("HyperLinkEvents");
1020 if (xRangePropSetInfo->hasPropertyByName(sHyperLinkEvents))
1022 Any aAny = xRangePropSet->getPropertyValue(sHyperLinkEvents);
1023 Reference<XNameReplace> xName;
1024 aAny >>= xName;
1025 GetExport().GetEventExport().Export(xName, false);
1030 XMLTextCharStyleNamesElementExport aCharStylesExport(
1031 GetExport(), bIsUICharStyle &&
1032 GetExport().GetTextParagraphExport()
1033 ->GetCharStyleNamesPropInfoCache().hasProperty(
1034 xRangePropSet, xRangePropSetInfo ), bHasAutoStyle,
1035 xRangePropSet, gsPropertyCharStyleNames );
1037 // export span with style (if necessary)
1038 // (except for combined characters field)
1039 if( bHasStyle )
1041 // export <text:span> element
1042 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
1043 GetExport().EncodeStyleName( sStyle ) );
1045 SvXMLElementExport aSpan( GetExport(), bHasStyle,
1046 XML_NAMESPACE_TEXT, XML_SPAN,
1047 false, false);
1049 // finally, export the field itself
1050 ExportFieldHelper( rTextField, xPropSet, xRangePropSet, nToken,
1051 bProgress, rPrevCharIsSpace);
1055 /// export the given field to XML. Called on second pass through document
1056 void XMLTextFieldExport::ExportFieldHelper(
1057 const Reference<XTextField> & rTextField,
1058 const Reference<XPropertySet> & rPropSet,
1059 const Reference<XPropertySet> &,
1060 enum FieldIdEnum nToken,
1061 bool bProgress,
1062 bool & rPrevCharIsSpace)
1064 // get property set info (because some attributes are not support
1065 // in all implementations)
1066 Reference<XPropertySetInfo> xPropSetInfo(rPropSet->getPropertySetInfo());
1068 OUString sPresentation = rTextField->getPresentation(false);
1070 // process each field type
1071 switch (nToken) {
1072 case FIELD_ID_AUTHOR:
1073 // author field: fixed, field (sub-)type
1074 if (xPropSetInfo->hasPropertyByName(gsPropertyIsFixed))
1076 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_FIXED,
1077 (GetBoolProperty(gsPropertyIsFixed, rPropSet) ? XML_TRUE : XML_FALSE) );
1079 ExportElement(MapAuthorFieldName(rPropSet), sPresentation);
1080 break;
1082 case FIELD_ID_SENDER:
1083 // sender field: fixed, field (sub-)type
1084 ProcessBoolean(XML_FIXED,
1085 GetBoolProperty(gsPropertyIsFixed, rPropSet), true);
1086 ExportElement(MapSenderFieldName(rPropSet), sPresentation);
1087 break;
1089 case FIELD_ID_PLACEHOLDER:
1090 // placeholder field: type, name, description
1091 ProcessString(XML_PLACEHOLDER_TYPE,
1092 MapPlaceholderType(
1093 GetInt16Property(gsPropertyPlaceholderType, rPropSet)));
1094 ProcessString(XML_DESCRIPTION,
1095 GetStringProperty(gsPropertyHint,rPropSet), true);
1096 ExportElement(XML_PLACEHOLDER, sPresentation);
1097 break;
1099 case FIELD_ID_VARIABLE_SET:
1101 // variable set field: name, visible, format&value
1102 ProcessString(XML_NAME,
1103 GetStringProperty(gsPropertyVariableName, rPropSet));
1104 ProcessDisplay(GetBoolProperty(gsPropertyIsVisible, rPropSet),
1105 false);
1106 ProcessString(XML_FORMULA, XML_NAMESPACE_OOOW,
1107 GetStringProperty(gsPropertyContent, rPropSet),
1108 sPresentation);
1109 ProcessValueAndType(IsStringField(nToken, rPropSet),
1110 GetIntProperty(gsPropertyNumberFormat, rPropSet),
1111 GetStringProperty(gsPropertyContent, rPropSet),
1112 sPresentation,
1113 GetDoubleProperty(gsPropertyValue, rPropSet),
1114 true, true, true,
1115 ! GetOptionalBoolProperty(
1116 gsPropertyIsFixedLanguage,
1117 rPropSet, xPropSetInfo, false ) );
1118 ExportElement(XML_VARIABLE_SET, sPresentation);
1119 break;
1121 case FIELD_ID_VARIABLE_GET:
1123 // variable get field: name, format&value
1124 ProcessString(XML_NAME,
1125 GetStringProperty(gsPropertyContent, rPropSet));
1126 bool bCmd = GetBoolProperty(gsPropertyIsShowFormula, rPropSet);
1127 ProcessDisplay(true, bCmd);
1128 // show style, unless name will be shown
1129 ProcessValueAndType(IsStringField(nToken, rPropSet),
1130 GetIntProperty(gsPropertyNumberFormat, rPropSet),
1131 "", "", 0.0, // values not used
1132 false,
1133 false,
1134 !bCmd,
1135 ! GetOptionalBoolProperty(
1136 gsPropertyIsFixedLanguage,
1137 rPropSet, xPropSetInfo, false ) );
1138 ExportElement(XML_VARIABLE_GET, sPresentation);
1139 break;
1141 case FIELD_ID_VARIABLE_INPUT:
1142 // variable input field: name, description, format&value
1143 ProcessString(XML_NAME,
1144 GetStringProperty(gsPropertyVariableName, rPropSet));
1145 ProcessString(XML_DESCRIPTION,
1146 GetStringProperty(gsPropertyHint , rPropSet));
1147 ProcessDisplay(GetBoolProperty(gsPropertyIsVisible, rPropSet),
1148 false);
1149 ProcessString(XML_FORMULA, XML_NAMESPACE_OOOW,
1150 GetStringProperty(gsPropertyContent, rPropSet),
1151 sPresentation);
1152 ProcessValueAndType(IsStringField(nToken, rPropSet),
1153 GetIntProperty(gsPropertyNumberFormat, rPropSet),
1154 GetStringProperty(gsPropertyContent, rPropSet),
1155 sPresentation,
1156 GetDoubleProperty(gsPropertyValue, rPropSet),
1157 true, true, true,
1158 ! GetOptionalBoolProperty(
1159 gsPropertyIsFixedLanguage,
1160 rPropSet, xPropSetInfo, false ) );
1161 ExportElement(XML_VARIABLE_INPUT, sPresentation);
1162 break;
1164 case FIELD_ID_USER_GET:
1165 // user field: name, hidden, style
1167 bool bCmd = GetBoolProperty(gsPropertyIsShowFormula, rPropSet);
1168 ProcessDisplay(GetBoolProperty(gsPropertyIsVisible, rPropSet),
1169 bCmd);
1170 ProcessValueAndType(IsStringField(nToken, rPropSet),
1171 GetIntProperty(gsPropertyNumberFormat, rPropSet),
1172 "", "", 0.0, // values not used
1173 false, false, !bCmd,
1174 ! GetOptionalBoolProperty(
1175 gsPropertyIsFixedLanguage,
1176 rPropSet, xPropSetInfo, false ) );
1178 // name from FieldMaster
1179 ProcessString(XML_NAME,
1180 GetStringProperty(gsPropertyName,
1181 GetMasterPropertySet(rTextField)));
1182 ExportElement(XML_USER_FIELD_GET, sPresentation);
1183 break;
1186 case FIELD_ID_USER_INPUT:
1187 // user input field: name (from FieldMaster), description
1188 // ProcessString(XML_NAME,
1189 // GetStringProperty(sPropertyName,
1190 // GetMasterPropertySet(rTextField)));
1191 ProcessString(XML_NAME,
1192 GetStringProperty(gsPropertyContent, rPropSet));
1193 ProcessString(XML_DESCRIPTION,
1194 GetStringProperty(gsPropertyHint, rPropSet));
1195 ExportElement(XML_USER_FIELD_INPUT, sPresentation);
1196 break;
1198 case FIELD_ID_SEQUENCE:
1200 // sequence field: name, formula, seq-format
1201 OUString sName = GetStringProperty(gsPropertyVariableName, rPropSet);
1202 // TODO: use reference name only if actually being referenced.
1203 ProcessString(XML_REF_NAME,
1204 MakeSequenceRefName(
1205 GetInt16Property(gsPropertySequenceValue, rPropSet),
1206 sName));
1207 ProcessString(XML_NAME, sName);
1208 ProcessString(XML_FORMULA, XML_NAMESPACE_OOOW,
1209 GetStringProperty(gsPropertyContent, rPropSet),
1210 sPresentation);
1211 ProcessNumberingType(GetInt16Property(gsPropertyNumberingType,
1212 rPropSet));
1213 ExportElement(XML_SEQUENCE, sPresentation);
1214 break;
1217 case FIELD_ID_EXPRESSION:
1219 // formula field: formula, format&value
1220 bool bCmd = GetBoolProperty(gsPropertyIsShowFormula, rPropSet);
1221 ProcessString(XML_FORMULA, XML_NAMESPACE_OOOW,
1222 GetStringProperty(gsPropertyContent, rPropSet),
1223 sPresentation);
1224 ProcessDisplay(true, bCmd);
1225 ProcessValueAndType(IsStringField(nToken, rPropSet),
1226 GetIntProperty(gsPropertyNumberFormat, rPropSet),
1227 GetStringProperty(gsPropertyContent, rPropSet),
1228 sPresentation,
1229 GetDoubleProperty(gsPropertyValue, rPropSet),
1230 !bCmd, !bCmd, !bCmd,
1231 ! GetOptionalBoolProperty(
1232 gsPropertyIsFixedLanguage,
1233 rPropSet, xPropSetInfo, false ) );
1234 ExportElement(XML_EXPRESSION, sPresentation);
1235 break;
1238 case FIELD_ID_TEXT_INPUT:
1239 // text input field: description and string-value
1240 ProcessString(XML_DESCRIPTION,
1241 GetStringProperty(gsPropertyHint, rPropSet));
1242 ProcessString(XML_HELP,
1243 GetStringProperty(gsPropertyHelp, rPropSet), true);
1244 ProcessString(XML_HINT,
1245 GetStringProperty(gsPropertyTooltip, rPropSet), true);
1246 ExportElement(XML_TEXT_INPUT, sPresentation);
1247 break;
1249 case FIELD_ID_TIME:
1250 // all properties (except IsDate) are optional!
1251 if (xPropSetInfo->hasPropertyByName(gsPropertyNumberFormat))
1253 ProcessValueAndType(false,
1254 GetIntProperty(gsPropertyNumberFormat,rPropSet),
1255 "", "", 0.0, // not used
1256 false, false, true,
1257 ! GetOptionalBoolProperty(
1258 gsPropertyIsFixedLanguage,
1259 rPropSet, xPropSetInfo, false ),
1260 true);
1262 if (xPropSetInfo->hasPropertyByName(gsPropertyDateTimeValue))
1264 // no value -> current time
1265 ProcessTimeOrDateTime(XML_TIME_VALUE,
1266 GetDateTimeProperty(gsPropertyDateTimeValue,
1267 rPropSet));
1269 if (xPropSetInfo->hasPropertyByName(gsPropertyDateTime))
1271 // no value -> current time
1272 ProcessTimeOrDateTime(XML_TIME_VALUE,
1273 GetDateTimeProperty(gsPropertyDateTime,rPropSet));
1275 if (xPropSetInfo->hasPropertyByName(gsPropertyIsFixed))
1277 ProcessBoolean(XML_FIXED,
1278 GetBoolProperty(gsPropertyIsFixed, rPropSet),
1279 false);
1281 if (xPropSetInfo->hasPropertyByName(gsPropertyAdjust))
1283 // adjust value given as integer in minutes
1284 ProcessDateTime(XML_TIME_ADJUST,
1285 GetIntProperty(gsPropertyAdjust, rPropSet),
1286 false, true);
1288 ExportElement(XML_TIME, sPresentation);
1289 break;
1291 case FIELD_ID_DATE:
1292 // all properties (except IsDate) are optional!
1293 if (xPropSetInfo->hasPropertyByName(gsPropertyNumberFormat))
1295 ProcessValueAndType(false,
1296 GetIntProperty(gsPropertyNumberFormat,rPropSet),
1297 "", "", 0.0, // not used
1298 false, false, true,
1299 ! GetOptionalBoolProperty(
1300 gsPropertyIsFixedLanguage,
1301 rPropSet, xPropSetInfo, false ) );
1303 if (xPropSetInfo->hasPropertyByName(gsPropertyDateTimeValue))
1305 // no value -> current date
1306 ProcessDateTime(XML_DATE_VALUE,
1307 GetDateTimeProperty(gsPropertyDateTimeValue,
1308 rPropSet));
1310 // TODO: remove double-handling after SRC614
1311 else if (xPropSetInfo->hasPropertyByName(gsPropertyDateTime))
1313 ProcessDateTime(XML_DATE_VALUE,
1314 GetDateTimeProperty(gsPropertyDateTime,rPropSet));
1316 if (xPropSetInfo->hasPropertyByName(gsPropertyIsFixed))
1318 ProcessBoolean(XML_FIXED,
1319 GetBoolProperty(gsPropertyIsFixed, rPropSet),
1320 false);
1322 if (xPropSetInfo->hasPropertyByName(gsPropertyAdjust))
1324 // adjust value given as number of days
1325 ProcessDateTime(XML_DATE_ADJUST,
1326 GetIntProperty(gsPropertyAdjust, rPropSet),
1327 true, true);
1329 ExportElement(XML_DATE, sPresentation);
1330 break;
1332 case FIELD_ID_PAGENUMBER:
1333 // all properties are optional
1334 if (xPropSetInfo->hasPropertyByName(gsPropertyNumberingType))
1336 ProcessNumberingType(GetInt16Property(gsPropertyNumberingType,
1337 rPropSet));
1339 if (xPropSetInfo->hasPropertyByName(gsPropertyOffset))
1341 sal_Int32 nAdjust = GetIntProperty(gsPropertyOffset, rPropSet);
1343 if (xPropSetInfo->hasPropertyByName(gsPropertySubType))
1345 // property SubType used in MapPageNumberName
1346 ProcessString(XML_SELECT_PAGE,
1347 MapPageNumberName(rPropSet, nAdjust));
1349 ProcessIntegerDef(XML_PAGE_ADJUST, nAdjust, 0);
1351 ExportElement(XML_PAGE_NUMBER, sPresentation);
1352 break;
1354 case FIELD_ID_PAGESTRING:
1356 ProcessString(XML_STRING_VALUE,
1357 GetStringProperty(gsPropertyUserText, rPropSet),
1358 sPresentation);
1359 sal_Int32 nDummy = 0; // MapPageNumberName need int
1360 ProcessString(XML_SELECT_PAGE, MapPageNumberName(rPropSet, nDummy));
1361 ExportElement(XML_PAGE_CONTINUATION, sPresentation);
1362 break;
1365 case FIELD_ID_DATABASE_NAME:
1366 ProcessString(XML_TABLE_NAME,
1367 GetStringProperty(gsPropertyDataTableName, rPropSet));
1368 ProcessCommandType(GetIntProperty(gsPropertyDataCommandType, rPropSet));
1369 ProcessDisplay(GetBoolProperty(gsPropertyIsVisible, rPropSet),
1370 false);
1371 ExportDataBaseElement(XML_DATABASE_NAME, sPresentation,
1372 rPropSet, xPropSetInfo);
1373 break;
1375 case FIELD_ID_DATABASE_NUMBER:
1376 ProcessString(XML_TABLE_NAME,
1377 GetStringProperty(gsPropertyDataTableName, rPropSet));
1378 ProcessCommandType(GetIntProperty(gsPropertyDataCommandType, rPropSet));
1379 ProcessNumberingType(
1380 GetInt16Property(gsPropertyNumberingType,rPropSet));
1381 ProcessInteger(XML_VALUE,
1382 GetIntProperty(gsPropertySetNumber, rPropSet));
1383 ProcessDisplay(GetBoolProperty(gsPropertyIsVisible, rPropSet),
1384 false);
1385 ExportDataBaseElement(XML_DATABASE_ROW_NUMBER, sPresentation,
1386 rPropSet, xPropSetInfo);
1387 break;
1389 case FIELD_ID_DATABASE_NEXT:
1390 ProcessString(XML_TABLE_NAME,
1391 GetStringProperty(gsPropertyDataTableName, rPropSet));
1392 ProcessCommandType(GetIntProperty(gsPropertyDataCommandType, rPropSet));
1393 ProcessString(XML_CONDITION, XML_NAMESPACE_OOOW,
1394 GetStringProperty(gsPropertyCondition, rPropSet));
1395 DBG_ASSERT(sPresentation.isEmpty(),
1396 "Unexpected presentation for database next field");
1397 ExportDataBaseElement(XML_DATABASE_NEXT, OUString(),
1398 rPropSet, xPropSetInfo);
1399 break;
1401 case FIELD_ID_DATABASE_SELECT:
1402 ProcessString(XML_TABLE_NAME,
1403 GetStringProperty(gsPropertyDataTableName, rPropSet));
1404 ProcessCommandType(GetIntProperty(gsPropertyDataCommandType, rPropSet));
1405 ProcessString(XML_CONDITION, XML_NAMESPACE_OOOW,
1406 GetStringProperty(gsPropertyCondition, rPropSet));
1407 ProcessInteger(XML_ROW_NUMBER,
1408 GetIntProperty(gsPropertySetNumber, rPropSet));
1409 DBG_ASSERT(sPresentation.isEmpty(),
1410 "Unexpected presentation for database select field");
1411 ExportDataBaseElement(XML_DATABASE_ROW_SELECT, OUString(),
1412 rPropSet, xPropSetInfo);
1413 break;
1415 case FIELD_ID_DATABASE_DISPLAY:
1417 // get database, table and column name from field master
1418 const Reference<XPropertySet> & xMaster = GetMasterPropertySet(rTextField);
1419 ProcessString(XML_TABLE_NAME,
1420 GetStringProperty(gsPropertyDataTableName, xMaster));
1421 ProcessCommandType(GetIntProperty(gsPropertyDataCommandType, xMaster));
1422 ProcessString(XML_COLUMN_NAME,
1423 GetStringProperty(gsPropertyDataColumnName, xMaster));
1424 // export number format if available (happens only for numbers!)
1425 if (!GetBoolProperty(gsPropertyIsDataBaseFormat, rPropSet))
1427 ProcessValueAndType(false, // doesn't happen for text
1428 GetIntProperty(gsPropertyNumberFormat,rPropSet),
1429 "", "", 0.0, // not used
1430 false, false, true, false);
1432 ProcessDisplay(GetBoolProperty(gsPropertyIsVisible, rPropSet),
1433 false);
1434 ExportDataBaseElement(XML_DATABASE_DISPLAY, sPresentation,
1435 xMaster, xMaster->getPropertySetInfo());
1436 break;
1439 case FIELD_ID_DOCINFO_REVISION:
1440 ProcessBoolean(XML_FIXED,
1441 GetBoolProperty(gsPropertyIsFixed, rPropSet), false);
1442 ExportElement(MapDocInfoFieldName(nToken), sPresentation);
1443 break;
1445 case FIELD_ID_DOCINFO_EDIT_DURATION:
1446 case FIELD_ID_DOCINFO_SAVE_TIME:
1447 case FIELD_ID_DOCINFO_CREATION_TIME:
1448 case FIELD_ID_DOCINFO_PRINT_TIME:
1449 case FIELD_ID_DOCINFO_SAVE_DATE:
1450 case FIELD_ID_DOCINFO_CREATION_DATE:
1451 case FIELD_ID_DOCINFO_PRINT_DATE:
1452 ProcessValueAndType(false,
1453 GetIntProperty(gsPropertyNumberFormat, rPropSet),
1454 "", "", 0.0,
1455 false, false, true,
1456 ! GetOptionalBoolProperty(
1457 gsPropertyIsFixedLanguage,
1458 rPropSet, xPropSetInfo, false ) );
1460 // todo: export date/time value, but values not available -> core bug
1461 ProcessBoolean(XML_FIXED,
1462 GetBoolProperty(gsPropertyIsFixed, rPropSet), false);
1463 ExportElement(MapDocInfoFieldName(nToken), sPresentation);
1464 break;
1466 case FIELD_ID_DOCINFO_CREATION_AUTHOR:
1467 case FIELD_ID_DOCINFO_DESCRIPTION:
1468 case FIELD_ID_DOCINFO_PRINT_AUTHOR:
1469 case FIELD_ID_DOCINFO_TITLE:
1470 case FIELD_ID_DOCINFO_SUBJECT:
1471 case FIELD_ID_DOCINFO_KEYWORDS:
1472 case FIELD_ID_DOCINFO_SAVE_AUTHOR:
1473 if (xPropSetInfo->hasPropertyByName(gsPropertyIsFixed))
1475 ProcessBoolean(XML_FIXED,
1476 GetBoolProperty(gsPropertyIsFixed, rPropSet), false);
1478 ExportElement(MapDocInfoFieldName(nToken), sPresentation);
1479 break;
1481 case FIELD_ID_DOCINFO_CUSTOM:
1483 ProcessValueAndType(false, // doesn't happen for text
1484 GetIntProperty(gsPropertyNumberFormat,rPropSet),
1485 "", "", 0.0, // not used
1486 false, false, true,
1487 ! GetOptionalBoolProperty(
1488 gsPropertyIsFixedLanguage,
1489 rPropSet, xPropSetInfo, false ));
1490 uno::Any aAny = rPropSet->getPropertyValue( gsPropertyName );
1491 OUString sName;
1492 aAny >>= sName;
1493 ProcessString(XML_NAME, sName);
1494 ProcessBoolean(XML_FIXED, GetBoolProperty(gsPropertyIsFixed, rPropSet), false);
1495 ExportElement(XML_USER_DEFINED, sPresentation);
1496 break;
1499 case FIELD_ID_COUNT_PAGES:
1500 case FIELD_ID_COUNT_PARAGRAPHS:
1501 case FIELD_ID_COUNT_WORDS:
1502 case FIELD_ID_COUNT_CHARACTERS:
1503 case FIELD_ID_COUNT_TABLES:
1504 case FIELD_ID_COUNT_GRAPHICS:
1505 case FIELD_ID_COUNT_OBJECTS:
1506 // all properties optional (applies to pages only, but I'll do
1507 // it for all for sake of common implementation)
1508 if (xPropSetInfo->hasPropertyByName(gsPropertyNumberingType))
1510 ProcessNumberingType(GetInt16Property(gsPropertyNumberingType,
1511 rPropSet));
1513 ExportElement(MapCountFieldName(nToken), sPresentation);
1514 break;
1516 case FIELD_ID_CONDITIONAL_TEXT:
1517 ProcessString(XML_CONDITION, XML_NAMESPACE_OOOW,
1518 GetStringProperty(gsPropertyCondition, rPropSet));
1519 ProcessString(XML_STRING_VALUE_IF_TRUE,
1520 GetStringProperty(gsPropertyTrueContent, rPropSet));
1521 ProcessString(XML_STRING_VALUE_IF_FALSE,
1522 GetStringProperty(gsPropertyFalseContent, rPropSet));
1523 ProcessBoolean(XML_CURRENT_VALUE,
1524 GetBoolProperty(gsPropertyIsConditionTrue, rPropSet),
1525 false);
1526 ExportElement(XML_CONDITIONAL_TEXT, sPresentation);
1527 break;
1529 case FIELD_ID_HIDDEN_TEXT:
1530 ProcessString(XML_CONDITION, XML_NAMESPACE_OOOW,
1531 GetStringProperty(gsPropertyCondition, rPropSet));
1532 ProcessString(XML_STRING_VALUE,
1533 GetStringProperty(gsPropertyContent, rPropSet));
1534 ProcessBoolean(XML_IS_HIDDEN,
1535 GetBoolProperty(gsPropertyIsHidden, rPropSet),
1536 false);
1537 ExportElement(XML_HIDDEN_TEXT, sPresentation);
1538 break;
1540 case FIELD_ID_HIDDEN_PARAGRAPH:
1541 ProcessString(XML_CONDITION, XML_NAMESPACE_OOOW,
1542 GetStringProperty(gsPropertyCondition, rPropSet));
1543 ProcessBoolean(XML_IS_HIDDEN,
1544 GetBoolProperty(gsPropertyIsHidden, rPropSet),
1545 false);
1546 DBG_ASSERT(sPresentation.isEmpty(),
1547 "Unexpected presentation for hidden paragraph field");
1548 ExportElement(XML_HIDDEN_PARAGRAPH);
1549 break;
1551 case FIELD_ID_TEMPLATE_NAME:
1552 ProcessString(XML_DISPLAY,
1553 MapTemplateDisplayFormat(
1554 GetInt16Property(gsPropertyFileFormat, rPropSet)));
1555 ExportElement(XML_TEMPLATE_NAME, sPresentation);
1556 break;
1558 case FIELD_ID_CHAPTER:
1559 ProcessString(XML_DISPLAY,
1560 MapChapterDisplayFormat(
1561 GetInt16Property(gsPropertyChapterFormat, rPropSet)));
1562 // API numbers 0..9, we number 1..10
1563 ProcessInteger(XML_OUTLINE_LEVEL,
1564 GetInt8Property(gsPropertyLevel, rPropSet) + 1);
1565 ExportElement(XML_CHAPTER, sPresentation);
1566 break;
1568 case FIELD_ID_FILE_NAME:
1569 // all properties are optional
1570 if (xPropSetInfo->hasPropertyByName(gsPropertyFileFormat))
1572 ProcessString(XML_DISPLAY,
1573 MapFilenameDisplayFormat(
1574 GetInt16Property(gsPropertyFileFormat, rPropSet)));
1576 if (xPropSetInfo->hasPropertyByName(gsPropertyIsFixed))
1578 ProcessBoolean(XML_FIXED,
1579 GetBoolProperty(gsPropertyIsFixed, rPropSet),
1580 false);
1582 ExportElement(XML_FILE_NAME, sPresentation);
1583 break;
1585 case FIELD_ID_REFPAGE_SET:
1586 ProcessBoolean(XML_ACTIVE,
1587 GetBoolProperty(gsPropertyOn, rPropSet), true);
1588 ProcessIntegerDef(XML_PAGE_ADJUST,
1589 GetInt16Property(gsPropertyOffset, rPropSet), 0);
1590 DBG_ASSERT(sPresentation.isEmpty(),
1591 "Unexpected presentation page variable field");
1592 ExportElement(XML_PAGE_VARIABLE_SET);
1593 break;
1595 case FIELD_ID_REFPAGE_GET:
1596 ProcessNumberingType(
1597 GetInt16Property(gsPropertyNumberingType, rPropSet));
1598 ExportElement(XML_PAGE_VARIABLE_GET, sPresentation);
1599 break;
1601 case FIELD_ID_MACRO:
1602 ExportMacro( rPropSet, sPresentation );
1603 break;
1605 case FIELD_ID_REF_SEQUENCE:
1606 // reference to sequence: format, name, find value (and element)
1607 // was: if (nSeqNumber != -1) ...
1608 ProcessString(XML_REFERENCE_FORMAT,
1609 MapReferenceType(GetInt16Property(
1610 gsPropertyReferenceFieldPart, rPropSet)),
1611 XML_TEMPLATE);
1612 ProcessString(XML_REF_NAME,
1613 MakeSequenceRefName(
1614 GetInt16Property(gsPropertySequenceNumber, rPropSet),
1615 GetStringProperty(gsPropertySourceName, rPropSet) ) );
1616 if (xPropSetInfo->hasPropertyByName(gsPropertyReferenceFieldLanguage) &&
1617 GetExport().getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
1619 // export text:reference-language attribute, if not empty
1620 ProcessString(XML_REFERENCE_LANGUAGE,
1621 GetStringProperty(gsPropertyReferenceFieldLanguage, rPropSet), true, XML_NAMESPACE_LO_EXT);
1623 ExportElement(
1624 MapReferenceSource(
1625 GetInt16Property(gsPropertyReferenceFieldSource, rPropSet)),
1626 sPresentation);
1627 break;
1629 case FIELD_ID_REF_REFERENCE:
1630 case FIELD_ID_REF_BOOKMARK:
1631 // reference to bookmarks, references: format, name (and element)
1632 ProcessString(XML_REFERENCE_FORMAT,
1633 MapReferenceType(GetInt16Property(
1634 gsPropertyReferenceFieldPart, rPropSet)),
1635 XML_TEMPLATE);
1636 ProcessString(XML_REF_NAME,
1637 GetStringProperty(gsPropertySourceName, rPropSet));
1638 if (xPropSetInfo->hasPropertyByName(gsPropertyReferenceFieldLanguage) &&
1639 GetExport().getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
1641 // export text:reference-language attribute, if not empty
1642 ProcessString(XML_REFERENCE_LANGUAGE,
1643 GetStringProperty(gsPropertyReferenceFieldLanguage, rPropSet), true, XML_NAMESPACE_LO_EXT);
1645 ExportElement(
1646 MapReferenceSource(GetInt16Property(
1647 gsPropertyReferenceFieldSource, rPropSet)),
1648 sPresentation);
1649 break;
1651 case FIELD_ID_REF_FOOTNOTE:
1652 case FIELD_ID_REF_ENDNOTE:
1653 // reference to end-/footnote: format, generate name, (and element)
1654 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_NOTE_CLASS,
1655 FIELD_ID_REF_ENDNOTE==nToken ? XML_ENDNOTE : XML_FOOTNOTE );
1656 ProcessString(XML_REFERENCE_FORMAT,
1657 MapReferenceType(GetInt16Property(
1658 gsPropertyReferenceFieldPart, rPropSet)),
1659 XML_TEMPLATE);
1660 ProcessString(XML_REF_NAME,
1661 MakeFootnoteRefName(GetInt16Property(
1662 gsPropertySequenceNumber, rPropSet)));
1663 if (xPropSetInfo->hasPropertyByName(gsPropertyReferenceFieldLanguage) &&
1664 GetExport().getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
1666 // export text:reference-language attribute, if not empty
1667 ProcessString(XML_REFERENCE_LANGUAGE,
1668 GetStringProperty(gsPropertyReferenceFieldLanguage, rPropSet), true, XML_NAMESPACE_LO_EXT);
1670 ExportElement(
1671 MapReferenceSource(GetInt16Property(
1672 gsPropertyReferenceFieldSource, rPropSet)),
1673 sPresentation);
1674 break;
1676 case FIELD_ID_DDE:
1677 // name from field master
1678 ProcessString(XML_CONNECTION_NAME,
1680 GetStringProperty(gsPropertyName,
1681 GetMasterPropertySet(rTextField)));
1682 ExportElement(XML_DDE_CONNECTION, sPresentation);
1683 break;
1685 case FIELD_ID_SHEET_NAME:
1686 // name of spreadsheet (Calc only)
1687 ExportElement(XML_SHEET_NAME, sPresentation);
1688 break;
1690 case FIELD_ID_PAGENAME:
1692 if (GetExport().getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
1694 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_LO_EXT, XML_PAGE_NAME, false, false );
1695 GetExport().Characters( sPresentation );
1697 break;
1700 case FIELD_ID_URL:
1702 // this field is a special case because it gets mapped onto a
1703 // hyperlink, rather than one of the regular text field.
1704 ProcessString(XML_HREF, GetExport().GetRelativeReference(GetStringProperty(gsPropertyURL, rPropSet)),
1705 false, XML_NAMESPACE_XLINK);
1706 ProcessString(XML_TARGET_FRAME_NAME,
1707 GetStringProperty(gsPropertyTargetFrame,rPropSet),
1708 true, XML_NAMESPACE_OFFICE);
1709 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1710 SvXMLElementExport aUrlField(rExport, XML_NAMESPACE_TEXT, XML_A,
1711 false, false);
1712 GetExport().Characters(sPresentation);
1713 break;
1716 case FIELD_ID_BIBLIOGRAPHY:
1718 ProcessBibliographyData(rPropSet);
1719 ExportElement(XML_BIBLIOGRAPHY_MARK, sPresentation);
1720 break;
1723 case FIELD_ID_SCRIPT:
1724 ProcessString(XML_LANGUAGE,
1725 GetStringProperty(gsPropertyScriptType, rPropSet),
1726 true, XML_NAMESPACE_SCRIPT);
1727 DBG_ASSERT(sPresentation.isEmpty(),
1728 "Unexpected presentation for script field");
1729 if (GetBoolProperty(gsPropertyURLContent, rPropSet))
1731 ProcessString(XML_HREF,
1732 GetExport().GetRelativeReference(GetStringProperty(gsPropertyContent, rPropSet)),
1733 false, XML_NAMESPACE_XLINK);
1734 ExportElement(XML_SCRIPT);
1736 else
1738 ExportElement(XML_SCRIPT,
1739 GetStringProperty(gsPropertyContent, rPropSet));
1741 break;
1743 case FIELD_ID_ANNOTATION:
1745 // check for empty presentation (just in case)
1746 DBG_ASSERT(sPresentation.isEmpty(),
1747 "Unexpected presentation for annotation field");
1749 // annotation element + content
1750 OUString aName;
1751 rPropSet->getPropertyValue(gsPropertyName) >>= aName;
1752 if (!aName.isEmpty())
1754 GetExport().AddAttribute(XML_NAMESPACE_OFFICE, XML_NAME, aName);
1756 SvtSaveOptions::ODFSaneDefaultVersion eVersion = rExport.getSaneDefaultVersion();
1757 if (eVersion & SvtSaveOptions::ODFSVER_EXTENDED)
1759 bool b = GetBoolProperty("Resolved", rPropSet);
1760 OUString aResolvedText;
1761 OUStringBuffer aResolvedTextBuffer;
1762 ::sax::Converter::convertBool(aResolvedTextBuffer, b);
1763 aResolvedText = aResolvedTextBuffer.makeStringAndClear();
1765 GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_RESOLVED, aResolvedText);
1767 SvXMLElementExport aElem(GetExport(), XML_NAMESPACE_OFFICE,
1768 XML_ANNOTATION, false, true);
1770 // author
1771 OUString aAuthor( GetStringProperty(gsPropertyAuthor, rPropSet) );
1772 if( !aAuthor.isEmpty() )
1774 SvXMLElementExport aCreatorElem( GetExport(), XML_NAMESPACE_DC,
1775 XML_CREATOR, true,
1776 false );
1777 GetExport().Characters(aAuthor);
1780 // date time
1781 util::DateTime aDate( GetDateTimeProperty(gsPropertyDateTimeValue, rPropSet) );
1783 OUStringBuffer aBuffer;
1784 ::sax::Converter::convertDateTime(aBuffer, aDate, nullptr, true);
1785 SvXMLElementExport aDateElem( GetExport(), XML_NAMESPACE_DC,
1786 XML_DATE, true,
1787 false );
1788 GetExport().Characters(aBuffer.makeStringAndClear());
1791 if (GetExport().getSaneDefaultVersion() > SvtSaveOptions::ODFSVER_012)
1793 // initials
1794 OUString aInitials( GetStringProperty(gsPropertyInitials, rPropSet) );
1795 if( !aInitials.isEmpty() )
1797 // ODF 1.3 OFFICE-3776 export meta:creator-initials for ODF 1.3
1798 SvXMLElementExport aCreatorElem( GetExport(),
1799 (SvtSaveOptions::ODFSVER_013 <= GetExport().getSaneDefaultVersion())
1800 ? XML_NAMESPACE_META
1801 : XML_NAMESPACE_LO_EXT,
1803 (SvtSaveOptions::ODFSVER_013 <= GetExport().getSaneDefaultVersion())
1804 ? XML_CREATOR_INITIALS
1805 : XML_SENDER_INITIALS,
1806 true, false );
1807 GetExport().Characters(aInitials);
1811 css::uno::Reference < css::text::XText > xText;
1814 css::uno::Any aRet = rPropSet->getPropertyValue(gsPropertyTextRange);
1815 aRet >>= xText;
1817 catch ( css::uno::Exception& )
1820 if ( xText.is() )
1821 GetExport().GetTextParagraphExport()->exportText( xText );
1822 else
1823 ProcessParagraphSequence(GetStringProperty(gsPropertyContent,rPropSet));
1824 break;
1827 case FIELD_ID_COMBINED_CHARACTERS:
1829 // The style with the combined characters attribute has
1830 // already been handled in the ExportField method. So all that
1831 // is left to do now is to export the characters.
1832 GetExport().Characters(sPresentation);
1833 break;
1836 case FIELD_ID_META:
1838 ExportMetaField(rPropSet, false, bProgress, rPrevCharIsSpace);
1839 break;
1842 case FIELD_ID_MEASURE:
1844 ProcessString(XML_KIND, MapMeasureKind(GetInt16Property(gsPropertyMeasureKind, rPropSet)));
1845 ExportElement( XML_MEASURE, sPresentation );
1846 break;
1849 case FIELD_ID_TABLE_FORMULA:
1850 ProcessString( XML_FORMULA, XML_NAMESPACE_OOOW,
1851 GetStringProperty(gsPropertyContent, rPropSet) );
1852 ProcessDisplay( true,
1853 GetBoolProperty(gsPropertyIsShowFormula, rPropSet) );
1854 ProcessValueAndType( false,
1855 GetIntProperty(gsPropertyNumberFormat, rPropSet),
1856 "", "", 0.0f,
1857 false, false, true,
1858 false );
1859 ExportElement( XML_TABLE_FORMULA, sPresentation );
1860 break;
1862 case FIELD_ID_DROP_DOWN:
1864 // tdf#133555 don't export in strict ODF versions that don't have it
1865 if (GetExport().getSaneDefaultVersion() <= SvtSaveOptions::ODFSVER_012)
1867 break;
1869 ProcessString(XML_NAME, GetStringProperty(gsPropertyName, rPropSet));
1870 ProcessString(XML_HELP,
1871 GetStringProperty(gsPropertyHelp, rPropSet), true);
1872 ProcessString(XML_HINT,
1873 GetStringProperty(gsPropertyTooltip, rPropSet), true);
1874 SvXMLElementExport aElem( GetExport(),
1875 XML_NAMESPACE_TEXT, XML_DROP_DOWN,
1876 false, false );
1877 ProcessStringSequence
1878 (GetStringSequenceProperty( gsPropertyItems, rPropSet ),
1879 GetStringProperty( gsPropertySelectedItem, rPropSet ) );
1881 GetExport().Characters( sPresentation );
1883 break;
1885 case FIELD_ID_DRAW_HEADER:
1887 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_PRESENTATION, XML_HEADER, false, false );
1889 break;
1891 case FIELD_ID_DRAW_FOOTER:
1893 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_PRESENTATION, XML_FOOTER, false, false );
1895 break;
1897 case FIELD_ID_DRAW_DATE_TIME:
1899 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_PRESENTATION, XML_DATE_TIME, false, false );
1901 break;
1904 case FIELD_ID_UNKNOWN:
1905 default:
1906 OSL_FAIL("unknown field type encountered!");
1907 // always export content
1908 GetExport().Characters(sPresentation);
1913 /// export field declarations / field masters
1914 void XMLTextFieldExport::ExportFieldDeclarations()
1916 Reference<XText> xEmptyText;
1917 ExportFieldDeclarations(xEmptyText);
1920 /// export field declarations / field masters
1921 void XMLTextFieldExport::ExportFieldDeclarations(
1922 const Reference<XText> & rText )
1924 // store lists for decl elements
1925 vector<OUString> aVarName;
1926 vector<OUString> aUserName;
1927 vector<OUString> aSeqName;
1928 vector<OUString> aDdeName;
1930 // get text fields supplier and field master name access
1931 Reference<XTextFieldsSupplier> xTextFieldsSupp(GetExport().GetModel(),
1932 UNO_QUERY);
1933 if( !xTextFieldsSupp.is() )
1934 return;
1936 Reference<container::XNameAccess> xFieldMasterNameAccess =
1937 xTextFieldsSupp->getTextFieldMasters();
1939 // where to get the text field masters from?
1940 // a) we get a specific XText: then use pUsedMasters
1941 // b) the XText is empty: then export all text fields
1942 Sequence<OUString> aFieldMasters;
1943 if (rText.is())
1945 // export only used masters
1946 DBG_ASSERT(nullptr != pUsedMasters,
1947 "field masters must be recorded in order to be "
1948 "written out separately" );
1949 if (nullptr != pUsedMasters)
1951 map<Reference<XText>, set<OUString> > ::iterator aMapIter =
1952 pUsedMasters->find(rText);
1953 if (aMapIter != pUsedMasters->end())
1955 // found the set of used field masters
1956 aFieldMasters = comphelper::containerToSequence(aMapIter->second);
1957 pUsedMasters->erase(rText);
1959 // else: XText not found -> ignore
1961 // else: no field masters have been recorded -> ignore
1963 else
1965 // no XText: export all!
1966 aFieldMasters = xFieldMasterNameAccess->getElementNames();
1969 for(const OUString& sFieldMaster : std::as_const(aFieldMasters)) {
1971 // workaround for #no-bug#
1972 if ( sFieldMaster.startsWithIgnoreAsciiCase(
1973 "com.sun.star.text.FieldMaster.DataBase.") )
1975 continue;
1979 OUString sFieldMasterType;
1980 OUString sVarName;
1981 ExplodeFieldMasterName(sFieldMaster, sFieldMasterType, sVarName);
1983 // get XPropertySet of this field master
1984 Reference<XPropertySet> xPropSet;
1985 Any aAny = xFieldMasterNameAccess->getByName(sFieldMaster);
1986 aAny >>= xPropSet;
1988 // save interesting field masters
1989 if (sFieldMasterType == FIELD_SERVICE_SETEXP)
1991 sal_Int32 nType = GetIntProperty(gsPropertySubType, xPropSet);
1993 // sequence or variable?
1994 if ( SetVariableType::SEQUENCE == nType )
1996 aSeqName.push_back( sFieldMaster );
1998 else
2000 aVarName.push_back( sFieldMaster );
2003 else if (sFieldMasterType == FIELD_SERVICE_USER)
2005 aUserName.push_back( sFieldMaster );
2007 else if (sFieldMasterType == FIELD_SERVICE_DDE)
2009 aDdeName.push_back( sFieldMaster );
2011 else
2013 ; // ignore
2017 // now process fields:
2019 // variable field masters:
2020 if ( !aVarName.empty() )
2022 SvXMLElementExport aElem( GetExport(),
2023 XML_NAMESPACE_TEXT,
2024 XML_VARIABLE_DECLS,
2025 true, true );
2027 for (const auto& sName : aVarName)
2029 // get field master property set
2030 Reference<XPropertySet> xPropSet;
2031 Any aAny = xFieldMasterNameAccess->getByName(sName);
2032 aAny >>= xPropSet;
2034 // field name and type
2035 OUString sFieldMasterType;
2036 OUString sVarName;
2037 ExplodeFieldMasterName(sName, sFieldMasterType, sVarName);
2039 // determine string/numeric field
2040 bool bIsString = ( GetIntProperty(gsPropertySubType, xPropSet)
2041 == SetVariableType::STRING );
2043 // get dependent field property set
2044 Reference<XPropertySet> xFieldPropSet;
2045 if (GetDependentFieldPropertySet(xPropSet, xFieldPropSet))
2047 // process value and type.
2048 ProcessValueAndType(
2049 bIsString,
2050 GetIntProperty(gsPropertyNumberFormat, xFieldPropSet),
2051 "", "", 0.0,
2052 false, true, false, false);
2054 else
2056 // If no dependent field is found, only string and
2057 // float types can be supported
2059 // number format: 0 is default number format for 1st
2060 // language. should be: getDefaultNumberFormat(Locale)
2061 // from NumberFormats
2062 ProcessValueAndType(
2063 bIsString,
2064 0, "", "", 0.0,
2065 false, true, false, false);
2068 ProcessString(XML_NAME, sVarName);
2069 ExportElement(XML_VARIABLE_DECL, true);
2072 // else: no declarations element
2074 // sequence field masters:
2075 if ( !aSeqName.empty() )
2077 SvXMLElementExport aElem( GetExport(),
2078 XML_NAMESPACE_TEXT,
2079 XML_SEQUENCE_DECLS,
2080 true, true );
2082 for (const auto& sName : aSeqName)
2084 // get field master property set
2085 Reference<XPropertySet> xPropSet;
2086 Any aAny = xFieldMasterNameAccess->getByName(sName);
2087 aAny >>= xPropSet;
2089 // field name and type
2090 OUString sFieldMasterType;
2091 OUString sVarName;
2092 ExplodeFieldMasterName(sName, sFieldMasterType, sVarName);
2094 // outline level
2095 sal_Int32 nLevel = 1 + GetIntProperty(
2096 gsPropertyChapterNumberingLevel, xPropSet);
2097 DBG_ASSERT(nLevel >= 0, "illegal outline level");
2098 DBG_ASSERT(nLevel < 127, "possible illegal outline level");
2099 ProcessInteger(XML_DISPLAY_OUTLINE_LEVEL, nLevel);
2101 // separation character
2102 if (nLevel > 0) {
2103 ProcessString(XML_SEPARATION_CHARACTER, GetStringProperty(
2104 gsPropertyNumberingSeparator, xPropSet));
2106 ProcessString(XML_NAME, sVarName);
2107 ExportElement(XML_SEQUENCE_DECL, true);
2110 // else: no declarations element
2112 // user field masters:
2113 if ( !aUserName.empty() )
2115 SvXMLElementExport aElem( GetExport(),
2116 XML_NAMESPACE_TEXT,
2117 XML_USER_FIELD_DECLS,
2118 true, true );
2120 for (const auto& sName : aUserName)
2122 // get field master property set
2123 Reference<XPropertySet> xPropSet;
2124 Any aAny = xFieldMasterNameAccess->getByName(sName);
2125 aAny >>= xPropSet;
2127 // field name and type
2128 OUString sFieldMasterType;
2129 OUString sVarName;
2130 ExplodeFieldMasterName(sName, sFieldMasterType, sVarName);
2132 if (GetBoolProperty(gsPropertyIsExpression, xPropSet))
2134 // expression:
2135 ProcessValueAndType(
2136 false,
2137 0, "", "",
2138 GetDoubleProperty(gsPropertyValue, xPropSet),
2139 true,
2140 true,
2141 false,
2142 false);
2144 else
2146 // string: write regardless of default
2147 ProcessString(XML_VALUE_TYPE, XML_STRING,
2148 XML_NAMESPACE_OFFICE);
2149 ProcessString(XML_STRING_VALUE,
2150 GetStringProperty(gsPropertyContent, xPropSet),
2151 false, XML_NAMESPACE_OFFICE );
2153 ProcessString(XML_NAME, sVarName);
2154 ExportElement(XML_USER_FIELD_DECL, true);
2157 // else: no declarations element
2159 // DDE field masters:
2160 if ( aDdeName.empty() )
2161 return;
2163 SvXMLElementExport aElem( GetExport(),
2164 XML_NAMESPACE_TEXT,
2165 XML_DDE_CONNECTION_DECLS,
2166 true, true );
2168 for (const auto& sName : aDdeName)
2170 // get field master property set
2171 Reference<XPropertySet> xPropSet;
2172 Any aAny = xFieldMasterNameAccess->getByName(sName);
2173 aAny >>= xPropSet;
2175 // check if this connection is being used by a field
2176 Reference<XPropertySet> xDummy;
2177 if (GetDependentFieldPropertySet(xPropSet, xDummy))
2180 ProcessString(XML_NAME,
2181 GetStringProperty(gsPropertyName, xPropSet),
2182 false, XML_NAMESPACE_OFFICE);
2184 // export elements; can't use ProcessString because
2185 // elements are in office namespace
2186 ProcessString(XML_DDE_APPLICATION,
2187 GetStringProperty(gsPropertyDDECommandType,
2188 xPropSet),
2189 false, XML_NAMESPACE_OFFICE);
2190 ProcessString(XML_DDE_TOPIC,
2191 GetStringProperty(gsPropertyDDECommandFile,
2192 xPropSet),
2193 false, XML_NAMESPACE_OFFICE);
2194 ProcessString(XML_DDE_ITEM,
2195 GetStringProperty(gsPropertyDDECommandElement,
2196 xPropSet),
2197 false, XML_NAMESPACE_OFFICE);
2198 bool bIsAutomaticUpdate = GetBoolProperty(
2199 gsPropertyIsAutomaticUpdate, xPropSet);
2200 if (bIsAutomaticUpdate)
2202 GetExport().AddAttribute(XML_NAMESPACE_OFFICE,
2203 XML_AUTOMATIC_UPDATE,
2204 XML_TRUE);
2207 ExportElement(XML_DDE_CONNECTION_DECL, true);
2209 // else: no dependent field -> no export of field declaration
2211 // else: no declarations element
2214 void XMLTextFieldExport::SetExportOnlyUsedFieldDeclarations(
2215 bool bExportOnlyUsed)
2217 pUsedMasters.reset();
2219 // create used masters set (if none is used)
2220 if (bExportOnlyUsed)
2221 pUsedMasters.reset( new map<Reference<XText>, set<OUString> > );
2224 void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName,
2225 bool bAddSpace)
2227 // can't call ExportElement(eElementName, const OUString&) with empty
2228 // string because xmlprinter only uses empty tags if no content
2229 // (not even empty content) was written.
2231 DBG_ASSERT(XML_TOKEN_INVALID != eElementName, "invalid element name!");
2232 if (XML_TOKEN_INVALID != eElementName)
2234 // Element
2235 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
2236 eElementName, bAddSpace, bAddSpace );
2237 } // else: ignore
2240 void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName,
2241 const OUString& sContent)
2243 DBG_ASSERT(eElementName != XML_TOKEN_INVALID, "invalid element name!");
2244 if (eElementName != XML_TOKEN_INVALID)
2246 // Element
2247 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
2248 eElementName, false, false );
2249 // export content
2250 GetExport().Characters(sContent);
2251 } else {
2252 // always export content
2253 GetExport().Characters(sContent);
2257 void XMLTextFieldExport::ExportMacro(
2258 const Reference<XPropertySet> & rPropSet,
2259 const OUString& rContent )
2261 // some strings we'll need
2262 OUString sEventType( "EventType" );
2263 OUString sPropertyScriptURL( "ScriptURL" );
2266 // the description attribute
2267 ProcessString(XML_DESCRIPTION,
2268 GetStringProperty(gsPropertyHint, rPropSet),
2269 rContent);
2271 // the element
2272 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
2273 XML_EXECUTE_MACRO, false, false );
2275 // the <office:events>-macro:
2277 // 1) build sequence of PropertyValues
2278 Sequence<PropertyValue> aSeq;
2279 OUString sName;
2280 rPropSet->getPropertyValue( sPropertyScriptURL ) >>= sName;
2282 // if the ScriptURL property is not empty then this is a Scripting
2283 // Framework URL, otherwise treat it as a Basic Macro
2284 if (!sName.isEmpty())
2286 OUString sScript( "Script" );
2287 aSeq = Sequence<PropertyValue> (2);
2288 PropertyValue* pArr = aSeq.getArray();
2289 pArr[0].Name = sEventType;
2290 pArr[0].Value <<= sScript;
2291 pArr[1].Name = sScript;
2292 pArr[1].Value = rPropSet->getPropertyValue( sPropertyScriptURL );
2294 else
2296 aSeq = Sequence<PropertyValue> (3);
2297 PropertyValue* pArr = aSeq.getArray();
2298 pArr[0].Name = sEventType;
2299 pArr[0].Value <<= OUString("StarBasic");
2300 pArr[1].Name = "Library";
2301 pArr[1].Value = rPropSet->getPropertyValue( "MacroLibrary" );
2302 pArr[2].Name = "MacroName";
2303 pArr[2].Value = rPropSet->getPropertyValue( "MacroName" );
2306 // 2) export the sequence
2307 GetExport().GetEventExport().ExportSingleEvent( aSeq, "OnClick", false );
2309 // and finally, the field presentation
2310 GetExport().Characters(rContent);
2313 void XMLTextFieldExport::ExportMetaField(
2314 const Reference<XPropertySet> & i_xMeta,
2315 bool i_bAutoStyles, bool i_bProgress,
2316 bool & rPrevCharIsSpace)
2318 bool doExport(!i_bAutoStyles); // do not export element if autostyles
2319 // check version >= 1.2
2320 switch (GetExport().getSaneDefaultVersion()) {
2321 case SvtSaveOptions::ODFSVER_011: // fall through
2322 case SvtSaveOptions::ODFSVER_010: doExport = false; break;
2323 default: break;
2326 const Reference < XEnumerationAccess > xEA( i_xMeta, UNO_QUERY_THROW );
2327 const Reference < XEnumeration > xTextEnum( xEA->createEnumeration() );
2329 if (doExport)
2331 const Reference<rdf::XMetadatable> xMeta( i_xMeta, UNO_QUERY_THROW );
2333 // style:data-style-name
2334 ProcessValueAndType(false,
2335 GetIntProperty(gsPropertyNumberFormat, i_xMeta),
2336 "", "", 0.0, false, false, true,
2337 false );
2339 // text:meta-field without xml:id is invalid
2340 xMeta->ensureMetadataReference();
2342 // xml:id for RDF metadata
2343 GetExport().AddAttributeXmlId(xMeta);
2346 SvXMLElementExport aElem( GetExport(), doExport,
2347 XML_NAMESPACE_TEXT, XML_META_FIELD, false, false );
2349 // recurse to export content
2350 GetExport().GetTextParagraphExport()->
2351 exportTextRangeEnumeration(xTextEnum, i_bAutoStyles, i_bProgress, rPrevCharIsSpace);
2354 /// export all data-style related attributes
2355 void XMLTextFieldExport::ProcessValueAndType(
2356 bool bIsString, /// do we process a string or a number?
2357 sal_Int32 nFormatKey, /// format key for NumberFormatter; inv. if string
2358 const OUString& sContent, /// string content; possibly invalid
2359 const OUString& sDefault, /// default string
2360 double fValue, /// float content; possibly invalid
2361 bool bExportValue, /// export value attribute?
2362 bool bExportValueType, /// export value-type attribute?
2363 bool bExportStyle, /// export style-attribute?
2364 bool bForceSystemLanguage, /// export language attributes?
2365 bool bTimeStyle) // exporting a time style?
2367 // String or number?
2368 if (bIsString)
2371 // string: attributes value-type=string, string-value=...
2373 if (bExportValue || bExportValueType)
2375 XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes(
2376 GetExport(), sContent, sDefault, bExportValue);
2380 else
2383 // number: value-type=..., value...=..., data-style-name=...
2385 DBG_ASSERT(bExportValueType || !bExportValue, "value w/o value type not supported!");
2387 // take care of illegal formats
2388 // (shouldn't happen, but does if document is corrupted)
2389 if (-1 != nFormatKey)
2391 if (bExportValue || bExportValueType)
2393 XMLNumberFormatAttributesExportHelper::
2394 SetNumberFormatAttributes(
2395 GetExport(), nFormatKey, fValue, bExportValue);
2398 if (bExportStyle)
2400 // don't export language (if desired)
2401 if( bForceSystemLanguage )
2402 nFormatKey =
2403 GetExport().dataStyleForceSystemLanguage( nFormatKey );
2405 OUString sDataStyleName =
2406 GetExport().getDataStyleName(nFormatKey, bTimeStyle);
2407 if( !sDataStyleName.isEmpty() )
2409 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
2410 XML_DATA_STYLE_NAME,
2411 sDataStyleName );
2412 } // else: ignore (no valid number format)
2413 } // else: ignore (no number format)
2419 /// process display related properties
2420 void XMLTextFieldExport::ProcessDisplay(bool bIsVisible,
2421 bool bIsCommand)
2423 enum XMLTokenEnum eValue;
2425 if (bIsVisible)
2427 eValue = bIsCommand ? XML_FORMULA : XML_VALUE;
2429 else
2431 eValue = XML_NONE;
2434 // omit attribute if default
2435 if (eValue != XML_VALUE)
2437 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_DISPLAY, eValue);
2442 /// export boolean property
2443 void XMLTextFieldExport::ProcessBoolean(enum XMLTokenEnum eName,
2444 bool bBool, bool bDefault)
2446 SAL_WARN_IF( eName == XML_TOKEN_INVALID, "xmloff.text", "invalid element token");
2447 if ( XML_TOKEN_INVALID == eName )
2448 return;
2450 // write attribute (if different than default)
2451 // negate to force 0/1 values (and make sal_Bool comparable)
2452 if ((!bBool) != (!bDefault)) {
2453 GetExport().AddAttribute(XML_NAMESPACE_TEXT, eName,
2454 (bBool ? XML_TRUE : XML_FALSE) );
2459 /// export string attribute
2460 void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName,
2461 const OUString& sValue,
2462 bool bOmitEmpty,
2463 sal_uInt16 nPrefix)
2465 SAL_WARN_IF( eName == XML_TOKEN_INVALID, "xmloff.text", "invalid element token");
2466 if ( XML_TOKEN_INVALID == eName )
2467 return;
2469 // check for empty string, if applicable
2470 if ( bOmitEmpty && sValue.isEmpty() )
2471 return;
2473 // write attribute
2474 GetExport().AddAttribute(nPrefix, eName, sValue);
2477 void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName,
2478 sal_uInt16 nValuePrefix,
2479 const OUString& sValue)
2481 OUString sQValue =
2482 GetExport().GetNamespaceMap().GetQNameByKey( nValuePrefix, sValue, false );
2483 ProcessString( eName, sQValue );
2486 /// export a string attribute
2487 void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName,
2488 const OUString& sValue,
2489 const OUString& sDefault)
2491 if (sValue != sDefault)
2493 ProcessString(eName, sValue);
2497 /// export a string attribute
2498 void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName,
2499 sal_uInt16 nValuePrefix,
2500 const OUString& sValue,
2501 const OUString& sDefault)
2503 if (sValue != sDefault)
2505 ProcessString(eName, nValuePrefix, sValue);
2510 /// export string attribute
2511 void XMLTextFieldExport::ProcessString(
2512 enum XMLTokenEnum eName,
2513 enum XMLTokenEnum eValue,
2514 sal_uInt16 nPrefix)
2516 SAL_WARN_IF( eName == XML_TOKEN_INVALID, "xmloff.text", "invalid element token" );
2517 SAL_WARN_IF( eValue == XML_TOKEN_INVALID, "xmloff.text", "invalid value token" );
2518 if ( XML_TOKEN_INVALID == eName )
2519 return;
2521 GetExport().AddAttribute(nPrefix, eName, eValue);
2524 /// export a string attribute
2525 void XMLTextFieldExport::ProcessString(
2526 enum XMLTokenEnum eName,
2527 enum XMLTokenEnum eValue,
2528 enum XMLTokenEnum eDefault)
2530 if ( eValue != eDefault )
2531 ProcessString( eName, eValue);
2535 /// export a string as a sequence of paragraphs
2536 void XMLTextFieldExport::ProcessParagraphSequence(
2537 const OUString& sParagraphSequence)
2539 // iterate over all string-pieces separated by return (0x0a) and
2540 // put each inside a paragraph element.
2541 SvXMLTokenEnumerator aEnumerator(sParagraphSequence, char(0x0a));
2542 OUString aSubString;
2543 while (aEnumerator.getNextToken(aSubString))
2545 SvXMLElementExport aParagraph(
2546 GetExport(), XML_NAMESPACE_TEXT, XML_P, true, false);
2547 GetExport().Characters(aSubString);
2551 // export an integer attribute
2552 void XMLTextFieldExport::ProcessInteger(enum XMLTokenEnum eName,
2553 sal_Int32 nNum)
2555 SAL_WARN_IF( eName == XML_TOKEN_INVALID, "xmloff.text", "invalid element token");
2556 if ( XML_TOKEN_INVALID == eName )
2557 return;
2559 GetExport().AddAttribute(XML_NAMESPACE_TEXT, eName,
2560 OUString::number(nNum));
2563 /// export an integer attribute, omit if default
2564 void XMLTextFieldExport::ProcessIntegerDef(enum XMLTokenEnum eName,
2565 sal_Int32 nNum, sal_Int32 nDefault)
2567 if (nNum != nDefault)
2568 ProcessInteger(eName, nNum);
2572 /// export a numbering type
2573 void XMLTextFieldExport::ProcessNumberingType(sal_Int16 nNumberingType)
2575 // process only if real format (not: like page descriptor)
2576 if (NumberingType::PAGE_DESCRIPTOR == nNumberingType)
2577 return;
2579 OUStringBuffer sTmp( 10 );
2580 // number type: num format
2581 GetExport().GetMM100UnitConverter().convertNumFormat( sTmp,
2582 nNumberingType );
2583 GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_FORMAT,
2584 sTmp.makeStringAndClear() );
2585 // and letter sync, if applicable
2586 SvXMLUnitConverter::convertNumLetterSync( sTmp, nNumberingType );
2588 if (!sTmp.isEmpty())
2590 GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_LETTER_SYNC,
2591 sTmp.makeStringAndClear() );
2593 // else: like page descriptor => ignore
2597 /// export a date, time, or duration
2598 void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName,
2599 double dValue,
2600 bool bIsDate,
2601 bool bIsDuration,
2602 bool bOmitDurationIfZero,
2603 sal_uInt16 nPrefix)
2605 // truncate for date granularity
2606 if (bIsDate)
2608 dValue = ::rtl::math::approxFloor(dValue);
2611 OUStringBuffer aBuffer;
2612 if (bIsDuration)
2614 // date/time duration handle bOmitDurationIfZero
2615 if (!bOmitDurationIfZero || dValue != 0.0)
2617 ::sax::Converter::convertDuration(aBuffer, dValue);
2620 else
2622 // date/time value
2623 rExport.GetMM100UnitConverter().convertDateTime(aBuffer, dValue);
2626 // output attribute
2627 ProcessString(eName, aBuffer.makeStringAndClear(), true, nPrefix);
2630 /// export a date or time
2631 void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName,
2632 const util::DateTime& rTime)
2634 OUStringBuffer aBuffer;
2636 util::DateTime aDateTime(rTime);
2638 // date/time value
2639 ::sax::Converter::convertDateTime(aBuffer, aDateTime, nullptr);
2641 // output attribute
2642 ProcessString(eName, aBuffer.makeStringAndClear(), true);
2645 /// export a date, time, or duration
2646 void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName,
2647 sal_Int32 nMinutes,
2648 bool bIsDate,
2649 bool bIsDuration)
2651 // handle bOmitDurationIfZero here, because we can precisely compare ints
2652 if (!(bIsDuration && (nMinutes==0)))
2654 ProcessDateTime(eName, static_cast<double>(nMinutes) / double(24*60),
2655 bIsDate, bIsDuration);
2659 /// export a time or dateTime
2660 void XMLTextFieldExport::ProcessTimeOrDateTime(enum XMLTokenEnum eName,
2661 const util::DateTime& rTime)
2663 OUStringBuffer aBuffer;
2665 // date/time value
2666 ::sax::Converter::convertTimeOrDateTime(aBuffer, rTime);
2668 // output attribute
2669 ProcessString(eName, aBuffer.makeStringAndClear(), true);
2673 SvXMLEnumMapEntry<sal_Int16> const aBibliographyDataTypeMap[] =
2675 { XML_ARTICLE, BibliographyDataType::ARTICLE },
2676 { XML_BOOK, BibliographyDataType::BOOK },
2677 { XML_BOOKLET, BibliographyDataType::BOOKLET },
2678 { XML_CONFERENCE, BibliographyDataType::CONFERENCE },
2679 { XML_CUSTOM1, BibliographyDataType::CUSTOM1 },
2680 { XML_CUSTOM2, BibliographyDataType::CUSTOM2 },
2681 { XML_CUSTOM3, BibliographyDataType::CUSTOM3 },
2682 { XML_CUSTOM4, BibliographyDataType::CUSTOM4 },
2683 { XML_CUSTOM5, BibliographyDataType::CUSTOM5 },
2684 { XML_EMAIL, BibliographyDataType::EMAIL },
2685 { XML_INBOOK, BibliographyDataType::INBOOK },
2686 { XML_INCOLLECTION, BibliographyDataType::INCOLLECTION },
2687 { XML_INPROCEEDINGS, BibliographyDataType::INPROCEEDINGS },
2688 { XML_JOURNAL, BibliographyDataType::JOURNAL },
2689 { XML_MANUAL, BibliographyDataType::MANUAL },
2690 { XML_MASTERSTHESIS, BibliographyDataType::MASTERSTHESIS },
2691 { XML_MISC, BibliographyDataType::MISC },
2692 { XML_PHDTHESIS, BibliographyDataType::PHDTHESIS },
2693 { XML_PROCEEDINGS, BibliographyDataType::PROCEEDINGS },
2694 { XML_TECHREPORT, BibliographyDataType::TECHREPORT },
2695 { XML_UNPUBLISHED, BibliographyDataType::UNPUBLISHED },
2696 { XML_WWW, BibliographyDataType::WWW },
2697 { XML_TOKEN_INVALID, 0 }
2701 void XMLTextFieldExport::ProcessBibliographyData(
2702 const Reference<XPropertySet>& rPropSet)
2704 // get the values
2705 Any aAny = rPropSet->getPropertyValue(gsPropertyFields);
2706 Sequence<PropertyValue> aValues;
2707 aAny >>= aValues;
2709 // one attribute per value (unless empty)
2710 for (const auto& rProp : std::as_const(aValues))
2712 if( rProp.Name == "BibiliographicType" )
2714 sal_Int16 nTypeId = 0;
2715 rProp.Value >>= nTypeId;
2716 OUStringBuffer sBuf;
2718 if (SvXMLUnitConverter::convertEnum(sBuf, nTypeId,
2719 aBibliographyDataTypeMap))
2721 rExport.AddAttribute(XML_NAMESPACE_TEXT,
2722 XML_BIBLIOGRAPHY_TYPE,
2723 sBuf.makeStringAndClear());
2725 // else: ignore this argument
2727 else
2729 OUString sStr;
2730 rProp.Value >>= sStr;
2732 if (!sStr.isEmpty())
2734 rExport.AddAttribute(XML_NAMESPACE_TEXT,
2735 MapBibliographyFieldName(rProp.Name),
2736 sStr);
2742 /// export CommandTypeAttribute
2743 void XMLTextFieldExport::ProcessCommandType(
2744 sal_Int32 nCommandType)
2746 enum XMLTokenEnum eToken = XML_TOKEN_INVALID;
2747 switch( nCommandType )
2749 case sdb::CommandType::TABLE: eToken = XML_TABLE; break;
2750 case sdb::CommandType::QUERY: eToken = XML_QUERY; break;
2751 case sdb::CommandType::COMMAND: eToken = XML_COMMAND; break;
2754 if( eToken != XML_TOKEN_INVALID )
2755 rExport.AddAttribute( XML_NAMESPACE_TEXT, XML_TABLE_TYPE, eToken );
2759 void XMLTextFieldExport::ProcessStringSequence(
2760 const Sequence<OUString>& rSequence,
2761 const OUString& sSelected )
2763 // find selected element
2764 sal_Int32 nSelected = comphelper::findValue(rSequence, sSelected);
2766 // delegate to ProcessStringSequence(OUString,sal_Int32)
2767 ProcessStringSequence( rSequence, nSelected );
2770 void XMLTextFieldExport::ProcessStringSequence(
2771 const Sequence<OUString>& rSequence,
2772 sal_Int32 nSelected )
2774 sal_Int32 nLength = rSequence.getLength();
2775 const OUString* pSequence = rSequence.getConstArray();
2776 for( sal_Int32 i = 0; i < nLength; i++ )
2778 if( i == nSelected )
2779 rExport.AddAttribute( XML_NAMESPACE_TEXT,
2780 XML_CURRENT_SELECTED, XML_TRUE );
2781 rExport.AddAttribute( XML_NAMESPACE_TEXT, XML_VALUE, pSequence[i] );
2782 SvXMLElementExport aElement( rExport, XML_NAMESPACE_TEXT, XML_LABEL,
2783 false, false );
2787 void XMLTextFieldExport::ExportDataBaseElement(
2788 enum XMLTokenEnum eElementName,
2789 const OUString& sPresentation,
2790 const Reference<XPropertySet>& rPropertySet,
2791 const Reference<XPropertySetInfo>& rPropertySetInfo )
2793 SAL_WARN_IF( eElementName == XML_TOKEN_INVALID, "xmloff.text", "need token" );
2794 SAL_WARN_IF( !rPropertySet.is(), "xmloff.text", "need property set" );
2795 SAL_WARN_IF( !rPropertySetInfo.is(), "xmloff.text", "need property set info" );
2797 // get database properties
2798 OUString sDataBaseName;
2799 OUString sDataBaseURL;
2800 OUString sStr;
2801 if( ( rPropertySet->getPropertyValue( gsPropertyDataBaseName ) >>= sStr )
2802 && !sStr.isEmpty() )
2804 sDataBaseName = sStr;
2806 else if( rPropertySetInfo->hasPropertyByName( gsPropertyDataBaseURL ) &&
2807 (rPropertySet->getPropertyValue( gsPropertyDataBaseURL ) >>= sStr) &&
2808 !sStr.isEmpty() )
2810 sDataBaseURL = sStr;
2813 // add database name property (if present)
2814 if( !sDataBaseName.isEmpty() )
2815 rExport.AddAttribute( XML_NAMESPACE_TEXT, XML_DATABASE_NAME,
2816 sDataBaseName );
2817 SvXMLElementExport aDataBaseElement( GetExport(),
2818 XML_NAMESPACE_TEXT, eElementName,
2819 false, false );
2821 // write URL as children
2822 if( !sDataBaseURL.isEmpty() )
2824 rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sDataBaseURL );
2825 SvXMLElementExport aDataSourceElement(
2826 GetExport(), XML_NAMESPACE_FORM, XML_CONNECTION_RESOURCE,
2827 false, false );
2830 // write presentation
2831 rExport.Characters( sPresentation );
2835 // explode a field master name into field type and field name
2836 void XMLTextFieldExport::ExplodeFieldMasterName(
2837 const OUString& sMasterName, OUString& sFieldType, OUString& sVarName)
2839 sal_Int32 nLength = gsFieldMasterPrefix.getLength();
2840 sal_Int32 nSeparator = sMasterName.indexOf('.', nLength);
2842 // '.' found?
2843 if (nSeparator <= nLength) {
2844 SAL_WARN("xmloff.text", "no field var name!");
2846 else
2848 sFieldType = sMasterName.copy(nLength, nSeparator-nLength);
2849 sVarName = sMasterName.copy(nSeparator+1);
2854 // for XDependentTextFields, get PropertySet of FieldMaster
2855 Reference<XPropertySet> XMLTextFieldExport::GetMasterPropertySet(
2856 const Reference<XTextField> & rTextField)
2858 // name, value => get Property set of TextFieldMaster
2859 Reference<XDependentTextField> xDep(rTextField, UNO_QUERY);
2860 return xDep->getTextFieldMaster();
2863 // get PropertySet of (any; the first) dependent field
2864 bool XMLTextFieldExport::GetDependentFieldPropertySet(
2865 const Reference<XPropertySet> & xMaster,
2866 Reference<XPropertySet> & xField)
2868 Any aAny;
2869 Sequence<Reference<XDependentTextField> > aFields;
2870 aAny = xMaster->getPropertyValue(gsPropertyDependentTextFields);
2871 aAny >>= aFields;
2873 // any fields?
2874 if (aFields.hasElements())
2876 // get first one and return
2877 Reference<XDependentTextField> xTField = aFields[0];
2878 xField.set(xTField, UNO_QUERY);
2879 DBG_ASSERT(xField.is(),
2880 "Surprisingly, this TextField refuses to be a PropertySet!");
2881 return true;
2883 else
2885 return false;
2890 /// map placeholder type
2891 enum XMLTokenEnum XMLTextFieldExport::MapPlaceholderType(sal_uInt16 nType)
2893 enum XMLTokenEnum eType = XML_TEXT;
2895 switch (nType)
2897 case PlaceholderType::TEXT:
2898 eType = XML_TEXT;
2899 break;
2901 case PlaceholderType::TABLE:
2902 eType = XML_TABLE;
2903 break;
2905 case PlaceholderType::TEXTFRAME:
2906 eType = XML_TEXT_BOX;
2907 break;
2909 case PlaceholderType::GRAPHIC:
2910 eType = XML_IMAGE;
2911 break;
2913 case PlaceholderType::OBJECT:
2914 eType = XML_OBJECT;
2915 break;
2917 default:
2918 // unknown placeholder: XML_TEXT
2919 OSL_FAIL("unknown placeholder type");
2922 return eType;
2926 /// element name for author fields
2927 enum XMLTokenEnum XMLTextFieldExport::MapAuthorFieldName(
2928 const Reference<XPropertySet> & xPropSet)
2930 // Initials or full name?
2931 return GetBoolProperty(gsPropertyFullName, xPropSet)
2932 ? XML_AUTHOR_NAME : XML_AUTHOR_INITIALS;
2935 enum XMLTokenEnum XMLTextFieldExport::MapPageNumberName(
2936 const Reference<XPropertySet> & xPropSet,
2937 sal_Int32& nOffset)
2939 enum XMLTokenEnum eName = XML_TOKEN_INVALID;
2940 PageNumberType ePage;
2941 Any aAny = xPropSet->getPropertyValue(gsPropertySubType);
2942 ePage = *o3tl::doAccess<PageNumberType>(aAny);
2944 switch (ePage)
2946 case PageNumberType_PREV:
2947 eName = XML_PREVIOUS;
2948 nOffset += 1;
2949 break;
2950 case PageNumberType_CURRENT:
2951 eName = XML_CURRENT;
2952 break;
2953 case PageNumberType_NEXT:
2954 eName = XML_NEXT;
2955 nOffset -= 1;
2956 break;
2957 default:
2958 OSL_FAIL("unknown page number type");
2959 eName = XML_TOKEN_INVALID;
2960 break;
2963 return eName;
2966 /// map TemplateDisplayFormat to XML
2967 enum XMLTokenEnum XMLTextFieldExport::MapTemplateDisplayFormat(sal_Int16 nFormat)
2969 enum XMLTokenEnum eName = XML_TOKEN_INVALID;
2971 switch (nFormat)
2973 case TemplateDisplayFormat::FULL:
2974 eName = XML_FULL;
2975 break;
2976 case TemplateDisplayFormat::PATH:
2977 eName = XML_PATH;
2978 break;
2979 case TemplateDisplayFormat::NAME:
2980 eName = XML_NAME;
2981 break;
2982 case TemplateDisplayFormat::NAME_AND_EXT:
2983 eName = XML_NAME_AND_EXTENSION;
2984 break;
2985 case TemplateDisplayFormat::AREA:
2986 eName = XML_AREA;
2987 break;
2988 case TemplateDisplayFormat::TITLE:
2989 eName = XML_TITLE;
2990 break;
2991 default:
2992 OSL_FAIL("unknown template display format");
2993 eName = XML_TOKEN_INVALID;
2994 break;
2997 return eName;
3000 /// map count/statistics field token to XML name
3001 enum XMLTokenEnum XMLTextFieldExport::MapCountFieldName(FieldIdEnum nToken)
3003 enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
3005 switch (nToken)
3007 case FIELD_ID_COUNT_PAGES:
3008 eElement = XML_PAGE_COUNT;
3009 break;
3010 case FIELD_ID_COUNT_PARAGRAPHS:
3011 eElement = XML_PARAGRAPH_COUNT;
3012 break;
3013 case FIELD_ID_COUNT_WORDS:
3014 eElement = XML_WORD_COUNT;
3015 break;
3016 case FIELD_ID_COUNT_CHARACTERS:
3017 eElement = XML_CHARACTER_COUNT;
3018 break;
3019 case FIELD_ID_COUNT_TABLES:
3020 eElement = XML_TABLE_COUNT;
3021 break;
3022 case FIELD_ID_COUNT_GRAPHICS:
3023 eElement = XML_IMAGE_COUNT;
3024 break;
3025 case FIELD_ID_COUNT_OBJECTS:
3026 eElement = XML_OBJECT_COUNT;
3027 break;
3028 default:
3029 OSL_FAIL("no count field token");
3030 eElement = XML_TOKEN_INVALID;
3031 break;
3034 return eElement;
3037 /// map ChapterDisplayFormat to XML string
3038 enum XMLTokenEnum XMLTextFieldExport::MapChapterDisplayFormat(sal_Int16 nFormat)
3040 enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3042 switch (nFormat)
3044 case ChapterFormat::NAME:
3045 eName = XML_NAME;
3046 break;
3047 case ChapterFormat::NUMBER:
3048 eName = XML_NUMBER;
3049 break;
3050 case ChapterFormat::NAME_NUMBER:
3051 eName = XML_NUMBER_AND_NAME;
3052 break;
3053 case ChapterFormat::NO_PREFIX_SUFFIX:
3054 eName = XML_PLAIN_NUMBER_AND_NAME;
3055 break;
3056 case ChapterFormat::DIGIT:
3057 eName = XML_PLAIN_NUMBER;
3058 break;
3059 default:
3060 OSL_FAIL("unknown chapter display format");
3061 eName = XML_TOKEN_INVALID;
3062 break;
3065 return eName;
3069 /// map FilenameDisplayFormat to XML attribute names
3070 enum XMLTokenEnum XMLTextFieldExport::MapFilenameDisplayFormat(sal_Int16 nFormat)
3072 enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3074 switch (nFormat)
3076 case FilenameDisplayFormat::FULL:
3077 eName = XML_FULL;
3078 break;
3079 case FilenameDisplayFormat::PATH:
3080 eName = XML_PATH;
3081 break;
3082 case FilenameDisplayFormat::NAME:
3083 eName = XML_NAME;
3084 break;
3085 case FilenameDisplayFormat::NAME_AND_EXT:
3086 eName = XML_NAME_AND_EXTENSION;
3087 break;
3088 default:
3089 OSL_FAIL("unknown filename display format");
3092 return eName;
3096 /// map ReferenceFieldPart to XML string
3097 enum XMLTokenEnum XMLTextFieldExport::MapReferenceType(sal_Int16 nType)
3099 enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
3101 switch (nType)
3103 case ReferenceFieldPart::PAGE:
3104 eElement = XML_PAGE;
3105 break;
3106 case ReferenceFieldPart::CHAPTER:
3107 eElement = XML_CHAPTER;
3108 break;
3109 case ReferenceFieldPart::TEXT:
3110 eElement = XML_TEXT;
3111 break;
3112 case ReferenceFieldPart::UP_DOWN:
3113 eElement = XML_DIRECTION;
3114 break;
3115 case ReferenceFieldPart::CATEGORY_AND_NUMBER:
3116 eElement = XML_CATEGORY_AND_VALUE;
3117 break;
3118 case ReferenceFieldPart::ONLY_CAPTION:
3119 eElement = XML_CAPTION;
3120 break;
3121 case ReferenceFieldPart::ONLY_SEQUENCE_NUMBER:
3122 eElement = XML_VALUE;
3123 break;
3124 case ReferenceFieldPart::PAGE_DESC:
3125 // small hack: this value never gets written, because
3126 // XML_TEMPLATE is default
3127 eElement = XML_TEMPLATE;
3128 break;
3129 // Core implementation for direct cross-references (#i81002#)
3130 case ReferenceFieldPart::NUMBER:
3131 eElement = XML_NUMBER;
3132 break;
3133 case ReferenceFieldPart::NUMBER_NO_CONTEXT:
3134 eElement = XML_NUMBER_NO_SUPERIOR;
3135 break;
3136 case ReferenceFieldPart::NUMBER_FULL_CONTEXT:
3137 eElement = XML_NUMBER_ALL_SUPERIOR;
3138 break;
3139 default:
3140 OSL_FAIL("unknown reference type");
3141 eElement = XML_TEMPLATE;
3142 break;
3145 return eElement;
3148 /// map ReferenceFieldPart to XML string
3149 enum XMLTokenEnum XMLTextFieldExport::MapReferenceSource(sal_Int16 nType)
3151 enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
3153 switch (nType)
3155 case ReferenceFieldSource::REFERENCE_MARK:
3156 eElement = XML_REFERENCE_REF;
3157 break;
3158 case ReferenceFieldSource::SEQUENCE_FIELD:
3159 eElement = XML_SEQUENCE_REF;
3160 break;
3161 case ReferenceFieldSource::BOOKMARK:
3162 eElement = XML_BOOKMARK_REF;
3163 break;
3164 case ReferenceFieldSource::FOOTNOTE:
3165 case ReferenceFieldSource::ENDNOTE:
3166 eElement = XML_NOTE_REF;
3167 break;
3168 default:
3169 OSL_FAIL("unknown reference source");
3170 break;
3173 return eElement;
3177 /// element name for sender fields
3178 enum XMLTokenEnum XMLTextFieldExport::MapSenderFieldName(
3179 const Reference<XPropertySet> & xPropSet)
3181 enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3183 // sub-field type
3184 switch (GetInt16Property(gsPropertyFieldSubType, xPropSet))
3186 case UserDataPart::COMPANY :
3187 eName = XML_SENDER_COMPANY;
3188 break;
3189 case UserDataPart::FIRSTNAME :
3190 eName = XML_SENDER_FIRSTNAME;
3191 break;
3192 case UserDataPart::NAME :
3193 eName = XML_SENDER_LASTNAME;
3194 break;
3195 case UserDataPart::SHORTCUT :
3196 eName = XML_SENDER_INITIALS;
3197 break;
3198 case UserDataPart::STREET :
3199 eName = XML_SENDER_STREET;
3200 break;
3201 case UserDataPart::COUNTRY :
3202 eName = XML_SENDER_COUNTRY;
3203 break;
3204 case UserDataPart::ZIP :
3205 eName = XML_SENDER_POSTAL_CODE;
3206 break;
3207 case UserDataPart::CITY :
3208 eName = XML_SENDER_CITY;
3209 break;
3210 case UserDataPart::TITLE :
3211 eName = XML_SENDER_TITLE;
3212 break;
3213 case UserDataPart::POSITION :
3214 eName = XML_SENDER_POSITION;
3215 break;
3216 case UserDataPart::PHONE_PRIVATE :
3217 eName = XML_SENDER_PHONE_PRIVATE;
3218 break;
3219 case UserDataPart::PHONE_COMPANY :
3220 eName = XML_SENDER_PHONE_WORK;
3221 break;
3222 case UserDataPart::FAX :
3223 eName = XML_SENDER_FAX;
3224 break;
3225 case UserDataPart::EMAIL :
3226 eName = XML_SENDER_EMAIL;
3227 break;
3228 case UserDataPart::STATE :
3229 eName = XML_SENDER_STATE_OR_PROVINCE;
3230 break;
3231 default:
3232 SAL_WARN("xmloff.text", "unknown sender type");
3233 eName = XML_TOKEN_INVALID;
3234 break;
3237 return eName;
3240 enum XMLTokenEnum XMLTextFieldExport::MapDocInfoFieldName(
3241 enum FieldIdEnum nToken)
3243 enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
3245 switch (nToken)
3247 case FIELD_ID_DOCINFO_CREATION_AUTHOR:
3248 eElement = XML_INITIAL_CREATOR;
3249 break;
3250 case FIELD_ID_DOCINFO_CREATION_DATE:
3251 eElement = XML_CREATION_DATE;
3252 break;
3253 case FIELD_ID_DOCINFO_CREATION_TIME:
3254 eElement = XML_CREATION_TIME;
3255 break;
3256 case FIELD_ID_DOCINFO_DESCRIPTION:
3257 eElement = XML_DESCRIPTION;
3258 break;
3259 case FIELD_ID_DOCINFO_PRINT_TIME:
3260 eElement = XML_PRINT_TIME;
3261 break;
3262 case FIELD_ID_DOCINFO_PRINT_DATE:
3263 eElement = XML_PRINT_DATE;
3264 break;
3265 case FIELD_ID_DOCINFO_PRINT_AUTHOR:
3266 eElement = XML_PRINTED_BY;
3267 break;
3268 case FIELD_ID_DOCINFO_TITLE:
3269 eElement = XML_TITLE;
3270 break;
3271 case FIELD_ID_DOCINFO_SUBJECT:
3272 eElement = XML_SUBJECT;
3273 break;
3274 case FIELD_ID_DOCINFO_KEYWORDS:
3275 eElement = XML_KEYWORDS;
3276 break;
3277 case FIELD_ID_DOCINFO_REVISION:
3278 eElement = XML_EDITING_CYCLES;
3279 break;
3280 case FIELD_ID_DOCINFO_EDIT_DURATION:
3281 eElement = XML_EDITING_DURATION;
3282 break;
3283 case FIELD_ID_DOCINFO_SAVE_TIME:
3284 eElement = XML_MODIFICATION_TIME;
3285 break;
3286 case FIELD_ID_DOCINFO_SAVE_DATE:
3287 eElement = XML_MODIFICATION_DATE;
3288 break;
3289 case FIELD_ID_DOCINFO_SAVE_AUTHOR:
3290 eElement = XML_CREATOR;
3291 break;
3292 default:
3293 SAL_WARN("xmloff.text", "unknown docinfo field type!");
3294 eElement = XML_TOKEN_INVALID;
3295 break;
3298 return eElement;
3301 enum XMLTokenEnum XMLTextFieldExport::MapBibliographyFieldName(const OUString& sName)
3303 enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3305 if( sName == "Identifier" )
3307 eName = XML_IDENTIFIER;
3309 else if( sName == "BibiliographicType" )
3311 eName = XML_BIBLIOGRAPHY_TYPE;
3313 else if( sName == "Address" )
3315 eName = XML_ADDRESS;
3317 else if( sName == "Annote" )
3319 eName = XML_ANNOTE;
3321 else if( sName == "Author" )
3323 eName = XML_AUTHOR;
3325 else if( sName == "Booktitle" )
3327 eName = XML_BOOKTITLE;
3329 else if( sName == "Chapter" )
3331 eName = XML_CHAPTER;
3333 else if( sName == "Edition" )
3335 eName = XML_EDITION;
3337 else if( sName == "Editor" )
3339 eName = XML_EDITOR;
3341 else if( sName == "Howpublished" )
3343 eName = XML_HOWPUBLISHED;
3345 else if( sName == "Institution" )
3347 eName = XML_INSTITUTION;
3349 else if( sName == "Journal" )
3351 eName = XML_JOURNAL;
3353 else if( sName =="Month" )
3355 eName = XML_MONTH;
3357 else if( sName == "Note" )
3359 eName = XML_NOTE;
3361 else if( sName == "Number" )
3363 eName = XML_NUMBER;
3365 else if( sName == "Organizations" )
3367 eName = XML_ORGANIZATIONS;
3369 else if( sName == "Pages" )
3371 eName = XML_PAGES;
3373 else if( sName == "Publisher" )
3375 eName = XML_PUBLISHER;
3377 else if( sName == "School" )
3379 eName = XML_SCHOOL;
3381 else if( sName == "Series" )
3383 eName = XML_SERIES;
3385 else if( sName == "Title" )
3387 eName = XML_TITLE;
3389 else if( sName == "Report_Type" )
3391 eName = XML_REPORT_TYPE;
3393 else if( sName == "Volume" )
3395 eName = XML_VOLUME;
3397 else if( sName == "Year" )
3399 eName = XML_YEAR;
3401 else if( sName == "URL" )
3403 eName = XML_URL;
3405 else if( sName == "Custom1" )
3407 eName = XML_CUSTOM1;
3409 else if( sName == "Custom2" )
3411 eName = XML_CUSTOM2;
3413 else if( sName == "Custom3" )
3415 eName = XML_CUSTOM3;
3417 else if( sName == "Custom4" )
3419 eName = XML_CUSTOM4;
3421 else if( sName == "Custom5" )
3423 eName = XML_CUSTOM5;
3425 else if( sName == "ISBN" )
3427 eName = XML_ISBN;
3429 else
3431 OSL_FAIL("Unknown bibliography info data");
3432 eName = XML_TOKEN_INVALID;
3435 return eName;
3438 enum XMLTokenEnum XMLTextFieldExport::MapMeasureKind(sal_Int16 nKind)
3440 switch( nKind )
3442 case 0:
3443 return XML_VALUE;
3444 case 1:
3445 return XML_UNIT;
3447 return XML_GAP;
3450 OUString XMLTextFieldExport::MakeFootnoteRefName(
3451 sal_Int16 nSeqNo)
3453 // generate foot-/endnote ID
3454 return "ftn" + OUString::number(static_cast<sal_Int32>(nSeqNo));
3457 OUString XMLTextFieldExport::MakeSequenceRefName(
3458 sal_Int16 nSeqNo,
3459 const OUString& rSeqName)
3461 // generate foot-/endnote ID
3462 return "ref" +rSeqName + OUString::number(static_cast<sal_Int32>(nSeqNo));
3466 // Property accessor helper functions
3469 // to be relegated (does that word exist?) to a more appropriate place
3472 bool GetBoolProperty(
3473 const OUString& sPropName,
3474 const Reference<XPropertySet> & xPropSet)
3476 Any aAny = xPropSet->getPropertyValue(sPropName);
3477 bool bBool = *o3tl::doAccess<bool>(aAny);
3478 return bBool;
3481 bool GetOptionalBoolProperty(
3482 const OUString& sPropName,
3483 const Reference<XPropertySet> & xPropSet,
3484 const Reference<XPropertySetInfo> & xPropSetInfo,
3485 bool bDefault)
3487 return xPropSetInfo->hasPropertyByName( sPropName )
3488 ? GetBoolProperty( sPropName, xPropSet ) : bDefault;
3491 double GetDoubleProperty(
3492 const OUString& sPropName,
3493 const Reference<XPropertySet> & xPropSet)
3495 Any aAny = xPropSet->getPropertyValue(sPropName);
3496 double fDouble = 0.0;
3497 aAny >>= fDouble;
3498 return fDouble;
3501 OUString GetStringProperty(
3502 const OUString& sPropName,
3503 const Reference<XPropertySet> & xPropSet)
3505 Any aAny = xPropSet->getPropertyValue(sPropName);
3506 OUString sString;
3507 aAny >>= sString;
3508 return sString;
3511 sal_Int32 GetIntProperty(
3512 const OUString& sPropName,
3513 const Reference<XPropertySet> & xPropSet)
3515 Any aAny = xPropSet->getPropertyValue(sPropName);
3516 sal_Int32 nInt = 0;
3517 aAny >>= nInt;
3518 return nInt;
3521 sal_Int16 GetInt16Property(
3522 const OUString& sPropName,
3523 const Reference<XPropertySet> & xPropSet)
3525 Any aAny = xPropSet->getPropertyValue(sPropName);
3526 sal_Int16 nInt = 0;
3527 aAny >>= nInt;
3528 return nInt;
3531 sal_Int8 GetInt8Property(
3532 const OUString& sPropName,
3533 const Reference<XPropertySet> & xPropSet)
3535 Any aAny = xPropSet->getPropertyValue(sPropName);
3536 sal_Int8 nInt = 0;
3537 aAny >>= nInt;
3538 return nInt;
3541 util::DateTime GetDateTimeProperty(
3542 const OUString& sPropName,
3543 const Reference<XPropertySet> & xPropSet)
3545 Any aAny = xPropSet->getPropertyValue(sPropName);
3546 util::DateTime aTime;
3547 aAny >>= aTime;
3548 return aTime;
3551 Sequence<OUString> GetStringSequenceProperty(
3552 const OUString& sPropName,
3553 const Reference<XPropertySet> & xPropSet)
3555 Any aAny = xPropSet->getPropertyValue(sPropName);
3556 Sequence<OUString> aSequence;
3557 aAny >>= aSequence;
3558 return aSequence;
3561 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */