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