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