Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/xmloff/source/text/txtflde.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
20
21
/** @#file
22
 *
23
 *  export of all text fields
24
 */
25
#include <comphelper/propertyvalue.hxx>
26
#include <txtflde.hxx>
27
#include <txtfld.hxx>
28
#include <xmloff/XMLEventExport.hxx>
29
#include <xmloff/families.hxx>
30
#include <xmloff/namespacemap.hxx>
31
#include <xmloff/numehelp.hxx>
32
#include <xmloff/xmlement.hxx>
33
#include <xmloff/xmlexp.hxx>
34
#include <xmloff/xmltoken.hxx>
35
#include <xmloff/xmluconv.hxx>
36
#include <xmloff/maptype.hxx>
37
38
#include "XMLTextCharStyleNamesElementExport.hxx"
39
#include <sax/tools/converter.hxx>
40
#include <com/sun/star/frame/XModel.hpp>
41
#include <com/sun/star/util/DateTime.hpp>
42
#include <com/sun/star/lang/XServiceInfo.hpp>
43
#include <com/sun/star/text/UserDataPart.hpp>
44
#include <com/sun/star/text/PageNumberType.hpp>
45
#include <com/sun/star/style/NumberingType.hpp>
46
#include <com/sun/star/text/ReferenceFieldPart.hpp>
47
#include <com/sun/star/text/ReferenceFieldSource.hpp>
48
#include <com/sun/star/beans/XPropertySet.hpp>
49
#include <com/sun/star/text/XTextField.hpp>
50
#include <com/sun/star/text/XDependentTextField.hpp>
51
#include <com/sun/star/text/XTextFieldsSupplier.hpp>
52
53
#include <com/sun/star/text/SetVariableType.hpp>
54
#include <com/sun/star/text/PlaceholderType.hpp>
55
#include <com/sun/star/text/FilenameDisplayFormat.hpp>
56
#include <com/sun/star/text/ChapterFormat.hpp>
57
#include <com/sun/star/text/TemplateDisplayFormat.hpp>
58
#include <com/sun/star/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 <o3tl/safeint.hxx>
65
#include <rtl/ustrbuf.hxx>
66
#include <tools/debug.hxx>
67
#include <rtl/math.hxx>
68
#include <sal/log.hxx>
69
70
#include <vector>
71
72
73
using namespace ::com::sun::star;
74
using namespace ::com::sun::star::uno;
75
using namespace ::com::sun::star::text;
76
using namespace ::com::sun::star::lang;
77
using namespace ::com::sun::star::beans;
78
using namespace ::com::sun::star::util;
79
using namespace ::com::sun::star::style;
80
using namespace ::com::sun::star::document;
81
using namespace ::com::sun::star::container;
82
using namespace ::xmloff::token;
83
84
85
char const FIELD_SERVICE_SENDER[] = "ExtendedUser";
86
char const FIELD_SERVICE_AUTHOR[] = "Author";
87
char const FIELD_SERVICE_JUMPEDIT[] = "JumpEdit";
88
char const FIELD_SERVICE_GETEXP[] = "GetExpression";
89
char const FIELD_SERVICE_SETEXP[] = "SetExpression";
90
char const FIELD_SERVICE_USER[] = "User";
91
char const FIELD_SERVICE_INPUT[] = "Input";
92
char const FIELD_SERVICE_USERINPUT[] = "InputUser";
93
char const FIELD_SERVICE_DATETIME[] = "DateTime";
94
char const FIELD_SERVICE_PAGENUMBER[] = "PageNumber";
95
char const FIELD_SERVICE_DB_NEXT[] = "DatabaseNextSet";
96
char const FIELD_SERVICE_DB_SELECT[] = "DatabaseNumberOfSet";
97
char const FIELD_SERVICE_DB_NUMBER[] = "DatabaseSetNumber";
98
char const FIELD_SERVICE_DB_DISPLAY[] = "Database";
99
char const FIELD_SERVICE_DB_NAME[] = "DatabaseName";
100
char const FIELD_SERVICE_CONDITIONAL_TEXT[] = "ConditionalText";
101
char const FIELD_SERVICE_HIDDEN_TEXT[] = "HiddenText";
102
char const FIELD_SERVICE_HIDDEN_PARAGRAPH[] = "HiddenParagraph";
103
char const FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR[] = "DocInfo.ChangeAuthor";
104
char const FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR2[] = "docinfo.ChangeAuthor";
105
char const FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME[] = "DocInfo.ChangeDateTime";
106
char const FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME2[] = "docinfo.ChangeDateTime";
107
char const FIELD_SERVICE_DOC_INFO_EDIT_TIME[] = "DocInfo.EditTime";
108
char const FIELD_SERVICE_DOC_INFO_EDIT_TIME2[] = "docinfo.EditTime";
109
char const FIELD_SERVICE_DOC_INFO_DESCRIPTION[] = "DocInfo.Description";
110
char const FIELD_SERVICE_DOC_INFO_DESCRIPTION2[] = "docinfo.Description";
111
char const FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR[] = "DocInfo.CreateAuthor";
112
char const FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR2[] = "docinfo.CreateAuthor";
113
char const FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME[] = "DocInfo.CreateDateTime";
114
char const FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME2[] = "docinfo.CreateDateTime";
115
char const FIELD_SERVICE_DOC_INFO_CUSTOM[] = "DocInfo.Custom";
116
char const FIELD_SERVICE_DOC_INFO_CUSTOM2[] = "docinfo.Custom";
117
char const FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR[] = "DocInfo.PrintAuthor";
118
char const FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR2[] = "docinfo.PrintAuthor";
119
char const FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME[] = "DocInfo.PrintDateTime";
120
char const FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME2[] = "docinfo.PrintDateTime";
121
char const FIELD_SERVICE_DOC_INFO_KEY_WORDS[] = "DocInfo.KeyWords";
122
char const FIELD_SERVICE_DOC_INFO_KEY_WORDS2[] = "docinfo.KeyWords";
123
char const FIELD_SERVICE_DOC_INFO_SUBJECT[] = "DocInfo.Subject";
124
char const FIELD_SERVICE_DOC_INFO_SUBJECT2[] = "docinfo.Subject";
125
char const FIELD_SERVICE_DOC_INFO_TITLE[] = "DocInfo.Title";
126
char const FIELD_SERVICE_DOC_INFO_TITLE2[] = "docinfo.Title";
127
char const FIELD_SERVICE_DOC_INFO_REVISION[] = "DocInfo.Revision";
128
char const FIELD_SERVICE_DOC_INFO_REVISION2[] = "docinfo.Revision";
129
char const FIELD_SERVICE_FILE_NAME[] = "FileName";
130
char const FIELD_SERVICE_CHAPTER[] = "Chapter";
131
char const FIELD_SERVICE_TEMPLATE_NAME[] = "TemplateName";
132
char const FIELD_SERVICE_PAGE_COUNT[] = "PageCount";
133
char const FIELD_SERVICE_PAGE_COUNT_RANGE[] = "PageCountRange";
134
char const FIELD_SERVICE_PARAGRAPH_COUNT[] = "ParagraphCount";
135
char const FIELD_SERVICE_WORD_COUNT[] = "WordCount";
136
char const FIELD_SERVICE_CHARACTER_COUNT[] = "CharacterCount";
137
char const FIELD_SERVICE_TABLE_COUNT[] = "TableCount";
138
char const FIELD_SERVICE_GRAPHIC_COUNT[] = "GraphicObjectCount";
139
char const FIELD_SERVICE_OBJECT_COUNT[] = "EmbeddedObjectCount";
140
char const FIELD_SERVICE_REFERENCE_PAGE_SET[] = "ReferencePageSet";
141
char const FIELD_SERVICE_REFERENCE_PAGE_GET[] = "ReferencePageGet";
142
char const FIELD_SERVICE_SHEET_NAME[] = "SheetName";
143
char const FIELD_SERVICE_PAGE_NAME[] = "PageName";
144
char const FIELD_SERVICE_MACRO[] = "Macro";
145
char const FIELD_SERVICE_GET_REFERENCE[] = "GetReference";
146
char const FIELD_SERVICE_DDE[] = "DDE";
147
char const FIELD_SERVICE_URL[] = "URL";
148
char const FIELD_SERVICE_BIBLIOGRAPHY[] = "Bibliography";
149
char const FIELD_SERVICE_SCRIPT[] = "Script";
150
char const FIELD_SERVICE_ANNOTATION[] = "Annotation";
151
char const FIELD_SERVICE_COMBINED_CHARACTERS[] = "CombinedCharacters";
152
char const FIELD_SERVICE_META[] = "MetadataField";
153
char const FIELD_SERVICE_MEASURE[] = "Measure";
154
char const FIELD_SERVICE_TABLE_FORMULA[] = "TableFormula";
155
char const FIELD_SERVICE_DROP_DOWN[] = "DropDown";
156
157
namespace
158
{
159
/// Walks up the parent chain of xText and returns the topmost text.
160
uno::Reference<text::XText> GetToplevelText(const uno::Reference<text::XText>& xText)
161
0
{
162
0
    uno::Reference<text::XText> xRet = xText;
163
0
    while (true)
164
0
    {
165
0
        uno::Reference<beans::XPropertySet> xPropertySet(xRet, uno::UNO_QUERY);
166
0
        if (!xPropertySet.is())
167
0
            return xRet;
168
169
0
        if (!xPropertySet->getPropertySetInfo()->hasPropertyByName(u"ParentText"_ustr))
170
0
            return xRet;
171
172
0
        uno::Reference<text::XText> xParent;
173
0
        if (xPropertySet->getPropertyValue(u"ParentText"_ustr) >>= xParent)
174
0
            xRet = std::move(xParent);
175
0
        else
176
0
            return xRet;
177
0
    }
178
0
    return xRet;
179
0
}
180
181
uno::Reference<css::text::XText> XTextFromTextRangeProp(const Reference<XPropertySet>& xPropSet)
182
0
{
183
0
    try
184
0
    {
185
0
        return xPropSet->getPropertyValue(u"TextRange"_ustr).query<css::text::XText>();
186
0
    }
187
0
    catch (css::uno::Exception&)
188
0
    {
189
0
        return {};
190
0
    }
191
0
}
192
}
193
194
SvXMLEnumStringMapEntry<FieldIdEnum> const aFieldServiceNameMapping[] =
195
{
196
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SENDER, FIELD_ID_SENDER ),
197
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_AUTHOR, FIELD_ID_AUTHOR ),
198
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_JUMPEDIT, FIELD_ID_PLACEHOLDER ),
199
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GETEXP, FIELD_ID_VARIABLE_GET ),
200
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SETEXP, FIELD_ID_VARIABLE_SET ),
201
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_USER, FIELD_ID_USER_GET ),
202
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_INPUT, FIELD_ID_TEXT_INPUT ),
203
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_USERINPUT, FIELD_ID_USER_INPUT ),
204
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DATETIME, FIELD_ID_TIME ),
205
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PAGENUMBER, FIELD_ID_PAGENUMBER ),
206
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_REFERENCE_PAGE_SET, FIELD_ID_REFPAGE_SET ),
207
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_REFERENCE_PAGE_GET, FIELD_ID_REFPAGE_GET ),
208
209
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NEXT, FIELD_ID_DATABASE_NEXT ),
210
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_SELECT, FIELD_ID_DATABASE_SELECT ),
211
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NUMBER, FIELD_ID_DATABASE_NUMBER ),
212
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_DISPLAY, FIELD_ID_DATABASE_DISPLAY ),
213
    // workaround for #no-bug#: Database/DataBase
214
    ENUM_STRING_MAP_ENTRY( "DataBase", FIELD_ID_DATABASE_DISPLAY ),
215
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NAME, FIELD_ID_DATABASE_NAME ),
216
217
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR, FIELD_ID_DOCINFO_CREATION_AUTHOR ),
218
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR2, FIELD_ID_DOCINFO_CREATION_AUTHOR ),
219
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME, FIELD_ID_DOCINFO_CREATION_TIME),
220
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME2, FIELD_ID_DOCINFO_CREATION_TIME),
221
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR, FIELD_ID_DOCINFO_SAVE_AUTHOR ),
222
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR2, FIELD_ID_DOCINFO_SAVE_AUTHOR ),
223
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME, FIELD_ID_DOCINFO_SAVE_TIME ),
224
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME2, FIELD_ID_DOCINFO_SAVE_TIME ),
225
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_EDIT_TIME, FIELD_ID_DOCINFO_EDIT_DURATION ),
226
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_EDIT_TIME2, FIELD_ID_DOCINFO_EDIT_DURATION ),
227
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_DESCRIPTION, FIELD_ID_DOCINFO_DESCRIPTION ),
228
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_DESCRIPTION2, FIELD_ID_DOCINFO_DESCRIPTION ),
229
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CUSTOM, FIELD_ID_DOCINFO_CUSTOM ),
230
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CUSTOM2, FIELD_ID_DOCINFO_CUSTOM ),
231
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR, FIELD_ID_DOCINFO_PRINT_AUTHOR ),
232
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR2, FIELD_ID_DOCINFO_PRINT_AUTHOR ),
233
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME, FIELD_ID_DOCINFO_PRINT_TIME ),
234
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME2, FIELD_ID_DOCINFO_PRINT_TIME ),
235
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_KEY_WORDS, FIELD_ID_DOCINFO_KEYWORDS ),
236
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_KEY_WORDS2, FIELD_ID_DOCINFO_KEYWORDS ),
237
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_SUBJECT, FIELD_ID_DOCINFO_SUBJECT ),
238
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_SUBJECT2, FIELD_ID_DOCINFO_SUBJECT ),
239
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_TITLE, FIELD_ID_DOCINFO_TITLE ),
240
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_TITLE2, FIELD_ID_DOCINFO_TITLE ),
241
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_REVISION, FIELD_ID_DOCINFO_REVISION ),
242
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_REVISION2, FIELD_ID_DOCINFO_REVISION ),
243
244
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CONDITIONAL_TEXT, FIELD_ID_CONDITIONAL_TEXT ),
245
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_HIDDEN_TEXT, FIELD_ID_HIDDEN_TEXT ),
246
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_HIDDEN_PARAGRAPH, FIELD_ID_HIDDEN_PARAGRAPH ),
247
248
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_FILE_NAME, FIELD_ID_FILE_NAME ),
249
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CHAPTER, FIELD_ID_CHAPTER ),
250
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TEMPLATE_NAME, FIELD_ID_TEMPLATE_NAME ),
251
252
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PAGE_COUNT, FIELD_ID_COUNT_PAGES ),
253
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PAGE_COUNT_RANGE, FIELD_ID_COUNT_PAGES_RANGE ),
254
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PARAGRAPH_COUNT, FIELD_ID_COUNT_PARAGRAPHS ),
255
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_WORD_COUNT, FIELD_ID_COUNT_WORDS ),
256
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CHARACTER_COUNT, FIELD_ID_COUNT_CHARACTERS ),
257
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TABLE_COUNT, FIELD_ID_COUNT_TABLES ),
258
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GRAPHIC_COUNT, FIELD_ID_COUNT_GRAPHICS ),
259
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_OBJECT_COUNT, FIELD_ID_COUNT_OBJECTS ),
260
261
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_MACRO, FIELD_ID_MACRO ),
262
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GET_REFERENCE, FIELD_ID_REF_REFERENCE ),
263
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DDE, FIELD_ID_DDE ),
264
265
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_BIBLIOGRAPHY, FIELD_ID_BIBLIOGRAPHY ),
266
267
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SCRIPT, FIELD_ID_SCRIPT ),
268
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_ANNOTATION, FIELD_ID_ANNOTATION ),
269
270
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_COMBINED_CHARACTERS, FIELD_ID_COMBINED_CHARACTERS ),
271
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_META, FIELD_ID_META ),
272
273
    // non-writer fields
274
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SHEET_NAME, FIELD_ID_SHEET_NAME ),
275
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PAGE_NAME, FIELD_ID_PAGENAME ),
276
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_URL, FIELD_ID_URL ),
277
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_MEASURE, FIELD_ID_MEASURE ),
278
279
    // deprecated fields
280
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TABLE_FORMULA, FIELD_ID_TABLE_FORMULA ),
281
    ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DROP_DOWN, FIELD_ID_DROP_DOWN ),
282
283
    { nullptr, 0, FieldIdEnum(0) }
284
};
285
286
287
// property accessor helper functions
288
static bool GetBoolProperty(const OUString&,
289
                                      const Reference<XPropertySet> &);
290
static bool GetOptionalBoolProperty(const OUString&,
291
                                              const Reference<XPropertySet> &,
292
                                              const Reference<XPropertySetInfo> &,
293
                                              bool bDefault);
294
static double GetDoubleProperty(const OUString&,
295
                                      const Reference<XPropertySet> &);
296
static OUString GetStringProperty(const OUString&,
297
                                        const Reference<XPropertySet> &);
298
static sal_Int32 GetIntProperty(const OUString&,
299
                                      const Reference<XPropertySet> &);
300
static sal_Int16 GetInt16Property(const OUString&,
301
                                        const Reference<XPropertySet> &);
302
static sal_Int8 GetInt8Property(const OUString&,
303
                                      const Reference<XPropertySet> &);
304
static util::DateTime GetDateTimeProperty( const OUString& sPropName,
305
                                           const Reference<XPropertySet> & xPropSet);
306
static Sequence<OUString> GetStringSequenceProperty(
307
                                   const OUString& sPropName,
308
                                   const Reference<XPropertySet> & xPropSet);
309
310
311
    // service names
312
constexpr OUString gsServicePrefix(u"com.sun.star.text.textfield."_ustr);
313
constexpr OUStringLiteral gsFieldMasterPrefix(u"com.sun.star.text.FieldMaster.");
314
constexpr OUString gsPresentationServicePrefix(u"com.sun.star.presentation.TextField."_ustr);
315
316
    // property names
317
constexpr OUString gsPropertyAdjust(u"Adjust"_ustr);
318
constexpr OUStringLiteral gsPropertyAuthor(u"Author");
319
constexpr OUStringLiteral gsPropertyChapterFormat(u"ChapterFormat");
320
constexpr OUStringLiteral gsPropertyChapterNumberingLevel(u"ChapterNumberingLevel");
321
constexpr OUStringLiteral gsPropertyCharStyleNames(u"CharStyleNames");
322
constexpr OUString gsPropertyCondition(u"Condition"_ustr);
323
constexpr OUString gsPropertyContent(u"Content"_ustr);
324
constexpr OUStringLiteral gsPropertyDataBaseName(u"DataBaseName");
325
constexpr OUString gsPropertyDataBaseURL(u"DataBaseURL"_ustr);
326
constexpr OUStringLiteral gsPropertyDataColumnName(u"DataColumnName");
327
constexpr OUString gsPropertyDataCommandType(u"DataCommandType"_ustr);
328
constexpr OUString gsPropertyDataTableName(u"DataTableName"_ustr);
329
constexpr OUString gsPropertyDateTime(u"DateTime"_ustr);
330
constexpr OUString gsPropertyDateTimeValue(u"DateTimeValue"_ustr);
331
constexpr OUStringLiteral gsPropertyDDECommandElement(u"DDECommandElement");
332
constexpr OUStringLiteral gsPropertyDDECommandFile(u"DDECommandFile");
333
constexpr OUStringLiteral gsPropertyDDECommandType(u"DDECommandType");
334
constexpr OUStringLiteral gsPropertyDependentTextFields(u"DependentTextFields");
335
constexpr OUStringLiteral gsPropertyFalseContent(u"FalseContent");
336
constexpr OUStringLiteral gsPropertyFields(u"Fields");
337
constexpr OUStringLiteral gsPropertyFieldSubType(u"UserDataType");
338
constexpr OUString gsPropertyFileFormat(u"FileFormat"_ustr);
339
constexpr OUStringLiteral gsPropertyFullName(u"FullName");
340
constexpr OUString gsPropertyHint(u"Hint"_ustr);
341
constexpr OUStringLiteral gsPropertyInitials(u"Initials");
342
constexpr OUStringLiteral gsPropertyInstanceName(u"InstanceName");
343
constexpr OUStringLiteral gsPropertyIsAutomaticUpdate(u"IsAutomaticUpdate");
344
constexpr OUStringLiteral gsPropertyIsConditionTrue(u"IsConditionTrue");
345
constexpr OUString gsPropertyIsDataBaseFormat(u"DataBaseFormat"_ustr);
346
constexpr OUString gsPropertyIsDate(u"IsDate"_ustr);
347
constexpr OUString gsPropertyIsExpression(u"IsExpression"_ustr);
348
constexpr OUString gsPropertyIsFixed(u"IsFixed"_ustr);
349
constexpr OUString gsPropertyIsFixedLanguage(u"IsFixedLanguage"_ustr);
350
constexpr OUString gsPropertyIsHidden(u"IsHidden"_ustr);
351
constexpr OUStringLiteral gsPropertyIsInput(u"Input");
352
constexpr OUString gsPropertyIsShowFormula(u"IsShowFormula"_ustr);
353
constexpr OUString gsPropertyIsVisible(u"IsVisible"_ustr);
354
constexpr OUStringLiteral gsPropertyItems(u"Items");
355
constexpr OUStringLiteral gsPropertyLevel(u"Level");
356
constexpr OUStringLiteral gsPropertyMeasureKind(u"Kind");
357
constexpr OUString gsPropertyName(u"Name"_ustr);
358
constexpr OUStringLiteral gsPropertyParentName(u"ParentName");
359
constexpr OUString gsPropertyNumberFormat(u"NumberFormat"_ustr);
360
constexpr OUStringLiteral gsPropertyNumberingSeparator(u"NumberingSeparator");
361
constexpr OUString gsPropertyNumberingType(u"NumberingType"_ustr);
362
constexpr OUString gsPropertyOffset(u"Offset"_ustr);
363
constexpr OUStringLiteral gsPropertyOn(u"On");
364
constexpr OUStringLiteral gsPropertyPlaceholderType(u"PlaceHolderType");
365
constexpr OUString gsPropertyReferenceFieldFlags(u"ReferenceFieldFlags"_ustr);
366
constexpr OUString gsPropertyReferenceFieldPart(u"ReferenceFieldPart"_ustr);
367
constexpr OUString gsPropertyReferenceFieldSource(u"ReferenceFieldSource"_ustr);
368
constexpr OUString gsPropertyReferenceFieldLanguage(u"ReferenceFieldLanguage"_ustr);
369
constexpr OUStringLiteral gsPropertyScriptType(u"ScriptType");
370
constexpr OUStringLiteral gsPropertySelectedItem(u"SelectedItem");
371
constexpr OUString gsPropertySequenceNumber(u"SequenceNumber"_ustr);
372
constexpr OUStringLiteral gsPropertySequenceValue(u"SequenceValue");
373
constexpr OUString gsPropertySetNumber(u"SetNumber"_ustr);
374
constexpr OUString gsPropertySourceName(u"SourceName"_ustr);
375
constexpr OUString gsPropertySubType(u"SubType"_ustr);
376
constexpr OUStringLiteral gsPropertyTargetFrame(u"TargetFrame");
377
constexpr OUStringLiteral gsPropertyTrueContent(u"TrueContent");
378
constexpr OUStringLiteral gsPropertyURL(u"URL");
379
constexpr OUStringLiteral gsPropertyURLContent(u"URLContent");
380
constexpr OUStringLiteral gsPropertyUserText(u"UserText");
381
constexpr OUString gsPropertyValue(u"Value"_ustr);
382
constexpr OUString gsPropertyVariableName(u"VariableName"_ustr);
383
constexpr OUString gsPropertyHelp(u"Help"_ustr);
384
constexpr OUString gsPropertyTooltip(u"Tooltip"_ustr);
385
386
XMLTextFieldExport::XMLTextFieldExport( SvXMLExport& rExp,
387
                                        std::unique_ptr<XMLPropertyState> pCombinedCharState)
388
3
    : rExport(rExp),
389
3
      pCombinedCharactersPropertyState(std::move(pCombinedCharState))
390
3
{
391
3
    SetExportOnlyUsedFieldDeclarations();
392
3
}
393
394
XMLTextFieldExport::~XMLTextFieldExport()
395
3
{
396
3
}
397
398
/// get the field ID (as in FieldIDEnum) from XTextField
399
enum FieldIdEnum XMLTextFieldExport::GetFieldID(
400
    const Reference<XTextField> & rTextField,
401
    const Reference<XPropertySet> & xPropSet)
402
0
{
403
    // get service names for rTextField (via XServiceInfo service)
404
0
    Reference<XServiceInfo> xService(rTextField, UNO_QUERY);
405
0
    const Sequence<OUString> aServices = xService->getSupportedServiceNames();
406
407
0
    OUString sFieldName;    // service name postfix of current field
408
409
    // search for TextField service name
410
0
    const OUString* pNames = std::find_if(aServices.begin(), aServices.end(),
411
0
        [](const OUString& rName) { return rName.matchIgnoreAsciiCase(gsServicePrefix); });
412
0
    if (pNames != aServices.end())
413
0
    {
414
        // TextField found => postfix is field type!
415
0
        sFieldName = pNames->copy(gsServicePrefix.getLength());
416
0
    }
417
418
    // if this is not a normal text field, check if it's a presentation text field
419
0
    if( sFieldName.isEmpty() )
420
0
    {
421
        // search for TextField service name
422
0
        pNames = std::find_if(aServices.begin(), aServices.end(),
423
0
            [](const OUString& rName) { return rName.startsWith(gsPresentationServicePrefix); });
424
0
        if (pNames != aServices.end())
425
0
        {
426
            // TextField found => postfix is field type!
427
0
            sFieldName = pNames->copy(gsPresentationServicePrefix.getLength());
428
0
        }
429
430
0
        if( !sFieldName.isEmpty() )
431
0
        {
432
0
            if( sFieldName == "Header" )
433
0
            {
434
0
                return FIELD_ID_DRAW_HEADER;
435
0
            }
436
0
            else if( sFieldName == "Footer" )
437
0
            {
438
0
                return FIELD_ID_DRAW_FOOTER;
439
0
            }
440
0
            else if( sFieldName == "DateTime" )
441
0
            {
442
0
                return FIELD_ID_DRAW_DATE_TIME;
443
0
            }
444
0
        }
445
0
    }
446
447
    // map postfix of service name to field ID
448
0
    DBG_ASSERT(!sFieldName.isEmpty(), "no TextField service found!");
449
0
    return MapFieldName(sFieldName, xPropSet);
450
0
}
451
452
enum FieldIdEnum XMLTextFieldExport::MapFieldName(
453
    std::u16string_view sFieldName,             // field (master) name
454
    const Reference<XPropertySet> & xPropSet)   // for subtype
455
0
{
456
    // we'll proceed in 2 steps:
457
    // a) map service name to preliminary FIELD_ID
458
    // b) map those prelim. FIELD_IDs that correspond to several field types
459
    //    (in our (XML) world) to final FIELD IDs
460
461
462
    // a) find prelim. FIELD_ID via aFieldServiceMapping
463
464
    // check for non-empty service name
465
0
    DBG_ASSERT(!sFieldName.empty(), "no valid service name!");
466
0
    enum FieldIdEnum nToken = FIELD_ID_UNKNOWN;
467
0
    if (!sFieldName.empty())
468
0
    {
469
        // map name to prelim. ID
470
0
        bool bRet = SvXMLUnitConverter::convertEnum(
471
0
            nToken, sFieldName, aFieldServiceNameMapping);
472
473
        // check return
474
0
        DBG_ASSERT(bRet, "Unknown field service name encountered!");
475
0
    }
476
477
    // b) map prelim. to final FIELD_IDs
478
0
    switch (nToken) {
479
0
        case FIELD_ID_VARIABLE_SET:
480
0
            if (GetBoolProperty(gsPropertyIsInput, xPropSet))
481
0
            {
482
0
                nToken = FIELD_ID_VARIABLE_INPUT;
483
0
            }
484
0
            else
485
0
            {
486
0
                switch (GetIntProperty(gsPropertySubType, xPropSet))
487
0
                {
488
0
                    case SetVariableType::STRING:   // text field
489
0
                    case SetVariableType::VAR:      // num field
490
0
                        nToken = FIELD_ID_VARIABLE_SET;
491
0
                        break;
492
0
                    case SetVariableType::SEQUENCE:
493
0
                        nToken = FIELD_ID_SEQUENCE;
494
0
                        break;
495
0
                    case SetVariableType::FORMULA:
496
0
                    default:
497
0
                        nToken = FIELD_ID_UNKNOWN;
498
0
                        break;
499
0
                }
500
0
            }
501
0
            break;
502
503
0
        case FIELD_ID_VARIABLE_GET:
504
0
            switch (GetIntProperty(gsPropertySubType, xPropSet))
505
0
            {
506
0
                case SetVariableType::STRING:   // text field
507
0
                case SetVariableType::VAR:      // num field
508
0
                    nToken = FIELD_ID_VARIABLE_GET;
509
0
                    break;
510
0
                case SetVariableType::FORMULA:
511
0
                    nToken = FIELD_ID_EXPRESSION;
512
0
                    break;
513
0
                case SetVariableType::SEQUENCE:
514
0
                default:
515
0
                    nToken = FIELD_ID_UNKNOWN;
516
0
                    break;
517
0
            }
518
0
            break;
519
520
0
        case FIELD_ID_TIME:
521
0
            if (GetBoolProperty(gsPropertyIsDate, xPropSet))
522
0
            {
523
0
                nToken = FIELD_ID_DATE;
524
0
            }
525
0
            break;
526
527
0
        case FIELD_ID_PAGENUMBER:
528
            // NumberingType not available in non-Writer apps
529
0
            if (xPropSet->getPropertySetInfo()->
530
0
                hasPropertyByName(gsPropertyNumberingType))
531
0
            {
532
0
                if (NumberingType::CHAR_SPECIAL == GetIntProperty(
533
0
                                            gsPropertyNumberingType, xPropSet))
534
0
                {
535
0
                    nToken = FIELD_ID_PAGESTRING;
536
0
                }
537
0
            }
538
0
            break;
539
540
0
        case FIELD_ID_DOCINFO_CREATION_TIME:
541
0
            if (GetBoolProperty(gsPropertyIsDate, xPropSet))
542
0
            {
543
0
                nToken = FIELD_ID_DOCINFO_CREATION_DATE;
544
0
            }
545
0
            break;
546
547
0
        case FIELD_ID_DOCINFO_PRINT_TIME:
548
0
            if (GetBoolProperty(gsPropertyIsDate, xPropSet))
549
0
            {
550
0
                nToken = FIELD_ID_DOCINFO_PRINT_DATE;
551
0
            }
552
0
            break;
553
554
0
        case FIELD_ID_DOCINFO_SAVE_TIME:
555
0
            if (GetBoolProperty(gsPropertyIsDate, xPropSet))
556
0
            {
557
0
                nToken = FIELD_ID_DOCINFO_SAVE_DATE;
558
0
            }
559
0
            break;
560
561
0
        case FIELD_ID_REF_REFERENCE:
562
0
            switch (GetInt16Property(gsPropertyReferenceFieldSource, xPropSet))
563
0
            {
564
0
                case ReferenceFieldSource::REFERENCE_MARK:
565
0
                    nToken = FIELD_ID_REF_REFERENCE;
566
0
                    break;
567
0
                case ReferenceFieldSource::SEQUENCE_FIELD:
568
0
                    nToken = FIELD_ID_REF_SEQUENCE;
569
0
                    break;
570
0
                case ReferenceFieldSource::BOOKMARK:
571
0
                    nToken = FIELD_ID_REF_BOOKMARK;
572
0
                    break;
573
0
                case ReferenceFieldSource::FOOTNOTE:
574
0
                    nToken = FIELD_ID_REF_FOOTNOTE;
575
0
                    break;
576
0
                case ReferenceFieldSource::ENDNOTE:
577
0
                    nToken = FIELD_ID_REF_ENDNOTE;
578
0
                    break;
579
0
                case ReferenceFieldSource::STYLE:
580
0
                    nToken = FIELD_ID_REF_STYLE;
581
0
                    break;
582
0
                default:
583
0
                    nToken = FIELD_ID_UNKNOWN;
584
0
                    break;
585
0
            }
586
0
            break;
587
588
0
        case FIELD_ID_COMBINED_CHARACTERS:
589
0
        case FIELD_ID_SCRIPT:
590
0
        case FIELD_ID_ANNOTATION:
591
0
        case FIELD_ID_BIBLIOGRAPHY:
592
0
        case FIELD_ID_DDE:
593
0
        case FIELD_ID_MACRO:
594
0
        case FIELD_ID_REFPAGE_SET:
595
0
        case FIELD_ID_REFPAGE_GET:
596
0
        case FIELD_ID_COUNT_PAGES:
597
0
        case FIELD_ID_COUNT_PAGES_RANGE:
598
0
        case FIELD_ID_COUNT_PARAGRAPHS:
599
0
        case FIELD_ID_COUNT_WORDS:
600
0
        case FIELD_ID_COUNT_CHARACTERS:
601
0
        case FIELD_ID_COUNT_TABLES:
602
0
        case FIELD_ID_COUNT_GRAPHICS:
603
0
        case FIELD_ID_COUNT_OBJECTS:
604
0
        case FIELD_ID_CONDITIONAL_TEXT:
605
0
        case FIELD_ID_HIDDEN_TEXT:
606
0
        case FIELD_ID_HIDDEN_PARAGRAPH:
607
0
        case FIELD_ID_DOCINFO_CREATION_AUTHOR:
608
0
        case FIELD_ID_DOCINFO_DESCRIPTION:
609
0
        case FIELD_ID_DOCINFO_CUSTOM:
610
0
        case FIELD_ID_DOCINFO_PRINT_AUTHOR:
611
0
        case FIELD_ID_DOCINFO_TITLE:
612
0
        case FIELD_ID_DOCINFO_SUBJECT:
613
0
        case FIELD_ID_DOCINFO_KEYWORDS:
614
0
        case FIELD_ID_DOCINFO_REVISION:
615
0
        case FIELD_ID_DOCINFO_EDIT_DURATION:
616
0
        case FIELD_ID_DOCINFO_SAVE_AUTHOR:
617
0
        case FIELD_ID_TEXT_INPUT:
618
0
        case FIELD_ID_USER_INPUT:
619
0
        case FIELD_ID_AUTHOR:
620
0
        case FIELD_ID_SENDER:
621
0
        case FIELD_ID_PLACEHOLDER:
622
0
        case FIELD_ID_USER_GET:
623
0
        case FIELD_ID_DATABASE_NEXT:
624
0
        case FIELD_ID_DATABASE_SELECT:
625
0
        case FIELD_ID_DATABASE_DISPLAY:
626
0
        case FIELD_ID_DATABASE_NAME:
627
0
        case FIELD_ID_DATABASE_NUMBER:
628
0
        case FIELD_ID_TEMPLATE_NAME:
629
0
        case FIELD_ID_CHAPTER:
630
0
        case FIELD_ID_FILE_NAME:
631
0
        case FIELD_ID_META:
632
0
        case FIELD_ID_SHEET_NAME:
633
0
        case FIELD_ID_PAGENAME:
634
0
        case FIELD_ID_MEASURE:
635
0
        case FIELD_ID_URL:
636
0
        case FIELD_ID_TABLE_FORMULA:
637
0
        case FIELD_ID_DROP_DOWN:
638
0
            ; // these field IDs are final
639
0
            break;
640
641
0
        default:
642
0
            nToken = FIELD_ID_UNKNOWN;
643
0
    }
644
645
    // ... and return final FIELD_ID
646
0
    return nToken;
647
0
}
648
649
// is string or numeric field?
650
bool XMLTextFieldExport::IsStringField(
651
    FieldIdEnum nFieldType,
652
    const Reference<XPropertySet> & xPropSet)
653
0
{
654
0
    switch (nFieldType) {
655
656
0
    case FIELD_ID_VARIABLE_GET:
657
0
    case FIELD_ID_VARIABLE_SET:
658
0
    case FIELD_ID_VARIABLE_INPUT:
659
0
    {
660
        // depends on field sub type
661
0
        return ( GetIntProperty(gsPropertySubType, xPropSet) ==
662
0
                 SetVariableType::STRING                    );
663
0
    }
664
665
0
    case FIELD_ID_USER_GET:
666
0
    case FIELD_ID_USER_INPUT:
667
0
    {
668
0
        Reference<XTextField> xTextField(xPropSet, UNO_QUERY);
669
0
        DBG_ASSERT(xTextField.is(), "field is no XTextField!");
670
0
        bool bRet = GetBoolProperty(gsPropertyIsExpression,
671
0
                                        GetMasterPropertySet(xTextField));
672
0
        return !bRet;
673
0
    }
674
675
0
    case FIELD_ID_META:
676
0
        return 0 > GetIntProperty(gsPropertyNumberFormat, xPropSet);
677
678
0
    case FIELD_ID_DATABASE_DISPLAY:
679
        // TODO: depends on... ???
680
        // workaround #no-bug#: no data type
681
0
        return 5100 == GetIntProperty(gsPropertyNumberFormat, xPropSet);
682
683
0
    case FIELD_ID_TABLE_FORMULA:
684
        // legacy field: always a number field (because it always has
685
        // a number format)
686
0
        return false;
687
688
0
    case FIELD_ID_COUNT_PAGES:
689
0
    case FIELD_ID_COUNT_PAGES_RANGE:
690
0
    case FIELD_ID_COUNT_PARAGRAPHS:
691
0
    case FIELD_ID_COUNT_WORDS:
692
0
    case FIELD_ID_COUNT_CHARACTERS:
693
0
    case FIELD_ID_COUNT_TABLES:
694
0
    case FIELD_ID_COUNT_GRAPHICS:
695
0
    case FIELD_ID_COUNT_OBJECTS:
696
0
    case FIELD_ID_DOCINFO_SAVE_TIME:
697
0
    case FIELD_ID_DOCINFO_SAVE_DATE:
698
0
    case FIELD_ID_DOCINFO_CREATION_DATE:
699
0
    case FIELD_ID_DOCINFO_CREATION_TIME:
700
0
    case FIELD_ID_DOCINFO_PRINT_TIME:
701
0
    case FIELD_ID_DOCINFO_PRINT_DATE:
702
0
    case FIELD_ID_DOCINFO_EDIT_DURATION:
703
0
    case FIELD_ID_DOCINFO_REVISION:
704
0
    case FIELD_ID_DATABASE_NUMBER:
705
0
    case FIELD_ID_EXPRESSION:
706
0
    case FIELD_ID_SEQUENCE:
707
0
    case FIELD_ID_DATE:
708
0
    case FIELD_ID_TIME:
709
0
    case FIELD_ID_PAGENUMBER:
710
0
    case FIELD_ID_REFPAGE_SET:
711
0
    case FIELD_ID_REFPAGE_GET:
712
0
    case FIELD_ID_DOCINFO_CUSTOM:
713
        // always number
714
0
        return false;
715
716
0
    case FIELD_ID_COMBINED_CHARACTERS:
717
0
    case FIELD_ID_BIBLIOGRAPHY:
718
0
    case FIELD_ID_DDE:
719
0
    case FIELD_ID_REF_REFERENCE:
720
0
    case FIELD_ID_REF_SEQUENCE:
721
0
    case FIELD_ID_REF_BOOKMARK:
722
0
    case FIELD_ID_REF_FOOTNOTE:
723
0
    case FIELD_ID_REF_ENDNOTE:
724
0
    case FIELD_ID_REF_STYLE:
725
0
    case FIELD_ID_MACRO:
726
0
    case FIELD_ID_TEMPLATE_NAME:
727
0
    case FIELD_ID_CHAPTER:
728
0
    case FIELD_ID_FILE_NAME:
729
0
    case FIELD_ID_CONDITIONAL_TEXT:
730
0
    case FIELD_ID_HIDDEN_TEXT:
731
0
    case FIELD_ID_HIDDEN_PARAGRAPH:
732
0
    case FIELD_ID_DOCINFO_CREATION_AUTHOR:
733
0
    case FIELD_ID_DOCINFO_DESCRIPTION:
734
0
    case FIELD_ID_DOCINFO_PRINT_AUTHOR:
735
0
    case FIELD_ID_DOCINFO_TITLE:
736
0
    case FIELD_ID_DOCINFO_SUBJECT:
737
0
    case FIELD_ID_DOCINFO_KEYWORDS:
738
0
    case FIELD_ID_DOCINFO_SAVE_AUTHOR:
739
0
    case FIELD_ID_DATABASE_NAME:
740
0
    case FIELD_ID_TEXT_INPUT:
741
0
    case FIELD_ID_SENDER:
742
0
    case FIELD_ID_AUTHOR:
743
0
    case FIELD_ID_PAGENAME:
744
0
    case FIELD_ID_PAGESTRING:
745
0
    case FIELD_ID_SHEET_NAME:
746
0
    case FIELD_ID_MEASURE:
747
0
    case FIELD_ID_URL:
748
0
    case FIELD_ID_DROP_DOWN:
749
        // always string:
750
0
        return true;
751
752
0
    case FIELD_ID_SCRIPT:
753
0
    case FIELD_ID_ANNOTATION:
754
0
    case FIELD_ID_DATABASE_NEXT:
755
0
    case FIELD_ID_DATABASE_SELECT:
756
0
    case FIELD_ID_PLACEHOLDER:
757
0
    case FIELD_ID_UNKNOWN:
758
0
    case FIELD_ID_DRAW_HEADER:
759
0
    case FIELD_ID_DRAW_FOOTER:
760
0
    case FIELD_ID_DRAW_DATE_TIME:
761
0
    default:
762
0
        OSL_FAIL("unknown field type/field has no content");
763
0
        return true; // invalid info; string in case of doubt
764
0
    }
765
0
}
766
767
/// export the styles needed by the given field. Called on first pass
768
/// through document
769
void XMLTextFieldExport::ExportFieldAutoStyle(
770
    const Reference<XTextField> & rTextField, const bool bProgress )
771
0
{
772
    // get property set
773
0
    Reference<XPropertySet> xPropSet(rTextField, UNO_QUERY);
774
775
    // add field master to list of used field masters (if desired)
776
0
    if (moUsedMasters)
777
0
    {
778
0
        Reference<XDependentTextField> xDepField(rTextField, UNO_QUERY);
779
0
        if (xDepField.is())
780
0
        {
781
            // The direct parent may be just the table cell, while we want the topmost parent, e.g.
782
            // a header text.
783
0
            Reference<XText> xOurText = GetToplevelText(rTextField->getAnchor()->getText());
784
785
            // insert a list for our XText (if necessary)
786
0
            auto aMapIter = moUsedMasters->try_emplace(xOurText).first;
787
0
            assert(aMapIter != moUsedMasters->end());
788
789
            // insert this text field master
790
0
            OUString sFieldMasterName = GetStringProperty(
791
0
                gsPropertyInstanceName, xDepField->getTextFieldMaster());
792
0
            if (!sFieldMasterName.isEmpty())
793
0
                aMapIter->second.insert( sFieldMasterName );
794
0
        }
795
        // else: no dependent field -> no master -> ignore
796
0
    }
797
798
    // get Field ID
799
0
    FieldIdEnum nToken = GetFieldID(rTextField, xPropSet);
800
801
    // export the character style for all fields
802
    // with one exception: combined character fields export their own
803
    //                     text style below
804
0
    Reference <XPropertySet> xRangePropSet(rTextField->getAnchor(), UNO_QUERY);
805
0
    if (FIELD_ID_COMBINED_CHARACTERS != nToken)
806
0
    {
807
0
        GetExport().GetTextParagraphExport()->Add(
808
0
            XmlStyleFamily::TEXT_TEXT, xRangePropSet);
809
0
    }
810
811
    // process special styles for each field (e.g. data styles)
812
0
    switch (nToken) {
813
814
0
    case FIELD_ID_DATABASE_DISPLAY:
815
0
    {
816
0
        sal_Int32 nFormat = GetIntProperty(gsPropertyNumberFormat, xPropSet);
817
        // workaround: #no-bug#; see IsStringField(...)
818
0
        if ( (5100 != nFormat) &&
819
0
             !GetBoolProperty(gsPropertyIsDataBaseFormat, xPropSet) )
820
0
        {
821
0
                GetExport().addDataStyle(nFormat);
822
0
        }
823
0
        break;
824
0
    }
825
826
0
    case FIELD_ID_DATE:
827
0
    case FIELD_ID_TIME:
828
0
        {
829
            // date and time fields are always number fields, but the
830
            // NumberFormat property is optional (e.g. Calc doesn't
831
            // support it)
832
0
            Reference<XPropertySetInfo> xPropSetInfo(
833
0
                xPropSet->getPropertySetInfo() );
834
0
            if ( xPropSetInfo->hasPropertyByName( gsPropertyNumberFormat ) )
835
0
            {
836
0
                sal_Int32 nFormat =
837
0
                    GetIntProperty(gsPropertyNumberFormat, xPropSet);
838
839
                // nFormat may be -1 for numeric fields that display their
840
                //  variable name. (Maybe this should be a field type, then?)
841
0
                if (nFormat != -1)
842
0
                {
843
0
                    if( ! GetOptionalBoolProperty(
844
0
                            gsPropertyIsFixedLanguage,
845
0
                            xPropSet, xPropSetInfo, false ) )
846
0
                    {
847
0
                        nFormat =
848
0
                            GetExport().dataStyleForceSystemLanguage(nFormat);
849
0
                    }
850
851
0
                    GetExport().addDataStyle( nFormat,
852
0
                                              nToken == FIELD_ID_TIME );
853
0
                }
854
0
            }
855
0
        }
856
0
        break;
857
858
0
    case FIELD_ID_META:
859
        // recurse into content (does not export element, so can be done first)
860
0
        {
861
0
            bool dummy_for_autostyles(true);
862
0
            ExportMetaField(xPropSet, true, bProgress, dummy_for_autostyles);
863
0
        }
864
0
        [[fallthrough]];
865
0
    case FIELD_ID_DOCINFO_PRINT_TIME:
866
0
    case FIELD_ID_DOCINFO_PRINT_DATE:
867
0
    case FIELD_ID_DOCINFO_CREATION_DATE:
868
0
    case FIELD_ID_DOCINFO_CREATION_TIME:
869
0
    case FIELD_ID_DOCINFO_SAVE_TIME:
870
0
    case FIELD_ID_DOCINFO_SAVE_DATE:
871
0
    case FIELD_ID_DOCINFO_EDIT_DURATION:
872
0
    case FIELD_ID_VARIABLE_SET:
873
0
    case FIELD_ID_VARIABLE_GET:
874
0
    case FIELD_ID_VARIABLE_INPUT:
875
0
    case FIELD_ID_USER_GET:
876
0
    case FIELD_ID_EXPRESSION:
877
0
    case FIELD_ID_TABLE_FORMULA:
878
0
    case FIELD_ID_DOCINFO_CUSTOM:
879
        // register number format, if this is a numeric field
880
0
        if (! IsStringField(nToken, xPropSet)) {
881
882
0
            sal_Int32 nFormat =
883
0
                GetIntProperty(gsPropertyNumberFormat, xPropSet);
884
885
            // nFormat may be -1 for numeric fields that display their
886
            //  variable name. (Maybe this should be a field type, then?)
887
0
            if (nFormat != -1)
888
0
            {
889
                // handle formats for fixed language fields
890
                // for all these fields (except table formula)
891
0
                if( ( nToken != FIELD_ID_TABLE_FORMULA ) &&
892
0
                    ! GetOptionalBoolProperty(
893
0
                          gsPropertyIsFixedLanguage,
894
0
                          xPropSet, xPropSet->getPropertySetInfo(),
895
0
                          false ) )
896
0
                {
897
0
                    nFormat =
898
0
                        GetExport().dataStyleForceSystemLanguage(nFormat);
899
0
                }
900
901
0
                GetExport().addDataStyle(nFormat);
902
0
            }
903
0
        }
904
0
        break;
905
906
0
    case FIELD_ID_COMBINED_CHARACTERS:
907
0
    {
908
        // export text style with the addition of the combined characters
909
0
        DBG_ASSERT(nullptr != pCombinedCharactersPropertyState,
910
0
                   "need proper PropertyState for combined characters");
911
0
        std::span<XMLPropertyState> aStates( pCombinedCharactersPropertyState.get(), 1 );
912
0
        GetExport().GetTextParagraphExport()->Add(
913
0
            XmlStyleFamily::TEXT_TEXT, xRangePropSet,
914
0
            aStates);
915
0
        break;
916
0
    }
917
918
0
    case FIELD_ID_ANNOTATION:
919
0
        if (auto xText = XTextFromTextRangeProp(xPropSet))
920
0
            GetExport().GetTextParagraphExport()->collectTextAutoStyles(xText, bProgress);
921
0
        break;
922
923
0
    case FIELD_ID_SCRIPT:
924
0
    case FIELD_ID_BIBLIOGRAPHY:
925
0
    case FIELD_ID_DDE:
926
0
    case FIELD_ID_REF_REFERENCE:
927
0
    case FIELD_ID_REF_SEQUENCE:
928
0
    case FIELD_ID_REF_BOOKMARK:
929
0
    case FIELD_ID_REF_FOOTNOTE:
930
0
    case FIELD_ID_REF_ENDNOTE:
931
0
    case FIELD_ID_REF_STYLE:
932
0
    case FIELD_ID_MACRO:
933
0
    case FIELD_ID_REFPAGE_SET:
934
0
    case FIELD_ID_REFPAGE_GET:
935
0
    case FIELD_ID_COUNT_PAGES:
936
0
    case FIELD_ID_COUNT_PAGES_RANGE:
937
0
    case FIELD_ID_COUNT_PARAGRAPHS:
938
0
    case FIELD_ID_COUNT_WORDS:
939
0
    case FIELD_ID_COUNT_CHARACTERS:
940
0
    case FIELD_ID_COUNT_TABLES:
941
0
    case FIELD_ID_COUNT_GRAPHICS:
942
0
    case FIELD_ID_COUNT_OBJECTS:
943
0
    case FIELD_ID_CONDITIONAL_TEXT:
944
0
    case FIELD_ID_HIDDEN_TEXT:
945
0
    case FIELD_ID_HIDDEN_PARAGRAPH:
946
0
    case FIELD_ID_DOCINFO_CREATION_AUTHOR:
947
0
    case FIELD_ID_DOCINFO_DESCRIPTION:
948
0
    case FIELD_ID_DOCINFO_PRINT_AUTHOR:
949
0
    case FIELD_ID_DOCINFO_TITLE:
950
0
    case FIELD_ID_DOCINFO_SUBJECT:
951
0
    case FIELD_ID_DOCINFO_KEYWORDS:
952
0
    case FIELD_ID_DOCINFO_REVISION:
953
0
    case FIELD_ID_DOCINFO_SAVE_AUTHOR:
954
0
    case FIELD_ID_SEQUENCE:
955
0
    case FIELD_ID_PAGENAME:
956
0
    case FIELD_ID_PAGENUMBER:
957
0
    case FIELD_ID_PAGESTRING:
958
0
    case FIELD_ID_AUTHOR:
959
0
    case FIELD_ID_SENDER:
960
0
    case FIELD_ID_PLACEHOLDER:
961
0
    case FIELD_ID_USER_INPUT:
962
0
    case FIELD_ID_TEXT_INPUT:
963
0
    case FIELD_ID_DATABASE_NEXT:
964
0
    case FIELD_ID_DATABASE_SELECT:
965
0
    case FIELD_ID_DATABASE_NAME:
966
0
    case FIELD_ID_DATABASE_NUMBER:
967
0
    case FIELD_ID_TEMPLATE_NAME:
968
0
    case FIELD_ID_CHAPTER:
969
0
    case FIELD_ID_FILE_NAME:
970
0
    case FIELD_ID_SHEET_NAME:
971
0
    case FIELD_ID_MEASURE:
972
0
    case FIELD_ID_URL:
973
0
    case FIELD_ID_DROP_DOWN:
974
0
    case FIELD_ID_DRAW_DATE_TIME:
975
0
    case FIELD_ID_DRAW_FOOTER:
976
0
    case FIELD_ID_DRAW_HEADER:
977
0
        ; // no formats for these fields!
978
0
        break;
979
980
0
    case FIELD_ID_UNKNOWN:
981
0
    default:
982
0
        OSL_FAIL("unknown field type!");
983
        // ignore -> no format for unknown
984
0
        break;
985
0
    }
986
0
}
987
988
/// export the given field to XML. Called on second pass through document
989
void XMLTextFieldExport::ExportField(
990
    const Reference<XTextField> & rTextField, bool bProgress,
991
    bool & rPrevCharIsSpace)
992
0
{
993
    // get property set
994
0
    Reference<XPropertySet> xPropSet(rTextField, UNO_QUERY);
995
996
    // get property set of range (for the attributes)
997
0
    Reference <XPropertySet> xRangePropSet(rTextField->getAnchor(), UNO_QUERY);
998
999
    // get Field ID
1000
0
    enum FieldIdEnum nToken = GetFieldID(rTextField, xPropSet);
1001
1002
    // special treatment for combined characters field, because it is
1003
    // exported as a style
1004
0
    const XMLPropertyState* aStates[] = { pCombinedCharactersPropertyState.get(), nullptr };
1005
0
    const XMLPropertyState **pStates =
1006
0
                FIELD_ID_COMBINED_CHARACTERS == nToken
1007
0
                    ? aStates
1008
0
                    : nullptr;
1009
1010
    // find out whether we need to set the style
1011
0
    bool bIsUICharStyle;
1012
0
    bool bHasAutoStyle;
1013
0
    OUString sStyle = GetExport().GetTextParagraphExport()->
1014
0
        FindTextStyle( xRangePropSet, bIsUICharStyle, bHasAutoStyle, pStates );
1015
0
    bool bHasStyle = !sStyle.isEmpty();
1016
1017
0
    {
1018
0
        Reference<XPropertySetInfo> xRangePropSetInfo;
1019
0
        XMLTextCharStyleNamesElementExport aCharStylesExport(
1020
0
            GetExport(), bIsUICharStyle &&
1021
0
                         GetExport().GetTextParagraphExport()
1022
0
                             ->GetCharStyleNamesPropInfoCache().hasProperty(
1023
0
                                        xRangePropSet, xRangePropSetInfo ), bHasAutoStyle,
1024
0
            xRangePropSet, gsPropertyCharStyleNames );
1025
1026
        // export span with style (if necessary)
1027
        // (except for combined characters field)
1028
0
        if( bHasStyle )
1029
0
        {
1030
            // export <text:span> element
1031
0
            GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
1032
0
                            GetExport().EncodeStyleName( sStyle ) );
1033
0
        }
1034
0
        SvXMLElementExport aSpan( GetExport(), bHasStyle,
1035
0
                                  XML_NAMESPACE_TEXT, XML_SPAN,
1036
0
                                  false, false);
1037
1038
        // finally, export the field itself
1039
0
        ExportFieldHelper( rTextField, xPropSet, xRangePropSet, nToken,
1040
0
            bProgress, rPrevCharIsSpace);
1041
0
    }
1042
0
}
1043
1044
/// export the given field to XML. Called on second pass through document
1045
void XMLTextFieldExport::ExportFieldHelper(
1046
    const Reference<XTextField> & rTextField,
1047
    const Reference<XPropertySet> & rPropSet,
1048
    const Reference<XPropertySet> &,
1049
    enum FieldIdEnum nToken,
1050
    bool bProgress,
1051
    bool & rPrevCharIsSpace)
1052
0
{
1053
    // get property set info (because some attributes are not support
1054
    // in all implementations)
1055
0
    Reference<XPropertySetInfo> xPropSetInfo(rPropSet->getPropertySetInfo());
1056
1057
0
    OUString sPresentation = rTextField->getPresentation(false);
1058
1059
    // process each field type
1060
0
    switch (nToken) {
1061
0
    case FIELD_ID_AUTHOR:
1062
        // author field: fixed, field (sub-)type
1063
0
        if (xPropSetInfo->hasPropertyByName(gsPropertyIsFixed))
1064
0
        {
1065
0
            GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_FIXED,
1066
0
                                 (GetBoolProperty(gsPropertyIsFixed, rPropSet) ? XML_TRUE : XML_FALSE) );
1067
0
        }
1068
0
        ExportElement(MapAuthorFieldName(rPropSet), sPresentation);
1069
0
        break;
1070
1071
0
    case FIELD_ID_SENDER:
1072
        // sender field: fixed, field (sub-)type
1073
0
        ProcessBoolean(XML_FIXED,
1074
0
                       GetBoolProperty(gsPropertyIsFixed, rPropSet), true);
1075
0
        ExportElement(MapSenderFieldName(rPropSet), sPresentation);
1076
0
        break;
1077
1078
0
    case FIELD_ID_PLACEHOLDER:
1079
        // placeholder field: type, name, description
1080
0
        ProcessString(XML_PLACEHOLDER_TYPE,
1081
0
                      MapPlaceholderType(
1082
0
                        GetInt16Property(gsPropertyPlaceholderType, rPropSet)));
1083
0
        ProcessString(XML_DESCRIPTION,
1084
0
                      GetStringProperty(gsPropertyHint,rPropSet), true);
1085
0
        ExportElement(XML_PLACEHOLDER, sPresentation);
1086
0
        break;
1087
1088
0
    case FIELD_ID_VARIABLE_SET:
1089
0
    {
1090
        // variable set field: name, visible, format&value
1091
0
        ProcessString(XML_NAME,
1092
0
                      GetStringProperty(gsPropertyVariableName, rPropSet));
1093
0
        ProcessDisplay(GetBoolProperty(gsPropertyIsVisible, rPropSet),
1094
0
                       false);
1095
0
        ProcessString(XML_FORMULA, XML_NAMESPACE_OOOW,
1096
0
                      GetStringProperty(gsPropertyContent, rPropSet),
1097
0
                      sPresentation);
1098
0
        ProcessValueAndType(IsStringField(nToken, rPropSet),
1099
0
                            GetIntProperty(gsPropertyNumberFormat, rPropSet),
1100
0
                            GetStringProperty(gsPropertyContent, rPropSet),
1101
0
                            sPresentation,
1102
0
                            GetDoubleProperty(gsPropertyValue, rPropSet),
1103
0
                            true, true, true,
1104
0
                            ! GetOptionalBoolProperty(
1105
0
                                 gsPropertyIsFixedLanguage,
1106
0
                                 rPropSet, xPropSetInfo, false ) );
1107
0
        ExportElement(XML_VARIABLE_SET, sPresentation);
1108
0
        break;
1109
0
    }
1110
0
    case FIELD_ID_VARIABLE_GET:
1111
0
    {
1112
        // variable get field: name, format&value
1113
0
        ProcessString(XML_NAME,
1114
0
                      GetStringProperty(gsPropertyContent, rPropSet));
1115
0
        bool bCmd = GetBoolProperty(gsPropertyIsShowFormula, rPropSet);
1116
0
        ProcessDisplay(true, bCmd);
1117
        // show style, unless name will be shown
1118
0
        ProcessValueAndType(IsStringField(nToken, rPropSet),
1119
0
                            GetIntProperty(gsPropertyNumberFormat, rPropSet),
1120
0
                            u""_ustr, u"", 0.0, // values not used
1121
0
                            false,
1122
0
                            false,
1123
0
                            !bCmd,
1124
0
                            ! GetOptionalBoolProperty(
1125
0
                                 gsPropertyIsFixedLanguage,
1126
0
                                 rPropSet, xPropSetInfo, false ) );
1127
0
        ExportElement(XML_VARIABLE_GET, sPresentation);
1128
0
        break;
1129
0
    }
1130
0
    case FIELD_ID_VARIABLE_INPUT:
1131
        // variable input field: name, description, format&value
1132
0
        ProcessString(XML_NAME,
1133
0
                      GetStringProperty(gsPropertyVariableName, rPropSet));
1134
0
        ProcessString(XML_DESCRIPTION,
1135
0
                      GetStringProperty(gsPropertyHint , rPropSet));
1136
0
        ProcessDisplay(GetBoolProperty(gsPropertyIsVisible, rPropSet),
1137
0
                       false);
1138
0
        ProcessString(XML_FORMULA, XML_NAMESPACE_OOOW,
1139
0
                      GetStringProperty(gsPropertyContent, rPropSet),
1140
0
                      sPresentation);
1141
0
        ProcessValueAndType(IsStringField(nToken, rPropSet),
1142
0
                            GetIntProperty(gsPropertyNumberFormat, rPropSet),
1143
0
                            GetStringProperty(gsPropertyContent, rPropSet),
1144
0
                            sPresentation,
1145
0
                            GetDoubleProperty(gsPropertyValue, rPropSet),
1146
0
                            true, true, true,
1147
0
                            ! GetOptionalBoolProperty(
1148
0
                                 gsPropertyIsFixedLanguage,
1149
0
                                 rPropSet, xPropSetInfo, false ) );
1150
0
        ExportElement(XML_VARIABLE_INPUT, sPresentation);
1151
0
        break;
1152
1153
0
    case FIELD_ID_USER_GET:
1154
        // user field: name, hidden, style
1155
0
    {
1156
0
        bool bCmd = GetBoolProperty(gsPropertyIsShowFormula, rPropSet);
1157
0
        ProcessDisplay(GetBoolProperty(gsPropertyIsVisible, rPropSet),
1158
0
                       bCmd);
1159
0
        ProcessValueAndType(IsStringField(nToken, rPropSet),
1160
0
                            GetIntProperty(gsPropertyNumberFormat, rPropSet),
1161
0
                            u""_ustr, u"", 0.0, // values not used
1162
0
                            false, false, !bCmd,
1163
0
                            ! GetOptionalBoolProperty(
1164
0
                                 gsPropertyIsFixedLanguage,
1165
0
                                 rPropSet, xPropSetInfo, false ) );
1166
1167
        // name from FieldMaster
1168
0
        ProcessString(XML_NAME,
1169
0
                      GetStringProperty(gsPropertyName,
1170
0
                                        GetMasterPropertySet(rTextField)));
1171
0
        ExportElement(XML_USER_FIELD_GET, sPresentation);
1172
0
        break;
1173
0
    }
1174
1175
0
    case FIELD_ID_USER_INPUT:
1176
        // user input field: name (from FieldMaster), description
1177
//      ProcessString(XML_NAME,
1178
//                    GetStringProperty(sPropertyName,
1179
//                                      GetMasterPropertySet(rTextField)));
1180
0
        ProcessString(XML_NAME,
1181
0
                      GetStringProperty(gsPropertyContent, rPropSet));
1182
0
        ProcessString(XML_DESCRIPTION,
1183
0
                      GetStringProperty(gsPropertyHint, rPropSet));
1184
0
        ExportElement(XML_USER_FIELD_INPUT, sPresentation);
1185
0
        break;
1186
1187
0
    case FIELD_ID_SEQUENCE:
1188
0
    {
1189
        // sequence field: name, formula, seq-format
1190
0
        OUString sName = GetStringProperty(gsPropertyVariableName, rPropSet);
1191
        // TODO: use reference name only if actually being referenced.
1192
0
        ProcessString(XML_REF_NAME,
1193
0
                      MakeSequenceRefName(
1194
0
                          GetInt16Property(gsPropertySequenceValue, rPropSet),
1195
0
                          sName));
1196
0
        ProcessString(XML_NAME, sName);
1197
0
        ProcessString(XML_FORMULA,  XML_NAMESPACE_OOOW,
1198
0
                      GetStringProperty(gsPropertyContent, rPropSet),
1199
0
                      sPresentation);
1200
0
        ProcessNumberingType(GetInt16Property(gsPropertyNumberingType,
1201
0
                                              rPropSet));
1202
0
        ExportElement(XML_SEQUENCE, sPresentation);
1203
0
        break;
1204
0
    }
1205
1206
0
    case FIELD_ID_EXPRESSION:
1207
0
    {
1208
        // formula field: formula, format&value
1209
0
        bool bCmd = GetBoolProperty(gsPropertyIsShowFormula, rPropSet);
1210
0
        ProcessString(XML_FORMULA,  XML_NAMESPACE_OOOW,
1211
0
                      GetStringProperty(gsPropertyContent, rPropSet),
1212
0
                      sPresentation);
1213
0
        ProcessDisplay(true, bCmd);
1214
0
        ProcessValueAndType(IsStringField(nToken, rPropSet),
1215
0
                            GetIntProperty(gsPropertyNumberFormat, rPropSet),
1216
0
                            GetStringProperty(gsPropertyContent, rPropSet),
1217
0
                            sPresentation,
1218
0
                            GetDoubleProperty(gsPropertyValue, rPropSet),
1219
0
                            !bCmd, !bCmd, !bCmd,
1220
0
                            ! GetOptionalBoolProperty(
1221
0
                                 gsPropertyIsFixedLanguage,
1222
0
                                 rPropSet, xPropSetInfo, false ) );
1223
0
        ExportElement(XML_EXPRESSION, sPresentation);
1224
0
        break;
1225
0
    }
1226
1227
0
    case FIELD_ID_TEXT_INPUT:
1228
        // text input field: description and string-value
1229
0
        ProcessString(XML_DESCRIPTION,
1230
0
                      GetStringProperty(gsPropertyHint, rPropSet));
1231
0
        ProcessString(XML_HELP,
1232
0
                      GetStringProperty(gsPropertyHelp, rPropSet), true);
1233
0
        ProcessString(XML_HINT,
1234
0
                      GetStringProperty(gsPropertyTooltip, rPropSet), true);
1235
0
        ExportElement(XML_TEXT_INPUT, sPresentation);
1236
0
        break;
1237
1238
0
    case FIELD_ID_TIME:
1239
        // all properties (except IsDate) are optional!
1240
0
        if (xPropSetInfo->hasPropertyByName(gsPropertyNumberFormat))
1241
0
        {
1242
0
            ProcessValueAndType(false,
1243
0
                                GetIntProperty(gsPropertyNumberFormat,rPropSet),
1244
0
                                u""_ustr, u"", 0.0, // not used
1245
0
                                false, false, true,
1246
0
                                ! GetOptionalBoolProperty(
1247
0
                                    gsPropertyIsFixedLanguage,
1248
0
                                    rPropSet, xPropSetInfo, false ),
1249
0
                                true);
1250
0
        }
1251
0
        if (xPropSetInfo->hasPropertyByName(gsPropertyDateTimeValue))
1252
0
        {
1253
            // no value -> current time
1254
0
            ProcessTimeOrDateTime(XML_TIME_VALUE,
1255
0
                            GetDateTimeProperty(gsPropertyDateTimeValue,
1256
0
                                                rPropSet));
1257
0
        }
1258
0
        if (xPropSetInfo->hasPropertyByName(gsPropertyDateTime))
1259
0
        {
1260
            // no value -> current time
1261
0
            ProcessTimeOrDateTime(XML_TIME_VALUE,
1262
0
                            GetDateTimeProperty(gsPropertyDateTime,rPropSet));
1263
0
        }
1264
0
        if (xPropSetInfo->hasPropertyByName(gsPropertyIsFixed))
1265
0
        {
1266
0
            ProcessBoolean(XML_FIXED,
1267
0
                           GetBoolProperty(gsPropertyIsFixed, rPropSet),
1268
0
                           false);
1269
0
        }
1270
0
        if (xPropSetInfo->hasPropertyByName(gsPropertyAdjust))
1271
0
        {
1272
            // adjust value given as integer in minutes
1273
0
            ProcessDateTime(XML_TIME_ADJUST,
1274
0
                            GetIntProperty(gsPropertyAdjust, rPropSet),
1275
0
                            false, true);
1276
0
        }
1277
0
        ExportElement(XML_TIME, sPresentation);
1278
0
        break;
1279
1280
0
    case FIELD_ID_DATE:
1281
        // all properties (except IsDate) are optional!
1282
0
        if (xPropSetInfo->hasPropertyByName(gsPropertyNumberFormat))
1283
0
        {
1284
0
            ProcessValueAndType(false,
1285
0
                                GetIntProperty(gsPropertyNumberFormat,rPropSet),
1286
0
                                u""_ustr, u"", 0.0, // not used
1287
0
                                false, false, true,
1288
0
                                ! GetOptionalBoolProperty(
1289
0
                                    gsPropertyIsFixedLanguage,
1290
0
                                    rPropSet, xPropSetInfo, false ) );
1291
0
        }
1292
0
        if (xPropSetInfo->hasPropertyByName(gsPropertyDateTimeValue))
1293
0
        {
1294
            // no value -> current date
1295
0
            ProcessDateTime(XML_DATE_VALUE,
1296
0
                            GetDateTimeProperty(gsPropertyDateTimeValue,
1297
0
                                                rPropSet));
1298
0
        }
1299
        // TODO: remove double-handling after SRC614
1300
0
        else if (xPropSetInfo->hasPropertyByName(gsPropertyDateTime))
1301
0
        {
1302
0
            ProcessDateTime(XML_DATE_VALUE,
1303
0
                            GetDateTimeProperty(gsPropertyDateTime,rPropSet));
1304
0
        }
1305
0
        if (xPropSetInfo->hasPropertyByName(gsPropertyIsFixed))
1306
0
        {
1307
0
            ProcessBoolean(XML_FIXED,
1308
0
                           GetBoolProperty(gsPropertyIsFixed, rPropSet),
1309
0
                           false);
1310
0
        }
1311
0
        if (xPropSetInfo->hasPropertyByName(gsPropertyAdjust))
1312
0
        {
1313
            // adjust value given as number of days
1314
0
            ProcessDateTime(XML_DATE_ADJUST,
1315
0
                            GetIntProperty(gsPropertyAdjust, rPropSet),
1316
0
                            true, true);
1317
0
        }
1318
0
        ExportElement(XML_DATE, sPresentation);
1319
0
        break;
1320
1321
0
    case FIELD_ID_PAGENUMBER:
1322
        // all properties are optional
1323
0
        if (xPropSetInfo->hasPropertyByName(gsPropertyNumberingType))
1324
0
        {
1325
0
            ProcessNumberingType(GetInt16Property(gsPropertyNumberingType,
1326
0
                                                  rPropSet));
1327
0
        }
1328
0
        if (xPropSetInfo->hasPropertyByName(gsPropertyOffset))
1329
0
        {
1330
0
            sal_Int32 nAdjust = GetIntProperty(gsPropertyOffset, rPropSet);
1331
1332
0
            if (xPropSetInfo->hasPropertyByName(gsPropertySubType))
1333
0
            {
1334
                // property SubType used in MapPageNumberName
1335
0
                ProcessString(XML_SELECT_PAGE,
1336
0
                              MapPageNumberName(rPropSet, nAdjust));
1337
0
            }
1338
0
            ProcessIntegerDef(XML_PAGE_ADJUST, nAdjust, 0);
1339
0
        }
1340
0
        ExportElement(XML_PAGE_NUMBER, sPresentation);
1341
0
        break;
1342
1343
0
    case FIELD_ID_PAGESTRING:
1344
0
    {
1345
0
        ProcessString(XML_STRING_VALUE,
1346
0
                      GetStringProperty(gsPropertyUserText, rPropSet),
1347
0
                      sPresentation);
1348
0
        sal_Int32 nDummy = 0; // MapPageNumberName need int
1349
0
        ProcessString(XML_SELECT_PAGE, MapPageNumberName(rPropSet, nDummy));
1350
0
        ExportElement(XML_PAGE_CONTINUATION, sPresentation);
1351
0
        break;
1352
0
    }
1353
1354
0
    case FIELD_ID_DATABASE_NAME:
1355
0
        ProcessString(XML_TABLE_NAME,
1356
0
                      GetStringProperty(gsPropertyDataTableName, rPropSet));
1357
0
        ProcessCommandType(GetIntProperty(gsPropertyDataCommandType, rPropSet));
1358
0
        ProcessDisplay(GetBoolProperty(gsPropertyIsVisible, rPropSet),
1359
0
                       false);
1360
0
        ExportDataBaseElement(XML_DATABASE_NAME, sPresentation,
1361
0
                              rPropSet, xPropSetInfo);
1362
0
        break;
1363
1364
0
    case FIELD_ID_DATABASE_NUMBER:
1365
0
        ProcessString(XML_TABLE_NAME,
1366
0
                      GetStringProperty(gsPropertyDataTableName, rPropSet));
1367
0
        ProcessCommandType(GetIntProperty(gsPropertyDataCommandType, rPropSet));
1368
0
        ProcessNumberingType(
1369
0
            GetInt16Property(gsPropertyNumberingType,rPropSet));
1370
0
        ProcessInteger(XML_VALUE,
1371
0
                       GetIntProperty(gsPropertySetNumber, rPropSet));
1372
0
        ProcessDisplay(GetBoolProperty(gsPropertyIsVisible, rPropSet),
1373
0
                       false);
1374
0
        ExportDataBaseElement(XML_DATABASE_ROW_NUMBER, sPresentation,
1375
0
                              rPropSet, xPropSetInfo);
1376
0
        break;
1377
1378
0
    case FIELD_ID_DATABASE_NEXT:
1379
0
        ProcessString(XML_TABLE_NAME,
1380
0
                      GetStringProperty(gsPropertyDataTableName, rPropSet));
1381
0
        ProcessCommandType(GetIntProperty(gsPropertyDataCommandType, rPropSet));
1382
0
        ProcessString(XML_CONDITION, XML_NAMESPACE_OOOW,
1383
0
                      GetStringProperty(gsPropertyCondition, rPropSet));
1384
0
        DBG_ASSERT(sPresentation.isEmpty(),
1385
0
                   "Unexpected presentation for database next field");
1386
0
        ExportDataBaseElement(XML_DATABASE_NEXT, OUString(),
1387
0
                              rPropSet, xPropSetInfo);
1388
0
        break;
1389
1390
0
    case FIELD_ID_DATABASE_SELECT:
1391
0
        ProcessString(XML_TABLE_NAME,
1392
0
                      GetStringProperty(gsPropertyDataTableName, rPropSet));
1393
0
        ProcessCommandType(GetIntProperty(gsPropertyDataCommandType, rPropSet));
1394
0
        ProcessString(XML_CONDITION, XML_NAMESPACE_OOOW,
1395
0
                      GetStringProperty(gsPropertyCondition, rPropSet));
1396
0
        ProcessInteger(XML_ROW_NUMBER,
1397
0
                       GetIntProperty(gsPropertySetNumber, rPropSet));
1398
0
        DBG_ASSERT(sPresentation.isEmpty(),
1399
0
                   "Unexpected presentation for database select field");
1400
0
        ExportDataBaseElement(XML_DATABASE_ROW_SELECT, OUString(),
1401
0
                              rPropSet, xPropSetInfo);
1402
0
        break;
1403
1404
0
    case FIELD_ID_DATABASE_DISPLAY:
1405
0
    {
1406
        // get database, table and column name from field master
1407
0
        const Reference<XPropertySet> xMaster = GetMasterPropertySet(rTextField);
1408
0
        ProcessString(XML_TABLE_NAME,
1409
0
                      GetStringProperty(gsPropertyDataTableName, xMaster));
1410
0
        ProcessCommandType(GetIntProperty(gsPropertyDataCommandType, xMaster));
1411
0
        ProcessString(XML_COLUMN_NAME,
1412
0
                      GetStringProperty(gsPropertyDataColumnName, xMaster));
1413
        // export number format if available (happens only for numbers!)
1414
0
        if (!GetBoolProperty(gsPropertyIsDataBaseFormat, rPropSet))
1415
0
        {
1416
0
            ProcessValueAndType(false,  // doesn't happen for text
1417
0
                                GetIntProperty(gsPropertyNumberFormat,rPropSet),
1418
0
                                u""_ustr, u"", 0.0, // not used
1419
0
                                false, false, true, false);
1420
0
        }
1421
0
        ProcessDisplay(GetBoolProperty(gsPropertyIsVisible, rPropSet),
1422
0
                       false);
1423
0
        ExportDataBaseElement(XML_DATABASE_DISPLAY, sPresentation,
1424
0
                              xMaster, xMaster->getPropertySetInfo());
1425
0
        break;
1426
0
    }
1427
1428
0
    case FIELD_ID_DOCINFO_REVISION:
1429
0
        ProcessBoolean(XML_FIXED,
1430
0
                       GetBoolProperty(gsPropertyIsFixed, rPropSet), false);
1431
0
        ExportElement(MapDocInfoFieldName(nToken), sPresentation);
1432
0
        break;
1433
1434
0
    case FIELD_ID_DOCINFO_EDIT_DURATION:
1435
0
    case FIELD_ID_DOCINFO_SAVE_TIME:
1436
0
    case FIELD_ID_DOCINFO_CREATION_TIME:
1437
0
    case FIELD_ID_DOCINFO_PRINT_TIME:
1438
0
    case FIELD_ID_DOCINFO_SAVE_DATE:
1439
0
    case FIELD_ID_DOCINFO_CREATION_DATE:
1440
0
    case FIELD_ID_DOCINFO_PRINT_DATE:
1441
0
        ProcessValueAndType(false,
1442
0
                            GetIntProperty(gsPropertyNumberFormat, rPropSet),
1443
0
                            u""_ustr, u"", 0.0,
1444
0
                            false, false, true,
1445
0
                            ! GetOptionalBoolProperty(
1446
0
                                    gsPropertyIsFixedLanguage,
1447
0
                                    rPropSet, xPropSetInfo, false ) );
1448
1449
        // todo: export date/time value, but values not available -> core bug
1450
0
        ProcessBoolean(XML_FIXED,
1451
0
                       GetBoolProperty(gsPropertyIsFixed, rPropSet), false);
1452
0
        ExportElement(MapDocInfoFieldName(nToken), sPresentation);
1453
0
        break;
1454
1455
0
    case FIELD_ID_DOCINFO_CREATION_AUTHOR:
1456
0
    case FIELD_ID_DOCINFO_DESCRIPTION:
1457
0
    case FIELD_ID_DOCINFO_PRINT_AUTHOR:
1458
0
    case FIELD_ID_DOCINFO_TITLE:
1459
0
    case FIELD_ID_DOCINFO_SUBJECT:
1460
0
    case FIELD_ID_DOCINFO_KEYWORDS:
1461
0
    case FIELD_ID_DOCINFO_SAVE_AUTHOR:
1462
0
        if (xPropSetInfo->hasPropertyByName(gsPropertyIsFixed))
1463
0
        {
1464
0
            ProcessBoolean(XML_FIXED,
1465
0
                           GetBoolProperty(gsPropertyIsFixed, rPropSet), false);
1466
0
        }
1467
0
        ExportElement(MapDocInfoFieldName(nToken), sPresentation);
1468
0
        break;
1469
1470
0
    case FIELD_ID_DOCINFO_CUSTOM:
1471
0
    {
1472
0
        ProcessValueAndType(false,  // doesn't happen for text
1473
0
                                GetIntProperty(gsPropertyNumberFormat,rPropSet),
1474
0
                                u""_ustr, u"", 0.0, // not used
1475
0
                                false, false, true,
1476
0
                                ! GetOptionalBoolProperty(
1477
0
                                    gsPropertyIsFixedLanguage,
1478
0
                                    rPropSet, xPropSetInfo, false ));
1479
0
        uno::Any aAny = rPropSet->getPropertyValue( gsPropertyName );
1480
0
        OUString sName;
1481
0
        aAny >>= sName;
1482
0
        ProcessString(XML_NAME, sName);
1483
0
        ProcessBoolean(XML_FIXED, GetBoolProperty(gsPropertyIsFixed, rPropSet), false);
1484
0
        ExportElement(XML_USER_DEFINED, sPresentation);
1485
0
        break;
1486
0
    }
1487
1488
0
    case FIELD_ID_COUNT_PAGES:
1489
0
    case FIELD_ID_COUNT_PARAGRAPHS:
1490
0
    case FIELD_ID_COUNT_WORDS:
1491
0
    case FIELD_ID_COUNT_CHARACTERS:
1492
0
    case FIELD_ID_COUNT_TABLES:
1493
0
    case FIELD_ID_COUNT_GRAPHICS:
1494
0
    case FIELD_ID_COUNT_OBJECTS:
1495
        // all properties optional (applies to pages only, but I'll do
1496
        // it for all for sake of common implementation)
1497
0
        if (xPropSetInfo->hasPropertyByName(gsPropertyNumberingType))
1498
0
        {
1499
0
            ProcessNumberingType(GetInt16Property(gsPropertyNumberingType,
1500
0
                                                  rPropSet));
1501
0
        }
1502
0
        ExportElement(MapCountFieldName(nToken), sPresentation, XML_NAMESPACE_TEXT);
1503
0
        break;
1504
1505
0
    case FIELD_ID_COUNT_PAGES_RANGE:
1506
0
        if (GetExport().getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
1507
0
        {
1508
0
            if (xPropSetInfo->hasPropertyByName(gsPropertyNumberingType))
1509
0
            {
1510
0
                ProcessNumberingType(GetInt16Property(gsPropertyNumberingType,
1511
0
                                                      rPropSet));
1512
0
            }
1513
0
            ExportElement(MapCountFieldName(nToken), sPresentation, XML_NAMESPACE_LO_EXT);
1514
0
        }
1515
0
        else
1516
0
        {
1517
0
              GetExport().Characters(sPresentation);
1518
0
        }
1519
0
        break;
1520
0
    case FIELD_ID_CONDITIONAL_TEXT:
1521
0
        ProcessString(XML_CONDITION, XML_NAMESPACE_OOOW,
1522
0
                      GetStringProperty(gsPropertyCondition, rPropSet));
1523
0
        ProcessString(XML_STRING_VALUE_IF_TRUE,
1524
0
                      GetStringProperty(gsPropertyTrueContent, rPropSet));
1525
0
        ProcessString(XML_STRING_VALUE_IF_FALSE,
1526
0
                      GetStringProperty(gsPropertyFalseContent, rPropSet));
1527
0
        ProcessBoolean(XML_CURRENT_VALUE,
1528
0
                       GetBoolProperty(gsPropertyIsConditionTrue, rPropSet),
1529
0
                       false);
1530
0
        ExportElement(XML_CONDITIONAL_TEXT, sPresentation);
1531
0
        break;
1532
1533
0
    case FIELD_ID_HIDDEN_TEXT:
1534
0
        ProcessString(XML_CONDITION, XML_NAMESPACE_OOOW,
1535
0
                      GetStringProperty(gsPropertyCondition, rPropSet));
1536
0
        ProcessString(XML_STRING_VALUE,
1537
0
                      GetStringProperty(gsPropertyContent, rPropSet));
1538
0
        ProcessBoolean(XML_IS_HIDDEN,
1539
0
                       GetBoolProperty(gsPropertyIsHidden, rPropSet),
1540
0
                       false);
1541
0
        ExportElement(XML_HIDDEN_TEXT, sPresentation);
1542
0
        break;
1543
1544
0
    case FIELD_ID_HIDDEN_PARAGRAPH:
1545
0
        ProcessString(XML_CONDITION, XML_NAMESPACE_OOOW,
1546
0
                      GetStringProperty(gsPropertyCondition, rPropSet));
1547
0
        ProcessBoolean(XML_IS_HIDDEN,
1548
0
                       GetBoolProperty(gsPropertyIsHidden, rPropSet),
1549
0
                       false);
1550
0
        DBG_ASSERT(sPresentation.isEmpty(),
1551
0
                   "Unexpected presentation for hidden paragraph field");
1552
0
        ExportElement(XML_HIDDEN_PARAGRAPH);
1553
0
        break;
1554
1555
0
    case FIELD_ID_TEMPLATE_NAME:
1556
0
        ProcessString(XML_DISPLAY,
1557
0
                      MapTemplateDisplayFormat(
1558
0
                          GetInt16Property(gsPropertyFileFormat, rPropSet)));
1559
0
        ExportElement(XML_TEMPLATE_NAME, sPresentation);
1560
0
        break;
1561
1562
0
    case FIELD_ID_CHAPTER:
1563
0
        ProcessString(XML_DISPLAY,
1564
0
                      MapChapterDisplayFormat(
1565
0
                          GetInt16Property(gsPropertyChapterFormat, rPropSet)));
1566
        // API numbers 0..9, we number 1..10
1567
0
        ProcessInteger(XML_OUTLINE_LEVEL,
1568
0
                       GetInt8Property(gsPropertyLevel, rPropSet) + 1);
1569
0
        ExportElement(XML_CHAPTER, sPresentation);
1570
0
        break;
1571
1572
0
    case FIELD_ID_FILE_NAME:
1573
        // all properties are optional
1574
0
        if (xPropSetInfo->hasPropertyByName(gsPropertyFileFormat))
1575
0
        {
1576
0
            ProcessString(XML_DISPLAY,
1577
0
                          MapFilenameDisplayFormat(
1578
0
                             GetInt16Property(gsPropertyFileFormat, rPropSet)));
1579
0
        }
1580
0
        if (xPropSetInfo->hasPropertyByName(gsPropertyIsFixed))
1581
0
        {
1582
0
            ProcessBoolean(XML_FIXED,
1583
0
                           GetBoolProperty(gsPropertyIsFixed, rPropSet),
1584
0
                           false);
1585
0
        }
1586
0
        ExportElement(XML_FILE_NAME, sPresentation);
1587
0
        break;
1588
1589
0
    case FIELD_ID_REFPAGE_SET:
1590
0
        ProcessBoolean(XML_ACTIVE,
1591
0
                       GetBoolProperty(gsPropertyOn, rPropSet), true);
1592
0
        ProcessIntegerDef(XML_PAGE_ADJUST,
1593
0
                       GetInt16Property(gsPropertyOffset, rPropSet), 0);
1594
0
        DBG_ASSERT(sPresentation.isEmpty(),
1595
0
                   "Unexpected presentation page variable field");
1596
0
        ExportElement(XML_PAGE_VARIABLE_SET);
1597
0
        break;
1598
1599
0
    case FIELD_ID_REFPAGE_GET:
1600
0
        ProcessNumberingType(
1601
0
            GetInt16Property(gsPropertyNumberingType, rPropSet));
1602
0
        ExportElement(XML_PAGE_VARIABLE_GET, sPresentation);
1603
0
        break;
1604
1605
0
    case FIELD_ID_MACRO:
1606
0
        ExportMacro( rPropSet, sPresentation );
1607
0
        break;
1608
1609
0
    case FIELD_ID_REF_SEQUENCE:
1610
        // reference to sequence: format, name, find value (and element)
1611
        // was: if (nSeqNumber != -1) ...
1612
0
        ProcessString(XML_REFERENCE_FORMAT,
1613
0
                      MapReferenceType(GetInt16Property(
1614
0
                          gsPropertyReferenceFieldPart, rPropSet)),
1615
0
                      XML_TEMPLATE);
1616
0
        ProcessString(XML_REF_NAME,
1617
0
                      MakeSequenceRefName(
1618
0
                          GetInt16Property(gsPropertySequenceNumber, rPropSet),
1619
0
                          GetStringProperty(gsPropertySourceName, rPropSet) ) );
1620
0
        if (xPropSetInfo->hasPropertyByName(gsPropertyReferenceFieldLanguage) &&
1621
0
            GetExport().getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
1622
0
        {
1623
            // export text:reference-language attribute, if not empty
1624
0
            ProcessString(XML_REFERENCE_LANGUAGE,
1625
0
                    GetStringProperty(gsPropertyReferenceFieldLanguage, rPropSet), true, XML_NAMESPACE_LO_EXT);
1626
0
        }
1627
0
        ExportElement(
1628
0
            MapReferenceSource(
1629
0
                GetInt16Property(gsPropertyReferenceFieldSource, rPropSet)),
1630
0
            sPresentation);
1631
0
        break;
1632
1633
0
    case FIELD_ID_REF_REFERENCE:
1634
0
    case FIELD_ID_REF_BOOKMARK:
1635
        // reference to bookmarks, references: format, name (and element)
1636
0
        ProcessString(XML_REFERENCE_FORMAT,
1637
0
                      MapReferenceType(GetInt16Property(
1638
0
                          gsPropertyReferenceFieldPart, rPropSet)),
1639
0
                      XML_TEMPLATE);
1640
0
        ProcessString(XML_REF_NAME,
1641
0
                      GetStringProperty(gsPropertySourceName, rPropSet));
1642
0
        if (xPropSetInfo->hasPropertyByName(gsPropertyReferenceFieldLanguage) &&
1643
0
            GetExport().getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
1644
0
        {
1645
            // export text:reference-language attribute, if not empty
1646
0
            ProcessString(XML_REFERENCE_LANGUAGE,
1647
0
                      GetStringProperty(gsPropertyReferenceFieldLanguage, rPropSet), true, XML_NAMESPACE_LO_EXT);
1648
0
        }
1649
0
        ExportElement(
1650
0
            MapReferenceSource(GetInt16Property(
1651
0
                gsPropertyReferenceFieldSource, rPropSet)),
1652
0
            sPresentation);
1653
0
        break;
1654
1655
0
    case FIELD_ID_REF_FOOTNOTE:
1656
0
    case FIELD_ID_REF_ENDNOTE:
1657
        // reference to end-/footnote: format, generate name, (and element)
1658
0
        GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_NOTE_CLASS,
1659
0
            FIELD_ID_REF_ENDNOTE==nToken ? XML_ENDNOTE : XML_FOOTNOTE );
1660
0
        ProcessString(XML_REFERENCE_FORMAT,
1661
0
                      MapReferenceType(GetInt16Property(
1662
0
                          gsPropertyReferenceFieldPart, rPropSet)),
1663
0
                      XML_TEMPLATE);
1664
0
        ProcessString(XML_REF_NAME,
1665
0
                      MakeFootnoteRefName(GetInt16Property(
1666
0
                          gsPropertySequenceNumber, rPropSet)));
1667
0
        if (xPropSetInfo->hasPropertyByName(gsPropertyReferenceFieldLanguage) &&
1668
0
            GetExport().getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
1669
0
        {
1670
            // export text:reference-language attribute, if not empty
1671
0
            ProcessString(XML_REFERENCE_LANGUAGE,
1672
0
                      GetStringProperty(gsPropertyReferenceFieldLanguage, rPropSet), true, XML_NAMESPACE_LO_EXT);
1673
0
        }
1674
0
        ExportElement(
1675
0
            MapReferenceSource(GetInt16Property(
1676
0
                gsPropertyReferenceFieldSource, rPropSet)),
1677
0
            sPresentation);
1678
0
        break;
1679
1680
0
    case FIELD_ID_REF_STYLE:
1681
0
    {
1682
0
        ProcessString(XML_REFERENCE_FORMAT,
1683
0
                      MapReferenceType(GetInt16Property(gsPropertyReferenceFieldPart, rPropSet)),
1684
0
                      XML_TEMPLATE);
1685
0
        ProcessString(XML_REF_NAME, GetStringProperty(gsPropertySourceName, rPropSet));
1686
1687
0
        sal_uInt16 referenceFieldFlags = GetIntProperty(gsPropertyReferenceFieldFlags, rPropSet);
1688
        // In reality gsPropertyReferenceFieldFlags is a uInt16... but there is no GetUInt16Property
1689
1690
0
        bool fromBottom = (referenceFieldFlags & REFFLDFLAG_STYLE_FROM_BOTTOM) == REFFLDFLAG_STYLE_FROM_BOTTOM;
1691
0
        bool hideNonNumerical = (referenceFieldFlags & REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL) == REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL;
1692
1693
0
        ProcessBoolean(XML_REFERENCE_FROM_BOTTOM, fromBottom,  false, XML_NAMESPACE_LO_EXT);
1694
0
        ProcessBoolean(XML_REFERENCE_HIDE_NON_NUMERICAL, hideNonNumerical,  false, XML_NAMESPACE_LO_EXT);
1695
1696
0
        if (xPropSetInfo->hasPropertyByName(gsPropertyReferenceFieldLanguage)
1697
0
            && GetExport().getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
1698
0
        {
1699
            // export text:reference-language attribute, if not empty
1700
0
            ProcessString(XML_REFERENCE_LANGUAGE,
1701
0
                          GetStringProperty(gsPropertyReferenceFieldLanguage, rPropSet), true,
1702
0
                          XML_NAMESPACE_LO_EXT);
1703
0
        }
1704
0
        SvXMLElementExport aElem(
1705
0
            GetExport(),
1706
0
            XML_NAMESPACE_LO_EXT,
1707
0
            MapReferenceSource(GetInt16Property(gsPropertyReferenceFieldSource, rPropSet)),
1708
0
            false,
1709
0
            false);
1710
0
        GetExport().Characters(sPresentation);
1711
0
        break;
1712
0
    }
1713
1714
0
    case FIELD_ID_DDE:
1715
        // name from field master
1716
0
         ProcessString(XML_CONNECTION_NAME,
1717
1718
0
                       GetStringProperty(gsPropertyName,
1719
0
                                         GetMasterPropertySet(rTextField)));
1720
0
        ExportElement(XML_DDE_CONNECTION, sPresentation);
1721
0
        break;
1722
1723
0
    case FIELD_ID_SHEET_NAME:
1724
        // name of spreadsheet (Calc only)
1725
0
        ExportElement(XML_SHEET_NAME, sPresentation);
1726
0
        break;
1727
1728
0
    case FIELD_ID_PAGENAME:
1729
0
    {
1730
0
        if (GetExport().getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
1731
0
        {
1732
0
            SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_LO_EXT, XML_PAGE_NAME, false, false );
1733
0
            GetExport().Characters( sPresentation );
1734
0
        }
1735
0
        break;
1736
0
    }
1737
1738
0
    case FIELD_ID_URL:
1739
0
    {
1740
        // this field is a special case because it gets mapped onto a
1741
        // hyperlink, rather than one of the regular text field.
1742
0
        ProcessString(XML_HREF, GetExport().GetRelativeReference(GetStringProperty(gsPropertyURL, rPropSet)),
1743
0
                      false, XML_NAMESPACE_XLINK);
1744
0
        ProcessString(XML_TARGET_FRAME_NAME,
1745
0
                      GetStringProperty(gsPropertyTargetFrame,rPropSet),
1746
0
                      true, XML_NAMESPACE_OFFICE);
1747
0
        GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1748
0
        SvXMLElementExport aUrlField(rExport, XML_NAMESPACE_TEXT, XML_A,
1749
0
                                     false, false);
1750
0
        GetExport().Characters(sPresentation);
1751
0
        break;
1752
0
    }
1753
1754
0
    case FIELD_ID_BIBLIOGRAPHY:
1755
0
    {
1756
0
        ProcessBibliographyData(rPropSet);
1757
0
        ExportElement(XML_BIBLIOGRAPHY_MARK, sPresentation);
1758
0
        break;
1759
0
    }
1760
1761
0
    case FIELD_ID_SCRIPT:
1762
0
        ProcessString(XML_LANGUAGE,
1763
0
                      GetStringProperty(gsPropertyScriptType, rPropSet),
1764
0
                      true, XML_NAMESPACE_SCRIPT);
1765
0
        DBG_ASSERT(sPresentation.isEmpty(),
1766
0
                   "Unexpected presentation for script field");
1767
0
        if (GetBoolProperty(gsPropertyURLContent, rPropSet))
1768
0
        {
1769
0
            ProcessString(XML_HREF,
1770
0
                          GetExport().GetRelativeReference(GetStringProperty(gsPropertyContent, rPropSet)),
1771
0
                          false, XML_NAMESPACE_XLINK);
1772
0
            ExportElement(XML_SCRIPT);
1773
0
        }
1774
0
        else
1775
0
        {
1776
0
            ExportElement(XML_SCRIPT,
1777
0
                          GetStringProperty(gsPropertyContent, rPropSet));
1778
0
        }
1779
0
        break;
1780
1781
0
    case FIELD_ID_ANNOTATION:
1782
0
    {
1783
        // check for empty presentation (just in case)
1784
0
        DBG_ASSERT(sPresentation.isEmpty(),
1785
0
                   "Unexpected presentation for annotation field");
1786
1787
0
        bool bRemovePersonalInfo = SvtSecurityOptions::IsOptionSet(
1788
0
            SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo ) && !SvtSecurityOptions::IsOptionSet(
1789
0
                SvtSecurityOptions::EOption::DocWarnKeepNoteAuthorDateInfo);
1790
1791
        // annotation element + content
1792
0
        OUString aName;
1793
0
        rPropSet->getPropertyValue(gsPropertyName) >>= aName;
1794
0
        if (!aName.isEmpty())
1795
0
        {
1796
0
            GetExport().AddAttribute(XML_NAMESPACE_OFFICE, XML_NAME, aName);
1797
0
        }
1798
1799
0
        OUString aParentName;
1800
0
        rPropSet->getPropertyValue(gsPropertyParentName) >>= aParentName;
1801
0
        if (!aParentName.isEmpty())
1802
0
        {
1803
0
            GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_PARENT_NAME, aParentName);
1804
0
        }
1805
1806
0
        SvtSaveOptions::ODFSaneDefaultVersion eVersion = rExport.getSaneDefaultVersion();
1807
0
        if (eVersion & SvtSaveOptions::ODFSVER_EXTENDED)
1808
0
        {
1809
0
            bool b = GetBoolProperty(u"Resolved"_ustr, rPropSet);
1810
0
            OUString aResolvedText;
1811
0
            OUStringBuffer aResolvedTextBuffer;
1812
0
            ::sax::Converter::convertBool(aResolvedTextBuffer, b);
1813
0
            aResolvedText = aResolvedTextBuffer.makeStringAndClear();
1814
1815
0
            GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_RESOLVED, aResolvedText);
1816
0
        }
1817
0
        SvXMLElementExport aElem(GetExport(), XML_NAMESPACE_OFFICE,
1818
0
                                 XML_ANNOTATION, false, true);
1819
1820
        // author
1821
0
        OUString aAuthor( GetStringProperty(gsPropertyAuthor, rPropSet) );
1822
0
        if( !aAuthor.isEmpty() )
1823
0
        {
1824
0
            SvXMLElementExport aCreatorElem( GetExport(), XML_NAMESPACE_DC,
1825
0
                                              XML_CREATOR, true,
1826
0
                                              false );
1827
0
            GetExport().Characters( bRemovePersonalInfo
1828
0
                    ? "Author" + OUString::number( rExport.GetInfoID(aAuthor) )
1829
0
                    : aAuthor );
1830
0
        }
1831
1832
        // date time
1833
0
        util::DateTime aDate( GetDateTimeProperty(gsPropertyDateTimeValue, rPropSet) );
1834
0
        if ( !bRemovePersonalInfo )
1835
0
        {
1836
0
            OUStringBuffer aBuffer;
1837
0
            ::sax::Converter::convertDateTime(aBuffer, aDate, nullptr, true);
1838
0
            SvXMLElementExport aDateElem( GetExport(), XML_NAMESPACE_DC,
1839
0
                                              XML_DATE, true,
1840
0
                                              false );
1841
0
            GetExport().Characters(aBuffer.makeStringAndClear());
1842
0
        }
1843
1844
0
        if (GetExport().getSaneDefaultVersion() > SvtSaveOptions::ODFSVER_012)
1845
0
        {
1846
            // initials
1847
0
            OUString aInitials( GetStringProperty(gsPropertyInitials, rPropSet) );
1848
0
            if( !aInitials.isEmpty() )
1849
0
            {
1850
                // ODF 1.3 OFFICE-3776 export meta:creator-initials for ODF 1.3
1851
0
                SvXMLElementExport aCreatorElem( GetExport(),
1852
0
                        (SvtSaveOptions::ODFSVER_013 <= GetExport().getSaneDefaultVersion())
1853
0
                            ? XML_NAMESPACE_META
1854
0
                            : XML_NAMESPACE_LO_EXT,
1855
1856
0
                        (SvtSaveOptions::ODFSVER_013 <= GetExport().getSaneDefaultVersion())
1857
0
                            ? XML_CREATOR_INITIALS
1858
0
                            : XML_SENDER_INITIALS,
1859
0
                        true, false );
1860
0
                GetExport().Characters( bRemovePersonalInfo
1861
0
                        ? OUString::number( rExport.GetInfoID(aInitials) )
1862
0
                        : aInitials);
1863
0
            }
1864
0
        }
1865
1866
0
        if (auto xText = XTextFromTextRangeProp(rPropSet))
1867
0
            GetExport().GetTextParagraphExport()->exportText( xText );
1868
0
        else
1869
0
            ProcessParagraphSequence(GetStringProperty(gsPropertyContent,rPropSet));
1870
0
        break;
1871
0
    }
1872
1873
0
    case FIELD_ID_COMBINED_CHARACTERS:
1874
0
    {
1875
        // The style with the combined characters attribute has
1876
        // already been handled in the ExportField method. So all that
1877
        // is left to do now is to export the characters.
1878
0
        GetExport().Characters(sPresentation);
1879
0
        break;
1880
0
    }
1881
1882
0
    case FIELD_ID_META:
1883
0
    {
1884
0
        ExportMetaField(rPropSet, false, bProgress, rPrevCharIsSpace);
1885
0
        break;
1886
0
    }
1887
1888
0
    case FIELD_ID_MEASURE:
1889
0
    {
1890
0
        ProcessString(XML_KIND, MapMeasureKind(GetInt16Property(gsPropertyMeasureKind, rPropSet)));
1891
0
        ExportElement( XML_MEASURE, sPresentation );
1892
0
        break;
1893
0
    }
1894
1895
0
    case FIELD_ID_TABLE_FORMULA:
1896
0
        ProcessString( XML_FORMULA,  XML_NAMESPACE_OOOW,
1897
0
                       GetStringProperty(gsPropertyContent, rPropSet) );
1898
0
        ProcessDisplay( true,
1899
0
                        GetBoolProperty(gsPropertyIsShowFormula, rPropSet) );
1900
0
        ProcessValueAndType( false,
1901
0
                             GetIntProperty(gsPropertyNumberFormat, rPropSet),
1902
0
                             u""_ustr, u"", 0.0f,
1903
0
                             false, false, true,
1904
0
                             false );
1905
0
        ExportElement( XML_TABLE_FORMULA, sPresentation );
1906
0
        break;
1907
1908
0
    case FIELD_ID_DROP_DOWN:
1909
0
    {
1910
        // tdf#133555 don't export in strict ODF versions that don't have it
1911
0
        if (GetExport().getSaneDefaultVersion() <= SvtSaveOptions::ODFSVER_012)
1912
0
        {
1913
0
            break;
1914
0
        }
1915
0
        ProcessString(XML_NAME, GetStringProperty(gsPropertyName, rPropSet));
1916
0
        ProcessString(XML_HELP,
1917
0
                      GetStringProperty(gsPropertyHelp, rPropSet), true);
1918
0
        ProcessString(XML_HINT,
1919
0
                      GetStringProperty(gsPropertyTooltip, rPropSet), true);
1920
0
        SvXMLElementExport aElem( GetExport(),
1921
0
                                  XML_NAMESPACE_TEXT, XML_DROP_DOWN,
1922
0
                                  false, false );
1923
0
        ProcessStringSequence
1924
0
            (GetStringSequenceProperty( gsPropertyItems, rPropSet ),
1925
0
             GetStringProperty( gsPropertySelectedItem, rPropSet ) );
1926
1927
0
        GetExport().Characters( sPresentation );
1928
0
    }
1929
0
    break;
1930
1931
0
    case FIELD_ID_DRAW_HEADER:
1932
0
    {
1933
0
        SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_PRESENTATION, XML_HEADER, false, false );
1934
0
    }
1935
0
    break;
1936
1937
0
    case FIELD_ID_DRAW_FOOTER:
1938
0
    {
1939
0
        SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_PRESENTATION, XML_FOOTER, false, false );
1940
0
    }
1941
0
    break;
1942
1943
0
    case FIELD_ID_DRAW_DATE_TIME:
1944
0
    {
1945
0
        SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_PRESENTATION, XML_DATE_TIME, false, false );
1946
0
    }
1947
0
    break;
1948
1949
1950
0
    case FIELD_ID_UNKNOWN:
1951
0
    default:
1952
0
        OSL_FAIL("unknown field type encountered!");
1953
        // always export content
1954
0
        GetExport().Characters(sPresentation);
1955
0
    }
1956
0
}
1957
1958
1959
/// export field declarations / field masters
1960
void XMLTextFieldExport::ExportFieldDeclarations()
1961
0
{
1962
0
    Reference<XText> xEmptyText;
1963
0
    ExportFieldDeclarations(xEmptyText);
1964
0
}
1965
1966
/// export field declarations / field masters
1967
void XMLTextFieldExport::ExportFieldDeclarations(
1968
    const Reference<XText> & rText )
1969
0
{
1970
    // store lists for decl elements
1971
0
    std::vector<OUString>                    aVarName;
1972
0
    std::vector<OUString>                    aUserName;
1973
0
    std::vector<OUString>                    aSeqName;
1974
0
    std::vector<OUString>                    aDdeName;
1975
1976
    // get text fields supplier and field master name access
1977
0
    Reference<XTextFieldsSupplier> xTextFieldsSupp(GetExport().GetModel(),
1978
0
                                                   UNO_QUERY);
1979
0
    if( !xTextFieldsSupp.is() )
1980
0
        return;
1981
1982
0
    Reference<container::XNameAccess> xFieldMasterNameAccess =
1983
0
        xTextFieldsSupp->getTextFieldMasters();
1984
1985
    // where to get the text field masters from?
1986
    // a) we get a specific XText: then use pUsedMasters
1987
    // b) the XText is empty: then export all text fields
1988
0
    Sequence<OUString> aFieldMasters;
1989
0
    if (rText.is())
1990
0
    {
1991
        // export only used masters
1992
0
        DBG_ASSERT(moUsedMasters.has_value(),
1993
0
                   "field masters must be recorded in order to be "
1994
0
                   "written out separately" );
1995
0
        if (moUsedMasters)
1996
0
        {
1997
0
            std::map<Reference<XText>, std::set<OUString> > ::iterator aMapIter =
1998
0
                moUsedMasters->find(rText);
1999
0
            if (aMapIter != moUsedMasters->end())
2000
0
            {
2001
                // found the set of used field masters
2002
0
                aFieldMasters = comphelper::containerToSequence(aMapIter->second);
2003
0
                moUsedMasters->erase(rText);
2004
0
            }
2005
            // else: XText not found -> ignore
2006
0
        }
2007
        // else: no field masters have been recorded -> ignore
2008
0
    }
2009
0
    else
2010
0
    {
2011
        // no XText: export all!
2012
0
        aFieldMasters = xFieldMasterNameAccess->getElementNames();
2013
0
    }
2014
2015
0
    for(const OUString& sFieldMaster : aFieldMasters) {
2016
2017
        // workaround for #no-bug#
2018
0
        if ( sFieldMaster.startsWithIgnoreAsciiCase(
2019
0
                 "com.sun.star.text.FieldMaster.DataBase.") )
2020
0
        {
2021
0
            continue;
2022
0
        }
2023
2024
2025
0
        OUString sFieldMasterType;
2026
0
        OUString sVarName;
2027
0
        ExplodeFieldMasterName(sFieldMaster, sFieldMasterType, sVarName);
2028
2029
        // get XPropertySet of this field master
2030
0
        Reference<XPropertySet> xPropSet;
2031
0
        Any aAny = xFieldMasterNameAccess->getByName(sFieldMaster);
2032
0
        aAny >>= xPropSet;
2033
2034
        // save interesting field masters
2035
0
        if (sFieldMasterType == FIELD_SERVICE_SETEXP)
2036
0
        {
2037
0
            sal_Int32 nType = GetIntProperty(gsPropertySubType, xPropSet);
2038
2039
            // sequence or variable?
2040
0
            if ( SetVariableType::SEQUENCE == nType )
2041
0
            {
2042
0
                aSeqName.push_back( sFieldMaster );
2043
0
            }
2044
0
            else
2045
0
            {
2046
0
                aVarName.push_back( sFieldMaster );
2047
0
            }
2048
0
        }
2049
0
        else if (sFieldMasterType == FIELD_SERVICE_USER)
2050
0
        {
2051
0
            aUserName.push_back( sFieldMaster );
2052
0
        }
2053
0
        else if (sFieldMasterType == FIELD_SERVICE_DDE)
2054
0
        {
2055
0
            aDdeName.push_back( sFieldMaster );
2056
0
        }
2057
0
        else
2058
0
        {
2059
0
            ; // ignore
2060
0
        }
2061
0
    }
2062
2063
    // now process fields:
2064
2065
    // variable field masters:
2066
0
    if ( !aVarName.empty() )
2067
0
    {
2068
0
        SvXMLElementExport aElem( GetExport(),
2069
0
                                  XML_NAMESPACE_TEXT,
2070
0
                                  XML_VARIABLE_DECLS,
2071
0
                                  true, true );
2072
2073
0
        for (const auto& sName : aVarName)
2074
0
        {
2075
            // get field master property set
2076
0
            Reference<XPropertySet> xPropSet;
2077
0
            Any aAny = xFieldMasterNameAccess->getByName(sName);
2078
0
            aAny >>= xPropSet;
2079
2080
            // field name and type
2081
0
            OUString sFieldMasterType;
2082
0
            OUString sVarName;
2083
0
            ExplodeFieldMasterName(sName, sFieldMasterType, sVarName);
2084
2085
            // determine string/numeric field
2086
0
            bool bIsString = ( GetIntProperty(gsPropertySubType, xPropSet)
2087
0
                                   == SetVariableType::STRING );
2088
2089
            // get dependent field property set
2090
0
            Reference<XPropertySet> xFieldPropSet;
2091
0
            if (GetDependentFieldPropertySet(xPropSet, xFieldPropSet))
2092
0
            {
2093
                // process value and type.
2094
0
                ProcessValueAndType(
2095
0
                    bIsString,
2096
0
                    GetIntProperty(gsPropertyNumberFormat, xFieldPropSet),
2097
0
                    u""_ustr, u"", 0.0,
2098
0
                    false, true, false, false);
2099
0
            }
2100
0
            else
2101
0
            {
2102
                // If no dependent field is found, only string and
2103
                // float types can be supported
2104
2105
                // number format: 0 is default number format for 1st
2106
                // language. should be: getDefaultNumberFormat(Locale)
2107
                // from NumberFormats
2108
0
                ProcessValueAndType(
2109
0
                    bIsString,
2110
0
                    0, u""_ustr, u"", 0.0,
2111
0
                    false, true, false, false);
2112
0
            }
2113
2114
0
            ProcessString(XML_NAME, sVarName);
2115
0
            ExportElement(XML_VARIABLE_DECL, true);
2116
0
        }
2117
0
    }
2118
    // else: no declarations element
2119
2120
    // sequence field masters:
2121
0
    if ( !aSeqName.empty() )
2122
0
    {
2123
0
        SvXMLElementExport aElem( GetExport(),
2124
0
                                  XML_NAMESPACE_TEXT,
2125
0
                                  XML_SEQUENCE_DECLS,
2126
0
                                  true, true );
2127
2128
0
        for (const auto& sName : aSeqName)
2129
0
        {
2130
            // get field master property set
2131
0
            Reference<XPropertySet> xPropSet;
2132
0
            Any aAny = xFieldMasterNameAccess->getByName(sName);
2133
0
            aAny >>= xPropSet;
2134
2135
            // field name and type
2136
0
            OUString sFieldMasterType;
2137
0
            OUString sVarName;
2138
0
            ExplodeFieldMasterName(sName, sFieldMasterType, sVarName);
2139
2140
            // outline level
2141
0
            sal_Int32 nLevel = 1 + GetIntProperty(
2142
0
                gsPropertyChapterNumberingLevel, xPropSet);
2143
0
            DBG_ASSERT(nLevel >= 0, "illegal outline level");
2144
0
            DBG_ASSERT(nLevel < 127, "possible illegal outline level");
2145
0
            ProcessInteger(XML_DISPLAY_OUTLINE_LEVEL, nLevel);
2146
2147
            // separation character
2148
0
            if (nLevel > 0) {
2149
0
                ProcessString(XML_SEPARATION_CHARACTER, GetStringProperty(
2150
0
                    gsPropertyNumberingSeparator, xPropSet));
2151
0
            }
2152
0
            ProcessString(XML_NAME, sVarName);
2153
0
            ExportElement(XML_SEQUENCE_DECL, true);
2154
0
        }
2155
0
    }
2156
    // else: no declarations element
2157
2158
    // user field masters:
2159
0
    if ( !aUserName.empty() )
2160
0
    {
2161
0
        SvXMLElementExport aElem( GetExport(),
2162
0
                                  XML_NAMESPACE_TEXT,
2163
0
                                  XML_USER_FIELD_DECLS,
2164
0
                                  true, true );
2165
2166
0
        for (const auto& sName : aUserName)
2167
0
        {
2168
            // get field master property set
2169
0
            Reference<XPropertySet> xPropSet;
2170
0
            Any aAny = xFieldMasterNameAccess->getByName(sName);
2171
0
            aAny >>= xPropSet;
2172
2173
            // field name and type
2174
0
            OUString sFieldMasterType;
2175
0
            OUString sVarName;
2176
0
            ExplodeFieldMasterName(sName, sFieldMasterType, sVarName);
2177
2178
0
            if (GetBoolProperty(gsPropertyIsExpression, xPropSet))
2179
0
            {
2180
                // expression:
2181
0
                ProcessValueAndType(
2182
0
                    false,
2183
0
                    0, u""_ustr, u"",
2184
0
                    GetDoubleProperty(gsPropertyValue, xPropSet),
2185
0
                    true,
2186
0
                    true,
2187
0
                    false,
2188
0
                    false);
2189
0
            }
2190
0
            else
2191
0
            {
2192
                // string: write regardless of default
2193
0
                ProcessString(XML_VALUE_TYPE, XML_STRING,
2194
0
                              XML_NAMESPACE_OFFICE);
2195
0
                ProcessString(XML_STRING_VALUE,
2196
0
                              GetStringProperty(gsPropertyContent, xPropSet),
2197
0
                              false, XML_NAMESPACE_OFFICE );
2198
0
            }
2199
0
            ProcessString(XML_NAME, sVarName);
2200
0
            ExportElement(XML_USER_FIELD_DECL, true);
2201
0
        }
2202
0
    }
2203
    // else: no declarations element
2204
2205
    // DDE field masters:
2206
0
    if ( aDdeName.empty() )
2207
0
        return;
2208
2209
0
    SvXMLElementExport aElem( GetExport(),
2210
0
                              XML_NAMESPACE_TEXT,
2211
0
                              XML_DDE_CONNECTION_DECLS,
2212
0
                              true, true );
2213
2214
0
    for (const auto& sName : aDdeName)
2215
0
    {
2216
        // get field master property set
2217
0
        Reference<XPropertySet> xPropSet;
2218
0
        Any aAny = xFieldMasterNameAccess->getByName(sName);
2219
0
        aAny >>= xPropSet;
2220
2221
        // check if this connection is being used by a field
2222
0
        Reference<XPropertySet> xDummy;
2223
0
        if (GetDependentFieldPropertySet(xPropSet, xDummy))
2224
0
        {
2225
2226
0
            ProcessString(XML_NAME,
2227
0
                          GetStringProperty(gsPropertyName, xPropSet),
2228
0
                          false, XML_NAMESPACE_OFFICE);
2229
2230
            // export elements; can't use ProcessString because
2231
            // elements are in office namespace
2232
0
            ProcessString(XML_DDE_APPLICATION,
2233
0
                          GetStringProperty(gsPropertyDDECommandType,
2234
0
                                            xPropSet),
2235
0
                          false, XML_NAMESPACE_OFFICE);
2236
0
            ProcessString(XML_DDE_TOPIC,
2237
0
                          GetStringProperty(gsPropertyDDECommandFile,
2238
0
                                            xPropSet),
2239
0
                          false, XML_NAMESPACE_OFFICE);
2240
0
            ProcessString(XML_DDE_ITEM,
2241
0
                          GetStringProperty(gsPropertyDDECommandElement,
2242
0
                                            xPropSet),
2243
0
                          false, XML_NAMESPACE_OFFICE);
2244
0
            bool bIsAutomaticUpdate = GetBoolProperty(
2245
0
                gsPropertyIsAutomaticUpdate, xPropSet);
2246
0
            if (bIsAutomaticUpdate)
2247
0
            {
2248
0
                GetExport().AddAttribute(XML_NAMESPACE_OFFICE,
2249
0
                                         XML_AUTOMATIC_UPDATE,
2250
0
                                         XML_TRUE);
2251
0
            }
2252
2253
0
            ExportElement(XML_DDE_CONNECTION_DECL, true);
2254
0
        }
2255
        // else: no dependent field -> no export of field declaration
2256
0
    }
2257
    // else: no declarations element
2258
0
}
2259
2260
void XMLTextFieldExport::SetExportOnlyUsedFieldDeclarations(
2261
    bool bExportOnlyUsed)
2262
3
{
2263
3
    moUsedMasters.reset();
2264
2265
    // create used masters set (if none is used)
2266
3
    if (bExportOnlyUsed)
2267
#if defined __GNUC__ && !defined __clang__ && __GNUC__ >= 14 && __GNUC__ <= 16
2268
#pragma GCC diagnostic push
2269
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
2270
#endif
2271
3
        moUsedMasters.emplace();
2272
#if defined __GNUC__ && !defined __clang__ && __GNUC__ >= 14 && __GNUC__ <= 16
2273
#pragma GCC diagnostic pop
2274
#endif
2275
3
}
2276
2277
void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName,
2278
                                       bool bAddSpace)
2279
0
{
2280
    // can't call ExportElement(eElementName, const OUString&) with empty
2281
    // string because xmlprinter only uses empty tags if no content
2282
    // (not even empty content) was written.
2283
2284
0
    DBG_ASSERT(XML_TOKEN_INVALID != eElementName, "invalid element name!");
2285
0
    if (XML_TOKEN_INVALID != eElementName)
2286
0
    {
2287
        // Element
2288
0
        SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
2289
0
                                  eElementName, bAddSpace, bAddSpace );
2290
0
    } // else: ignore
2291
0
}
2292
2293
void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName,
2294
                                       const OUString& sContent,
2295
                                       sal_uInt16 nNamespace)
2296
0
{
2297
0
    DBG_ASSERT(eElementName != XML_TOKEN_INVALID, "invalid element name!");
2298
0
    if (eElementName != XML_TOKEN_INVALID)
2299
0
    {
2300
        // Element
2301
0
        SvXMLElementExport aElem( GetExport(), nNamespace,
2302
0
                eElementName, false, false );
2303
        // export content
2304
0
        GetExport().Characters(sContent);
2305
0
    } else {
2306
        // always export content
2307
0
        GetExport().Characters(sContent);
2308
0
    }
2309
0
}
2310
2311
void XMLTextFieldExport::ExportMacro(
2312
    const Reference<XPropertySet> & rPropSet,
2313
    const OUString& rContent )
2314
0
{
2315
    // some strings we'll need
2316
0
    OUString sEventType( u"EventType"_ustr );
2317
2318
2319
    // the description attribute
2320
0
    ProcessString(XML_DESCRIPTION,
2321
0
                  GetStringProperty(gsPropertyHint, rPropSet),
2322
0
                  rContent);
2323
2324
    // the element
2325
0
    SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
2326
0
                              XML_EXECUTE_MACRO, false, false );
2327
2328
    // the <office:events>-macro:
2329
2330
    // 1) build sequence of PropertyValues
2331
0
    Sequence<PropertyValue> aSeq;
2332
0
    OUString sName;
2333
0
    rPropSet->getPropertyValue(u"ScriptURL"_ustr) >>= sName;
2334
2335
    // if the ScriptURL property is not empty then this is a Scripting
2336
    // Framework URL, otherwise treat it as a Basic Macro
2337
0
    if (!sName.isEmpty())
2338
0
    {
2339
0
        OUString sScript( u"Script"_ustr );
2340
0
        aSeq = Sequence<PropertyValue>
2341
0
        {
2342
0
            comphelper::makePropertyValue(sEventType, sScript),
2343
0
            comphelper::makePropertyValue(sScript, sName)
2344
0
        };
2345
0
    }
2346
0
    else
2347
0
    {
2348
0
        aSeq = Sequence<PropertyValue>
2349
0
        {
2350
0
            comphelper::makePropertyValue(sEventType, u"StarBasic"_ustr),
2351
0
            comphelper::makePropertyValue(u"Library"_ustr, rPropSet->getPropertyValue( u"MacroLibrary"_ustr )),
2352
0
            comphelper::makePropertyValue(u"MacroName"_ustr, rPropSet->getPropertyValue( u"MacroName"_ustr ))
2353
0
        };
2354
0
    }
2355
2356
    // 2) export the sequence
2357
0
    GetExport().GetEventExport().ExportSingleEvent( aSeq, u"OnClick"_ustr, false );
2358
2359
    // and finally, the field presentation
2360
0
    GetExport().Characters(rContent);
2361
0
}
2362
2363
void XMLTextFieldExport::ExportMetaField(
2364
    const Reference<XPropertySet> & i_xMeta,
2365
    bool i_bAutoStyles, bool i_bProgress,
2366
    bool & rPrevCharIsSpace)
2367
0
{
2368
0
    bool doExport(!i_bAutoStyles); // do not export element if autostyles
2369
    // check version >= 1.2
2370
0
    switch (GetExport().getSaneDefaultVersion()) {
2371
0
        case SvtSaveOptions::ODFSVER_011: // fall through
2372
0
        case SvtSaveOptions::ODFSVER_010: doExport = false; break;
2373
0
        default: break;
2374
0
    }
2375
2376
0
    const Reference < XEnumerationAccess > xEA( i_xMeta, UNO_QUERY_THROW );
2377
0
    const Reference < XEnumeration > xTextEnum( xEA->createEnumeration() );
2378
2379
0
    if (doExport)
2380
0
    {
2381
0
        const Reference<rdf::XMetadatable> xMeta( i_xMeta, UNO_QUERY_THROW );
2382
2383
        // style:data-style-name
2384
0
        ProcessValueAndType(false,
2385
0
            GetIntProperty(gsPropertyNumberFormat, i_xMeta),
2386
0
            u""_ustr, u"", 0.0, false, false, true,
2387
0
            false  );
2388
2389
        // text:meta-field without xml:id is invalid
2390
0
        xMeta->ensureMetadataReference();
2391
2392
        // xml:id for RDF metadata
2393
0
        GetExport().AddAttributeXmlId(xMeta);
2394
0
    }
2395
2396
0
    SvXMLElementExport aElem( GetExport(), doExport,
2397
0
        XML_NAMESPACE_TEXT, XML_META_FIELD, false, false );
2398
2399
    // recurse to export content
2400
0
    GetExport().GetTextParagraphExport()->
2401
0
        exportTextRangeEnumeration(xTextEnum, i_bAutoStyles, i_bProgress, rPrevCharIsSpace);
2402
0
}
2403
2404
/// export all data-style related attributes
2405
void XMLTextFieldExport::ProcessValueAndType(
2406
    bool bIsString,     /// do we process a string or a number?
2407
    sal_Int32 nFormatKey,   /// format key for NumberFormatter; inv. if string
2408
    const OUString& sContent,   /// string content; possibly invalid
2409
    std::u16string_view sDefault, /// default string
2410
    double fValue,          /// float content; possibly invalid
2411
    bool bExportValue,  /// export value attribute?
2412
    bool bExportValueType,  /// export value-type attribute?
2413
    bool bExportStyle,  /// export style-attribute?
2414
    bool bForceSystemLanguage, /// export language attributes?
2415
    bool bTimeStyle)    // exporting a time style?
2416
0
{
2417
    // String or number?
2418
0
    if (bIsString)
2419
0
    {
2420
2421
        // string: attributes value-type=string, string-value=...
2422
2423
0
        if (bExportValue || bExportValueType)
2424
0
        {
2425
0
            XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes(
2426
0
                GetExport(), sContent, sDefault, bExportValue);
2427
0
        }
2428
2429
0
    }
2430
0
    else
2431
0
    {
2432
2433
        // number: value-type=..., value...=..., data-style-name=...
2434
2435
0
        DBG_ASSERT(bExportValueType || !bExportValue, "value w/o value type not supported!");
2436
2437
        // take care of illegal formats
2438
        // (shouldn't happen, but does if document is corrupted)
2439
0
        if (-1 != nFormatKey)
2440
0
        {
2441
0
            if (bExportValue || bExportValueType)
2442
0
            {
2443
0
                XMLNumberFormatAttributesExportHelper::
2444
0
                    SetNumberFormatAttributes(
2445
0
                        GetExport(), nFormatKey, fValue, bExportValue);
2446
0
            }
2447
2448
0
            if (bExportStyle)
2449
0
            {
2450
                // don't export language (if desired)
2451
0
                if( bForceSystemLanguage )
2452
0
                    nFormatKey =
2453
0
                        GetExport().dataStyleForceSystemLanguage( nFormatKey );
2454
2455
0
                OUString sDataStyleName =
2456
0
                    GetExport().getDataStyleName(nFormatKey, bTimeStyle);
2457
0
                if( !sDataStyleName.isEmpty() )
2458
0
                {
2459
0
                    GetExport().AddAttribute( XML_NAMESPACE_STYLE,
2460
0
                                              XML_DATA_STYLE_NAME,
2461
0
                                                sDataStyleName );
2462
0
                } // else: ignore (no valid number format)
2463
0
            }  // else: ignore (no number format)
2464
0
        }
2465
0
    }
2466
0
}
2467
2468
2469
/// process display related properties
2470
void XMLTextFieldExport::ProcessDisplay(bool bIsVisible,
2471
                                        bool bIsCommand)
2472
0
{
2473
0
    enum XMLTokenEnum eValue;
2474
2475
0
    if (bIsVisible)
2476
0
    {
2477
0
        eValue = bIsCommand ? XML_FORMULA : XML_VALUE;
2478
0
    }
2479
0
    else
2480
0
    {
2481
0
        eValue = XML_NONE;
2482
0
    }
2483
2484
    // omit attribute if default
2485
0
    if (eValue != XML_VALUE)
2486
0
    {
2487
0
        GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_DISPLAY, eValue);
2488
0
    }
2489
0
}
2490
2491
2492
void XMLTextFieldExport::ProcessBoolean(enum XMLTokenEnum eName,
2493
                                        bool bBool, bool bDefault)
2494
0
{
2495
0
    ProcessBoolean(eName, bBool, bDefault, XML_NAMESPACE_TEXT);
2496
0
}
2497
2498
/// export boolean property
2499
void XMLTextFieldExport::ProcessBoolean(enum XMLTokenEnum eName,
2500
                                        bool bBool, bool bDefault, sal_uInt16 nPrefix)
2501
0
{
2502
0
    SAL_WARN_IF( eName == XML_TOKEN_INVALID, "xmloff.text", "invalid element token");
2503
0
    if ( XML_TOKEN_INVALID == eName )
2504
0
        return;
2505
2506
    // write attribute (if different than default)
2507
    // negate to force 0/1 values (and make sal_Bool comparable)
2508
0
    if ((!bBool) != (!bDefault)) {
2509
0
        GetExport().AddAttribute(nPrefix, eName,
2510
0
                                 (bBool ? XML_TRUE : XML_FALSE) );
2511
0
    }
2512
0
}
2513
2514
/// export string attribute
2515
void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName,
2516
                                       const OUString& sValue,
2517
                                       bool bOmitEmpty,
2518
                                       sal_uInt16 nPrefix)
2519
0
{
2520
0
    SAL_WARN_IF( eName == XML_TOKEN_INVALID, "xmloff.text", "invalid element token");
2521
0
    if ( XML_TOKEN_INVALID == eName )
2522
0
        return;
2523
2524
    // check for empty string, if applicable
2525
0
    if ( bOmitEmpty && sValue.isEmpty() )
2526
0
        return;
2527
2528
    // write attribute
2529
0
    GetExport().AddAttribute(nPrefix, eName, sValue);
2530
0
}
2531
2532
void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName,
2533
                                       sal_uInt16 nValuePrefix,
2534
                                       const OUString& sValue)
2535
0
{
2536
0
    OUString sQValue =
2537
0
        GetExport().GetNamespaceMap().GetQNameByKey( nValuePrefix, sValue, false );
2538
0
    ProcessString( eName, sQValue );
2539
0
}
2540
2541
/// export a string attribute
2542
void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName,
2543
                                       const OUString& sValue,
2544
                                       std::u16string_view sDefault)
2545
0
{
2546
0
    if (sValue != sDefault)
2547
0
    {
2548
0
        ProcessString(eName, sValue);
2549
0
    }
2550
0
}
2551
2552
/// export a string attribute
2553
void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName,
2554
                                       sal_uInt16 nValuePrefix,
2555
                                       const OUString& sValue,
2556
                                       std::u16string_view sDefault)
2557
0
{
2558
0
    if (sValue != sDefault)
2559
0
    {
2560
0
        ProcessString(eName, nValuePrefix, sValue);
2561
0
    }
2562
0
}
2563
2564
2565
/// export string attribute
2566
void XMLTextFieldExport::ProcessString(
2567
    enum XMLTokenEnum eName,
2568
    enum XMLTokenEnum eValue,
2569
    sal_uInt16 nPrefix)
2570
0
{
2571
0
    SAL_WARN_IF( eName == XML_TOKEN_INVALID, "xmloff.text", "invalid element token" );
2572
0
    SAL_WARN_IF( eValue == XML_TOKEN_INVALID, "xmloff.text", "invalid value token" );
2573
0
    if ( XML_TOKEN_INVALID == eName )
2574
0
        return;
2575
2576
0
    GetExport().AddAttribute(nPrefix, eName, eValue);
2577
0
}
2578
2579
/// export a string attribute
2580
void XMLTextFieldExport::ProcessString(
2581
    enum XMLTokenEnum eName,
2582
    enum XMLTokenEnum eValue,
2583
    enum XMLTokenEnum eDefault)
2584
0
{
2585
0
    if ( eValue != eDefault )
2586
0
        ProcessString( eName, eValue);
2587
0
}
2588
2589
2590
/// export a string as a sequence of paragraphs
2591
void XMLTextFieldExport::ProcessParagraphSequence(
2592
    std::u16string_view sParagraphSequence)
2593
0
{
2594
    // iterate over all string-pieces separated by return (0x0a) and
2595
    // put each inside a paragraph element.
2596
0
    SvXMLTokenEnumerator aEnumerator(sParagraphSequence, char(0x0a));
2597
0
    std::u16string_view aSubString;
2598
0
    while (aEnumerator.getNextToken(aSubString))
2599
0
    {
2600
0
        SvXMLElementExport aParagraph(
2601
0
            GetExport(), XML_NAMESPACE_TEXT, XML_P, true, false);
2602
0
        GetExport().Characters(OUString(aSubString));
2603
0
    }
2604
0
}
2605
2606
// export an integer attribute
2607
void XMLTextFieldExport::ProcessInteger(enum XMLTokenEnum eName,
2608
                                        sal_Int32 nNum)
2609
0
{
2610
0
    SAL_WARN_IF( eName == XML_TOKEN_INVALID, "xmloff.text", "invalid element token");
2611
0
    if ( XML_TOKEN_INVALID == eName )
2612
0
        return;
2613
2614
0
    GetExport().AddAttribute(XML_NAMESPACE_TEXT, eName,
2615
0
                             OUString::number(nNum));
2616
0
}
2617
2618
/// export an integer attribute, omit if default
2619
void XMLTextFieldExport::ProcessIntegerDef(enum XMLTokenEnum eName,
2620
                                        sal_Int32 nNum, sal_Int32 nDefault)
2621
0
{
2622
0
    if (nNum != nDefault)
2623
0
        ProcessInteger(eName, nNum);
2624
0
}
2625
2626
2627
/// export a numbering type
2628
void XMLTextFieldExport::ProcessNumberingType(sal_Int16 nNumberingType)
2629
0
{
2630
    // process only if real format (not: like page descriptor)
2631
0
    if (NumberingType::PAGE_DESCRIPTOR == nNumberingType)
2632
0
        return;
2633
2634
0
    OUStringBuffer sTmp( 10 );
2635
    // number type: num format
2636
0
    GetExport().GetMM100UnitConverter().convertNumFormat( sTmp,
2637
0
                                                          nNumberingType );
2638
0
    GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_FORMAT,
2639
0
                                  sTmp.makeStringAndClear() );
2640
    // and letter sync, if applicable
2641
0
    SvXMLUnitConverter::convertNumLetterSync( sTmp, nNumberingType );
2642
2643
0
    if (!sTmp.isEmpty())
2644
0
    {
2645
0
        GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_LETTER_SYNC,
2646
0
                                 sTmp.makeStringAndClear() );
2647
0
    }
2648
    // else: like page descriptor => ignore
2649
0
}
2650
2651
2652
/// export a date, time, or duration
2653
void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName,
2654
                                         double dValue,
2655
                                         bool bIsDate,
2656
                                         bool bIsDuration,
2657
                                         bool bOmitDurationIfZero,
2658
                                         sal_uInt16 nPrefix)
2659
0
{
2660
    // truncate for date granularity
2661
0
    if (bIsDate)
2662
0
    {
2663
0
        dValue = ::rtl::math::approxFloor(dValue);
2664
0
    }
2665
2666
0
    OUStringBuffer aBuffer;
2667
0
    if (bIsDuration)
2668
0
    {
2669
        // date/time duration handle bOmitDurationIfZero
2670
0
        if (!bOmitDurationIfZero || dValue != 0.0)
2671
0
        {
2672
0
            ::sax::Converter::convertDuration(aBuffer, dValue);
2673
0
        }
2674
0
    }
2675
0
    else
2676
0
    {
2677
        // date/time value
2678
0
        rExport.GetMM100UnitConverter().convertDateTime(aBuffer, dValue);
2679
0
    }
2680
2681
    // output attribute
2682
0
    ProcessString(eName, aBuffer.makeStringAndClear(), true, nPrefix);
2683
0
}
2684
2685
/// export a date or time
2686
void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName,
2687
                                         const util::DateTime& rTime)
2688
0
{
2689
0
    OUStringBuffer aBuffer;
2690
2691
0
    util::DateTime aDateTime(rTime);
2692
2693
    // date/time value
2694
0
    ::sax::Converter::convertDateTime(aBuffer, aDateTime, nullptr);
2695
2696
    // output attribute
2697
0
    ProcessString(eName, aBuffer.makeStringAndClear(), true);
2698
0
}
2699
2700
/// export a date, time, or duration
2701
void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName,
2702
                                         sal_Int32 nMinutes,
2703
                                         bool bIsDate,
2704
                                         bool bIsDuration)
2705
0
{
2706
    // handle bOmitDurationIfZero here, because we can precisely compare ints
2707
0
    if (!(bIsDuration && (nMinutes==0)))
2708
0
    {
2709
0
        ProcessDateTime(eName, static_cast<double>(nMinutes) / double(24*60),
2710
0
                        bIsDate, bIsDuration);
2711
0
    }
2712
0
}
2713
2714
/// export a time or dateTime
2715
void XMLTextFieldExport::ProcessTimeOrDateTime(enum XMLTokenEnum eName,
2716
                                         const util::DateTime& rTime)
2717
0
{
2718
0
    OUStringBuffer aBuffer;
2719
2720
    // date/time value
2721
0
    ::sax::Converter::convertTimeOrDateTime(aBuffer, rTime);
2722
2723
    // output attribute
2724
0
    ProcessString(eName, aBuffer.makeStringAndClear(), true);
2725
0
}
2726
2727
2728
SvXMLEnumMapEntry<sal_Int16> const aBibliographyDataTypeMap[] =
2729
{
2730
    { XML_ARTICLE,          BibliographyDataType::ARTICLE },
2731
    { XML_BOOK,             BibliographyDataType::BOOK },
2732
    { XML_BOOKLET,          BibliographyDataType::BOOKLET },
2733
    { XML_CONFERENCE,       BibliographyDataType::CONFERENCE },
2734
    { XML_CUSTOM1,          BibliographyDataType::CUSTOM1 },
2735
    { XML_CUSTOM2,          BibliographyDataType::CUSTOM2 },
2736
    { XML_CUSTOM3,          BibliographyDataType::CUSTOM3 },
2737
    { XML_CUSTOM4,          BibliographyDataType::CUSTOM4 },
2738
    { XML_CUSTOM5,          BibliographyDataType::CUSTOM5 },
2739
    { XML_EMAIL,            BibliographyDataType::EMAIL },
2740
    { XML_INBOOK,           BibliographyDataType::INBOOK },
2741
    { XML_INCOLLECTION,     BibliographyDataType::INCOLLECTION },
2742
    { XML_INPROCEEDINGS,    BibliographyDataType::INPROCEEDINGS },
2743
    { XML_JOURNAL,          BibliographyDataType::JOURNAL },
2744
    { XML_MANUAL,           BibliographyDataType::MANUAL },
2745
    { XML_MASTERSTHESIS,    BibliographyDataType::MASTERSTHESIS },
2746
    { XML_MISC,             BibliographyDataType::MISC },
2747
    { XML_PHDTHESIS,        BibliographyDataType::PHDTHESIS },
2748
    { XML_PROCEEDINGS,      BibliographyDataType::PROCEEDINGS },
2749
    { XML_TECHREPORT,       BibliographyDataType::TECHREPORT },
2750
    { XML_UNPUBLISHED,      BibliographyDataType::UNPUBLISHED },
2751
    { XML_WWW,              BibliographyDataType::WWW },
2752
    { XML_TOKEN_INVALID, 0 }
2753
};
2754
2755
2756
void XMLTextFieldExport::ProcessBibliographyData(
2757
    const Reference<XPropertySet>& rPropSet)
2758
0
{
2759
    // get the values
2760
0
    Any aAny = rPropSet->getPropertyValue(gsPropertyFields);
2761
0
    Sequence<PropertyValue> aValues;
2762
0
    aAny >>= aValues;
2763
2764
    // one attribute per value (unless empty)
2765
0
    for (const auto& rProp : aValues)
2766
0
    {
2767
0
        if( rProp.Name == "BibiliographicType" )
2768
0
        {
2769
0
            sal_Int16 nTypeId = 0;
2770
0
            rProp.Value >>= nTypeId;
2771
0
            OUStringBuffer sBuf;
2772
2773
0
            if (SvXMLUnitConverter::convertEnum(sBuf, nTypeId,
2774
0
                                                aBibliographyDataTypeMap))
2775
0
            {
2776
0
                rExport.AddAttribute(XML_NAMESPACE_TEXT,
2777
0
                                     XML_BIBLIOGRAPHY_TYPE,
2778
0
                                     sBuf.makeStringAndClear());
2779
0
            }
2780
            // else: ignore this argument
2781
0
        }
2782
0
        else
2783
0
        {
2784
0
            OUString sStr;
2785
0
            rProp.Value >>= sStr;
2786
2787
0
            if (!sStr.isEmpty())
2788
0
            {
2789
0
                XMLTokenEnum eElement = MapBibliographyFieldName(rProp.Name);
2790
0
                if (eElement == XML_URL || eElement == XML_LOCAL_URL || eElement == XML_TARGET_URL)
2791
0
                {
2792
0
                    sStr = GetExport().GetRelativeReference(sStr);
2793
0
                }
2794
0
                sal_uInt16 nPrefix = XML_NAMESPACE_TEXT;
2795
0
                if (eElement == XML_LOCAL_URL || eElement == XML_TARGET_TYPE
2796
0
                    || eElement == XML_TARGET_URL)
2797
0
                {
2798
0
                    nPrefix = XML_NAMESPACE_LO_EXT;
2799
0
                }
2800
0
                rExport.AddAttribute(nPrefix, eElement, sStr);
2801
0
            }
2802
0
        }
2803
0
    }
2804
0
}
2805
2806
/// export CommandTypeAttribute
2807
void XMLTextFieldExport::ProcessCommandType(
2808
    sal_Int32 nCommandType)
2809
0
{
2810
0
    enum XMLTokenEnum eToken = XML_TOKEN_INVALID;
2811
0
    switch( nCommandType )
2812
0
    {
2813
0
        case sdb::CommandType::TABLE:   eToken = XML_TABLE; break;
2814
0
        case sdb::CommandType::QUERY:   eToken = XML_QUERY; break;
2815
0
        case sdb::CommandType::COMMAND: eToken = XML_COMMAND; break;
2816
0
    }
2817
2818
0
    if( eToken != XML_TOKEN_INVALID )
2819
0
        rExport.AddAttribute( XML_NAMESPACE_TEXT, XML_TABLE_TYPE, eToken );
2820
0
}
2821
2822
2823
void XMLTextFieldExport::ProcessStringSequence(
2824
    const Sequence<OUString>& rSequence,
2825
    const OUString& sSelected )
2826
0
{
2827
    // find selected element
2828
0
    sal_Int32 nSelected = comphelper::findValue(rSequence, sSelected);
2829
2830
    // delegate to ProcessStringSequence(OUString,sal_Int32)
2831
0
    ProcessStringSequence( rSequence, nSelected );
2832
0
}
2833
2834
void XMLTextFieldExport::ProcessStringSequence(
2835
    const Sequence<OUString>& rSequence,
2836
    sal_Int32 nSelected )
2837
0
{
2838
0
    sal_Int32 nLength = rSequence.getLength();
2839
0
    const OUString* pSequence = rSequence.getConstArray();
2840
0
    for( sal_Int32 i = 0; i < nLength; i++ )
2841
0
    {
2842
0
        if( i == nSelected )
2843
0
            rExport.AddAttribute( XML_NAMESPACE_TEXT,
2844
0
                                  XML_CURRENT_SELECTED, XML_TRUE );
2845
0
        rExport.AddAttribute( XML_NAMESPACE_TEXT, XML_VALUE, pSequence[i] );
2846
0
        SvXMLElementExport aElement( rExport, XML_NAMESPACE_TEXT, XML_LABEL,
2847
0
                                     false, false );
2848
0
    }
2849
0
}
2850
2851
void XMLTextFieldExport::ExportDataBaseElement(
2852
    enum XMLTokenEnum eElementName,
2853
    const OUString& sPresentation,
2854
    const Reference<XPropertySet>& rPropertySet,
2855
    const Reference<XPropertySetInfo>& rPropertySetInfo )
2856
0
{
2857
0
    SAL_WARN_IF( eElementName == XML_TOKEN_INVALID, "xmloff.text", "need token" );
2858
0
    SAL_WARN_IF( !rPropertySet.is(), "xmloff.text", "need property set" );
2859
0
    SAL_WARN_IF( !rPropertySetInfo.is(), "xmloff.text", "need property set info" );
2860
2861
    // get database properties
2862
0
    OUString sDataBaseName;
2863
0
    OUString sDataBaseURL;
2864
0
    OUString sStr;
2865
0
    if( ( rPropertySet->getPropertyValue( gsPropertyDataBaseName ) >>= sStr )
2866
0
        && !sStr.isEmpty() )
2867
0
    {
2868
0
        sDataBaseName = sStr;
2869
0
    }
2870
0
    else if( rPropertySetInfo->hasPropertyByName( gsPropertyDataBaseURL ) &&
2871
0
             (rPropertySet->getPropertyValue( gsPropertyDataBaseURL ) >>= sStr) &&
2872
0
             !sStr.isEmpty() )
2873
0
    {
2874
0
        sDataBaseURL = sStr;
2875
0
    }
2876
2877
    // add database name property (if present)
2878
0
    if( !sDataBaseName.isEmpty() )
2879
0
        rExport.AddAttribute( XML_NAMESPACE_TEXT, XML_DATABASE_NAME,
2880
0
                              sDataBaseName );
2881
0
    SvXMLElementExport aDataBaseElement( GetExport(),
2882
0
                                         XML_NAMESPACE_TEXT, eElementName,
2883
0
                                         false, false );
2884
2885
    // write URL as children
2886
0
    if( !sDataBaseURL.isEmpty() )
2887
0
    {
2888
0
        rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sDataBaseURL );
2889
0
        SvXMLElementExport aDataSourceElement(
2890
0
            GetExport(), XML_NAMESPACE_FORM, XML_CONNECTION_RESOURCE,
2891
0
            false, false );
2892
0
    }
2893
2894
    // write presentation
2895
0
    rExport.Characters( sPresentation );
2896
0
}
2897
2898
2899
// explode a field master name into field type and field name
2900
void XMLTextFieldExport::ExplodeFieldMasterName(
2901
    std::u16string_view sMasterName, OUString& sFieldType, OUString& sVarName)
2902
0
{
2903
0
    sal_Int32 nLength = gsFieldMasterPrefix.getLength();
2904
0
    size_t nSeparator = sMasterName.find('.', nLength);
2905
2906
    // '.' found?
2907
0
    if (nSeparator == o3tl::make_unsigned(nLength) || nSeparator == std::u16string_view::npos) {
2908
0
        SAL_WARN("xmloff.text", "no field var name!");
2909
0
    }
2910
0
    else
2911
0
    {
2912
0
        sFieldType = sMasterName.substr(nLength, nSeparator-nLength);
2913
0
        sVarName = sMasterName.substr(nSeparator+1);
2914
0
    }
2915
0
}
2916
2917
2918
// for XDependentTextFields, get PropertySet of FieldMaster
2919
Reference<XPropertySet> XMLTextFieldExport::GetMasterPropertySet(
2920
    const Reference<XTextField> & rTextField)
2921
0
{
2922
    // name, value => get Property set of TextFieldMaster
2923
0
    Reference<XDependentTextField> xDep(rTextField, UNO_QUERY);
2924
0
    return xDep->getTextFieldMaster();
2925
0
}
2926
2927
// get PropertySet of (any; the first) dependent field
2928
bool XMLTextFieldExport::GetDependentFieldPropertySet(
2929
    const Reference<XPropertySet> & xMaster,
2930
    Reference<XPropertySet> & xField)
2931
0
{
2932
0
    Any aAny;
2933
0
    Sequence<Reference<XDependentTextField> > aFields;
2934
0
    aAny = xMaster->getPropertyValue(gsPropertyDependentTextFields);
2935
0
    aAny >>= aFields;
2936
2937
    // any fields?
2938
0
    if (aFields.hasElements())
2939
0
    {
2940
        // get first one and return
2941
0
        const Reference<XDependentTextField>& xTField = aFields[0];
2942
0
        xField.set(xTField, UNO_QUERY);
2943
0
        DBG_ASSERT(xField.is(),
2944
0
                  "Surprisingly, this TextField refuses to be a PropertySet!");
2945
0
        return true;
2946
0
    }
2947
0
    else
2948
0
    {
2949
0
        return false;
2950
0
    }
2951
0
}
2952
2953
2954
/// map placeholder type
2955
enum XMLTokenEnum XMLTextFieldExport::MapPlaceholderType(sal_uInt16 nType)
2956
0
{
2957
0
    enum XMLTokenEnum eType = XML_TEXT;
2958
2959
0
    switch (nType)
2960
0
    {
2961
0
        case PlaceholderType::TEXT:
2962
0
            eType = XML_TEXT;
2963
0
            break;
2964
2965
0
        case PlaceholderType::TABLE:
2966
0
            eType = XML_TABLE;
2967
0
            break;
2968
2969
0
        case PlaceholderType::TEXTFRAME:
2970
0
            eType = XML_TEXT_BOX;
2971
0
            break;
2972
2973
0
        case PlaceholderType::GRAPHIC:
2974
0
            eType = XML_IMAGE;
2975
0
            break;
2976
2977
0
        case PlaceholderType::OBJECT:
2978
0
            eType = XML_OBJECT;
2979
0
            break;
2980
2981
0
        default:
2982
            // unknown placeholder: XML_TEXT
2983
0
            OSL_FAIL("unknown placeholder type");
2984
0
    }
2985
2986
0
    return eType;
2987
0
}
2988
2989
2990
/// element name for author fields
2991
enum XMLTokenEnum XMLTextFieldExport::MapAuthorFieldName(
2992
    const Reference<XPropertySet> & xPropSet)
2993
0
{
2994
    // Initials or full name?
2995
0
    return GetBoolProperty(gsPropertyFullName, xPropSet)
2996
0
        ? XML_AUTHOR_NAME : XML_AUTHOR_INITIALS;
2997
0
}
2998
2999
enum XMLTokenEnum XMLTextFieldExport::MapPageNumberName(
3000
    const Reference<XPropertySet> & xPropSet,
3001
    sal_Int32& nOffset)
3002
0
{
3003
0
    enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3004
0
    PageNumberType ePage;
3005
0
    Any aAny = xPropSet->getPropertyValue(gsPropertySubType);
3006
0
    ePage = *o3tl::doAccess<PageNumberType>(aAny);
3007
3008
0
    switch (ePage)
3009
0
    {
3010
0
        case PageNumberType_PREV:
3011
0
            eName = XML_PREVIOUS;
3012
0
            nOffset += 1;
3013
0
            break;
3014
0
        case PageNumberType_CURRENT:
3015
0
            eName = XML_CURRENT;
3016
0
            break;
3017
0
        case PageNumberType_NEXT:
3018
0
            eName = XML_NEXT;
3019
0
            nOffset -= 1;
3020
0
            break;
3021
0
        default:
3022
0
            OSL_FAIL("unknown page number type");
3023
0
            eName = XML_TOKEN_INVALID;
3024
0
            break;
3025
0
    }
3026
3027
0
    return eName;
3028
0
}
3029
3030
/// map TemplateDisplayFormat to XML
3031
enum XMLTokenEnum XMLTextFieldExport::MapTemplateDisplayFormat(sal_Int16 nFormat)
3032
0
{
3033
0
    enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3034
3035
0
    switch (nFormat)
3036
0
    {
3037
0
        case TemplateDisplayFormat::FULL:
3038
0
            eName = XML_FULL;
3039
0
            break;
3040
0
        case TemplateDisplayFormat::PATH:
3041
0
            eName = XML_PATH;
3042
0
            break;
3043
0
        case TemplateDisplayFormat::NAME:
3044
0
            eName = XML_NAME;
3045
0
            break;
3046
0
        case TemplateDisplayFormat::NAME_AND_EXT:
3047
0
            eName = XML_NAME_AND_EXTENSION;
3048
0
            break;
3049
0
        case TemplateDisplayFormat::AREA:
3050
0
            eName = XML_AREA;
3051
0
            break;
3052
0
        case TemplateDisplayFormat::TITLE:
3053
0
            eName = XML_TITLE;
3054
0
            break;
3055
0
        default:
3056
0
            OSL_FAIL("unknown template display format");
3057
0
            eName = XML_TOKEN_INVALID;
3058
0
            break;
3059
0
    }
3060
3061
0
    return eName;
3062
0
}
3063
3064
/// map count/statistics field token to XML name
3065
enum XMLTokenEnum XMLTextFieldExport::MapCountFieldName(FieldIdEnum nToken)
3066
0
{
3067
0
    enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
3068
3069
0
    switch (nToken)
3070
0
    {
3071
0
        case FIELD_ID_COUNT_PAGES:
3072
0
            eElement = XML_PAGE_COUNT;
3073
0
            break;
3074
0
        case FIELD_ID_COUNT_PAGES_RANGE:
3075
0
            eElement = XML_PAGE_COUNT_RANGE;
3076
0
            break;
3077
0
        case FIELD_ID_COUNT_PARAGRAPHS:
3078
0
            eElement = XML_PARAGRAPH_COUNT;
3079
0
            break;
3080
0
        case FIELD_ID_COUNT_WORDS:
3081
0
            eElement = XML_WORD_COUNT;
3082
0
            break;
3083
0
        case FIELD_ID_COUNT_CHARACTERS:
3084
0
            eElement = XML_CHARACTER_COUNT;
3085
0
            break;
3086
0
        case FIELD_ID_COUNT_TABLES:
3087
0
            eElement = XML_TABLE_COUNT;
3088
0
            break;
3089
0
        case FIELD_ID_COUNT_GRAPHICS:
3090
0
            eElement = XML_IMAGE_COUNT;
3091
0
            break;
3092
0
        case FIELD_ID_COUNT_OBJECTS:
3093
0
            eElement = XML_OBJECT_COUNT;
3094
0
            break;
3095
0
        default:
3096
0
            OSL_FAIL("no count field token");
3097
0
            eElement = XML_TOKEN_INVALID;
3098
0
            break;
3099
0
    }
3100
3101
0
    return eElement;
3102
0
}
3103
3104
/// map ChapterDisplayFormat to XML string
3105
enum XMLTokenEnum XMLTextFieldExport::MapChapterDisplayFormat(sal_Int16 nFormat)
3106
0
{
3107
0
    enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3108
3109
0
    switch (nFormat)
3110
0
    {
3111
0
        case ChapterFormat::NAME:
3112
0
            eName = XML_NAME;
3113
0
            break;
3114
0
        case ChapterFormat::NUMBER:
3115
0
            eName = XML_NUMBER;
3116
0
            break;
3117
0
        case ChapterFormat::NAME_NUMBER:
3118
0
            eName = XML_NUMBER_AND_NAME;
3119
0
            break;
3120
0
        case ChapterFormat::NO_PREFIX_SUFFIX:
3121
0
            eName = XML_PLAIN_NUMBER_AND_NAME;
3122
0
            break;
3123
0
        case ChapterFormat::DIGIT:
3124
0
            eName = XML_PLAIN_NUMBER;
3125
0
            break;
3126
0
        default:
3127
0
            OSL_FAIL("unknown chapter display format");
3128
0
            eName = XML_TOKEN_INVALID;
3129
0
            break;
3130
0
    }
3131
3132
0
    return eName;
3133
0
}
3134
3135
3136
/// map FilenameDisplayFormat to XML attribute names
3137
enum XMLTokenEnum XMLTextFieldExport::MapFilenameDisplayFormat(sal_Int16 nFormat)
3138
0
{
3139
0
    enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3140
3141
0
    switch (nFormat)
3142
0
    {
3143
0
        case FilenameDisplayFormat::FULL:
3144
0
            eName = XML_FULL;
3145
0
            break;
3146
0
        case FilenameDisplayFormat::PATH:
3147
0
            eName = XML_PATH;
3148
0
            break;
3149
0
        case FilenameDisplayFormat::NAME:
3150
0
            eName = XML_NAME;
3151
0
            break;
3152
0
        case FilenameDisplayFormat::NAME_AND_EXT:
3153
0
            eName = XML_NAME_AND_EXTENSION;
3154
0
            break;
3155
0
        default:
3156
0
            OSL_FAIL("unknown filename display format");
3157
0
    }
3158
3159
0
    return eName;
3160
0
}
3161
3162
3163
/// map ReferenceFieldPart to XML string
3164
enum XMLTokenEnum XMLTextFieldExport::MapReferenceType(sal_Int16 nType)
3165
0
{
3166
0
    enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
3167
3168
0
    switch (nType)
3169
0
    {
3170
0
        case ReferenceFieldPart::PAGE:
3171
0
            eElement = XML_PAGE;
3172
0
            break;
3173
0
        case ReferenceFieldPart::CHAPTER:
3174
0
            eElement = XML_CHAPTER;
3175
0
            break;
3176
0
        case ReferenceFieldPart::TEXT:
3177
0
            eElement = XML_TEXT;
3178
0
            break;
3179
0
        case ReferenceFieldPart::UP_DOWN:
3180
0
            eElement = XML_DIRECTION;
3181
0
            break;
3182
0
        case ReferenceFieldPart::CATEGORY_AND_NUMBER:
3183
0
            eElement = XML_CATEGORY_AND_VALUE;
3184
0
            break;
3185
0
        case ReferenceFieldPart::ONLY_CAPTION:
3186
0
            eElement = XML_CAPTION;
3187
0
            break;
3188
0
        case ReferenceFieldPart::ONLY_SEQUENCE_NUMBER:
3189
0
            eElement = XML_VALUE;
3190
0
            break;
3191
0
        case ReferenceFieldPart::PAGE_DESC:
3192
            // small hack: this value never gets written, because
3193
            // XML_TEMPLATE is default
3194
0
            eElement = XML_TEMPLATE;
3195
0
            break;
3196
        // Core implementation for direct cross-references (#i81002#)
3197
0
        case ReferenceFieldPart::NUMBER:
3198
0
            eElement = XML_NUMBER;
3199
0
            break;
3200
0
        case ReferenceFieldPart::NUMBER_NO_CONTEXT:
3201
0
            eElement = XML_NUMBER_NO_SUPERIOR;
3202
0
            break;
3203
0
        case ReferenceFieldPart::NUMBER_FULL_CONTEXT:
3204
0
            eElement = XML_NUMBER_ALL_SUPERIOR;
3205
0
            break;
3206
0
        default:
3207
0
            OSL_FAIL("unknown reference type");
3208
0
            eElement = XML_TEMPLATE;
3209
0
            break;
3210
0
    }
3211
3212
0
    return eElement;
3213
0
}
3214
3215
/// map ReferenceFieldPart to XML string
3216
enum XMLTokenEnum XMLTextFieldExport::MapReferenceSource(sal_Int16 nType)
3217
0
{
3218
0
    enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
3219
3220
0
    switch (nType)
3221
0
    {
3222
0
        case ReferenceFieldSource::REFERENCE_MARK:
3223
0
            eElement = XML_REFERENCE_REF;
3224
0
            break;
3225
0
        case ReferenceFieldSource::SEQUENCE_FIELD:
3226
0
            eElement = XML_SEQUENCE_REF;
3227
0
            break;
3228
0
        case ReferenceFieldSource::BOOKMARK:
3229
0
            eElement = XML_BOOKMARK_REF;
3230
0
            break;
3231
0
        case ReferenceFieldSource::FOOTNOTE:
3232
0
        case ReferenceFieldSource::ENDNOTE:
3233
0
            eElement = XML_NOTE_REF;
3234
0
            break;
3235
0
        case ReferenceFieldSource::STYLE:
3236
0
            eElement = XML_STYLE_REF;
3237
0
            break;
3238
0
        default:
3239
0
            OSL_FAIL("unknown reference source");
3240
0
            break;
3241
0
    }
3242
3243
0
    return eElement;
3244
0
}
3245
3246
3247
/// element name for sender fields
3248
enum XMLTokenEnum XMLTextFieldExport::MapSenderFieldName(
3249
    const Reference<XPropertySet> & xPropSet)
3250
0
{
3251
0
    enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3252
3253
    // sub-field type
3254
0
    switch (GetInt16Property(gsPropertyFieldSubType, xPropSet))
3255
0
    {
3256
0
        case UserDataPart::COMPANY :
3257
0
            eName = XML_SENDER_COMPANY;
3258
0
            break;
3259
0
        case UserDataPart::FIRSTNAME :
3260
0
            eName = XML_SENDER_FIRSTNAME;
3261
0
            break;
3262
0
        case UserDataPart::NAME :
3263
0
            eName = XML_SENDER_LASTNAME;
3264
0
            break;
3265
0
        case UserDataPart::SHORTCUT :
3266
0
            eName = XML_SENDER_INITIALS;
3267
0
            break;
3268
0
        case UserDataPart::STREET :
3269
0
            eName = XML_SENDER_STREET;
3270
0
            break;
3271
0
        case UserDataPart::COUNTRY :
3272
0
            eName = XML_SENDER_COUNTRY;
3273
0
            break;
3274
0
        case UserDataPart::ZIP :
3275
0
            eName = XML_SENDER_POSTAL_CODE;
3276
0
            break;
3277
0
        case UserDataPart::CITY :
3278
0
            eName = XML_SENDER_CITY;
3279
0
            break;
3280
0
        case UserDataPart::TITLE :
3281
0
            eName = XML_SENDER_TITLE;
3282
0
            break;
3283
0
        case UserDataPart::POSITION :
3284
0
            eName = XML_SENDER_POSITION;
3285
0
            break;
3286
0
        case UserDataPart::PHONE_PRIVATE :
3287
0
            eName = XML_SENDER_PHONE_PRIVATE;
3288
0
            break;
3289
0
        case UserDataPart::PHONE_COMPANY :
3290
0
            eName = XML_SENDER_PHONE_WORK;
3291
0
            break;
3292
0
        case UserDataPart::FAX :
3293
0
            eName = XML_SENDER_FAX;
3294
0
            break;
3295
0
        case UserDataPart::EMAIL :
3296
0
            eName = XML_SENDER_EMAIL;
3297
0
            break;
3298
0
        case UserDataPart::STATE :
3299
0
            eName = XML_SENDER_STATE_OR_PROVINCE;
3300
0
            break;
3301
0
        default:
3302
0
            SAL_WARN("xmloff.text", "unknown sender type");
3303
0
            eName = XML_TOKEN_INVALID;
3304
0
            break;
3305
0
    }
3306
3307
0
    return eName;
3308
0
}
3309
3310
enum XMLTokenEnum XMLTextFieldExport::MapDocInfoFieldName(
3311
    enum FieldIdEnum nToken)
3312
0
{
3313
0
    enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
3314
3315
0
    switch (nToken)
3316
0
    {
3317
0
        case FIELD_ID_DOCINFO_CREATION_AUTHOR:
3318
0
            eElement = XML_INITIAL_CREATOR;
3319
0
            break;
3320
0
        case FIELD_ID_DOCINFO_CREATION_DATE:
3321
0
            eElement = XML_CREATION_DATE;
3322
0
            break;
3323
0
        case FIELD_ID_DOCINFO_CREATION_TIME:
3324
0
            eElement = XML_CREATION_TIME;
3325
0
            break;
3326
0
        case FIELD_ID_DOCINFO_DESCRIPTION:
3327
0
            eElement = XML_DESCRIPTION;
3328
0
            break;
3329
0
        case FIELD_ID_DOCINFO_PRINT_TIME:
3330
0
            eElement = XML_PRINT_TIME;
3331
0
            break;
3332
0
        case FIELD_ID_DOCINFO_PRINT_DATE:
3333
0
            eElement = XML_PRINT_DATE;
3334
0
            break;
3335
0
        case FIELD_ID_DOCINFO_PRINT_AUTHOR:
3336
0
            eElement = XML_PRINTED_BY;
3337
0
            break;
3338
0
        case FIELD_ID_DOCINFO_TITLE:
3339
0
            eElement = XML_TITLE;
3340
0
            break;
3341
0
        case FIELD_ID_DOCINFO_SUBJECT:
3342
0
            eElement = XML_SUBJECT;
3343
0
            break;
3344
0
        case FIELD_ID_DOCINFO_KEYWORDS:
3345
0
            eElement = XML_KEYWORDS;
3346
0
            break;
3347
0
        case FIELD_ID_DOCINFO_REVISION:
3348
0
            eElement = XML_EDITING_CYCLES;
3349
0
            break;
3350
0
        case FIELD_ID_DOCINFO_EDIT_DURATION:
3351
0
            eElement = XML_EDITING_DURATION;
3352
0
            break;
3353
0
        case FIELD_ID_DOCINFO_SAVE_TIME:
3354
0
            eElement = XML_MODIFICATION_TIME;
3355
0
            break;
3356
0
        case FIELD_ID_DOCINFO_SAVE_DATE:
3357
0
            eElement = XML_MODIFICATION_DATE;
3358
0
            break;
3359
0
        case FIELD_ID_DOCINFO_SAVE_AUTHOR:
3360
0
            eElement = XML_CREATOR;
3361
0
            break;
3362
0
        default:
3363
0
            SAL_WARN("xmloff.text", "unknown docinfo field type!");
3364
0
            eElement = XML_TOKEN_INVALID;
3365
0
            break;
3366
0
    }
3367
3368
0
    return eElement;
3369
0
}
3370
3371
enum XMLTokenEnum XMLTextFieldExport::MapBibliographyFieldName(std::u16string_view sName)
3372
0
{
3373
0
    enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3374
3375
0
    if( sName == u"Identifier" )
3376
0
    {
3377
0
        eName = XML_IDENTIFIER;
3378
0
    }
3379
0
    else if( sName == u"BibiliographicType" )
3380
0
    {
3381
0
        eName = XML_BIBLIOGRAPHY_TYPE;
3382
0
    }
3383
0
    else if( sName == u"Address" )
3384
0
    {
3385
0
        eName = XML_ADDRESS;
3386
0
    }
3387
0
    else if( sName == u"Annote" )
3388
0
    {
3389
0
        eName = XML_ANNOTE;
3390
0
    }
3391
0
    else if( sName == u"Author" )
3392
0
    {
3393
0
        eName = XML_AUTHOR;
3394
0
    }
3395
0
    else if( sName == u"Booktitle" )
3396
0
    {
3397
0
        eName = XML_BOOKTITLE;
3398
0
    }
3399
0
    else if( sName == u"Chapter" )
3400
0
    {
3401
0
        eName = XML_CHAPTER;
3402
0
    }
3403
0
    else if( sName == u"Edition" )
3404
0
    {
3405
0
        eName = XML_EDITION;
3406
0
    }
3407
0
    else if( sName == u"Editor" )
3408
0
    {
3409
0
        eName = XML_EDITOR;
3410
0
    }
3411
0
    else if( sName == u"Howpublished" )
3412
0
    {
3413
0
        eName = XML_HOWPUBLISHED;
3414
0
    }
3415
0
    else if( sName == u"Institution" )
3416
0
    {
3417
0
        eName = XML_INSTITUTION;
3418
0
    }
3419
0
    else if( sName == u"Journal" )
3420
0
    {
3421
0
        eName = XML_JOURNAL;
3422
0
    }
3423
0
    else if( sName == u"Month" )
3424
0
    {
3425
0
        eName = XML_MONTH;
3426
0
    }
3427
0
    else if( sName == u"Note" )
3428
0
    {
3429
0
        eName = XML_NOTE;
3430
0
    }
3431
0
    else if( sName == u"Number" )
3432
0
    {
3433
0
        eName = XML_NUMBER;
3434
0
    }
3435
0
    else if( sName == u"Organizations" )
3436
0
    {
3437
0
        eName = XML_ORGANIZATIONS;
3438
0
    }
3439
0
    else if( sName == u"Pages" )
3440
0
    {
3441
0
        eName = XML_PAGES;
3442
0
    }
3443
0
    else if( sName == u"Publisher" )
3444
0
    {
3445
0
        eName = XML_PUBLISHER;
3446
0
    }
3447
0
    else if( sName == u"School" )
3448
0
    {
3449
0
        eName = XML_SCHOOL;
3450
0
    }
3451
0
    else if( sName == u"Series" )
3452
0
    {
3453
0
        eName = XML_SERIES;
3454
0
    }
3455
0
    else if( sName == u"Title" )
3456
0
    {
3457
0
        eName = XML_TITLE;
3458
0
    }
3459
0
    else if( sName == u"Report_Type" )
3460
0
    {
3461
0
        eName = XML_REPORT_TYPE;
3462
0
    }
3463
0
    else if( sName == u"Volume" )
3464
0
    {
3465
0
        eName = XML_VOLUME;
3466
0
    }
3467
0
    else if( sName == u"Year" )
3468
0
    {
3469
0
        eName = XML_YEAR;
3470
0
    }
3471
0
    else if( sName == u"URL" )
3472
0
    {
3473
0
        eName = XML_URL;
3474
0
    }
3475
0
    else if( sName == u"Custom1" )
3476
0
    {
3477
0
        eName = XML_CUSTOM1;
3478
0
    }
3479
0
    else if( sName == u"Custom2" )
3480
0
    {
3481
0
        eName = XML_CUSTOM2;
3482
0
    }
3483
0
    else if( sName == u"Custom3" )
3484
0
    {
3485
0
        eName = XML_CUSTOM3;
3486
0
    }
3487
0
    else if( sName == u"Custom4" )
3488
0
    {
3489
0
        eName = XML_CUSTOM4;
3490
0
    }
3491
0
    else if( sName == u"Custom5" )
3492
0
    {
3493
0
        eName = XML_CUSTOM5;
3494
0
    }
3495
0
    else if( sName == u"ISBN" )
3496
0
    {
3497
0
        eName = XML_ISBN;
3498
0
    }
3499
0
    else if (sName == u"LocalURL")
3500
0
    {
3501
0
        eName = XML_LOCAL_URL;
3502
0
    }
3503
0
    else if (sName == u"TargetType")
3504
0
    {
3505
0
        eName = XML_TARGET_TYPE;
3506
0
    }
3507
0
    else if (sName == u"TargetURL")
3508
0
    {
3509
0
        eName = XML_TARGET_URL;
3510
0
    }
3511
0
    else
3512
0
    {
3513
0
        SAL_WARN("xmloff.text", "Unknown bibliography info data");
3514
0
        eName = XML_TOKEN_INVALID;
3515
0
    }
3516
3517
0
    return eName;
3518
0
}
3519
3520
enum XMLTokenEnum XMLTextFieldExport::MapMeasureKind(sal_Int16 nKind)
3521
0
{
3522
0
    switch( nKind )
3523
0
    {
3524
0
    case 0:
3525
0
        return XML_VALUE;
3526
0
    case 1:
3527
0
        return XML_UNIT;
3528
0
    }
3529
0
    return XML_GAP;
3530
0
}
3531
3532
OUString XMLTextFieldExport::MakeFootnoteRefName(
3533
    sal_Int16 nSeqNo)
3534
0
{
3535
    // generate foot-/endnote ID
3536
0
    return "ftn" + OUString::number(static_cast<sal_Int32>(nSeqNo));
3537
0
}
3538
3539
OUString XMLTextFieldExport::MakeSequenceRefName(
3540
    sal_Int16 nSeqNo,
3541
    std::u16string_view rSeqName)
3542
0
{
3543
    // generate foot-/endnote ID
3544
0
    return OUString::Concat("ref") +rSeqName + OUString::number(static_cast<sal_Int32>(nSeqNo));
3545
0
}
3546
3547
3548
// Property accessor helper functions
3549
3550
3551
// to be relegated (does that word exist?) to a more appropriate place
3552
3553
3554
bool GetBoolProperty(
3555
    const OUString& sPropName,
3556
    const Reference<XPropertySet> & xPropSet)
3557
0
{
3558
0
    Any aAny = xPropSet->getPropertyValue(sPropName);
3559
0
    bool bBool = *o3tl::doAccess<bool>(aAny);
3560
0
    return bBool;
3561
0
}
3562
3563
bool GetOptionalBoolProperty(
3564
    const OUString& sPropName,
3565
    const Reference<XPropertySet> & xPropSet,
3566
    const Reference<XPropertySetInfo> & xPropSetInfo,
3567
    bool bDefault)
3568
0
{
3569
0
    return xPropSetInfo->hasPropertyByName( sPropName )
3570
0
        ? GetBoolProperty( sPropName, xPropSet ) : bDefault;
3571
0
}
3572
3573
double GetDoubleProperty(
3574
    const OUString& sPropName,
3575
    const Reference<XPropertySet> & xPropSet)
3576
0
{
3577
0
    Any aAny = xPropSet->getPropertyValue(sPropName);
3578
0
    double fDouble = 0.0;
3579
0
    aAny >>= fDouble;
3580
0
    return fDouble;
3581
0
}
3582
3583
OUString GetStringProperty(
3584
    const OUString& sPropName,
3585
    const Reference<XPropertySet> & xPropSet)
3586
0
{
3587
0
    Any aAny = xPropSet->getPropertyValue(sPropName);
3588
0
    OUString sString;
3589
0
    aAny >>= sString;
3590
0
    return sString;
3591
0
}
3592
3593
sal_Int32 GetIntProperty(
3594
    const OUString& sPropName,
3595
    const Reference<XPropertySet> & xPropSet)
3596
0
{
3597
0
    Any aAny = xPropSet->getPropertyValue(sPropName);
3598
0
    sal_Int32 nInt = 0;
3599
0
    aAny >>= nInt;
3600
0
    return nInt;
3601
0
}
3602
3603
sal_Int16 GetInt16Property(
3604
    const OUString& sPropName,
3605
    const Reference<XPropertySet> & xPropSet)
3606
0
{
3607
0
    Any aAny = xPropSet->getPropertyValue(sPropName);
3608
0
    sal_Int16 nInt = 0;
3609
0
    aAny >>= nInt;
3610
0
    return nInt;
3611
0
}
3612
3613
sal_Int8 GetInt8Property(
3614
    const OUString& sPropName,
3615
    const Reference<XPropertySet> & xPropSet)
3616
0
{
3617
0
    Any aAny = xPropSet->getPropertyValue(sPropName);
3618
0
    sal_Int8 nInt = 0;
3619
0
    aAny >>= nInt;
3620
0
    return nInt;
3621
0
}
3622
3623
util::DateTime GetDateTimeProperty(
3624
    const OUString& sPropName,
3625
    const Reference<XPropertySet> & xPropSet)
3626
0
{
3627
0
    Any aAny = xPropSet->getPropertyValue(sPropName);
3628
0
    util::DateTime aTime;
3629
0
    aAny >>= aTime;
3630
0
    return aTime;
3631
0
}
3632
3633
Sequence<OUString> GetStringSequenceProperty(
3634
    const OUString& sPropName,
3635
    const Reference<XPropertySet> & xPropSet)
3636
0
{
3637
0
    Any aAny = xPropSet->getPropertyValue(sPropName);
3638
0
    Sequence<OUString> aSequence;
3639
0
    aAny >>= aSequence;
3640
0
    return aSequence;
3641
0
}
3642
3643
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */