1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 * export of all text fields
25 #include "txtflde.hxx"
26 #include <xmloff/XMLEventExport.hxx>
27 #include <xmloff/families.hxx>
28 #include <xmloff/nmspmap.hxx>
29 #include <xmloff/numehelp.hxx>
30 #include <xmloff/xmlement.hxx>
31 #include <xmloff/xmlexp.hxx>
32 #include <xmloff/xmlnume.hxx>
33 #include <xmloff/xmlnumfe.hxx>
34 #include <xmloff/xmltoken.hxx>
35 #include <xmloff/xmluconv.hxx>
36 #include <xmloff/maptype.hxx>
38 #include "XMLTextCharStyleNamesElementExport.hxx"
39 #include <sax/tools/converter.hxx>
41 #include <com/sun/star/util/DateTime.hpp>
42 #include <com/sun/star/util/Date.hpp>
43 #include <com/sun/star/lang/XServiceInfo.hpp>
44 #include <com/sun/star/text/UserDataPart.hpp>
45 #include <com/sun/star/text/PageNumberType.hpp>
46 #include <com/sun/star/style/NumberingType.hpp>
47 #include <com/sun/star/text/ReferenceFieldPart.hpp>
48 #include <com/sun/star/text/ReferenceFieldSource.hpp>
49 #include <com/sun/star/beans/XPropertySet.hpp>
50 #include <com/sun/star/beans/XPropertyState.hpp>
51 #include <com/sun/star/text/XTextField.hpp>
52 #include <com/sun/star/text/XDependentTextField.hpp>
53 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
55 #include <com/sun/star/text/SetVariableType.hpp>
56 #include <com/sun/star/text/PlaceholderType.hpp>
57 #include <com/sun/star/text/FilenameDisplayFormat.hpp>
58 #include <com/sun/star/text/ChapterFormat.hpp>
59 #include <com/sun/star/text/TemplateDisplayFormat.hpp>
60 #include <com/sun/star/frame/XModel.hpp>
61 #include <com/sun/star/container/XNameReplace.hpp>
62 #include <com/sun/star/uno/Sequence.h>
63 #include <com/sun/star/util/NumberFormat.hpp>
64 #include <com/sun/star/text/BibliographyDataType.hpp>
65 #include <com/sun/star/sdb/CommandType.hpp>
66 #include <com/sun/star/rdf/XMetadatable.hpp>
67 #include <rtl/ustrbuf.hxx>
68 #include <tools/debug.hxx>
69 #include <rtl/math.hxx>
74 using namespace ::std
;
75 using namespace ::com::sun::star
;
76 using namespace ::com::sun::star::uno
;
77 using namespace ::com::sun::star::text
;
78 using namespace ::com::sun::star::lang
;
79 using namespace ::com::sun::star::beans
;
80 using namespace ::com::sun::star::util
;
81 using namespace ::com::sun::star::style
;
82 using namespace ::com::sun::star::document
;
83 using namespace ::com::sun::star::container
;
84 using namespace ::xmloff::token
;
87 static sal_Char
const FIELD_SERVICE_SENDER
[] = "ExtendedUser";
88 static sal_Char
const FIELD_SERVICE_AUTHOR
[] = "Author";
89 static sal_Char
const FIELD_SERVICE_JUMPEDIT
[] = "JumpEdit";
90 static sal_Char
const FIELD_SERVICE_GETEXP
[] = "GetExpression";
91 static sal_Char
const FIELD_SERVICE_SETEXP
[] = "SetExpression";
92 static sal_Char
const FIELD_SERVICE_USER
[] = "User";
93 static sal_Char
const FIELD_SERVICE_INPUT
[] = "Input";
94 static sal_Char
const FIELD_SERVICE_USERINPUT
[] = "InputUser";
95 static sal_Char
const FIELD_SERVICE_DATETIME
[] = "DateTime";
96 static sal_Char
const FIELD_SERVICE_PAGENUMBER
[] = "PageNumber";
97 static sal_Char
const FIELD_SERVICE_DB_NEXT
[] = "DatabaseNextSet";
98 static sal_Char
const FIELD_SERVICE_DB_SELECT
[] = "DatabaseNumberOfSet";
99 static sal_Char
const FIELD_SERVICE_DB_NUMBER
[] = "DatabaseSetNumber";
100 static sal_Char
const FIELD_SERVICE_DB_DISPLAY
[] = "Database";
101 static sal_Char
const FIELD_SERVICE_DB_NAME
[] = "DatabaseName";
102 static sal_Char
const FIELD_SERVICE_CONDITIONAL_TEXT
[] = "ConditionalText";
103 static sal_Char
const FIELD_SERVICE_HIDDEN_TEXT
[] = "HiddenText";
104 static sal_Char
const FIELD_SERVICE_HIDDEN_PARAGRAPH
[] = "HiddenParagraph";
105 static sal_Char
const FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR
[] = "DocInfo.ChangeAuthor";
106 static sal_Char
const FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR2
[] = "docinfo.ChangeAuthor";
107 static sal_Char
const FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME
[] = "DocInfo.ChangeDateTime";
108 static sal_Char
const FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME2
[] = "docinfo.ChangeDateTime";
109 static sal_Char
const FIELD_SERVICE_DOC_INFO_EDIT_TIME
[] = "DocInfo.EditTime";
110 static sal_Char
const FIELD_SERVICE_DOC_INFO_EDIT_TIME2
[] = "docinfo.EditTime";
111 static sal_Char
const FIELD_SERVICE_DOC_INFO_DESCRIPTION
[] = "DocInfo.Description";
112 static sal_Char
const FIELD_SERVICE_DOC_INFO_DESCRIPTION2
[] = "docinfo.Description";
113 static sal_Char
const FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR
[] = "DocInfo.CreateAuthor";
114 static sal_Char
const FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR2
[] = "docinfo.CreateAuthor";
115 static sal_Char
const FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME
[] = "DocInfo.CreateDateTime";
116 static sal_Char
const FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME2
[] = "docinfo.CreateDateTime";
117 static sal_Char
const FIELD_SERVICE_DOC_INFO_CUSTOM
[] = "DocInfo.Custom";
118 static sal_Char
const FIELD_SERVICE_DOC_INFO_CUSTOM2
[] = "docinfo.Custom";
119 static sal_Char
const FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR
[] = "DocInfo.PrintAuthor";
120 static sal_Char
const FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR2
[] = "docinfo.PrintAuthor";
121 static sal_Char
const FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME
[] = "DocInfo.PrintDateTime";
122 static sal_Char
const FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME2
[] = "docinfo.PrintDateTime";
123 static sal_Char
const FIELD_SERVICE_DOC_INFO_KEY_WORDS
[] = "DocInfo.KeyWords";
124 static sal_Char
const FIELD_SERVICE_DOC_INFO_KEY_WORDS2
[] = "docinfo.KeyWords";
125 static sal_Char
const FIELD_SERVICE_DOC_INFO_SUBJECT
[] = "DocInfo.Subject";
126 static sal_Char
const FIELD_SERVICE_DOC_INFO_SUBJECT2
[] = "docinfo.Subject";
127 static sal_Char
const FIELD_SERVICE_DOC_INFO_TITLE
[] = "DocInfo.Title";
128 static sal_Char
const FIELD_SERVICE_DOC_INFO_TITLE2
[] = "docinfo.Title";
129 static sal_Char
const FIELD_SERVICE_DOC_INFO_REVISION
[] = "DocInfo.Revision";
130 static sal_Char
const FIELD_SERVICE_DOC_INFO_REVISION2
[] = "docinfo.Revision";
131 static sal_Char
const FIELD_SERVICE_FILE_NAME
[] = "FileName";
132 static sal_Char
const FIELD_SERVICE_CHAPTER
[] = "Chapter";
133 static sal_Char
const FIELD_SERVICE_TEMPLATE_NAME
[] = "TemplateName";
134 static sal_Char
const FIELD_SERVICE_PAGE_COUNT
[] = "PageCount";
135 static sal_Char
const FIELD_SERVICE_PARAGRAPH_COUNT
[] = "ParagraphCount";
136 static sal_Char
const FIELD_SERVICE_WORD_COUNT
[] = "WordCount";
137 static sal_Char
const FIELD_SERVICE_CHARACTER_COUNT
[] = "CharacterCount";
138 static sal_Char
const FIELD_SERVICE_TABLE_COUNT
[] = "TableCount";
139 static sal_Char
const FIELD_SERVICE_GRAPHIC_COUNT
[] = "GraphicObjectCount";
140 static sal_Char
const FIELD_SERVICE_OBJECT_COUNT
[] = "EmbeddedObjectCount";
141 static sal_Char
const FIELD_SERVICE_REFERENCE_PAGE_SET
[] = "ReferencePageSet";
142 static sal_Char
const FIELD_SERVICE_REFERENCE_PAGE_GET
[] = "ReferencePageGet";
143 static sal_Char
const FIELD_SERVICE_SHEET_NAME
[] = "SheetName";
144 static sal_Char
const FIELD_SERVICE_PAGE_NAME
[] = "PageName";
145 static sal_Char
const FIELD_SERVICE_MACRO
[] = "Macro";
146 static sal_Char
const FIELD_SERVICE_GET_REFERENCE
[] = "GetReference";
147 static sal_Char
const FIELD_SERVICE_DDE
[] = "DDE";
148 static sal_Char
const FIELD_SERVICE_URL
[] = "URL";
149 static sal_Char
const FIELD_SERVICE_BIBLIOGRAPHY
[] = "Bibliography";
150 static sal_Char
const FIELD_SERVICE_SCRIPT
[] = "Script";
151 static sal_Char
const FIELD_SERVICE_ANNOTATION
[] = "Annotation";
152 static sal_Char
const FIELD_SERVICE_COMBINED_CHARACTERS
[] = "CombinedCharacters";
153 static sal_Char
const FIELD_SERVICE_META
[] = "MetadataField";
154 static sal_Char
const FIELD_SERVICE_MEASURE
[] = "Measure";
155 static sal_Char
const FIELD_SERVICE_TABLE_FORMULA
[] = "TableFormula";
156 static sal_Char
const FIELD_SERVICE_DROP_DOWN
[] = "DropDown";
158 SvXMLEnumStringMapEntry
const aFieldServiceNameMapping
[] =
160 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SENDER
, FIELD_ID_SENDER
),
161 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_AUTHOR
, FIELD_ID_AUTHOR
),
162 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_JUMPEDIT
, FIELD_ID_PLACEHOLDER
),
163 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GETEXP
, FIELD_ID_VARIABLE_GET
),
164 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SETEXP
, FIELD_ID_VARIABLE_SET
),
165 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_USER
, FIELD_ID_USER_GET
),
166 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_INPUT
, FIELD_ID_TEXT_INPUT
),
167 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_USERINPUT
, FIELD_ID_USER_INPUT
),
168 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DATETIME
, FIELD_ID_TIME
),
169 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PAGENUMBER
, FIELD_ID_PAGENUMBER
),
170 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_REFERENCE_PAGE_SET
, FIELD_ID_REFPAGE_SET
),
171 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_REFERENCE_PAGE_GET
, FIELD_ID_REFPAGE_GET
),
173 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NEXT
, FIELD_ID_DATABASE_NEXT
),
174 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_SELECT
, FIELD_ID_DATABASE_SELECT
),
175 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NUMBER
, FIELD_ID_DATABASE_NUMBER
),
176 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_DISPLAY
, FIELD_ID_DATABASE_DISPLAY
),
177 // workaround for #no-bug#: Database/DataBase
178 ENUM_STRING_MAP_ENTRY( "DataBase", FIELD_ID_DATABASE_DISPLAY
),
179 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NAME
, FIELD_ID_DATABASE_NAME
),
181 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR
, FIELD_ID_DOCINFO_CREATION_AUTHOR
),
182 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR2
, FIELD_ID_DOCINFO_CREATION_AUTHOR
),
183 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME
, FIELD_ID_DOCINFO_CREATION_TIME
),
184 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME2
, FIELD_ID_DOCINFO_CREATION_TIME
),
185 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR
, FIELD_ID_DOCINFO_SAVE_AUTHOR
),
186 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR2
, FIELD_ID_DOCINFO_SAVE_AUTHOR
),
187 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME
, FIELD_ID_DOCINFO_SAVE_TIME
),
188 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME2
, FIELD_ID_DOCINFO_SAVE_TIME
),
189 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_EDIT_TIME
, FIELD_ID_DOCINFO_EDIT_DURATION
),
190 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_EDIT_TIME2
, FIELD_ID_DOCINFO_EDIT_DURATION
),
191 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_DESCRIPTION
, FIELD_ID_DOCINFO_DESCRIPTION
),
192 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_DESCRIPTION2
, FIELD_ID_DOCINFO_DESCRIPTION
),
193 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CUSTOM
, FIELD_ID_DOCINFO_CUSTOM
),
194 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CUSTOM2
, FIELD_ID_DOCINFO_CUSTOM
),
195 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR
, FIELD_ID_DOCINFO_PRINT_AUTHOR
),
196 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR2
, FIELD_ID_DOCINFO_PRINT_AUTHOR
),
197 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME
, FIELD_ID_DOCINFO_PRINT_TIME
),
198 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME2
, FIELD_ID_DOCINFO_PRINT_TIME
),
199 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_KEY_WORDS
, FIELD_ID_DOCINFO_KEYWORDS
),
200 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_KEY_WORDS2
, FIELD_ID_DOCINFO_KEYWORDS
),
201 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_SUBJECT
, FIELD_ID_DOCINFO_SUBJECT
),
202 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_SUBJECT2
, FIELD_ID_DOCINFO_SUBJECT
),
203 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_TITLE
, FIELD_ID_DOCINFO_TITLE
),
204 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_TITLE2
, FIELD_ID_DOCINFO_TITLE
),
205 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_REVISION
, FIELD_ID_DOCINFO_REVISION
),
206 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_REVISION2
, FIELD_ID_DOCINFO_REVISION
),
208 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CONDITIONAL_TEXT
, FIELD_ID_CONDITIONAL_TEXT
),
209 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_HIDDEN_TEXT
, FIELD_ID_HIDDEN_TEXT
),
210 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_HIDDEN_PARAGRAPH
, FIELD_ID_HIDDEN_PARAGRAPH
),
212 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_FILE_NAME
, FIELD_ID_FILE_NAME
),
213 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CHAPTER
, FIELD_ID_CHAPTER
),
214 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TEMPLATE_NAME
, FIELD_ID_TEMPLATE_NAME
),
216 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PAGE_COUNT
, FIELD_ID_COUNT_PAGES
),
217 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PARAGRAPH_COUNT
, FIELD_ID_COUNT_PARAGRAPHS
),
218 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_WORD_COUNT
, FIELD_ID_COUNT_WORDS
),
219 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CHARACTER_COUNT
, FIELD_ID_COUNT_CHARACTERS
),
220 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TABLE_COUNT
, FIELD_ID_COUNT_TABLES
),
221 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GRAPHIC_COUNT
, FIELD_ID_COUNT_GRAPHICS
),
222 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_OBJECT_COUNT
, FIELD_ID_COUNT_OBJECTS
),
224 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_MACRO
, FIELD_ID_MACRO
),
225 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GET_REFERENCE
, FIELD_ID_REF_REFERENCE
),
226 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DDE
, FIELD_ID_DDE
),
228 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_BIBLIOGRAPHY
, FIELD_ID_BIBLIOGRAPHY
),
230 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SCRIPT
, FIELD_ID_SCRIPT
),
231 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_ANNOTATION
, FIELD_ID_ANNOTATION
),
233 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_COMBINED_CHARACTERS
, FIELD_ID_COMBINED_CHARACTERS
),
234 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_META
, FIELD_ID_META
),
237 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SHEET_NAME
, FIELD_ID_SHEET_NAME
),
238 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PAGE_NAME
, FIELD_ID_PAGENAME
),
239 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_URL
, FIELD_ID_URL
),
240 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_MEASURE
, FIELD_ID_MEASURE
),
243 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TABLE_FORMULA
, FIELD_ID_TABLE_FORMULA
),
244 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DROP_DOWN
, FIELD_ID_DROP_DOWN
),
246 ENUM_STRING_MAP_END()
251 // property accessor helper functions
252 inline bool GetBoolProperty(const OUString
&,
253 const Reference
<XPropertySet
> &);
254 inline bool GetOptionalBoolProperty(const OUString
&,
255 const Reference
<XPropertySet
> &,
256 const Reference
<XPropertySetInfo
> &,
258 inline double GetDoubleProperty(const OUString
&,
259 const Reference
<XPropertySet
> &);
260 inline OUString
const GetStringProperty(const OUString
&,
261 const Reference
<XPropertySet
> &);
262 inline sal_Int32
GetIntProperty(const OUString
&,
263 const Reference
<XPropertySet
> &);
264 inline sal_Int16
GetInt16Property(const OUString
&,
265 const Reference
<XPropertySet
> &);
266 inline sal_Int8
GetInt8Property(const OUString
&,
267 const Reference
<XPropertySet
> &);
268 inline util::DateTime
const GetDateTimeProperty( const OUString
& sPropName
,
269 const Reference
<XPropertySet
> & xPropSet
);
270 inline Sequence
<OUString
> const GetStringSequenceProperty(
271 const OUString
& sPropName
,
272 const Reference
<XPropertySet
> & xPropSet
);
276 XMLTextFieldExport::XMLTextFieldExport( SvXMLExport
& rExp
,
277 XMLPropertyState
* pCombinedCharState
)
280 sServicePrefix("com.sun.star.text.textfield."),
281 sFieldMasterPrefix("com.sun.star.text.FieldMaster."),
282 sPresentationServicePrefix("com.sun.star.presentation.TextField."),
284 sPropertyAdjust("Adjust"),
285 sPropertyAuthor("Author"),
286 sPropertyChapterFormat("ChapterFormat"),
287 sPropertyChapterNumberingLevel("ChapterNumberingLevel"),
288 sPropertyCharStyleNames("CharStyleNames"),
289 sPropertyCondition("Condition"),
290 sPropertyContent("Content"),
291 sPropertyDataBaseName("DataBaseName"),
292 sPropertyDataBaseURL("DataBaseURL"),
293 sPropertyDataColumnName("DataColumnName"),
294 sPropertyDataCommandType("DataCommandType"),
295 sPropertyDataTableName("DataTableName"),
296 sPropertyDateTime("DateTime"),
297 sPropertyDateTimeValue("DateTimeValue"),
298 sPropertyDDECommandElement("DDECommandElement"),
299 sPropertyDDECommandFile("DDECommandFile"),
300 sPropertyDDECommandType("DDECommandType"),
301 sPropertyDependentTextFields("DependentTextFields"),
302 sPropertyFalseContent("FalseContent"),
303 sPropertyFields("Fields"),
304 sPropertyFieldSubType("UserDataType"),
305 sPropertyFileFormat("FileFormat"),
306 sPropertyFullName("FullName"),
307 sPropertyHint("Hint"),
308 sPropertyInitials("Initials"),
309 sPropertyInstanceName("InstanceName"),
310 sPropertyIsAutomaticUpdate("IsAutomaticUpdate"),
311 sPropertyIsConditionTrue("IsConditionTrue"),
312 sPropertyIsDataBaseFormat("DataBaseFormat"),
313 sPropertyIsDate("IsDate"),
314 sPropertyIsExpression("IsExpression"),
315 sPropertyIsFixed("IsFixed"),
316 sPropertyIsFixedLanguage("IsFixedLanguage"),
317 sPropertyIsHidden("IsHidden"),
318 sPropertyIsInput("Input"),
319 sPropertyIsShowFormula("IsShowFormula"),
320 sPropertyIsVisible("IsVisible"),
321 sPropertyItems("Items"),
322 sPropertyLevel("Level"),
323 sPropertyMeasureKind("Kind"),
324 sPropertyName("Name"),
325 sPropertyNumberFormat("NumberFormat"),
326 sPropertyNumberingSeparator("NumberingSeparator"),
327 sPropertyNumberingType("NumberingType"),
328 sPropertyOffset("Offset"),
330 sPropertyPlaceholderType("PlaceHolderType"),
331 sPropertyReferenceFieldPart("ReferenceFieldPart"),
332 sPropertyReferenceFieldSource("ReferenceFieldSource"),
333 sPropertyScriptType("ScriptType"),
334 sPropertySelectedItem("SelectedItem"),
335 sPropertySequenceNumber("SequenceNumber"),
336 sPropertySequenceValue("SequenceValue"),
337 sPropertySetNumber("SetNumber"),
338 sPropertySourceName("SourceName"),
339 sPropertySubType("SubType"),
340 sPropertyTargetFrame("TargetFrame"),
341 sPropertyTrueContent("TrueContent"),
343 sPropertyURLContent("URLContent"),
344 sPropertyUserText("UserText"),
345 sPropertyValue("Value"),
346 sPropertyVariableName("VariableName"),
347 sPropertyHelp("Help"),
348 sPropertyTooltip("Tooltip"),
349 sPropertyTextRange("TextRange"),
350 pCombinedCharactersPropertyState(pCombinedCharState
)
352 SetExportOnlyUsedFieldDeclarations();
355 XMLTextFieldExport::~XMLTextFieldExport()
357 delete pCombinedCharactersPropertyState
;
361 /// get the field ID (as in FieldIDEnum) from XTextField
362 enum FieldIdEnum
XMLTextFieldExport::GetFieldID(
363 const Reference
<XTextField
> & rTextField
,
364 const Reference
<XPropertySet
> & xPropSet
)
366 // get service names for rTextField (via XServiceInfo service)
367 Reference
<XServiceInfo
> xService(rTextField
, UNO_QUERY
);
368 const Sequence
<OUString
> aServices
= xService
->getSupportedServiceNames();
369 const OUString
* pNames
= aServices
.getConstArray();
370 sal_Int32 nCount
= aServices
.getLength();
372 OUString sFieldName
; // service name postfix of current field
374 // search for TextField service name
377 if (pNames
->matchIgnoreAsciiCase(sServicePrefix
))
379 // TextField found => postfix is field type!
380 sFieldName
= pNames
->copy(sServicePrefix
.getLength());
387 // if this is not a normal text field, check if it's a presentation text field
388 if( sFieldName
.isEmpty() )
390 const OUString
* pNames2
= aServices
.getConstArray();
391 sal_Int32 nCount2
= aServices
.getLength();
392 // search for TextField service name
395 if( 0 == pNames2
->compareTo(sPresentationServicePrefix
, sPresentationServicePrefix
.getLength()))
397 // TextField found => postfix is field type!
398 sFieldName
= pNames2
->copy(sPresentationServicePrefix
.getLength());
405 if( !sFieldName
.isEmpty() )
407 if( sFieldName
== "Header" )
409 return FIELD_ID_DRAW_HEADER
;
411 else if( sFieldName
== "Footer" )
413 return FIELD_ID_DRAW_FOOTER
;
415 else if( sFieldName
== "DateTime" )
417 return FIELD_ID_DRAW_DATE_TIME
;
422 // map postfix of service name to field ID
423 DBG_ASSERT(!sFieldName
.isEmpty(), "no TextField service found!");
424 return MapFieldName(sFieldName
, xPropSet
);
427 enum FieldIdEnum
XMLTextFieldExport::MapFieldName(
428 const OUString
& sFieldName
, // field (master) name
429 const Reference
<XPropertySet
> & xPropSet
) // for subtype
431 // we'll proceed in 2 steps:
432 // a) map service name to preliminary FIELD_ID
433 // b) map those prelim. FIELD_IDs that correspond to several field types
434 // (in our (XML) world) to final FIELD IDs
437 // a) find prelim. FIELD_ID via aFieldServiceMapping
439 // check for non-empty service name
440 DBG_ASSERT(!sFieldName
.isEmpty(), "no valid service name!");
441 enum FieldIdEnum nToken
= FIELD_ID_UNKNOWN
;
442 if (!sFieldName
.isEmpty())
444 // map name to prelim. ID
446 bool bRet
= SvXMLUnitConverter::convertEnum(
447 nTmp
, sFieldName
, aFieldServiceNameMapping
);
450 DBG_ASSERT(bRet
, "Unknown field service name encountered!");
453 nToken
= FIELD_ID_UNKNOWN
;
457 nToken
= (enum FieldIdEnum
)nTmp
;
460 // invalid service name
461 nToken
= FIELD_ID_UNKNOWN
;
464 // b) map prelim. to final FIELD_IDs
466 case FIELD_ID_VARIABLE_SET
:
467 if (GetBoolProperty(sPropertyIsInput
, xPropSet
))
469 nToken
= FIELD_ID_VARIABLE_INPUT
;
473 switch (GetIntProperty(sPropertySubType
, xPropSet
))
475 case SetVariableType::STRING
: // text field
476 case SetVariableType::VAR
: // num field
477 nToken
= FIELD_ID_VARIABLE_SET
;
479 case SetVariableType::SEQUENCE
:
480 nToken
= FIELD_ID_SEQUENCE
;
482 case SetVariableType::FORMULA
:
484 nToken
= FIELD_ID_UNKNOWN
;
490 case FIELD_ID_VARIABLE_GET
:
491 switch (GetIntProperty(sPropertySubType
, xPropSet
))
493 case SetVariableType::STRING
: // text field
494 case SetVariableType::VAR
: // num field
495 nToken
= FIELD_ID_VARIABLE_GET
;
497 case SetVariableType::FORMULA
:
498 nToken
= FIELD_ID_EXPRESSION
;
500 case SetVariableType::SEQUENCE
:
502 nToken
= FIELD_ID_UNKNOWN
;
508 if (GetBoolProperty(sPropertyIsDate
, xPropSet
))
510 nToken
= FIELD_ID_DATE
;
514 case FIELD_ID_PAGENUMBER
:
515 // NumberingType not available in non-Writer apps
516 if (xPropSet
->getPropertySetInfo()->
517 hasPropertyByName(sPropertyNumberingType
))
519 if (NumberingType::CHAR_SPECIAL
== GetIntProperty(
520 sPropertyNumberingType
, xPropSet
))
522 nToken
= FIELD_ID_PAGESTRING
;
527 case FIELD_ID_DOCINFO_CREATION_TIME
:
528 if (GetBoolProperty(sPropertyIsDate
, xPropSet
))
530 nToken
= FIELD_ID_DOCINFO_CREATION_DATE
;
534 case FIELD_ID_DOCINFO_PRINT_TIME
:
535 if (GetBoolProperty(sPropertyIsDate
, xPropSet
))
537 nToken
= FIELD_ID_DOCINFO_PRINT_DATE
;
541 case FIELD_ID_DOCINFO_SAVE_TIME
:
542 if (GetBoolProperty(sPropertyIsDate
, xPropSet
))
544 nToken
= FIELD_ID_DOCINFO_SAVE_DATE
;
548 case FIELD_ID_REF_REFERENCE
:
549 switch (GetInt16Property(sPropertyReferenceFieldSource
, xPropSet
))
551 case ReferenceFieldSource::REFERENCE_MARK
:
552 nToken
= FIELD_ID_REF_REFERENCE
;
554 case ReferenceFieldSource::SEQUENCE_FIELD
:
555 nToken
= FIELD_ID_REF_SEQUENCE
;
557 case ReferenceFieldSource::BOOKMARK
:
558 nToken
= FIELD_ID_REF_BOOKMARK
;
560 case ReferenceFieldSource::FOOTNOTE
:
561 nToken
= FIELD_ID_REF_FOOTNOTE
;
563 case ReferenceFieldSource::ENDNOTE
:
564 nToken
= FIELD_ID_REF_ENDNOTE
;
567 nToken
= FIELD_ID_UNKNOWN
;
572 case FIELD_ID_COMBINED_CHARACTERS
:
573 case FIELD_ID_SCRIPT
:
574 case FIELD_ID_ANNOTATION
:
575 case FIELD_ID_BIBLIOGRAPHY
:
578 case FIELD_ID_REFPAGE_SET
:
579 case FIELD_ID_REFPAGE_GET
:
580 case FIELD_ID_COUNT_PAGES
:
581 case FIELD_ID_COUNT_PARAGRAPHS
:
582 case FIELD_ID_COUNT_WORDS
:
583 case FIELD_ID_COUNT_CHARACTERS
:
584 case FIELD_ID_COUNT_TABLES
:
585 case FIELD_ID_COUNT_GRAPHICS
:
586 case FIELD_ID_COUNT_OBJECTS
:
587 case FIELD_ID_CONDITIONAL_TEXT
:
588 case FIELD_ID_HIDDEN_TEXT
:
589 case FIELD_ID_HIDDEN_PARAGRAPH
:
590 case FIELD_ID_DOCINFO_CREATION_AUTHOR
:
591 case FIELD_ID_DOCINFO_DESCRIPTION
:
592 case FIELD_ID_DOCINFO_CUSTOM
:
593 case FIELD_ID_DOCINFO_PRINT_AUTHOR
:
594 case FIELD_ID_DOCINFO_TITLE
:
595 case FIELD_ID_DOCINFO_SUBJECT
:
596 case FIELD_ID_DOCINFO_KEYWORDS
:
597 case FIELD_ID_DOCINFO_REVISION
:
598 case FIELD_ID_DOCINFO_EDIT_DURATION
:
599 case FIELD_ID_DOCINFO_SAVE_AUTHOR
:
600 case FIELD_ID_TEXT_INPUT
:
601 case FIELD_ID_USER_INPUT
:
602 case FIELD_ID_AUTHOR
:
603 case FIELD_ID_SENDER
:
604 case FIELD_ID_PLACEHOLDER
:
605 case FIELD_ID_USER_GET
:
606 case FIELD_ID_DATABASE_NEXT
:
607 case FIELD_ID_DATABASE_SELECT
:
608 case FIELD_ID_DATABASE_DISPLAY
:
609 case FIELD_ID_DATABASE_NAME
:
610 case FIELD_ID_DATABASE_NUMBER
:
611 case FIELD_ID_TEMPLATE_NAME
:
612 case FIELD_ID_CHAPTER
:
613 case FIELD_ID_FILE_NAME
:
615 case FIELD_ID_SHEET_NAME
:
616 case FIELD_ID_PAGENAME
:
617 case FIELD_ID_MEASURE
:
619 case FIELD_ID_TABLE_FORMULA
:
620 case FIELD_ID_DROP_DOWN
:
621 ; // these field IDs are final
625 nToken
= FIELD_ID_UNKNOWN
;
628 // ... and return final FIELD_ID
632 // is string or numeric field?
633 bool XMLTextFieldExport::IsStringField(
634 FieldIdEnum nFieldType
,
635 const Reference
<XPropertySet
> & xPropSet
)
637 switch (nFieldType
) {
639 case FIELD_ID_VARIABLE_GET
:
640 case FIELD_ID_VARIABLE_SET
:
641 case FIELD_ID_VARIABLE_INPUT
:
643 // depends on field sub type
644 return ( GetIntProperty(sPropertySubType
, xPropSet
) ==
645 SetVariableType::STRING
);
648 case FIELD_ID_USER_GET
:
649 case FIELD_ID_USER_INPUT
:
651 Reference
<XTextField
> xTextField(xPropSet
, UNO_QUERY
);
652 DBG_ASSERT(xTextField
.is(), "field is no XTextField!");
653 bool bRet
= GetBoolProperty(sPropertyIsExpression
,
654 GetMasterPropertySet(xTextField
));
659 return 0 > GetIntProperty(sPropertyNumberFormat
, xPropSet
);
661 case FIELD_ID_DATABASE_DISPLAY
:
662 // TODO: depends on... ???
663 // workaround #no-bug#: no data type
664 return 5100 == GetIntProperty(sPropertyNumberFormat
, xPropSet
);
666 case FIELD_ID_TABLE_FORMULA
:
667 // legacy field: always a number field (because it always has
671 case FIELD_ID_COUNT_PAGES
:
672 case FIELD_ID_COUNT_PARAGRAPHS
:
673 case FIELD_ID_COUNT_WORDS
:
674 case FIELD_ID_COUNT_CHARACTERS
:
675 case FIELD_ID_COUNT_TABLES
:
676 case FIELD_ID_COUNT_GRAPHICS
:
677 case FIELD_ID_COUNT_OBJECTS
:
678 case FIELD_ID_DOCINFO_SAVE_TIME
:
679 case FIELD_ID_DOCINFO_SAVE_DATE
:
680 case FIELD_ID_DOCINFO_CREATION_DATE
:
681 case FIELD_ID_DOCINFO_CREATION_TIME
:
682 case FIELD_ID_DOCINFO_PRINT_TIME
:
683 case FIELD_ID_DOCINFO_PRINT_DATE
:
684 case FIELD_ID_DOCINFO_EDIT_DURATION
:
685 case FIELD_ID_DOCINFO_REVISION
:
686 case FIELD_ID_DATABASE_NUMBER
:
687 case FIELD_ID_EXPRESSION
:
688 case FIELD_ID_SEQUENCE
:
691 case FIELD_ID_PAGENUMBER
:
692 case FIELD_ID_REFPAGE_SET
:
693 case FIELD_ID_REFPAGE_GET
:
694 case FIELD_ID_DOCINFO_CUSTOM
:
698 case FIELD_ID_COMBINED_CHARACTERS
:
699 case FIELD_ID_BIBLIOGRAPHY
:
701 case FIELD_ID_REF_REFERENCE
:
702 case FIELD_ID_REF_SEQUENCE
:
703 case FIELD_ID_REF_BOOKMARK
:
704 case FIELD_ID_REF_FOOTNOTE
:
705 case FIELD_ID_REF_ENDNOTE
:
707 case FIELD_ID_TEMPLATE_NAME
:
708 case FIELD_ID_CHAPTER
:
709 case FIELD_ID_FILE_NAME
:
710 case FIELD_ID_CONDITIONAL_TEXT
:
711 case FIELD_ID_HIDDEN_TEXT
:
712 case FIELD_ID_HIDDEN_PARAGRAPH
:
713 case FIELD_ID_DOCINFO_CREATION_AUTHOR
:
714 case FIELD_ID_DOCINFO_DESCRIPTION
:
715 case FIELD_ID_DOCINFO_PRINT_AUTHOR
:
716 case FIELD_ID_DOCINFO_TITLE
:
717 case FIELD_ID_DOCINFO_SUBJECT
:
718 case FIELD_ID_DOCINFO_KEYWORDS
:
719 case FIELD_ID_DOCINFO_SAVE_AUTHOR
:
720 case FIELD_ID_DATABASE_NAME
:
721 case FIELD_ID_TEXT_INPUT
:
722 case FIELD_ID_SENDER
:
723 case FIELD_ID_AUTHOR
:
724 case FIELD_ID_PAGENAME
:
725 case FIELD_ID_PAGESTRING
:
726 case FIELD_ID_SHEET_NAME
:
727 case FIELD_ID_MEASURE
:
729 case FIELD_ID_DROP_DOWN
:
733 case FIELD_ID_SCRIPT
:
734 case FIELD_ID_ANNOTATION
:
735 case FIELD_ID_DATABASE_NEXT
:
736 case FIELD_ID_DATABASE_SELECT
:
737 case FIELD_ID_VARIABLE_DECL
:
738 case FIELD_ID_USER_DECL
:
739 case FIELD_ID_SEQUENCE_DECL
:
740 case FIELD_ID_PLACEHOLDER
:
741 case FIELD_ID_UNKNOWN
:
742 case FIELD_ID_DRAW_HEADER
:
743 case FIELD_ID_DRAW_FOOTER
:
744 case FIELD_ID_DRAW_DATE_TIME
:
746 OSL_FAIL("unknown field type/field has no content");
747 return true; // invalid info; string in case of doubt
751 /// export the styles needed by the given field. Called on first pass
753 void XMLTextFieldExport::ExportFieldAutoStyle(
754 const Reference
<XTextField
> & rTextField
, const bool bProgress
,
755 const bool bRecursive
)
758 Reference
<XPropertySet
> xPropSet(rTextField
, UNO_QUERY
);
760 // add field master to list of used field masters (if desired)
761 if (NULL
!= pUsedMasters
)
763 Reference
<XDependentTextField
> xDepField(rTextField
, UNO_QUERY
);
766 Reference
<XText
> xOurText
= rTextField
->getAnchor()->getText();
768 map
<Reference
<XText
>, set
<OUString
> >::iterator aMapIter
=
769 pUsedMasters
->find(xOurText
);
771 // insert a list for our XText (if necessary)
772 if (aMapIter
== pUsedMasters
->end())
775 (*pUsedMasters
)[xOurText
] = aSet
;
776 aMapIter
= pUsedMasters
->find(xOurText
);
779 // insert this text field master
780 OUString sFieldMasterName
= GetStringProperty(
781 sPropertyInstanceName
, xDepField
->getTextFieldMaster());
782 if (!sFieldMasterName
.isEmpty())
783 aMapIter
->second
.insert( sFieldMasterName
);
785 // else: no dependent field -> no master -> ignore
789 FieldIdEnum nToken
= GetFieldID(rTextField
, xPropSet
);
791 // export the character style for all fields
792 // with one exception: combined character fields export their own
794 Reference
<XPropertySet
> xRangePropSet(rTextField
->getAnchor(), UNO_QUERY
);
795 if (FIELD_ID_COMBINED_CHARACTERS
!= nToken
)
797 GetExport().GetTextParagraphExport()->Add(
798 XML_STYLE_FAMILY_TEXT_TEXT
, xRangePropSet
);
801 // process special styles for each field (e.g. data styles)
804 case FIELD_ID_DATABASE_DISPLAY
:
806 sal_Int32 nFormat
= GetIntProperty(sPropertyNumberFormat
, xPropSet
);
807 // workaround: #no-bug#; see IsStringField(...)
808 if ( (5100 != nFormat
) &&
809 !GetBoolProperty(sPropertyIsDataBaseFormat
, xPropSet
) )
811 GetExport().addDataStyle(nFormat
);
819 // date and time fields are always number fields, but the
820 // NumberFormat property is optional (e.g. Calc doesn't
822 Reference
<XPropertySetInfo
> xPropSetInfo(
823 xPropSet
->getPropertySetInfo() );
824 if ( xPropSetInfo
->hasPropertyByName( sPropertyNumberFormat
) )
827 GetIntProperty(sPropertyNumberFormat
, xPropSet
);
829 // nFormat may be -1 for numeric fields that display their
830 // variable name. (Maybe this should be a field type, then?)
833 if( ! GetOptionalBoolProperty(
834 sPropertyIsFixedLanguage
,
835 xPropSet
, xPropSetInfo
, false ) )
838 GetExport().dataStyleForceSystemLanguage(nFormat
);
841 GetExport().addDataStyle( nFormat
,
842 nToken
== FIELD_ID_TIME
);
849 // recurse into content (does not export element, so can be done first)
852 ExportMetaField(xPropSet
, true, bProgress
);
854 // fall-through: for the meta-field itself!
855 case FIELD_ID_DOCINFO_PRINT_TIME
:
856 case FIELD_ID_DOCINFO_PRINT_DATE
:
857 case FIELD_ID_DOCINFO_CREATION_DATE
:
858 case FIELD_ID_DOCINFO_CREATION_TIME
:
859 case FIELD_ID_DOCINFO_SAVE_TIME
:
860 case FIELD_ID_DOCINFO_SAVE_DATE
:
861 case FIELD_ID_DOCINFO_EDIT_DURATION
:
862 case FIELD_ID_VARIABLE_SET
:
863 case FIELD_ID_VARIABLE_GET
:
864 case FIELD_ID_VARIABLE_INPUT
:
865 case FIELD_ID_USER_GET
:
866 case FIELD_ID_EXPRESSION
:
867 case FIELD_ID_TABLE_FORMULA
:
868 case FIELD_ID_DOCINFO_CUSTOM
:
869 // register number format, if this is a numeric field
870 if (! IsStringField(nToken
, xPropSet
)) {
873 GetIntProperty(sPropertyNumberFormat
, xPropSet
);
875 // nFormat may be -1 for numeric fields that display their
876 // variable name. (Maybe this should be a field type, then?)
879 // handle formats for fixed language fields
880 // for all these fields (except table formula)
881 if( ( nToken
!= FIELD_ID_TABLE_FORMULA
) &&
882 ! GetOptionalBoolProperty(
883 sPropertyIsFixedLanguage
,
884 xPropSet
, xPropSet
->getPropertySetInfo(),
888 GetExport().dataStyleForceSystemLanguage(nFormat
);
891 GetExport().addDataStyle(nFormat
);
896 case FIELD_ID_COMBINED_CHARACTERS
:
898 // export text style with the addition of the combined characters
899 DBG_ASSERT(NULL
!= pCombinedCharactersPropertyState
,
900 "need proper PropertyState for combined characters");
901 const XMLPropertyState
*aStates
[] = { pCombinedCharactersPropertyState
, 0 };
902 GetExport().GetTextParagraphExport()->Add(
903 XML_STYLE_FAMILY_TEXT_TEXT
, xRangePropSet
,
908 case FIELD_ID_SCRIPT
:
909 case FIELD_ID_ANNOTATION
:
910 case FIELD_ID_BIBLIOGRAPHY
:
912 case FIELD_ID_REF_REFERENCE
:
913 case FIELD_ID_REF_SEQUENCE
:
914 case FIELD_ID_REF_BOOKMARK
:
915 case FIELD_ID_REF_FOOTNOTE
:
916 case FIELD_ID_REF_ENDNOTE
:
918 case FIELD_ID_REFPAGE_SET
:
919 case FIELD_ID_REFPAGE_GET
:
920 case FIELD_ID_COUNT_PAGES
:
921 case FIELD_ID_COUNT_PARAGRAPHS
:
922 case FIELD_ID_COUNT_WORDS
:
923 case FIELD_ID_COUNT_CHARACTERS
:
924 case FIELD_ID_COUNT_TABLES
:
925 case FIELD_ID_COUNT_GRAPHICS
:
926 case FIELD_ID_COUNT_OBJECTS
:
927 case FIELD_ID_CONDITIONAL_TEXT
:
928 case FIELD_ID_HIDDEN_TEXT
:
929 case FIELD_ID_HIDDEN_PARAGRAPH
:
930 case FIELD_ID_DOCINFO_CREATION_AUTHOR
:
931 case FIELD_ID_DOCINFO_DESCRIPTION
:
932 case FIELD_ID_DOCINFO_PRINT_AUTHOR
:
933 case FIELD_ID_DOCINFO_TITLE
:
934 case FIELD_ID_DOCINFO_SUBJECT
:
935 case FIELD_ID_DOCINFO_KEYWORDS
:
936 case FIELD_ID_DOCINFO_REVISION
:
937 case FIELD_ID_DOCINFO_SAVE_AUTHOR
:
938 case FIELD_ID_SEQUENCE
:
939 case FIELD_ID_PAGENAME
:
940 case FIELD_ID_PAGENUMBER
:
941 case FIELD_ID_PAGESTRING
:
942 case FIELD_ID_AUTHOR
:
943 case FIELD_ID_SENDER
:
944 case FIELD_ID_PLACEHOLDER
:
945 case FIELD_ID_USER_INPUT
:
946 case FIELD_ID_TEXT_INPUT
:
947 case FIELD_ID_DATABASE_NEXT
:
948 case FIELD_ID_DATABASE_SELECT
:
949 case FIELD_ID_DATABASE_NAME
:
950 case FIELD_ID_DATABASE_NUMBER
:
951 case FIELD_ID_TEMPLATE_NAME
:
952 case FIELD_ID_CHAPTER
:
953 case FIELD_ID_FILE_NAME
:
954 case FIELD_ID_SHEET_NAME
:
955 case FIELD_ID_MEASURE
:
957 case FIELD_ID_DROP_DOWN
:
958 case FIELD_ID_DRAW_DATE_TIME
:
959 case FIELD_ID_DRAW_FOOTER
:
960 case FIELD_ID_DRAW_HEADER
:
961 ; // no formats for these fields!
964 case FIELD_ID_UNKNOWN
:
966 OSL_FAIL("unknown field type!");
967 // ignore -> no format for ukowns
972 /// export the given field to XML. Called on second pass through document
973 void XMLTextFieldExport::ExportField(
974 const Reference
<XTextField
> & rTextField
, bool bProgress
)
977 Reference
<XPropertySet
> xPropSet(rTextField
, UNO_QUERY
);
979 // get property set of range (for the attributes)
980 Reference
<XPropertySet
> xRangePropSet(rTextField
->getAnchor(), UNO_QUERY
);
983 enum FieldIdEnum nToken
= GetFieldID(rTextField
, xPropSet
);
985 // special treatment for combined characters field, because it is
986 // exported as a style
987 const XMLPropertyState
* aStates
[] = { pCombinedCharactersPropertyState
, 0 };
988 const XMLPropertyState
**pStates
=
989 FIELD_ID_COMBINED_CHARACTERS
== nToken
993 // find out whether we need to set the style or hyperlink
997 OUString sStyle
= GetExport().GetTextParagraphExport()->
998 FindTextStyleAndHyperlink( xRangePropSet
, bHasHyperlink
, bIsUICharStyle
,
999 bHasAutoStyle
, pStates
);
1000 bool bHasStyle
= !sStyle
.isEmpty();
1002 // export hyperlink (if we have one)
1003 Reference
< XPropertySetInfo
> xRangePropSetInfo
;
1006 Reference
<XPropertyState
> xRangePropState( xRangePropSet
, UNO_QUERY
);
1007 xRangePropSetInfo
= xRangePropSet
->getPropertySetInfo();
1009 GetExport().GetTextParagraphExport()->addHyperlinkAttributes(
1010 xRangePropSet
, xRangePropState
,
1011 xRangePropSetInfo
);
1013 SvXMLElementExport
aHyperlink( GetExport(), bHasHyperlink
,
1014 XML_NAMESPACE_TEXT
, XML_A
,
1019 // export events (if supported)
1020 OUString
sHyperLinkEvents("HyperLinkEvents");
1021 if (xRangePropSetInfo
->hasPropertyByName(sHyperLinkEvents
))
1023 Any aAny
= xRangePropSet
->getPropertyValue(sHyperLinkEvents
);
1024 Reference
<XNameReplace
> xName
;
1026 GetExport().GetEventExport().Export(xName
, false);
1031 XMLTextCharStyleNamesElementExport
aCharStylesExport(
1032 GetExport(), bIsUICharStyle
&&
1033 GetExport().GetTextParagraphExport()
1034 ->GetCharStyleNamesPropInfoCache().hasProperty(
1035 xRangePropSet
, xRangePropSetInfo
), bHasAutoStyle
,
1036 xRangePropSet
, sPropertyCharStyleNames
);
1038 // export span with style (if necessary)
1039 // (except for combined characters field)
1042 // export <text:span> element
1043 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
1044 GetExport().EncodeStyleName( sStyle
) );
1046 SvXMLElementExport
aSpan( GetExport(), bHasStyle
,
1047 XML_NAMESPACE_TEXT
, XML_SPAN
,
1050 // finally, export the field itself
1051 ExportFieldHelper( rTextField
, xPropSet
, xRangePropSet
, nToken
,
1056 /// export the given field to XML. Called on second pass through document
1057 void XMLTextFieldExport::ExportFieldHelper(
1058 const Reference
<XTextField
> & rTextField
,
1059 const Reference
<XPropertySet
> & rPropSet
,
1060 const Reference
<XPropertySet
> &,
1061 enum FieldIdEnum nToken
,
1064 // get property set info (because some attributes are not support
1065 // in all implementations)
1066 Reference
<XPropertySetInfo
> xPropSetInfo(rPropSet
->getPropertySetInfo());
1068 OUString sPresentation
= rTextField
->getPresentation(sal_False
);
1070 // process each field type
1072 case FIELD_ID_AUTHOR
:
1073 // author field: fixed, field (sub-)type
1074 ProcessBoolean(XML_FIXED
,
1075 GetBoolProperty(sPropertyIsFixed
, rPropSet
), true);
1076 ExportElement(MapAuthorFieldName(rPropSet
), sPresentation
);
1079 case FIELD_ID_SENDER
:
1080 // sender field: fixed, field (sub-)type
1081 ProcessBoolean(XML_FIXED
,
1082 GetBoolProperty(sPropertyIsFixed
, rPropSet
), true);
1083 ExportElement(MapSenderFieldName(rPropSet
), sPresentation
);
1086 case FIELD_ID_PLACEHOLDER
:
1087 // placeholder field: type, name, description
1088 ProcessString(XML_PLACEHOLDER_TYPE
,
1090 GetInt16Property(sPropertyPlaceholderType
, rPropSet
)));
1091 ProcessString(XML_DESCRIPTION
,
1092 GetStringProperty(sPropertyHint
,rPropSet
), true);
1093 ExportElement(XML_PLACEHOLDER
, sPresentation
);
1096 case FIELD_ID_VARIABLE_SET
:
1098 // variable set field: name, visible, format&value
1099 ProcessString(XML_NAME
,
1100 GetStringProperty(sPropertyVariableName
, rPropSet
));
1101 ProcessDisplay(GetBoolProperty(sPropertyIsVisible
, rPropSet
),
1103 ProcessString(XML_FORMULA
, XML_NAMESPACE_OOOW
,
1104 GetStringProperty(sPropertyContent
, rPropSet
),
1106 ProcessValueAndType(IsStringField(nToken
, rPropSet
),
1107 GetIntProperty(sPropertyNumberFormat
, rPropSet
),
1108 GetStringProperty(sPropertyContent
, rPropSet
),
1110 GetDoubleProperty(sPropertyValue
, rPropSet
),
1112 ! GetOptionalBoolProperty(
1113 sPropertyIsFixedLanguage
,
1114 rPropSet
, xPropSetInfo
, false ) );
1115 ExportElement(XML_VARIABLE_SET
, sPresentation
);
1118 case FIELD_ID_VARIABLE_GET
:
1120 // variable get field: name, format&value
1121 ProcessString(XML_NAME
,
1122 GetStringProperty(sPropertyContent
, rPropSet
));
1123 bool bCmd
= GetBoolProperty(sPropertyIsShowFormula
, rPropSet
);
1124 ProcessDisplay(true, bCmd
);
1125 // #i81766# for older versions export of the value-type
1126 bool bExportValueType
= !bCmd
&& ( GetExport().getExportFlags() & SvXMLExportFlags::SAVEBACKWARDCOMPATIBLE
);
1127 // show style, unless name will be shown
1128 ProcessValueAndType(IsStringField(nToken
, rPropSet
),
1129 GetIntProperty(sPropertyNumberFormat
, rPropSet
),
1130 sEmpty
, sEmpty
, 0.0, // values not used
1134 ! GetOptionalBoolProperty(
1135 sPropertyIsFixedLanguage
,
1136 rPropSet
, xPropSetInfo
, false ) );
1137 ExportElement(XML_VARIABLE_GET
, sPresentation
);
1140 case FIELD_ID_VARIABLE_INPUT
:
1141 // variable input field: name, description, format&value
1142 ProcessString(XML_NAME
,
1143 GetStringProperty(sPropertyVariableName
, rPropSet
));
1144 ProcessString(XML_DESCRIPTION
,
1145 GetStringProperty(sPropertyHint
, rPropSet
));
1146 ProcessDisplay(GetBoolProperty(sPropertyIsVisible
, rPropSet
),
1148 ProcessString(XML_FORMULA
, XML_NAMESPACE_OOOW
,
1149 GetStringProperty(sPropertyContent
, rPropSet
),
1151 ProcessValueAndType(IsStringField(nToken
, rPropSet
),
1152 GetIntProperty(sPropertyNumberFormat
, rPropSet
),
1153 GetStringProperty(sPropertyContent
, rPropSet
),
1155 GetDoubleProperty(sPropertyValue
, rPropSet
),
1157 ! GetOptionalBoolProperty(
1158 sPropertyIsFixedLanguage
,
1159 rPropSet
, xPropSetInfo
, false ) );
1160 ExportElement(XML_VARIABLE_INPUT
, sPresentation
);
1163 case FIELD_ID_USER_GET
:
1164 // user field: name, hidden, style
1166 bool bCmd
= GetBoolProperty(sPropertyIsShowFormula
, rPropSet
);
1167 ProcessDisplay(GetBoolProperty(sPropertyIsVisible
, rPropSet
),
1169 ProcessValueAndType(IsStringField(nToken
, rPropSet
),
1170 GetIntProperty(sPropertyNumberFormat
, rPropSet
),
1171 sEmpty
, sEmpty
, 0.0, // values not used
1172 false, false, !bCmd
,
1173 ! GetOptionalBoolProperty(
1174 sPropertyIsFixedLanguage
,
1175 rPropSet
, xPropSetInfo
, false ) );
1177 // name from FieldMaster
1178 ProcessString(XML_NAME
,
1179 GetStringProperty(sPropertyName
,
1180 GetMasterPropertySet(rTextField
)));
1181 ExportElement(XML_USER_FIELD_GET
, sPresentation
);
1185 case FIELD_ID_USER_INPUT
:
1186 // user input field: name (from FieldMaster), description
1187 // ProcessString(XML_NAME,
1188 // GetStringProperty(sPropertyName,
1189 // GetMasterPropertySet(rTextField)));
1190 ProcessString(XML_NAME
,
1191 GetStringProperty(sPropertyContent
, rPropSet
));
1192 ProcessString(XML_DESCRIPTION
,
1193 GetStringProperty(sPropertyHint
, rPropSet
));
1194 ExportElement(XML_USER_FIELD_INPUT
, sPresentation
);
1197 case FIELD_ID_SEQUENCE
:
1199 // sequence field: name, formula, seq-format
1200 OUString sName
= GetStringProperty(sPropertyVariableName
, rPropSet
);
1201 // TODO: use reference name only if actually being referenced.
1202 ProcessString(XML_REF_NAME
,
1203 MakeSequenceRefName(
1204 GetInt16Property(sPropertySequenceValue
, rPropSet
),
1206 ProcessString(XML_NAME
, sName
);
1207 ProcessString(XML_FORMULA
, XML_NAMESPACE_OOOW
,
1208 GetStringProperty(sPropertyContent
, rPropSet
),
1210 ProcessNumberingType(GetInt16Property(sPropertyNumberingType
,
1212 ExportElement(XML_SEQUENCE
, sPresentation
);
1216 case FIELD_ID_EXPRESSION
:
1218 // formula field: formula, format&value
1219 bool bCmd
= GetBoolProperty(sPropertyIsShowFormula
, rPropSet
);
1220 ProcessString(XML_FORMULA
, XML_NAMESPACE_OOOW
,
1221 GetStringProperty(sPropertyContent
, rPropSet
),
1223 ProcessDisplay(true, bCmd
);
1224 ProcessValueAndType(IsStringField(nToken
, rPropSet
),
1225 GetIntProperty(sPropertyNumberFormat
, rPropSet
),
1226 GetStringProperty(sPropertyContent
, rPropSet
),
1228 GetDoubleProperty(sPropertyValue
, rPropSet
),
1229 !bCmd
, !bCmd
, !bCmd
,
1230 ! GetOptionalBoolProperty(
1231 sPropertyIsFixedLanguage
,
1232 rPropSet
, xPropSetInfo
, false ) );
1233 ExportElement(XML_EXPRESSION
, sPresentation
);
1237 case FIELD_ID_TEXT_INPUT
:
1238 // text input field: description and string-value
1239 ProcessString(XML_DESCRIPTION
,
1240 GetStringProperty(sPropertyHint
, rPropSet
));
1241 ProcessString(XML_HELP
,
1242 GetStringProperty(sPropertyHelp
, rPropSet
), true);
1243 ProcessString(XML_HINT
,
1244 GetStringProperty(sPropertyTooltip
, rPropSet
), true);
1245 ExportElement(XML_TEXT_INPUT
, sPresentation
);
1249 // all properties (except IsDate) are optional!
1250 if (xPropSetInfo
->hasPropertyByName(sPropertyNumberFormat
))
1252 ProcessValueAndType(false,
1253 GetIntProperty(sPropertyNumberFormat
,rPropSet
),
1254 sEmpty
, sEmpty
, 0.0, // not used
1256 ! GetOptionalBoolProperty(
1257 sPropertyIsFixedLanguage
,
1258 rPropSet
, xPropSetInfo
, false ),
1261 if (xPropSetInfo
->hasPropertyByName(sPropertyDateTimeValue
))
1263 // no value -> current time
1264 ProcessTimeOrDateTime(XML_TIME_VALUE
,
1265 GetDateTimeProperty(sPropertyDateTimeValue
,
1267 XML_NAMESPACE_TEXT
);
1269 if (xPropSetInfo
->hasPropertyByName(sPropertyDateTime
))
1271 // no value -> current time
1272 ProcessTimeOrDateTime(XML_TIME_VALUE
,
1273 GetDateTimeProperty(sPropertyDateTime
,rPropSet
),
1274 XML_NAMESPACE_TEXT
);
1276 if (xPropSetInfo
->hasPropertyByName(sPropertyIsFixed
))
1278 ProcessBoolean(XML_FIXED
,
1279 GetBoolProperty(sPropertyIsFixed
, rPropSet
),
1282 if (xPropSetInfo
->hasPropertyByName(sPropertyAdjust
))
1284 // adjust value given as integer in minutes
1285 ProcessDateTime(XML_TIME_ADJUST
,
1286 GetIntProperty(sPropertyAdjust
, rPropSet
),
1289 ExportElement(XML_TIME
, sPresentation
);
1293 // all properties (except IsDate) are optional!
1294 if (xPropSetInfo
->hasPropertyByName(sPropertyNumberFormat
))
1296 ProcessValueAndType(false,
1297 GetIntProperty(sPropertyNumberFormat
,rPropSet
),
1298 sEmpty
, sEmpty
, 0.0, // not used
1300 ! GetOptionalBoolProperty(
1301 sPropertyIsFixedLanguage
,
1302 rPropSet
, xPropSetInfo
, false ) );
1304 if (xPropSetInfo
->hasPropertyByName(sPropertyDateTimeValue
))
1306 // no value -> current date
1307 ProcessDateTime(XML_DATE_VALUE
,
1308 GetDateTimeProperty(sPropertyDateTimeValue
,
1310 // #96457#: date fields should also save time
1313 // TODO: remove double-handling after SRC614
1314 else if (xPropSetInfo
->hasPropertyByName(sPropertyDateTime
))
1316 ProcessDateTime(XML_DATE_VALUE
,
1317 GetDateTimeProperty(sPropertyDateTime
,rPropSet
),
1318 // #96457#: date fields should also save time
1321 if (xPropSetInfo
->hasPropertyByName(sPropertyIsFixed
))
1323 ProcessBoolean(XML_FIXED
,
1324 GetBoolProperty(sPropertyIsFixed
, rPropSet
),
1327 if (xPropSetInfo
->hasPropertyByName(sPropertyAdjust
))
1329 // adjust value given as number of days
1330 ProcessDateTime(XML_DATE_ADJUST
,
1331 GetIntProperty(sPropertyAdjust
, rPropSet
),
1334 ExportElement(XML_DATE
, sPresentation
);
1337 case FIELD_ID_PAGENUMBER
:
1338 // all properties are optional
1339 if (xPropSetInfo
->hasPropertyByName(sPropertyNumberingType
))
1341 ProcessNumberingType(GetInt16Property(sPropertyNumberingType
,
1344 if (xPropSetInfo
->hasPropertyByName(sPropertyOffset
))
1346 sal_Int32 nAdjust
= GetIntProperty(sPropertyOffset
, rPropSet
);
1348 if (xPropSetInfo
->hasPropertyByName(sPropertySubType
))
1350 // property SubType used in MapPageNumebrName
1351 ProcessString(XML_SELECT_PAGE
,
1352 MapPageNumberName(rPropSet
, nAdjust
));
1354 ProcessIntegerDef(XML_PAGE_ADJUST
, nAdjust
, 0);
1356 ExportElement(XML_PAGE_NUMBER
, sPresentation
);
1359 case FIELD_ID_PAGESTRING
:
1361 ProcessString(XML_STRING_VALUE
,
1362 GetStringProperty(sPropertyUserText
, rPropSet
),
1364 sal_Int32 nDummy
= 0; // MapPageNumberName need int
1365 ProcessString(XML_SELECT_PAGE
, MapPageNumberName(rPropSet
, nDummy
));
1366 if( !( GetExport().getExportFlags() & SvXMLExportFlags::SAVEBACKWARDCOMPATIBLE
) )
1367 ExportElement(XML_PAGE_CONTINUATION
, sPresentation
);
1369 ExportElement(XML_PAGE_CONTINUATION_STRING
, sPresentation
);
1373 case FIELD_ID_DATABASE_NAME
:
1374 ProcessString(XML_TABLE_NAME
,
1375 GetStringProperty(sPropertyDataTableName
, rPropSet
));
1376 ProcessCommandType(GetIntProperty(sPropertyDataCommandType
, rPropSet
));
1377 ProcessDisplay(GetBoolProperty(sPropertyIsVisible
, rPropSet
),
1379 ExportDataBaseElement(XML_DATABASE_NAME
, sPresentation
,
1380 rPropSet
, xPropSetInfo
);
1383 case FIELD_ID_DATABASE_NUMBER
:
1384 ProcessString(XML_TABLE_NAME
,
1385 GetStringProperty(sPropertyDataTableName
, rPropSet
));
1386 ProcessCommandType(GetIntProperty(sPropertyDataCommandType
, rPropSet
));
1387 ProcessNumberingType(
1388 GetInt16Property(sPropertyNumberingType
,rPropSet
));
1389 ProcessInteger(XML_VALUE
,
1390 GetIntProperty(sPropertySetNumber
, rPropSet
));
1391 ProcessDisplay(GetBoolProperty(sPropertyIsVisible
, rPropSet
),
1393 ExportDataBaseElement(XML_DATABASE_ROW_NUMBER
, sPresentation
,
1394 rPropSet
, xPropSetInfo
);
1397 case FIELD_ID_DATABASE_NEXT
:
1398 ProcessString(XML_TABLE_NAME
,
1399 GetStringProperty(sPropertyDataTableName
, rPropSet
));
1400 ProcessCommandType(GetIntProperty(sPropertyDataCommandType
, rPropSet
));
1401 ProcessString(XML_CONDITION
, XML_NAMESPACE_OOOW
,
1402 GetStringProperty(sPropertyCondition
, rPropSet
));
1403 DBG_ASSERT(sPresentation
.equals(sEmpty
),
1404 "Unexpected presentation for database next field");
1405 ExportDataBaseElement(XML_DATABASE_NEXT
, OUString(),
1406 rPropSet
, xPropSetInfo
);
1409 case FIELD_ID_DATABASE_SELECT
:
1410 ProcessString(XML_TABLE_NAME
,
1411 GetStringProperty(sPropertyDataTableName
, rPropSet
));
1412 ProcessCommandType(GetIntProperty(sPropertyDataCommandType
, rPropSet
));
1413 ProcessString(XML_CONDITION
, XML_NAMESPACE_OOOW
,
1414 GetStringProperty(sPropertyCondition
, rPropSet
));
1415 ProcessInteger(XML_ROW_NUMBER
,
1416 GetIntProperty(sPropertySetNumber
, rPropSet
));
1417 DBG_ASSERT(sPresentation
.equals(sEmpty
),
1418 "Unexpected presentation for database select field");
1419 ExportDataBaseElement(XML_DATABASE_ROW_SELECT
, OUString(),
1420 rPropSet
, xPropSetInfo
);
1423 case FIELD_ID_DATABASE_DISPLAY
:
1425 // get database, table and column name from field master
1426 const Reference
<XPropertySet
> & xMaster
= GetMasterPropertySet(rTextField
);
1427 ProcessString(XML_TABLE_NAME
,
1428 GetStringProperty(sPropertyDataTableName
, xMaster
));
1429 ProcessCommandType(GetIntProperty(sPropertyDataCommandType
, xMaster
));
1430 ProcessString(XML_COLUMN_NAME
,
1431 GetStringProperty(sPropertyDataColumnName
, xMaster
));
1432 // export number format if available (happens only for numbers!)
1433 if (!GetBoolProperty(sPropertyIsDataBaseFormat
, rPropSet
))
1435 ProcessValueAndType(false, // doesn't happen for text
1436 GetIntProperty(sPropertyNumberFormat
,rPropSet
),
1437 sEmpty
, sEmpty
, 0.0, // not used
1438 false, false, true, false);
1440 ProcessDisplay(GetBoolProperty(sPropertyIsVisible
, rPropSet
),
1442 ExportDataBaseElement(XML_DATABASE_DISPLAY
, sPresentation
,
1443 xMaster
, xMaster
->getPropertySetInfo());
1447 case FIELD_ID_DOCINFO_REVISION
:
1448 ProcessBoolean(XML_FIXED
,
1449 GetBoolProperty(sPropertyIsFixed
, rPropSet
), false);
1450 ExportElement(MapDocInfoFieldName(nToken
), sPresentation
);
1453 case FIELD_ID_DOCINFO_EDIT_DURATION
:
1454 case FIELD_ID_DOCINFO_SAVE_TIME
:
1455 case FIELD_ID_DOCINFO_CREATION_TIME
:
1456 case FIELD_ID_DOCINFO_PRINT_TIME
:
1457 case FIELD_ID_DOCINFO_SAVE_DATE
:
1458 case FIELD_ID_DOCINFO_CREATION_DATE
:
1459 case FIELD_ID_DOCINFO_PRINT_DATE
:
1460 ProcessValueAndType(false,
1461 GetIntProperty(sPropertyNumberFormat
, rPropSet
),
1462 sEmpty
, sEmpty
, 0.0,
1464 ! GetOptionalBoolProperty(
1465 sPropertyIsFixedLanguage
,
1466 rPropSet
, xPropSetInfo
, false ) );
1468 // todo: export date/time value, but values not available -> core bug
1469 ProcessBoolean(XML_FIXED
,
1470 GetBoolProperty(sPropertyIsFixed
, rPropSet
), false);
1471 ExportElement(MapDocInfoFieldName(nToken
), sPresentation
);
1474 case FIELD_ID_DOCINFO_CREATION_AUTHOR
:
1475 case FIELD_ID_DOCINFO_DESCRIPTION
:
1476 case FIELD_ID_DOCINFO_PRINT_AUTHOR
:
1477 case FIELD_ID_DOCINFO_TITLE
:
1478 case FIELD_ID_DOCINFO_SUBJECT
:
1479 case FIELD_ID_DOCINFO_KEYWORDS
:
1480 case FIELD_ID_DOCINFO_SAVE_AUTHOR
:
1481 if (xPropSetInfo
->hasPropertyByName(sPropertyIsFixed
))
1483 ProcessBoolean(XML_FIXED
,
1484 GetBoolProperty(sPropertyIsFixed
, rPropSet
), false);
1486 ExportElement(MapDocInfoFieldName(nToken
), sPresentation
);
1489 case FIELD_ID_DOCINFO_CUSTOM
:
1491 ProcessValueAndType(false, // doesn't happen for text
1492 GetIntProperty(sPropertyNumberFormat
,rPropSet
),
1493 sEmpty
, sEmpty
, 0.0, // not used
1495 ! GetOptionalBoolProperty(
1496 sPropertyIsFixedLanguage
,
1497 rPropSet
, xPropSetInfo
, false ));
1498 uno::Any aAny
= rPropSet
->getPropertyValue( sPropertyName
);
1501 ProcessString(XML_NAME
, sName
);
1502 ProcessBoolean(XML_FIXED
, GetBoolProperty(sPropertyIsFixed
, rPropSet
), false);
1503 ExportElement(XML_USER_DEFINED
, sPresentation
);
1507 case FIELD_ID_COUNT_PAGES
:
1508 case FIELD_ID_COUNT_PARAGRAPHS
:
1509 case FIELD_ID_COUNT_WORDS
:
1510 case FIELD_ID_COUNT_CHARACTERS
:
1511 case FIELD_ID_COUNT_TABLES
:
1512 case FIELD_ID_COUNT_GRAPHICS
:
1513 case FIELD_ID_COUNT_OBJECTS
:
1514 // all properties optional (applies to pages only, but I'll do
1515 // it for all for sake of common implementation)
1516 if (xPropSetInfo
->hasPropertyByName(sPropertyNumberingType
))
1518 ProcessNumberingType(GetInt16Property(sPropertyNumberingType
,
1521 ExportElement(MapCountFieldName(nToken
), sPresentation
);
1524 case FIELD_ID_CONDITIONAL_TEXT
:
1525 ProcessString(XML_CONDITION
, XML_NAMESPACE_OOOW
,
1526 GetStringProperty(sPropertyCondition
, rPropSet
));
1527 ProcessString(XML_STRING_VALUE_IF_TRUE
,
1528 GetStringProperty(sPropertyTrueContent
, rPropSet
));
1529 ProcessString(XML_STRING_VALUE_IF_FALSE
,
1530 GetStringProperty(sPropertyFalseContent
, rPropSet
));
1531 ProcessBoolean(XML_CURRENT_VALUE
,
1532 GetBoolProperty(sPropertyIsConditionTrue
, rPropSet
),
1534 ExportElement(XML_CONDITIONAL_TEXT
, sPresentation
);
1537 case FIELD_ID_HIDDEN_TEXT
:
1538 ProcessString(XML_CONDITION
, XML_NAMESPACE_OOOW
,
1539 GetStringProperty(sPropertyCondition
, rPropSet
));
1540 ProcessString(XML_STRING_VALUE
,
1541 GetStringProperty(sPropertyContent
, rPropSet
));
1542 ProcessBoolean(XML_IS_HIDDEN
,
1543 GetBoolProperty(sPropertyIsHidden
, rPropSet
),
1545 ExportElement(XML_HIDDEN_TEXT
, sPresentation
);
1548 case FIELD_ID_HIDDEN_PARAGRAPH
:
1549 ProcessString(XML_CONDITION
, XML_NAMESPACE_OOOW
,
1550 GetStringProperty(sPropertyCondition
, rPropSet
));
1551 ProcessBoolean(XML_IS_HIDDEN
,
1552 GetBoolProperty(sPropertyIsHidden
, rPropSet
),
1554 DBG_ASSERT(sPresentation
.equals(sEmpty
),
1555 "Unexpected presentation for hidden paragraph field");
1556 ExportElement(XML_HIDDEN_PARAGRAPH
);
1559 case FIELD_ID_TEMPLATE_NAME
:
1560 ProcessString(XML_DISPLAY
,
1561 MapTemplateDisplayFormat(
1562 GetInt16Property(sPropertyFileFormat
, rPropSet
)));
1563 ExportElement(XML_TEMPLATE_NAME
, sPresentation
);
1566 case FIELD_ID_CHAPTER
:
1567 ProcessString(XML_DISPLAY
,
1568 MapChapterDisplayFormat(
1569 GetInt16Property(sPropertyChapterFormat
, rPropSet
)));
1570 // API numbers 0..9, we number 1..10
1571 ProcessInteger(XML_OUTLINE_LEVEL
,
1572 GetInt8Property(sPropertyLevel
, rPropSet
) + 1);
1573 ExportElement(XML_CHAPTER
, sPresentation
);
1576 case FIELD_ID_FILE_NAME
:
1577 // all properties are optional
1578 if (xPropSetInfo
->hasPropertyByName(sPropertyFileFormat
))
1580 ProcessString(XML_DISPLAY
,
1581 MapFilenameDisplayFormat(
1582 GetInt16Property(sPropertyFileFormat
, rPropSet
)));
1584 if (xPropSetInfo
->hasPropertyByName(sPropertyIsFixed
))
1586 ProcessBoolean(XML_FIXED
,
1587 GetBoolProperty(sPropertyIsFixed
, rPropSet
),
1590 ExportElement(XML_FILE_NAME
, sPresentation
);
1593 case FIELD_ID_REFPAGE_SET
:
1594 ProcessBoolean(XML_ACTIVE
,
1595 GetBoolProperty(sPropertyOn
, rPropSet
), true);
1596 ProcessIntegerDef(XML_PAGE_ADJUST
,
1597 GetInt16Property(sPropertyOffset
, rPropSet
), 0);
1598 DBG_ASSERT(sPresentation
.equals(sEmpty
),
1599 "Unexpected presentation page variable field");
1600 ExportElement(XML_PAGE_VARIABLE_SET
);
1603 case FIELD_ID_REFPAGE_GET
:
1604 ProcessNumberingType(
1605 GetInt16Property(sPropertyNumberingType
, rPropSet
));
1606 ExportElement(XML_PAGE_VARIABLE_GET
, sPresentation
);
1609 case FIELD_ID_MACRO
:
1610 ExportMacro( rPropSet
, sPresentation
);
1613 case FIELD_ID_REF_SEQUENCE
:
1614 // reference to sequence: format, name, find value (and element)
1615 // was: if (nSeqNumber != -1) ...
1616 ProcessString(XML_REFERENCE_FORMAT
,
1617 MapReferenceType(GetInt16Property(
1618 sPropertyReferenceFieldPart
, rPropSet
)),
1620 ProcessString(XML_REF_NAME
,
1621 MakeSequenceRefName(
1622 GetInt16Property(sPropertySequenceNumber
, rPropSet
),
1623 GetStringProperty(sPropertySourceName
, rPropSet
) ) );
1626 GetInt16Property(sPropertyReferenceFieldSource
, rPropSet
)),
1630 case FIELD_ID_REF_REFERENCE
:
1631 case FIELD_ID_REF_BOOKMARK
:
1632 // reference to bookmarks, references: format, name (and element)
1633 ProcessString(XML_REFERENCE_FORMAT
,
1634 MapReferenceType(GetInt16Property(
1635 sPropertyReferenceFieldPart
, rPropSet
)),
1637 ProcessString(XML_REF_NAME
,
1638 GetStringProperty(sPropertySourceName
, rPropSet
));
1640 MapReferenceSource(GetInt16Property(
1641 sPropertyReferenceFieldSource
, rPropSet
)),
1645 case FIELD_ID_REF_FOOTNOTE
:
1646 case FIELD_ID_REF_ENDNOTE
:
1647 // reference to end-/footnote: format, generate name, (and element)
1648 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_NOTE_CLASS
,
1649 FIELD_ID_REF_ENDNOTE
==nToken
? XML_ENDNOTE
: XML_FOOTNOTE
);
1650 ProcessString(XML_REFERENCE_FORMAT
,
1651 MapReferenceType(GetInt16Property(
1652 sPropertyReferenceFieldPart
, rPropSet
)),
1654 ProcessString(XML_REF_NAME
,
1655 MakeFootnoteRefName(GetInt16Property(
1656 sPropertySequenceNumber
, rPropSet
)));
1658 MapReferenceSource(GetInt16Property(
1659 sPropertyReferenceFieldSource
, rPropSet
)),
1664 // name from field master
1665 ProcessString(XML_CONNECTION_NAME
,
1667 GetStringProperty(sPropertyName
,
1668 GetMasterPropertySet(rTextField
)));
1669 ExportElement(XML_DDE_CONNECTION
, sPresentation
);
1672 case FIELD_ID_SHEET_NAME
:
1673 // name of spreadsheet (Calc only)
1674 ExportElement(XML_SHEET_NAME
, sPresentation
);
1677 case FIELD_ID_PAGENAME
:
1679 if (SvtSaveOptions().GetODFDefaultVersion() > SvtSaveOptions::ODFVER_012
)
1681 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_LO_EXT
, XML_PAGE_NAME
, false, false );
1682 GetExport().Characters( sPresentation
);
1689 // this field is a special case because it gets mapped onto a
1690 // hyperlink, rather than one of the regular text field.
1691 ProcessString(XML_HREF
, GetExport().GetRelativeReference(GetStringProperty(sPropertyURL
, rPropSet
)),
1692 false, XML_NAMESPACE_XLINK
);
1693 ProcessString(XML_TARGET_FRAME_NAME
,
1694 GetStringProperty(sPropertyTargetFrame
,rPropSet
),
1695 true, XML_NAMESPACE_OFFICE
);
1696 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_TYPE
, XML_SIMPLE
);
1697 SvXMLElementExport
aUrlField(rExport
, XML_NAMESPACE_TEXT
, XML_A
,
1699 GetExport().Characters(sPresentation
);
1703 case FIELD_ID_BIBLIOGRAPHY
:
1705 ProcessBibliographyData(rPropSet
);
1706 ExportElement(XML_BIBLIOGRAPHY_MARK
, sPresentation
);
1710 case FIELD_ID_SCRIPT
:
1711 ProcessString(XML_LANGUAGE
,
1712 GetStringProperty(sPropertyScriptType
, rPropSet
),
1713 true, XML_NAMESPACE_SCRIPT
);
1714 DBG_ASSERT(sPresentation
.equals(sEmpty
),
1715 "Unexpected presentation for script field");
1716 if (GetBoolProperty(sPropertyURLContent
, rPropSet
))
1718 ProcessString(XML_HREF
,
1719 GetExport().GetRelativeReference(GetStringProperty(sPropertyContent
, rPropSet
)),
1720 false, XML_NAMESPACE_XLINK
);
1721 ExportElement(XML_SCRIPT
);
1725 ExportElement(XML_SCRIPT
,
1726 GetStringProperty(sPropertyContent
, rPropSet
));
1730 case FIELD_ID_ANNOTATION
:
1732 // check for empty presentation (just in case)
1733 DBG_ASSERT(sPresentation
.equals(sEmpty
),
1734 "Unexpected presentation for annotation field");
1736 // annotation element + content
1738 rPropSet
->getPropertyValue(sPropertyName
) >>= aName
;
1739 if (!aName
.isEmpty())
1740 GetExport().AddAttribute(XML_NAMESPACE_OFFICE
, XML_NAME
, aName
);
1741 SvXMLElementExport
aElem(GetExport(), XML_NAMESPACE_OFFICE
,
1742 XML_ANNOTATION
, false, true);
1745 OUString
aAuthor( GetStringProperty(sPropertyAuthor
, rPropSet
) );
1746 if( !aAuthor
.isEmpty() )
1748 SvXMLElementExport
aCreatorElem( GetExport(), XML_NAMESPACE_DC
,
1751 GetExport().Characters(aAuthor
);
1755 util::DateTime
aDate( GetDateTimeProperty(sPropertyDateTimeValue
, rPropSet
) );
1757 OUStringBuffer aBuffer
;
1758 ::sax::Converter::convertDateTime(aBuffer
, aDate
, 0, true);
1759 SvXMLElementExport
aDateElem( GetExport(), XML_NAMESPACE_DC
,
1762 GetExport().Characters(aBuffer
.makeStringAndClear());
1765 if (SvtSaveOptions().GetODFDefaultVersion() > SvtSaveOptions::ODFVER_012
)
1768 OUString
aInitials( GetStringProperty(sPropertyInitials
, rPropSet
) );
1769 if( !aInitials
.isEmpty() )
1771 SvXMLElementExport
aCreatorElem( GetExport(), XML_NAMESPACE_LO_EXT
,
1772 XML_SENDER_INITIALS
, true,
1774 GetExport().Characters(aInitials
);
1778 com::sun::star::uno::Reference
< com::sun::star::text::XText
> xText
;
1781 com::sun::star::uno::Any aRet
= rPropSet
->getPropertyValue(sPropertyTextRange
);
1784 catch ( com::sun::star::uno::Exception
& )
1788 GetExport().GetTextParagraphExport()->exportText( xText
);
1790 ProcessParagraphSequence(GetStringProperty(sPropertyContent
,rPropSet
));
1794 case FIELD_ID_COMBINED_CHARACTERS
:
1796 // The style with the combined characters attribute has
1797 // already been handled in the ExportField method. So all that
1798 // is left to do now is to export the characters.
1799 GetExport().Characters(sPresentation
);
1805 ExportMetaField(rPropSet
, false, bProgress
);
1809 case FIELD_ID_MEASURE
:
1811 ProcessString(XML_KIND
, MapMeasureKind(GetInt16Property(sPropertyMeasureKind
, rPropSet
)));
1812 ExportElement( XML_MEASURE
, sPresentation
);
1816 case FIELD_ID_TABLE_FORMULA
:
1817 ProcessString( XML_FORMULA
, XML_NAMESPACE_OOOW
,
1818 GetStringProperty(sPropertyContent
, rPropSet
) );
1819 ProcessDisplay( true,
1820 GetBoolProperty(sPropertyIsShowFormula
, rPropSet
),
1822 ProcessValueAndType( false,
1823 GetIntProperty(sPropertyNumberFormat
, rPropSet
),
1824 sEmpty
, sEmpty
, 0.0f
,
1827 ExportElement( XML_TABLE_FORMULA
, sPresentation
);
1830 case FIELD_ID_DROP_DOWN
:
1832 ProcessString(XML_NAME
, GetStringProperty(sPropertyName
, rPropSet
));
1833 ProcessString(XML_HELP
,
1834 GetStringProperty(sPropertyHelp
, rPropSet
), true);
1835 ProcessString(XML_HINT
,
1836 GetStringProperty(sPropertyTooltip
, rPropSet
), true);
1837 SvXMLElementExport
aElem( GetExport(),
1838 XML_NAMESPACE_TEXT
, XML_DROP_DOWN
,
1840 ProcessStringSequence
1841 (GetStringSequenceProperty( sPropertyItems
, rPropSet
),
1842 GetStringProperty( sPropertySelectedItem
, rPropSet
) );
1844 GetExport().Characters( sPresentation
);
1848 case FIELD_ID_DRAW_HEADER
:
1850 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_PRESENTATION
, XML_HEADER
, false, false );
1854 case FIELD_ID_DRAW_FOOTER
:
1856 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_PRESENTATION
, XML_FOOTER
, false, false );
1860 case FIELD_ID_DRAW_DATE_TIME
:
1862 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_PRESENTATION
, XML_DATE_TIME
, false, false );
1867 case FIELD_ID_UNKNOWN
:
1869 OSL_FAIL("unknown field type encountered!");
1870 // always export content
1871 GetExport().Characters(sPresentation
);
1876 /// export field declarations / field masters
1877 void XMLTextFieldExport::ExportFieldDeclarations()
1879 Reference
<XText
> xEmptyText
;
1880 ExportFieldDeclarations(xEmptyText
);
1883 /// export field declarations / field masters
1884 void XMLTextFieldExport::ExportFieldDeclarations(
1885 const Reference
<XText
> & rText
)
1887 // store lists for decl elements
1888 vector
<OUString
> aVarName
;
1889 vector
<OUString
> aUserName
;
1890 vector
<OUString
> aSeqName
;
1891 vector
<OUString
> aDdeName
;
1893 // get text fields supplier and field master name access
1894 Reference
<XTextFieldsSupplier
> xTextFieldsSupp(GetExport().GetModel(),
1896 if( !xTextFieldsSupp
.is() )
1899 Reference
<container::XNameAccess
> xFieldMasterNameAccess(
1900 xTextFieldsSupp
->getTextFieldMasters(), UNO_QUERY
);
1902 // where to get the text field masters from?
1903 // a) we get a specific XText: then use pUsedMasters
1904 // b) the XText is empty: then export all text fields
1905 Sequence
<OUString
> aFieldMasters
;
1908 // export only used masters
1909 DBG_ASSERT(NULL
!= pUsedMasters
,
1910 "field masters must be recorded in order to be "
1911 "written out separatly" );
1912 if (NULL
!= pUsedMasters
)
1914 map
<Reference
<XText
>, set
<OUString
> > ::iterator aMapIter
=
1915 pUsedMasters
->find(rText
);
1916 if (aMapIter
!= pUsedMasters
->end())
1918 // found the set of used field masters
1919 set
<OUString
> & rOurMasters
= aMapIter
->second
;
1921 // copy set to sequence
1922 aFieldMasters
.realloc( rOurMasters
.size() );
1924 for( set
<OUString
>::iterator aSetIter
= rOurMasters
.begin();
1925 aSetIter
!= rOurMasters
.end();
1928 aFieldMasters
[i
] = *aSetIter
;
1931 pUsedMasters
->erase(rText
);
1933 // else: XText not found -> ignore
1935 // else: no field masters have been recorded -> ignore
1939 // no XText: export all!
1940 aFieldMasters
= xFieldMasterNameAccess
->getElementNames();
1943 for(sal_Int32 i
=0; i
<aFieldMasters
.getLength(); i
++) {
1945 // get field master name
1946 OUString sFieldMaster
= aFieldMasters
[i
];
1948 // workaround for #no-bug#
1949 if ( sFieldMaster
.startsWithIgnoreAsciiCase(
1950 "com.sun.star.text.FieldMaster.DataBase.") )
1956 OUString sFieldMasterType
;
1958 ExplodeFieldMasterName(sFieldMaster
, sFieldMasterType
, sVarName
);
1960 // get XPropertySet of this field master
1961 Reference
<XPropertySet
> xPropSet
;
1962 Any aAny
= xFieldMasterNameAccess
->getByName(sFieldMaster
);
1965 // save interesting field masters
1966 if (sFieldMasterType
== FIELD_SERVICE_SETEXP
)
1968 sal_Int32 nType
= GetIntProperty(sPropertySubType
, xPropSet
);
1970 // sequence or variable?
1971 if ( SetVariableType::SEQUENCE
== nType
)
1973 aSeqName
.push_back( sFieldMaster
);
1977 aVarName
.push_back( sFieldMaster
);
1980 else if (sFieldMasterType
== FIELD_SERVICE_USER
)
1982 aUserName
.push_back( sFieldMaster
);
1984 else if (sFieldMasterType
== FIELD_SERVICE_DDE
)
1986 aDdeName
.push_back( sFieldMaster
);
1994 // now process fields:
1996 // variable field masters:
1997 if ( !aVarName
.empty() )
1999 SvXMLElementExport
aElem( GetExport(),
2004 for (vector
<OUString
>::iterator aVarIter
= aVarName
.begin();
2005 aVarIter
!= aVarName
.end();
2008 OUString sName
= *aVarIter
;
2010 // get field master property set
2011 Reference
<XPropertySet
> xPropSet
;
2012 Any aAny
= xFieldMasterNameAccess
->getByName(sName
);
2015 // field name and type
2016 OUString sFieldMasterType
;
2018 ExplodeFieldMasterName(sName
, sFieldMasterType
, sVarName
);
2020 // determine string/numeric field
2021 bool bIsString
= ( GetIntProperty(sPropertySubType
, xPropSet
)
2022 == SetVariableType::STRING
);
2024 // get dependent field property set
2025 Reference
<XPropertySet
> xFieldPropSet
;
2026 if (GetDependentFieldPropertySet(xPropSet
, xFieldPropSet
))
2028 // process value and type.
2029 ProcessValueAndType(
2031 GetIntProperty(sPropertyNumberFormat
, xFieldPropSet
),
2032 sEmpty
, sEmpty
, 0.0,
2033 false, true, false, false);
2037 // If no dependent field is found, only string and
2038 // float types can be supported
2040 // number format: 0 is default number format for 1st
2041 // language. should be: getDefaultNumberFormat(Locale)
2042 // from NumberFormats
2043 ProcessValueAndType(
2045 0, sEmpty
, sEmpty
, 0.0,
2046 false, true, false, false);
2049 ProcessString(XML_NAME
, sVarName
);
2050 ExportElement(XML_VARIABLE_DECL
, true);
2053 // else: no declarations element
2055 // sequence field masters:
2056 if ( !aSeqName
.empty() )
2058 SvXMLElementExport
aElem( GetExport(),
2063 for (vector
<OUString
>::iterator aSeqIter
= aSeqName
.begin();
2064 aSeqIter
!= aSeqName
.end();
2067 OUString sName
= *aSeqIter
;
2069 // get field master property set
2070 Reference
<XPropertySet
> xPropSet
;
2071 Any aAny
= xFieldMasterNameAccess
->getByName(sName
);
2074 // field name and type
2075 OUString sFieldMasterType
;
2077 ExplodeFieldMasterName(sName
, sFieldMasterType
, sVarName
);
2080 sal_Int32 nLevel
= 1 + GetIntProperty(
2081 sPropertyChapterNumberingLevel
, xPropSet
);
2082 DBG_ASSERT(nLevel
>= 0, "illegal outline level");
2083 DBG_ASSERT(nLevel
< 127, "possible illegal outline level");
2084 ProcessInteger(XML_DISPLAY_OUTLINE_LEVEL
, nLevel
);
2086 // separation character
2088 ProcessString(XML_SEPARATION_CHARACTER
, GetStringProperty(
2089 sPropertyNumberingSeparator
, xPropSet
));
2091 ProcessString(XML_NAME
, sVarName
);
2092 ExportElement(XML_SEQUENCE_DECL
, true);
2095 // else: no declarations element
2097 // user field field masters:
2098 if ( !aUserName
.empty() )
2100 SvXMLElementExport
aElem( GetExport(),
2102 XML_USER_FIELD_DECLS
,
2105 for (vector
<OUString
>::iterator aUserIter
= aUserName
.begin();
2106 aUserIter
!= aUserName
.end();
2109 OUString sName
= *aUserIter
;
2111 // get field master property set
2112 Reference
<XPropertySet
> xPropSet
;
2113 Any aAny
= xFieldMasterNameAccess
->getByName(sName
);
2116 // field name and type
2117 OUString sFieldMasterType
;
2119 ExplodeFieldMasterName(sName
, sFieldMasterType
, sVarName
);
2121 if (GetBoolProperty(sPropertyIsExpression
, xPropSet
))
2124 ProcessValueAndType(
2127 GetDoubleProperty(sPropertyValue
, xPropSet
),
2135 // string: write regardless of default
2136 ProcessString(XML_VALUE_TYPE
, XML_STRING
, false,
2137 XML_NAMESPACE_OFFICE
);
2138 ProcessString(XML_STRING_VALUE
,
2139 GetStringProperty(sPropertyContent
, xPropSet
),
2140 false, XML_NAMESPACE_OFFICE
);
2142 ProcessString(XML_NAME
, sVarName
);
2143 ExportElement(XML_USER_FIELD_DECL
, true);
2146 // else: no declarations element
2148 // DDE field field masters:
2149 if ( !aDdeName
.empty() )
2151 SvXMLElementExport
aElem( GetExport(),
2153 XML_DDE_CONNECTION_DECLS
,
2156 for (vector
<OUString
>::iterator aDdeIter
= aDdeName
.begin();
2157 aDdeIter
!= aDdeName
.end();
2160 OUString sName
= *aDdeIter
;
2162 // get field master property set
2163 Reference
<XPropertySet
> xPropSet
;
2164 Any aAny
= xFieldMasterNameAccess
->getByName(sName
);
2167 // check if this connection is being used by a field
2168 Reference
<XPropertySet
> xDummy
;
2169 if (GetDependentFieldPropertySet(xPropSet
, xDummy
))
2172 ProcessString(XML_NAME
,
2173 GetStringProperty(sPropertyName
, xPropSet
),
2174 false, XML_NAMESPACE_OFFICE
);
2176 // export elements; can't use ProcessString because
2177 // elements are in office namespace
2178 ProcessString(XML_DDE_APPLICATION
,
2179 GetStringProperty(sPropertyDDECommandType
,
2181 false, XML_NAMESPACE_OFFICE
);
2182 ProcessString(XML_DDE_TOPIC
,
2183 GetStringProperty(sPropertyDDECommandFile
,
2185 false, XML_NAMESPACE_OFFICE
);
2186 ProcessString(XML_DDE_ITEM
,
2187 GetStringProperty(sPropertyDDECommandElement
,
2189 false, XML_NAMESPACE_OFFICE
);
2190 bool bIsAutomaticUpdate
= GetBoolProperty(
2191 sPropertyIsAutomaticUpdate
, xPropSet
);
2192 if (bIsAutomaticUpdate
)
2194 GetExport().AddAttribute(XML_NAMESPACE_OFFICE
,
2195 XML_AUTOMATIC_UPDATE
,
2199 ExportElement(XML_DDE_CONNECTION_DECL
, true);
2201 // else: no dependent field -> no export of field declaration
2204 // else: no declarations element
2207 void XMLTextFieldExport::SetExportOnlyUsedFieldDeclarations(
2208 bool bExportOnlyUsed
)
2210 delete pUsedMasters
;
2211 pUsedMasters
= NULL
;
2213 // create used masters set (if none is used)
2214 if (bExportOnlyUsed
)
2215 pUsedMasters
= new map
<Reference
<XText
>, set
<OUString
> > ;
2218 void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName
,
2221 // can't call ExportElement(eElementName, const OUString&) with empty
2222 // string because xmlprinter only uses empty tags if no content
2223 // (not even empty content) was written.
2225 DBG_ASSERT(XML_TOKEN_INVALID
!= eElementName
, "invalid element name!");
2226 if (XML_TOKEN_INVALID
!= eElementName
)
2229 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
2230 eElementName
, bAddSpace
, bAddSpace
);
2234 void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName
,
2235 const OUString
& sContent
,
2238 DBG_ASSERT(eElementName
!= XML_TOKEN_INVALID
, "invalid element name!");
2239 if (eElementName
!= XML_TOKEN_INVALID
)
2242 if (eElementName
== XML_SENDER_INITIALS
)
2244 if (SvtSaveOptions().GetODFDefaultVersion() > SvtSaveOptions::ODFVER_012
)
2246 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_LO_EXT
,
2247 eElementName
, bAddSpace
, bAddSpace
);
2249 GetExport().Characters(sContent
);
2254 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
2255 eElementName
, bAddSpace
, bAddSpace
);
2257 GetExport().Characters(sContent
);
2260 // always export content
2261 GetExport().Characters(sContent
);
2265 void XMLTextFieldExport::ExportMacro(
2266 const Reference
<XPropertySet
> & rPropSet
,
2267 const OUString
& rContent
)
2269 // some strings we'll need
2270 OUString
sEventType( "EventType" );
2271 OUString
sStarBasic( "StarBasic" );
2272 OUString
sScript( "Script" );
2273 OUString
sLibrary( "Library" );
2274 OUString
sMacroName( "MacroName" );
2275 OUString
sOnClick( "OnClick" );
2276 OUString
sPropertyMacroLibrary( "MacroLibrary" );
2277 OUString
sPropertyMacroName( "MacroName" );
2278 OUString
sPropertyScriptURL( "ScriptURL" );
2281 // the description attribute
2282 ProcessString(XML_DESCRIPTION
,
2283 GetStringProperty(sPropertyHint
, rPropSet
),
2287 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
2288 XML_EXECUTE_MACRO
, false, false );
2290 // the <office:events>-macro:
2292 // 1) build sequence of PropertyValues
2293 Sequence
<PropertyValue
> aSeq
;
2295 rPropSet
->getPropertyValue( sPropertyScriptURL
) >>= sName
;
2297 // if the ScriptURL property is not empty then this is a Scripting
2298 // Framework URL, otherwise treat it as a Basic Macro
2299 if (!sName
.isEmpty())
2301 aSeq
= Sequence
<PropertyValue
> (2);
2302 PropertyValue
* pArr
= aSeq
.getArray();
2303 pArr
[0].Name
= sEventType
;
2304 pArr
[0].Value
<<= sScript
;
2305 pArr
[1].Name
= sScript
;
2306 pArr
[1].Value
= rPropSet
->getPropertyValue( sPropertyScriptURL
);
2310 aSeq
= Sequence
<PropertyValue
> (3);
2311 PropertyValue
* pArr
= aSeq
.getArray();
2312 pArr
[0].Name
= sEventType
;
2313 pArr
[0].Value
<<= sStarBasic
;
2314 pArr
[1].Name
= sLibrary
;
2315 pArr
[1].Value
= rPropSet
->getPropertyValue( sPropertyMacroLibrary
);
2316 pArr
[2].Name
= sMacroName
;
2317 pArr
[2].Value
= rPropSet
->getPropertyValue( sPropertyMacroName
);
2320 // 2) export the sequence
2321 GetExport().GetEventExport().ExportSingleEvent( aSeq
, sOnClick
, false );
2323 // and finally, the field presentation
2324 GetExport().Characters(rContent
);
2327 void XMLTextFieldExport::ExportMetaField(
2328 const Reference
<XPropertySet
> & i_xMeta
,
2329 bool i_bAutoStyles
, bool i_bProgress
)
2331 bool doExport(!i_bAutoStyles
); // do not export element if autostyles
2332 // check version >= 1.2
2333 switch (GetExport().getDefaultVersion()) {
2334 case SvtSaveOptions::ODFVER_011
: // fall through
2335 case SvtSaveOptions::ODFVER_010
: doExport
= false; break;
2339 const Reference
< XEnumerationAccess
> xEA( i_xMeta
, UNO_QUERY_THROW
);
2340 const Reference
< XEnumeration
> xTextEnum( xEA
->createEnumeration() );
2344 const Reference
<rdf::XMetadatable
> xMeta( i_xMeta
, UNO_QUERY_THROW
);
2346 // style:data-style-name
2347 ProcessValueAndType(false,
2348 GetIntProperty(sPropertyNumberFormat
, i_xMeta
),
2349 sEmpty
, sEmpty
, 0.0, false, false, true,
2350 false, false /*, sal_False*/ );
2352 // text:meta-field without xml:id is invalid
2353 xMeta
->ensureMetadataReference();
2355 // xml:id for RDF metadata
2356 GetExport().AddAttributeXmlId(xMeta
);
2359 SvXMLElementExport
aElem( GetExport(), doExport
,
2360 XML_NAMESPACE_TEXT
, XML_META_FIELD
, false, false );
2362 // recurse to export content
2363 GetExport().GetTextParagraphExport()->
2364 exportTextRangeEnumeration( xTextEnum
, i_bAutoStyles
, i_bProgress
);
2367 /// export all data-style related attributes
2368 void XMLTextFieldExport::ProcessValueAndType(
2369 bool bIsString
, /// do we process a string or a number?
2370 sal_Int32 nFormatKey
, /// format key for NumberFormatter; inv. if string
2371 const OUString
& sContent
, /// string content; possibly invalid
2372 const OUString
& sDefault
, /// default string
2373 double fValue
, /// float content; possibly invalid
2374 bool bExportValue
, /// export value attribute?
2375 bool bExportValueType
, /// export value-type attribute?
2376 bool bExportStyle
, /// export style-sttribute?
2377 bool bForceSystemLanguage
, /// export language attributes?
2378 bool bTimeStyle
) // exporting a time style?
2380 // String or number?
2384 // string: attributes value-type=string, string-value=...
2386 if (bExportValue
|| bExportValueType
)
2388 XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes(
2389 GetExport(), sContent
, sDefault
, bExportValue
);
2396 // number: value-type=..., value...=..., data-style-name=...
2398 DBG_ASSERT(bExportValueType
|| !bExportValue
, "value w/o value type not supported!");
2400 // take care of illegal formats
2401 // (shouldn't happen, but does if document is corrupted)
2402 if (-1 != nFormatKey
)
2404 if (bExportValue
|| bExportValueType
)
2406 XMLNumberFormatAttributesExportHelper::
2407 SetNumberFormatAttributes(
2408 GetExport(), nFormatKey
, fValue
, bExportValue
);
2413 // don't export language (if desired)
2414 if( bForceSystemLanguage
)
2416 GetExport().dataStyleForceSystemLanguage( nFormatKey
);
2418 OUString sDataStyleName
=
2419 GetExport().getDataStyleName(nFormatKey
, bTimeStyle
);
2420 if( !sDataStyleName
.isEmpty() )
2422 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
2423 XML_DATA_STYLE_NAME
,
2425 } // else: ignore (no valid number format)
2426 } // else: ignore (no number format)
2433 /// process display related properties
2434 void XMLTextFieldExport::ProcessDisplay(bool bIsVisible
,
2438 enum XMLTokenEnum eValue
;
2442 eValue
= bIsCommand
? XML_FORMULA
: XML_VALUE
;
2449 // omit attribute if default
2450 if (!bValueDefault
|| (eValue
!= XML_VALUE
))
2452 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_DISPLAY
, eValue
);
2458 /// export boolean property
2459 void XMLTextFieldExport::ProcessBoolean(enum XMLTokenEnum eName
,
2460 bool bBool
, bool bDefault
)
2462 DBG_ASSERT( eName
!= XML_TOKEN_INVALID
, "invalid element token");
2463 if ( XML_TOKEN_INVALID
== eName
)
2466 // write attribute (if different than default)
2467 // negate to force 0/1 values (and make sal_Bool comparable)
2468 if ((!bBool
) != (!bDefault
)) {
2469 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, eName
,
2470 (bBool
? XML_TRUE
: XML_FALSE
) );
2477 /// export string attribute
2478 void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName
,
2479 const OUString
& sValue
,
2483 DBG_ASSERT( eName
!= XML_TOKEN_INVALID
, "invalid element token");
2484 if ( XML_TOKEN_INVALID
== eName
)
2487 // check for empty string, if applicable
2488 if ( bOmitEmpty
&& sValue
.isEmpty() )
2492 GetExport().AddAttribute(nPrefix
, eName
, sValue
);
2495 void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName
,
2496 sal_uInt16 nValuePrefix
,
2497 const OUString
& sValue
,
2502 GetExport().GetNamespaceMap().GetQNameByKey( nValuePrefix
, sValue
, false );
2503 ProcessString( eName
, sQValue
, bOmitEmpty
, nPrefix
);
2506 /// export a string attribute
2507 void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName
,
2508 const OUString
& sValue
,
2509 const OUString
& sDefault
,
2512 if (sValue
!= sDefault
)
2514 ProcessString(eName
, sValue
, false, nPrefix
);
2518 /// export a string attribute
2519 void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName
,
2520 sal_uInt16 nValuePrefix
,
2521 const OUString
& sValue
,
2522 const OUString
& sDefault
,
2525 if (sValue
!= sDefault
)
2527 ProcessString(eName
, nValuePrefix
, sValue
, false, nPrefix
);
2532 /// export string attribute
2533 void XMLTextFieldExport::ProcessString(
2534 enum XMLTokenEnum eName
,
2535 enum XMLTokenEnum eValue
,
2539 DBG_ASSERT( eName
!= XML_TOKEN_INVALID
, "invalid element token" );
2540 DBG_ASSERT( bOmitEmpty
|| (eValue
!= XML_TOKEN_INVALID
),
2541 "invalid value token" );
2542 if ( XML_TOKEN_INVALID
== eName
)
2545 // check for empty string, if applicable
2546 if (bOmitEmpty
&& (eValue
== XML_TOKEN_INVALID
))
2549 GetExport().AddAttribute(nPrefix
, eName
, eValue
);
2552 /// export a string attribute
2553 void XMLTextFieldExport::ProcessString(
2554 enum XMLTokenEnum eName
,
2555 enum XMLTokenEnum eValue
,
2556 enum XMLTokenEnum eDefault
,
2559 if ( eValue
!= eDefault
)
2560 ProcessString( eName
, eValue
, false, nPrefix
);
2564 /// export a string as a sequence of paragraphs
2565 void XMLTextFieldExport::ProcessParagraphSequence(
2566 const OUString
& sParagraphSequence
)
2568 // iterate over all string-pieces separated by return (0x0a) and
2569 // put each inside a paragraph element.
2570 SvXMLTokenEnumerator
aEnumerator(sParagraphSequence
, sal_Char(0x0a));
2571 OUString aSubString
;
2572 while (aEnumerator
.getNextToken(aSubString
))
2574 SvXMLElementExport
aParagraph(
2575 GetExport(), XML_NAMESPACE_TEXT
, XML_P
, true, false);
2576 GetExport().Characters(aSubString
);
2580 // export an integer attribute
2581 void XMLTextFieldExport::ProcessInteger(enum XMLTokenEnum eName
,
2584 DBG_ASSERT( eName
!= XML_TOKEN_INVALID
, "invalid element token");
2585 if ( XML_TOKEN_INVALID
== eName
)
2588 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, eName
,
2589 OUString::number(nNum
));
2592 /// export an integer attribute, omit if default
2593 void XMLTextFieldExport::ProcessIntegerDef(enum XMLTokenEnum eName
,
2594 sal_Int32 nNum
, sal_Int32 nDefault
)
2596 if (nNum
!= nDefault
)
2597 ProcessInteger(eName
, nNum
);
2602 /// export a numbering type
2603 void XMLTextFieldExport::ProcessNumberingType(sal_Int16 nNumberingType
)
2605 // process only if real format (not: like page descriptor)
2606 if (NumberingType::PAGE_DESCRIPTOR
!= nNumberingType
)
2608 OUStringBuffer
sTmp( 10 );
2609 // number type: num format
2610 GetExport().GetMM100UnitConverter().convertNumFormat( sTmp
,
2612 GetExport().AddAttribute(XML_NAMESPACE_STYLE
, XML_NUM_FORMAT
,
2613 sTmp
.makeStringAndClear() );
2614 // and letter sync, if applicable
2615 SvXMLUnitConverter::convertNumLetterSync( sTmp
, nNumberingType
);
2617 if (!sTmp
.isEmpty())
2619 GetExport().AddAttribute(XML_NAMESPACE_STYLE
, XML_NUM_LETTER_SYNC
,
2620 sTmp
.makeStringAndClear() );
2623 // else: like page descriptor => ignore
2627 /// export a date, time, or duration
2628 void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName
,
2632 bool bOmitDurationIfZero
,
2635 // truncate for date granularity
2638 dValue
= ::rtl::math::approxFloor(dValue
);
2641 OUStringBuffer aBuffer
;
2644 // date/time durationM handle bOmitDurationIfZero
2645 if (!bOmitDurationIfZero
|| !::rtl::math::approxEqual(dValue
, 0.0))
2647 ::sax::Converter::convertDuration(aBuffer
, dValue
);
2653 rExport
.GetMM100UnitConverter().convertDateTime(aBuffer
, dValue
);
2657 ProcessString(eName
, aBuffer
.makeStringAndClear(), true, nPrefix
);
2660 /// export a date or time
2661 void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName
,
2662 const util::DateTime
& rTime
,
2666 OUStringBuffer aBuffer
;
2668 util::DateTime
aDateTime(rTime
);
2673 aDateTime
.NanoSeconds
= 0;
2674 aDateTime
.Seconds
= 0;
2675 aDateTime
.Minutes
= 0;
2676 aDateTime
.Hours
= 0;
2680 ::sax::Converter::convertDateTime(aBuffer
, aDateTime
, 0);
2683 ProcessString(eName
, aBuffer
.makeStringAndClear(), true, nPrefix
);
2686 /// export a date, time, or duration
2687 void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName
,
2691 bool bOmitDurationIfZero
,
2694 // handle bOmitDurationIfZero here, because we can precisely compare ints
2695 if (!(bIsDuration
&& bOmitDurationIfZero
&& (nMinutes
==0)))
2697 ProcessDateTime(eName
, (double)nMinutes
/ (double)(24*60),
2698 bIsDate
, bIsDuration
, bOmitDurationIfZero
, nPrefix
);
2702 /// export a time or dateTime
2703 void XMLTextFieldExport::ProcessTimeOrDateTime(enum XMLTokenEnum eName
,
2704 const util::DateTime
& rTime
,
2707 OUStringBuffer aBuffer
;
2710 ::sax::Converter::convertTimeOrDateTime(aBuffer
, rTime
, 0);
2713 ProcessString(eName
, aBuffer
.makeStringAndClear(), true, nPrefix
);
2717 SvXMLEnumMapEntry
const aBibliographyDataTypeMap
[] =
2719 { XML_ARTICLE
, BibliographyDataType::ARTICLE
},
2720 { XML_BOOK
, BibliographyDataType::BOOK
},
2721 { XML_BOOKLET
, BibliographyDataType::BOOKLET
},
2722 { XML_CONFERENCE
, BibliographyDataType::CONFERENCE
},
2723 { XML_CUSTOM1
, BibliographyDataType::CUSTOM1
},
2724 { XML_CUSTOM2
, BibliographyDataType::CUSTOM2
},
2725 { XML_CUSTOM3
, BibliographyDataType::CUSTOM3
},
2726 { XML_CUSTOM4
, BibliographyDataType::CUSTOM4
},
2727 { XML_CUSTOM5
, BibliographyDataType::CUSTOM5
},
2728 { XML_EMAIL
, BibliographyDataType::EMAIL
},
2729 { XML_INBOOK
, BibliographyDataType::INBOOK
},
2730 { XML_INCOLLECTION
, BibliographyDataType::INCOLLECTION
},
2731 { XML_INPROCEEDINGS
, BibliographyDataType::INPROCEEDINGS
},
2732 { XML_JOURNAL
, BibliographyDataType::JOURNAL
},
2733 { XML_MANUAL
, BibliographyDataType::MANUAL
},
2734 { XML_MASTERSTHESIS
, BibliographyDataType::MASTERSTHESIS
},
2735 { XML_MISC
, BibliographyDataType::MISC
},
2736 { XML_PHDTHESIS
, BibliographyDataType::PHDTHESIS
},
2737 { XML_PROCEEDINGS
, BibliographyDataType::PROCEEDINGS
},
2738 { XML_TECHREPORT
, BibliographyDataType::TECHREPORT
},
2739 { XML_UNPUBLISHED
, BibliographyDataType::UNPUBLISHED
},
2740 { XML_WWW
, BibliographyDataType::WWW
},
2741 { XML_TOKEN_INVALID
, 0 }
2746 void XMLTextFieldExport::ProcessBibliographyData(
2747 const Reference
<XPropertySet
>& rPropSet
)
2750 Any aAny
= rPropSet
->getPropertyValue(sPropertyFields
);
2751 Sequence
<PropertyValue
> aValues
;
2754 // one attribute per value (unless empty)
2755 sal_Int32 nLength
= aValues
.getLength();
2756 for (sal_Int32 i
= 0; i
< nLength
; i
++)
2758 if( aValues
[i
].Name
== "BibiliographicType" )
2760 sal_Int16 nTypeId
= 0;
2761 aValues
[i
].Value
>>= nTypeId
;
2762 OUStringBuffer sBuf
;
2764 if (SvXMLUnitConverter::convertEnum(sBuf
, nTypeId
,
2765 aBibliographyDataTypeMap
))
2767 rExport
.AddAttribute(XML_NAMESPACE_TEXT
,
2768 XML_BIBLIOGRAPHY_TYPE
,
2769 sBuf
.makeStringAndClear());
2771 // else: ignore this argument
2776 aValues
[i
].Value
>>= sStr
;
2778 if (!sStr
.isEmpty())
2780 rExport
.AddAttribute(XML_NAMESPACE_TEXT
,
2781 MapBibliographyFieldName(aValues
[i
].Name
),
2788 /// export CommandTypeAttribute
2789 void XMLTextFieldExport::ProcessCommandType(
2790 sal_Int32 nCommandType
)
2792 enum XMLTokenEnum eToken
= XML_TOKEN_INVALID
;
2793 switch( nCommandType
)
2795 case sdb::CommandType::TABLE
: eToken
= XML_TABLE
; break;
2796 case sdb::CommandType::QUERY
: eToken
= XML_QUERY
; break;
2797 case sdb::CommandType::COMMAND
: eToken
= XML_COMMAND
; break;
2800 if( eToken
!= XML_TOKEN_INVALID
)
2801 rExport
.AddAttribute( XML_NAMESPACE_TEXT
, XML_TABLE_TYPE
, eToken
);
2805 void XMLTextFieldExport::ProcessStringSequence(
2806 const Sequence
<OUString
>& rSequence
,
2807 const OUString
& sSelected
)
2809 // find selected element
2810 sal_Int32 nSelected
= -1;
2811 sal_Int32 nLength
= rSequence
.getLength();
2812 const OUString
* pSequence
= rSequence
.getConstArray();
2813 for( sal_Int32 i
= 0; i
< nLength
; i
++ )
2815 if( pSequence
[i
] == sSelected
)
2819 // delegate to ProcessStringSequence(OUString,sal_Int32)
2820 ProcessStringSequence( rSequence
, nSelected
);
2823 void XMLTextFieldExport::ProcessStringSequence(
2824 const Sequence
<OUString
>& rSequence
,
2825 sal_Int32 nSelected
)
2827 sal_Int32 nLength
= rSequence
.getLength();
2828 const OUString
* pSequence
= rSequence
.getConstArray();
2829 for( sal_Int32 i
= 0; i
< nLength
; i
++ )
2831 if( i
== nSelected
)
2832 rExport
.AddAttribute( XML_NAMESPACE_TEXT
,
2833 XML_CURRENT_SELECTED
, XML_TRUE
);
2834 rExport
.AddAttribute( XML_NAMESPACE_TEXT
, XML_VALUE
, pSequence
[i
] );
2835 SvXMLElementExport
aElement( rExport
, XML_NAMESPACE_TEXT
, XML_LABEL
,
2840 void XMLTextFieldExport::ExportDataBaseElement(
2841 enum XMLTokenEnum eElementName
,
2842 const OUString
& sPresentation
,
2843 const Reference
<XPropertySet
>& rPropertySet
,
2844 const Reference
<XPropertySetInfo
>& rPropertySetInfo
)
2846 DBG_ASSERT( eElementName
!= XML_TOKEN_INVALID
, "need token" );
2847 DBG_ASSERT( rPropertySet
.is(), "need property set" );
2848 DBG_ASSERT( rPropertySetInfo
.is(), "need property set info" );
2850 // get database properties
2851 OUString sDataBaseName
;
2852 OUString sDataBaseURL
;
2854 if( ( rPropertySet
->getPropertyValue( sPropertyDataBaseName
) >>= sStr
)
2855 && !sStr
.isEmpty() )
2857 sDataBaseName
= sStr
;
2859 else if( rPropertySetInfo
->hasPropertyByName( sPropertyDataBaseURL
) &&
2860 (rPropertySet
->getPropertyValue( sPropertyDataBaseURL
) >>= sStr
) &&
2863 sDataBaseURL
= sStr
;
2866 // add database name property (if present)
2867 if( !sDataBaseName
.isEmpty() )
2868 rExport
.AddAttribute( XML_NAMESPACE_TEXT
, XML_DATABASE_NAME
,
2870 SvXMLElementExport
aDataBaseElement( GetExport(),
2871 XML_NAMESPACE_TEXT
, eElementName
,
2874 // write URL as children
2875 if( !sDataBaseURL
.isEmpty() )
2877 rExport
.AddAttribute( XML_NAMESPACE_XLINK
, XML_HREF
, sDataBaseURL
);
2878 SvXMLElementExport
aDataSourceElement(
2879 GetExport(), XML_NAMESPACE_FORM
, XML_CONNECTION_RESOURCE
,
2883 // write presentation
2884 rExport
.Characters( sPresentation
);
2889 // explode a field master name into field type and field name
2890 bool XMLTextFieldExport::ExplodeFieldMasterName(
2891 const OUString
& sMasterName
, OUString
& sFieldType
, OUString
& sVarName
)
2893 sal_Int32 nLength
= sFieldMasterPrefix
.getLength();
2894 sal_Int32 nSeparator
= sMasterName
.indexOf('.', nLength
);
2895 bool bReturn
= true;
2898 // check for service name
2899 bReturn
&= (0 == sFieldMasterPrefix
.compareTo(sMasterName
, nLength
));
2903 if (nSeparator
<= nLength
) {
2904 nSeparator
= sMasterName
.getLength();
2905 SAL_WARN("xmloff.text", "no field var name!");
2910 sFieldType
= sMasterName
.copy(nLength
, nSeparator
-nLength
);
2911 sVarName
= sMasterName
.copy(nSeparator
+1);
2918 // for XDependentTextFields, get PropertySet of FieldMaster
2919 Reference
<XPropertySet
> XMLTextFieldExport::GetMasterPropertySet(
2920 const Reference
<XTextField
> & rTextField
)
2922 // name, value => get Property set of TextFieldMaster
2923 Reference
<XDependentTextField
> xDep(rTextField
, UNO_QUERY
);
2924 return xDep
->getTextFieldMaster();
2927 // get PropertySet of (any; the first) dependent field
2928 bool XMLTextFieldExport::GetDependentFieldPropertySet(
2929 const Reference
<XPropertySet
> & xMaster
,
2930 Reference
<XPropertySet
> & xField
)
2933 Sequence
<Reference
<XDependentTextField
> > aFields
;
2934 aAny
= xMaster
->getPropertyValue(sPropertyDependentTextFields
);
2938 if (aFields
.getLength() > 0)
2940 // get first one and return
2941 Reference
<XDependentTextField
> xTField
= aFields
[0];
2942 xField
= Reference
<XPropertySet
>(xTField
, UNO_QUERY
);
2943 DBG_ASSERT(xField
.is(),
2944 "Surprisinlgy, this TextField refuses to be a PropertySet!");
2954 /// map placeholder type
2955 enum XMLTokenEnum
XMLTextFieldExport::MapPlaceholderType(sal_uInt16 nType
)
2957 enum XMLTokenEnum eType
= XML_TEXT
;
2961 case PlaceholderType::TEXT
:
2965 case PlaceholderType::TABLE
:
2969 case PlaceholderType::TEXTFRAME
:
2970 eType
= XML_TEXT_BOX
;
2973 case PlaceholderType::GRAPHIC
:
2977 case PlaceholderType::OBJECT
:
2982 // unknown placeholder: XML_TEXT
2983 OSL_FAIL("unknown placeholder type");
2990 /// element name for author fields
2991 enum XMLTokenEnum
XMLTextFieldExport::MapAuthorFieldName(
2992 const Reference
<XPropertySet
> & xPropSet
)
2994 // Initalen oder voller Name?
2995 return GetBoolProperty(sPropertyFullName
, xPropSet
)
2996 ? XML_AUTHOR_NAME
: XML_AUTHOR_INITIALS
;
2999 enum XMLTokenEnum
XMLTextFieldExport::MapPageNumberName(
3000 const Reference
<XPropertySet
> & xPropSet
,
3003 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
3004 PageNumberType ePage
;
3005 Any aAny
= xPropSet
->getPropertyValue(sPropertySubType
);
3006 ePage
= *static_cast<PageNumberType
const *>(aAny
.getValue());
3010 case PageNumberType_PREV
:
3011 eName
= XML_PREVIOUS
;
3014 case PageNumberType_CURRENT
:
3015 eName
= XML_CURRENT
;
3017 case PageNumberType_NEXT
:
3022 OSL_FAIL("unknown page number type");
3023 eName
= XML_TOKEN_INVALID
;
3030 /// map TemplateDisplayFormat to XML
3031 enum XMLTokenEnum
XMLTextFieldExport::MapTemplateDisplayFormat(sal_Int16 nFormat
)
3033 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
3037 case TemplateDisplayFormat::FULL
:
3040 case TemplateDisplayFormat::PATH
:
3043 case TemplateDisplayFormat::NAME
:
3046 case TemplateDisplayFormat::NAME_AND_EXT
:
3047 eName
= XML_NAME_AND_EXTENSION
;
3049 case TemplateDisplayFormat::AREA
:
3052 case TemplateDisplayFormat::TITLE
:
3056 OSL_FAIL("unknown template display format");
3057 eName
= XML_TOKEN_INVALID
;
3064 /// map count/statistics field token to XML name
3065 enum XMLTokenEnum
XMLTextFieldExport::MapCountFieldName(FieldIdEnum nToken
)
3067 enum XMLTokenEnum eElement
= XML_TOKEN_INVALID
;
3071 case FIELD_ID_COUNT_PAGES
:
3072 eElement
= XML_PAGE_COUNT
;
3074 case FIELD_ID_COUNT_PARAGRAPHS
:
3075 eElement
= XML_PARAGRAPH_COUNT
;
3077 case FIELD_ID_COUNT_WORDS
:
3078 eElement
= XML_WORD_COUNT
;
3080 case FIELD_ID_COUNT_CHARACTERS
:
3081 eElement
= XML_CHARACTER_COUNT
;
3083 case FIELD_ID_COUNT_TABLES
:
3084 eElement
= XML_TABLE_COUNT
;
3086 case FIELD_ID_COUNT_GRAPHICS
:
3087 eElement
= XML_IMAGE_COUNT
;
3089 case FIELD_ID_COUNT_OBJECTS
:
3090 eElement
= XML_OBJECT_COUNT
;
3093 OSL_FAIL("no count field token");
3094 eElement
= XML_TOKEN_INVALID
;
3101 /// map ChapterDisplayFormat to XML string
3102 enum XMLTokenEnum
XMLTextFieldExport::MapChapterDisplayFormat(sal_Int16 nFormat
)
3104 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
3108 case ChapterFormat::NAME
:
3111 case ChapterFormat::NUMBER
:
3114 case ChapterFormat::NAME_NUMBER
:
3115 eName
= XML_NUMBER_AND_NAME
;
3117 case ChapterFormat::NO_PREFIX_SUFFIX
:
3118 eName
= XML_PLAIN_NUMBER_AND_NAME
;
3120 case ChapterFormat::DIGIT
:
3121 eName
= XML_PLAIN_NUMBER
;
3124 OSL_FAIL("unknown chapter display format");
3125 eName
= XML_TOKEN_INVALID
;
3133 /// map FilenameDisplayFormat to XML attribute names
3134 enum XMLTokenEnum
XMLTextFieldExport::MapFilenameDisplayFormat(sal_Int16 nFormat
)
3136 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
3140 case FilenameDisplayFormat::FULL
:
3143 case FilenameDisplayFormat::PATH
:
3146 case FilenameDisplayFormat::NAME
:
3149 case FilenameDisplayFormat::NAME_AND_EXT
:
3150 eName
= XML_NAME_AND_EXTENSION
;
3153 OSL_FAIL("unknown filename display format");
3160 /// map ReferenceFieldPart to XML string
3161 enum XMLTokenEnum
XMLTextFieldExport::MapReferenceType(sal_Int16 nType
)
3163 enum XMLTokenEnum eElement
= XML_TOKEN_INVALID
;
3167 case ReferenceFieldPart::PAGE
:
3168 eElement
= XML_PAGE
;
3170 case ReferenceFieldPart::CHAPTER
:
3171 eElement
= XML_CHAPTER
;
3173 case ReferenceFieldPart::TEXT
:
3174 eElement
= XML_TEXT
;
3176 case ReferenceFieldPart::UP_DOWN
:
3177 eElement
= XML_DIRECTION
;
3179 case ReferenceFieldPart::CATEGORY_AND_NUMBER
:
3180 eElement
= XML_CATEGORY_AND_VALUE
;
3182 case ReferenceFieldPart::ONLY_CAPTION
:
3183 eElement
= XML_CAPTION
;
3185 case ReferenceFieldPart::ONLY_SEQUENCE_NUMBER
:
3186 eElement
= XML_VALUE
;
3188 case ReferenceFieldPart::PAGE_DESC
:
3189 // small hack: this value never gets written, because
3190 // XML_TEMPLATE is default
3191 eElement
= XML_TEMPLATE
;
3193 // Core implementation for direct cross-references (#i81002#)
3194 case ReferenceFieldPart::NUMBER
:
3195 eElement
= XML_NUMBER
;
3197 case ReferenceFieldPart::NUMBER_NO_CONTEXT
:
3198 eElement
= XML_NUMBER_NO_SUPERIOR
;
3200 case ReferenceFieldPart::NUMBER_FULL_CONTEXT
:
3201 eElement
= XML_NUMBER_ALL_SUPERIOR
;
3204 OSL_FAIL("unknown reference type");
3205 eElement
= XML_TEMPLATE
;
3212 /// map ReferenceFieldPart to XML string
3213 enum XMLTokenEnum
XMLTextFieldExport::MapReferenceSource(sal_Int16 nType
)
3215 enum XMLTokenEnum eElement
= XML_TOKEN_INVALID
;
3219 case ReferenceFieldSource::REFERENCE_MARK
:
3220 eElement
= XML_REFERENCE_REF
;
3222 case ReferenceFieldSource::SEQUENCE_FIELD
:
3223 eElement
= XML_SEQUENCE_REF
;
3225 case ReferenceFieldSource::BOOKMARK
:
3226 eElement
= XML_BOOKMARK_REF
;
3228 case ReferenceFieldSource::FOOTNOTE
:
3229 case ReferenceFieldSource::ENDNOTE
:
3230 eElement
= XML_NOTE_REF
;
3233 OSL_FAIL("unknown reference source");
3241 /// element name for sender fields
3242 enum XMLTokenEnum
XMLTextFieldExport::MapSenderFieldName(
3243 const Reference
<XPropertySet
> & xPropSet
)
3245 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
3248 switch (GetInt16Property(sPropertyFieldSubType
, xPropSet
))
3250 case UserDataPart::COMPANY
:
3251 eName
= XML_SENDER_COMPANY
;
3253 case UserDataPart::FIRSTNAME
:
3254 eName
= XML_SENDER_FIRSTNAME
;
3256 case UserDataPart::NAME
:
3257 eName
= XML_SENDER_LASTNAME
;
3259 case UserDataPart::SHORTCUT
:
3260 eName
= XML_SENDER_INITIALS
;
3262 case UserDataPart::STREET
:
3263 eName
= XML_SENDER_STREET
;
3265 case UserDataPart::COUNTRY
:
3266 eName
= XML_SENDER_COUNTRY
;
3268 case UserDataPart::ZIP
:
3269 eName
= XML_SENDER_POSTAL_CODE
;
3271 case UserDataPart::CITY
:
3272 eName
= XML_SENDER_CITY
;
3274 case UserDataPart::TITLE
:
3275 eName
= XML_SENDER_TITLE
;
3277 case UserDataPart::POSITION
:
3278 eName
= XML_SENDER_POSITION
;
3280 case UserDataPart::PHONE_PRIVATE
:
3281 eName
= XML_SENDER_PHONE_PRIVATE
;
3283 case UserDataPart::PHONE_COMPANY
:
3284 eName
= XML_SENDER_PHONE_WORK
;
3286 case UserDataPart::FAX
:
3287 eName
= XML_SENDER_FAX
;
3289 case UserDataPart::EMAIL
:
3290 eName
= XML_SENDER_EMAIL
;
3292 case UserDataPart::STATE
:
3293 eName
= XML_SENDER_STATE_OR_PROVINCE
;
3296 SAL_WARN("xmloff.text", "unknown sender type");
3297 eName
= XML_TOKEN_INVALID
;
3304 enum XMLTokenEnum
XMLTextFieldExport::MapDocInfoFieldName(
3305 enum FieldIdEnum nToken
)
3307 enum XMLTokenEnum eElement
= XML_TOKEN_INVALID
;
3311 case FIELD_ID_DOCINFO_CREATION_AUTHOR
:
3312 eElement
= XML_INITIAL_CREATOR
;
3314 case FIELD_ID_DOCINFO_CREATION_DATE
:
3315 eElement
= XML_CREATION_DATE
;
3317 case FIELD_ID_DOCINFO_CREATION_TIME
:
3318 eElement
= XML_CREATION_TIME
;
3320 case FIELD_ID_DOCINFO_DESCRIPTION
:
3321 eElement
= XML_DESCRIPTION
;
3323 case FIELD_ID_DOCINFO_PRINT_TIME
:
3324 eElement
= XML_PRINT_TIME
;
3326 case FIELD_ID_DOCINFO_PRINT_DATE
:
3327 eElement
= XML_PRINT_DATE
;
3329 case FIELD_ID_DOCINFO_PRINT_AUTHOR
:
3330 eElement
= XML_PRINTED_BY
;
3332 case FIELD_ID_DOCINFO_TITLE
:
3333 eElement
= XML_TITLE
;
3335 case FIELD_ID_DOCINFO_SUBJECT
:
3336 eElement
= XML_SUBJECT
;
3338 case FIELD_ID_DOCINFO_KEYWORDS
:
3339 eElement
= XML_KEYWORDS
;
3341 case FIELD_ID_DOCINFO_REVISION
:
3342 eElement
= XML_EDITING_CYCLES
;
3344 case FIELD_ID_DOCINFO_EDIT_DURATION
:
3345 eElement
= XML_EDITING_DURATION
;
3347 case FIELD_ID_DOCINFO_SAVE_TIME
:
3348 eElement
= XML_MODIFICATION_TIME
;
3350 case FIELD_ID_DOCINFO_SAVE_DATE
:
3351 eElement
= XML_MODIFICATION_DATE
;
3353 case FIELD_ID_DOCINFO_SAVE_AUTHOR
:
3354 eElement
= XML_CREATOR
;
3357 SAL_WARN("xmloff.text", "unknown docinfo field type!");
3358 eElement
= XML_TOKEN_INVALID
;
3365 enum XMLTokenEnum
XMLTextFieldExport::MapBibliographyFieldName(const OUString
& sName
)
3367 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
3369 if( sName
== "Identifier" )
3371 eName
= XML_IDENTIFIER
;
3373 else if( sName
== "BibiliographicType" )
3375 eName
= XML_BIBLIOGRAPHY_TYPE
;
3377 else if( sName
== "Address" )
3379 eName
= XML_ADDRESS
;
3381 else if( sName
== "Annote" )
3385 else if( sName
== "Author" )
3389 else if( sName
== "Booktitle" )
3391 eName
= XML_BOOKTITLE
;
3393 else if( sName
== "Chapter" )
3395 eName
= XML_CHAPTER
;
3397 else if( sName
== "Edition" )
3399 eName
= XML_EDITION
;
3401 else if( sName
== "Editor" )
3405 else if( sName
== "Howpublished" )
3407 eName
= XML_HOWPUBLISHED
;
3409 else if( sName
== "Institution" )
3411 eName
= XML_INSTITUTION
;
3413 else if( sName
== "Journal" )
3415 eName
= XML_JOURNAL
;
3417 else if( sName
=="Month" )
3421 else if( sName
== "Note" )
3425 else if( sName
== "Number" )
3429 else if( sName
== "Organizations" )
3431 eName
= XML_ORGANIZATIONS
;
3433 else if( sName
== "Pages" )
3437 else if( sName
== "Publisher" )
3439 eName
= XML_PUBLISHER
;
3441 else if( sName
== "School" )
3445 else if( sName
== "Series" )
3449 else if( sName
== "Title" )
3453 else if( sName
== "Report_Type" )
3455 eName
= XML_REPORT_TYPE
;
3457 else if( sName
== "Volume" )
3461 else if( sName
== "Year" )
3465 else if( sName
== "URL" )
3469 else if( sName
== "Custom1" )
3471 eName
= XML_CUSTOM1
;
3473 else if( sName
== "Custom2" )
3475 eName
= XML_CUSTOM2
;
3477 else if( sName
== "Custom3" )
3479 eName
= XML_CUSTOM3
;
3481 else if( sName
== "Custom4" )
3483 eName
= XML_CUSTOM4
;
3485 else if( sName
== "Custom5" )
3487 eName
= XML_CUSTOM5
;
3489 else if( sName
== "ISBN" )
3495 OSL_FAIL("Unknown bibliography info data");
3496 eName
= XML_TOKEN_INVALID
;
3502 enum XMLTokenEnum
XMLTextFieldExport::MapMeasureKind(sal_Int16 nKind
)
3514 OUString
XMLTextFieldExport::MakeFootnoteRefName(
3517 // generate foot-/endnote ID
3518 OUStringBuffer aBuf
;
3519 aBuf
.appendAscii("ftn");
3520 aBuf
.append((sal_Int32
)nSeqNo
);
3521 return aBuf
.makeStringAndClear();
3524 OUString
XMLTextFieldExport::MakeSequenceRefName(
3526 const OUString
& rSeqName
)
3528 // generate foot-/endnote ID
3529 OUStringBuffer aBuf
;
3530 aBuf
.appendAscii("ref");
3531 aBuf
.append(rSeqName
);
3532 aBuf
.append((sal_Int32
)nSeqNo
);
3533 return aBuf
.makeStringAndClear();
3537 // Property accessor helper functions
3540 // to be relegated (does that word exist?) to a more appropriate place
3544 inline bool GetBoolProperty(
3545 const OUString
& sPropName
,
3546 const Reference
<XPropertySet
> & xPropSet
)
3548 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3549 bool bBool
= *static_cast<sal_Bool
const *>(aAny
.getValue());
3553 inline bool GetOptionalBoolProperty(
3554 const OUString
& sPropName
,
3555 const Reference
<XPropertySet
> & xPropSet
,
3556 const Reference
<XPropertySetInfo
> & xPropSetInfo
,
3559 return xPropSetInfo
->hasPropertyByName( sPropName
)
3560 ? GetBoolProperty( sPropName
, xPropSet
) : bDefault
;
3563 inline double GetDoubleProperty(
3564 const OUString
& sPropName
,
3565 const Reference
<XPropertySet
> & xPropSet
)
3567 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3568 double fDouble
= 0.0;
3573 inline OUString
const GetStringProperty(
3574 const OUString
& sPropName
,
3575 const Reference
<XPropertySet
> & xPropSet
)
3577 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3583 inline sal_Int32
GetIntProperty(
3584 const OUString
& sPropName
,
3585 const Reference
<XPropertySet
> & xPropSet
)
3587 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3593 inline sal_Int16
GetInt16Property(
3594 const OUString
& sPropName
,
3595 const Reference
<XPropertySet
> & xPropSet
)
3597 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3603 inline sal_Int8
GetInt8Property(
3604 const OUString
& sPropName
,
3605 const Reference
<XPropertySet
> & xPropSet
)
3607 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3613 inline util::DateTime
const GetDateTimeProperty(
3614 const OUString
& sPropName
,
3615 const Reference
<XPropertySet
> & xPropSet
)
3617 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3618 util::DateTime aTime
;
3623 inline Sequence
<OUString
> const GetStringSequenceProperty(
3624 const OUString
& sPropName
,
3625 const Reference
<XPropertySet
> & xPropSet
)
3627 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3628 Sequence
<OUString
> aSequence
;
3633 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */