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/xmlexp.hxx>
27 #include <xmloff/xmlnumfe.hxx>
28 #include <xmloff/xmltoken.hxx>
29 #include <xmloff/xmlement.hxx>
30 #include <xmloff/xmluconv.hxx>
31 #include <xmloff/xmlnume.hxx>
32 #include "xmloff/numehelp.hxx"
34 #include <xmloff/families.hxx>
35 #include <xmloff/XMLEventExport.hxx>
36 #include "XMLTextCharStyleNamesElementExport.hxx"
37 #include <xmloff/nmspmap.hxx>
38 #include <sax/tools/converter.hxx>
40 #include <com/sun/star/util/DateTime.hpp>
41 #include <com/sun/star/util/Date.hpp>
42 #include <com/sun/star/lang/XServiceInfo.hpp>
43 #include <com/sun/star/text/UserDataPart.hpp>
44 #include <com/sun/star/text/PageNumberType.hpp>
45 #include <com/sun/star/style/NumberingType.hpp>
46 #include <com/sun/star/text/ReferenceFieldPart.hpp>
47 #include <com/sun/star/text/ReferenceFieldSource.hpp>
48 #include <com/sun/star/beans/XPropertySet.hpp>
49 #include <com/sun/star/beans/XPropertyState.hpp>
50 #include <com/sun/star/text/XTextField.hpp>
51 #include <com/sun/star/text/XDependentTextField.hpp>
52 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
54 #include <com/sun/star/text/SetVariableType.hpp>
55 #include <com/sun/star/text/PlaceholderType.hpp>
56 #include <com/sun/star/text/FilenameDisplayFormat.hpp>
57 #include <com/sun/star/text/ChapterFormat.hpp>
58 #include <com/sun/star/text/TemplateDisplayFormat.hpp>
59 #include <com/sun/star/frame/XModel.hpp>
60 #include <com/sun/star/container/XNameReplace.hpp>
61 #include <com/sun/star/uno/Sequence.h>
62 #include <com/sun/star/util/NumberFormat.hpp>
63 #include <com/sun/star/text/BibliographyDataType.hpp>
64 #include <com/sun/star/sdb/CommandType.hpp>
65 #include <com/sun/star/rdf/XMetadatable.hpp>
66 #include <rtl/ustrbuf.hxx>
67 #include <tools/debug.hxx>
68 #include <rtl/math.hxx>
73 using namespace ::std
;
74 using namespace ::com::sun::star
;
75 using namespace ::com::sun::star::uno
;
76 using namespace ::com::sun::star::text
;
77 using namespace ::com::sun::star::lang
;
78 using namespace ::com::sun::star::beans
;
79 using namespace ::com::sun::star::util
;
80 using namespace ::com::sun::star::style
;
81 using namespace ::com::sun::star::document
;
82 using namespace ::com::sun::star::container
;
83 using namespace ::xmloff::token
;
86 static sal_Char
const FIELD_SERVICE_SENDER
[] = "ExtendedUser";
87 static sal_Char
const FIELD_SERVICE_AUTHOR
[] = "Author";
88 static sal_Char
const FIELD_SERVICE_JUMPEDIT
[] = "JumpEdit";
89 static sal_Char
const FIELD_SERVICE_GETEXP
[] = "GetExpression";
90 static sal_Char
const FIELD_SERVICE_SETEXP
[] = "SetExpression";
91 static sal_Char
const FIELD_SERVICE_USER
[] = "User";
92 static sal_Char
const FIELD_SERVICE_INPUT
[] = "Input";
93 static sal_Char
const FIELD_SERVICE_USERINPUT
[] = "InputUser";
94 static sal_Char
const FIELD_SERVICE_DATETIME
[] = "DateTime";
95 static sal_Char
const FIELD_SERVICE_PAGENUMBER
[] = "PageNumber";
96 static sal_Char
const FIELD_SERVICE_DB_NEXT
[] = "DatabaseNextSet";
97 static sal_Char
const FIELD_SERVICE_DB_SELECT
[] = "DatabaseNumberOfSet";
98 static sal_Char
const FIELD_SERVICE_DB_NUMBER
[] = "DatabaseSetNumber";
99 static sal_Char
const FIELD_SERVICE_DB_DISPLAY
[] = "Database";
100 static sal_Char
const FIELD_SERVICE_DB_NAME
[] = "DatabaseName";
101 static sal_Char
const FIELD_SERVICE_CONDITIONAL_TEXT
[] = "ConditionalText";
102 static sal_Char
const FIELD_SERVICE_HIDDEN_TEXT
[] = "HiddenText";
103 static sal_Char
const FIELD_SERVICE_HIDDEN_PARAGRAPH
[] = "HiddenParagraph";
104 static sal_Char
const FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR
[] = "DocInfo.ChangeAuthor";
105 static sal_Char
const FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR2
[] = "docinfo.ChangeAuthor";
106 static sal_Char
const FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME
[] = "DocInfo.ChangeDateTime";
107 static sal_Char
const FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME2
[] = "docinfo.ChangeDateTime";
108 static sal_Char
const FIELD_SERVICE_DOC_INFO_EDIT_TIME
[] = "DocInfo.EditTime";
109 static sal_Char
const FIELD_SERVICE_DOC_INFO_EDIT_TIME2
[] = "docinfo.EditTime";
110 static sal_Char
const FIELD_SERVICE_DOC_INFO_DESCRIPTION
[] = "DocInfo.Description";
111 static sal_Char
const FIELD_SERVICE_DOC_INFO_DESCRIPTION2
[] = "docinfo.Description";
112 static sal_Char
const FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR
[] = "DocInfo.CreateAuthor";
113 static sal_Char
const FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR2
[] = "docinfo.CreateAuthor";
114 static sal_Char
const FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME
[] = "DocInfo.CreateDateTime";
115 static sal_Char
const FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME2
[] = "docinfo.CreateDateTime";
116 static sal_Char
const FIELD_SERVICE_DOC_INFO_CUSTOM
[] = "DocInfo.Custom";
117 static sal_Char
const FIELD_SERVICE_DOC_INFO_CUSTOM2
[] = "docinfo.Custom";
118 static sal_Char
const FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR
[] = "DocInfo.PrintAuthor";
119 static sal_Char
const FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR2
[] = "docinfo.PrintAuthor";
120 static sal_Char
const FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME
[] = "DocInfo.PrintDateTime";
121 static sal_Char
const FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME2
[] = "docinfo.PrintDateTime";
122 static sal_Char
const FIELD_SERVICE_DOC_INFO_KEY_WORDS
[] = "DocInfo.KeyWords";
123 static sal_Char
const FIELD_SERVICE_DOC_INFO_KEY_WORDS2
[] = "docinfo.KeyWords";
124 static sal_Char
const FIELD_SERVICE_DOC_INFO_SUBJECT
[] = "DocInfo.Subject";
125 static sal_Char
const FIELD_SERVICE_DOC_INFO_SUBJECT2
[] = "docinfo.Subject";
126 static sal_Char
const FIELD_SERVICE_DOC_INFO_TITLE
[] = "DocInfo.Title";
127 static sal_Char
const FIELD_SERVICE_DOC_INFO_TITLE2
[] = "docinfo.Title";
128 static sal_Char
const FIELD_SERVICE_DOC_INFO_REVISION
[] = "DocInfo.Revision";
129 static sal_Char
const FIELD_SERVICE_DOC_INFO_REVISION2
[] = "docinfo.Revision";
130 static sal_Char
const FIELD_SERVICE_FILE_NAME
[] = "FileName";
131 static sal_Char
const FIELD_SERVICE_CHAPTER
[] = "Chapter";
132 static sal_Char
const FIELD_SERVICE_TEMPLATE_NAME
[] = "TemplateName";
133 static sal_Char
const FIELD_SERVICE_PAGE_COUNT
[] = "PageCount";
134 static sal_Char
const FIELD_SERVICE_PARAGRAPH_COUNT
[] = "ParagraphCount";
135 static sal_Char
const FIELD_SERVICE_WORD_COUNT
[] = "WordCount";
136 static sal_Char
const FIELD_SERVICE_CHARACTER_COUNT
[] = "CharacterCount";
137 static sal_Char
const FIELD_SERVICE_TABLE_COUNT
[] = "TableCount";
138 static sal_Char
const FIELD_SERVICE_GRAPHIC_COUNT
[] = "GraphicObjectCount";
139 static sal_Char
const FIELD_SERVICE_OBJECT_COUNT
[] = "EmbeddedObjectCount";
140 static sal_Char
const FIELD_SERVICE_REFERENCE_PAGE_SET
[] = "ReferencePageSet";
141 static sal_Char
const FIELD_SERVICE_REFERENCE_PAGE_GET
[] = "ReferencePageGet";
142 static sal_Char
const FIELD_SERVICE_SHEET_NAME
[] = "SheetName";
143 static sal_Char
const FIELD_SERVICE_MACRO
[] = "Macro";
144 static sal_Char
const FIELD_SERVICE_GET_REFERENCE
[] = "GetReference";
145 static sal_Char
const FIELD_SERVICE_DDE
[] = "DDE";
146 static sal_Char
const FIELD_SERVICE_URL
[] = "URL";
147 static sal_Char
const FIELD_SERVICE_BIBLIOGRAPHY
[] = "Bibliography";
148 static sal_Char
const FIELD_SERVICE_SCRIPT
[] = "Script";
149 static sal_Char
const FIELD_SERVICE_ANNOTATION
[] = "Annotation";
150 static sal_Char
const FIELD_SERVICE_COMBINED_CHARACTERS
[] = "CombinedCharacters";
151 static sal_Char
const FIELD_SERVICE_META
[] = "MetadataField";
152 static sal_Char
const FIELD_SERVICE_MEASURE
[] = "Measure";
153 static sal_Char
const FIELD_SERVICE_TABLE_FORMULA
[] = "TableFormula";
154 static sal_Char
const FIELD_SERVICE_DROP_DOWN
[] = "DropDown";
156 SvXMLEnumStringMapEntry
const aFieldServiceNameMapping
[] =
158 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SENDER
, FIELD_ID_SENDER
),
159 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_AUTHOR
, FIELD_ID_AUTHOR
),
160 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_JUMPEDIT
, FIELD_ID_PLACEHOLDER
),
161 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GETEXP
, FIELD_ID_VARIABLE_GET
),
162 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SETEXP
, FIELD_ID_VARIABLE_SET
),
163 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_USER
, FIELD_ID_USER_GET
),
164 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_INPUT
, FIELD_ID_TEXT_INPUT
),
165 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_USERINPUT
, FIELD_ID_USER_INPUT
),
166 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DATETIME
, FIELD_ID_TIME
),
167 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PAGENUMBER
, FIELD_ID_PAGENUMBER
),
168 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_REFERENCE_PAGE_SET
, FIELD_ID_REFPAGE_SET
),
169 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_REFERENCE_PAGE_GET
, FIELD_ID_REFPAGE_GET
),
171 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NEXT
, FIELD_ID_DATABASE_NEXT
),
172 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_SELECT
, FIELD_ID_DATABASE_SELECT
),
173 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NUMBER
, FIELD_ID_DATABASE_NUMBER
),
174 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_DISPLAY
, FIELD_ID_DATABASE_DISPLAY
),
175 // workaround for #no-bug#: Database/DataBase
176 ENUM_STRING_MAP_ENTRY( "DataBase", FIELD_ID_DATABASE_DISPLAY
),
177 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NAME
, FIELD_ID_DATABASE_NAME
),
179 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR
, FIELD_ID_DOCINFO_CREATION_AUTHOR
),
180 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR2
, FIELD_ID_DOCINFO_CREATION_AUTHOR
),
181 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME
, FIELD_ID_DOCINFO_CREATION_TIME
),
182 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME2
, FIELD_ID_DOCINFO_CREATION_TIME
),
183 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR
, FIELD_ID_DOCINFO_SAVE_AUTHOR
),
184 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR2
, FIELD_ID_DOCINFO_SAVE_AUTHOR
),
185 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME
, FIELD_ID_DOCINFO_SAVE_TIME
),
186 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME2
, FIELD_ID_DOCINFO_SAVE_TIME
),
187 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_EDIT_TIME
, FIELD_ID_DOCINFO_EDIT_DURATION
),
188 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_EDIT_TIME2
, FIELD_ID_DOCINFO_EDIT_DURATION
),
189 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_DESCRIPTION
, FIELD_ID_DOCINFO_DESCRIPTION
),
190 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_DESCRIPTION2
, FIELD_ID_DOCINFO_DESCRIPTION
),
191 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CUSTOM
, FIELD_ID_DOCINFO_CUSTOM
),
192 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CUSTOM2
, FIELD_ID_DOCINFO_CUSTOM
),
193 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR
, FIELD_ID_DOCINFO_PRINT_AUTHOR
),
194 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR2
, FIELD_ID_DOCINFO_PRINT_AUTHOR
),
195 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME
, FIELD_ID_DOCINFO_PRINT_TIME
),
196 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME2
, FIELD_ID_DOCINFO_PRINT_TIME
),
197 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_KEY_WORDS
, FIELD_ID_DOCINFO_KEYWORDS
),
198 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_KEY_WORDS2
, FIELD_ID_DOCINFO_KEYWORDS
),
199 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_SUBJECT
, FIELD_ID_DOCINFO_SUBJECT
),
200 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_SUBJECT2
, FIELD_ID_DOCINFO_SUBJECT
),
201 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_TITLE
, FIELD_ID_DOCINFO_TITLE
),
202 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_TITLE2
, FIELD_ID_DOCINFO_TITLE
),
203 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_REVISION
, FIELD_ID_DOCINFO_REVISION
),
204 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_REVISION2
, FIELD_ID_DOCINFO_REVISION
),
206 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CONDITIONAL_TEXT
, FIELD_ID_CONDITIONAL_TEXT
),
207 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_HIDDEN_TEXT
, FIELD_ID_HIDDEN_TEXT
),
208 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_HIDDEN_PARAGRAPH
, FIELD_ID_HIDDEN_PARAGRAPH
),
210 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_FILE_NAME
, FIELD_ID_FILE_NAME
),
211 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CHAPTER
, FIELD_ID_CHAPTER
),
212 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TEMPLATE_NAME
, FIELD_ID_TEMPLATE_NAME
),
214 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PAGE_COUNT
, FIELD_ID_COUNT_PAGES
),
215 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PARAGRAPH_COUNT
, FIELD_ID_COUNT_PARAGRAPHS
),
216 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_WORD_COUNT
, FIELD_ID_COUNT_WORDS
),
217 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CHARACTER_COUNT
, FIELD_ID_COUNT_CHARACTERS
),
218 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TABLE_COUNT
, FIELD_ID_COUNT_TABLES
),
219 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GRAPHIC_COUNT
, FIELD_ID_COUNT_GRAPHICS
),
220 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_OBJECT_COUNT
, FIELD_ID_COUNT_OBJECTS
),
222 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_MACRO
, FIELD_ID_MACRO
),
223 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GET_REFERENCE
, FIELD_ID_REF_REFERENCE
),
224 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DDE
, FIELD_ID_DDE
),
226 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_BIBLIOGRAPHY
, FIELD_ID_BIBLIOGRAPHY
),
228 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SCRIPT
, FIELD_ID_SCRIPT
),
229 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_ANNOTATION
, FIELD_ID_ANNOTATION
),
231 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_COMBINED_CHARACTERS
, FIELD_ID_COMBINED_CHARACTERS
),
232 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_META
, FIELD_ID_META
),
235 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SHEET_NAME
, FIELD_ID_SHEET_NAME
),
236 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_URL
, FIELD_ID_URL
),
237 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_MEASURE
, FIELD_ID_MEASURE
),
240 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TABLE_FORMULA
, FIELD_ID_TABLE_FORMULA
),
241 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DROP_DOWN
, FIELD_ID_DROP_DOWN
),
243 ENUM_STRING_MAP_END()
248 // property accessor helper functions
249 inline sal_Bool
GetBoolProperty(const OUString
&,
250 const Reference
<XPropertySet
> &);
251 inline sal_Bool
GetOptionalBoolProperty(const OUString
&,
252 const Reference
<XPropertySet
> &,
253 const Reference
<XPropertySetInfo
> &,
255 inline double GetDoubleProperty(const OUString
&,
256 const Reference
<XPropertySet
> &);
257 inline OUString
const GetStringProperty(const OUString
&,
258 const Reference
<XPropertySet
> &);
259 inline sal_Int32
GetIntProperty(const OUString
&,
260 const Reference
<XPropertySet
> &);
261 inline sal_Int16
GetInt16Property(const OUString
&,
262 const Reference
<XPropertySet
> &);
263 inline sal_Int8
GetInt8Property(const OUString
&,
264 const Reference
<XPropertySet
> &);
265 inline util::DateTime
const GetDateTimeProperty( const OUString
& sPropName
,
266 const Reference
<XPropertySet
> & xPropSet
);
267 inline Sequence
<OUString
> const GetStringSequenceProperty(
268 const OUString
& sPropName
,
269 const Reference
<XPropertySet
> & xPropSet
);
273 XMLTextFieldExport::XMLTextFieldExport( SvXMLExport
& rExp
,
274 XMLPropertyState
* pCombinedCharState
)
277 sServicePrefix("com.sun.star.text.textfield."),
278 sFieldMasterPrefix("com.sun.star.text.FieldMaster."),
279 sPresentationServicePrefix("com.sun.star.presentation.TextField."),
281 sPropertyAdjust("Adjust"),
282 sPropertyAuthor("Author"),
283 sPropertyChapterFormat("ChapterFormat"),
284 sPropertyChapterNumberingLevel("ChapterNumberingLevel"),
285 sPropertyCharStyleNames("CharStyleNames"),
286 sPropertyCondition("Condition"),
287 sPropertyContent("Content"),
288 sPropertyDataBaseName("DataBaseName"),
289 sPropertyDataBaseURL("DataBaseURL"),
290 sPropertyDataColumnName("DataColumnName"),
291 sPropertyDataCommandType("DataCommandType"),
292 sPropertyDataTableName("DataTableName"),
293 sPropertyDate("Date"),
294 sPropertyDateTime("DateTime"),
295 sPropertyDateTimeValue("DateTimeValue"),
296 sPropertyDDECommandElement("DDECommandElement"),
297 sPropertyDDECommandFile("DDECommandFile"),
298 sPropertyDDECommandType("DDECommandType"),
299 sPropertyDependentTextFields("DependentTextFields"),
300 sPropertyFalseContent("FalseContent"),
301 sPropertyFields("Fields"),
302 sPropertyFieldSubType("UserDataType"),
303 sPropertyFileFormat("FileFormat"),
304 sPropertyFullName("FullName"),
305 sPropertyHint("Hint"),
306 sPropertyInitials("Initials"),
307 sPropertyInstanceName("InstanceName"),
308 sPropertyIsAutomaticUpdate("IsAutomaticUpdate"),
309 sPropertyIsConditionTrue("IsConditionTrue"),
310 sPropertyIsDataBaseFormat("DataBaseFormat"),
311 sPropertyIsDate("IsDate"),
312 sPropertyIsExpression("IsExpression"),
313 sPropertyIsFixed("IsFixed"),
314 sPropertyIsFixedLanguage("IsFixedLanguage"),
315 sPropertyIsHidden("IsHidden"),
316 sPropertyIsInput("Input"),
317 sPropertyIsShowFormula("IsShowFormula"),
318 sPropertyIsVisible("IsVisible"),
319 sPropertyItems("Items"),
320 sPropertyLevel("Level"),
321 sPropertyMacro("Macro"),
322 sPropertyMeasureKind("Kind"),
323 sPropertyName("Name"),
324 sPropertyNumberFormat("NumberFormat"),
325 sPropertyNumberingSeparator("NumberingSeparator"),
326 sPropertyNumberingType("NumberingType"),
327 sPropertyOffset("Offset"),
329 sPropertyPlaceholder("PlaceHolder"),
330 sPropertyPlaceholderType("PlaceHolderType"),
331 sPropertyReferenceFieldPart("ReferenceFieldPart"),
332 sPropertyReferenceFieldSource("ReferenceFieldSource"),
333 sPropertyReferenceFieldType("ReferenceFieldType"),
334 sPropertyRevision("Revision"),
335 sPropertyScriptType("ScriptType"),
336 sPropertySelectedItem("SelectedItem"),
337 sPropertySequenceNumber("SequenceNumber"),
338 sPropertySequenceValue("SequenceValue"),
339 sPropertySetNumber("SetNumber"),
340 sPropertySourceName("SourceName"),
341 sPropertySubType("SubType"),
342 sPropertyTargetFrame("TargetFrame"),
343 sPropertyTrueContent("TrueContent"),
345 sPropertyURLContent("URLContent"),
346 sPropertyUserText("UserText"),
347 sPropertyValue("Value"),
348 sPropertyVariableName("VariableName"),
349 sPropertyVariableSubType("VariableSubtype"),
350 sPropertyHelp("Help"),
351 sPropertyTooltip("Tooltip"),
352 sPropertyTextRange("TextRange"),
353 pCombinedCharactersPropertyState(pCombinedCharState
)
355 SetExportOnlyUsedFieldDeclarations();
358 XMLTextFieldExport::~XMLTextFieldExport()
360 delete pCombinedCharactersPropertyState
;
364 /// get the field ID (as in FieldIDEnum) from XTextField
365 enum FieldIdEnum
XMLTextFieldExport::GetFieldID(
366 const Reference
<XTextField
> & rTextField
,
367 const Reference
<XPropertySet
> & xPropSet
)
369 // get service names for rTextField (via XServiceInfo service)
370 Reference
<XServiceInfo
> xService(rTextField
, UNO_QUERY
);
371 const Sequence
<OUString
> aServices
= xService
->getSupportedServiceNames();
372 const OUString
* pNames
= aServices
.getConstArray();
373 sal_Int32 nCount
= aServices
.getLength();
375 OUString sFieldName
; // service name postfix of current field
377 // search for TextField service name
380 if (pNames
->matchIgnoreAsciiCase(sServicePrefix
))
382 // TextField found => postfix is field type!
383 sFieldName
= pNames
->copy(sServicePrefix
.getLength());
390 // if this is not a normal text field, check if its a presentation text field
391 if( sFieldName
.isEmpty() )
393 const OUString
* pNames2
= aServices
.getConstArray();
394 sal_Int32 nCount2
= aServices
.getLength();
395 // search for TextField service name
398 if( 0 == pNames2
->compareTo(sPresentationServicePrefix
, sPresentationServicePrefix
.getLength()))
400 // TextField found => postfix is field type!
401 sFieldName
= pNames2
->copy(sPresentationServicePrefix
.getLength());
408 if( !sFieldName
.isEmpty() )
410 if( sFieldName
.reverseCompareTo( "Header" ) == 0 )
412 return FIELD_ID_DRAW_HEADER
;
414 else if( sFieldName
.reverseCompareTo( "Footer" ) == 0 )
416 return FIELD_ID_DRAW_FOOTER
;
418 else if( sFieldName
.reverseCompareTo( "DateTime" ) == 0 )
420 return FIELD_ID_DRAW_DATE_TIME
;
425 // map postfix of service name to field ID
426 DBG_ASSERT(!sFieldName
.isEmpty(), "no TextField service found!");
427 return MapFieldName(sFieldName
, xPropSet
);
430 enum FieldIdEnum
XMLTextFieldExport::MapFieldName(
431 const OUString
& sFieldName
, // field (master) name
432 const Reference
<XPropertySet
> & xPropSet
) // for subtype
434 // we'll proceed in 2 steps:
435 // a) map service name to preliminary FIELD_ID
436 // b) map those prelim. FIELD_IDs that correspond to several field types
437 // (in our (XML) world) to final FIELD IDs
440 // a) find prelim. FIELD_ID via aFieldServiceMapping
442 // check for non-empty service name
443 DBG_ASSERT(!sFieldName
.isEmpty(), "no valid service name!");
444 enum FieldIdEnum nToken
= FIELD_ID_UNKNOWN
;
445 if (!sFieldName
.isEmpty())
447 // map name to prelim. ID
449 sal_Bool bRet
= GetExport().GetMM100UnitConverter().convertEnum(
450 nTmp
, sFieldName
, aFieldServiceNameMapping
);
453 DBG_ASSERT(bRet
, "Unknown field service name encountered!");
456 nToken
= FIELD_ID_UNKNOWN
;
460 nToken
= (enum FieldIdEnum
)nTmp
;
463 // invalid service name
464 nToken
= FIELD_ID_UNKNOWN
;
467 // b) map prelim. to final FIELD_IDs
469 case FIELD_ID_VARIABLE_SET
:
470 if (GetBoolProperty(sPropertyIsInput
, xPropSet
))
472 nToken
= FIELD_ID_VARIABLE_INPUT
;
476 switch (GetIntProperty(sPropertySubType
, xPropSet
))
478 case SetVariableType::STRING
: // text field
479 case SetVariableType::VAR
: // num field
480 nToken
= FIELD_ID_VARIABLE_SET
;
482 case SetVariableType::SEQUENCE
:
483 nToken
= FIELD_ID_SEQUENCE
;
485 case SetVariableType::FORMULA
:
487 nToken
= FIELD_ID_UNKNOWN
;
493 case FIELD_ID_VARIABLE_GET
:
494 switch (GetIntProperty(sPropertySubType
, xPropSet
))
496 case SetVariableType::STRING
: // text field
497 case SetVariableType::VAR
: // num field
498 nToken
= FIELD_ID_VARIABLE_GET
;
500 case SetVariableType::FORMULA
:
501 nToken
= FIELD_ID_EXPRESSION
;
503 case SetVariableType::SEQUENCE
:
505 nToken
= FIELD_ID_UNKNOWN
;
511 if (GetBoolProperty(sPropertyIsDate
, xPropSet
))
513 nToken
= FIELD_ID_DATE
;
517 case FIELD_ID_PAGENUMBER
:
518 // NumberingType not available in non-Writer apps
519 if (xPropSet
->getPropertySetInfo()->
520 hasPropertyByName(sPropertyNumberingType
))
522 if (NumberingType::CHAR_SPECIAL
== GetIntProperty(
523 sPropertyNumberingType
, xPropSet
))
525 nToken
= FIELD_ID_PAGESTRING
;
530 case FIELD_ID_DOCINFO_CREATION_TIME
:
531 if (GetBoolProperty(sPropertyIsDate
, xPropSet
))
533 nToken
= FIELD_ID_DOCINFO_CREATION_DATE
;
537 case FIELD_ID_DOCINFO_PRINT_TIME
:
538 if (GetBoolProperty(sPropertyIsDate
, xPropSet
))
540 nToken
= FIELD_ID_DOCINFO_PRINT_DATE
;
544 case FIELD_ID_DOCINFO_SAVE_TIME
:
545 if (GetBoolProperty(sPropertyIsDate
, xPropSet
))
547 nToken
= FIELD_ID_DOCINFO_SAVE_DATE
;
551 case FIELD_ID_REF_REFERENCE
:
552 switch (GetInt16Property(sPropertyReferenceFieldSource
, xPropSet
))
554 case ReferenceFieldSource::REFERENCE_MARK
:
555 nToken
= FIELD_ID_REF_REFERENCE
;
557 case ReferenceFieldSource::SEQUENCE_FIELD
:
558 nToken
= FIELD_ID_REF_SEQUENCE
;
560 case ReferenceFieldSource::BOOKMARK
:
561 nToken
= FIELD_ID_REF_BOOKMARK
;
563 case ReferenceFieldSource::FOOTNOTE
:
564 nToken
= FIELD_ID_REF_FOOTNOTE
;
566 case ReferenceFieldSource::ENDNOTE
:
567 nToken
= FIELD_ID_REF_ENDNOTE
;
570 nToken
= FIELD_ID_UNKNOWN
;
575 case FIELD_ID_COMBINED_CHARACTERS
:
576 case FIELD_ID_SCRIPT
:
577 case FIELD_ID_ANNOTATION
:
578 case FIELD_ID_BIBLIOGRAPHY
:
581 case FIELD_ID_REFPAGE_SET
:
582 case FIELD_ID_REFPAGE_GET
:
583 case FIELD_ID_COUNT_PAGES
:
584 case FIELD_ID_COUNT_PARAGRAPHS
:
585 case FIELD_ID_COUNT_WORDS
:
586 case FIELD_ID_COUNT_CHARACTERS
:
587 case FIELD_ID_COUNT_TABLES
:
588 case FIELD_ID_COUNT_GRAPHICS
:
589 case FIELD_ID_COUNT_OBJECTS
:
590 case FIELD_ID_CONDITIONAL_TEXT
:
591 case FIELD_ID_HIDDEN_TEXT
:
592 case FIELD_ID_HIDDEN_PARAGRAPH
:
593 case FIELD_ID_DOCINFO_CREATION_AUTHOR
:
594 case FIELD_ID_DOCINFO_DESCRIPTION
:
595 case FIELD_ID_DOCINFO_CUSTOM
:
596 case FIELD_ID_DOCINFO_PRINT_AUTHOR
:
597 case FIELD_ID_DOCINFO_TITLE
:
598 case FIELD_ID_DOCINFO_SUBJECT
:
599 case FIELD_ID_DOCINFO_KEYWORDS
:
600 case FIELD_ID_DOCINFO_REVISION
:
601 case FIELD_ID_DOCINFO_EDIT_DURATION
:
602 case FIELD_ID_DOCINFO_SAVE_AUTHOR
:
603 case FIELD_ID_TEXT_INPUT
:
604 case FIELD_ID_USER_INPUT
:
605 case FIELD_ID_AUTHOR
:
606 case FIELD_ID_SENDER
:
607 case FIELD_ID_PLACEHOLDER
:
608 case FIELD_ID_USER_GET
:
609 case FIELD_ID_DATABASE_NEXT
:
610 case FIELD_ID_DATABASE_SELECT
:
611 case FIELD_ID_DATABASE_DISPLAY
:
612 case FIELD_ID_DATABASE_NAME
:
613 case FIELD_ID_DATABASE_NUMBER
:
614 case FIELD_ID_TEMPLATE_NAME
:
615 case FIELD_ID_CHAPTER
:
616 case FIELD_ID_FILE_NAME
:
618 case FIELD_ID_SHEET_NAME
:
619 case FIELD_ID_MEASURE
:
621 case FIELD_ID_TABLE_FORMULA
:
622 case FIELD_ID_DROP_DOWN
:
623 ; // these field IDs are final
627 nToken
= FIELD_ID_UNKNOWN
;
630 // ... and return final FIELD_ID
634 // is string or numeric field?
635 sal_Bool
XMLTextFieldExport::IsStringField(
636 FieldIdEnum nFieldType
,
637 const Reference
<XPropertySet
> & xPropSet
)
639 switch (nFieldType
) {
641 case FIELD_ID_VARIABLE_GET
:
642 case FIELD_ID_VARIABLE_SET
:
643 case FIELD_ID_VARIABLE_INPUT
:
645 // depends on field sub type
646 return ( GetIntProperty(sPropertySubType
, xPropSet
) ==
647 SetVariableType::STRING
);
650 case FIELD_ID_USER_GET
:
651 case FIELD_ID_USER_INPUT
:
653 Reference
<XTextField
> xTextField(xPropSet
, UNO_QUERY
);
654 DBG_ASSERT(xTextField
.is(), "field is no XTextField!");
655 sal_Bool bRet
= GetBoolProperty(sPropertyIsExpression
,
656 GetMasterPropertySet(xTextField
));
661 return 0 > GetIntProperty(sPropertyNumberFormat
, xPropSet
);
663 case FIELD_ID_DATABASE_DISPLAY
:
664 // TODO: depends on... ???
665 // workaround #no-bug#: no data type
666 return 5100 == GetIntProperty(sPropertyNumberFormat
, xPropSet
);
668 case FIELD_ID_TABLE_FORMULA
:
669 // legacy field: always a number field (because it always has
673 case FIELD_ID_COUNT_PAGES
:
674 case FIELD_ID_COUNT_PARAGRAPHS
:
675 case FIELD_ID_COUNT_WORDS
:
676 case FIELD_ID_COUNT_CHARACTERS
:
677 case FIELD_ID_COUNT_TABLES
:
678 case FIELD_ID_COUNT_GRAPHICS
:
679 case FIELD_ID_COUNT_OBJECTS
:
680 case FIELD_ID_DOCINFO_SAVE_TIME
:
681 case FIELD_ID_DOCINFO_SAVE_DATE
:
682 case FIELD_ID_DOCINFO_CREATION_DATE
:
683 case FIELD_ID_DOCINFO_CREATION_TIME
:
684 case FIELD_ID_DOCINFO_PRINT_TIME
:
685 case FIELD_ID_DOCINFO_PRINT_DATE
:
686 case FIELD_ID_DOCINFO_EDIT_DURATION
:
687 case FIELD_ID_DOCINFO_REVISION
:
688 case FIELD_ID_DATABASE_NUMBER
:
689 case FIELD_ID_EXPRESSION
:
690 case FIELD_ID_SEQUENCE
:
693 case FIELD_ID_PAGENUMBER
:
694 case FIELD_ID_REFPAGE_SET
:
695 case FIELD_ID_REFPAGE_GET
:
696 case FIELD_ID_DOCINFO_CUSTOM
:
700 case FIELD_ID_COMBINED_CHARACTERS
:
701 case FIELD_ID_BIBLIOGRAPHY
:
703 case FIELD_ID_REF_REFERENCE
:
704 case FIELD_ID_REF_SEQUENCE
:
705 case FIELD_ID_REF_BOOKMARK
:
706 case FIELD_ID_REF_FOOTNOTE
:
707 case FIELD_ID_REF_ENDNOTE
:
709 case FIELD_ID_TEMPLATE_NAME
:
710 case FIELD_ID_CHAPTER
:
711 case FIELD_ID_FILE_NAME
:
712 case FIELD_ID_CONDITIONAL_TEXT
:
713 case FIELD_ID_HIDDEN_TEXT
:
714 case FIELD_ID_HIDDEN_PARAGRAPH
:
715 case FIELD_ID_DOCINFO_CREATION_AUTHOR
:
716 case FIELD_ID_DOCINFO_DESCRIPTION
:
717 case FIELD_ID_DOCINFO_PRINT_AUTHOR
:
718 case FIELD_ID_DOCINFO_TITLE
:
719 case FIELD_ID_DOCINFO_SUBJECT
:
720 case FIELD_ID_DOCINFO_KEYWORDS
:
721 case FIELD_ID_DOCINFO_SAVE_AUTHOR
:
722 case FIELD_ID_DATABASE_NAME
:
723 case FIELD_ID_TEXT_INPUT
:
724 case FIELD_ID_SENDER
:
725 case FIELD_ID_AUTHOR
:
726 case FIELD_ID_PAGESTRING
:
727 case FIELD_ID_SHEET_NAME
:
728 case FIELD_ID_MEASURE
:
730 case FIELD_ID_DROP_DOWN
:
734 case FIELD_ID_SCRIPT
:
735 case FIELD_ID_ANNOTATION
:
736 case FIELD_ID_DATABASE_NEXT
:
737 case FIELD_ID_DATABASE_SELECT
:
738 case FIELD_ID_VARIABLE_DECL
:
739 case FIELD_ID_USER_DECL
:
740 case FIELD_ID_SEQUENCE_DECL
:
741 case FIELD_ID_PLACEHOLDER
:
742 case FIELD_ID_UNKNOWN
:
743 case FIELD_ID_DRAW_HEADER
:
744 case FIELD_ID_DRAW_FOOTER
:
745 case FIELD_ID_DRAW_DATE_TIME
:
747 OSL_FAIL("unknown field type/field has no content");
748 return sal_True
; // invalid info; string in case of doubt
752 /// export the styles needed by the given field. Called on first pass
754 void XMLTextFieldExport::ExportFieldAutoStyle(
755 const Reference
<XTextField
> & rTextField
, const sal_Bool bProgress
,
756 const sal_Bool bRecursive
)
759 Reference
<XPropertySet
> xPropSet(rTextField
, UNO_QUERY
);
761 // add field master to list of used field masters (if desired)
762 if (NULL
!= pUsedMasters
)
764 Reference
<XDependentTextField
> xDepField(rTextField
, UNO_QUERY
);
767 Reference
<XText
> xOurText
= rTextField
->getAnchor()->getText();
769 map
<Reference
<XText
>, set
<OUString
> >::iterator aMapIter
=
770 pUsedMasters
->find(xOurText
);
772 // insert a list for our XText (if necessary)
773 if (aMapIter
== pUsedMasters
->end())
776 (*pUsedMasters
)[xOurText
] = aSet
;
777 aMapIter
= pUsedMasters
->find(xOurText
);
780 // insert this text field master
781 OUString sFieldMasterName
= GetStringProperty(
782 sPropertyInstanceName
, xDepField
->getTextFieldMaster());
783 if (!sFieldMasterName
.isEmpty())
784 aMapIter
->second
.insert( sFieldMasterName
);
786 // else: no dependent field -> no master -> ignore
790 FieldIdEnum nToken
= GetFieldID(rTextField
, xPropSet
);
792 // export the character style for all fields
793 // with one exception: combined character fields export their own
795 Reference
<XPropertySet
> xRangePropSet(rTextField
->getAnchor(), UNO_QUERY
);
796 if (FIELD_ID_COMBINED_CHARACTERS
!= nToken
)
798 GetExport().GetTextParagraphExport()->Add(
799 XML_STYLE_FAMILY_TEXT_TEXT
, xRangePropSet
);
802 // process special styles for each field (e.g. data styles)
805 case FIELD_ID_DATABASE_DISPLAY
:
807 sal_Int32 nFormat
= GetIntProperty(sPropertyNumberFormat
, xPropSet
);
808 // workaround: #no-bug#; see IsStringField(...)
809 if ( (5100 != nFormat
) &&
810 !GetBoolProperty(sPropertyIsDataBaseFormat
, xPropSet
) )
812 GetExport().addDataStyle(nFormat
);
820 // date and time fields are always number fields, but the
821 // NumberFormat property is optional (e.g. Calc doesn't
823 Reference
<XPropertySetInfo
> xPropSetInfo(
824 xPropSet
->getPropertySetInfo() );
825 if ( xPropSetInfo
->hasPropertyByName( sPropertyNumberFormat
) )
828 GetIntProperty(sPropertyNumberFormat
, xPropSet
);
830 // nFormat may be -1 for numeric fields that display their
831 // variable name. (Maybe this should be a field type, then?)
834 if( ! GetOptionalBoolProperty(
835 sPropertyIsFixedLanguage
,
836 xPropSet
, xPropSetInfo
, sal_False
) )
839 GetExport().dataStyleForceSystemLanguage(nFormat
);
842 GetExport().addDataStyle( nFormat
,
843 nToken
== FIELD_ID_TIME
);
850 // recurse into content (does not export element, so can be done first)
853 ExportMetaField(xPropSet
, true, bProgress
);
855 // fall-through: for the meta-field itself!
856 case FIELD_ID_DOCINFO_PRINT_TIME
:
857 case FIELD_ID_DOCINFO_PRINT_DATE
:
858 case FIELD_ID_DOCINFO_CREATION_DATE
:
859 case FIELD_ID_DOCINFO_CREATION_TIME
:
860 case FIELD_ID_DOCINFO_SAVE_TIME
:
861 case FIELD_ID_DOCINFO_SAVE_DATE
:
862 case FIELD_ID_DOCINFO_EDIT_DURATION
:
863 case FIELD_ID_VARIABLE_SET
:
864 case FIELD_ID_VARIABLE_GET
:
865 case FIELD_ID_VARIABLE_INPUT
:
866 case FIELD_ID_USER_GET
:
867 case FIELD_ID_EXPRESSION
:
868 case FIELD_ID_TABLE_FORMULA
:
869 case FIELD_ID_DOCINFO_CUSTOM
:
870 // register number format, if this is a numeric field
871 if (! IsStringField(nToken
, xPropSet
)) {
874 GetIntProperty(sPropertyNumberFormat
, xPropSet
);
876 // nFormat may be -1 for numeric fields that display their
877 // variable name. (Maybe this should be a field type, then?)
880 // handle formats for fixed language fields
881 // for all these fields (except table formula)
882 if( ( nToken
!= FIELD_ID_TABLE_FORMULA
) &&
883 ! GetOptionalBoolProperty(
884 sPropertyIsFixedLanguage
,
885 xPropSet
, xPropSet
->getPropertySetInfo(),
889 GetExport().dataStyleForceSystemLanguage(nFormat
);
892 GetExport().addDataStyle(nFormat
);
897 case FIELD_ID_COMBINED_CHARACTERS
:
899 // export text style with the addition of the combined characters
900 DBG_ASSERT(NULL
!= pCombinedCharactersPropertyState
,
901 "need proper PropertyState for combined characters");
902 const XMLPropertyState
*aStates
[] = { pCombinedCharactersPropertyState
, 0 };
903 GetExport().GetTextParagraphExport()->Add(
904 XML_STYLE_FAMILY_TEXT_TEXT
, xRangePropSet
,
909 case FIELD_ID_SCRIPT
:
910 case FIELD_ID_ANNOTATION
:
911 case FIELD_ID_BIBLIOGRAPHY
:
913 case FIELD_ID_REF_REFERENCE
:
914 case FIELD_ID_REF_SEQUENCE
:
915 case FIELD_ID_REF_BOOKMARK
:
916 case FIELD_ID_REF_FOOTNOTE
:
917 case FIELD_ID_REF_ENDNOTE
:
919 case FIELD_ID_REFPAGE_SET
:
920 case FIELD_ID_REFPAGE_GET
:
921 case FIELD_ID_COUNT_PAGES
:
922 case FIELD_ID_COUNT_PARAGRAPHS
:
923 case FIELD_ID_COUNT_WORDS
:
924 case FIELD_ID_COUNT_CHARACTERS
:
925 case FIELD_ID_COUNT_TABLES
:
926 case FIELD_ID_COUNT_GRAPHICS
:
927 case FIELD_ID_COUNT_OBJECTS
:
928 case FIELD_ID_CONDITIONAL_TEXT
:
929 case FIELD_ID_HIDDEN_TEXT
:
930 case FIELD_ID_HIDDEN_PARAGRAPH
:
931 case FIELD_ID_DOCINFO_CREATION_AUTHOR
:
932 case FIELD_ID_DOCINFO_DESCRIPTION
:
933 case FIELD_ID_DOCINFO_PRINT_AUTHOR
:
934 case FIELD_ID_DOCINFO_TITLE
:
935 case FIELD_ID_DOCINFO_SUBJECT
:
936 case FIELD_ID_DOCINFO_KEYWORDS
:
937 case FIELD_ID_DOCINFO_REVISION
:
938 case FIELD_ID_DOCINFO_SAVE_AUTHOR
:
939 case FIELD_ID_SEQUENCE
:
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
, sal_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
994 sal_Bool bHasHyperlink
;
995 sal_Bool bIsUICharStyle
;
996 sal_Bool bHasAutoStyle
;
997 OUString sStyle
= GetExport().GetTextParagraphExport()->
998 FindTextStyleAndHyperlink( xRangePropSet
, bHasHyperlink
, bIsUICharStyle
,
999 bHasAutoStyle
, pStates
);
1000 sal_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
,
1015 sal_False
, sal_False
);
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
, sal_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
,
1048 sal_False
, sal_False
);
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
,
1062 sal_Bool bProgress
)
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
), sal_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
), sal_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
), sal_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
),
1111 sal_True
, sal_True
, sal_True
,
1112 ! GetOptionalBoolProperty(
1113 sPropertyIsFixedLanguage
,
1114 rPropSet
, xPropSetInfo
, sal_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 sal_Bool bCmd
= GetBoolProperty(sPropertyIsShowFormula
, rPropSet
);
1124 ProcessDisplay(sal_True
, bCmd
);
1125 // #i81766# for older versions export of the value-type
1126 sal_Bool bExportValueType
= !bCmd
&& ( GetExport().getExportFlags() & EXPORT_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
, sal_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
),
1156 sal_True
, sal_True
, sal_True
,
1157 ! GetOptionalBoolProperty(
1158 sPropertyIsFixedLanguage
,
1159 rPropSet
, xPropSetInfo
, sal_False
) );
1160 ExportElement(XML_VARIABLE_INPUT
, sPresentation
);
1163 case FIELD_ID_USER_GET
:
1164 // user field: name, hidden, style
1166 sal_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 sal_False
, sal_False
, !bCmd
,
1173 ! GetOptionalBoolProperty(
1174 sPropertyIsFixedLanguage
,
1175 rPropSet
, xPropSetInfo
, sal_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 beeing 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 sal_Bool bCmd
= GetBoolProperty(sPropertyIsShowFormula
, rPropSet
);
1220 ProcessString(XML_FORMULA
, XML_NAMESPACE_OOOW
,
1221 GetStringProperty(sPropertyContent
, rPropSet
),
1223 ProcessDisplay(sal_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
, sal_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(sal_False
,
1253 GetIntProperty(sPropertyNumberFormat
,rPropSet
),
1254 sEmpty
, sEmpty
, 0.0, // not used
1255 sal_False
, sal_False
, sal_True
,
1256 ! GetOptionalBoolProperty(
1257 sPropertyIsFixedLanguage
,
1258 rPropSet
, xPropSetInfo
, sal_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
),
1287 sal_False
, sal_True
, sal_True
);
1289 ExportElement(XML_TIME
, sPresentation
);
1293 // all properties (except IsDate) are optional!
1294 if (xPropSetInfo
->hasPropertyByName(sPropertyNumberFormat
))
1296 ProcessValueAndType(sal_False
,
1297 GetIntProperty(sPropertyNumberFormat
,rPropSet
),
1298 sEmpty
, sEmpty
, 0.0, // not used
1299 sal_False
, sal_False
, sal_True
,
1300 ! GetOptionalBoolProperty(
1301 sPropertyIsFixedLanguage
,
1302 rPropSet
, xPropSetInfo
, sal_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
),
1332 sal_True
, sal_True
, sal_True
);
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( 0 == ( GetExport().getExportFlags() & EXPORT_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(sal_False
, // doesn't happen for text
1436 GetIntProperty(sPropertyNumberFormat
,rPropSet
),
1437 sEmpty
, sEmpty
, 0.0, // not used
1438 sal_False
, sal_False
, sal_True
, sal_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
), sal_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(sal_False
,
1461 GetIntProperty(sPropertyNumberFormat
, rPropSet
),
1462 sEmpty
, sEmpty
, 0.0,
1463 sal_False
, sal_False
, sal_True
,
1464 ! GetOptionalBoolProperty(
1465 sPropertyIsFixedLanguage
,
1466 rPropSet
, xPropSetInfo
, sal_False
) );
1468 // todo: export date/time value, but values not available -> core bug
1469 ProcessBoolean(XML_FIXED
,
1470 GetBoolProperty(sPropertyIsFixed
, rPropSet
), sal_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
), sal_False
);
1486 ExportElement(MapDocInfoFieldName(nToken
), sPresentation
);
1489 case FIELD_ID_DOCINFO_CUSTOM
:
1491 ProcessValueAndType(sal_False
, // doesn't happen for text
1492 GetIntProperty(sPropertyNumberFormat
,rPropSet
),
1493 sEmpty
, sEmpty
, 0.0, // not used
1494 sal_False
, sal_False
, sal_True
,
1495 ! GetOptionalBoolProperty(
1496 sPropertyIsFixedLanguage
,
1497 rPropSet
, xPropSetInfo
, sal_False
));
1498 uno::Any aAny
= rPropSet
->getPropertyValue( sPropertyName
);
1501 ProcessString(XML_NAME
, sName
);
1502 ProcessBoolean(XML_FIXED
, GetBoolProperty(sPropertyIsFixed
, rPropSet
), sal_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
), sal_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
);
1679 // this field is a special case because it gets mapped onto a
1680 // hyperlink, rather than one of the regular text field.
1681 ProcessString(XML_HREF
, GetExport().GetRelativeReference(GetStringProperty(sPropertyURL
, rPropSet
)),
1682 sal_False
, XML_NAMESPACE_XLINK
);
1683 ProcessString(XML_TARGET_FRAME_NAME
,
1684 GetStringProperty(sPropertyTargetFrame
,rPropSet
),
1685 sal_True
, XML_NAMESPACE_OFFICE
);
1686 GetExport().AddAttribute( XML_NAMESPACE_XLINK
, XML_TYPE
, XML_SIMPLE
);
1687 SvXMLElementExport
aUrlField(rExport
, XML_NAMESPACE_TEXT
, XML_A
,
1688 sal_False
, sal_False
);
1689 GetExport().Characters(sPresentation
);
1693 case FIELD_ID_BIBLIOGRAPHY
:
1695 ProcessBibliographyData(rPropSet
);
1696 ExportElement(XML_BIBLIOGRAPHY_MARK
, sPresentation
);
1700 case FIELD_ID_SCRIPT
:
1701 ProcessString(XML_LANGUAGE
,
1702 GetStringProperty(sPropertyScriptType
, rPropSet
),
1703 sal_True
, XML_NAMESPACE_SCRIPT
);
1704 DBG_ASSERT(sPresentation
.equals(sEmpty
),
1705 "Unexpected presentation for script field");
1706 if (GetBoolProperty(sPropertyURLContent
, rPropSet
))
1708 ProcessString(XML_HREF
,
1709 GetExport().GetRelativeReference(GetStringProperty(sPropertyContent
, rPropSet
)),
1710 sal_False
, XML_NAMESPACE_XLINK
);
1711 ExportElement(XML_SCRIPT
);
1715 ExportElement(XML_SCRIPT
,
1716 GetStringProperty(sPropertyContent
, rPropSet
));
1720 case FIELD_ID_ANNOTATION
:
1722 // check for empty presentation (just in case)
1723 DBG_ASSERT(sPresentation
.equals(sEmpty
),
1724 "Unexpected presentation for annotation field");
1726 // annotation element + content
1728 rPropSet
->getPropertyValue(sPropertyName
) >>= aName
;
1729 if (!aName
.isEmpty())
1730 GetExport().AddAttribute(XML_NAMESPACE_OFFICE
, XML_NAME
, aName
);
1731 SvXMLElementExport
aElem(GetExport(), XML_NAMESPACE_OFFICE
,
1732 XML_ANNOTATION
, sal_False
, sal_True
);
1735 OUString
aAuthor( GetStringProperty(sPropertyAuthor
, rPropSet
) );
1736 if( !aAuthor
.isEmpty() )
1738 SvXMLElementExport
aCreatorElem( GetExport(), XML_NAMESPACE_DC
,
1739 XML_CREATOR
, sal_True
,
1741 GetExport().Characters(aAuthor
);
1745 util::DateTime
aDate( GetDateTimeProperty(sPropertyDateTimeValue
, rPropSet
) );
1747 OUStringBuffer aBuffer
;
1748 ::sax::Converter::convertDateTime(aBuffer
, aDate
, true);
1749 SvXMLElementExport
aDateElem( GetExport(), XML_NAMESPACE_DC
,
1752 GetExport().Characters(aBuffer
.makeStringAndClear());
1755 if (SvtSaveOptions().GetODFDefaultVersion() > SvtSaveOptions::ODFVER_012
)
1758 OUString
aInitials( GetStringProperty(sPropertyInitials
, rPropSet
) );
1759 if( !aInitials
.isEmpty() )
1761 SvXMLElementExport
aCreatorElem( GetExport(), XML_NAMESPACE_TEXT
,
1762 XML_SENDER_INITIALS
, sal_True
,
1764 GetExport().Characters(aInitials
);
1768 com::sun::star::uno::Reference
< com::sun::star::text::XText
> xText
;
1771 com::sun::star::uno::Any aRet
= rPropSet
->getPropertyValue(sPropertyTextRange
);
1774 catch ( com::sun::star::uno::Exception
& )
1778 GetExport().GetTextParagraphExport()->exportText( xText
);
1780 ProcessParagraphSequence(GetStringProperty(sPropertyContent
,rPropSet
));
1784 case FIELD_ID_COMBINED_CHARACTERS
:
1786 // The style with the combined characters attribute has
1787 // already been handled in the ExportField method. So all that
1788 // is left to do now is to export the characters.
1789 GetExport().Characters(sPresentation
);
1795 ExportMetaField(rPropSet
, false, bProgress
);
1799 case FIELD_ID_MEASURE
:
1801 ProcessString(XML_KIND
, MapMeasureKind(GetInt16Property(sPropertyMeasureKind
, rPropSet
)));
1802 ExportElement( XML_MEASURE
, sPresentation
);
1806 case FIELD_ID_TABLE_FORMULA
:
1807 ProcessString( XML_FORMULA
, XML_NAMESPACE_OOOW
,
1808 GetStringProperty(sPropertyContent
, rPropSet
) );
1809 ProcessDisplay( sal_True
,
1810 GetBoolProperty(sPropertyIsShowFormula
, rPropSet
),
1812 ProcessValueAndType( sal_False
,
1813 GetIntProperty(sPropertyNumberFormat
, rPropSet
),
1814 sEmpty
, sEmpty
, 0.0f
,
1815 sal_False
, sal_False
, sal_True
,
1816 sal_False
, sal_False
);
1817 ExportElement( XML_TABLE_FORMULA
, sPresentation
);
1820 case FIELD_ID_DROP_DOWN
:
1822 ProcessString(XML_NAME
, GetStringProperty(sPropertyName
, rPropSet
));
1823 ProcessString(XML_HELP
,
1824 GetStringProperty(sPropertyHelp
, rPropSet
), true);
1825 ProcessString(XML_HINT
,
1826 GetStringProperty(sPropertyTooltip
, rPropSet
), true);
1827 SvXMLElementExport
aElem( GetExport(),
1828 XML_NAMESPACE_TEXT
, XML_DROPDOWN
,
1829 sal_False
, sal_False
);
1830 ProcessStringSequence
1831 (GetStringSequenceProperty( sPropertyItems
, rPropSet
),
1832 GetStringProperty( sPropertySelectedItem
, rPropSet
) );
1834 GetExport().Characters( sPresentation
);
1838 case FIELD_ID_DRAW_HEADER
:
1840 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_PRESENTATION
, XML_HEADER
, sal_False
, sal_False
);
1844 case FIELD_ID_DRAW_FOOTER
:
1846 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_PRESENTATION
, XML_FOOTER
, sal_False
, sal_False
);
1850 case FIELD_ID_DRAW_DATE_TIME
:
1852 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_PRESENTATION
, XML_DATE_TIME
, sal_False
, sal_False
);
1856 case FIELD_ID_UNKNOWN
:
1858 OSL_FAIL("unknown field type encountered!");
1859 // always export content
1860 GetExport().Characters(sPresentation
);
1865 /// export field declarations / field masters
1866 void XMLTextFieldExport::ExportFieldDeclarations()
1868 Reference
<XText
> xEmptyText
;
1869 ExportFieldDeclarations(xEmptyText
);
1872 /// export field declarations / field masters
1873 void XMLTextFieldExport::ExportFieldDeclarations(
1874 const Reference
<XText
> & rText
)
1876 // store lists for decl elements
1877 vector
<OUString
> aVarName
;
1878 vector
<OUString
> aUserName
;
1879 vector
<OUString
> aSeqName
;
1880 vector
<OUString
> aDdeName
;
1882 // get text fields supplier and field master name access
1883 Reference
<XTextFieldsSupplier
> xTextFieldsSupp(GetExport().GetModel(),
1885 if( !xTextFieldsSupp
.is() )
1888 Reference
<container::XNameAccess
> xFieldMasterNameAccess(
1889 xTextFieldsSupp
->getTextFieldMasters(), UNO_QUERY
);
1891 // where to get the text field masters from?
1892 // a) we get a specific XText: then use pUsedMasters
1893 // b) the XText is empty: then export all text fields
1894 Sequence
<OUString
> aFieldMasters
;
1897 // export only used masters
1898 DBG_ASSERT(NULL
!= pUsedMasters
,
1899 "field masters must be recorded in order to be "
1900 "written out separatly" );
1901 if (NULL
!= pUsedMasters
)
1903 map
<Reference
<XText
>, set
<OUString
> > ::iterator aMapIter
=
1904 pUsedMasters
->find(rText
);
1905 if (aMapIter
!= pUsedMasters
->end())
1907 // found the set of used field masters
1908 set
<OUString
> & rOurMasters
= aMapIter
->second
;
1910 // copy set to sequence
1911 aFieldMasters
.realloc( rOurMasters
.size() );
1913 for( set
<OUString
>::iterator aSetIter
= rOurMasters
.begin();
1914 aSetIter
!= rOurMasters
.end();
1917 aFieldMasters
[i
] = *aSetIter
;
1920 pUsedMasters
->erase(rText
);
1922 // else: XText not found -> ignore
1924 // else: no field masters have been recorded -> ignore
1928 // no XText: export all!
1929 aFieldMasters
= xFieldMasterNameAccess
->getElementNames();
1932 for(sal_Int32 i
=0; i
<aFieldMasters
.getLength(); i
++) {
1934 // get field master name
1935 OUString sFieldMaster
= aFieldMasters
[i
];
1937 // workaround for #no-bug#
1938 static const sal_Char sDB
[] =
1939 "com.sun.star.text.FieldMaster.DataBase.";
1940 if ( sFieldMaster
.matchIgnoreAsciiCaseAsciiL( sDB
, sizeof(sDB
)-1) )
1946 OUString sFieldMasterType
;
1948 ExplodeFieldMasterName(sFieldMaster
, sFieldMasterType
, sVarName
);
1950 // get XPropertySet of this field master
1951 Reference
<XPropertySet
> xPropSet
;
1952 Any aAny
= xFieldMasterNameAccess
->getByName(sFieldMaster
);
1955 // save interesting field masters
1956 if (0 == sFieldMasterType
.compareToAscii(FIELD_SERVICE_SETEXP
))
1958 sal_Int32 nType
= GetIntProperty(sPropertySubType
, xPropSet
);
1960 // sequence or variable?
1961 if ( SetVariableType::SEQUENCE
== nType
)
1963 aSeqName
.push_back( sFieldMaster
);
1967 aVarName
.push_back( sFieldMaster
);
1970 else if (0 == sFieldMasterType
.compareToAscii(FIELD_SERVICE_USER
))
1972 aUserName
.push_back( sFieldMaster
);
1974 else if (0 == sFieldMasterType
.compareToAscii(FIELD_SERVICE_DDE
))
1976 aDdeName
.push_back( sFieldMaster
);
1984 // now process fields:
1986 // variable field masters:
1987 if ( !aVarName
.empty() )
1989 SvXMLElementExport
aElem( GetExport(),
1992 sal_True
, sal_True
);
1994 for (vector
<OUString
>::iterator aVarIter
= aVarName
.begin();
1995 aVarIter
!= aVarName
.end();
1998 OUString sName
= *aVarIter
;
2000 // get field master property set
2001 Reference
<XPropertySet
> xPropSet
;
2002 Any aAny
= xFieldMasterNameAccess
->getByName(sName
);
2005 // field name and type
2006 OUString sFieldMasterType
;
2008 ExplodeFieldMasterName(sName
, sFieldMasterType
, sVarName
);
2010 // determine string/numeric field
2011 sal_Bool bIsString
= ( GetIntProperty(sPropertySubType
, xPropSet
)
2012 == SetVariableType::STRING
);
2014 // get dependent field property set
2015 Reference
<XPropertySet
> xFieldPropSet
;
2016 if (GetDependentFieldPropertySet(xPropSet
, xFieldPropSet
))
2018 // process value and type.
2019 ProcessValueAndType(
2021 GetIntProperty(sPropertyNumberFormat
, xFieldPropSet
),
2022 sEmpty
, sEmpty
, 0.0,
2023 sal_False
, sal_True
, sal_False
, sal_False
);
2027 // If no dependent field is found, only string and
2028 // float types can be supported
2030 // number format: 0 is default number format for 1st
2031 // language. should be: getDefaultNumberFormat(Locale)
2032 // from NumberFormats
2033 ProcessValueAndType(
2035 0, sEmpty
, sEmpty
, 0.0,
2036 sal_False
, sal_True
, sal_False
, sal_False
);
2039 ProcessString(XML_NAME
, sVarName
);
2040 ExportElement(XML_VARIABLE_DECL
, sal_True
);
2043 // else: no declarations element
2045 // sequence field masters:
2046 if ( !aSeqName
.empty() )
2048 SvXMLElementExport
aElem( GetExport(),
2051 sal_True
, sal_True
);
2053 for (vector
<OUString
>::iterator aSeqIter
= aSeqName
.begin();
2054 aSeqIter
!= aSeqName
.end();
2057 OUString sName
= *aSeqIter
;
2059 // get field master property set
2060 Reference
<XPropertySet
> xPropSet
;
2061 Any aAny
= xFieldMasterNameAccess
->getByName(sName
);
2064 // field name and type
2065 OUString sFieldMasterType
;
2067 ExplodeFieldMasterName(sName
, sFieldMasterType
, sVarName
);
2070 sal_Int32 nLevel
= 1 + GetIntProperty(
2071 sPropertyChapterNumberingLevel
, xPropSet
);
2072 DBG_ASSERT(nLevel
>= 0, "illegal outline level");
2073 DBG_ASSERT(nLevel
< 127, "possible illegal outline level");
2074 ProcessInteger(XML_DISPLAY_OUTLINE_LEVEL
, nLevel
);
2076 // separation character
2078 ProcessString(XML_SEPARATION_CHARACTER
, GetStringProperty(
2079 sPropertyNumberingSeparator
, xPropSet
));
2081 ProcessString(XML_NAME
, sVarName
);
2082 ExportElement(XML_SEQUENCE_DECL
, sal_True
);
2085 // else: no declarations element
2087 // user field field masters:
2088 if ( !aUserName
.empty() )
2090 SvXMLElementExport
aElem( GetExport(),
2092 XML_USER_FIELD_DECLS
,
2093 sal_True
, sal_True
);
2095 for (vector
<OUString
>::iterator aUserIter
= aUserName
.begin();
2096 aUserIter
!= aUserName
.end();
2099 OUString sName
= *aUserIter
;
2101 // get field master property set
2102 Reference
<XPropertySet
> xPropSet
;
2103 Any aAny
= xFieldMasterNameAccess
->getByName(sName
);
2106 // field name and type
2107 OUString sFieldMasterType
;
2109 ExplodeFieldMasterName(sName
, sFieldMasterType
, sVarName
);
2111 if (GetBoolProperty(sPropertyIsExpression
, xPropSet
))
2114 ProcessValueAndType(
2117 GetDoubleProperty(sPropertyValue
, xPropSet
),
2125 // string: write regardless of default
2126 ProcessString(XML_VALUE_TYPE
, XML_STRING
, sal_False
,
2127 XML_NAMESPACE_OFFICE
);
2128 ProcessString(XML_STRING_VALUE
,
2129 GetStringProperty(sPropertyContent
, xPropSet
),
2130 sal_False
, XML_NAMESPACE_OFFICE
);
2132 ProcessString(XML_NAME
, sVarName
);
2133 ExportElement(XML_USER_FIELD_DECL
, sal_True
);
2136 // else: no declarations element
2138 // DDE field field masters:
2139 if ( !aDdeName
.empty() )
2141 SvXMLElementExport
aElem( GetExport(),
2143 XML_DDE_CONNECTION_DECLS
,
2144 sal_True
, sal_True
);
2146 for (vector
<OUString
>::iterator aDdeIter
= aDdeName
.begin();
2147 aDdeIter
!= aDdeName
.end();
2150 OUString sName
= *aDdeIter
;
2152 // get field master property set
2153 Reference
<XPropertySet
> xPropSet
;
2154 Any aAny
= xFieldMasterNameAccess
->getByName(sName
);
2157 // check if this connection is being used by a field
2158 Reference
<XPropertySet
> xDummy
;
2159 if (GetDependentFieldPropertySet(xPropSet
, xDummy
))
2162 ProcessString(XML_NAME
,
2163 GetStringProperty(sPropertyName
, xPropSet
),
2164 sal_False
, XML_NAMESPACE_OFFICE
);
2166 // export elements; can't use ProcessString because
2167 // elements are in office namespace
2168 ProcessString(XML_DDE_APPLICATION
,
2169 GetStringProperty(sPropertyDDECommandType
,
2171 sal_False
, XML_NAMESPACE_OFFICE
);
2172 ProcessString(XML_DDE_TOPIC
,
2173 GetStringProperty(sPropertyDDECommandFile
,
2175 sal_False
, XML_NAMESPACE_OFFICE
);
2176 ProcessString(XML_DDE_ITEM
,
2177 GetStringProperty(sPropertyDDECommandElement
,
2179 sal_False
, XML_NAMESPACE_OFFICE
);
2180 sal_Bool bIsAutomaticUpdate
= GetBoolProperty(
2181 sPropertyIsAutomaticUpdate
, xPropSet
);
2182 if (bIsAutomaticUpdate
)
2184 GetExport().AddAttribute(XML_NAMESPACE_OFFICE
,
2185 XML_AUTOMATIC_UPDATE
,
2189 ExportElement(XML_DDE_CONNECTION_DECL
, sal_True
);
2191 // else: no dependent field -> no export of field declaration
2194 // else: no declarations element
2197 void XMLTextFieldExport::SetExportOnlyUsedFieldDeclarations(
2198 sal_Bool bExportOnlyUsed
)
2200 delete pUsedMasters
;
2201 pUsedMasters
= NULL
;
2203 // create used masters set (if none is used)
2204 if (bExportOnlyUsed
)
2205 pUsedMasters
= new map
<Reference
<XText
>, set
<OUString
> > ;
2208 void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName
,
2211 // can't call ExportElement(eElementName, const OUString&) with empty
2212 // string because xmlprinter only uses empty tags if no content
2213 // (not even empty content) was written.
2215 DBG_ASSERT(XML_TOKEN_INVALID
!= eElementName
, "invalid element name!");
2216 if (XML_TOKEN_INVALID
!= eElementName
)
2219 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
2220 eElementName
, bAddSpace
, bAddSpace
);
2224 void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName
,
2225 const OUString
& sContent
,
2228 DBG_ASSERT(eElementName
!= XML_TOKEN_INVALID
, "invalid element name!");
2229 if (eElementName
!= XML_TOKEN_INVALID
)
2232 if (eElementName
== XML_SENDER_INITIALS
)
2234 if (SvtSaveOptions().GetODFDefaultVersion() > SvtSaveOptions::ODFVER_012
)
2236 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
2237 eElementName
, bAddSpace
, bAddSpace
);
2239 GetExport().Characters(sContent
);
2244 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
2245 eElementName
, bAddSpace
, bAddSpace
);
2247 GetExport().Characters(sContent
);
2250 // always export content
2251 GetExport().Characters(sContent
);
2255 void XMLTextFieldExport::ExportMacro(
2256 const Reference
<XPropertySet
> & rPropSet
,
2257 const OUString
& rContent
)
2259 // some strings we'll need
2260 OUString
sEventType( "EventType" );
2261 OUString
sStarBasic( "StarBasic" );
2262 OUString
sScript( "Script" );
2263 OUString
sLibrary( "Library" );
2264 OUString
sMacroName( "MacroName" );
2265 OUString
sOnClick( "OnClick" );
2266 OUString
sPropertyMacroLibrary( "MacroLibrary" );
2267 OUString
sPropertyMacroName( "MacroName" );
2268 OUString
sPropertyScriptURL( "ScriptURL" );
2271 // the description attribute
2272 ProcessString(XML_DESCRIPTION
,
2273 GetStringProperty(sPropertyHint
, rPropSet
),
2277 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
2278 XML_EXECUTE_MACRO
, sal_False
, sal_False
);
2280 // the <office:events>-macro:
2282 // 1) build sequence of PropertyValues
2283 Sequence
<PropertyValue
> aSeq
;
2285 rPropSet
->getPropertyValue( sPropertyScriptURL
) >>= sName
;
2287 // if the ScriptURL property is not empty then this is a Scripting
2288 // Framework URL, otherwise treat it as a Basic Macro
2289 if (!sName
.isEmpty())
2291 aSeq
= Sequence
<PropertyValue
> (2);
2292 PropertyValue
* pArr
= aSeq
.getArray();
2293 pArr
[0].Name
= sEventType
;
2294 pArr
[0].Value
<<= sScript
;
2295 pArr
[1].Name
= sScript
;
2296 pArr
[1].Value
= rPropSet
->getPropertyValue( sPropertyScriptURL
);
2300 aSeq
= Sequence
<PropertyValue
> (3);
2301 PropertyValue
* pArr
= aSeq
.getArray();
2302 pArr
[0].Name
= sEventType
;
2303 pArr
[0].Value
<<= sStarBasic
;
2304 pArr
[1].Name
= sLibrary
;
2305 pArr
[1].Value
= rPropSet
->getPropertyValue( sPropertyMacroLibrary
);
2306 pArr
[2].Name
= sMacroName
;
2307 pArr
[2].Value
= rPropSet
->getPropertyValue( sPropertyMacroName
);
2310 // 2) export the sequence
2311 GetExport().GetEventExport().ExportSingleEvent( aSeq
, sOnClick
, sal_False
);
2313 // and finally, the field presentation
2314 GetExport().Characters(rContent
);
2317 void XMLTextFieldExport::ExportMetaField(
2318 const Reference
<XPropertySet
> & i_xMeta
,
2319 bool i_bAutoStyles
, sal_Bool i_bProgress
)
2321 bool doExport(!i_bAutoStyles
); // do not export element if autostyles
2322 // check version >= 1.2
2323 switch (GetExport().getDefaultVersion()) {
2324 case SvtSaveOptions::ODFVER_011
: // fall thru
2325 case SvtSaveOptions::ODFVER_010
: doExport
= false; break;
2329 const Reference
< XEnumerationAccess
> xEA( i_xMeta
, UNO_QUERY_THROW
);
2330 const Reference
< XEnumeration
> xTextEnum( xEA
->createEnumeration() );
2334 const Reference
<rdf::XMetadatable
> xMeta( i_xMeta
, UNO_QUERY_THROW
);
2336 // style:data-style-name
2337 ProcessValueAndType(sal_False
,
2338 GetIntProperty(sPropertyNumberFormat
, i_xMeta
),
2339 sEmpty
, sEmpty
, 0.0, sal_False
, sal_False
, sal_True
,
2340 sal_False
, sal_False
/*, sal_False*/ );
2342 // text:meta-field without xml:id is invalid
2343 xMeta
->ensureMetadataReference();
2345 // xml:id for RDF metadata
2346 GetExport().AddAttributeXmlId(xMeta
);
2349 SvXMLElementExport
aElem( GetExport(), doExport
,
2350 XML_NAMESPACE_TEXT
, XML_META_FIELD
, sal_False
, sal_False
);
2352 // recurse to export content
2353 GetExport().GetTextParagraphExport()->
2354 exportTextRangeEnumeration( xTextEnum
, i_bAutoStyles
, i_bProgress
);
2357 /// export all data-style related attributes
2358 void XMLTextFieldExport::ProcessValueAndType(
2359 sal_Bool bIsString
, /// do we process a string or a number?
2360 sal_Int32 nFormatKey
, /// format key for NumberFormatter; inv. if string
2361 const OUString
& sContent
, /// string content; possibly invalid
2362 const OUString
& sDefault
, /// default string
2363 double fValue
, /// float content; possibly invalid
2364 sal_Bool bExportValue
, /// export value attribute?
2365 sal_Bool bExportValueType
, /// export value-type attribute?
2366 sal_Bool bExportStyle
, /// export style-sttribute?
2367 sal_Bool bForceSystemLanguage
, /// export language attributes?
2368 sal_Bool bTimeStyle
) // exporting a time style?
2370 // String or number?
2374 // string: attributes value-type=string, string-value=...
2376 if (bExportValue
|| bExportValueType
)
2378 XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes(
2379 GetExport(), sContent
, sDefault
, bExportValue
);
2386 // number: value-type=..., value...=..., data-style-name=...
2388 DBG_ASSERT(bExportValueType
|| !bExportValue
, "value w/o value type not supported!");
2390 // take care of illegal formats
2391 // (shouldn't happen, but does if document is corrupted)
2392 if (-1 != nFormatKey
)
2394 if (bExportValue
|| bExportValueType
)
2396 XMLNumberFormatAttributesExportHelper::
2397 SetNumberFormatAttributes(
2398 GetExport(), nFormatKey
, fValue
, bExportValue
);
2403 // don't export language (if desired)
2404 if( bForceSystemLanguage
)
2406 GetExport().dataStyleForceSystemLanguage( nFormatKey
);
2408 OUString sDataStyleName
=
2409 GetExport().getDataStyleName(nFormatKey
, bTimeStyle
);
2410 if( !sDataStyleName
.isEmpty() )
2412 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
2413 XML_DATA_STYLE_NAME
,
2415 } // else: ignore (no valid number format)
2416 } // else: ignore (no number format)
2423 /// process display related properties
2424 void XMLTextFieldExport::ProcessDisplay(sal_Bool bIsVisible
,
2425 sal_Bool bIsCommand
,
2426 sal_Bool bValueDefault
)
2428 enum XMLTokenEnum eValue
;
2432 eValue
= bIsCommand
? XML_FORMULA
: XML_VALUE
;
2439 // omit attribute if default
2440 if (!bValueDefault
|| (eValue
!= XML_VALUE
))
2442 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_DISPLAY
, eValue
);
2448 /// export boolean property
2449 void XMLTextFieldExport::ProcessBoolean(enum XMLTokenEnum eName
,
2450 sal_Bool bBool
, sal_Bool bDefault
)
2452 DBG_ASSERT( eName
!= XML_TOKEN_INVALID
, "invalid element token");
2453 if ( XML_TOKEN_INVALID
== eName
)
2456 // write attribute (if different than default)
2457 // negate to force 0/1 values (and make sal_Bool comparable)
2458 if ((!bBool
) != (!bDefault
)) {
2459 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, eName
,
2460 (bBool
? XML_TRUE
: XML_FALSE
) );
2467 /// export string attribute
2468 void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName
,
2469 const OUString
& sValue
,
2470 sal_Bool bOmitEmpty
,
2473 DBG_ASSERT( eName
!= XML_TOKEN_INVALID
, "invalid element token");
2474 if ( XML_TOKEN_INVALID
== eName
)
2477 // check for empty string, if applicable
2478 if ( bOmitEmpty
&& sValue
.isEmpty() )
2482 GetExport().AddAttribute(nPrefix
, eName
, sValue
);
2485 void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName
,
2486 sal_uInt16 nValuePrefix
,
2487 const OUString
& sValue
,
2488 sal_Bool bOmitEmpty
,
2492 GetExport().GetNamespaceMap().GetQNameByKey( nValuePrefix
, sValue
, sal_False
);
2493 ProcessString( eName
, sQValue
, bOmitEmpty
, nPrefix
);
2496 /// export a string attribute
2497 void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName
,
2498 const OUString
& sValue
,
2499 const OUString
& sDefault
,
2502 if (sValue
!= sDefault
)
2504 ProcessString(eName
, sValue
, sal_False
, nPrefix
);
2508 /// export a string attribute
2509 void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName
,
2510 sal_uInt16 nValuePrefix
,
2511 const OUString
& sValue
,
2512 const OUString
& sDefault
,
2515 if (sValue
!= sDefault
)
2517 ProcessString(eName
, nValuePrefix
, sValue
, sal_False
, nPrefix
);
2522 /// export string attribute
2523 void XMLTextFieldExport::ProcessString(
2524 enum XMLTokenEnum eName
,
2525 enum XMLTokenEnum eValue
,
2526 sal_Bool bOmitEmpty
,
2529 DBG_ASSERT( eName
!= XML_TOKEN_INVALID
, "invalid element token" );
2530 DBG_ASSERT( bOmitEmpty
|| (eValue
!= XML_TOKEN_INVALID
),
2531 "invalid value token" );
2532 if ( XML_TOKEN_INVALID
== eName
)
2535 // check for empty string, if applicable
2536 if (bOmitEmpty
&& (eValue
== XML_TOKEN_INVALID
))
2539 GetExport().AddAttribute(nPrefix
, eName
, eValue
);
2542 /// export a string attribute
2543 void XMLTextFieldExport::ProcessString(
2544 enum XMLTokenEnum eName
,
2545 enum XMLTokenEnum eValue
,
2546 enum XMLTokenEnum eDefault
,
2549 if ( eValue
!= eDefault
)
2550 ProcessString( eName
, eValue
, sal_False
, nPrefix
);
2554 /// export a string as a sequence of paragraphs
2555 void XMLTextFieldExport::ProcessParagraphSequence(
2556 const OUString
& sParagraphSequence
)
2558 // iterate over all string-pieces separated by return (0x0a) and
2559 // put each inside a paragraph element.
2560 SvXMLTokenEnumerator
aEnumerator(sParagraphSequence
, sal_Char(0x0a));
2561 OUString aSubString
;
2562 while (aEnumerator
.getNextToken(aSubString
))
2564 SvXMLElementExport
aParagraph(
2565 GetExport(), XML_NAMESPACE_TEXT
, XML_P
, sal_True
, sal_False
);
2566 GetExport().Characters(aSubString
);
2570 // export an integer attribute
2571 void XMLTextFieldExport::ProcessInteger(enum XMLTokenEnum eName
,
2574 DBG_ASSERT( eName
!= XML_TOKEN_INVALID
, "invalid element token");
2575 if ( XML_TOKEN_INVALID
== eName
)
2578 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, eName
,
2579 OUString::valueOf(nNum
));
2582 /// export an integer attribute, omit if default
2583 void XMLTextFieldExport::ProcessIntegerDef(enum XMLTokenEnum eName
,
2584 sal_Int32 nNum
, sal_Int32 nDefault
)
2586 if (nNum
!= nDefault
)
2587 ProcessInteger(eName
, nNum
);
2592 /// export a numbering type
2593 void XMLTextFieldExport::ProcessNumberingType(sal_Int16 nNumberingType
)
2595 // process only if real format (not: like page descriptor)
2596 if (NumberingType::PAGE_DESCRIPTOR
!= nNumberingType
)
2598 OUStringBuffer
sTmp( 10 );
2599 // number type: num format
2600 GetExport().GetMM100UnitConverter().convertNumFormat( sTmp
,
2602 GetExport().AddAttribute(XML_NAMESPACE_STYLE
, XML_NUM_FORMAT
,
2603 sTmp
.makeStringAndClear() );
2604 // and letter sync, if applicable
2605 GetExport().GetMM100UnitConverter().convertNumLetterSync( sTmp
,
2608 if (sTmp
.getLength())
2610 GetExport().AddAttribute(XML_NAMESPACE_STYLE
, XML_NUM_LETTER_SYNC
,
2611 sTmp
.makeStringAndClear() );
2614 // else: like page descriptor => ignore
2618 /// export a date, time, or duration
2619 void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName
,
2622 sal_Bool bIsDuration
,
2623 sal_Bool bOmitDurationIfZero
,
2626 // truncate for date granularity
2629 dValue
= ::rtl::math::approxFloor(dValue
);
2632 OUStringBuffer aBuffer
;
2635 // date/time durationM handle bOmitDurationIfZero
2636 if (!bOmitDurationIfZero
|| !::rtl::math::approxEqual(dValue
, 0.0))
2638 ::sax::Converter::convertDuration(aBuffer
, dValue
);
2644 rExport
.GetMM100UnitConverter().convertDateTime(aBuffer
, dValue
);
2648 ProcessString(eName
, aBuffer
.makeStringAndClear(), sal_True
, nPrefix
);
2651 /// export a date or time
2652 void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName
,
2653 const util::DateTime
& rTime
,
2657 OUStringBuffer aBuffer
;
2659 util::DateTime
aDateTime(rTime
);
2664 aDateTime
.NanoSeconds
= 0;
2665 aDateTime
.Seconds
= 0;
2666 aDateTime
.Minutes
= 0;
2667 aDateTime
.Hours
= 0;
2671 ::sax::Converter::convertDateTime(aBuffer
, aDateTime
);
2674 ProcessString(eName
, aBuffer
.makeStringAndClear(), sal_True
, nPrefix
);
2677 /// export a date, time, or duration
2678 void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName
,
2681 sal_Bool bIsDuration
,
2682 sal_Bool bOmitDurationIfZero
,
2685 // handle bOmitDurationIfZero here, because we can precisely compare ints
2686 if (!(bIsDuration
&& bOmitDurationIfZero
&& (nMinutes
==0)))
2688 ProcessDateTime(eName
, (double)nMinutes
/ (double)(24*60),
2689 bIsDate
, bIsDuration
, bOmitDurationIfZero
, nPrefix
);
2693 /// export a time or dateTime
2694 void XMLTextFieldExport::ProcessTimeOrDateTime(enum XMLTokenEnum eName
,
2695 const util::DateTime
& rTime
,
2698 OUStringBuffer aBuffer
;
2701 // ::sax::Converter::convertTimeOrDateTime(aBuffer, rTime, 0);
2702 // NOTE: for 4.1 continue writing the invalid value that old versions can read
2703 ::sax::Converter::convertDateTime(aBuffer
, rTime
);
2706 ProcessString(eName
, aBuffer
.makeStringAndClear(), sal_True
, nPrefix
);
2710 SvXMLEnumMapEntry
const aBibliographyDataTypeMap
[] =
2712 { XML_ARTICLE
, BibliographyDataType::ARTICLE
},
2713 { XML_BOOK
, BibliographyDataType::BOOK
},
2714 { XML_BOOKLET
, BibliographyDataType::BOOKLET
},
2715 { XML_CONFERENCE
, BibliographyDataType::CONFERENCE
},
2716 { XML_CUSTOM1
, BibliographyDataType::CUSTOM1
},
2717 { XML_CUSTOM2
, BibliographyDataType::CUSTOM2
},
2718 { XML_CUSTOM3
, BibliographyDataType::CUSTOM3
},
2719 { XML_CUSTOM4
, BibliographyDataType::CUSTOM4
},
2720 { XML_CUSTOM5
, BibliographyDataType::CUSTOM5
},
2721 { XML_EMAIL
, BibliographyDataType::EMAIL
},
2722 { XML_INBOOK
, BibliographyDataType::INBOOK
},
2723 { XML_INCOLLECTION
, BibliographyDataType::INCOLLECTION
},
2724 { XML_INPROCEEDINGS
, BibliographyDataType::INPROCEEDINGS
},
2725 { XML_JOURNAL
, BibliographyDataType::JOURNAL
},
2726 { XML_MANUAL
, BibliographyDataType::MANUAL
},
2727 { XML_MASTERSTHESIS
, BibliographyDataType::MASTERSTHESIS
},
2728 { XML_MISC
, BibliographyDataType::MISC
},
2729 { XML_PHDTHESIS
, BibliographyDataType::PHDTHESIS
},
2730 { XML_PROCEEDINGS
, BibliographyDataType::PROCEEDINGS
},
2731 { XML_TECHREPORT
, BibliographyDataType::TECHREPORT
},
2732 { XML_UNPUBLISHED
, BibliographyDataType::UNPUBLISHED
},
2733 { XML_WWW
, BibliographyDataType::WWW
},
2734 { XML_TOKEN_INVALID
, 0 }
2739 void XMLTextFieldExport::ProcessBibliographyData(
2740 const Reference
<XPropertySet
>& rPropSet
)
2743 Any aAny
= rPropSet
->getPropertyValue(sPropertyFields
);
2744 Sequence
<PropertyValue
> aValues
;
2747 // one attribute per value (unless empty)
2748 sal_Int32 nLength
= aValues
.getLength();
2749 for (sal_Int32 i
= 0; i
< nLength
; i
++)
2751 if (aValues
[i
].Name
.equalsAsciiL("BibiliographicType",
2752 sizeof("BibiliographicType")-1))
2754 sal_Int16 nTypeId
= 0;
2755 aValues
[i
].Value
>>= nTypeId
;
2756 OUStringBuffer sBuf
;
2758 if (SvXMLUnitConverter::convertEnum(sBuf
, nTypeId
,
2759 aBibliographyDataTypeMap
))
2761 rExport
.AddAttribute(XML_NAMESPACE_TEXT
,
2762 XML_BIBLIOGRAPHY_TYPE
,
2763 sBuf
.makeStringAndClear());
2765 // else: ignore this argument
2770 aValues
[i
].Value
>>= sStr
;
2772 if (!sStr
.isEmpty())
2774 rExport
.AddAttribute(XML_NAMESPACE_TEXT
,
2775 MapBibliographyFieldName(aValues
[i
].Name
),
2782 /// export CommandTypeAttribute
2783 void XMLTextFieldExport::ProcessCommandType(
2784 sal_Int32 nCommandType
)
2786 enum XMLTokenEnum eToken
= XML_TOKEN_INVALID
;
2787 switch( nCommandType
)
2789 case sdb::CommandType::TABLE
: eToken
= XML_TABLE
; break;
2790 case sdb::CommandType::QUERY
: eToken
= XML_QUERY
; break;
2791 case sdb::CommandType::COMMAND
: eToken
= XML_COMMAND
; break;
2794 if( eToken
!= XML_TOKEN_INVALID
)
2795 rExport
.AddAttribute( XML_NAMESPACE_TEXT
, XML_TABLE_TYPE
, eToken
);
2799 void XMLTextFieldExport::ProcessStringSequence(
2800 const Sequence
<OUString
>& rSequence
,
2801 const OUString sSelected
)
2803 // find selected element
2804 sal_Int32 nSelected
= -1;
2805 sal_Int32 nLength
= rSequence
.getLength();
2806 const OUString
* pSequence
= rSequence
.getConstArray();
2807 for( sal_Int32 i
= 0; i
< nLength
; i
++ )
2809 if( pSequence
[i
] == sSelected
)
2813 // delegate to ProcessStringSequence(OUString,sal_Int32)
2814 ProcessStringSequence( rSequence
, nSelected
);
2817 void XMLTextFieldExport::ProcessStringSequence(
2818 const Sequence
<OUString
>& rSequence
,
2819 sal_Int32 nSelected
)
2821 sal_Int32 nLength
= rSequence
.getLength();
2822 const OUString
* pSequence
= rSequence
.getConstArray();
2823 for( sal_Int32 i
= 0; i
< nLength
; i
++ )
2825 if( i
== nSelected
)
2826 rExport
.AddAttribute( XML_NAMESPACE_TEXT
,
2827 XML_CURRENT_SELECTED
, XML_TRUE
);
2828 rExport
.AddAttribute( XML_NAMESPACE_TEXT
, XML_VALUE
, pSequence
[i
] );
2829 SvXMLElementExport
aElement( rExport
, XML_NAMESPACE_TEXT
, XML_LABEL
,
2830 sal_False
, sal_False
);
2834 void XMLTextFieldExport::ExportDataBaseElement(
2835 enum XMLTokenEnum eElementName
,
2836 const OUString
& sPresentation
,
2837 const Reference
<XPropertySet
>& rPropertySet
,
2838 const Reference
<XPropertySetInfo
>& rPropertySetInfo
)
2840 DBG_ASSERT( eElementName
!= XML_TOKEN_INVALID
, "need token" );
2841 DBG_ASSERT( rPropertySet
.is(), "need property set" );
2842 DBG_ASSERT( rPropertySetInfo
.is(), "need property set info" );
2844 // get database properties
2845 OUString sDataBaseName
;
2846 OUString sDataBaseURL
;
2848 if( ( rPropertySet
->getPropertyValue( sPropertyDataBaseName
) >>= sStr
)
2849 && !sStr
.isEmpty() )
2851 sDataBaseName
= sStr
;
2853 else if( rPropertySetInfo
->hasPropertyByName( sPropertyDataBaseURL
) &&
2854 (rPropertySet
->getPropertyValue( sPropertyDataBaseURL
) >>= sStr
) &&
2857 sDataBaseURL
= sStr
;
2860 // add database name property (if present)
2861 if( !sDataBaseName
.isEmpty() )
2862 rExport
.AddAttribute( XML_NAMESPACE_TEXT
, XML_DATABASE_NAME
,
2864 SvXMLElementExport
aDataBaseElement( GetExport(),
2865 XML_NAMESPACE_TEXT
, eElementName
,
2866 sal_False
, sal_False
);
2868 // write URL as children
2869 if( !sDataBaseURL
.isEmpty() )
2871 rExport
.AddAttribute( XML_NAMESPACE_XLINK
, XML_HREF
, sDataBaseURL
);
2872 SvXMLElementExport
aDataSourceElement(
2873 GetExport(), XML_NAMESPACE_FORM
, XML_CONNECTION_RESOURCE
,
2874 sal_False
, sal_False
);
2877 // write presentation
2878 rExport
.Characters( sPresentation
);
2883 // explode a field master name into field type and field name
2884 sal_Bool
XMLTextFieldExport::ExplodeFieldMasterName(
2885 const OUString
& sMasterName
, OUString
& sFieldType
, OUString
& sVarName
)
2887 sal_Int32 nLength
= sFieldMasterPrefix
.getLength();
2888 sal_Int32 nSeparator
= sMasterName
.indexOf('.', nLength
);
2889 sal_Bool bReturn
= sal_True
;
2892 // check for service name
2893 bReturn
&= (0 == sFieldMasterPrefix
.compareTo(sMasterName
, nLength
));
2897 if (nSeparator
<= nLength
) {
2898 nSeparator
= sMasterName
.getLength();
2899 DBG_WARNING("no field var name!");
2900 bReturn
= sal_False
;
2904 sFieldType
= sMasterName
.copy(nLength
, nSeparator
-nLength
);
2905 sVarName
= sMasterName
.copy(nSeparator
+1);
2912 // for XDependentTextFields, get PropertySet of FieldMaster
2913 Reference
<XPropertySet
> XMLTextFieldExport::GetMasterPropertySet(
2914 const Reference
<XTextField
> & rTextField
)
2916 // name, value => get Property set of TextFieldMaster
2917 Reference
<XDependentTextField
> xDep(rTextField
, UNO_QUERY
);
2918 return xDep
->getTextFieldMaster();
2921 // get PropertySet of (any; the first) dependent field
2922 sal_Bool
XMLTextFieldExport::GetDependentFieldPropertySet(
2923 const Reference
<XPropertySet
> & xMaster
,
2924 Reference
<XPropertySet
> & xField
)
2927 Sequence
<Reference
<XDependentTextField
> > aFields
;
2928 aAny
= xMaster
->getPropertyValue(sPropertyDependentTextFields
);
2932 if (aFields
.getLength() > 0)
2934 // get first one and return
2935 Reference
<XDependentTextField
> xTField
= aFields
[0];
2936 xField
= Reference
<XPropertySet
>(xTField
, UNO_QUERY
);
2937 DBG_ASSERT(xField
.is(),
2938 "Surprisinlgy, this TextField refuses to be a PropertySet!");
2948 /// map placeholder type
2949 enum XMLTokenEnum
XMLTextFieldExport::MapPlaceholderType(sal_uInt16 nType
)
2951 enum XMLTokenEnum eType
= XML_TEXT
;
2955 case PlaceholderType::TEXT
:
2959 case PlaceholderType::TABLE
:
2963 case PlaceholderType::TEXTFRAME
:
2964 eType
= XML_TEXT_BOX
;
2967 case PlaceholderType::GRAPHIC
:
2971 case PlaceholderType::OBJECT
:
2976 // unknown placeholder: XML_TEXT
2977 OSL_FAIL("unknown placeholder type");
2984 /// element name for author fields
2985 enum XMLTokenEnum
XMLTextFieldExport::MapAuthorFieldName(
2986 const Reference
<XPropertySet
> & xPropSet
)
2988 // Initalen oder voller Name?
2989 return GetBoolProperty(sPropertyFullName
, xPropSet
)
2990 ? XML_AUTHOR_NAME
: XML_AUTHOR_INITIALS
;
2993 enum XMLTokenEnum
XMLTextFieldExport::MapPageNumberName(
2994 const Reference
<XPropertySet
> & xPropSet
,
2997 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
2998 PageNumberType ePage
;
2999 Any aAny
= xPropSet
->getPropertyValue(sPropertySubType
);
3000 ePage
= *(PageNumberType
*)aAny
.getValue();
3004 case PageNumberType_PREV
:
3005 eName
= XML_PREVIOUS
;
3008 case PageNumberType_CURRENT
:
3009 eName
= XML_CURRENT
;
3011 case PageNumberType_NEXT
:
3016 OSL_FAIL("unknown page number type");
3017 eName
= XML_TOKEN_INVALID
;
3024 /// map TemplateDisplayFormat to XML
3025 enum XMLTokenEnum
XMLTextFieldExport::MapTemplateDisplayFormat(sal_Int16 nFormat
)
3027 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
3031 case TemplateDisplayFormat::FULL
:
3034 case TemplateDisplayFormat::PATH
:
3037 case TemplateDisplayFormat::NAME
:
3040 case TemplateDisplayFormat::NAME_AND_EXT
:
3041 eName
= XML_NAME_AND_EXTENSION
;
3043 case TemplateDisplayFormat::AREA
:
3046 case TemplateDisplayFormat::TITLE
:
3050 OSL_FAIL("unknown template display format");
3051 eName
= XML_TOKEN_INVALID
;
3058 /// map count/statistics field token to XML name
3059 enum XMLTokenEnum
XMLTextFieldExport::MapCountFieldName(FieldIdEnum nToken
)
3061 enum XMLTokenEnum eElement
= XML_TOKEN_INVALID
;
3065 case FIELD_ID_COUNT_PAGES
:
3066 eElement
= XML_PAGE_COUNT
;
3068 case FIELD_ID_COUNT_PARAGRAPHS
:
3069 eElement
= XML_PARAGRAPH_COUNT
;
3071 case FIELD_ID_COUNT_WORDS
:
3072 eElement
= XML_WORD_COUNT
;
3074 case FIELD_ID_COUNT_CHARACTERS
:
3075 eElement
= XML_CHARACTER_COUNT
;
3077 case FIELD_ID_COUNT_TABLES
:
3078 eElement
= XML_TABLE_COUNT
;
3080 case FIELD_ID_COUNT_GRAPHICS
:
3081 eElement
= XML_IMAGE_COUNT
;
3083 case FIELD_ID_COUNT_OBJECTS
:
3084 eElement
= XML_OBJECT_COUNT
;
3087 OSL_FAIL("no count field token");
3088 eElement
= XML_TOKEN_INVALID
;
3095 /// map ChapterDisplayFormat to XML string
3096 enum XMLTokenEnum
XMLTextFieldExport::MapChapterDisplayFormat(sal_Int16 nFormat
)
3098 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
3102 case ChapterFormat::NAME
:
3105 case ChapterFormat::NUMBER
:
3108 case ChapterFormat::NAME_NUMBER
:
3109 eName
= XML_NUMBER_AND_NAME
;
3111 case ChapterFormat::NO_PREFIX_SUFFIX
:
3112 eName
= XML_PLAIN_NUMBER_AND_NAME
;
3114 case ChapterFormat::DIGIT
:
3115 eName
= XML_PLAIN_NUMBER
;
3118 OSL_FAIL("unknown chapter display format");
3119 eName
= XML_TOKEN_INVALID
;
3127 /// map FilenameDisplayFormat to XML attribute names
3128 enum XMLTokenEnum
XMLTextFieldExport::MapFilenameDisplayFormat(sal_Int16 nFormat
)
3130 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
3134 case FilenameDisplayFormat::FULL
:
3137 case FilenameDisplayFormat::PATH
:
3140 case FilenameDisplayFormat::NAME
:
3143 case FilenameDisplayFormat::NAME_AND_EXT
:
3144 eName
= XML_NAME_AND_EXTENSION
;
3147 OSL_FAIL("unknown filename display format");
3154 /// map ReferenceFieldPart to XML string
3155 enum XMLTokenEnum
XMLTextFieldExport::MapReferenceType(sal_Int16 nType
)
3157 enum XMLTokenEnum eElement
= XML_TOKEN_INVALID
;
3161 case ReferenceFieldPart::PAGE
:
3162 eElement
= XML_PAGE
;
3164 case ReferenceFieldPart::CHAPTER
:
3165 eElement
= XML_CHAPTER
;
3167 case ReferenceFieldPart::TEXT
:
3168 eElement
= XML_TEXT
;
3170 case ReferenceFieldPart::UP_DOWN
:
3171 eElement
= XML_DIRECTION
;
3173 case ReferenceFieldPart::CATEGORY_AND_NUMBER
:
3174 eElement
= XML_CATEGORY_AND_VALUE
;
3176 case ReferenceFieldPart::ONLY_CAPTION
:
3177 eElement
= XML_CAPTION
;
3179 case ReferenceFieldPart::ONLY_SEQUENCE_NUMBER
:
3180 eElement
= XML_VALUE
;
3182 case ReferenceFieldPart::PAGE_DESC
:
3183 // small hack: this value never gets written, because
3184 // XML_TEMPLATE is default
3185 eElement
= XML_TEMPLATE
;
3187 // Core implementation for direct cross-references (#i81002#)
3188 case ReferenceFieldPart::NUMBER
:
3189 eElement
= XML_NUMBER
;
3191 case ReferenceFieldPart::NUMBER_NO_CONTEXT
:
3192 eElement
= XML_NUMBER_NO_SUPERIOR
;
3194 case ReferenceFieldPart::NUMBER_FULL_CONTEXT
:
3195 eElement
= XML_NUMBER_ALL_SUPERIOR
;
3198 OSL_FAIL("unknown reference type");
3199 eElement
= XML_TEMPLATE
;
3206 /// map ReferenceFieldPart to XML string
3207 enum XMLTokenEnum
XMLTextFieldExport::MapReferenceSource(sal_Int16 nType
)
3209 enum XMLTokenEnum eElement
= XML_TOKEN_INVALID
;
3213 case ReferenceFieldSource::REFERENCE_MARK
:
3214 eElement
= XML_REFERENCE_REF
;
3216 case ReferenceFieldSource::SEQUENCE_FIELD
:
3217 eElement
= XML_SEQUENCE_REF
;
3219 case ReferenceFieldSource::BOOKMARK
:
3220 eElement
= XML_BOOKMARK_REF
;
3222 case ReferenceFieldSource::FOOTNOTE
:
3223 case ReferenceFieldSource::ENDNOTE
:
3224 eElement
= XML_NOTE_REF
;
3227 OSL_FAIL("unknown reference source");
3235 /// element name for sender fields
3236 enum XMLTokenEnum
XMLTextFieldExport::MapSenderFieldName(
3237 const Reference
<XPropertySet
> & xPropSet
)
3239 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
3242 switch (GetInt16Property(sPropertyFieldSubType
, xPropSet
))
3244 case UserDataPart::COMPANY
:
3245 eName
= XML_SENDER_COMPANY
;
3247 case UserDataPart::FIRSTNAME
:
3248 eName
= XML_SENDER_FIRSTNAME
;
3250 case UserDataPart::NAME
:
3251 eName
= XML_SENDER_LASTNAME
;
3253 case UserDataPart::SHORTCUT
:
3254 eName
= XML_SENDER_INITIALS
;
3256 case UserDataPart::STREET
:
3257 eName
= XML_SENDER_STREET
;
3259 case UserDataPart::COUNTRY
:
3260 eName
= XML_SENDER_COUNTRY
;
3262 case UserDataPart::ZIP
:
3263 eName
= XML_SENDER_POSTAL_CODE
;
3265 case UserDataPart::CITY
:
3266 eName
= XML_SENDER_CITY
;
3268 case UserDataPart::TITLE
:
3269 eName
= XML_SENDER_TITLE
;
3271 case UserDataPart::POSITION
:
3272 eName
= XML_SENDER_POSITION
;
3274 case UserDataPart::PHONE_PRIVATE
:
3275 eName
= XML_SENDER_PHONE_PRIVATE
;
3277 case UserDataPart::PHONE_COMPANY
:
3278 eName
= XML_SENDER_PHONE_WORK
;
3280 case UserDataPart::FAX
:
3281 eName
= XML_SENDER_FAX
;
3283 case UserDataPart::EMAIL
:
3284 eName
= XML_SENDER_EMAIL
;
3286 case UserDataPart::STATE
:
3287 eName
= XML_SENDER_STATE_OR_PROVINCE
;
3290 DBG_WARNING("unknown sender type");
3291 eName
= XML_TOKEN_INVALID
;
3298 enum XMLTokenEnum
XMLTextFieldExport::MapDocInfoFieldName(
3299 enum FieldIdEnum nToken
)
3301 enum XMLTokenEnum eElement
= XML_TOKEN_INVALID
;
3305 case FIELD_ID_DOCINFO_CREATION_AUTHOR
:
3306 eElement
= XML_INITIAL_CREATOR
;
3308 case FIELD_ID_DOCINFO_CREATION_DATE
:
3309 eElement
= XML_CREATION_DATE
;
3311 case FIELD_ID_DOCINFO_CREATION_TIME
:
3312 eElement
= XML_CREATION_TIME
;
3314 case FIELD_ID_DOCINFO_DESCRIPTION
:
3315 eElement
= XML_DESCRIPTION
;
3317 case FIELD_ID_DOCINFO_PRINT_TIME
:
3318 eElement
= XML_PRINT_TIME
;
3320 case FIELD_ID_DOCINFO_PRINT_DATE
:
3321 eElement
= XML_PRINT_DATE
;
3323 case FIELD_ID_DOCINFO_PRINT_AUTHOR
:
3324 eElement
= XML_PRINTED_BY
;
3326 case FIELD_ID_DOCINFO_TITLE
:
3327 eElement
= XML_TITLE
;
3329 case FIELD_ID_DOCINFO_SUBJECT
:
3330 eElement
= XML_SUBJECT
;
3332 case FIELD_ID_DOCINFO_KEYWORDS
:
3333 eElement
= XML_KEYWORDS
;
3335 case FIELD_ID_DOCINFO_REVISION
:
3336 eElement
= XML_EDITING_CYCLES
;
3338 case FIELD_ID_DOCINFO_EDIT_DURATION
:
3339 eElement
= XML_EDITING_DURATION
;
3341 case FIELD_ID_DOCINFO_SAVE_TIME
:
3342 eElement
= XML_MODIFICATION_TIME
;
3344 case FIELD_ID_DOCINFO_SAVE_DATE
:
3345 eElement
= XML_MODIFICATION_DATE
;
3347 case FIELD_ID_DOCINFO_SAVE_AUTHOR
:
3348 eElement
= XML_CREATOR
;
3351 DBG_WARNING("unknown docinfo field type!");
3352 eElement
= XML_TOKEN_INVALID
;
3359 enum XMLTokenEnum
XMLTextFieldExport::MapBibliographyFieldName(OUString sName
)
3361 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
3363 if (sName
.equalsAsciiL("Identifier", sizeof("Identifier")-1))
3365 eName
= XML_IDENTIFIER
;
3367 else if (sName
.equalsAsciiL("BibiliographicType",
3368 sizeof("BibiliographicType")-1))
3370 eName
= XML_BIBLIOGRAPHY_TYPE
;
3372 else if (sName
.equalsAsciiL("Address", sizeof("Address")-1))
3374 eName
= XML_ADDRESS
;
3376 else if (sName
.equalsAsciiL("Annote", sizeof("Annote")-1))
3380 else if (sName
.equalsAsciiL("Author", sizeof("Author")-1))
3384 else if (sName
.equalsAsciiL("Booktitle", sizeof("Booktitle")-1))
3386 eName
= XML_BOOKTITLE
;
3388 else if (sName
.equalsAsciiL("Chapter", sizeof("Chapter")-1))
3390 eName
= XML_CHAPTER
;
3392 else if (sName
.equalsAsciiL("Edition", sizeof("Edition")-1))
3394 eName
= XML_EDITION
;
3396 else if (sName
.equalsAsciiL("Editor", sizeof("Editor")-1))
3400 else if (sName
.equalsAsciiL("Howpublished", sizeof("Howpublished")-1))
3402 eName
= XML_HOWPUBLISHED
;
3404 else if (sName
.equalsAsciiL("Institution", sizeof("Institution")-1))
3406 eName
= XML_INSTITUTION
;
3408 else if (sName
.equalsAsciiL("Journal", sizeof("Journal")-1))
3410 eName
= XML_JOURNAL
;
3412 else if (sName
.equalsAsciiL("Month", sizeof("Month")-1))
3416 else if (sName
.equalsAsciiL("Note", sizeof("Note")-1))
3420 else if (sName
.equalsAsciiL("Number", sizeof("Number")-1))
3424 else if (sName
.equalsAsciiL("Organizations", sizeof("Organizations")-1))
3426 eName
= XML_ORGANIZATIONS
;
3428 else if (sName
.equalsAsciiL("Pages", sizeof("Pages")-1))
3432 else if (sName
.equalsAsciiL("Publisher", sizeof("Publisher")-1))
3434 eName
= XML_PUBLISHER
;
3436 else if (sName
.equalsAsciiL("School", sizeof("School")-1))
3440 else if (sName
.equalsAsciiL("Series", sizeof("Series")-1))
3444 else if (sName
.equalsAsciiL("Title", sizeof("Title")-1))
3448 else if (sName
.equalsAsciiL("Report_Type", sizeof("Report_Type")-1))
3450 eName
= XML_REPORT_TYPE
;
3452 else if (sName
.equalsAsciiL("Volume", sizeof("Volume")-1))
3456 else if (sName
.equalsAsciiL("Year", sizeof("Year")-1))
3460 else if (sName
.equalsAsciiL("URL", sizeof("URL")-1))
3464 else if (sName
.equalsAsciiL("Custom1", sizeof("Custom1")-1))
3466 eName
= XML_CUSTOM1
;
3468 else if (sName
.equalsAsciiL("Custom2", sizeof("Custom2")-1))
3470 eName
= XML_CUSTOM2
;
3472 else if (sName
.equalsAsciiL("Custom3", sizeof("Custom3")-1))
3474 eName
= XML_CUSTOM3
;
3476 else if (sName
.equalsAsciiL("Custom4", sizeof("Custom4")-1))
3478 eName
= XML_CUSTOM4
;
3480 else if (sName
.equalsAsciiL("Custom5", sizeof("Custom5")-1))
3482 eName
= XML_CUSTOM5
;
3484 else if (sName
.equalsAsciiL("ISBN", sizeof("ISBN")-1))
3490 OSL_FAIL("Unknown bibliography info data");
3491 eName
= XML_TOKEN_INVALID
;
3497 enum XMLTokenEnum
XMLTextFieldExport::MapMeasureKind(sal_Int16 nKind
)
3509 OUString
XMLTextFieldExport::MakeFootnoteRefName(
3512 // generate foot-/endnote ID
3513 OUStringBuffer aBuf
;
3514 aBuf
.appendAscii("ftn");
3515 aBuf
.append((sal_Int32
)nSeqNo
);
3516 return aBuf
.makeStringAndClear();
3519 OUString
XMLTextFieldExport::MakeSequenceRefName(
3521 const OUString
& rSeqName
)
3523 // generate foot-/endnote ID
3524 OUStringBuffer aBuf
;
3525 aBuf
.appendAscii("ref");
3526 aBuf
.append(rSeqName
);
3527 aBuf
.append((sal_Int32
)nSeqNo
);
3528 return aBuf
.makeStringAndClear();
3532 // Property accessor helper functions
3535 // to be relegated (does that word exist?) to a more appropriate place
3539 inline sal_Bool
GetBoolProperty(
3540 const OUString
& sPropName
,
3541 const Reference
<XPropertySet
> & xPropSet
)
3543 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3544 sal_Bool bBool
= *(sal_Bool
*)aAny
.getValue();
3548 inline sal_Bool
GetOptionalBoolProperty(
3549 const OUString
& sPropName
,
3550 const Reference
<XPropertySet
> & xPropSet
,
3551 const Reference
<XPropertySetInfo
> & xPropSetInfo
,
3554 return xPropSetInfo
->hasPropertyByName( sPropName
)
3555 ? GetBoolProperty( sPropName
, xPropSet
) : bDefault
;
3558 inline double GetDoubleProperty(
3559 const OUString
& sPropName
,
3560 const Reference
<XPropertySet
> & xPropSet
)
3562 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3563 double fDouble
= 0.0;
3568 inline OUString
const GetStringProperty(
3569 const OUString
& sPropName
,
3570 const Reference
<XPropertySet
> & xPropSet
)
3572 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3578 inline sal_Int32
GetIntProperty(
3579 const OUString
& sPropName
,
3580 const Reference
<XPropertySet
> & xPropSet
)
3582 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3588 inline sal_Int16
GetInt16Property(
3589 const OUString
& sPropName
,
3590 const Reference
<XPropertySet
> & xPropSet
)
3592 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3598 inline sal_Int8
GetInt8Property(
3599 const OUString
& sPropName
,
3600 const Reference
<XPropertySet
> & xPropSet
)
3602 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3608 inline util::DateTime
const GetDateTimeProperty(
3609 const OUString
& sPropName
,
3610 const Reference
<XPropertySet
> & xPropSet
)
3612 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3613 util::DateTime aTime
;
3618 inline Sequence
<OUString
> const GetStringSequenceProperty(
3619 const OUString
& sPropName
,
3620 const Reference
<XPropertySet
> & xPropSet
)
3622 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3623 Sequence
<OUString
> aSequence
;
3628 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */