Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : /** @#file
22 : *
23 : * export of all text fields
24 : */
25 : #include "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"
33 :
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>
39 :
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>
53 :
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>
69 :
70 : #include <vector>
71 :
72 :
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;
84 :
85 :
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";
155 :
156 : SvXMLEnumStringMapEntry const aFieldServiceNameMapping[] =
157 : {
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 ),
170 :
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 ),
178 :
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 ),
205 :
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 ),
209 :
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 ),
213 :
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 ),
221 :
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 ),
225 :
226 : ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_BIBLIOGRAPHY, FIELD_ID_BIBLIOGRAPHY ),
227 :
228 : ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SCRIPT, FIELD_ID_SCRIPT ),
229 : ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_ANNOTATION, FIELD_ID_ANNOTATION ),
230 :
231 : ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_COMBINED_CHARACTERS, FIELD_ID_COMBINED_CHARACTERS ),
232 : ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_META, FIELD_ID_META ),
233 :
234 : // non-writer fields
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 ),
238 :
239 : // deprecated fields
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 ),
242 :
243 : ENUM_STRING_MAP_END()
244 : };
245 :
246 :
247 :
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> &,
254 : sal_Bool bDefault);
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);
270 :
271 :
272 :
273 88 : XMLTextFieldExport::XMLTextFieldExport( SvXMLExport& rExp,
274 : XMLPropertyState* pCombinedCharState)
275 : : rExport(rExp),
276 : pUsedMasters(NULL),
277 : sServicePrefix("com.sun.star.text.textfield."),
278 : sFieldMasterPrefix("com.sun.star.text.FieldMaster."),
279 : sPresentationServicePrefix("com.sun.star.presentation.TextField."),
280 :
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"),
328 : sPropertyOn("On"),
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"),
344 : sPropertyURL("URL"),
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 88 : pCombinedCharactersPropertyState(pCombinedCharState)
354 : {
355 88 : SetExportOnlyUsedFieldDeclarations();
356 88 : }
357 :
358 264 : XMLTextFieldExport::~XMLTextFieldExport()
359 : {
360 88 : delete pCombinedCharactersPropertyState;
361 88 : delete pUsedMasters;
362 176 : }
363 :
364 : /// get the field ID (as in FieldIDEnum) from XTextField
365 200 : enum FieldIdEnum XMLTextFieldExport::GetFieldID(
366 : const Reference<XTextField> & rTextField,
367 : const Reference<XPropertySet> & xPropSet)
368 : {
369 : // get service names for rTextField (via XServiceInfo service)
370 200 : Reference<XServiceInfo> xService(rTextField, UNO_QUERY);
371 400 : const Sequence<OUString> aServices = xService->getSupportedServiceNames();
372 200 : const OUString* pNames = aServices.getConstArray();
373 200 : sal_Int32 nCount = aServices.getLength();
374 :
375 400 : OUString sFieldName; // service name postfix of current field
376 :
377 : // search for TextField service name
378 848 : while( nCount-- )
379 : {
380 616 : if (pNames->matchIgnoreAsciiCase(sServicePrefix))
381 : {
382 : // TextField found => postfix is field type!
383 168 : sFieldName = pNames->copy(sServicePrefix.getLength());
384 168 : break;
385 : }
386 :
387 448 : ++pNames;
388 : }
389 :
390 : // if this is not a normal text field, check if its a presentation text field
391 200 : if( sFieldName.isEmpty() )
392 : {
393 32 : const OUString* pNames2 = aServices.getConstArray();
394 32 : sal_Int32 nCount2 = aServices.getLength();
395 : // search for TextField service name
396 128 : while( nCount2-- )
397 : {
398 96 : if( 0 == pNames2->compareTo(sPresentationServicePrefix, sPresentationServicePrefix.getLength()))
399 : {
400 : // TextField found => postfix is field type!
401 32 : sFieldName = pNames2->copy(sPresentationServicePrefix.getLength());
402 32 : break;
403 : }
404 :
405 64 : ++pNames2;
406 : }
407 :
408 32 : if( !sFieldName.isEmpty() )
409 : {
410 32 : if( sFieldName.reverseCompareTo( "Header" ) == 0 )
411 : {
412 8 : return FIELD_ID_DRAW_HEADER;
413 : }
414 24 : else if( sFieldName.reverseCompareTo( "Footer" ) == 0 )
415 : {
416 12 : return FIELD_ID_DRAW_FOOTER;
417 : }
418 12 : else if( sFieldName.reverseCompareTo( "DateTime" ) == 0 )
419 : {
420 12 : return FIELD_ID_DRAW_DATE_TIME;
421 : }
422 : }
423 : }
424 :
425 : // map postfix of service name to field ID
426 : DBG_ASSERT(!sFieldName.isEmpty(), "no TextField service found!");
427 368 : return MapFieldName(sFieldName, xPropSet);
428 : }
429 :
430 168 : enum FieldIdEnum XMLTextFieldExport::MapFieldName(
431 : const OUString& sFieldName, // field (master) name
432 : const Reference<XPropertySet> & xPropSet) // for subtype
433 : {
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
438 :
439 :
440 : // a) find prelim. FIELD_ID via aFieldServiceMapping
441 :
442 : // check for non-empty service name
443 : DBG_ASSERT(!sFieldName.isEmpty(), "no valid service name!");
444 168 : enum FieldIdEnum nToken = FIELD_ID_UNKNOWN;
445 168 : if (!sFieldName.isEmpty())
446 : {
447 : // map name to prelim. ID
448 : sal_uInt16 nTmp;
449 168 : sal_Bool bRet = GetExport().GetMM100UnitConverter().convertEnum(
450 168 : nTmp, sFieldName, aFieldServiceNameMapping);
451 :
452 : // check return
453 : DBG_ASSERT(bRet, "Unknown field service name encountered!");
454 168 : if (! bRet)
455 : {
456 0 : nToken = FIELD_ID_UNKNOWN;
457 : }
458 : else
459 : {
460 168 : nToken = (enum FieldIdEnum)nTmp;
461 : }
462 : } else {
463 : // invalid service name
464 0 : nToken = FIELD_ID_UNKNOWN;
465 : }
466 :
467 : // b) map prelim. to final FIELD_IDs
468 168 : switch (nToken) {
469 : case FIELD_ID_VARIABLE_SET:
470 4 : if (GetBoolProperty(sPropertyIsInput, xPropSet))
471 : {
472 0 : nToken = FIELD_ID_VARIABLE_INPUT;
473 : }
474 : else
475 : {
476 4 : switch (GetIntProperty(sPropertySubType, xPropSet))
477 : {
478 : case SetVariableType::STRING: // text field
479 : case SetVariableType::VAR: // num field
480 4 : nToken = FIELD_ID_VARIABLE_SET;
481 4 : break;
482 : case SetVariableType::SEQUENCE:
483 0 : nToken = FIELD_ID_SEQUENCE;
484 0 : break;
485 : case SetVariableType::FORMULA:
486 : default:
487 0 : nToken = FIELD_ID_UNKNOWN;
488 0 : break;
489 : }
490 : }
491 4 : break;
492 :
493 : case FIELD_ID_VARIABLE_GET:
494 0 : switch (GetIntProperty(sPropertySubType, xPropSet))
495 : {
496 : case SetVariableType::STRING: // text field
497 : case SetVariableType::VAR: // num field
498 0 : nToken = FIELD_ID_VARIABLE_GET;
499 0 : break;
500 : case SetVariableType::FORMULA:
501 0 : nToken = FIELD_ID_EXPRESSION;
502 0 : break;
503 : case SetVariableType::SEQUENCE:
504 : default:
505 0 : nToken = FIELD_ID_UNKNOWN;
506 0 : break;
507 : }
508 0 : break;
509 :
510 : case FIELD_ID_TIME:
511 32 : if (GetBoolProperty(sPropertyIsDate, xPropSet))
512 : {
513 16 : nToken = FIELD_ID_DATE;
514 : }
515 32 : break;
516 :
517 : case FIELD_ID_PAGENUMBER:
518 : // NumberingType not available in non-Writer apps
519 88 : if (xPropSet->getPropertySetInfo()->
520 44 : hasPropertyByName(sPropertyNumberingType))
521 : {
522 0 : if (NumberingType::CHAR_SPECIAL == GetIntProperty(
523 0 : sPropertyNumberingType, xPropSet))
524 : {
525 0 : nToken = FIELD_ID_PAGESTRING;
526 : }
527 : }
528 44 : break;
529 :
530 : case FIELD_ID_DOCINFO_CREATION_TIME:
531 0 : if (GetBoolProperty(sPropertyIsDate, xPropSet))
532 : {
533 0 : nToken = FIELD_ID_DOCINFO_CREATION_DATE;
534 : }
535 0 : break;
536 :
537 : case FIELD_ID_DOCINFO_PRINT_TIME:
538 0 : if (GetBoolProperty(sPropertyIsDate, xPropSet))
539 : {
540 0 : nToken = FIELD_ID_DOCINFO_PRINT_DATE;
541 : }
542 0 : break;
543 :
544 : case FIELD_ID_DOCINFO_SAVE_TIME:
545 0 : if (GetBoolProperty(sPropertyIsDate, xPropSet))
546 : {
547 0 : nToken = FIELD_ID_DOCINFO_SAVE_DATE;
548 : }
549 0 : break;
550 :
551 : case FIELD_ID_REF_REFERENCE:
552 0 : switch (GetInt16Property(sPropertyReferenceFieldSource, xPropSet))
553 : {
554 : case ReferenceFieldSource::REFERENCE_MARK:
555 0 : nToken = FIELD_ID_REF_REFERENCE;
556 0 : break;
557 : case ReferenceFieldSource::SEQUENCE_FIELD:
558 0 : nToken = FIELD_ID_REF_SEQUENCE;
559 0 : break;
560 : case ReferenceFieldSource::BOOKMARK:
561 0 : nToken = FIELD_ID_REF_BOOKMARK;
562 0 : break;
563 : case ReferenceFieldSource::FOOTNOTE:
564 0 : nToken = FIELD_ID_REF_FOOTNOTE;
565 0 : break;
566 : case ReferenceFieldSource::ENDNOTE:
567 0 : nToken = FIELD_ID_REF_ENDNOTE;
568 0 : break;
569 : default:
570 0 : nToken = FIELD_ID_UNKNOWN;
571 0 : break;
572 : }
573 0 : break;
574 :
575 : case FIELD_ID_COMBINED_CHARACTERS:
576 : case FIELD_ID_SCRIPT:
577 : case FIELD_ID_ANNOTATION:
578 : case FIELD_ID_BIBLIOGRAPHY:
579 : case FIELD_ID_DDE:
580 : case FIELD_ID_MACRO:
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:
617 : case FIELD_ID_META:
618 : case FIELD_ID_SHEET_NAME:
619 : case FIELD_ID_MEASURE:
620 : case FIELD_ID_URL:
621 : case FIELD_ID_TABLE_FORMULA:
622 : case FIELD_ID_DROP_DOWN:
623 : ; // these field IDs are final
624 88 : break;
625 :
626 : default:
627 0 : nToken = FIELD_ID_UNKNOWN;
628 : }
629 :
630 : // ... and return final FIELD_ID
631 168 : return nToken;
632 : }
633 :
634 : // is string or numeric field?
635 14 : sal_Bool XMLTextFieldExport::IsStringField(
636 : FieldIdEnum nFieldType,
637 : const Reference<XPropertySet> & xPropSet)
638 : {
639 14 : switch (nFieldType) {
640 :
641 : case FIELD_ID_VARIABLE_GET:
642 : case FIELD_ID_VARIABLE_SET:
643 : case FIELD_ID_VARIABLE_INPUT:
644 : {
645 : // depends on field sub type
646 4 : return ( GetIntProperty(sPropertySubType, xPropSet) ==
647 4 : SetVariableType::STRING );
648 : }
649 :
650 : case FIELD_ID_USER_GET:
651 : case FIELD_ID_USER_INPUT:
652 : {
653 0 : Reference<XTextField> xTextField(xPropSet, UNO_QUERY);
654 : DBG_ASSERT(xTextField.is(), "field is no XTextField!");
655 : sal_Bool bRet = GetBoolProperty(sPropertyIsExpression,
656 0 : GetMasterPropertySet(xTextField));
657 0 : return !bRet;
658 : }
659 :
660 : case FIELD_ID_META:
661 10 : return 0 > GetIntProperty(sPropertyNumberFormat, xPropSet);
662 :
663 : case FIELD_ID_DATABASE_DISPLAY:
664 : // TODO: depends on... ???
665 : // workaround #no-bug#: no data type
666 0 : return 5100 == GetIntProperty(sPropertyNumberFormat, xPropSet);
667 :
668 : case FIELD_ID_TABLE_FORMULA:
669 : // legacy field: always a number field (because it always has
670 : // a number format)
671 0 : return sal_False;
672 :
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:
691 : case FIELD_ID_DATE:
692 : case FIELD_ID_TIME:
693 : case FIELD_ID_PAGENUMBER:
694 : case FIELD_ID_REFPAGE_SET:
695 : case FIELD_ID_REFPAGE_GET:
696 : case FIELD_ID_DOCINFO_CUSTOM:
697 : // always number
698 0 : return sal_False;
699 :
700 : case FIELD_ID_COMBINED_CHARACTERS:
701 : case FIELD_ID_BIBLIOGRAPHY:
702 : case FIELD_ID_DDE:
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:
708 : case FIELD_ID_MACRO:
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:
729 : case FIELD_ID_URL:
730 : case FIELD_ID_DROP_DOWN:
731 : // always string:
732 0 : return sal_True;
733 :
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:
746 : default:
747 : OSL_FAIL("unknown field type/field has no content");
748 0 : return sal_True; // invalid info; string in case of doubt
749 : }
750 : }
751 :
752 : /// export the styles needed by the given field. Called on first pass
753 : /// through document
754 100 : void XMLTextFieldExport::ExportFieldAutoStyle(
755 : const Reference<XTextField> & rTextField, const sal_Bool bProgress,
756 : const sal_Bool bRecursive )
757 : {
758 : // get property set
759 100 : Reference<XPropertySet> xPropSet(rTextField, UNO_QUERY);
760 :
761 : // add field master to list of used field masters (if desired)
762 100 : if (NULL != pUsedMasters)
763 : {
764 86 : Reference<XDependentTextField> xDepField(rTextField, UNO_QUERY);
765 86 : if (xDepField.is())
766 : {
767 0 : Reference<XText> xOurText = rTextField->getAnchor()->getText();
768 :
769 : map<Reference<XText>, set<OUString> >::iterator aMapIter =
770 0 : pUsedMasters->find(xOurText);
771 :
772 : // insert a list for our XText (if necessary)
773 0 : if (aMapIter == pUsedMasters->end())
774 : {
775 0 : set<OUString> aSet;
776 0 : (*pUsedMasters)[xOurText] = aSet;
777 0 : aMapIter = pUsedMasters->find(xOurText);
778 : }
779 :
780 : // insert this text field master
781 : OUString sFieldMasterName = GetStringProperty(
782 0 : sPropertyInstanceName, xDepField->getTextFieldMaster());
783 0 : if (!sFieldMasterName.isEmpty())
784 0 : aMapIter->second.insert( sFieldMasterName );
785 86 : }
786 : // else: no dependent field -> no master -> ignore
787 : }
788 :
789 : // get Field ID
790 100 : FieldIdEnum nToken = GetFieldID(rTextField, xPropSet);
791 :
792 : // export the character style for all fields
793 : // with one exception: combined character fields export their own
794 : // text style below
795 200 : Reference <XPropertySet> xRangePropSet(rTextField->getAnchor(), UNO_QUERY);
796 100 : if (FIELD_ID_COMBINED_CHARACTERS != nToken)
797 : {
798 100 : GetExport().GetTextParagraphExport()->Add(
799 100 : XML_STYLE_FAMILY_TEXT_TEXT, xRangePropSet);
800 : }
801 :
802 : // process special styles for each field (e.g. data styles)
803 100 : switch (nToken) {
804 :
805 : case FIELD_ID_DATABASE_DISPLAY:
806 : {
807 0 : sal_Int32 nFormat = GetIntProperty(sPropertyNumberFormat, xPropSet);
808 : // workaround: #no-bug#; see IsStringField(...)
809 0 : if ( (5100 != nFormat) &&
810 0 : !GetBoolProperty(sPropertyIsDataBaseFormat, xPropSet) )
811 : {
812 0 : GetExport().addDataStyle(nFormat);
813 : }
814 0 : break;
815 : }
816 :
817 : case FIELD_ID_DATE:
818 : case FIELD_ID_TIME:
819 : {
820 : // date and time fields are always number fields, but the
821 : // NumberFormat property is optional (e.g. Calc doesn't
822 : // support it)
823 : Reference<XPropertySetInfo> xPropSetInfo(
824 16 : xPropSet->getPropertySetInfo() );
825 16 : if ( xPropSetInfo->hasPropertyByName( sPropertyNumberFormat ) )
826 : {
827 : sal_Int32 nFormat =
828 12 : GetIntProperty(sPropertyNumberFormat, xPropSet);
829 :
830 : // nFormat may be -1 for numeric fields that display their
831 : // variable name. (Maybe this should be a field type, then?)
832 12 : if (nFormat != -1)
833 : {
834 12 : if( ! GetOptionalBoolProperty(
835 : sPropertyIsFixedLanguage,
836 12 : xPropSet, xPropSetInfo, sal_False ) )
837 : {
838 : nFormat =
839 12 : GetExport().dataStyleForceSystemLanguage(nFormat);
840 : }
841 :
842 12 : GetExport().addDataStyle( nFormat,
843 12 : nToken == FIELD_ID_TIME );
844 : }
845 16 : }
846 : }
847 16 : break;
848 :
849 : case FIELD_ID_META:
850 : // recurse into content (does not export element, so can be done first)
851 10 : if (bRecursive)
852 : {
853 0 : ExportMetaField(xPropSet, true, bProgress);
854 : }
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 12 : if (! IsStringField(nToken, xPropSet)) {
872 :
873 : sal_Int32 nFormat =
874 4 : GetIntProperty(sPropertyNumberFormat, xPropSet);
875 :
876 : // nFormat may be -1 for numeric fields that display their
877 : // variable name. (Maybe this should be a field type, then?)
878 4 : if (nFormat != -1)
879 : {
880 : // handle formats for fixed language fields
881 : // for all these fields (except table formula)
882 16 : if( ( nToken != FIELD_ID_TABLE_FORMULA ) &&
883 : ! GetOptionalBoolProperty(
884 : sPropertyIsFixedLanguage,
885 4 : xPropSet, xPropSet->getPropertySetInfo(),
886 16 : sal_False ) )
887 : {
888 : nFormat =
889 1 : GetExport().dataStyleForceSystemLanguage(nFormat);
890 : }
891 :
892 4 : GetExport().addDataStyle(nFormat);
893 : }
894 : }
895 12 : break;
896 :
897 : case FIELD_ID_COMBINED_CHARACTERS:
898 : {
899 : // export text style with the addition of the combined characters
900 : DBG_ASSERT(NULL != pCombinedCharactersPropertyState,
901 : "need proper PropertyState for combined characters");
902 0 : const XMLPropertyState *aStates[] = { pCombinedCharactersPropertyState, 0 };
903 0 : GetExport().GetTextParagraphExport()->Add(
904 : XML_STYLE_FAMILY_TEXT_TEXT, xRangePropSet,
905 0 : aStates);
906 0 : break;
907 : }
908 :
909 : case FIELD_ID_SCRIPT:
910 : case FIELD_ID_ANNOTATION:
911 : case FIELD_ID_BIBLIOGRAPHY:
912 : case FIELD_ID_DDE:
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:
918 : case FIELD_ID_MACRO:
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:
956 : case FIELD_ID_URL:
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!
962 72 : break;
963 :
964 : case FIELD_ID_UNKNOWN:
965 : default:
966 : OSL_FAIL("unknown field type!");
967 : // ignore -> no format for ukowns
968 0 : break;
969 100 : }
970 100 : }
971 :
972 : /// export the given field to XML. Called on second pass through document
973 100 : void XMLTextFieldExport::ExportField(
974 : const Reference<XTextField> & rTextField, sal_Bool bProgress )
975 : {
976 : // get property set
977 100 : Reference<XPropertySet> xPropSet(rTextField, UNO_QUERY);
978 :
979 : // get property set of range (for the attributes)
980 200 : Reference <XPropertySet> xRangePropSet(rTextField->getAnchor(), UNO_QUERY);
981 :
982 : // get Field ID
983 100 : enum FieldIdEnum nToken = GetFieldID(rTextField, xPropSet);
984 :
985 : // special treatment for combined characters field, because it is
986 : // exported as a style
987 100 : const XMLPropertyState* aStates[] = { pCombinedCharactersPropertyState, 0 };
988 : const XMLPropertyState **pStates =
989 : FIELD_ID_COMBINED_CHARACTERS == nToken
990 : ? aStates
991 100 : : 0;
992 :
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 100 : OUString sStyle = GetExport().GetTextParagraphExport()->
998 : FindTextStyleAndHyperlink( xRangePropSet, bHasHyperlink, bIsUICharStyle,
999 200 : bHasAutoStyle, pStates );
1000 100 : sal_Bool bHasStyle = !sStyle.isEmpty();
1001 :
1002 : // export hyperlink (if we have one)
1003 200 : Reference < XPropertySetInfo > xRangePropSetInfo;
1004 100 : if( bHasHyperlink )
1005 : {
1006 0 : Reference<XPropertyState> xRangePropState( xRangePropSet, UNO_QUERY );
1007 0 : xRangePropSetInfo = xRangePropSet->getPropertySetInfo();
1008 : bHasHyperlink =
1009 0 : GetExport().GetTextParagraphExport()->addHyperlinkAttributes(
1010 : xRangePropSet, xRangePropState,
1011 0 : xRangePropSetInfo );
1012 : }
1013 100 : SvXMLElementExport aHyperlink( GetExport(), bHasHyperlink,
1014 : XML_NAMESPACE_TEXT, XML_A,
1015 300 : sal_False, sal_False );
1016 :
1017 100 : if( bHasHyperlink )
1018 : {
1019 : // export events (if supported)
1020 0 : OUString sHyperLinkEvents("HyperLinkEvents");
1021 0 : if (xRangePropSetInfo->hasPropertyByName(sHyperLinkEvents))
1022 : {
1023 0 : Any aAny = xRangePropSet->getPropertyValue(sHyperLinkEvents);
1024 0 : Reference<XNameReplace> xName;
1025 0 : aAny >>= xName;
1026 0 : GetExport().GetEventExport().Export(xName, sal_False);
1027 0 : }
1028 : }
1029 :
1030 : {
1031 : XMLTextCharStyleNamesElementExport aCharStylesExport(
1032 200 : GetExport(), bIsUICharStyle &&
1033 0 : GetExport().GetTextParagraphExport()
1034 100 : ->GetCharStyleNamesPropInfoCache().hasProperty(
1035 0 : xRangePropSet, xRangePropSetInfo ), bHasAutoStyle,
1036 400 : xRangePropSet, sPropertyCharStyleNames );
1037 :
1038 : // export span with style (if necessary)
1039 : // (except for combined characters field)
1040 100 : if( bHasStyle )
1041 : {
1042 : // export <text:span> element
1043 0 : GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
1044 0 : GetExport().EncodeStyleName( sStyle ) );
1045 : }
1046 100 : SvXMLElementExport aSpan( GetExport(), bHasStyle,
1047 : XML_NAMESPACE_TEXT, XML_SPAN,
1048 300 : sal_False, sal_False);
1049 :
1050 : // finally, export the field itself
1051 : ExportFieldHelper( rTextField, xPropSet, xRangePropSet, nToken,
1052 200 : bProgress );
1053 100 : }
1054 100 : }
1055 :
1056 : /// export the given field to XML. Called on second pass through document
1057 100 : 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 )
1063 : {
1064 : // get property set info (because some attributes are not support
1065 : // in all implementations)
1066 100 : Reference<XPropertySetInfo> xPropSetInfo(rPropSet->getPropertySetInfo());
1067 :
1068 200 : OUString sPresentation = rTextField->getPresentation(sal_False);
1069 :
1070 : // process each field type
1071 100 : switch (nToken) {
1072 : case FIELD_ID_AUTHOR:
1073 : // author field: fixed, field (sub-)type
1074 : ProcessBoolean(XML_FIXED,
1075 0 : GetBoolProperty(sPropertyIsFixed, rPropSet), sal_True);
1076 0 : ExportElement(MapAuthorFieldName(rPropSet), sPresentation);
1077 0 : break;
1078 :
1079 : case FIELD_ID_SENDER:
1080 : // sender field: fixed, field (sub-)type
1081 : ProcessBoolean(XML_FIXED,
1082 0 : GetBoolProperty(sPropertyIsFixed, rPropSet), sal_True);
1083 0 : ExportElement(MapSenderFieldName(rPropSet), sPresentation);
1084 0 : break;
1085 :
1086 : case FIELD_ID_PLACEHOLDER:
1087 : // placeholder field: type, name, description
1088 : ProcessString(XML_PLACEHOLDER_TYPE,
1089 : MapPlaceholderType(
1090 0 : GetInt16Property(sPropertyPlaceholderType, rPropSet)));
1091 : ProcessString(XML_DESCRIPTION,
1092 0 : GetStringProperty(sPropertyHint,rPropSet), sal_True);
1093 0 : ExportElement(XML_PLACEHOLDER, sPresentation);
1094 0 : break;
1095 :
1096 : case FIELD_ID_VARIABLE_SET:
1097 : {
1098 : // variable set field: name, visible, format&value
1099 : ProcessString(XML_NAME,
1100 2 : GetStringProperty(sPropertyVariableName, rPropSet));
1101 2 : ProcessDisplay(GetBoolProperty(sPropertyIsVisible, rPropSet),
1102 2 : sal_False);
1103 : ProcessString(XML_FORMULA, XML_NAMESPACE_OOOW,
1104 : GetStringProperty(sPropertyContent, rPropSet),
1105 2 : sPresentation);
1106 2 : ProcessValueAndType(IsStringField(nToken, rPropSet),
1107 : GetIntProperty(sPropertyNumberFormat, rPropSet),
1108 : GetStringProperty(sPropertyContent, rPropSet),
1109 : sPresentation,
1110 : GetDoubleProperty(sPropertyValue, rPropSet),
1111 : sal_True, sal_True, sal_True,
1112 : ! GetOptionalBoolProperty(
1113 : sPropertyIsFixedLanguage,
1114 4 : rPropSet, xPropSetInfo, sal_False ) );
1115 2 : ExportElement(XML_VARIABLE_SET, sPresentation);
1116 2 : break;
1117 : }
1118 : case FIELD_ID_VARIABLE_GET:
1119 : {
1120 : // variable get field: name, format&value
1121 : ProcessString(XML_NAME,
1122 0 : GetStringProperty(sPropertyContent, rPropSet));
1123 0 : sal_Bool bCmd = GetBoolProperty(sPropertyIsShowFormula, rPropSet);
1124 0 : ProcessDisplay(sal_True, bCmd);
1125 : // #i81766# for older versions export of the value-type
1126 0 : sal_Bool bExportValueType = !bCmd && ( GetExport().getExportFlags() & EXPORT_SAVEBACKWARDCOMPATIBLE );
1127 : // show style, unless name will be shown
1128 0 : ProcessValueAndType(IsStringField(nToken, rPropSet),
1129 : GetIntProperty(sPropertyNumberFormat, rPropSet),
1130 : sEmpty, sEmpty, 0.0, // values not used
1131 : sal_False,
1132 : bExportValueType,
1133 : !bCmd,
1134 : ! GetOptionalBoolProperty(
1135 : sPropertyIsFixedLanguage,
1136 0 : rPropSet, xPropSetInfo, sal_False ) );
1137 0 : ExportElement(XML_VARIABLE_GET, sPresentation);
1138 0 : break;
1139 : }
1140 : case FIELD_ID_VARIABLE_INPUT:
1141 : // variable input field: name, description, format&value
1142 : ProcessString(XML_NAME,
1143 0 : GetStringProperty(sPropertyVariableName, rPropSet));
1144 : ProcessString(XML_DESCRIPTION,
1145 0 : GetStringProperty(sPropertyHint , rPropSet));
1146 0 : ProcessDisplay(GetBoolProperty(sPropertyIsVisible, rPropSet),
1147 0 : sal_False);
1148 : ProcessString(XML_FORMULA, XML_NAMESPACE_OOOW,
1149 : GetStringProperty(sPropertyContent, rPropSet),
1150 0 : sPresentation);
1151 0 : ProcessValueAndType(IsStringField(nToken, rPropSet),
1152 : GetIntProperty(sPropertyNumberFormat, rPropSet),
1153 : GetStringProperty(sPropertyContent, rPropSet),
1154 : sPresentation,
1155 : GetDoubleProperty(sPropertyValue, rPropSet),
1156 : sal_True, sal_True, sal_True,
1157 : ! GetOptionalBoolProperty(
1158 : sPropertyIsFixedLanguage,
1159 0 : rPropSet, xPropSetInfo, sal_False ) );
1160 0 : ExportElement(XML_VARIABLE_INPUT, sPresentation);
1161 0 : break;
1162 :
1163 : case FIELD_ID_USER_GET:
1164 : // user field: name, hidden, style
1165 : {
1166 0 : sal_Bool bCmd = GetBoolProperty(sPropertyIsShowFormula, rPropSet);
1167 0 : ProcessDisplay(GetBoolProperty(sPropertyIsVisible, rPropSet),
1168 0 : bCmd);
1169 0 : 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 0 : rPropSet, xPropSetInfo, sal_False ) );
1176 :
1177 : // name from FieldMaster
1178 : ProcessString(XML_NAME,
1179 : GetStringProperty(sPropertyName,
1180 0 : GetMasterPropertySet(rTextField)));
1181 0 : ExportElement(XML_USER_FIELD_GET, sPresentation);
1182 0 : break;
1183 : }
1184 :
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 0 : GetStringProperty(sPropertyContent, rPropSet));
1192 : ProcessString(XML_DESCRIPTION,
1193 0 : GetStringProperty(sPropertyHint, rPropSet));
1194 0 : ExportElement(XML_USER_FIELD_INPUT, sPresentation);
1195 0 : break;
1196 :
1197 : case FIELD_ID_SEQUENCE:
1198 : {
1199 : // sequence field: name, formula, seq-format
1200 0 : OUString sName = GetStringProperty(sPropertyVariableName, rPropSet);
1201 : // TODO: use reference name only if actually beeing referenced.
1202 : ProcessString(XML_REF_NAME,
1203 : MakeSequenceRefName(
1204 0 : GetInt16Property(sPropertySequenceValue, rPropSet),
1205 0 : sName));
1206 0 : ProcessString(XML_NAME, sName);
1207 : ProcessString(XML_FORMULA, XML_NAMESPACE_OOOW,
1208 : GetStringProperty(sPropertyContent, rPropSet),
1209 0 : sPresentation);
1210 : ProcessNumberingType(GetInt16Property(sPropertyNumberingType,
1211 0 : rPropSet));
1212 0 : ExportElement(XML_SEQUENCE, sPresentation);
1213 0 : break;
1214 : }
1215 :
1216 : case FIELD_ID_EXPRESSION:
1217 : {
1218 : // formula field: formula, format&value
1219 0 : sal_Bool bCmd = GetBoolProperty(sPropertyIsShowFormula, rPropSet);
1220 : ProcessString(XML_FORMULA, XML_NAMESPACE_OOOW,
1221 : GetStringProperty(sPropertyContent, rPropSet),
1222 0 : sPresentation);
1223 0 : ProcessDisplay(sal_True, bCmd);
1224 0 : ProcessValueAndType(IsStringField(nToken, rPropSet),
1225 : GetIntProperty(sPropertyNumberFormat, rPropSet),
1226 : GetStringProperty(sPropertyContent, rPropSet),
1227 : sPresentation,
1228 : GetDoubleProperty(sPropertyValue, rPropSet),
1229 : !bCmd, !bCmd, !bCmd,
1230 : ! GetOptionalBoolProperty(
1231 : sPropertyIsFixedLanguage,
1232 0 : rPropSet, xPropSetInfo, sal_False ) );
1233 0 : ExportElement(XML_EXPRESSION, sPresentation);
1234 0 : break;
1235 : }
1236 :
1237 : case FIELD_ID_TEXT_INPUT:
1238 : // text input field: description and string-value
1239 : ProcessString(XML_DESCRIPTION,
1240 0 : GetStringProperty(sPropertyHint, rPropSet));
1241 : ProcessString(XML_HELP,
1242 0 : GetStringProperty(sPropertyHelp, rPropSet), true);
1243 : ProcessString(XML_HINT,
1244 0 : GetStringProperty(sPropertyTooltip, rPropSet), true);
1245 0 : ExportElement(XML_TEXT_INPUT, sPresentation);
1246 0 : break;
1247 :
1248 : case FIELD_ID_TIME:
1249 : // all properties (except IsDate) are optional!
1250 8 : if (xPropSetInfo->hasPropertyByName(sPropertyNumberFormat))
1251 : {
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 4 : rPropSet, xPropSetInfo, sal_False ),
1259 4 : sal_True);
1260 : }
1261 8 : if (xPropSetInfo->hasPropertyByName(sPropertyDateTimeValue))
1262 : {
1263 : // no value -> current time
1264 : ProcessDateTime(XML_TIME_VALUE,
1265 : GetDateTimeProperty(sPropertyDateTimeValue,
1266 0 : rPropSet),
1267 0 : sal_False );
1268 : }
1269 8 : if (xPropSetInfo->hasPropertyByName(sPropertyDateTime))
1270 : {
1271 : // no value -> current time
1272 : ProcessDateTime(XML_TIME_VALUE,
1273 4 : GetDateTimeProperty(sPropertyDateTime,rPropSet),
1274 4 : sal_False );
1275 : }
1276 8 : if (xPropSetInfo->hasPropertyByName(sPropertyIsFixed))
1277 : {
1278 : ProcessBoolean(XML_FIXED,
1279 4 : GetBoolProperty(sPropertyIsFixed, rPropSet),
1280 4 : sal_False);
1281 : }
1282 8 : if (xPropSetInfo->hasPropertyByName(sPropertyAdjust))
1283 : {
1284 : // adjust value given as integer in minutes
1285 : ProcessDateTime(XML_TIME_ADJUST,
1286 : GetIntProperty(sPropertyAdjust, rPropSet),
1287 0 : sal_False, sal_True, sal_True);
1288 : }
1289 8 : ExportElement(XML_TIME, sPresentation);
1290 8 : break;
1291 :
1292 : case FIELD_ID_DATE:
1293 : // all properties (except IsDate) are optional!
1294 8 : if (xPropSetInfo->hasPropertyByName(sPropertyNumberFormat))
1295 : {
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 8 : rPropSet, xPropSetInfo, sal_False ) );
1303 : }
1304 8 : if (xPropSetInfo->hasPropertyByName(sPropertyDateTimeValue))
1305 : {
1306 : // no value -> current date
1307 : ProcessDateTime(XML_DATE_VALUE,
1308 : GetDateTimeProperty(sPropertyDateTimeValue,
1309 0 : rPropSet),
1310 : // #96457#: date fields should also save time
1311 0 : sal_False);
1312 : }
1313 : // TODO: remove double-handling after SRC614
1314 8 : else if (xPropSetInfo->hasPropertyByName(sPropertyDateTime))
1315 : {
1316 : ProcessDateTime(XML_DATE_VALUE,
1317 8 : GetDateTimeProperty(sPropertyDateTime,rPropSet),
1318 : // #96457#: date fields should also save time
1319 8 : sal_False);
1320 : }
1321 8 : if (xPropSetInfo->hasPropertyByName(sPropertyIsFixed))
1322 : {
1323 : ProcessBoolean(XML_FIXED,
1324 8 : GetBoolProperty(sPropertyIsFixed, rPropSet),
1325 8 : sal_False);
1326 : }
1327 8 : if (xPropSetInfo->hasPropertyByName(sPropertyAdjust))
1328 : {
1329 : // adjust value given as number of days
1330 : ProcessDateTime(XML_DATE_ADJUST,
1331 : GetIntProperty(sPropertyAdjust, rPropSet),
1332 0 : sal_True, sal_True, sal_True);
1333 : }
1334 8 : ExportElement(XML_DATE, sPresentation);
1335 8 : break;
1336 :
1337 : case FIELD_ID_PAGENUMBER:
1338 : // all properties are optional
1339 22 : if (xPropSetInfo->hasPropertyByName(sPropertyNumberingType))
1340 : {
1341 : ProcessNumberingType(GetInt16Property(sPropertyNumberingType,
1342 0 : rPropSet));
1343 : }
1344 22 : if (xPropSetInfo->hasPropertyByName(sPropertyOffset))
1345 : {
1346 0 : sal_Int32 nAdjust = GetIntProperty(sPropertyOffset, rPropSet);
1347 :
1348 0 : if (xPropSetInfo->hasPropertyByName(sPropertySubType))
1349 : {
1350 : // property SubType used in MapPageNumebrName
1351 : ProcessString(XML_SELECT_PAGE,
1352 0 : MapPageNumberName(rPropSet, nAdjust));
1353 : }
1354 0 : ProcessIntegerDef(XML_PAGE_ADJUST, nAdjust, 0);
1355 : }
1356 22 : ExportElement(XML_PAGE_NUMBER, sPresentation);
1357 22 : break;
1358 :
1359 : case FIELD_ID_PAGESTRING:
1360 : {
1361 : ProcessString(XML_STRING_VALUE,
1362 : GetStringProperty(sPropertyUserText, rPropSet),
1363 0 : sPresentation);
1364 0 : sal_Int32 nDummy = 0; // MapPageNumberName need int
1365 0 : ProcessString(XML_SELECT_PAGE, MapPageNumberName(rPropSet, nDummy));
1366 0 : if( 0 == ( GetExport().getExportFlags() & EXPORT_SAVEBACKWARDCOMPATIBLE ) )
1367 0 : ExportElement(XML_PAGE_CONTINUATION, sPresentation);
1368 : else
1369 0 : ExportElement(XML_PAGE_CONTINUATION_STRING, sPresentation);
1370 0 : break;
1371 : }
1372 :
1373 : case FIELD_ID_DATABASE_NAME:
1374 : ProcessString(XML_TABLE_NAME,
1375 0 : GetStringProperty(sPropertyDataTableName, rPropSet));
1376 0 : ProcessCommandType(GetIntProperty(sPropertyDataCommandType, rPropSet));
1377 0 : ProcessDisplay(GetBoolProperty(sPropertyIsVisible, rPropSet),
1378 0 : sal_False);
1379 : ExportDataBaseElement(XML_DATABASE_NAME, sPresentation,
1380 0 : rPropSet, xPropSetInfo);
1381 0 : break;
1382 :
1383 : case FIELD_ID_DATABASE_NUMBER:
1384 : ProcessString(XML_TABLE_NAME,
1385 0 : GetStringProperty(sPropertyDataTableName, rPropSet));
1386 0 : ProcessCommandType(GetIntProperty(sPropertyDataCommandType, rPropSet));
1387 : ProcessNumberingType(
1388 0 : GetInt16Property(sPropertyNumberingType,rPropSet));
1389 : ProcessInteger(XML_VALUE,
1390 0 : GetIntProperty(sPropertySetNumber, rPropSet));
1391 0 : ProcessDisplay(GetBoolProperty(sPropertyIsVisible, rPropSet),
1392 0 : sal_False);
1393 : ExportDataBaseElement(XML_DATABASE_ROW_NUMBER, sPresentation,
1394 0 : rPropSet, xPropSetInfo);
1395 0 : break;
1396 :
1397 : case FIELD_ID_DATABASE_NEXT:
1398 : ProcessString(XML_TABLE_NAME,
1399 0 : GetStringProperty(sPropertyDataTableName, rPropSet));
1400 0 : ProcessCommandType(GetIntProperty(sPropertyDataCommandType, rPropSet));
1401 : ProcessString(XML_CONDITION, XML_NAMESPACE_OOOW,
1402 0 : GetStringProperty(sPropertyCondition, rPropSet));
1403 : DBG_ASSERT(sPresentation.equals(sEmpty),
1404 : "Unexpected presentation for database next field");
1405 : ExportDataBaseElement(XML_DATABASE_NEXT, OUString(),
1406 0 : rPropSet, xPropSetInfo);
1407 0 : break;
1408 :
1409 : case FIELD_ID_DATABASE_SELECT:
1410 : ProcessString(XML_TABLE_NAME,
1411 0 : GetStringProperty(sPropertyDataTableName, rPropSet));
1412 0 : ProcessCommandType(GetIntProperty(sPropertyDataCommandType, rPropSet));
1413 : ProcessString(XML_CONDITION, XML_NAMESPACE_OOOW,
1414 0 : GetStringProperty(sPropertyCondition, rPropSet));
1415 : ProcessInteger(XML_ROW_NUMBER,
1416 0 : GetIntProperty(sPropertySetNumber, rPropSet));
1417 : DBG_ASSERT(sPresentation.equals(sEmpty),
1418 : "Unexpected presentation for database select field");
1419 : ExportDataBaseElement(XML_DATABASE_ROW_SELECT, OUString(),
1420 0 : rPropSet, xPropSetInfo);
1421 0 : break;
1422 :
1423 : case FIELD_ID_DATABASE_DISPLAY:
1424 : {
1425 : // get database, table and column name from field master
1426 0 : const Reference<XPropertySet> & xMaster = GetMasterPropertySet(rTextField);
1427 : ProcessString(XML_TABLE_NAME,
1428 0 : GetStringProperty(sPropertyDataTableName, xMaster));
1429 0 : ProcessCommandType(GetIntProperty(sPropertyDataCommandType, xMaster));
1430 : ProcessString(XML_COLUMN_NAME,
1431 0 : GetStringProperty(sPropertyDataColumnName, xMaster));
1432 : // export number format if available (happens only for numbers!)
1433 0 : if (!GetBoolProperty(sPropertyIsDataBaseFormat, rPropSet))
1434 : {
1435 : ProcessValueAndType(sal_False, // doesn't happen for text
1436 : GetIntProperty(sPropertyNumberFormat,rPropSet),
1437 : sEmpty, sEmpty, 0.0, // not used
1438 0 : sal_False, sal_False, sal_True, sal_False);
1439 : }
1440 0 : ProcessDisplay(GetBoolProperty(sPropertyIsVisible, rPropSet),
1441 0 : sal_False);
1442 : ExportDataBaseElement(XML_DATABASE_DISPLAY, sPresentation,
1443 0 : xMaster, xMaster->getPropertySetInfo());
1444 0 : break;
1445 : }
1446 :
1447 : case FIELD_ID_DOCINFO_REVISION:
1448 : ProcessBoolean(XML_FIXED,
1449 0 : GetBoolProperty(sPropertyIsFixed, rPropSet), sal_False);
1450 0 : ExportElement(MapDocInfoFieldName(nToken), sPresentation);
1451 0 : break;
1452 :
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 0 : rPropSet, xPropSetInfo, sal_False ) );
1467 :
1468 : // todo: export date/time value, but values not available -> core bug
1469 : ProcessBoolean(XML_FIXED,
1470 0 : GetBoolProperty(sPropertyIsFixed, rPropSet), sal_False);
1471 0 : ExportElement(MapDocInfoFieldName(nToken), sPresentation);
1472 0 : break;
1473 :
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 8 : if (xPropSetInfo->hasPropertyByName(sPropertyIsFixed))
1482 : {
1483 : ProcessBoolean(XML_FIXED,
1484 0 : GetBoolProperty(sPropertyIsFixed, rPropSet), sal_False);
1485 : }
1486 8 : ExportElement(MapDocInfoFieldName(nToken), sPresentation);
1487 8 : break;
1488 :
1489 : case FIELD_ID_DOCINFO_CUSTOM:
1490 : {
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 0 : rPropSet, xPropSetInfo, sal_False ));
1498 0 : uno::Any aAny = rPropSet->getPropertyValue( sPropertyName );
1499 0 : OUString sName;
1500 0 : aAny >>= sName;
1501 0 : ProcessString(XML_NAME, sName);
1502 0 : ProcessBoolean(XML_FIXED, GetBoolProperty(sPropertyIsFixed, rPropSet), sal_False);
1503 0 : ExportElement(XML_USER_DEFINED, sPresentation);
1504 0 : break;
1505 : }
1506 :
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 8 : if (xPropSetInfo->hasPropertyByName(sPropertyNumberingType))
1517 : {
1518 : ProcessNumberingType(GetInt16Property(sPropertyNumberingType,
1519 0 : rPropSet));
1520 : }
1521 8 : ExportElement(MapCountFieldName(nToken), sPresentation);
1522 8 : break;
1523 :
1524 : case FIELD_ID_CONDITIONAL_TEXT:
1525 : ProcessString(XML_CONDITION, XML_NAMESPACE_OOOW,
1526 0 : GetStringProperty(sPropertyCondition, rPropSet));
1527 : ProcessString(XML_STRING_VALUE_IF_TRUE,
1528 0 : GetStringProperty(sPropertyTrueContent, rPropSet));
1529 : ProcessString(XML_STRING_VALUE_IF_FALSE,
1530 0 : GetStringProperty(sPropertyFalseContent, rPropSet));
1531 : ProcessBoolean(XML_CURRENT_VALUE,
1532 0 : GetBoolProperty(sPropertyIsConditionTrue, rPropSet),
1533 0 : sal_False);
1534 0 : ExportElement(XML_CONDITIONAL_TEXT, sPresentation);
1535 0 : break;
1536 :
1537 : case FIELD_ID_HIDDEN_TEXT:
1538 : ProcessString(XML_CONDITION, XML_NAMESPACE_OOOW,
1539 0 : GetStringProperty(sPropertyCondition, rPropSet));
1540 : ProcessString(XML_STRING_VALUE,
1541 0 : GetStringProperty(sPropertyContent, rPropSet));
1542 : ProcessBoolean(XML_IS_HIDDEN,
1543 0 : GetBoolProperty(sPropertyIsHidden, rPropSet),
1544 0 : sal_False);
1545 0 : ExportElement(XML_HIDDEN_TEXT, sPresentation);
1546 0 : break;
1547 :
1548 : case FIELD_ID_HIDDEN_PARAGRAPH:
1549 : ProcessString(XML_CONDITION, XML_NAMESPACE_OOOW,
1550 0 : GetStringProperty(sPropertyCondition, rPropSet));
1551 : ProcessBoolean(XML_IS_HIDDEN,
1552 0 : GetBoolProperty(sPropertyIsHidden, rPropSet),
1553 0 : sal_False);
1554 : DBG_ASSERT(sPresentation.equals(sEmpty),
1555 : "Unexpected presentation for hidden paragraph field");
1556 0 : ExportElement(XML_HIDDEN_PARAGRAPH);
1557 0 : break;
1558 :
1559 : case FIELD_ID_TEMPLATE_NAME:
1560 : ProcessString(XML_DISPLAY,
1561 : MapTemplateDisplayFormat(
1562 0 : GetInt16Property(sPropertyFileFormat, rPropSet)));
1563 0 : ExportElement(XML_TEMPLATE_NAME, sPresentation);
1564 0 : break;
1565 :
1566 : case FIELD_ID_CHAPTER:
1567 : ProcessString(XML_DISPLAY,
1568 : MapChapterDisplayFormat(
1569 0 : GetInt16Property(sPropertyChapterFormat, rPropSet)));
1570 : // API numbers 0..9, we number 1..10
1571 : ProcessInteger(XML_OUTLINE_LEVEL,
1572 0 : GetInt8Property(sPropertyLevel, rPropSet) + 1);
1573 0 : ExportElement(XML_CHAPTER, sPresentation);
1574 0 : break;
1575 :
1576 : case FIELD_ID_FILE_NAME:
1577 : // all properties are optional
1578 0 : if (xPropSetInfo->hasPropertyByName(sPropertyFileFormat))
1579 : {
1580 : ProcessString(XML_DISPLAY,
1581 : MapFilenameDisplayFormat(
1582 0 : GetInt16Property(sPropertyFileFormat, rPropSet)));
1583 : }
1584 0 : if (xPropSetInfo->hasPropertyByName(sPropertyIsFixed))
1585 : {
1586 : ProcessBoolean(XML_FIXED,
1587 0 : GetBoolProperty(sPropertyIsFixed, rPropSet),
1588 0 : sal_False);
1589 : }
1590 0 : ExportElement(XML_FILE_NAME, sPresentation);
1591 0 : break;
1592 :
1593 : case FIELD_ID_REFPAGE_SET:
1594 : ProcessBoolean(XML_ACTIVE,
1595 0 : GetBoolProperty(sPropertyOn, rPropSet), sal_True);
1596 : ProcessIntegerDef(XML_PAGE_ADJUST,
1597 0 : GetInt16Property(sPropertyOffset, rPropSet), 0);
1598 : DBG_ASSERT(sPresentation.equals(sEmpty),
1599 : "Unexpected presentation page variable field");
1600 0 : ExportElement(XML_PAGE_VARIABLE_SET);
1601 0 : break;
1602 :
1603 : case FIELD_ID_REFPAGE_GET:
1604 : ProcessNumberingType(
1605 0 : GetInt16Property(sPropertyNumberingType, rPropSet));
1606 0 : ExportElement(XML_PAGE_VARIABLE_GET, sPresentation);
1607 0 : break;
1608 :
1609 : case FIELD_ID_MACRO:
1610 0 : ExportMacro( rPropSet, sPresentation );
1611 0 : break;
1612 :
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 0 : sPropertyReferenceFieldPart, rPropSet)),
1619 0 : XML_TEMPLATE);
1620 : ProcessString(XML_REF_NAME,
1621 : MakeSequenceRefName(
1622 0 : GetInt16Property(sPropertySequenceNumber, rPropSet),
1623 0 : GetStringProperty(sPropertySourceName, rPropSet) ) );
1624 : ExportElement(
1625 : MapReferenceSource(
1626 0 : GetInt16Property(sPropertyReferenceFieldSource, rPropSet)),
1627 0 : sPresentation);
1628 0 : break;
1629 :
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 0 : sPropertyReferenceFieldPart, rPropSet)),
1636 0 : XML_TEMPLATE);
1637 : ProcessString(XML_REF_NAME,
1638 0 : GetStringProperty(sPropertySourceName, rPropSet));
1639 : ExportElement(
1640 : MapReferenceSource(GetInt16Property(
1641 0 : sPropertyReferenceFieldSource, rPropSet)),
1642 0 : sPresentation);
1643 0 : break;
1644 :
1645 : case FIELD_ID_REF_FOOTNOTE:
1646 : case FIELD_ID_REF_ENDNOTE:
1647 : // reference to end-/footnote: format, generate name, (and element)
1648 0 : GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_NOTE_CLASS,
1649 0 : FIELD_ID_REF_ENDNOTE==nToken ? XML_ENDNOTE : XML_FOOTNOTE );
1650 : ProcessString(XML_REFERENCE_FORMAT,
1651 : MapReferenceType(GetInt16Property(
1652 0 : sPropertyReferenceFieldPart, rPropSet)),
1653 0 : XML_TEMPLATE);
1654 : ProcessString(XML_REF_NAME,
1655 : MakeFootnoteRefName(GetInt16Property(
1656 0 : sPropertySequenceNumber, rPropSet)));
1657 : ExportElement(
1658 : MapReferenceSource(GetInt16Property(
1659 0 : sPropertyReferenceFieldSource, rPropSet)),
1660 0 : sPresentation);
1661 0 : break;
1662 :
1663 : case FIELD_ID_DDE:
1664 : // name from field master
1665 : ProcessString(XML_CONNECTION_NAME,
1666 :
1667 : GetStringProperty(sPropertyName,
1668 0 : GetMasterPropertySet(rTextField)));
1669 0 : ExportElement(XML_DDE_CONNECTION, sPresentation);
1670 0 : break;
1671 :
1672 : case FIELD_ID_SHEET_NAME:
1673 : // name of spreadsheet (Calc only)
1674 16 : ExportElement(XML_SHEET_NAME, sPresentation);
1675 16 : break;
1676 :
1677 : case FIELD_ID_URL:
1678 : {
1679 : // this field is a special case because it gets mapped onto a
1680 : // hyperlink, rather than one of the regular text field.
1681 0 : ProcessString(XML_HREF, GetExport().GetRelativeReference(GetStringProperty(sPropertyURL, rPropSet)),
1682 0 : sal_False, XML_NAMESPACE_XLINK);
1683 : ProcessString(XML_TARGET_FRAME_NAME,
1684 : GetStringProperty(sPropertyTargetFrame,rPropSet),
1685 0 : sal_True, XML_NAMESPACE_OFFICE);
1686 0 : GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1687 : SvXMLElementExport aUrlField(rExport, XML_NAMESPACE_TEXT, XML_A,
1688 0 : sal_False, sal_False);
1689 0 : GetExport().Characters(sPresentation);
1690 0 : break;
1691 : }
1692 :
1693 : case FIELD_ID_BIBLIOGRAPHY:
1694 : {
1695 0 : ProcessBibliographyData(rPropSet);
1696 0 : ExportElement(XML_BIBLIOGRAPHY_MARK, sPresentation);
1697 0 : break;
1698 : }
1699 :
1700 : case FIELD_ID_SCRIPT:
1701 : ProcessString(XML_LANGUAGE,
1702 : GetStringProperty(sPropertyScriptType, rPropSet),
1703 0 : sal_True, XML_NAMESPACE_SCRIPT);
1704 : DBG_ASSERT(sPresentation.equals(sEmpty),
1705 : "Unexpected presentation for script field");
1706 0 : if (GetBoolProperty(sPropertyURLContent, rPropSet))
1707 : {
1708 : ProcessString(XML_HREF,
1709 0 : GetExport().GetRelativeReference(GetStringProperty(sPropertyContent, rPropSet)),
1710 0 : sal_False, XML_NAMESPACE_XLINK);
1711 0 : ExportElement(XML_SCRIPT);
1712 : }
1713 : else
1714 : {
1715 : ExportElement(XML_SCRIPT,
1716 0 : GetStringProperty(sPropertyContent, rPropSet));
1717 : }
1718 0 : break;
1719 :
1720 : case FIELD_ID_ANNOTATION:
1721 : {
1722 : // check for empty presentation (just in case)
1723 : DBG_ASSERT(sPresentation.equals(sEmpty),
1724 : "Unexpected presentation for annotation field");
1725 :
1726 : // annotation element + content
1727 2 : OUString aName;
1728 2 : rPropSet->getPropertyValue(sPropertyName) >>= aName;
1729 2 : if (!aName.isEmpty())
1730 2 : GetExport().AddAttribute(XML_NAMESPACE_OFFICE, XML_NAME, aName);
1731 2 : SvXMLElementExport aElem(GetExport(), XML_NAMESPACE_OFFICE,
1732 4 : XML_ANNOTATION, sal_False, sal_True);
1733 :
1734 : // author
1735 4 : OUString aAuthor( GetStringProperty(sPropertyAuthor, rPropSet) );
1736 2 : if( !aAuthor.isEmpty() )
1737 : {
1738 2 : SvXMLElementExport aCreatorElem( GetExport(), XML_NAMESPACE_DC,
1739 : XML_CREATOR, sal_True,
1740 2 : sal_False );
1741 2 : GetExport().Characters(aAuthor);
1742 : }
1743 :
1744 : // date time
1745 2 : util::DateTime aDate( GetDateTimeProperty(sPropertyDateTimeValue, rPropSet) );
1746 : {
1747 2 : OUStringBuffer aBuffer;
1748 2 : ::sax::Converter::convertDateTime(aBuffer, aDate, true);
1749 2 : SvXMLElementExport aDateElem( GetExport(), XML_NAMESPACE_DC,
1750 : XML_DATE, sal_True,
1751 4 : sal_False );
1752 4 : GetExport().Characters(aBuffer.makeStringAndClear());
1753 : }
1754 :
1755 : // initials
1756 4 : OUString aInitials( GetStringProperty(sPropertyInitials, rPropSet) );
1757 2 : if( !aInitials.isEmpty() )
1758 : {
1759 2 : SvXMLElementExport aCreatorElem( GetExport(), XML_NAMESPACE_TEXT,
1760 : XML_SENDER_INITIALS, sal_True,
1761 2 : sal_False );
1762 2 : GetExport().Characters(aInitials);
1763 : }
1764 :
1765 4 : com::sun::star::uno::Reference < com::sun::star::text::XText > xText;
1766 : try
1767 : {
1768 2 : com::sun::star::uno::Any aRet = rPropSet->getPropertyValue(sPropertyTextRange);
1769 2 : aRet >>= xText;
1770 : }
1771 0 : catch ( com::sun::star::uno::Exception& )
1772 : {}
1773 :
1774 2 : if ( xText.is() )
1775 2 : GetExport().GetTextParagraphExport()->exportText( xText );
1776 : else
1777 0 : ProcessParagraphSequence(GetStringProperty(sPropertyContent,rPropSet));
1778 4 : break;
1779 : }
1780 :
1781 : case FIELD_ID_COMBINED_CHARACTERS:
1782 : {
1783 : // The style with the combined characters attribute has
1784 : // already been handled in the ExportField method. So all that
1785 : // is left to do now is to export the characters.
1786 0 : GetExport().Characters(sPresentation);
1787 0 : break;
1788 : }
1789 :
1790 : case FIELD_ID_META:
1791 : {
1792 10 : ExportMetaField(rPropSet, false, bProgress);
1793 10 : break;
1794 : }
1795 :
1796 : case FIELD_ID_MEASURE:
1797 : {
1798 0 : ProcessString(XML_KIND, MapMeasureKind(GetInt16Property(sPropertyMeasureKind, rPropSet)));
1799 0 : ExportElement( XML_MEASURE, sPresentation );
1800 0 : break;
1801 : }
1802 :
1803 : case FIELD_ID_TABLE_FORMULA:
1804 : ProcessString( XML_FORMULA, XML_NAMESPACE_OOOW,
1805 0 : GetStringProperty(sPropertyContent, rPropSet) );
1806 : ProcessDisplay( sal_True,
1807 0 : GetBoolProperty(sPropertyIsShowFormula, rPropSet),
1808 0 : sal_True );
1809 : ProcessValueAndType( sal_False,
1810 : GetIntProperty(sPropertyNumberFormat, rPropSet),
1811 : sEmpty, sEmpty, 0.0f,
1812 : sal_False, sal_False, sal_True,
1813 0 : sal_False, sal_False );
1814 0 : ExportElement( XML_TABLE_FORMULA, sPresentation );
1815 0 : break;
1816 :
1817 : case FIELD_ID_DROP_DOWN:
1818 : {
1819 0 : ProcessString(XML_NAME, GetStringProperty(sPropertyName, rPropSet));
1820 : ProcessString(XML_HELP,
1821 0 : GetStringProperty(sPropertyHelp, rPropSet), true);
1822 : ProcessString(XML_HINT,
1823 0 : GetStringProperty(sPropertyTooltip, rPropSet), true);
1824 0 : SvXMLElementExport aElem( GetExport(),
1825 : XML_NAMESPACE_TEXT, XML_DROPDOWN,
1826 0 : sal_False, sal_False );
1827 : ProcessStringSequence
1828 : (GetStringSequenceProperty( sPropertyItems, rPropSet ),
1829 0 : GetStringProperty( sPropertySelectedItem, rPropSet ) );
1830 :
1831 0 : GetExport().Characters( sPresentation );
1832 : }
1833 0 : break;
1834 :
1835 : case FIELD_ID_DRAW_HEADER:
1836 : {
1837 4 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_PRESENTATION, XML_HEADER, sal_False, sal_False );
1838 : }
1839 4 : break;
1840 :
1841 : case FIELD_ID_DRAW_FOOTER:
1842 : {
1843 6 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_PRESENTATION, XML_FOOTER, sal_False, sal_False );
1844 : }
1845 6 : break;
1846 :
1847 : case FIELD_ID_DRAW_DATE_TIME:
1848 : {
1849 6 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_PRESENTATION, XML_DATE_TIME, sal_False, sal_False );
1850 : }
1851 6 : break;
1852 :
1853 : case FIELD_ID_UNKNOWN:
1854 : default:
1855 : OSL_FAIL("unknown field type encountered!");
1856 : // always export content
1857 0 : GetExport().Characters(sPresentation);
1858 100 : }
1859 100 : }
1860 :
1861 :
1862 : /// export field declarations / field masters
1863 16 : void XMLTextFieldExport::ExportFieldDeclarations()
1864 : {
1865 16 : Reference<XText> xEmptyText;
1866 16 : ExportFieldDeclarations(xEmptyText);
1867 16 : }
1868 :
1869 : /// export field declarations / field masters
1870 68 : void XMLTextFieldExport::ExportFieldDeclarations(
1871 : const Reference<XText> & rText )
1872 : {
1873 : // store lists for decl elements
1874 68 : vector<OUString> aVarName;
1875 96 : vector<OUString> aUserName;
1876 96 : vector<OUString> aSeqName;
1877 96 : vector<OUString> aDdeName;
1878 :
1879 : // get text fields supplier and field master name access
1880 68 : Reference<XTextFieldsSupplier> xTextFieldsSupp(GetExport().GetModel(),
1881 96 : UNO_QUERY);
1882 68 : if( !xTextFieldsSupp.is() )
1883 108 : return;
1884 :
1885 : Reference<container::XNameAccess> xFieldMasterNameAccess(
1886 56 : xTextFieldsSupp->getTextFieldMasters(), UNO_QUERY);
1887 :
1888 : // where to get the text field masters from?
1889 : // a) we get a specific XText: then use pUsedMasters
1890 : // b) the XText is empty: then export all text fields
1891 56 : Sequence<OUString> aFieldMasters;
1892 28 : if (rText.is())
1893 : {
1894 : // export only used masters
1895 : DBG_ASSERT(NULL != pUsedMasters,
1896 : "field masters must be recorded in order to be "
1897 : "written out separatly" );
1898 12 : if (NULL != pUsedMasters)
1899 : {
1900 : map<Reference<XText>, set<OUString> > ::iterator aMapIter =
1901 12 : pUsedMasters->find(rText);
1902 12 : if (aMapIter != pUsedMasters->end())
1903 : {
1904 : // found the set of used field masters
1905 0 : set<OUString> & rOurMasters = aMapIter->second;
1906 :
1907 : // copy set to sequence
1908 0 : aFieldMasters.realloc( rOurMasters.size() );
1909 0 : sal_Int32 i = 0;
1910 0 : for( set<OUString>::iterator aSetIter = rOurMasters.begin();
1911 0 : aSetIter != rOurMasters.end();
1912 : ++aSetIter, ++i )
1913 : {
1914 0 : aFieldMasters[i] = *aSetIter;
1915 : }
1916 :
1917 0 : pUsedMasters->erase(rText);
1918 : }
1919 : // else: XText not found -> ignore
1920 : }
1921 : // else: no field masters have been recorded -> ignore
1922 : }
1923 : else
1924 : {
1925 : // no XText: export all!
1926 16 : aFieldMasters = xFieldMasterNameAccess->getElementNames();
1927 : }
1928 :
1929 95 : for(sal_Int32 i=0; i<aFieldMasters.getLength(); i++) {
1930 :
1931 : // get field master name
1932 67 : OUString sFieldMaster = aFieldMasters[i];
1933 :
1934 : // workaround for #no-bug#
1935 : static const sal_Char sDB[] =
1936 : "com.sun.star.text.FieldMaster.DataBase.";
1937 67 : if ( sFieldMaster.matchIgnoreAsciiCaseAsciiL( sDB, sizeof(sDB)-1) )
1938 : {
1939 0 : continue;
1940 : }
1941 :
1942 :
1943 134 : OUString sFieldMasterType;
1944 134 : OUString sVarName;
1945 67 : ExplodeFieldMasterName(sFieldMaster, sFieldMasterType, sVarName);
1946 :
1947 : // get XPropertySet of this field master
1948 134 : Reference<XPropertySet> xPropSet;
1949 134 : Any aAny = xFieldMasterNameAccess->getByName(sFieldMaster);
1950 67 : aAny >>= xPropSet;
1951 :
1952 : // save interesting field masters
1953 67 : if (0 == sFieldMasterType.compareToAscii(FIELD_SERVICE_SETEXP))
1954 : {
1955 66 : sal_Int32 nType = GetIntProperty(sPropertySubType, xPropSet);
1956 :
1957 : // sequence or variable?
1958 66 : if ( SetVariableType::SEQUENCE == nType )
1959 : {
1960 64 : aSeqName.push_back( sFieldMaster );
1961 : }
1962 : else
1963 : {
1964 2 : aVarName.push_back( sFieldMaster );
1965 : }
1966 : }
1967 1 : else if (0 == sFieldMasterType.compareToAscii(FIELD_SERVICE_USER))
1968 : {
1969 0 : aUserName.push_back( sFieldMaster );
1970 : }
1971 1 : else if (0 == sFieldMasterType.compareToAscii(FIELD_SERVICE_DDE))
1972 : {
1973 0 : aDdeName.push_back( sFieldMaster );
1974 : }
1975 : else
1976 : {
1977 : ; // ignore
1978 : }
1979 67 : }
1980 :
1981 : // now process fields:
1982 :
1983 : // variable field masters:
1984 28 : if ( !aVarName.empty() )
1985 : {
1986 2 : SvXMLElementExport aElem( GetExport(),
1987 : XML_NAMESPACE_TEXT,
1988 : XML_VARIABLE_DECLS,
1989 2 : sal_True, sal_True );
1990 :
1991 12 : for (vector<OUString>::iterator aVarIter = aVarName.begin();
1992 8 : aVarIter != aVarName.end();
1993 : ++aVarIter) {
1994 :
1995 2 : OUString sName = *aVarIter;
1996 :
1997 : // get field master property set
1998 4 : Reference<XPropertySet> xPropSet;
1999 4 : Any aAny = xFieldMasterNameAccess->getByName(sName);
2000 2 : aAny >>= xPropSet;
2001 :
2002 : // field name and type
2003 4 : OUString sFieldMasterType;
2004 4 : OUString sVarName;
2005 2 : ExplodeFieldMasterName(sName, sFieldMasterType, sVarName);
2006 :
2007 : // determine string/numeric field
2008 2 : sal_Bool bIsString = ( GetIntProperty(sPropertySubType, xPropSet)
2009 2 : == SetVariableType::STRING );
2010 :
2011 : // get dependent field property set
2012 4 : Reference<XPropertySet> xFieldPropSet;
2013 2 : if (GetDependentFieldPropertySet(xPropSet, xFieldPropSet))
2014 : {
2015 : // process value and type.
2016 : ProcessValueAndType(
2017 : bIsString,
2018 : GetIntProperty(sPropertyNumberFormat, xFieldPropSet),
2019 : sEmpty, sEmpty, 0.0,
2020 2 : sal_False, sal_True, sal_False, sal_False);
2021 : }
2022 : else
2023 : {
2024 : // If no dependent field is found, only string and
2025 : // float types can be supported
2026 :
2027 : // number format: 0 is default number format for 1st
2028 : // language. should be: getDefaultNumberFormat(Locale)
2029 : // from NumberFormats
2030 : ProcessValueAndType(
2031 : bIsString,
2032 : 0, sEmpty, sEmpty, 0.0,
2033 0 : sal_False, sal_True, sal_False, sal_False);
2034 : }
2035 :
2036 2 : ProcessString(XML_NAME, sVarName);
2037 2 : ExportElement(XML_VARIABLE_DECL, sal_True);
2038 4 : }
2039 : }
2040 : // else: no declarations element
2041 :
2042 : // sequence field masters:
2043 28 : if ( !aSeqName.empty() )
2044 : {
2045 16 : SvXMLElementExport aElem( GetExport(),
2046 : XML_NAMESPACE_TEXT,
2047 : XML_SEQUENCE_DECLS,
2048 16 : sal_True, sal_True );
2049 :
2050 240 : for (vector<OUString>::iterator aSeqIter = aSeqName.begin();
2051 160 : aSeqIter != aSeqName.end();
2052 : ++aSeqIter) {
2053 :
2054 64 : OUString sName = *aSeqIter;
2055 :
2056 : // get field master property set
2057 128 : Reference<XPropertySet> xPropSet;
2058 128 : Any aAny = xFieldMasterNameAccess->getByName(sName);
2059 64 : aAny >>= xPropSet;
2060 :
2061 : // field name and type
2062 128 : OUString sFieldMasterType;
2063 128 : OUString sVarName;
2064 64 : ExplodeFieldMasterName(sName, sFieldMasterType, sVarName);
2065 :
2066 : // outline level
2067 : sal_Int32 nLevel = 1 + GetIntProperty(
2068 64 : sPropertyChapterNumberingLevel, xPropSet);
2069 : DBG_ASSERT(nLevel >= 0, "illegal outline level");
2070 : DBG_ASSERT(nLevel < 127, "possible illegal outline level");
2071 64 : ProcessInteger(XML_DISPLAY_OUTLINE_LEVEL, nLevel);
2072 :
2073 : // separation character
2074 64 : if (nLevel > 0) {
2075 : ProcessString(XML_SEPARATION_CHARACTER, GetStringProperty(
2076 0 : sPropertyNumberingSeparator, xPropSet));
2077 : }
2078 64 : ProcessString(XML_NAME, sVarName);
2079 64 : ExportElement(XML_SEQUENCE_DECL, sal_True);
2080 80 : }
2081 : }
2082 : // else: no declarations element
2083 :
2084 : // user field field masters:
2085 28 : if ( !aUserName.empty() )
2086 : {
2087 0 : SvXMLElementExport aElem( GetExport(),
2088 : XML_NAMESPACE_TEXT,
2089 : XML_USER_FIELD_DECLS,
2090 0 : sal_True, sal_True );
2091 :
2092 0 : for (vector<OUString>::iterator aUserIter = aUserName.begin();
2093 0 : aUserIter != aUserName.end();
2094 : ++aUserIter) {
2095 :
2096 0 : OUString sName = *aUserIter;
2097 :
2098 : // get field master property set
2099 0 : Reference<XPropertySet> xPropSet;
2100 0 : Any aAny = xFieldMasterNameAccess->getByName(sName);
2101 0 : aAny >>= xPropSet;
2102 :
2103 : // field name and type
2104 0 : OUString sFieldMasterType;
2105 0 : OUString sVarName;
2106 0 : ExplodeFieldMasterName(sName, sFieldMasterType, sVarName);
2107 :
2108 0 : if (GetBoolProperty(sPropertyIsExpression, xPropSet))
2109 : {
2110 : // expression:
2111 : ProcessValueAndType(
2112 : sal_False,
2113 : 0, sEmpty, sEmpty,
2114 : GetDoubleProperty(sPropertyValue, xPropSet),
2115 : sal_True,
2116 : sal_True,
2117 : sal_False,
2118 0 : sal_False);
2119 : }
2120 : else
2121 : {
2122 : // string: write regardless of default
2123 : ProcessString(XML_VALUE_TYPE, XML_STRING, sal_False,
2124 0 : XML_NAMESPACE_OFFICE);
2125 : ProcessString(XML_STRING_VALUE,
2126 : GetStringProperty(sPropertyContent, xPropSet),
2127 0 : sal_False, XML_NAMESPACE_OFFICE );
2128 : }
2129 0 : ProcessString(XML_NAME, sVarName);
2130 0 : ExportElement(XML_USER_FIELD_DECL, sal_True);
2131 0 : }
2132 : }
2133 : // else: no declarations element
2134 :
2135 : // DDE field field masters:
2136 28 : if ( !aDdeName.empty() )
2137 : {
2138 0 : SvXMLElementExport aElem( GetExport(),
2139 : XML_NAMESPACE_TEXT,
2140 : XML_DDE_CONNECTION_DECLS,
2141 0 : sal_True, sal_True );
2142 :
2143 0 : for (vector<OUString>::iterator aDdeIter = aDdeName.begin();
2144 0 : aDdeIter != aDdeName.end();
2145 : ++aDdeIter)
2146 : {
2147 0 : OUString sName = *aDdeIter;
2148 :
2149 : // get field master property set
2150 0 : Reference<XPropertySet> xPropSet;
2151 0 : Any aAny = xFieldMasterNameAccess->getByName(sName);
2152 0 : aAny >>= xPropSet;
2153 :
2154 : // check if this connection is being used by a field
2155 0 : Reference<XPropertySet> xDummy;
2156 0 : if (GetDependentFieldPropertySet(xPropSet, xDummy))
2157 : {
2158 :
2159 : ProcessString(XML_NAME,
2160 : GetStringProperty(sPropertyName, xPropSet),
2161 0 : sal_False, XML_NAMESPACE_OFFICE);
2162 :
2163 : // export elements; can't use ProcessString because
2164 : // elements are in office namespace
2165 : ProcessString(XML_DDE_APPLICATION,
2166 : GetStringProperty(sPropertyDDECommandType,
2167 : xPropSet),
2168 0 : sal_False, XML_NAMESPACE_OFFICE);
2169 : ProcessString(XML_DDE_TOPIC,
2170 : GetStringProperty(sPropertyDDECommandFile,
2171 : xPropSet),
2172 0 : sal_False, XML_NAMESPACE_OFFICE);
2173 : ProcessString(XML_DDE_ITEM,
2174 : GetStringProperty(sPropertyDDECommandElement,
2175 : xPropSet),
2176 0 : sal_False, XML_NAMESPACE_OFFICE);
2177 : sal_Bool bIsAutomaticUpdate = GetBoolProperty(
2178 0 : sPropertyIsAutomaticUpdate, xPropSet);
2179 0 : if (bIsAutomaticUpdate)
2180 : {
2181 0 : GetExport().AddAttribute(XML_NAMESPACE_OFFICE,
2182 : XML_AUTOMATIC_UPDATE,
2183 0 : XML_TRUE);
2184 : }
2185 :
2186 0 : ExportElement(XML_DDE_CONNECTION_DECL, sal_True);
2187 : }
2188 : // else: no dependent field -> no export of field declaration
2189 0 : }
2190 28 : }
2191 : // else: no declarations element
2192 : }
2193 :
2194 104 : void XMLTextFieldExport::SetExportOnlyUsedFieldDeclarations(
2195 : sal_Bool bExportOnlyUsed)
2196 : {
2197 104 : delete pUsedMasters;
2198 104 : pUsedMasters = NULL;
2199 :
2200 : // create used masters set (if none is used)
2201 104 : if (bExportOnlyUsed)
2202 88 : pUsedMasters = new map<Reference<XText>, set<OUString> > ;
2203 104 : }
2204 :
2205 66 : void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName,
2206 : sal_Bool bAddSpace)
2207 : {
2208 : // can't call ExportElement(eElementName, const OUString&) with empty
2209 : // string because xmlprinter only uses empty tags if no content
2210 : // (not even empty content) was written.
2211 :
2212 : DBG_ASSERT(XML_TOKEN_INVALID != eElementName, "invalid element name!");
2213 66 : if (XML_TOKEN_INVALID != eElementName)
2214 : {
2215 : // Element
2216 66 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
2217 132 : eElementName, bAddSpace, bAddSpace );
2218 : } // else: ignore
2219 66 : }
2220 :
2221 72 : void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName,
2222 : const OUString& sContent,
2223 : sal_Bool bAddSpace)
2224 : {
2225 : DBG_ASSERT(eElementName != XML_TOKEN_INVALID, "invalid element name!");
2226 72 : if (eElementName != XML_TOKEN_INVALID)
2227 : {
2228 : // Element
2229 72 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
2230 144 : eElementName, bAddSpace, bAddSpace );
2231 : // export content
2232 72 : GetExport().Characters(sContent);
2233 : } else {
2234 : // always export content
2235 0 : GetExport().Characters(sContent);
2236 : }
2237 72 : }
2238 :
2239 0 : void XMLTextFieldExport::ExportMacro(
2240 : const Reference<XPropertySet> & rPropSet,
2241 : const OUString& rContent )
2242 : {
2243 : // some strings we'll need
2244 0 : OUString sEventType( "EventType" );
2245 0 : OUString sStarBasic( "StarBasic" );
2246 0 : OUString sScript( "Script" );
2247 0 : OUString sLibrary( "Library" );
2248 0 : OUString sMacroName( "MacroName" );
2249 0 : OUString sOnClick( "OnClick" );
2250 0 : OUString sPropertyMacroLibrary( "MacroLibrary" );
2251 0 : OUString sPropertyMacroName( "MacroName" );
2252 0 : OUString sPropertyScriptURL( "ScriptURL" );
2253 :
2254 :
2255 : // the description attribute
2256 : ProcessString(XML_DESCRIPTION,
2257 : GetStringProperty(sPropertyHint, rPropSet),
2258 0 : rContent);
2259 :
2260 : // the element
2261 0 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
2262 0 : XML_EXECUTE_MACRO, sal_False, sal_False );
2263 :
2264 : // the <office:events>-macro:
2265 :
2266 : // 1) build sequence of PropertyValues
2267 0 : Sequence<PropertyValue> aSeq;
2268 0 : OUString sName;
2269 0 : rPropSet->getPropertyValue( sPropertyScriptURL ) >>= sName;
2270 :
2271 : // if the ScriptURL property is not empty then this is a Scripting
2272 : // Framework URL, otherwise treat it as a Basic Macro
2273 0 : if (!sName.isEmpty())
2274 : {
2275 0 : aSeq = Sequence<PropertyValue> (2);
2276 0 : PropertyValue* pArr = aSeq.getArray();
2277 0 : pArr[0].Name = sEventType;
2278 0 : pArr[0].Value <<= sScript;
2279 0 : pArr[1].Name = sScript;
2280 0 : pArr[1].Value = rPropSet->getPropertyValue( sPropertyScriptURL );
2281 : }
2282 : else
2283 : {
2284 0 : aSeq = Sequence<PropertyValue> (3);
2285 0 : PropertyValue* pArr = aSeq.getArray();
2286 0 : pArr[0].Name = sEventType;
2287 0 : pArr[0].Value <<= sStarBasic;
2288 0 : pArr[1].Name = sLibrary;
2289 0 : pArr[1].Value = rPropSet->getPropertyValue( sPropertyMacroLibrary );
2290 0 : pArr[2].Name = sMacroName;
2291 0 : pArr[2].Value = rPropSet->getPropertyValue( sPropertyMacroName );
2292 : }
2293 :
2294 : // 2) export the sequence
2295 0 : GetExport().GetEventExport().ExportSingleEvent( aSeq, sOnClick, sal_False );
2296 :
2297 : // and finally, the field presentation
2298 0 : GetExport().Characters(rContent);
2299 0 : }
2300 :
2301 10 : void XMLTextFieldExport::ExportMetaField(
2302 : const Reference<XPropertySet> & i_xMeta,
2303 : bool i_bAutoStyles, sal_Bool i_bProgress )
2304 : {
2305 10 : bool doExport(!i_bAutoStyles); // do not export element if autostyles
2306 : // check version >= 1.2
2307 10 : switch (GetExport().getDefaultVersion()) {
2308 : case SvtSaveOptions::ODFVER_011: // fall thru
2309 0 : case SvtSaveOptions::ODFVER_010: doExport = false; break;
2310 10 : default: break;
2311 : }
2312 :
2313 10 : const Reference < XEnumerationAccess > xEA( i_xMeta, UNO_QUERY_THROW );
2314 20 : const Reference < XEnumeration > xTextEnum( xEA->createEnumeration() );
2315 :
2316 10 : if (doExport)
2317 : {
2318 10 : const Reference<rdf::XMetadatable> xMeta( i_xMeta, UNO_QUERY_THROW );
2319 :
2320 : // style:data-style-name
2321 : ProcessValueAndType(sal_False,
2322 : GetIntProperty(sPropertyNumberFormat, i_xMeta),
2323 : sEmpty, sEmpty, 0.0, sal_False, sal_False, sal_True,
2324 10 : sal_False, sal_False /*, sal_False*/ );
2325 :
2326 : // text:meta-field without xml:id is invalid
2327 10 : xMeta->ensureMetadataReference();
2328 :
2329 : // xml:id for RDF metadata
2330 10 : GetExport().AddAttributeXmlId(xMeta);
2331 : }
2332 :
2333 10 : SvXMLElementExport aElem( GetExport(), doExport,
2334 30 : XML_NAMESPACE_TEXT, XML_META_FIELD, sal_False, sal_False );
2335 :
2336 : // recurse to export content
2337 10 : GetExport().GetTextParagraphExport()->
2338 30 : exportTextRangeEnumeration( xTextEnum, i_bAutoStyles, i_bProgress );
2339 10 : }
2340 :
2341 : /// export all data-style related attributes
2342 26 : void XMLTextFieldExport::ProcessValueAndType(
2343 : sal_Bool bIsString, /// do we process a string or a number?
2344 : sal_Int32 nFormatKey, /// format key for NumberFormatter; inv. if string
2345 : const OUString& sContent, /// string content; possibly invalid
2346 : const OUString& sDefault, /// default string
2347 : double fValue, /// float content; possibly invalid
2348 : sal_Bool bExportValue, /// export value attribute?
2349 : sal_Bool bExportValueType, /// export value-type attribute?
2350 : sal_Bool bExportStyle, /// export style-sttribute?
2351 : sal_Bool bForceSystemLanguage, /// export language attributes?
2352 : sal_Bool bTimeStyle) // exporting a time style?
2353 : {
2354 : // String or number?
2355 26 : if (bIsString)
2356 : {
2357 :
2358 : // string: attributes value-type=string, string-value=...
2359 :
2360 0 : if (bExportValue || bExportValueType)
2361 : {
2362 : XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes(
2363 0 : GetExport(), sContent, sDefault, bExportValue);
2364 : }
2365 :
2366 : }
2367 : else
2368 : {
2369 :
2370 : // number: value-type=..., value...=..., data-style-name=...
2371 :
2372 : DBG_ASSERT(bExportValueType || !bExportValue, "value w/o value type not supported!");
2373 :
2374 : // take care of illegal formats
2375 : // (shouldn't happen, but does if document is corrupted)
2376 26 : if (-1 != nFormatKey)
2377 : {
2378 18 : if (bExportValue || bExportValueType)
2379 : {
2380 : XMLNumberFormatAttributesExportHelper::
2381 : SetNumberFormatAttributes(
2382 4 : GetExport(), nFormatKey, fValue, bExportValue);
2383 : }
2384 :
2385 18 : if (bExportStyle)
2386 : {
2387 : // don't export language (if desired)
2388 16 : if( bForceSystemLanguage )
2389 : nFormatKey =
2390 12 : GetExport().dataStyleForceSystemLanguage( nFormatKey );
2391 :
2392 : OUString sDataStyleName =
2393 16 : GetExport().getDataStyleName(nFormatKey, bTimeStyle);
2394 16 : if( !sDataStyleName.isEmpty() )
2395 : {
2396 16 : GetExport().AddAttribute( XML_NAMESPACE_STYLE,
2397 : XML_DATA_STYLE_NAME,
2398 16 : sDataStyleName );
2399 16 : } // else: ignore (no valid number format)
2400 : } // else: ignore (no number format)
2401 : }
2402 : }
2403 26 : }
2404 :
2405 :
2406 :
2407 : /// process display related properties
2408 2 : void XMLTextFieldExport::ProcessDisplay(sal_Bool bIsVisible,
2409 : sal_Bool bIsCommand,
2410 : sal_Bool bValueDefault)
2411 : {
2412 : enum XMLTokenEnum eValue;
2413 :
2414 2 : if (bIsVisible)
2415 : {
2416 2 : eValue = bIsCommand ? XML_FORMULA : XML_VALUE;
2417 : }
2418 : else
2419 : {
2420 0 : eValue = XML_NONE;
2421 : }
2422 :
2423 : // omit attribute if default
2424 2 : if (!bValueDefault || (eValue != XML_VALUE))
2425 : {
2426 0 : GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_DISPLAY, eValue);
2427 : }
2428 2 : }
2429 :
2430 :
2431 :
2432 : /// export boolean property
2433 12 : void XMLTextFieldExport::ProcessBoolean(enum XMLTokenEnum eName,
2434 : sal_Bool bBool, sal_Bool bDefault)
2435 : {
2436 : DBG_ASSERT( eName != XML_TOKEN_INVALID, "invalid element token");
2437 12 : if ( XML_TOKEN_INVALID == eName )
2438 12 : return;
2439 :
2440 : // write attribute (if different than default)
2441 : // negate to force 0/1 values (and make sal_Bool comparable)
2442 12 : if ((!bBool) != (!bDefault)) {
2443 0 : GetExport().AddAttribute(XML_NAMESPACE_TEXT, eName,
2444 0 : (bBool ? XML_TRUE : XML_FALSE) );
2445 : }
2446 : }
2447 :
2448 :
2449 :
2450 :
2451 : /// export string attribute
2452 80 : void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName,
2453 : const OUString& sValue,
2454 : sal_Bool bOmitEmpty,
2455 : sal_uInt16 nPrefix)
2456 : {
2457 : DBG_ASSERT( eName != XML_TOKEN_INVALID, "invalid element token");
2458 80 : if ( XML_TOKEN_INVALID == eName )
2459 0 : return;
2460 :
2461 : // check for empty string, if applicable
2462 80 : if ( bOmitEmpty && sValue.isEmpty() )
2463 0 : return;
2464 :
2465 : // write attribute
2466 80 : GetExport().AddAttribute(nPrefix, eName, sValue);
2467 : }
2468 :
2469 0 : void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName,
2470 : sal_uInt16 nValuePrefix,
2471 : const OUString& sValue,
2472 : sal_Bool bOmitEmpty,
2473 : sal_uInt16 nPrefix)
2474 : {
2475 : OUString sQValue =
2476 0 : GetExport().GetNamespaceMap().GetQNameByKey( nValuePrefix, sValue, sal_False );
2477 0 : ProcessString( eName, sQValue, bOmitEmpty, nPrefix );
2478 0 : }
2479 :
2480 : /// export a string attribute
2481 0 : void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName,
2482 : const OUString& sValue,
2483 : const OUString& sDefault,
2484 : sal_uInt16 nPrefix)
2485 : {
2486 0 : if (sValue != sDefault)
2487 : {
2488 0 : ProcessString(eName, sValue, sal_False, nPrefix);
2489 : }
2490 0 : }
2491 :
2492 : /// export a string attribute
2493 2 : void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName,
2494 : sal_uInt16 nValuePrefix,
2495 : const OUString& sValue,
2496 : const OUString& sDefault,
2497 : sal_uInt16 nPrefix)
2498 : {
2499 2 : if (sValue != sDefault)
2500 : {
2501 0 : ProcessString(eName, nValuePrefix, sValue, sal_False, nPrefix);
2502 : }
2503 2 : }
2504 :
2505 :
2506 : /// export string attribute
2507 0 : void XMLTextFieldExport::ProcessString(
2508 : enum XMLTokenEnum eName,
2509 : enum XMLTokenEnum eValue,
2510 : sal_Bool bOmitEmpty,
2511 : sal_uInt16 nPrefix)
2512 : {
2513 : DBG_ASSERT( eName != XML_TOKEN_INVALID, "invalid element token" );
2514 : DBG_ASSERT( bOmitEmpty || (eValue != XML_TOKEN_INVALID),
2515 : "invalid value token" );
2516 0 : if ( XML_TOKEN_INVALID == eName )
2517 0 : return;
2518 :
2519 : // check for empty string, if applicable
2520 0 : if (bOmitEmpty && (eValue == XML_TOKEN_INVALID))
2521 0 : return;
2522 :
2523 0 : GetExport().AddAttribute(nPrefix, eName, eValue);
2524 : }
2525 :
2526 : /// export a string attribute
2527 0 : void XMLTextFieldExport::ProcessString(
2528 : enum XMLTokenEnum eName,
2529 : enum XMLTokenEnum eValue,
2530 : enum XMLTokenEnum eDefault,
2531 : sal_uInt16 nPrefix)
2532 : {
2533 0 : if ( eValue != eDefault )
2534 0 : ProcessString( eName, eValue, sal_False, nPrefix);
2535 0 : }
2536 :
2537 :
2538 : /// export a string as a sequence of paragraphs
2539 0 : void XMLTextFieldExport::ProcessParagraphSequence(
2540 : const OUString& sParagraphSequence)
2541 : {
2542 : // iterate over all string-pieces separated by return (0x0a) and
2543 : // put each inside a paragraph element.
2544 0 : SvXMLTokenEnumerator aEnumerator(sParagraphSequence, sal_Char(0x0a));
2545 0 : OUString aSubString;
2546 0 : while (aEnumerator.getNextToken(aSubString))
2547 : {
2548 : SvXMLElementExport aParagraph(
2549 0 : GetExport(), XML_NAMESPACE_TEXT, XML_P, sal_True, sal_False);
2550 0 : GetExport().Characters(aSubString);
2551 0 : }
2552 0 : }
2553 :
2554 : // export an integer attribute
2555 64 : void XMLTextFieldExport::ProcessInteger(enum XMLTokenEnum eName,
2556 : sal_Int32 nNum)
2557 : {
2558 : DBG_ASSERT( eName != XML_TOKEN_INVALID, "invalid element token");
2559 64 : if ( XML_TOKEN_INVALID == eName )
2560 64 : return;
2561 :
2562 64 : GetExport().AddAttribute(XML_NAMESPACE_TEXT, eName,
2563 128 : OUString::valueOf(nNum));
2564 : }
2565 :
2566 : /// export an integer attribute, omit if default
2567 0 : void XMLTextFieldExport::ProcessIntegerDef(enum XMLTokenEnum eName,
2568 : sal_Int32 nNum, sal_Int32 nDefault)
2569 : {
2570 0 : if (nNum != nDefault)
2571 0 : ProcessInteger(eName, nNum);
2572 0 : }
2573 :
2574 :
2575 :
2576 : /// export a numbering type
2577 0 : void XMLTextFieldExport::ProcessNumberingType(sal_Int16 nNumberingType)
2578 : {
2579 : // process only if real format (not: like page descriptor)
2580 0 : if (NumberingType::PAGE_DESCRIPTOR != nNumberingType)
2581 : {
2582 0 : OUStringBuffer sTmp( 10 );
2583 : // number type: num format
2584 0 : GetExport().GetMM100UnitConverter().convertNumFormat( sTmp,
2585 0 : nNumberingType );
2586 0 : GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_FORMAT,
2587 0 : sTmp.makeStringAndClear() );
2588 : // and letter sync, if applicable
2589 0 : GetExport().GetMM100UnitConverter().convertNumLetterSync( sTmp,
2590 0 : nNumberingType );
2591 :
2592 0 : if (!sTmp.isEmpty())
2593 : {
2594 0 : GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_LETTER_SYNC,
2595 0 : sTmp.makeStringAndClear() );
2596 0 : }
2597 : }
2598 : // else: like page descriptor => ignore
2599 0 : }
2600 :
2601 :
2602 : /// export a date, time, or duration
2603 0 : void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName,
2604 : double dValue,
2605 : sal_Bool bIsDate,
2606 : sal_Bool bIsDuration,
2607 : sal_Bool bOmitDurationIfZero,
2608 : sal_uInt16 nPrefix)
2609 : {
2610 : // truncate for date granularity
2611 0 : if (bIsDate)
2612 : {
2613 0 : dValue = ::rtl::math::approxFloor(dValue);
2614 : }
2615 :
2616 0 : OUStringBuffer aBuffer;
2617 0 : if (bIsDuration)
2618 : {
2619 : // date/time durationM handle bOmitDurationIfZero
2620 0 : if (!bOmitDurationIfZero || !::rtl::math::approxEqual(dValue, 0.0))
2621 : {
2622 0 : ::sax::Converter::convertDuration(aBuffer, dValue);
2623 : }
2624 : }
2625 : else
2626 : {
2627 : // date/time value
2628 0 : rExport.GetMM100UnitConverter().convertDateTime(aBuffer, dValue);
2629 : }
2630 :
2631 : // output attribute
2632 0 : ProcessString(eName, aBuffer.makeStringAndClear(), sal_True, nPrefix);
2633 0 : }
2634 :
2635 : /// export a date or time
2636 12 : void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName,
2637 : const util::DateTime& rTime,
2638 : sal_Bool bIsDate,
2639 : sal_uInt16 nPrefix)
2640 : {
2641 12 : OUStringBuffer aBuffer;
2642 :
2643 12 : util::DateTime aDateTime(rTime);
2644 :
2645 : // truncate dates
2646 12 : if(bIsDate)
2647 : {
2648 0 : aDateTime.NanoSeconds = 0;
2649 0 : aDateTime.Seconds = 0;
2650 0 : aDateTime.Minutes = 0;
2651 0 : aDateTime.Hours = 0;
2652 : }
2653 :
2654 : // date/time value
2655 12 : ::sax::Converter::convertDateTime(aBuffer, aDateTime);
2656 :
2657 : // output attribute
2658 12 : ProcessString(eName, aBuffer.makeStringAndClear(), sal_True, nPrefix);
2659 12 : }
2660 :
2661 : /// export a date, time, or duration
2662 0 : void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName,
2663 : sal_Int32 nMinutes,
2664 : sal_Bool bIsDate,
2665 : sal_Bool bIsDuration,
2666 : sal_Bool bOmitDurationIfZero,
2667 : sal_uInt16 nPrefix)
2668 : {
2669 : // handle bOmitDurationIfZero here, because we can precisely compare ints
2670 0 : if (!(bIsDuration && bOmitDurationIfZero && (nMinutes==0)))
2671 : {
2672 : ProcessDateTime(eName, (double)nMinutes / (double)(24*60),
2673 0 : bIsDate, bIsDuration, bOmitDurationIfZero, nPrefix);
2674 : }
2675 0 : }
2676 :
2677 :
2678 : SvXMLEnumMapEntry const aBibliographyDataTypeMap[] =
2679 : {
2680 : { XML_ARTICLE, BibliographyDataType::ARTICLE },
2681 : { XML_BOOK, BibliographyDataType::BOOK },
2682 : { XML_BOOKLET, BibliographyDataType::BOOKLET },
2683 : { XML_CONFERENCE, BibliographyDataType::CONFERENCE },
2684 : { XML_CUSTOM1, BibliographyDataType::CUSTOM1 },
2685 : { XML_CUSTOM2, BibliographyDataType::CUSTOM2 },
2686 : { XML_CUSTOM3, BibliographyDataType::CUSTOM3 },
2687 : { XML_CUSTOM4, BibliographyDataType::CUSTOM4 },
2688 : { XML_CUSTOM5, BibliographyDataType::CUSTOM5 },
2689 : { XML_EMAIL, BibliographyDataType::EMAIL },
2690 : { XML_INBOOK, BibliographyDataType::INBOOK },
2691 : { XML_INCOLLECTION, BibliographyDataType::INCOLLECTION },
2692 : { XML_INPROCEEDINGS, BibliographyDataType::INPROCEEDINGS },
2693 : { XML_JOURNAL, BibliographyDataType::JOURNAL },
2694 : { XML_MANUAL, BibliographyDataType::MANUAL },
2695 : { XML_MASTERSTHESIS, BibliographyDataType::MASTERSTHESIS },
2696 : { XML_MISC, BibliographyDataType::MISC },
2697 : { XML_PHDTHESIS, BibliographyDataType::PHDTHESIS },
2698 : { XML_PROCEEDINGS, BibliographyDataType::PROCEEDINGS },
2699 : { XML_TECHREPORT, BibliographyDataType::TECHREPORT },
2700 : { XML_UNPUBLISHED, BibliographyDataType::UNPUBLISHED },
2701 : { XML_WWW, BibliographyDataType::WWW },
2702 : { XML_TOKEN_INVALID, 0 }
2703 : };
2704 :
2705 :
2706 :
2707 0 : void XMLTextFieldExport::ProcessBibliographyData(
2708 : const Reference<XPropertySet>& rPropSet)
2709 : {
2710 : // get the values
2711 0 : Any aAny = rPropSet->getPropertyValue(sPropertyFields);
2712 0 : Sequence<PropertyValue> aValues;
2713 0 : aAny >>= aValues;
2714 :
2715 : // one attribute per value (unless empty)
2716 0 : sal_Int32 nLength = aValues.getLength();
2717 0 : for (sal_Int32 i = 0; i < nLength; i++)
2718 : {
2719 0 : if (aValues[i].Name.equalsAsciiL("BibiliographicType",
2720 0 : sizeof("BibiliographicType")-1))
2721 : {
2722 0 : sal_Int16 nTypeId = 0;
2723 0 : aValues[i].Value >>= nTypeId;
2724 0 : OUStringBuffer sBuf;
2725 :
2726 0 : if (SvXMLUnitConverter::convertEnum(sBuf, nTypeId,
2727 0 : aBibliographyDataTypeMap))
2728 : {
2729 : rExport.AddAttribute(XML_NAMESPACE_TEXT,
2730 : XML_BIBLIOGRAPHY_TYPE,
2731 0 : sBuf.makeStringAndClear());
2732 0 : }
2733 : // else: ignore this argument
2734 : }
2735 : else
2736 : {
2737 0 : OUString sStr;
2738 0 : aValues[i].Value >>= sStr;
2739 :
2740 0 : if (!sStr.isEmpty())
2741 : {
2742 : rExport.AddAttribute(XML_NAMESPACE_TEXT,
2743 0 : MapBibliographyFieldName(aValues[i].Name),
2744 0 : sStr);
2745 0 : }
2746 : }
2747 0 : }
2748 0 : }
2749 :
2750 : /// export CommandTypeAttribute
2751 0 : void XMLTextFieldExport::ProcessCommandType(
2752 : sal_Int32 nCommandType)
2753 : {
2754 0 : enum XMLTokenEnum eToken = XML_TOKEN_INVALID;
2755 0 : switch( nCommandType )
2756 : {
2757 0 : case sdb::CommandType::TABLE: eToken = XML_TABLE; break;
2758 0 : case sdb::CommandType::QUERY: eToken = XML_QUERY; break;
2759 0 : case sdb::CommandType::COMMAND: eToken = XML_COMMAND; break;
2760 : }
2761 :
2762 0 : if( eToken != XML_TOKEN_INVALID )
2763 0 : rExport.AddAttribute( XML_NAMESPACE_TEXT, XML_TABLE_TYPE, eToken );
2764 0 : }
2765 :
2766 :
2767 0 : void XMLTextFieldExport::ProcessStringSequence(
2768 : const Sequence<OUString>& rSequence,
2769 : const OUString sSelected )
2770 : {
2771 : // find selected element
2772 0 : sal_Int32 nSelected = -1;
2773 0 : sal_Int32 nLength = rSequence.getLength();
2774 0 : const OUString* pSequence = rSequence.getConstArray();
2775 0 : for( sal_Int32 i = 0; i < nLength; i++ )
2776 : {
2777 0 : if( pSequence[i] == sSelected )
2778 0 : nSelected = i;
2779 : }
2780 :
2781 : // delegate to ProcessStringSequence(OUString,sal_Int32)
2782 0 : ProcessStringSequence( rSequence, nSelected );
2783 0 : }
2784 :
2785 0 : void XMLTextFieldExport::ProcessStringSequence(
2786 : const Sequence<OUString>& rSequence,
2787 : sal_Int32 nSelected )
2788 : {
2789 0 : sal_Int32 nLength = rSequence.getLength();
2790 0 : const OUString* pSequence = rSequence.getConstArray();
2791 0 : for( sal_Int32 i = 0; i < nLength; i++ )
2792 : {
2793 0 : if( i == nSelected )
2794 : rExport.AddAttribute( XML_NAMESPACE_TEXT,
2795 0 : XML_CURRENT_SELECTED, XML_TRUE );
2796 0 : rExport.AddAttribute( XML_NAMESPACE_TEXT, XML_VALUE, pSequence[i] );
2797 : SvXMLElementExport aElement( rExport, XML_NAMESPACE_TEXT, XML_LABEL,
2798 0 : sal_False, sal_False );
2799 0 : }
2800 0 : }
2801 :
2802 0 : void XMLTextFieldExport::ExportDataBaseElement(
2803 : enum XMLTokenEnum eElementName,
2804 : const OUString& sPresentation,
2805 : const Reference<XPropertySet>& rPropertySet,
2806 : const Reference<XPropertySetInfo>& rPropertySetInfo )
2807 : {
2808 : DBG_ASSERT( eElementName != XML_TOKEN_INVALID, "need token" );
2809 : DBG_ASSERT( rPropertySet.is(), "need property set" );
2810 : DBG_ASSERT( rPropertySetInfo.is(), "need property set info" );
2811 :
2812 : // get database properties
2813 0 : OUString sDataBaseName;
2814 0 : OUString sDataBaseURL;
2815 0 : OUString sStr;
2816 0 : if( ( rPropertySet->getPropertyValue( sPropertyDataBaseName ) >>= sStr )
2817 0 : && !sStr.isEmpty() )
2818 : {
2819 0 : sDataBaseName = sStr;
2820 : }
2821 0 : else if( rPropertySetInfo->hasPropertyByName( sPropertyDataBaseURL ) &&
2822 0 : (rPropertySet->getPropertyValue( sPropertyDataBaseURL ) >>= sStr) &&
2823 0 : !sStr.isEmpty() )
2824 : {
2825 0 : sDataBaseURL = sStr;
2826 : }
2827 :
2828 : // add database name property (if present)
2829 0 : if( !sDataBaseName.isEmpty() )
2830 : rExport.AddAttribute( XML_NAMESPACE_TEXT, XML_DATABASE_NAME,
2831 0 : sDataBaseName );
2832 0 : SvXMLElementExport aDataBaseElement( GetExport(),
2833 : XML_NAMESPACE_TEXT, eElementName,
2834 0 : sal_False, sal_False );
2835 :
2836 : // write URL as children
2837 0 : if( !sDataBaseURL.isEmpty() )
2838 : {
2839 0 : rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sDataBaseURL );
2840 : SvXMLElementExport aDataSourceElement(
2841 0 : GetExport(), XML_NAMESPACE_FORM, XML_CONNECTION_RESOURCE,
2842 0 : sal_False, sal_False );
2843 : }
2844 :
2845 : // write presentation
2846 0 : rExport.Characters( sPresentation );
2847 0 : }
2848 :
2849 :
2850 :
2851 : // explode a field master name into field type and field name
2852 133 : sal_Bool XMLTextFieldExport::ExplodeFieldMasterName(
2853 : const OUString& sMasterName, OUString& sFieldType, OUString& sVarName)
2854 : {
2855 133 : sal_Int32 nLength = sFieldMasterPrefix.getLength();
2856 133 : sal_Int32 nSeparator = sMasterName.indexOf('.', nLength);
2857 133 : sal_Bool bReturn = sal_True;
2858 :
2859 : #ifdef DBG_UTIL
2860 : // check for service name
2861 : bReturn &= (0 == sFieldMasterPrefix.compareTo(sMasterName, nLength));
2862 : #endif
2863 :
2864 : // '.' found?
2865 133 : if (nSeparator <= nLength) {
2866 1 : nSeparator = sMasterName.getLength();
2867 : DBG_WARNING("no field var name!");
2868 1 : bReturn = sal_False;
2869 : }
2870 : else
2871 : {
2872 132 : sFieldType = sMasterName.copy(nLength, nSeparator-nLength);
2873 132 : sVarName = sMasterName.copy(nSeparator+1);
2874 : }
2875 :
2876 133 : return bReturn;
2877 : }
2878 :
2879 :
2880 : // for XDependentTextFields, get PropertySet of FieldMaster
2881 0 : Reference<XPropertySet> XMLTextFieldExport::GetMasterPropertySet(
2882 : const Reference<XTextField> & rTextField)
2883 : {
2884 : // name, value => get Property set of TextFieldMaster
2885 0 : Reference<XDependentTextField> xDep(rTextField, UNO_QUERY);
2886 0 : return xDep->getTextFieldMaster();
2887 : }
2888 :
2889 : // get PropertySet of (any; the first) dependent field
2890 2 : sal_Bool XMLTextFieldExport::GetDependentFieldPropertySet(
2891 : const Reference<XPropertySet> & xMaster,
2892 : Reference<XPropertySet> & xField)
2893 : {
2894 2 : Any aAny;
2895 4 : Sequence<Reference<XDependentTextField> > aFields;
2896 2 : aAny = xMaster->getPropertyValue(sPropertyDependentTextFields);
2897 2 : aAny >>= aFields;
2898 :
2899 : // any fields?
2900 2 : if (aFields.getLength() > 0)
2901 : {
2902 : // get first one and return
2903 2 : Reference<XDependentTextField> xTField = aFields[0];
2904 2 : xField = Reference<XPropertySet>(xTField, UNO_QUERY);
2905 : DBG_ASSERT(xField.is(),
2906 : "Surprisinlgy, this TextField refuses to be a PropertySet!");
2907 2 : return sal_True;
2908 : }
2909 : else
2910 : {
2911 0 : return sal_False;
2912 2 : }
2913 : }
2914 :
2915 :
2916 : /// map placeholder type
2917 0 : enum XMLTokenEnum XMLTextFieldExport::MapPlaceholderType(sal_uInt16 nType)
2918 : {
2919 0 : enum XMLTokenEnum eType = XML_TEXT;
2920 :
2921 0 : switch (nType)
2922 : {
2923 : case PlaceholderType::TEXT:
2924 0 : eType = XML_TEXT;
2925 0 : break;
2926 :
2927 : case PlaceholderType::TABLE:
2928 0 : eType = XML_TABLE;
2929 0 : break;
2930 :
2931 : case PlaceholderType::TEXTFRAME:
2932 0 : eType = XML_TEXT_BOX;
2933 0 : break;
2934 :
2935 : case PlaceholderType::GRAPHIC:
2936 0 : eType = XML_IMAGE;
2937 0 : break;
2938 :
2939 : case PlaceholderType::OBJECT:
2940 0 : eType = XML_OBJECT;
2941 0 : break;
2942 :
2943 : default:
2944 : // unknown placeholder: XML_TEXT
2945 : OSL_FAIL("unknown placeholder type");
2946 : }
2947 :
2948 0 : return eType;
2949 : }
2950 :
2951 :
2952 : /// element name for author fields
2953 0 : enum XMLTokenEnum XMLTextFieldExport::MapAuthorFieldName(
2954 : const Reference<XPropertySet> & xPropSet)
2955 : {
2956 : // Initalen oder voller Name?
2957 0 : return GetBoolProperty(sPropertyFullName, xPropSet)
2958 0 : ? XML_AUTHOR_NAME : XML_AUTHOR_INITIALS;
2959 : }
2960 :
2961 0 : enum XMLTokenEnum XMLTextFieldExport::MapPageNumberName(
2962 : const Reference<XPropertySet> & xPropSet,
2963 : sal_Int32& nOffset)
2964 : {
2965 0 : enum XMLTokenEnum eName = XML_TOKEN_INVALID;
2966 : PageNumberType ePage;
2967 0 : Any aAny = xPropSet->getPropertyValue(sPropertySubType);
2968 0 : ePage = *(PageNumberType*)aAny.getValue();
2969 :
2970 0 : switch (ePage)
2971 : {
2972 : case PageNumberType_PREV:
2973 0 : eName = XML_PREVIOUS;
2974 0 : nOffset += 1;
2975 0 : break;
2976 : case PageNumberType_CURRENT:
2977 0 : eName = XML_CURRENT;
2978 0 : break;
2979 : case PageNumberType_NEXT:
2980 0 : eName = XML_NEXT;
2981 0 : nOffset -= 1;
2982 0 : break;
2983 : default:
2984 : OSL_FAIL("unknown page number type");
2985 0 : eName = XML_TOKEN_INVALID;
2986 0 : break;
2987 : }
2988 :
2989 0 : return eName;
2990 : }
2991 :
2992 : /// map TemplateDisplayFormat to XML
2993 0 : enum XMLTokenEnum XMLTextFieldExport::MapTemplateDisplayFormat(sal_Int16 nFormat)
2994 : {
2995 0 : enum XMLTokenEnum eName = XML_TOKEN_INVALID;
2996 :
2997 0 : switch (nFormat)
2998 : {
2999 : case TemplateDisplayFormat::FULL:
3000 0 : eName = XML_FULL;
3001 0 : break;
3002 : case TemplateDisplayFormat::PATH:
3003 0 : eName = XML_PATH;
3004 0 : break;
3005 : case TemplateDisplayFormat::NAME:
3006 0 : eName = XML_NAME;
3007 0 : break;
3008 : case TemplateDisplayFormat::NAME_AND_EXT:
3009 0 : eName = XML_NAME_AND_EXTENSION;
3010 0 : break;
3011 : case TemplateDisplayFormat::AREA:
3012 0 : eName = XML_AREA;
3013 0 : break;
3014 : case TemplateDisplayFormat::TITLE:
3015 0 : eName = XML_TITLE;
3016 0 : break;
3017 : default:
3018 : OSL_FAIL("unknown template display format");
3019 0 : eName = XML_TOKEN_INVALID;
3020 0 : break;
3021 : }
3022 :
3023 0 : return eName;
3024 : }
3025 :
3026 : /// map count/statistics field token to XML name
3027 8 : enum XMLTokenEnum XMLTextFieldExport::MapCountFieldName(FieldIdEnum nToken)
3028 : {
3029 8 : enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
3030 :
3031 8 : switch (nToken)
3032 : {
3033 : case FIELD_ID_COUNT_PAGES:
3034 8 : eElement = XML_PAGE_COUNT;
3035 8 : break;
3036 : case FIELD_ID_COUNT_PARAGRAPHS:
3037 0 : eElement = XML_PARAGRAPH_COUNT;
3038 0 : break;
3039 : case FIELD_ID_COUNT_WORDS:
3040 0 : eElement = XML_WORD_COUNT;
3041 0 : break;
3042 : case FIELD_ID_COUNT_CHARACTERS:
3043 0 : eElement = XML_CHARACTER_COUNT;
3044 0 : break;
3045 : case FIELD_ID_COUNT_TABLES:
3046 0 : eElement = XML_TABLE_COUNT;
3047 0 : break;
3048 : case FIELD_ID_COUNT_GRAPHICS:
3049 0 : eElement = XML_IMAGE_COUNT;
3050 0 : break;
3051 : case FIELD_ID_COUNT_OBJECTS:
3052 0 : eElement = XML_OBJECT_COUNT;
3053 0 : break;
3054 : default:
3055 : OSL_FAIL("no count field token");
3056 0 : eElement = XML_TOKEN_INVALID;
3057 0 : break;
3058 : }
3059 :
3060 8 : return eElement;
3061 : }
3062 :
3063 : /// map ChapterDisplayFormat to XML string
3064 0 : enum XMLTokenEnum XMLTextFieldExport::MapChapterDisplayFormat(sal_Int16 nFormat)
3065 : {
3066 0 : enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3067 :
3068 0 : switch (nFormat)
3069 : {
3070 : case ChapterFormat::NAME:
3071 0 : eName = XML_NAME;
3072 0 : break;
3073 : case ChapterFormat::NUMBER:
3074 0 : eName = XML_NUMBER;
3075 0 : break;
3076 : case ChapterFormat::NAME_NUMBER:
3077 0 : eName = XML_NUMBER_AND_NAME;
3078 0 : break;
3079 : case ChapterFormat::NO_PREFIX_SUFFIX:
3080 0 : eName = XML_PLAIN_NUMBER_AND_NAME;
3081 0 : break;
3082 : case ChapterFormat::DIGIT:
3083 0 : eName = XML_PLAIN_NUMBER;
3084 0 : break;
3085 : default:
3086 : OSL_FAIL("unknown chapter display format");
3087 0 : eName = XML_TOKEN_INVALID;
3088 0 : break;
3089 : }
3090 :
3091 0 : return eName;
3092 : }
3093 :
3094 :
3095 : /// map FilenameDisplayFormat to XML attribute names
3096 0 : enum XMLTokenEnum XMLTextFieldExport::MapFilenameDisplayFormat(sal_Int16 nFormat)
3097 : {
3098 0 : enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3099 :
3100 0 : switch (nFormat)
3101 : {
3102 : case FilenameDisplayFormat::FULL:
3103 0 : eName = XML_FULL;
3104 0 : break;
3105 : case FilenameDisplayFormat::PATH:
3106 0 : eName = XML_PATH;
3107 0 : break;
3108 : case FilenameDisplayFormat::NAME:
3109 0 : eName = XML_NAME;
3110 0 : break;
3111 : case FilenameDisplayFormat::NAME_AND_EXT:
3112 0 : eName = XML_NAME_AND_EXTENSION;
3113 0 : break;
3114 : default:
3115 : OSL_FAIL("unknown filename display format");
3116 : }
3117 :
3118 0 : return eName;
3119 : }
3120 :
3121 :
3122 : /// map ReferenceFieldPart to XML string
3123 2 : enum XMLTokenEnum XMLTextFieldExport::MapReferenceType(sal_Int16 nType)
3124 : {
3125 2 : enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
3126 :
3127 2 : switch (nType)
3128 : {
3129 : case ReferenceFieldPart::PAGE:
3130 0 : eElement = XML_PAGE;
3131 0 : break;
3132 : case ReferenceFieldPart::CHAPTER:
3133 0 : eElement = XML_CHAPTER;
3134 0 : break;
3135 : case ReferenceFieldPart::TEXT:
3136 2 : eElement = XML_TEXT;
3137 2 : break;
3138 : case ReferenceFieldPart::UP_DOWN:
3139 0 : eElement = XML_DIRECTION;
3140 0 : break;
3141 : case ReferenceFieldPart::CATEGORY_AND_NUMBER:
3142 0 : eElement = XML_CATEGORY_AND_VALUE;
3143 0 : break;
3144 : case ReferenceFieldPart::ONLY_CAPTION:
3145 0 : eElement = XML_CAPTION;
3146 0 : break;
3147 : case ReferenceFieldPart::ONLY_SEQUENCE_NUMBER:
3148 0 : eElement = XML_VALUE;
3149 0 : break;
3150 : case ReferenceFieldPart::PAGE_DESC:
3151 : // small hack: this value never gets written, because
3152 : // XML_TEMPLATE is default
3153 0 : eElement = XML_TEMPLATE;
3154 0 : break;
3155 : // Core implementation for direct cross-references (#i81002#)
3156 : case ReferenceFieldPart::NUMBER:
3157 0 : eElement = XML_NUMBER;
3158 0 : break;
3159 : case ReferenceFieldPart::NUMBER_NO_CONTEXT:
3160 0 : eElement = XML_NUMBER_NO_SUPERIOR;
3161 0 : break;
3162 : case ReferenceFieldPart::NUMBER_FULL_CONTEXT:
3163 0 : eElement = XML_NUMBER_ALL_SUPERIOR;
3164 0 : break;
3165 : default:
3166 : OSL_FAIL("unknown reference type");
3167 0 : eElement = XML_TEMPLATE;
3168 0 : break;
3169 : }
3170 :
3171 2 : return eElement;
3172 : }
3173 :
3174 : /// map ReferenceFieldPart to XML string
3175 0 : enum XMLTokenEnum XMLTextFieldExport::MapReferenceSource(sal_Int16 nType)
3176 : {
3177 0 : enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
3178 :
3179 0 : switch (nType)
3180 : {
3181 : case ReferenceFieldSource::REFERENCE_MARK:
3182 0 : eElement = XML_REFERENCE_REF;
3183 0 : break;
3184 : case ReferenceFieldSource::SEQUENCE_FIELD:
3185 0 : eElement = XML_SEQUENCE_REF;
3186 0 : break;
3187 : case ReferenceFieldSource::BOOKMARK:
3188 0 : eElement = XML_BOOKMARK_REF;
3189 0 : break;
3190 : case ReferenceFieldSource::FOOTNOTE:
3191 : case ReferenceFieldSource::ENDNOTE:
3192 0 : eElement = XML_NOTE_REF;
3193 0 : break;
3194 : default:
3195 : OSL_FAIL("unknown reference source");
3196 0 : break;
3197 : }
3198 :
3199 0 : return eElement;
3200 : }
3201 :
3202 :
3203 : /// element name for sender fields
3204 0 : enum XMLTokenEnum XMLTextFieldExport::MapSenderFieldName(
3205 : const Reference<XPropertySet> & xPropSet)
3206 : {
3207 0 : enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3208 :
3209 : // sub-field type
3210 0 : switch (GetInt16Property(sPropertyFieldSubType, xPropSet))
3211 : {
3212 : case UserDataPart::COMPANY :
3213 0 : eName = XML_SENDER_COMPANY;
3214 0 : break;
3215 : case UserDataPart::FIRSTNAME :
3216 0 : eName = XML_SENDER_FIRSTNAME;
3217 0 : break;
3218 : case UserDataPart::NAME :
3219 0 : eName = XML_SENDER_LASTNAME;
3220 0 : break;
3221 : case UserDataPart::SHORTCUT :
3222 0 : eName = XML_SENDER_INITIALS;
3223 0 : break;
3224 : case UserDataPart::STREET :
3225 0 : eName = XML_SENDER_STREET;
3226 0 : break;
3227 : case UserDataPart::COUNTRY :
3228 0 : eName = XML_SENDER_COUNTRY;
3229 0 : break;
3230 : case UserDataPart::ZIP :
3231 0 : eName = XML_SENDER_POSTAL_CODE;
3232 0 : break;
3233 : case UserDataPart::CITY :
3234 0 : eName = XML_SENDER_CITY;
3235 0 : break;
3236 : case UserDataPart::TITLE :
3237 0 : eName = XML_SENDER_TITLE;
3238 0 : break;
3239 : case UserDataPart::POSITION :
3240 0 : eName = XML_SENDER_POSITION;
3241 0 : break;
3242 : case UserDataPart::PHONE_PRIVATE :
3243 0 : eName = XML_SENDER_PHONE_PRIVATE;
3244 0 : break;
3245 : case UserDataPart::PHONE_COMPANY :
3246 0 : eName = XML_SENDER_PHONE_WORK;
3247 0 : break;
3248 : case UserDataPart::FAX :
3249 0 : eName = XML_SENDER_FAX;
3250 0 : break;
3251 : case UserDataPart::EMAIL :
3252 0 : eName = XML_SENDER_EMAIL;
3253 0 : break;
3254 : case UserDataPart::STATE :
3255 0 : eName = XML_SENDER_STATE_OR_PROVINCE;
3256 0 : break;
3257 : default:
3258 : DBG_WARNING("unknown sender type");
3259 0 : eName = XML_TOKEN_INVALID;
3260 0 : break;
3261 : }
3262 :
3263 0 : return eName;
3264 : }
3265 :
3266 8 : enum XMLTokenEnum XMLTextFieldExport::MapDocInfoFieldName(
3267 : enum FieldIdEnum nToken)
3268 : {
3269 8 : enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
3270 :
3271 8 : switch (nToken)
3272 : {
3273 : case FIELD_ID_DOCINFO_CREATION_AUTHOR:
3274 0 : eElement = XML_INITIAL_CREATOR;
3275 0 : break;
3276 : case FIELD_ID_DOCINFO_CREATION_DATE:
3277 0 : eElement = XML_CREATION_DATE;
3278 0 : break;
3279 : case FIELD_ID_DOCINFO_CREATION_TIME:
3280 0 : eElement = XML_CREATION_TIME;
3281 0 : break;
3282 : case FIELD_ID_DOCINFO_DESCRIPTION:
3283 0 : eElement = XML_DESCRIPTION;
3284 0 : break;
3285 : case FIELD_ID_DOCINFO_PRINT_TIME:
3286 0 : eElement = XML_PRINT_TIME;
3287 0 : break;
3288 : case FIELD_ID_DOCINFO_PRINT_DATE:
3289 0 : eElement = XML_PRINT_DATE;
3290 0 : break;
3291 : case FIELD_ID_DOCINFO_PRINT_AUTHOR:
3292 0 : eElement = XML_PRINTED_BY;
3293 0 : break;
3294 : case FIELD_ID_DOCINFO_TITLE:
3295 8 : eElement = XML_TITLE;
3296 8 : break;
3297 : case FIELD_ID_DOCINFO_SUBJECT:
3298 0 : eElement = XML_SUBJECT;
3299 0 : break;
3300 : case FIELD_ID_DOCINFO_KEYWORDS:
3301 0 : eElement = XML_KEYWORDS;
3302 0 : break;
3303 : case FIELD_ID_DOCINFO_REVISION:
3304 0 : eElement = XML_EDITING_CYCLES;
3305 0 : break;
3306 : case FIELD_ID_DOCINFO_EDIT_DURATION:
3307 0 : eElement = XML_EDITING_DURATION;
3308 0 : break;
3309 : case FIELD_ID_DOCINFO_SAVE_TIME:
3310 0 : eElement = XML_MODIFICATION_TIME;
3311 0 : break;
3312 : case FIELD_ID_DOCINFO_SAVE_DATE:
3313 0 : eElement = XML_MODIFICATION_DATE;
3314 0 : break;
3315 : case FIELD_ID_DOCINFO_SAVE_AUTHOR:
3316 0 : eElement = XML_CREATOR;
3317 0 : break;
3318 : default:
3319 : DBG_WARNING("unknown docinfo field type!");
3320 0 : eElement = XML_TOKEN_INVALID;
3321 0 : break;
3322 : }
3323 :
3324 8 : return eElement;
3325 : }
3326 :
3327 0 : enum XMLTokenEnum XMLTextFieldExport::MapBibliographyFieldName(OUString sName)
3328 : {
3329 0 : enum XMLTokenEnum eName = XML_TOKEN_INVALID;
3330 :
3331 0 : if (sName.equalsAsciiL("Identifier", sizeof("Identifier")-1))
3332 : {
3333 0 : eName = XML_IDENTIFIER;
3334 : }
3335 0 : else if (sName.equalsAsciiL("BibiliographicType",
3336 0 : sizeof("BibiliographicType")-1))
3337 : {
3338 0 : eName = XML_BIBLIOGRAPHY_TYPE;
3339 : }
3340 0 : else if (sName.equalsAsciiL("Address", sizeof("Address")-1))
3341 : {
3342 0 : eName = XML_ADDRESS;
3343 : }
3344 0 : else if (sName.equalsAsciiL("Annote", sizeof("Annote")-1))
3345 : {
3346 0 : eName = XML_ANNOTE;
3347 : }
3348 0 : else if (sName.equalsAsciiL("Author", sizeof("Author")-1))
3349 : {
3350 0 : eName = XML_AUTHOR;
3351 : }
3352 0 : else if (sName.equalsAsciiL("Booktitle", sizeof("Booktitle")-1))
3353 : {
3354 0 : eName = XML_BOOKTITLE;
3355 : }
3356 0 : else if (sName.equalsAsciiL("Chapter", sizeof("Chapter")-1))
3357 : {
3358 0 : eName = XML_CHAPTER;
3359 : }
3360 0 : else if (sName.equalsAsciiL("Edition", sizeof("Edition")-1))
3361 : {
3362 0 : eName = XML_EDITION;
3363 : }
3364 0 : else if (sName.equalsAsciiL("Editor", sizeof("Editor")-1))
3365 : {
3366 0 : eName = XML_EDITOR;
3367 : }
3368 0 : else if (sName.equalsAsciiL("Howpublished", sizeof("Howpublished")-1))
3369 : {
3370 0 : eName = XML_HOWPUBLISHED;
3371 : }
3372 0 : else if (sName.equalsAsciiL("Institution", sizeof("Institution")-1))
3373 : {
3374 0 : eName = XML_INSTITUTION;
3375 : }
3376 0 : else if (sName.equalsAsciiL("Journal", sizeof("Journal")-1))
3377 : {
3378 0 : eName = XML_JOURNAL;
3379 : }
3380 0 : else if (sName.equalsAsciiL("Month", sizeof("Month")-1))
3381 : {
3382 0 : eName = XML_MONTH;
3383 : }
3384 0 : else if (sName.equalsAsciiL("Note", sizeof("Note")-1))
3385 : {
3386 0 : eName = XML_NOTE;
3387 : }
3388 0 : else if (sName.equalsAsciiL("Number", sizeof("Number")-1))
3389 : {
3390 0 : eName = XML_NUMBER;
3391 : }
3392 0 : else if (sName.equalsAsciiL("Organizations", sizeof("Organizations")-1))
3393 : {
3394 0 : eName = XML_ORGANIZATIONS;
3395 : }
3396 0 : else if (sName.equalsAsciiL("Pages", sizeof("Pages")-1))
3397 : {
3398 0 : eName = XML_PAGES;
3399 : }
3400 0 : else if (sName.equalsAsciiL("Publisher", sizeof("Publisher")-1))
3401 : {
3402 0 : eName = XML_PUBLISHER;
3403 : }
3404 0 : else if (sName.equalsAsciiL("School", sizeof("School")-1))
3405 : {
3406 0 : eName = XML_SCHOOL;
3407 : }
3408 0 : else if (sName.equalsAsciiL("Series", sizeof("Series")-1))
3409 : {
3410 0 : eName = XML_SERIES;
3411 : }
3412 0 : else if (sName.equalsAsciiL("Title", sizeof("Title")-1))
3413 : {
3414 0 : eName = XML_TITLE;
3415 : }
3416 0 : else if (sName.equalsAsciiL("Report_Type", sizeof("Report_Type")-1))
3417 : {
3418 0 : eName = XML_REPORT_TYPE;
3419 : }
3420 0 : else if (sName.equalsAsciiL("Volume", sizeof("Volume")-1))
3421 : {
3422 0 : eName = XML_VOLUME;
3423 : }
3424 0 : else if (sName.equalsAsciiL("Year", sizeof("Year")-1))
3425 : {
3426 0 : eName = XML_YEAR;
3427 : }
3428 0 : else if (sName.equalsAsciiL("URL", sizeof("URL")-1))
3429 : {
3430 0 : eName = XML_URL;
3431 : }
3432 0 : else if (sName.equalsAsciiL("Custom1", sizeof("Custom1")-1))
3433 : {
3434 0 : eName = XML_CUSTOM1;
3435 : }
3436 0 : else if (sName.equalsAsciiL("Custom2", sizeof("Custom2")-1))
3437 : {
3438 0 : eName = XML_CUSTOM2;
3439 : }
3440 0 : else if (sName.equalsAsciiL("Custom3", sizeof("Custom3")-1))
3441 : {
3442 0 : eName = XML_CUSTOM3;
3443 : }
3444 0 : else if (sName.equalsAsciiL("Custom4", sizeof("Custom4")-1))
3445 : {
3446 0 : eName = XML_CUSTOM4;
3447 : }
3448 0 : else if (sName.equalsAsciiL("Custom5", sizeof("Custom5")-1))
3449 : {
3450 0 : eName = XML_CUSTOM5;
3451 : }
3452 0 : else if (sName.equalsAsciiL("ISBN", sizeof("ISBN")-1))
3453 : {
3454 0 : eName = XML_ISBN;
3455 : }
3456 : else
3457 : {
3458 : OSL_FAIL("Unknown bibliography info data");
3459 0 : eName = XML_TOKEN_INVALID;
3460 : }
3461 :
3462 0 : return eName;
3463 : }
3464 :
3465 0 : enum XMLTokenEnum XMLTextFieldExport::MapMeasureKind(sal_Int16 nKind)
3466 : {
3467 0 : switch( nKind )
3468 : {
3469 : case 0:
3470 0 : return XML_VALUE;
3471 : case 1:
3472 0 : return XML_UNIT;
3473 : }
3474 0 : return XML_GAP;
3475 : }
3476 :
3477 0 : OUString XMLTextFieldExport::MakeFootnoteRefName(
3478 : sal_Int16 nSeqNo)
3479 : {
3480 : // generate foot-/endnote ID
3481 0 : OUStringBuffer aBuf;
3482 0 : aBuf.appendAscii("ftn");
3483 0 : aBuf.append((sal_Int32)nSeqNo);
3484 0 : return aBuf.makeStringAndClear();
3485 : }
3486 :
3487 0 : OUString XMLTextFieldExport::MakeSequenceRefName(
3488 : sal_Int16 nSeqNo,
3489 : const OUString& rSeqName)
3490 : {
3491 : // generate foot-/endnote ID
3492 0 : OUStringBuffer aBuf;
3493 0 : aBuf.appendAscii("ref");
3494 0 : aBuf.append(rSeqName);
3495 0 : aBuf.append((sal_Int32)nSeqNo);
3496 0 : return aBuf.makeStringAndClear();
3497 : }
3498 :
3499 : //
3500 : // Property accessor helper functions
3501 : //
3502 :
3503 : // to be relegated (does that word exist?) to a more appropriate place
3504 : //
3505 :
3506 :
3507 56 : inline sal_Bool GetBoolProperty(
3508 : const OUString& sPropName,
3509 : const Reference<XPropertySet> & xPropSet)
3510 : {
3511 56 : Any aAny = xPropSet->getPropertyValue(sPropName);
3512 56 : sal_Bool bBool = *(sal_Bool *)aAny.getValue();
3513 56 : return bBool;
3514 : }
3515 :
3516 30 : inline sal_Bool GetOptionalBoolProperty(
3517 : const OUString& sPropName,
3518 : const Reference<XPropertySet> & xPropSet,
3519 : const Reference<XPropertySetInfo> & xPropSetInfo,
3520 : sal_Bool bDefault)
3521 : {
3522 30 : return xPropSetInfo->hasPropertyByName( sPropName )
3523 30 : ? GetBoolProperty( sPropName, xPropSet ) : bDefault;
3524 : }
3525 :
3526 2 : inline double GetDoubleProperty(
3527 : const OUString& sPropName,
3528 : const Reference<XPropertySet> & xPropSet)
3529 : {
3530 2 : Any aAny = xPropSet->getPropertyValue(sPropName);
3531 2 : double fDouble = 0.0;
3532 2 : aAny >>= fDouble;
3533 2 : return fDouble;
3534 : }
3535 :
3536 10 : inline OUString const GetStringProperty(
3537 : const OUString& sPropName,
3538 : const Reference<XPropertySet> & xPropSet)
3539 : {
3540 10 : Any aAny = xPropSet->getPropertyValue(sPropName);
3541 10 : OUString sString;
3542 10 : aAny >>= sString;
3543 10 : return sString;
3544 : }
3545 :
3546 192 : inline sal_Int32 GetIntProperty(
3547 : const OUString& sPropName,
3548 : const Reference<XPropertySet> & xPropSet)
3549 : {
3550 192 : Any aAny = xPropSet->getPropertyValue(sPropName);
3551 192 : sal_Int32 nInt = 0;
3552 192 : aAny >>= nInt;
3553 192 : return nInt;
3554 : }
3555 :
3556 0 : inline sal_Int16 GetInt16Property(
3557 : const OUString& sPropName,
3558 : const Reference<XPropertySet> & xPropSet)
3559 : {
3560 0 : Any aAny = xPropSet->getPropertyValue(sPropName);
3561 0 : sal_Int16 nInt = 0;
3562 0 : aAny >>= nInt;
3563 0 : return nInt;
3564 : }
3565 :
3566 0 : inline sal_Int8 GetInt8Property(
3567 : const OUString& sPropName,
3568 : const Reference<XPropertySet> & xPropSet)
3569 : {
3570 0 : Any aAny = xPropSet->getPropertyValue(sPropName);
3571 0 : sal_Int8 nInt = 0;
3572 0 : aAny >>= nInt;
3573 0 : return nInt;
3574 : }
3575 :
3576 14 : inline util::DateTime const GetDateTimeProperty(
3577 : const OUString& sPropName,
3578 : const Reference<XPropertySet> & xPropSet)
3579 : {
3580 14 : Any aAny = xPropSet->getPropertyValue(sPropName);
3581 14 : util::DateTime aTime;
3582 14 : aAny >>= aTime;
3583 14 : return aTime;
3584 : }
3585 :
3586 0 : inline Sequence<OUString> const GetStringSequenceProperty(
3587 : const OUString& sPropName,
3588 : const Reference<XPropertySet> & xPropSet)
3589 : {
3590 0 : Any aAny = xPropSet->getPropertyValue(sPropName);
3591 0 : Sequence<OUString> aSequence;
3592 0 : aAny >>= aSequence;
3593 0 : return aSequence;
3594 : }
3595 :
3596 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|