1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: txtfldi.cxx,v $
10 * $Revision: 1.71.66.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
36 * Import of all text fields except those from txtvfldi.cxx
37 * (variable related text fields and database display fields)
39 #include "txtfldi.hxx"
40 #include "txtvfldi.hxx"
41 #include <xmloff/xmlimp.hxx>
42 #include <xmloff/xmlnumi.hxx>
43 #include <xmloff/txtimp.hxx>
44 #include "xmlnmspe.hxx"
45 #include <xmloff/nmspmap.hxx>
46 #include <xmloff/xmltoken.hxx>
47 #include <xmloff/xmluconv.hxx>
48 #include <xmloff/xmlement.hxx>
49 #include "XMLStringBufferImportContext.hxx"
50 #include <xmloff/XMLEventsImportContext.hxx>
51 #include <com/sun/star/xml/sax/XAttributeList.hpp>
52 #include <com/sun/star/text/UserDataPart.hpp>
53 #include <com/sun/star/style/NumberingType.hpp>
54 #include <com/sun/star/text/PlaceholderType.hpp>
55 #include <com/sun/star/text/ReferenceFieldPart.hpp>
56 #include <com/sun/star/text/ReferenceFieldSource.hpp>
57 #include <com/sun/star/text/XTextField.hpp>
58 #include <com/sun/star/text/XTextContent.hpp>
59 #include <com/sun/star/beans/XPropertySet.hpp>
60 #include <com/sun/star/beans/XPropertySetInfo.hpp>
61 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
62 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
63 #include <com/sun/star/text/XDependentTextField.hpp>
64 #include <com/sun/star/text/SetVariableType.hpp>
65 #include <com/sun/star/text/FilenameDisplayFormat.hpp>
66 #include <com/sun/star/text/ChapterFormat.hpp>
67 #include <com/sun/star/text/TemplateDisplayFormat.hpp>
68 #include <com/sun/star/beans/PropertyValue.hpp>
69 #include <com/sun/star/text/BibliographyDataType.hpp>
70 #include <com/sun/star/text/BibliographyDataField.hpp>
71 #include <com/sun/star/util/XUpdatable.hpp>
72 #include <com/sun/star/sdb/CommandType.hpp>
74 #include <rtl/ustring.hxx>
75 #include <rtl/ustrbuf.hxx>
76 #include <rtl/math.hxx>
77 #include <tools/debug.hxx>
80 using ::rtl::OUString
;
81 using ::rtl::OUStringBuffer
;
83 using namespace ::com::sun::star
;
84 using namespace ::com::sun::star::uno
;
85 using namespace ::com::sun::star::text
;
86 using namespace ::com::sun::star::lang
;
87 using namespace ::com::sun::star::beans
;
88 using namespace ::com::sun::star::document
;
89 using namespace ::com::sun::star::util
;
90 using namespace ::com::sun::star::xml::sax
;
91 using namespace ::xmloff::token
;
95 // SO API string constants
98 // service prefix and service anems
99 const sal_Char sAPI_textfield_prefix
[] = "com.sun.star.text.TextField.";
100 const sal_Char sAPI_fieldmaster_prefix
[] = "com.sun.star.text.FieldMaster.";
101 const sal_Char sAPI_presentation_prefix
[] = "com.sun.star.presentation.TextField.";
103 const sal_Char sAPI_extended_user
[] = "ExtendedUser";
104 const sal_Char sAPI_user_data_type
[] = "UserDataType";
105 const sal_Char sAPI_jump_edit
[] = "JumpEdit";
106 const sal_Char sAPI_get_expression
[] = "GetExpression";
107 const sal_Char sAPI_set_expression
[] = "SetExpression";
108 const sal_Char sAPI_user
[] = "User";
109 const sal_Char sAPI_date_time
[] = "DateTime";
110 const sal_Char sAPI_page_number
[] = "PageNumber";
111 const sal_Char sAPI_database_next
[] = "DatabaseNextSet";
112 const sal_Char sAPI_database_select
[] = "DatabaseNumberOfSet";
113 const sal_Char sAPI_database_number
[] = "DatabaseSetNumber";
114 const sal_Char sAPI_database
[] = "Database";
115 const sal_Char sAPI_database_name
[] = "DatabaseName";
116 const sal_Char sAPI_docinfo_change_author
[] = "DocInfo.ChangeAuthor";
117 const sal_Char sAPI_docinfo_change_date_time
[] = "DocInfo.ChangeDateTime";
118 const sal_Char sAPI_docinfo_edit_time
[] = "DocInfo.EditTime";
119 const sal_Char sAPI_docinfo_description
[] = "DocInfo.Description";
120 const sal_Char sAPI_docinfo_create_author
[] = "DocInfo.CreateAuthor";
121 const sal_Char sAPI_docinfo_create_date_time
[] = "DocInfo.CreateDateTime";
122 const sal_Char sAPI_docinfo_custom
[] = "DocInfo.Custom";
123 const sal_Char sAPI_docinfo_print_author
[] = "DocInfo.PrintAuthor";
124 const sal_Char sAPI_docinfo_print_date_time
[] = "DocInfo.PrintDateTime";
125 const sal_Char sAPI_docinfo_keywords
[] = "DocInfo.KeyWords";
126 const sal_Char sAPI_docinfo_subject
[] = "DocInfo.Subject";
127 const sal_Char sAPI_docinfo_title
[] = "DocInfo.Title";
128 const sal_Char sAPI_docinfo_revision
[] = "DocInfo.Revision";
129 const sal_Char sAPI_hidden_paragraph
[] = "HiddenParagraph";
130 const sal_Char sAPI_hidden_text
[] = "HiddenText";
131 const sal_Char sAPI_conditional_text
[] = "ConditionalText";
132 const sal_Char sAPI_file_name
[] = "FileName";
133 const sal_Char sAPI_chapter
[] = "Chapter";
134 const sal_Char sAPI_template_name
[] = "TemplateName";
135 const sal_Char sAPI_page_count
[] = "PageCount";
136 const sal_Char sAPI_paragraph_count
[] = "ParagraphCount";
137 const sal_Char sAPI_word_count
[] = "WordCount";
138 const sal_Char sAPI_character_count
[] = "CharacterCount";
139 const sal_Char sAPI_table_count
[] = "TableCount";
140 const sal_Char sAPI_graphic_object_count
[] = "GraphicObjectCount";
141 const sal_Char sAPI_embedded_object_count
[] = "EmbeddedObjectCount";
142 const sal_Char sAPI_reference_page_set
[] = "ReferencePageSet";
143 const sal_Char sAPI_reference_page_get
[] = "ReferencePageGet";
144 const sal_Char sAPI_macro
[] = "Macro";
145 const sal_Char sAPI_dde
[] = "DDE";
146 const sal_Char sAPI_get_reference
[] = "GetReference";
147 const sal_Char sAPI_sheet_name
[] = "SheetName";
148 const sal_Char sAPI_url
[] = "URL";
149 const sal_Char sAPI_bibliography
[] = "Bibliography";
150 const sal_Char sAPI_annotation
[] = "Annotation";
151 const sal_Char sAPI_script
[] = "Script";
152 const sal_Char sAPI_measure
[] = "Measure";
153 const sal_Char sAPI_drop_down
[] = "DropDown";
154 const sal_Char sAPI_header
[] = "Header";
155 const sal_Char sAPI_footer
[] = "Footer";
156 const sal_Char sAPI_datetime
[] = "DateTime";
159 const sal_Char sAPI_is_fixed
[] = "IsFixed";
160 const sal_Char sAPI_content
[] = "Content";
161 const sal_Char sAPI_value
[] = "Value";
162 const sal_Char sAPI_author
[] = "Author";
163 const sal_Char sAPI_full_name
[] = "FullName";
164 const sal_Char sAPI_place_holder_type
[] = "PlaceHolderType";
165 const sal_Char sAPI_place_holder
[] = "PlaceHolder";
166 const sal_Char sAPI_hint
[] = "Hint";
167 const sal_Char sAPI_variable_name
[] = "VariableName";
168 const sal_Char sAPI_name
[] = "Name";
169 const sal_Char sAPI_sub_type
[] = "SubType";
170 const sal_Char sAPI_numbering_separator
[] = "NumberingSeparator";
171 const sal_Char sAPI_chapter_numbering_level
[] = "ChapterNumberingLevel";
172 const sal_Char sAPI_variable_subtype
[] = "VariableSubtype";
173 const sal_Char sAPI_formula
[] = "Formula";
174 const sal_Char sAPI_date_time_value
[] = "DateTimeValue";
175 const sal_Char sAPI_number_format
[] = "NumberFormat";
176 const sal_Char sAPI_user_text
[] = "UserText";
177 const sal_Char sAPI_numbering_type
[] = "NumberingType";
178 const sal_Char sAPI_offset
[] = "Offset";
179 const sal_Char sAPI_data_base_name
[] = "DataBaseName";
180 const sal_Char sAPI_data_base_u_r_l
[] = "DataBaseURL";
181 const sal_Char sAPI_data_table_name
[] = "DataTableName";
182 const sal_Char sAPI_condition
[] = "Condition";
183 const sal_Char sAPI_set_number
[] = "SetNumber";
184 const sal_Char sAPI_is_data_base_format
[] = "DataBaseFormat";
185 const sal_Char sAPI_true_content
[] = "TrueContent";
186 const sal_Char sAPI_false_content
[] = "FalseContent";
187 const sal_Char sAPI_revision
[] = "Revision";
188 const sal_Char sAPI_file_format
[] = "FileFormat";
189 const sal_Char sAPI_chapter_format
[] = "ChapterFormat";
190 const sal_Char sAPI_level
[] = "Level";
191 const sal_Char sAPI_is_date
[] = "IsDate";
192 const sal_Char sAPI_adjust
[] = "Adjust";
193 const sal_Char sAPI_on
[] = "On";
194 const sal_Char sAPI_is_automatic_update
[] = "IsAutomaticUpdate";
195 const sal_Char sAPI_source_name
[] = "SourceName";
196 const sal_Char sAPI_current_presentation
[] = "CurrentPresentation";
197 const sal_Char sAPI_reference_field_part
[] = "ReferenceFieldPart";
198 const sal_Char sAPI_reference_field_source
[] = "ReferenceFieldSource";
199 const sal_Char sAPI_dde_command_type
[] = "DDECommandType";
200 const sal_Char sAPI_dde_command_file
[] = "DDECommandFile";
201 const sal_Char sAPI_dde_command_element
[] = "DDECommandElement";
202 // sAPI_url: also used as service name
203 const sal_Char sAPI_target_frame
[] = "TargetFrame";
204 const sal_Char sAPI_representation
[] = "Representation";
205 const sal_Char sAPI_date
[] = "Date";
206 const sal_Char sAPI_url_content
[] = "URLContent";
207 const sal_Char sAPI_script_type
[] = "ScriptType";
208 const sal_Char sAPI_is_hidden
[] = "IsHidden";
209 const sal_Char sAPI_is_condition_true
[] = "IsConditionTrue";
210 const sal_Char sAPI_data_command_type
[] = "DataCommandType";
211 const sal_Char sAPI_is_fixed_language
[] = "IsFixedLanguage";
212 const sal_Char sAPI_is_visible
[] = "IsVisible";
213 const sal_Char sAPI_TextRange
[] = "TextRange";
215 const sal_Char sAPI_true
[] = "TRUE";
218 static __FAR_DATA SvXMLTokenMapEntry aTextFieldAttrTokenMap
[] =
220 { XML_NAMESPACE_TEXT
, XML_FIXED
, XML_TOK_TEXTFIELD_FIXED
},
221 { XML_NAMESPACE_TEXT
, XML_DESCRIPTION
, XML_TOK_TEXTFIELD_DESCRIPTION
},
222 { XML_NAMESPACE_TEXT
, XML_HELP
, XML_TOK_TEXTFIELD_HELP
},
223 { XML_NAMESPACE_TEXT
, XML_HINT
, XML_TOK_TEXTFIELD_HINT
},
224 { XML_NAMESPACE_TEXT
, XML_PLACEHOLDER_TYPE
,
225 XML_TOK_TEXTFIELD_PLACEHOLDER_TYPE
},
226 { XML_NAMESPACE_TEXT
, XML_NAME
, XML_TOK_TEXTFIELD_NAME
},
227 { XML_NAMESPACE_TEXT
, XML_FORMULA
, XML_TOK_TEXTFIELD_FORMULA
},
228 { XML_NAMESPACE_STYLE
, XML_NUM_FORMAT
, XML_TOK_TEXTFIELD_NUM_FORMAT
},
229 { XML_NAMESPACE_STYLE
, XML_NUM_LETTER_SYNC
,
230 XML_TOK_TEXTFIELD_NUM_LETTER_SYNC
},
231 { XML_NAMESPACE_TEXT
, XML_DISPLAY_FORMULA
,
232 XML_TOK_TEXTFIELD_DISPLAY_FORMULA
},
233 { XML_NAMESPACE_TEXT
, XML_VALUE_TYPE
, XML_TOK_TEXTFIELD_VALUE_TYPE
}, // #i32362#: src680m48++ saves text:value-type
234 { XML_NAMESPACE_OFFICE
, XML_VALUE_TYPE
, XML_TOK_TEXTFIELD_VALUE_TYPE
},
235 { XML_NAMESPACE_TEXT
, XML_VALUE
, XML_TOK_TEXTFIELD_VALUE
},
236 { XML_NAMESPACE_OFFICE
, XML_VALUE
, XML_TOK_TEXTFIELD_VALUE
},
237 { XML_NAMESPACE_TEXT
, XML_STRING_VALUE
, XML_TOK_TEXTFIELD_STRING_VALUE
},
238 { XML_NAMESPACE_OFFICE
, XML_STRING_VALUE
, XML_TOK_TEXTFIELD_STRING_VALUE
},
239 { XML_NAMESPACE_TEXT
, XML_DATE_VALUE
, XML_TOK_TEXTFIELD_DATE_VALUE
},
240 { XML_NAMESPACE_OFFICE
, XML_DATE_VALUE
, XML_TOK_TEXTFIELD_DATE_VALUE
},
241 { XML_NAMESPACE_TEXT
, XML_TIME_VALUE
, XML_TOK_TEXTFIELD_TIME_VALUE
},
242 { XML_NAMESPACE_OFFICE
, XML_TIME_VALUE
, XML_TOK_TEXTFIELD_TIME_VALUE
},
243 { XML_NAMESPACE_OFFICE
, XML_BOOLEAN_VALUE
, XML_TOK_TEXTFIELD_BOOL_VALUE
},
244 { XML_NAMESPACE_OFFICE
, XML_CURRENCY
, XML_TOK_TEXTFIELD_CURRENCY
},
245 { XML_NAMESPACE_STYLE
, XML_DATA_STYLE_NAME
,
246 XML_TOK_TEXTFIELD_DATA_STYLE_NAME
},
247 { XML_NAMESPACE_TEXT
, XML_DISPLAY_OUTLINE_LEVEL
,
248 XML_TOK_TEXTFIELD_NUMBERING_LEVEL
},
249 { XML_NAMESPACE_TEXT
, XML_SEPARATION_CHARACTER
,
250 XML_TOK_TEXTFIELD_NUMBERING_SEPARATOR
},
251 { XML_NAMESPACE_TEXT
, XML_DISPLAY
, XML_TOK_TEXTFIELD_DISPLAY
},
252 { XML_NAMESPACE_TEXT
, XML_TIME_ADJUST
, XML_TOK_TEXTFIELD_TIME_ADJUST
},
253 { XML_NAMESPACE_TEXT
, XML_DATE_ADJUST
, XML_TOK_TEXTFIELD_DATE_ADJUST
},
254 { XML_NAMESPACE_TEXT
, XML_PAGE_ADJUST
, XML_TOK_TEXTFIELD_PAGE_ADJUST
},
255 { XML_NAMESPACE_TEXT
, XML_SELECT_PAGE
, XML_TOK_TEXTFIELD_SELECT_PAGE
},
256 { XML_NAMESPACE_TEXT
, XML_DATABASE_NAME
, XML_TOK_TEXTFIELD_DATABASE_NAME
},
257 { XML_NAMESPACE_TEXT
, XML_TABLE_NAME
, XML_TOK_TEXTFIELD_TABLE_NAME
},
258 { XML_NAMESPACE_TEXT
, XML_COLUMN_NAME
, XML_TOK_TEXTFIELD_COLUMN_NAME
},
259 { XML_NAMESPACE_TEXT
, XML_ROW_NUMBER
, XML_TOK_TEXTFIELD_ROW_NUMBER
},
260 { XML_NAMESPACE_TEXT
, XML_CONDITION
, XML_TOK_TEXTFIELD_CONDITION
},
261 { XML_NAMESPACE_TEXT
, XML_STRING_VALUE_IF_TRUE
,
262 XML_TOK_TEXTFIELD_STRING_VALUE_IF_TRUE
},
263 { XML_NAMESPACE_TEXT
, XML_STRING_VALUE_IF_FALSE
,
264 XML_TOK_TEXTFIELD_STRING_VALUE_IF_FALSE
},
265 { XML_NAMESPACE_TEXT
, XML_EDITING_CYCLES
, XML_TOK_TEXTFIELD_REVISION
},
266 { XML_NAMESPACE_TEXT
, XML_OUTLINE_LEVEL
, XML_TOK_TEXTFIELD_OUTLINE_LEVEL
},
267 { XML_NAMESPACE_TEXT
, XML_ACTIVE
, XML_TOK_TEXTFIELD_ACTIVE
},
268 { XML_NAMESPACE_TEXT
, XML_NOTE_CLASS
, XML_TOK_TEXTFIELD_NOTE_CLASS
},
269 { XML_NAMESPACE_TEXT
, XML_REFERENCE_FORMAT
,
270 XML_TOK_TEXTFIELD_REFERENCE_FORMAT
},
271 { XML_NAMESPACE_TEXT
, XML_REF_NAME
, XML_TOK_TEXTFIELD_REF_NAME
},
272 { XML_NAMESPACE_TEXT
, XML_CONNECTION_NAME
,
273 XML_TOK_TEXTFIELD_CONNECTION_NAME
},
274 { XML_NAMESPACE_XLINK
, XML_HREF
, XML_TOK_TEXTFIELD_HREF
},
275 { XML_NAMESPACE_OFFICE
, XML_TARGET_FRAME_NAME
,
276 XML_TOK_TEXTFIELD_TARGET_FRAME
},
277 { XML_NAMESPACE_TEXT
, XML_ANNOTATION
, XML_TOK_TEXTFIELD_ANNOTATION
},
278 { XML_NAMESPACE_SCRIPT
, XML_LANGUAGE
, XML_TOK_TEXTFIELD_LANGUAGE
},
279 { XML_NAMESPACE_TEXT
, XML_KIND
, XML_TOK_TEXTFIELD_MEASURE_KIND
},
280 { XML_NAMESPACE_TEXT
, XML_IS_HIDDEN
, XML_TOK_TEXTFIELD_IS_HIDDEN
},
281 { XML_NAMESPACE_TEXT
, XML_CURRENT_VALUE
,
282 XML_TOK_TEXTFIELD_CURRENT_VALUE
},
283 { XML_NAMESPACE_TEXT
, XML_TABLE_TYPE
, XML_TOK_TEXTFIELD_TABLE_TYPE
},
288 const SvXMLTokenMap
& XMLTextImportHelper::GetTextFieldAttrTokenMap()
290 if ( !pTextFieldAttrTokenMap
.get() ) {
291 pTextFieldAttrTokenMap
.reset(
292 new SvXMLTokenMap(aTextFieldAttrTokenMap
) );
295 return *pTextFieldAttrTokenMap
;
299 TYPEINIT1( XMLTextFieldImportContext
, SvXMLImportContext
);
301 XMLTextFieldImportContext::XMLTextFieldImportContext(
302 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
303 const sal_Char
* pService
,
304 sal_uInt16 nPrefix
, const OUString
& rElementName
)
305 : SvXMLImportContext( rImport
, nPrefix
, rElementName
)
306 , sIsFixed(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_fixed
))
307 , rTextImportHelper(rHlp
)
308 , sServicePrefix(RTL_CONSTASCII_USTRINGPARAM(sAPI_textfield_prefix
))
311 DBG_ASSERT(NULL
!= pService
, "Need service name!");
312 sServiceName
= OUString::createFromAscii(pService
);
315 void XMLTextFieldImportContext::StartElement(
316 const Reference
<XAttributeList
> & xAttrList
)
318 // process attributes
319 sal_Int16 nLength
= xAttrList
->getLength();
320 for(sal_Int16 i
=0; i
<nLength
; i
++) {
323 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().
324 GetKeyByAttrName( xAttrList
->getNameByIndex(i
), &sLocalName
);
326 ProcessAttribute(rTextImportHelper
.GetTextFieldAttrTokenMap().
327 Get(nPrefix
, sLocalName
),
328 xAttrList
->getValueByIndex(i
) );
332 XMLTextFieldImportContext::~XMLTextFieldImportContext() {
335 OUString
XMLTextFieldImportContext::GetContent()
337 if (sContent
.getLength()==0)
339 sContent
= sContentBuffer
.makeStringAndClear();
345 void XMLTextFieldImportContext::EndElement()
347 DBG_ASSERT(GetServiceName().getLength()>0, "no service name for element!");
351 // create field/Service
352 Reference
<XPropertySet
> xPropSet
;
353 if (CreateField(xPropSet
, sServicePrefix
+ GetServiceName()))
355 // set field properties
356 PrepareField(xPropSet
);
358 // attach field to document
359 Reference
<XTextContent
> xTextContent(xPropSet
, UNO_QUERY
);
361 // workaround for #80606#
364 rTextImportHelper
.InsertTextContent(xTextContent
);
366 catch (lang::IllegalArgumentException e
)
374 // in case of error: write element content
375 rTextImportHelper
.InsertString(GetContent());
378 void XMLTextFieldImportContext::Characters(const OUString
& rContent
)
380 sContentBuffer
.append(rContent
);
383 sal_Bool
XMLTextFieldImportContext::CreateField(
384 Reference
<XPropertySet
> & xField
,
385 const OUString
& rServiceName
)
387 // instantiate new XTextField:
388 // ask import for model, model is factory, ask factory to create service
390 Reference
<XMultiServiceFactory
> xFactory(GetImport().GetModel(),UNO_QUERY
);
393 Reference
<XInterface
> xIfc
= xFactory
->createInstance(rServiceName
);
396 Reference
<XPropertySet
> xTmp( xIfc
, UNO_QUERY
);
400 return sal_False
; // can't create instance
403 return sal_False
; // can't get MultiServiceFactory
409 /// create the appropriate field context from
410 XMLTextFieldImportContext
*
411 XMLTextFieldImportContext::CreateTextFieldImportContext(
412 SvXMLImport
& rImport
,
413 XMLTextImportHelper
& rHlp
,
415 const OUString
& rName
,
418 XMLTextFieldImportContext
* pContext
= NULL
;
422 case XML_TOK_TEXT_SENDER_FIRSTNAME
:
423 case XML_TOK_TEXT_SENDER_LASTNAME
:
424 case XML_TOK_TEXT_SENDER_INITIALS
:
425 case XML_TOK_TEXT_SENDER_TITLE
:
426 case XML_TOK_TEXT_SENDER_POSITION
:
427 case XML_TOK_TEXT_SENDER_EMAIL
:
428 case XML_TOK_TEXT_SENDER_PHONE_PRIVATE
:
429 case XML_TOK_TEXT_SENDER_FAX
:
430 case XML_TOK_TEXT_SENDER_COMPANY
:
431 case XML_TOK_TEXT_SENDER_PHONE_WORK
:
432 case XML_TOK_TEXT_SENDER_STREET
:
433 case XML_TOK_TEXT_SENDER_CITY
:
434 case XML_TOK_TEXT_SENDER_POSTAL_CODE
:
435 case XML_TOK_TEXT_SENDER_COUNTRY
:
436 case XML_TOK_TEXT_SENDER_STATE_OR_PROVINCE
:
438 new XMLSenderFieldImportContext( rImport
, rHlp
,
439 nPrefix
, rName
, nToken
);
442 case XML_TOK_TEXT_AUTHOR_NAME
:
443 case XML_TOK_TEXT_AUTHOR_INITIALS
:
445 new XMLAuthorFieldImportContext( rImport
, rHlp
,
446 nPrefix
, rName
, nToken
);
449 case XML_TOK_TEXT_PLACEHOLDER
:
451 new XMLPlaceholderFieldImportContext( rImport
, rHlp
,
454 case XML_TOK_TEXT_SEQUENCE
:
456 new XMLSequenceFieldImportContext( rImport
, rHlp
,
459 case XML_TOK_TEXT_TEXT_INPUT
:
461 new XMLTextInputFieldImportContext( rImport
, rHlp
,
464 case XML_TOK_TEXT_EXPRESSION
:
466 new XMLExpressionFieldImportContext( rImport
, rHlp
,
469 case XML_TOK_TEXT_VARIABLE_SET
:
471 new XMLVariableSetFieldImportContext( rImport
, rHlp
,
474 case XML_TOK_TEXT_VARIABLE_INPUT
:
476 new XMLVariableInputFieldImportContext( rImport
, rHlp
,
479 case XML_TOK_TEXT_VARIABLE_GET
:
481 new XMLVariableGetFieldImportContext( rImport
, rHlp
,
484 case XML_TOK_TEXT_USER_FIELD_GET
:
485 pContext
= new XMLUserFieldImportContext( rImport
, rHlp
,
488 case XML_TOK_TEXT_USER_FIELD_INPUT
:
489 pContext
= new XMLUserFieldInputImportContext( rImport
, rHlp
,
492 case XML_TOK_TEXT_TIME
:
493 pContext
= new XMLTimeFieldImportContext( rImport
, rHlp
,
496 case XML_TOK_TEXT_PAGE_CONTINUATION_STRING
:
497 case XML_TOK_TEXT_PAGE_CONTINUATION
:
498 pContext
= new XMLPageContinuationImportContext( rImport
, rHlp
,
502 case XML_TOK_TEXT_PAGE_NUMBER
:
503 pContext
= new XMLPageNumberImportContext( rImport
, rHlp
,
507 case XML_TOK_TEXT_DATE
:
508 pContext
= new XMLDateFieldImportContext( rImport
, rHlp
,
512 case XML_TOK_TEXT_DATABASE_NAME
:
513 pContext
= new XMLDatabaseNameImportContext( rImport
, rHlp
,
516 case XML_TOK_TEXT_DATABASE_NEXT
:
517 pContext
= new XMLDatabaseNextImportContext( rImport
, rHlp
,
520 case XML_TOK_TEXT_DATABASE_SELECT
:
521 pContext
= new XMLDatabaseSelectImportContext( rImport
, rHlp
,
524 case XML_TOK_TEXT_DATABASE_ROW_NUMBER
:
525 pContext
= new XMLDatabaseNumberImportContext( rImport
, rHlp
,
528 case XML_TOK_TEXT_DATABASE_DISPLAY
:
529 pContext
= new XMLDatabaseDisplayImportContext( rImport
, rHlp
,
532 case XML_TOK_TEXT_CONDITIONAL_TEXT
:
533 pContext
= new XMLConditionalTextImportContext( rImport
, rHlp
,
536 case XML_TOK_TEXT_HIDDEN_TEXT
:
537 pContext
= new XMLHiddenTextImportContext( rImport
, rHlp
,
540 case XML_TOK_TEXT_HIDDEN_PARAGRAPH
:
541 pContext
= new XMLHiddenParagraphImportContext( rImport
, rHlp
,
544 case XML_TOK_TEXT_DOCUMENT_DESCRIPTION
:
545 case XML_TOK_TEXT_DOCUMENT_TITLE
:
546 case XML_TOK_TEXT_DOCUMENT_SUBJECT
:
547 case XML_TOK_TEXT_DOCUMENT_KEYWORDS
:
548 pContext
= new XMLSimpleDocInfoImportContext( rImport
, rHlp
,
553 case XML_TOK_TEXT_DOCUMENT_CREATION_AUTHOR
:
554 case XML_TOK_TEXT_DOCUMENT_PRINT_AUTHOR
:
555 case XML_TOK_TEXT_DOCUMENT_SAVE_AUTHOR
:
556 pContext
= new XMLSimpleDocInfoImportContext( rImport
, rHlp
,
562 case XML_TOK_TEXT_DOCUMENT_CREATION_DATE
:
563 case XML_TOK_TEXT_DOCUMENT_CREATION_TIME
:
564 case XML_TOK_TEXT_DOCUMENT_PRINT_DATE
:
565 case XML_TOK_TEXT_DOCUMENT_PRINT_TIME
:
566 case XML_TOK_TEXT_DOCUMENT_SAVE_DATE
:
567 case XML_TOK_TEXT_DOCUMENT_SAVE_TIME
:
568 case XML_TOK_TEXT_DOCUMENT_EDIT_DURATION
:
569 pContext
= new XMLDateTimeDocInfoImportContext( rImport
, rHlp
,
574 case XML_TOK_TEXT_DOCUMENT_REVISION
:
575 pContext
= new XMLRevisionDocInfoImportContext( rImport
, rHlp
,
580 case XML_TOK_TEXT_DOCUMENT_USER_DEFINED
:
581 pContext
= new XMLUserDocInfoImportContext( rImport
, rHlp
,
586 case XML_TOK_TEXT_FILENAME
:
587 pContext
= new XMLFileNameImportContext( rImport
, rHlp
,
591 case XML_TOK_TEXT_CHAPTER
:
592 pContext
= new XMLChapterImportContext( rImport
, rHlp
,
596 case XML_TOK_TEXT_TEMPLATENAME
:
597 pContext
= new XMLTemplateNameImportContext( rImport
, rHlp
,
601 case XML_TOK_TEXT_WORD_COUNT
:
602 case XML_TOK_TEXT_PARAGRAPH_COUNT
:
603 case XML_TOK_TEXT_TABLE_COUNT
:
604 case XML_TOK_TEXT_CHARACTER_COUNT
:
605 case XML_TOK_TEXT_IMAGE_COUNT
:
606 case XML_TOK_TEXT_OBJECT_COUNT
:
607 case XML_TOK_TEXT_PAGE_COUNT
:
608 pContext
= new XMLCountFieldImportContext( rImport
, rHlp
,
609 nPrefix
, rName
, nToken
);
612 case XML_TOK_TEXT_GET_PAGE_VAR
:
613 pContext
= new XMLPageVarGetFieldImportContext( rImport
, rHlp
,
617 case XML_TOK_TEXT_SET_PAGE_VAR
:
618 pContext
= new XMLPageVarSetFieldImportContext( rImport
, rHlp
,
622 case XML_TOK_TEXT_MACRO
:
623 pContext
= new XMLMacroFieldImportContext( rImport
, rHlp
,
627 case XML_TOK_TEXT_DDE
:
628 pContext
= new XMLDdeFieldImportContext( rImport
, rHlp
,
632 case XML_TOK_TEXT_REFERENCE_REF
:
633 case XML_TOK_TEXT_BOOKMARK_REF
:
634 case XML_TOK_TEXT_NOTE_REF
:
635 case XML_TOK_TEXT_SEQUENCE_REF
:
636 pContext
= new XMLReferenceFieldImportContext( rImport
, rHlp
,
641 case XML_TOK_TEXT_SHEET_NAME
:
642 pContext
= new XMLSheetNameImportContext( rImport
, rHlp
,
646 case XML_TOK_TEXT_BIBLIOGRAPHY_MARK
:
647 pContext
= new XMLBibliographyFieldImportContext( rImport
, rHlp
,
651 case XML_TOK_TEXT_ANNOTATION
:
652 pContext
= new XMLAnnotationImportContext( rImport
, rHlp
,
656 case XML_TOK_TEXT_SCRIPT
:
657 pContext
= new XMLScriptImportContext( rImport
, rHlp
,
661 case XML_TOK_TEXT_MEASURE
:
662 pContext
= new XMLMeasureFieldImportContext( rImport
, rHlp
,
666 case XML_TOK_TEXT_TABLE_FORMULA
:
667 pContext
= new XMLTableFormulaImportContext( rImport
, rHlp
,
670 case XML_TOK_TEXT_DROPDOWN
:
671 pContext
= new XMLDropDownFieldImportContext( rImport
, rHlp
,
674 case XML_TOK_DRAW_HEADER
:
675 pContext
= new XMLHeaderFieldImportContext( rImport
, rHlp
,
678 case XML_TOK_DRAW_FOOTER
:
679 pContext
= new XMLFooterFieldImportContext( rImport
, rHlp
,
682 case XML_TOK_DRAW_DATE_TIME
:
683 pContext
= new XMLDateTimeFieldImportContext( rImport
, rHlp
,
688 // ignore! May not even be a textfield.
689 // (Reminder: This method is called inside default:-branch)
698 void XMLTextFieldImportContext::ForceUpdate(
699 const Reference
<XPropertySet
> & rPropertySet
)
702 Reference
<XUpdatable
> xUpdate(rPropertySet
, UNO_QUERY
);
709 DBG_ERROR("Expected XUpdatable support!");
716 // XMLSenderFieldImportContext
719 TYPEINIT1( XMLSenderFieldImportContext
, XMLTextFieldImportContext
);
721 XMLSenderFieldImportContext::XMLSenderFieldImportContext(
722 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
723 sal_uInt16 nPrfx
, const OUString
& sLocalName
,
725 : XMLTextFieldImportContext(rImport
, rHlp
, sAPI_extended_user
,nPrfx
, sLocalName
)
726 , sPropertyFixed(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_fixed
))
727 , sPropertyFieldSubType(RTL_CONSTASCII_USTRINGPARAM(sAPI_user_data_type
))
728 , sPropertyContent(RTL_CONSTASCII_USTRINGPARAM(sAPI_content
))
730 , nElementToken(nToken
)
734 void XMLSenderFieldImportContext::StartElement(
735 const Reference
<XAttributeList
> & xAttrList
)
738 switch (nElementToken
) {
739 case XML_TOK_TEXT_SENDER_FIRSTNAME
:
740 nSubType
= UserDataPart::FIRSTNAME
;
742 case XML_TOK_TEXT_SENDER_LASTNAME
:
743 nSubType
= UserDataPart::NAME
;
745 case XML_TOK_TEXT_SENDER_INITIALS
:
746 nSubType
= UserDataPart::SHORTCUT
;
748 case XML_TOK_TEXT_SENDER_TITLE
:
749 nSubType
= UserDataPart::TITLE
;
751 case XML_TOK_TEXT_SENDER_POSITION
:
752 nSubType
= UserDataPart::POSITION
;
754 case XML_TOK_TEXT_SENDER_EMAIL
:
755 nSubType
= UserDataPart::EMAIL
;
757 case XML_TOK_TEXT_SENDER_PHONE_PRIVATE
:
758 nSubType
= UserDataPart::PHONE_PRIVATE
;
760 case XML_TOK_TEXT_SENDER_FAX
:
761 nSubType
= UserDataPart::FAX
;
763 case XML_TOK_TEXT_SENDER_COMPANY
:
764 nSubType
= UserDataPart::COMPANY
;
766 case XML_TOK_TEXT_SENDER_PHONE_WORK
:
767 nSubType
= UserDataPart::PHONE_COMPANY
;
769 case XML_TOK_TEXT_SENDER_STREET
:
770 nSubType
= UserDataPart::STREET
;
772 case XML_TOK_TEXT_SENDER_CITY
:
773 nSubType
= UserDataPart::CITY
;
775 case XML_TOK_TEXT_SENDER_POSTAL_CODE
:
776 nSubType
= UserDataPart::ZIP
;
778 case XML_TOK_TEXT_SENDER_COUNTRY
:
779 nSubType
= UserDataPart::COUNTRY
;
781 case XML_TOK_TEXT_SENDER_STATE_OR_PROVINCE
:
782 nSubType
= UserDataPart::STATE
;
789 // process Attributes
790 XMLTextFieldImportContext::StartElement(xAttrList
);
793 void XMLSenderFieldImportContext::ProcessAttribute(
794 sal_uInt16 nAttrToken
,
795 const OUString
& sAttrValue
)
797 if (XML_TOK_TEXTFIELD_FIXED
== nAttrToken
) {
801 sal_Bool bRet
= GetImport().GetMM100UnitConverter().
802 convertBool(bVal
, sAttrValue
);
804 // set bFixed if successfull
811 void XMLSenderFieldImportContext::PrepareField(
812 const Reference
<XPropertySet
> & rPropSet
)
817 rPropSet
->setPropertyValue(sPropertyFieldSubType
, aAny
);
820 aAny
.setValue( &bFixed
, ::getBooleanCppuType() );
821 rPropSet
->setPropertyValue(sPropertyFixed
, aAny
);
823 // set content if fixed
826 // in organizer or styles-only mode: force update
827 if (GetImport().GetTextImport()->IsOrganizerMode() ||
828 GetImport().GetTextImport()->IsStylesOnlyMode() )
830 ForceUpdate(rPropSet
);
834 aAny
<<= GetContent();
835 rPropSet
->setPropertyValue(sPropertyContent
, aAny
);
843 // XMLAuthorFieldImportContext
846 TYPEINIT1( XMLAuthorFieldImportContext
, XMLSenderFieldImportContext
);
848 XMLAuthorFieldImportContext::XMLAuthorFieldImportContext(
849 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
850 sal_uInt16 nPrfx
, const OUString
& sLocalName
,
852 : XMLSenderFieldImportContext(rImport
, rHlp
, nPrfx
, sLocalName
, nToken
)
853 , bAuthorFullName(sal_True
)
854 , sServiceAuthor(RTL_CONSTASCII_USTRINGPARAM(sAPI_author
))
855 , sPropertyAuthorFullName(RTL_CONSTASCII_USTRINGPARAM(sAPI_full_name
))
856 , sPropertyFixed(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_fixed
))
857 , sPropertyContent(RTL_CONSTASCII_USTRINGPARAM(sAPI_content
))
859 // overwrite service name from XMLSenderFieldImportContext
860 SetServiceName(sServiceAuthor
);
863 void XMLAuthorFieldImportContext::StartElement(
864 const Reference
<XAttributeList
> & xAttrList
) {
866 bAuthorFullName
= (XML_TOK_TEXT_AUTHOR_INITIALS
!= nElementToken
);
869 // process Attributes
870 XMLTextFieldImportContext::StartElement(xAttrList
);
873 void XMLAuthorFieldImportContext::PrepareField(
874 const Reference
<XPropertySet
> & rPropSet
)
878 aAny
.setValue( &bAuthorFullName
, ::getBooleanCppuType() );
879 rPropSet
->setPropertyValue(sPropertyAuthorFullName
, aAny
);
881 aAny
.setValue( &bFixed
, ::getBooleanCppuType() );
882 rPropSet
->setPropertyValue(sPropertyFixed
, aAny
);
884 // set content if fixed
887 // organizer or styles-only mode: force update
888 if (GetImport().GetTextImport()->IsOrganizerMode() ||
889 GetImport().GetTextImport()->IsStylesOnlyMode() )
891 ForceUpdate(rPropSet
);
895 aAny
<<= GetContent();
896 rPropSet
->setPropertyValue(sPropertyContent
, aAny
);
903 // page continuation string
906 TYPEINIT1( XMLPageContinuationImportContext
, XMLTextFieldImportContext
);
908 static SvXMLEnumMapEntry __READONLY_DATA lcl_aSelectPageAttrMap
[] =
910 { XML_PREVIOUS
, PageNumberType_PREV
},
911 { XML_CURRENT
, PageNumberType_CURRENT
},
912 { XML_NEXT
, PageNumberType_NEXT
},
913 { XML_TOKEN_INVALID
, 0 },
916 XMLPageContinuationImportContext::XMLPageContinuationImportContext(
917 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
, sal_uInt16 nPrfx
,
918 const OUString
& sLocalName
)
919 : XMLTextFieldImportContext(rImport
, rHlp
, sAPI_page_number
, nPrfx
, sLocalName
)
920 , sPropertySubType(RTL_CONSTASCII_USTRINGPARAM(sAPI_sub_type
))
921 , sPropertyUserText(RTL_CONSTASCII_USTRINGPARAM(sAPI_user_text
))
922 , sPropertyNumberingType(RTL_CONSTASCII_USTRINGPARAM(sAPI_numbering_type
))
923 , eSelectPage(PageNumberType_CURRENT
)
924 , sStringOK(sal_False
)
929 void XMLPageContinuationImportContext::ProcessAttribute(
930 sal_uInt16 nAttrToken
, const OUString
& sAttrValue
)
934 case XML_TOK_TEXTFIELD_SELECT_PAGE
:
937 if (SvXMLUnitConverter::convertEnum(nTmp
, sAttrValue
,
938 lcl_aSelectPageAttrMap
)
939 && (PageNumberType_CURRENT
!= nTmp
) )
941 eSelectPage
= (PageNumberType
)nTmp
;
945 case XML_TOK_TEXTFIELD_STRING_VALUE
:
946 sString
= sAttrValue
;
947 sStringOK
= sal_True
;
952 void XMLPageContinuationImportContext::PrepareField(
953 const Reference
<XPropertySet
> & xPropertySet
)
957 aAny
<<= eSelectPage
;
958 xPropertySet
->setPropertyValue(sPropertySubType
, aAny
);
960 aAny
<<= (sStringOK
? sString
: GetContent());
961 xPropertySet
->setPropertyValue(sPropertyUserText
, aAny
);
963 aAny
<<= style::NumberingType::CHAR_SPECIAL
;
964 xPropertySet
->setPropertyValue(sPropertyNumberingType
, aAny
);
973 TYPEINIT1( XMLPageNumberImportContext
, XMLTextFieldImportContext
);
975 XMLPageNumberImportContext::XMLPageNumberImportContext(
976 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
, sal_uInt16 nPrfx
,
977 const OUString
& sLocalName
)
978 : XMLTextFieldImportContext(rImport
, rHlp
, sAPI_page_number
, nPrfx
, sLocalName
)
979 , sPropertySubType(RTL_CONSTASCII_USTRINGPARAM(sAPI_sub_type
))
980 , sPropertyNumberingType(RTL_CONSTASCII_USTRINGPARAM(sAPI_numbering_type
))
981 , sPropertyOffset(RTL_CONSTASCII_USTRINGPARAM(sAPI_offset
))
982 , sNumberSync(GetXMLToken(XML_FALSE
))
984 , eSelectPage(PageNumberType_CURRENT
)
985 , sNumberFormatOK(sal_False
)
990 void XMLPageNumberImportContext::ProcessAttribute(
991 sal_uInt16 nAttrToken
,
992 const OUString
& sAttrValue
)
996 case XML_TOK_TEXTFIELD_NUM_FORMAT
:
997 sNumberFormat
= sAttrValue
;
998 sNumberFormatOK
= sal_True
;
1000 case XML_TOK_TEXTFIELD_NUM_LETTER_SYNC
:
1001 sNumberSync
= sAttrValue
;
1003 case XML_TOK_TEXTFIELD_SELECT_PAGE
:
1006 if (SvXMLUnitConverter::convertEnum(nTmp
, sAttrValue
,
1007 lcl_aSelectPageAttrMap
))
1009 eSelectPage
= (PageNumberType
)nTmp
;
1013 case XML_TOK_TEXTFIELD_PAGE_ADJUST
:
1016 if (SvXMLUnitConverter::convertNumber(nTmp
, sAttrValue
))
1018 nPageAdjust
= (sal_Int16
)nTmp
;
1025 void XMLPageNumberImportContext::PrepareField(
1026 const Reference
<XPropertySet
> & xPropertySet
)
1030 // all properties are optional
1031 Reference
<XPropertySetInfo
> xPropertySetInfo(
1032 xPropertySet
->getPropertySetInfo());
1034 if (xPropertySetInfo
->hasPropertyByName(sPropertyNumberingType
))
1037 if( sNumberFormatOK
)
1039 nNumType
= style::NumberingType::ARABIC
;
1040 GetImport().GetMM100UnitConverter().convertNumFormat( nNumType
,
1045 nNumType
= style::NumberingType::PAGE_DESCRIPTOR
;
1048 xPropertySet
->setPropertyValue(sPropertyNumberingType
, aAny
);
1051 if (xPropertySetInfo
->hasPropertyByName(sPropertyOffset
))
1054 switch (eSelectPage
)
1056 case PageNumberType_PREV
:
1059 case PageNumberType_CURRENT
:
1061 case PageNumberType_NEXT
:
1065 DBG_WARNING("unknown page number type");
1067 aAny
<<= nPageAdjust
;
1068 xPropertySet
->setPropertyValue(sPropertyOffset
, aAny
);
1071 if (xPropertySetInfo
->hasPropertyByName(sPropertySubType
))
1073 aAny
<<= eSelectPage
;
1074 xPropertySet
->setPropertyValue(sPropertySubType
, aAny
);
1084 TYPEINIT1( XMLPlaceholderFieldImportContext
, XMLTextFieldImportContext
);
1086 XMLPlaceholderFieldImportContext::XMLPlaceholderFieldImportContext(
1087 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
1088 sal_uInt16 nPrfx
, const OUString
& sLocalName
)
1089 : XMLTextFieldImportContext(rImport
, rHlp
, sAPI_jump_edit
,nPrfx
, sLocalName
)
1090 , sPropertyPlaceholderType(RTL_CONSTASCII_USTRINGPARAM(sAPI_place_holder_type
))
1091 , sPropertyPlaceholder(RTL_CONSTASCII_USTRINGPARAM(sAPI_place_holder
))
1092 , sPropertyHint(RTL_CONSTASCII_USTRINGPARAM(sAPI_hint
))
1096 /// process attribute values
1097 void XMLPlaceholderFieldImportContext::ProcessAttribute(
1098 sal_uInt16 nAttrToken
, const OUString
& sAttrValue
)
1100 switch (nAttrToken
) {
1101 case XML_TOK_TEXTFIELD_DESCRIPTION
:
1102 sDescription
= sAttrValue
;
1105 case XML_TOK_TEXTFIELD_PLACEHOLDER_TYPE
:
1107 if (IsXMLToken(sAttrValue
, XML_TABLE
))
1109 nPlaceholderType
= PlaceholderType::TABLE
;
1111 else if (IsXMLToken(sAttrValue
, XML_TEXT
))
1113 nPlaceholderType
= PlaceholderType::TEXT
;
1115 else if (IsXMLToken(sAttrValue
, XML_TEXT_BOX
))
1117 nPlaceholderType
= PlaceholderType::TEXTFRAME
;
1119 else if (IsXMLToken(sAttrValue
, XML_IMAGE
))
1121 nPlaceholderType
= PlaceholderType::GRAPHIC
;
1123 else if (IsXMLToken(sAttrValue
, XML_OBJECT
))
1125 nPlaceholderType
= PlaceholderType::OBJECT
;
1138 void XMLPlaceholderFieldImportContext::PrepareField(
1139 const Reference
<XPropertySet
> & xPropertySet
) {
1142 aAny
<<= sDescription
;
1143 xPropertySet
->setPropertyValue(sPropertyHint
, aAny
);
1145 // remove <...> around content (if present)
1146 OUString aContent
= GetContent();
1147 sal_Int32 nStart
= 0;
1148 sal_Int32 nLength
= aContent
.getLength();
1149 if ((nLength
> 0) && (aContent
.getStr()[0] == '<'))
1154 if ((nLength
> 0) && (aContent
.getStr()[aContent
.getLength()-1] == '>'))
1158 aAny
<<= aContent
.copy(nStart
, nLength
);
1159 xPropertySet
->setPropertyValue(sPropertyPlaceholder
, aAny
);
1161 aAny
<<= nPlaceholderType
;
1162 xPropertySet
->setPropertyValue(sPropertyPlaceholderType
, aAny
);
1170 TYPEINIT1( XMLTimeFieldImportContext
, XMLTextFieldImportContext
);
1172 XMLTimeFieldImportContext::XMLTimeFieldImportContext(
1173 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
1174 sal_uInt16 nPrfx
, const OUString
& sLocalName
)
1175 : XMLTextFieldImportContext(rImport
, rHlp
, sAPI_date_time
, nPrfx
, sLocalName
)
1176 , sPropertyNumberFormat(RTL_CONSTASCII_USTRINGPARAM(sAPI_number_format
))
1177 , sPropertyFixed(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_fixed
))
1178 , sPropertyDateTimeValue(RTL_CONSTASCII_USTRINGPARAM(sAPI_date_time_value
))
1179 , sPropertyDateTime(RTL_CONSTASCII_USTRINGPARAM(sAPI_date_time
))
1180 , sPropertyAdjust(RTL_CONSTASCII_USTRINGPARAM(sAPI_adjust
))
1181 , sPropertyIsDate(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_date
))
1182 , sPropertyIsFixedLanguage(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_fixed_language
))
1186 , bTimeOK(sal_False
)
1187 , bFormatOK(sal_False
)
1189 , bIsDate(sal_False
)
1190 , bIsDefaultLanguage( sal_True
)
1192 bValid
= sal_True
; // always valid!
1195 void XMLTimeFieldImportContext::ProcessAttribute(
1196 sal_uInt16 nAttrToken
, const OUString
& sAttrValue
)
1200 case XML_TOK_TEXTFIELD_TIME_VALUE
:
1203 if (GetImport().GetMM100UnitConverter().
1204 convertDateTime(fTmp
, sAttrValue
))
1210 if (GetImport().GetMM100UnitConverter().
1211 convertDateTime(aDateTimeValue
, sAttrValue
))
1217 case XML_TOK_TEXTFIELD_FIXED
:
1220 if (SvXMLUnitConverter::convertBool(bTmp
, sAttrValue
))
1226 case XML_TOK_TEXTFIELD_DATA_STYLE_NAME
:
1228 sal_Int32 nKey
= GetImportHelper().GetDataStyleKey(
1229 sAttrValue
, &bIsDefaultLanguage
);
1233 bFormatOK
= sal_True
;
1237 case XML_TOK_TEXTFIELD_TIME_ADJUST
:
1241 if (SvXMLUnitConverter::convertTime(fTmp
, sAttrValue
))
1243 // convert to minutes
1244 nAdjust
= (sal_Int32
)::rtl::math::approxFloor(fTmp
* 60 * 24);
1251 void XMLTimeFieldImportContext::PrepareField(
1252 const Reference
<XPropertySet
> & rPropertySet
)
1256 // all properties are optional (except IsDate)
1257 Reference
<XPropertySetInfo
> xPropertySetInfo(
1258 rPropertySet
->getPropertySetInfo());
1260 if (xPropertySetInfo
->hasPropertyByName(sPropertyFixed
))
1262 aAny
.setValue( &bFixed
, ::getBooleanCppuType() );
1263 rPropertySet
->setPropertyValue(sPropertyFixed
, aAny
);
1266 aAny
.setValue( &bIsDate
, ::getBooleanCppuType() );
1267 rPropertySet
->setPropertyValue(sPropertyIsDate
, aAny
);
1269 if (xPropertySetInfo
->hasPropertyByName(sPropertyAdjust
))
1272 rPropertySet
->setPropertyValue(sPropertyAdjust
, aAny
);
1278 // organizer or styles-only mode: force update
1279 if (GetImport().GetTextImport()->IsOrganizerMode() ||
1280 GetImport().GetTextImport()->IsStylesOnlyMode() )
1282 ForceUpdate(rPropertySet
);
1286 // normal mode: set value (if present)
1289 if (xPropertySetInfo
->hasPropertyByName(sPropertyDateTimeValue
))
1291 aAny
<<= aDateTimeValue
;
1292 rPropertySet
->setPropertyValue(sPropertyDateTimeValue
,aAny
);
1294 else if (xPropertySetInfo
->hasPropertyByName(sPropertyDateTime
))
1296 aAny
<<= aDateTimeValue
;
1297 rPropertySet
->setPropertyValue(sPropertyDateTime
, aAny
);
1304 xPropertySetInfo
->hasPropertyByName(sPropertyNumberFormat
))
1306 aAny
<<= nFormatKey
;
1307 rPropertySet
->setPropertyValue(sPropertyNumberFormat
, aAny
);
1309 if( xPropertySetInfo
->hasPropertyByName( sPropertyIsFixedLanguage
) )
1311 sal_Bool bIsFixedLanguage
= ! bIsDefaultLanguage
;
1312 aAny
.setValue( &bIsFixedLanguage
, ::getBooleanCppuType() );
1313 rPropertySet
->setPropertyValue( sPropertyIsFixedLanguage
, aAny
);
1324 TYPEINIT1( XMLDateFieldImportContext
, XMLTimeFieldImportContext
);
1326 XMLDateFieldImportContext::XMLDateFieldImportContext(
1327 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
1328 sal_uInt16 nPrfx
, const OUString
& sLocalName
) :
1329 XMLTimeFieldImportContext(rImport
, rHlp
, nPrfx
, sLocalName
)
1331 bIsDate
= sal_True
; // always a date!
1334 void XMLDateFieldImportContext::ProcessAttribute(
1335 sal_uInt16 nAttrToken
,
1336 const ::rtl::OUString
& sAttrValue
)
1340 case XML_TOK_TEXTFIELD_DATE_VALUE
:
1344 if (GetImport().GetMM100UnitConverter().
1345 convertDateTime(fTmp
, sAttrValue
))
1347 // #96457#: don't truncate in order to read date+time
1352 if (GetImport().GetMM100UnitConverter().
1353 convertDateTime(aDateTimeValue
, sAttrValue
))
1359 case XML_TOK_TEXTFIELD_DATE_ADJUST
:
1360 // delegate to superclass, pretending it was a time-adjust attr.
1361 XMLTimeFieldImportContext::ProcessAttribute(
1362 XML_TOK_TEXTFIELD_TIME_ADJUST
,
1365 case XML_TOK_TEXTFIELD_TIME_VALUE
:
1366 case XML_TOK_TEXTFIELD_TIME_ADJUST
:
1367 ; // ignore time-adjust and time-value attributes
1370 // all others: delegate to super-class
1371 XMLTimeFieldImportContext::ProcessAttribute(nAttrToken
,
1381 // database field superclass
1384 TYPEINIT1( XMLDatabaseFieldImportContext
, XMLTextFieldImportContext
);
1386 XMLDatabaseFieldImportContext::XMLDatabaseFieldImportContext(
1387 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
1388 const sal_Char
* pServiceName
, sal_uInt16 nPrfx
,
1389 const OUString
& sLocalName
, bool bUseDisply
)
1390 : XMLTextFieldImportContext(rImport
, rHlp
, pServiceName
, nPrfx
, sLocalName
)
1391 , sPropertyDataBaseName(RTL_CONSTASCII_USTRINGPARAM(sAPI_data_base_name
))
1392 , sPropertyDataBaseURL(RTL_CONSTASCII_USTRINGPARAM(sAPI_data_base_u_r_l
))
1393 , sPropertyTableName(RTL_CONSTASCII_USTRINGPARAM(sAPI_data_table_name
))
1394 , sPropertyDataCommandType(RTL_CONSTASCII_USTRINGPARAM(sAPI_data_command_type
))
1395 , sPropertyIsVisible(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_visible
))
1396 , nCommandType( sdb::CommandType::TABLE
)
1397 , bCommandTypeOK(sal_False
)
1398 , bDisplay( sal_True
)
1399 , bDisplayOK( false )
1400 , bUseDisplay( bUseDisply
)
1401 , bDatabaseOK(sal_False
)
1402 , bDatabaseNameOK(sal_False
)
1403 , bDatabaseURLOK(sal_False
)
1404 , bTableOK(sal_False
)
1408 void XMLDatabaseFieldImportContext::ProcessAttribute(
1409 sal_uInt16 nAttrToken
, const OUString
& sAttrValue
)
1413 case XML_TOK_TEXTFIELD_DATABASE_NAME
:
1414 sDatabaseName
= sAttrValue
;
1415 bDatabaseOK
= sal_True
;
1416 bDatabaseNameOK
= sal_True
;
1418 case XML_TOK_TEXTFIELD_TABLE_NAME
:
1419 sTableName
= sAttrValue
;
1420 bTableOK
= sal_True
;
1422 case XML_TOK_TEXTFIELD_TABLE_TYPE
:
1423 if( IsXMLToken( sAttrValue
, XML_TABLE
) )
1425 nCommandType
= sdb::CommandType::TABLE
;
1426 bCommandTypeOK
= sal_True
;
1428 else if( IsXMLToken( sAttrValue
, XML_QUERY
) )
1430 nCommandType
= sdb::CommandType::QUERY
;
1431 bCommandTypeOK
= sal_True
;
1433 else if( IsXMLToken( sAttrValue
, XML_COMMAND
) )
1435 nCommandType
= sdb::CommandType::COMMAND
;
1436 bCommandTypeOK
= sal_True
;
1439 case XML_TOK_TEXTFIELD_DISPLAY
:
1440 if( IsXMLToken( sAttrValue
, XML_NONE
) )
1442 bDisplay
= sal_False
;
1445 else if( IsXMLToken( sAttrValue
, XML_VALUE
) )
1447 bDisplay
= sal_True
;
1454 SvXMLImportContext
* XMLDatabaseFieldImportContext::CreateChildContext(
1455 sal_uInt16 p_nPrefix
,
1456 const OUString
& rLocalName
,
1457 const Reference
<XAttributeList
>& xAttrList
)
1459 if( ( p_nPrefix
== XML_NAMESPACE_FORM
) &&
1460 IsXMLToken( rLocalName
, XML_CONNECTION_RESOURCE
) )
1462 // process attribute list directly
1463 sal_Int16 nLength
= xAttrList
->getLength();
1464 for( sal_Int16 n
= 0; n
< nLength
; n
++ )
1466 OUString sLocalName
;
1467 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().
1468 GetKeyByAttrName( xAttrList
->getNameByIndex(n
), &sLocalName
);
1470 if( ( nPrefix
== XML_NAMESPACE_XLINK
) &&
1471 IsXMLToken( sLocalName
, XML_HREF
) )
1473 sDatabaseURL
= xAttrList
->getValueByIndex(n
);
1474 bDatabaseOK
= sal_True
;
1475 bDatabaseURLOK
= sal_True
;
1479 // we call ProcessAttribute in order to set bValid appropriatly
1480 ProcessAttribute( XML_TOKEN_INVALID
, OUString() );
1483 return SvXMLImportContext::CreateChildContext(p_nPrefix
, rLocalName
,
1488 void XMLDatabaseFieldImportContext::PrepareField(
1489 const Reference
<XPropertySet
> & xPropertySet
)
1493 aAny
<<= sTableName
;
1494 xPropertySet
->setPropertyValue(sPropertyTableName
, aAny
);
1496 if( bDatabaseNameOK
)
1498 aAny
<<= sDatabaseName
;
1499 xPropertySet
->setPropertyValue(sPropertyDataBaseName
, aAny
);
1501 else if( bDatabaseURLOK
)
1503 aAny
<<= sDatabaseURL
;
1504 xPropertySet
->setPropertyValue(sPropertyDataBaseURL
, aAny
);
1507 // #99980# load/save command type for all fields; also load
1508 // old documents without command type
1509 if( bCommandTypeOK
)
1511 aAny
<<= nCommandType
;
1512 xPropertySet
->setPropertyValue( sPropertyDataCommandType
, aAny
);
1515 if( bUseDisplay
&& bDisplayOK
)
1517 aAny
.setValue( &bDisplay
, ::getBooleanCppuType() );
1518 xPropertySet
->setPropertyValue( sPropertyIsVisible
, aAny
);
1525 // database name field
1528 TYPEINIT1( XMLDatabaseNameImportContext
, XMLDatabaseFieldImportContext
);
1530 XMLDatabaseNameImportContext::XMLDatabaseNameImportContext(
1531 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
1532 sal_uInt16 nPrfx
, const OUString
& sLocalName
) :
1533 XMLDatabaseFieldImportContext(rImport
, rHlp
, sAPI_database_name
,
1534 nPrfx
, sLocalName
, true)
1538 void XMLDatabaseNameImportContext::ProcessAttribute(
1539 sal_uInt16 nAttrToken
, const OUString
& sAttrValue
)
1541 // delegate to superclass and check for success
1542 XMLDatabaseFieldImportContext::ProcessAttribute(nAttrToken
, sAttrValue
);
1543 bValid
= bDatabaseOK
&& bTableOK
;
1549 // database next field
1552 TYPEINIT1( XMLDatabaseNextImportContext
, XMLDatabaseFieldImportContext
);
1554 XMLDatabaseNextImportContext::XMLDatabaseNextImportContext(
1555 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
1556 const sal_Char
* pServiceName
, sal_uInt16 nPrfx
,
1557 const OUString
& sLocalName
) :
1558 XMLDatabaseFieldImportContext(rImport
, rHlp
, pServiceName
,
1559 nPrfx
, sLocalName
, false),
1560 sPropertyCondition(RTL_CONSTASCII_USTRINGPARAM(sAPI_condition
)),
1561 sTrue(RTL_CONSTASCII_USTRINGPARAM(sAPI_true
)),
1563 bConditionOK(sal_False
)
1567 XMLDatabaseNextImportContext::XMLDatabaseNextImportContext(
1568 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
1569 sal_uInt16 nPrfx
, const OUString
& sLocalName
)
1570 : XMLDatabaseFieldImportContext(rImport
, rHlp
, sAPI_database_next
, nPrfx
, sLocalName
, false)
1571 , sPropertyCondition(RTL_CONSTASCII_USTRINGPARAM(sAPI_condition
))
1572 , sTrue(RTL_CONSTASCII_USTRINGPARAM(sAPI_true
))
1573 , bConditionOK(sal_False
)
1577 void XMLDatabaseNextImportContext::ProcessAttribute(
1578 sal_uInt16 nAttrToken
, const OUString
& sAttrValue
)
1580 if (XML_TOK_TEXTFIELD_CONDITION
== nAttrToken
)
1583 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap()._GetKeyByAttrName(
1584 sAttrValue
, &sTmp
, sal_False
);
1585 if( XML_NAMESPACE_OOOW
== nPrefix
)
1588 bConditionOK
= sal_True
;
1591 sCondition
= sAttrValue
;
1595 XMLDatabaseFieldImportContext::ProcessAttribute(nAttrToken
,
1599 bValid
= bDatabaseOK
&& bTableOK
;
1602 void XMLDatabaseNextImportContext::PrepareField(
1603 const Reference
<XPropertySet
> & xPropertySet
)
1607 aAny
<<= bConditionOK
? sCondition
: sTrue
;
1608 xPropertySet
->setPropertyValue(sPropertyCondition
, aAny
);
1610 XMLDatabaseFieldImportContext::PrepareField(xPropertySet
);
1616 // database select field
1619 TYPEINIT1( XMLDatabaseSelectImportContext
, XMLDatabaseNextImportContext
);
1621 XMLDatabaseSelectImportContext::XMLDatabaseSelectImportContext(
1622 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
1623 sal_uInt16 nPrfx
, const ::rtl::OUString
& sLocalName
) :
1624 XMLDatabaseNextImportContext(rImport
, rHlp
, sAPI_database_select
,
1626 sPropertySetNumber(RTL_CONSTASCII_USTRINGPARAM(sAPI_set_number
)),
1628 bNumberOK(sal_False
)
1632 void XMLDatabaseSelectImportContext::ProcessAttribute(
1633 sal_uInt16 nAttrToken
,
1634 const ::rtl::OUString
& sAttrValue
)
1636 if (XML_TOK_TEXTFIELD_ROW_NUMBER
== nAttrToken
)
1639 if (SvXMLUnitConverter::convertNumber( nTmp
, sAttrValue
1640 /* , nMin, nMax ??? */ ))
1643 bNumberOK
= sal_True
;
1648 XMLDatabaseNextImportContext::ProcessAttribute(nAttrToken
, sAttrValue
);
1651 bValid
= bTableOK
&& bDatabaseOK
&& bNumberOK
;
1654 void XMLDatabaseSelectImportContext::PrepareField(
1655 const Reference
<XPropertySet
> & xPropertySet
)
1660 xPropertySet
->setPropertyValue(sPropertySetNumber
, aAny
);
1662 XMLDatabaseNextImportContext::PrepareField(xPropertySet
);
1668 // database display row number field
1671 TYPEINIT1( XMLDatabaseNumberImportContext
, XMLDatabaseFieldImportContext
);
1673 XMLDatabaseNumberImportContext::XMLDatabaseNumberImportContext(
1674 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
1675 sal_uInt16 nPrfx
, const OUString
& sLocalName
) :
1676 XMLDatabaseFieldImportContext(rImport
, rHlp
, sAPI_database_number
,
1677 nPrfx
, sLocalName
, true),
1678 sPropertyNumberingType(
1679 RTL_CONSTASCII_USTRINGPARAM(sAPI_numbering_type
)),
1680 sPropertySetNumber(RTL_CONSTASCII_USTRINGPARAM(sAPI_set_number
)),
1681 sNumberFormat(RTL_CONSTASCII_USTRINGPARAM("1")),
1682 sNumberSync(GetXMLToken(XML_FALSE
)),
1688 void XMLDatabaseNumberImportContext::ProcessAttribute(
1689 sal_uInt16 nAttrToken
,
1690 const OUString
& sAttrValue
)
1694 case XML_TOK_TEXTFIELD_NUM_FORMAT
:
1695 sNumberFormat
= sAttrValue
;
1697 case XML_TOK_TEXTFIELD_NUM_LETTER_SYNC
:
1698 sNumberSync
= sAttrValue
;
1700 case XML_TOK_TEXTFIELD_VALUE
:
1703 if (SvXMLUnitConverter::convertNumber( nTmp
, sAttrValue
))
1706 bValueOK
= sal_True
;
1711 XMLDatabaseFieldImportContext::ProcessAttribute(nAttrToken
,
1716 bValid
= bTableOK
&& bDatabaseOK
;
1719 void XMLDatabaseNumberImportContext::PrepareField(
1720 const Reference
<XPropertySet
> & xPropertySet
)
1724 sal_Int16 nNumType
= style::NumberingType::ARABIC
;
1725 GetImport().GetMM100UnitConverter().convertNumFormat( nNumType
,
1729 xPropertySet
->setPropertyValue(sPropertyNumberingType
, aAny
);
1734 xPropertySet
->setPropertyValue(sPropertySetNumber
, aAny
);
1737 XMLDatabaseFieldImportContext::PrepareField(xPropertySet
);
1743 // Simple doc info fields
1746 TYPEINIT1( XMLSimpleDocInfoImportContext
, XMLTextFieldImportContext
);
1748 XMLSimpleDocInfoImportContext::XMLSimpleDocInfoImportContext(
1749 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
1750 sal_uInt16 nPrfx
, const OUString
& sLocalName
, sal_uInt16 nToken
,
1751 sal_Bool bContent
, sal_Bool bAuthor
)
1752 : XMLTextFieldImportContext(rImport
, rHlp
, MapTokenToServiceName(nToken
),nPrfx
, sLocalName
)
1753 , sPropertyFixed(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_fixed
))
1754 , sPropertyContent(RTL_CONSTASCII_USTRINGPARAM(sAPI_content
))
1755 , sPropertyAuthor(RTL_CONSTASCII_USTRINGPARAM(sAPI_author
))
1756 , sPropertyCurrentPresentation(RTL_CONSTASCII_USTRINGPARAM(sAPI_current_presentation
))
1758 , bHasAuthor(bAuthor
)
1759 , bHasContent(bContent
)
1764 void XMLSimpleDocInfoImportContext::ProcessAttribute(
1765 sal_uInt16 nAttrToken
,
1766 const OUString
& sAttrValue
)
1768 if (XML_TOK_TEXTFIELD_FIXED
== nAttrToken
)
1771 if (SvXMLUnitConverter::convertBool(bTmp
, sAttrValue
))
1778 void XMLSimpleDocInfoImportContext::PrepareField(
1779 const Reference
<XPropertySet
> & rPropertySet
)
1781 // title field in Calc has no Fixed property
1782 Reference
<XPropertySetInfo
> xPropertySetInfo(rPropertySet
->getPropertySetInfo());
1783 if (xPropertySetInfo
->hasPropertyByName(sPropertyFixed
))
1786 aAny
.setValue(&bFixed
, ::getBooleanCppuType() );
1787 rPropertySet
->setPropertyValue(sPropertyFixed
, aAny
);
1789 // set Content and CurrentPresentation (if fixed)
1792 // in organizer-mode or styles-only-mode, only force update
1793 if (GetImport().GetTextImport()->IsOrganizerMode() ||
1794 GetImport().GetTextImport()->IsStylesOnlyMode() )
1796 ForceUpdate(rPropertySet
);
1800 // set content (author, if that's the name) and current
1802 aAny
<<= GetContent();
1804 if (bFixed
&& bHasAuthor
)
1806 rPropertySet
->setPropertyValue(sPropertyAuthor
, aAny
);
1809 if (bFixed
&& bHasContent
)
1811 rPropertySet
->setPropertyValue(sPropertyContent
, aAny
);
1814 rPropertySet
->setPropertyValue(sPropertyCurrentPresentation
, aAny
);
1820 const sal_Char
* XMLSimpleDocInfoImportContext::MapTokenToServiceName(
1823 const sal_Char
* pServiceName
= NULL
;
1827 case XML_TOK_TEXT_DOCUMENT_CREATION_AUTHOR
:
1828 pServiceName
= sAPI_docinfo_create_author
;
1830 case XML_TOK_TEXT_DOCUMENT_CREATION_DATE
:
1831 pServiceName
= sAPI_docinfo_create_date_time
;
1833 case XML_TOK_TEXT_DOCUMENT_CREATION_TIME
:
1834 pServiceName
= sAPI_docinfo_create_date_time
;
1836 case XML_TOK_TEXT_DOCUMENT_DESCRIPTION
:
1837 pServiceName
= sAPI_docinfo_description
;
1839 case XML_TOK_TEXT_DOCUMENT_EDIT_DURATION
:
1840 pServiceName
= sAPI_docinfo_edit_time
;
1842 case XML_TOK_TEXT_DOCUMENT_USER_DEFINED
:
1843 pServiceName
= sAPI_docinfo_custom
;
1845 case XML_TOK_TEXT_DOCUMENT_PRINT_AUTHOR
:
1846 pServiceName
= sAPI_docinfo_print_author
;
1848 case XML_TOK_TEXT_DOCUMENT_PRINT_DATE
:
1849 pServiceName
= sAPI_docinfo_print_date_time
;
1851 case XML_TOK_TEXT_DOCUMENT_PRINT_TIME
:
1852 pServiceName
= sAPI_docinfo_print_date_time
;
1854 case XML_TOK_TEXT_DOCUMENT_KEYWORDS
:
1855 pServiceName
= sAPI_docinfo_keywords
;
1857 case XML_TOK_TEXT_DOCUMENT_SUBJECT
:
1858 pServiceName
= sAPI_docinfo_subject
;
1860 case XML_TOK_TEXT_DOCUMENT_REVISION
:
1861 pServiceName
= sAPI_docinfo_revision
;
1863 case XML_TOK_TEXT_DOCUMENT_SAVE_AUTHOR
:
1864 pServiceName
= sAPI_docinfo_change_author
;
1866 case XML_TOK_TEXT_DOCUMENT_SAVE_DATE
:
1867 pServiceName
= sAPI_docinfo_change_date_time
;
1869 case XML_TOK_TEXT_DOCUMENT_SAVE_TIME
:
1870 pServiceName
= sAPI_docinfo_change_date_time
;
1872 case XML_TOK_TEXT_DOCUMENT_TITLE
:
1873 pServiceName
= sAPI_docinfo_title
;
1877 DBG_ERROR("no docinfo field token");
1878 pServiceName
= NULL
;
1882 return pServiceName
;
1890 TYPEINIT1( XMLRevisionDocInfoImportContext
, XMLSimpleDocInfoImportContext
);
1892 XMLRevisionDocInfoImportContext::XMLRevisionDocInfoImportContext(
1893 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
, sal_uInt16 nPrfx
,
1894 const OUString
& sLocalName
, sal_uInt16 nToken
) :
1895 XMLSimpleDocInfoImportContext(rImport
, rHlp
, nPrfx
, sLocalName
,
1896 nToken
, sal_False
, sal_False
),
1897 sPropertyRevision(RTL_CONSTASCII_USTRINGPARAM(sAPI_revision
))
1902 void XMLRevisionDocInfoImportContext::PrepareField(
1903 const Reference
<XPropertySet
> & rPropertySet
)
1905 XMLSimpleDocInfoImportContext::PrepareField(rPropertySet
);
1907 // set revision number
1908 // if fixed, if not in organizer-mode, if not in styles-only-mode
1911 if ( GetImport().GetTextImport()->IsOrganizerMode() ||
1912 GetImport().GetTextImport()->IsStylesOnlyMode() )
1914 ForceUpdate(rPropertySet
);
1919 if (SvXMLUnitConverter::convertNumber(nTmp
, GetContent()))
1923 rPropertySet
->setPropertyValue(sPropertyRevision
, aAny
);
1932 // DocInfo fields with date/time attributes
1935 TYPEINIT1( XMLDateTimeDocInfoImportContext
, XMLSimpleDocInfoImportContext
);
1937 XMLDateTimeDocInfoImportContext::XMLDateTimeDocInfoImportContext(
1938 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
, sal_uInt16 nPrfx
,
1939 const OUString
& sLocalName
, sal_uInt16 nToken
)
1940 : XMLSimpleDocInfoImportContext(rImport
, rHlp
, nPrfx
, sLocalName
,nToken
, sal_False
, sal_False
)
1941 , sPropertyNumberFormat(RTL_CONSTASCII_USTRINGPARAM(sAPI_number_format
))
1942 , sPropertyIsDate(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_date
))
1943 , sPropertyIsFixedLanguage(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_fixed_language
))
1945 , bFormatOK(sal_False
)
1946 , bIsDefaultLanguage(sal_True
)
1948 // we allow processing of EDIT_DURATION here, because import of actual
1949 // is not supported anyway. If it was, we'd need an extra import class
1950 // because times and time durations are presented differently!
1955 case XML_TOK_TEXT_DOCUMENT_CREATION_DATE
:
1956 case XML_TOK_TEXT_DOCUMENT_PRINT_DATE
:
1957 case XML_TOK_TEXT_DOCUMENT_SAVE_DATE
:
1959 bHasDateTime
= sal_True
;
1961 case XML_TOK_TEXT_DOCUMENT_CREATION_TIME
:
1962 case XML_TOK_TEXT_DOCUMENT_PRINT_TIME
:
1963 case XML_TOK_TEXT_DOCUMENT_SAVE_TIME
:
1964 bIsDate
= sal_False
;
1965 bHasDateTime
= sal_True
;
1967 case XML_TOK_TEXT_DOCUMENT_EDIT_DURATION
:
1968 bIsDate
= sal_False
;
1969 bHasDateTime
= sal_False
;
1973 "XMLDateTimeDocInfoImportContext needs date/time doc. fields");
1979 void XMLDateTimeDocInfoImportContext::ProcessAttribute(
1980 sal_uInt16 nAttrToken
,
1981 const OUString
& sAttrValue
)
1985 case XML_TOK_TEXTFIELD_DATA_STYLE_NAME
:
1987 sal_Int32 nKey
= GetImportHelper().GetDataStyleKey(
1988 sAttrValue
, &bIsDefaultLanguage
);
1992 bFormatOK
= sal_True
;
1996 case XML_TOK_TEXTFIELD_FIXED
:
1997 XMLSimpleDocInfoImportContext::ProcessAttribute(nAttrToken
,
2001 // ignore -> we can't set date/time value anyway!
2006 void XMLDateTimeDocInfoImportContext::PrepareField(
2007 const Reference
<XPropertySet
> & xPropertySet
)
2009 // process fixed and presentation
2010 XMLSimpleDocInfoImportContext::PrepareField(xPropertySet
);
2016 aAny
.setValue( &bIsDate
, ::getBooleanCppuType());
2017 xPropertySet
->setPropertyValue(sPropertyIsDate
, aAny
);
2023 xPropertySet
->setPropertyValue(sPropertyNumberFormat
, aAny
);
2025 if( xPropertySet
->getPropertySetInfo()->
2026 hasPropertyByName( sPropertyIsFixedLanguage
) )
2028 sal_Bool bIsFixedLanguage
= ! bIsDefaultLanguage
;
2029 aAny
.setValue( &bIsFixedLanguage
, ::getBooleanCppuType() );
2030 xPropertySet
->setPropertyValue( sPropertyIsFixedLanguage
, aAny
);
2034 // can't set date/time/duration value! Sorry.
2039 // user defined docinfo fields
2042 TYPEINIT1( XMLUserDocInfoImportContext
, XMLSimpleDocInfoImportContext
);
2044 XMLUserDocInfoImportContext::XMLUserDocInfoImportContext(
2045 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
2046 sal_uInt16 nPrfx
, const OUString
& sLocalName
, sal_uInt16 nToken
) :
2047 XMLSimpleDocInfoImportContext(rImport
, rHlp
, nPrfx
,
2049 sal_False
, sal_False
)
2050 , sPropertyName(RTL_CONSTASCII_USTRINGPARAM(sAPI_name
))
2055 void XMLUserDocInfoImportContext::ProcessAttribute(
2056 sal_uInt16 nAttrToken
,
2057 const OUString
& sAttrValue
)
2061 case XML_TOK_TEXTFIELD_NAME
:
2065 SetServiceName(OUString::createFromAscii( sAPI_docinfo_custom
) );
2073 XMLSimpleDocInfoImportContext::ProcessAttribute(nAttrToken
,
2079 void XMLUserDocInfoImportContext::PrepareField(
2080 const ::com::sun::star::uno::Reference
<
2081 ::com::sun::star::beans::XPropertySet
> & xPropertySet
)
2083 if ( aName
.getLength() )
2087 xPropertySet
->setPropertyValue(sPropertyName
, aAny
);
2090 // call superclass to handle "fixed"
2091 XMLSimpleDocInfoImportContext::PrepareField(xPropertySet
);
2096 // import hidden paragraph fields
2099 TYPEINIT1( XMLHiddenParagraphImportContext
, XMLTextFieldImportContext
);
2101 XMLHiddenParagraphImportContext::XMLHiddenParagraphImportContext(
2102 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
2103 sal_uInt16 nPrfx
, const OUString
& sLocalName
) :
2104 XMLTextFieldImportContext(rImport
, rHlp
, sAPI_hidden_paragraph
,
2106 sPropertyCondition(RTL_CONSTASCII_USTRINGPARAM(sAPI_condition
)),
2107 sPropertyIsHidden(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_hidden
)),
2109 bIsHidden(sal_False
)
2113 void XMLHiddenParagraphImportContext::ProcessAttribute(
2114 sal_uInt16 nAttrToken
,
2115 const OUString
& sAttrValue
)
2117 if (XML_TOK_TEXTFIELD_CONDITION
== nAttrToken
)
2120 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap()._GetKeyByAttrName(
2121 sAttrValue
, &sTmp
, sal_False
);
2122 if( XML_NAMESPACE_OOOW
== nPrefix
)
2128 sCondition
= sAttrValue
;
2130 else if (XML_TOK_TEXTFIELD_IS_HIDDEN
== nAttrToken
)
2133 if (SvXMLUnitConverter::convertBool(bTmp
, sAttrValue
))
2140 void XMLHiddenParagraphImportContext::PrepareField(
2141 const Reference
<XPropertySet
> & xPropertySet
)
2144 aAny
<<= sCondition
;
2145 xPropertySet
->setPropertyValue(sPropertyCondition
, aAny
);
2147 aAny
.setValue( &bIsHidden
, ::getBooleanCppuType() );
2148 xPropertySet
->setPropertyValue(sPropertyIsHidden
, aAny
);
2154 // import conditional text (<text:conditional-text>)
2157 TYPEINIT1( XMLConditionalTextImportContext
, XMLTextFieldImportContext
);
2159 XMLConditionalTextImportContext::XMLConditionalTextImportContext(
2160 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
2161 sal_uInt16 nPrfx
, const OUString
& sLocalName
) :
2162 XMLTextFieldImportContext(rImport
, rHlp
, sAPI_conditional_text
,
2164 sPropertyCondition(RTL_CONSTASCII_USTRINGPARAM(sAPI_condition
)),
2165 sPropertyTrueContent(RTL_CONSTASCII_USTRINGPARAM(sAPI_true_content
)),
2166 sPropertyFalseContent(RTL_CONSTASCII_USTRINGPARAM(sAPI_false_content
)),
2167 sPropertyIsConditionTrue(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_condition_true
)),
2168 sPropertyCurrentPresentation(RTL_CONSTASCII_USTRINGPARAM(sAPI_current_presentation
)),
2169 bConditionOK(sal_False
),
2171 bFalseOK(sal_False
),
2172 bCurrentValue(sal_False
)
2176 void XMLConditionalTextImportContext::ProcessAttribute(
2177 sal_uInt16 nAttrToken
,
2178 const OUString
& sAttrValue
)
2182 case XML_TOK_TEXTFIELD_CONDITION
:
2185 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().
2186 _GetKeyByAttrName( sAttrValue
, &sTmp
, sal_False
);
2187 if( XML_NAMESPACE_OOOW
== nPrefix
)
2190 bConditionOK
= sal_True
;
2193 sCondition
= sAttrValue
;
2196 case XML_TOK_TEXTFIELD_STRING_VALUE_IF_FALSE
:
2197 sFalseContent
= sAttrValue
;
2198 bFalseOK
= sal_True
;
2200 case XML_TOK_TEXTFIELD_STRING_VALUE_IF_TRUE
:
2201 sTrueContent
= sAttrValue
;
2204 case XML_TOK_TEXTFIELD_CURRENT_VALUE
:
2207 if (SvXMLUnitConverter::convertBool(bTmp
, sAttrValue
))
2209 bCurrentValue
= bTmp
;
2215 bValid
= bConditionOK
&& bFalseOK
&& bTrueOK
;
2218 void XMLConditionalTextImportContext::PrepareField(
2219 const Reference
<XPropertySet
> & xPropertySet
)
2223 aAny
<<= sCondition
;
2224 xPropertySet
->setPropertyValue(sPropertyCondition
, aAny
);
2226 aAny
<<= sFalseContent
;
2227 xPropertySet
->setPropertyValue(sPropertyFalseContent
, aAny
);
2229 aAny
<<= sTrueContent
;
2230 xPropertySet
->setPropertyValue(sPropertyTrueContent
, aAny
);
2232 aAny
.setValue( &bCurrentValue
, ::getBooleanCppuType() );
2233 xPropertySet
->setPropertyValue(sPropertyIsConditionTrue
, aAny
);
2235 aAny
<<= GetContent();
2236 xPropertySet
->setPropertyValue(sPropertyCurrentPresentation
, aAny
);
2245 TYPEINIT1( XMLHiddenTextImportContext
, XMLTextFieldImportContext
);
2247 XMLHiddenTextImportContext::XMLHiddenTextImportContext(
2248 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
2249 sal_uInt16 nPrfx
, const OUString
& sLocalName
) :
2250 XMLTextFieldImportContext(rImport
, rHlp
, sAPI_hidden_text
,
2252 sPropertyCondition(RTL_CONSTASCII_USTRINGPARAM(sAPI_condition
)),
2253 sPropertyContent(RTL_CONSTASCII_USTRINGPARAM(sAPI_content
)),
2254 sPropertyIsHidden(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_hidden
)),
2255 bConditionOK(sal_False
),
2256 bStringOK(sal_False
),
2257 bIsHidden(sal_False
)
2261 void XMLHiddenTextImportContext::ProcessAttribute(
2262 sal_uInt16 nAttrToken
,
2263 const OUString
& sAttrValue
)
2267 case XML_TOK_TEXTFIELD_CONDITION
:
2270 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().
2271 _GetKeyByAttrName( sAttrValue
, &sTmp
, sal_False
);
2272 if( XML_NAMESPACE_OOOW
== nPrefix
)
2275 bConditionOK
= sal_True
;
2278 sCondition
= sAttrValue
;
2281 case XML_TOK_TEXTFIELD_STRING_VALUE
:
2282 sString
= sAttrValue
;
2283 bStringOK
= sal_True
;
2285 case XML_TOK_TEXTFIELD_IS_HIDDEN
:
2288 if (SvXMLUnitConverter::convertBool(bTmp
, sAttrValue
))
2296 bValid
= bConditionOK
&& bStringOK
;
2299 void XMLHiddenTextImportContext::PrepareField(
2300 const Reference
<XPropertySet
> & xPropertySet
)
2304 aAny
<<= sCondition
;
2305 xPropertySet
->setPropertyValue(sPropertyCondition
, aAny
);
2308 xPropertySet
->setPropertyValue(sPropertyContent
, aAny
);
2310 aAny
.setValue( &bIsHidden
, ::getBooleanCppuType() );
2311 xPropertySet
->setPropertyValue(sPropertyIsHidden
, aAny
);
2320 TYPEINIT1( XMLFileNameImportContext
, XMLTextFieldImportContext
);
2322 static const SvXMLEnumMapEntry aFilenameDisplayMap
[] =
2324 { XML_PATH
, FilenameDisplayFormat::PATH
},
2325 { XML_NAME
, FilenameDisplayFormat::NAME
},
2326 { XML_NAME_AND_EXTENSION
, FilenameDisplayFormat::NAME_AND_EXT
},
2327 { XML_FULL
, FilenameDisplayFormat::FULL
},
2328 { XML_TOKEN_INVALID
, 0 }
2331 XMLFileNameImportContext::XMLFileNameImportContext(
2332 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
, sal_uInt16 nPrfx
,
2333 const OUString
& sLocalName
) :
2334 XMLTextFieldImportContext(rImport
, rHlp
, sAPI_file_name
,
2336 sPropertyFixed(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_fixed
)),
2337 sPropertyFileFormat(RTL_CONSTASCII_USTRINGPARAM(sAPI_file_format
)),
2338 sPropertyCurrentPresentation(
2339 RTL_CONSTASCII_USTRINGPARAM(sAPI_current_presentation
)),
2340 nFormat(FilenameDisplayFormat::FULL
),
2346 void XMLFileNameImportContext::ProcessAttribute(
2347 sal_uInt16 nAttrToken
,
2348 const ::rtl::OUString
& sAttrValue
)
2352 case XML_TOK_TEXTFIELD_FIXED
:
2355 if (SvXMLUnitConverter::convertBool(bTmp
, sAttrValue
))
2361 case XML_TOK_TEXTFIELD_DISPLAY
:
2364 if (SvXMLUnitConverter::convertEnum(nTmp
, sAttrValue
,
2365 aFilenameDisplayMap
))
2367 nFormat
= (sal_uInt16
)nTmp
;
2372 ; // unkown attribute: ignore
2377 void XMLFileNameImportContext::PrepareField(
2378 const Reference
<XPropertySet
> & xPropertySet
)
2382 // properties are optional
2383 Reference
<XPropertySetInfo
> xPropertySetInfo(
2384 xPropertySet
->getPropertySetInfo());
2386 if (xPropertySetInfo
->hasPropertyByName(sPropertyFixed
))
2389 xPropertySet
->setPropertyValue(sPropertyFixed
, aAny
);
2392 if (xPropertySetInfo
->hasPropertyByName(sPropertyFileFormat
))
2395 xPropertySet
->setPropertyValue(sPropertyFileFormat
, aAny
);
2398 if (xPropertySetInfo
->hasPropertyByName(sPropertyCurrentPresentation
))
2400 aAny
<<= GetContent();
2401 xPropertySet
->setPropertyValue(sPropertyCurrentPresentation
, aAny
);
2407 // template name field
2410 static const SvXMLEnumMapEntry aTemplateDisplayMap
[] =
2412 { XML_FULL
, TemplateDisplayFormat::FULL
},
2413 { XML_PATH
, TemplateDisplayFormat::PATH
},
2414 { XML_NAME
, TemplateDisplayFormat::NAME
},
2415 { XML_NAME_AND_EXTENSION
, TemplateDisplayFormat::NAME_AND_EXT
},
2416 { XML_AREA
, TemplateDisplayFormat::AREA
},
2417 { XML_TITLE
, TemplateDisplayFormat::TITLE
},
2418 { XML_TOKEN_INVALID
, 0 }
2421 TYPEINIT1( XMLTemplateNameImportContext
, XMLTextFieldImportContext
);
2423 XMLTemplateNameImportContext::XMLTemplateNameImportContext(
2424 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
, sal_uInt16 nPrfx
,
2425 const OUString
& sLocalName
) :
2426 XMLTextFieldImportContext(rImport
, rHlp
, sAPI_template_name
,
2428 sPropertyFileFormat(RTL_CONSTASCII_USTRINGPARAM(sAPI_file_format
)),
2429 nFormat(TemplateDisplayFormat::FULL
)
2434 void XMLTemplateNameImportContext::ProcessAttribute(
2435 sal_uInt16 nAttrToken
,
2436 const OUString
& sAttrValue
)
2440 case XML_TOK_TEXTFIELD_DISPLAY
:
2443 if (SvXMLUnitConverter::convertEnum(nTmp
, sAttrValue
,
2444 aTemplateDisplayMap
))
2446 nFormat
= (sal_uInt16
)nTmp
;
2451 ; // unknown attribute: ignore
2456 void XMLTemplateNameImportContext::PrepareField(
2457 const Reference
<XPropertySet
> & xPropertySet
)
2462 xPropertySet
->setPropertyValue(sPropertyFileFormat
, aAny
);
2467 // import chapter fields
2470 TYPEINIT1( XMLChapterImportContext
, XMLTextFieldImportContext
);
2472 static const SvXMLEnumMapEntry aChapterDisplayMap
[] =
2474 { XML_NAME
, ChapterFormat::NAME
},
2475 { XML_NUMBER
, ChapterFormat::NUMBER
},
2476 { XML_NUMBER_AND_NAME
, ChapterFormat::NAME_NUMBER
},
2477 { XML_PLAIN_NUMBER_AND_NAME
, ChapterFormat::NO_PREFIX_SUFFIX
},
2478 { XML_PLAIN_NUMBER
, ChapterFormat::DIGIT
},
2479 { XML_TOKEN_INVALID
, 0 }
2482 XMLChapterImportContext::XMLChapterImportContext(
2483 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
2484 sal_uInt16 nPrfx
, const OUString
& sLocalName
) :
2485 XMLTextFieldImportContext(rImport
, rHlp
, sAPI_chapter
,
2487 sPropertyChapterFormat(
2488 RTL_CONSTASCII_USTRINGPARAM(sAPI_chapter_format
)),
2489 sPropertyLevel(RTL_CONSTASCII_USTRINGPARAM(sAPI_level
)),
2490 nFormat(ChapterFormat::NAME_NUMBER
),
2496 void XMLChapterImportContext::ProcessAttribute(
2497 sal_uInt16 nAttrToken
,
2498 const OUString
& sAttrValue
)
2502 case XML_TOK_TEXTFIELD_DISPLAY
:
2505 if (SvXMLUnitConverter::convertEnum(nTmp
, sAttrValue
,
2506 aChapterDisplayMap
))
2508 nFormat
= (sal_Int16
)nTmp
;
2512 case XML_TOK_TEXTFIELD_OUTLINE_LEVEL
:
2515 if (SvXMLUnitConverter::convertNumber(
2516 nTmp
, sAttrValue
, 1,
2517 GetImport().GetTextImport()->GetChapterNumbering()->getCount()
2520 // API numbers 0..9, we number 1..10
2521 nLevel
= (sal_Int8
)nTmp
;
2527 ; // unknown attribute: ignore
2532 void XMLChapterImportContext::PrepareField(
2533 const Reference
<XPropertySet
> & xPropertySet
)
2538 xPropertySet
->setPropertyValue(sPropertyChapterFormat
, aAny
);
2541 xPropertySet
->setPropertyValue(sPropertyLevel
, aAny
);
2549 TYPEINIT1( XMLCountFieldImportContext
, XMLTextFieldImportContext
);
2551 XMLCountFieldImportContext::XMLCountFieldImportContext(
2552 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
2553 sal_uInt16 nPrfx
, const OUString
& sLocalName
, sal_uInt16 nToken
) :
2554 XMLTextFieldImportContext(rImport
, rHlp
, MapTokenToServiceName(nToken
),
2556 sPropertyNumberingType(
2557 RTL_CONSTASCII_USTRINGPARAM(sAPI_numbering_type
)),
2560 bNumberFormatOK(sal_False
)
2565 void XMLCountFieldImportContext::ProcessAttribute(
2566 sal_uInt16 nAttrToken
,
2567 const OUString
& sAttrValue
)
2571 case XML_TOK_TEXTFIELD_NUM_FORMAT
:
2572 sNumberFormat
= sAttrValue
;
2573 bNumberFormatOK
= sal_True
;
2575 case XML_TOK_TEXTFIELD_NUM_LETTER_SYNC
:
2576 sLetterSync
= sAttrValue
;
2581 void XMLCountFieldImportContext::PrepareField(
2582 const Reference
<XPropertySet
> & xPropertySet
)
2586 // properties optional
2587 // (only page count, but do for all to save common implementation)
2589 if (xPropertySet
->getPropertySetInfo()->
2590 hasPropertyByName(sPropertyNumberingType
))
2593 if( bNumberFormatOK
)
2595 nNumType
= style::NumberingType::ARABIC
;
2596 GetImport().GetMM100UnitConverter().convertNumFormat( nNumType
,
2601 nNumType
= style::NumberingType::PAGE_DESCRIPTOR
;
2603 xPropertySet
->setPropertyValue(sPropertyNumberingType
, aAny
);
2607 const sal_Char
* XMLCountFieldImportContext::MapTokenToServiceName(
2610 const sal_Char
* pServiceName
= NULL
;
2614 case XML_TOK_TEXT_WORD_COUNT
:
2615 pServiceName
= sAPI_word_count
;
2617 case XML_TOK_TEXT_PARAGRAPH_COUNT
:
2618 pServiceName
= sAPI_paragraph_count
;
2620 case XML_TOK_TEXT_TABLE_COUNT
:
2621 pServiceName
= sAPI_table_count
;
2623 case XML_TOK_TEXT_CHARACTER_COUNT
:
2624 pServiceName
= sAPI_character_count
;
2626 case XML_TOK_TEXT_IMAGE_COUNT
:
2627 pServiceName
= sAPI_graphic_object_count
;
2629 case XML_TOK_TEXT_OBJECT_COUNT
:
2630 pServiceName
= sAPI_embedded_object_count
;
2632 case XML_TOK_TEXT_PAGE_COUNT
:
2633 pServiceName
= sAPI_page_count
;
2636 pServiceName
= NULL
;
2637 DBG_ERROR("unknown count field!");
2641 return pServiceName
;
2647 // page variable import
2650 TYPEINIT1( XMLPageVarGetFieldImportContext
, XMLTextFieldImportContext
);
2652 XMLPageVarGetFieldImportContext::XMLPageVarGetFieldImportContext(
2653 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
2654 sal_uInt16 nPrfx
, const OUString
& sLocalName
) :
2655 XMLTextFieldImportContext(rImport
, rHlp
, sAPI_reference_page_get
,
2657 sPropertyNumberingType(
2658 RTL_CONSTASCII_USTRINGPARAM(sAPI_numbering_type
)),
2661 bNumberFormatOK(sal_False
)
2666 void XMLPageVarGetFieldImportContext::ProcessAttribute(
2667 sal_uInt16 nAttrToken
,
2668 const OUString
& sAttrValue
)
2672 case XML_TOK_TEXTFIELD_NUM_FORMAT
:
2673 sNumberFormat
= sAttrValue
;
2674 bNumberFormatOK
= sal_True
;
2676 case XML_TOK_TEXTFIELD_NUM_LETTER_SYNC
:
2677 sLetterSync
= sAttrValue
;
2682 void XMLPageVarGetFieldImportContext::PrepareField(
2683 const Reference
<XPropertySet
> & xPropertySet
)
2688 if( bNumberFormatOK
)
2690 nNumType
= style::NumberingType::ARABIC
;
2691 GetImport().GetMM100UnitConverter().convertNumFormat( nNumType
,
2696 nNumType
= style::NumberingType::PAGE_DESCRIPTOR
;
2698 xPropertySet
->setPropertyValue(sPropertyNumberingType
, aAny
);
2700 // display old content (#96657#)
2701 aAny
<<= GetContent();
2702 xPropertySet
->setPropertyValue(
2703 OUString(RTL_CONSTASCII_USTRINGPARAM(sAPI_current_presentation
)),
2710 // page variable set fields
2713 TYPEINIT1(XMLPageVarSetFieldImportContext
, XMLTextFieldImportContext
);
2715 XMLPageVarSetFieldImportContext::XMLPageVarSetFieldImportContext(
2716 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
, sal_uInt16 nPrfx
,
2717 const OUString
& sLocalName
) :
2718 XMLTextFieldImportContext(rImport
, rHlp
, sAPI_reference_page_set
,
2720 sPropertyOn(RTL_CONSTASCII_USTRINGPARAM(sAPI_on
)),
2721 sPropertyOffset(RTL_CONSTASCII_USTRINGPARAM(sAPI_offset
)),
2728 void XMLPageVarSetFieldImportContext::ProcessAttribute(
2729 sal_uInt16 nAttrToken
,
2730 const ::rtl::OUString
& sAttrValue
)
2734 case XML_TOK_TEXTFIELD_ACTIVE
:
2737 if (SvXMLUnitConverter::convertBool(bTmp
, sAttrValue
))
2742 case XML_TOK_TEXTFIELD_PAGE_ADJUST
:
2745 if (SvXMLUnitConverter::convertNumber(nTmp
, sAttrValue
))
2747 nAdjust
= (sal_Int16
)nTmp
;
2753 void XMLPageVarSetFieldImportContext::PrepareField(
2754 const Reference
<XPropertySet
> & xPropertySet
)
2758 aAny
.setValue(&bActive
, ::getBooleanCppuType());
2759 xPropertySet
->setPropertyValue(sPropertyOn
, aAny
);
2762 xPropertySet
->setPropertyValue(sPropertyOffset
, aAny
);
2771 TYPEINIT1( XMLMacroFieldImportContext
, XMLTextFieldImportContext
);
2773 XMLMacroFieldImportContext::XMLMacroFieldImportContext(
2774 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
, sal_uInt16 nPrfx
,
2775 const OUString
& sLocalName
) :
2776 XMLTextFieldImportContext(rImport
, rHlp
, sAPI_macro
,
2778 sPropertyHint(RTL_CONSTASCII_USTRINGPARAM(sAPI_hint
)),
2779 sPropertyMacroName(RTL_CONSTASCII_USTRINGPARAM("MacroName")),
2780 sPropertyScriptURL(RTL_CONSTASCII_USTRINGPARAM("ScriptURL")),
2781 bDescriptionOK(sal_False
)
2785 SvXMLImportContext
* XMLMacroFieldImportContext::CreateChildContext(
2787 const OUString
& rLocalName
,
2788 const Reference
<XAttributeList
> & xAttrList
)
2790 SvXMLImportContext
* pContext
= NULL
;
2792 if ( (nPrefix
== XML_NAMESPACE_OFFICE
) &&
2793 IsXMLToken( rLocalName
, XML_EVENT_LISTENERS
) )
2795 // create events context and remember it!
2796 pContext
= new XMLEventsImportContext(
2797 GetImport(), nPrefix
, rLocalName
);
2798 xEventContext
= pContext
;
2802 pContext
= SvXMLImportContext::CreateChildContext(
2803 nPrefix
, rLocalName
, xAttrList
);
2809 void XMLMacroFieldImportContext::ProcessAttribute(
2810 sal_uInt16 nAttrToken
,
2811 const OUString
& sAttrValue
)
2815 case XML_TOK_TEXTFIELD_DESCRIPTION
:
2816 sDescription
= sAttrValue
;
2817 bDescriptionOK
= sal_True
;
2819 case XML_TOK_TEXTFIELD_NAME
:
2820 sMacro
= sAttrValue
;
2826 void XMLMacroFieldImportContext::PrepareField(
2827 const Reference
<XPropertySet
> & xPropertySet
)
2831 OUString
sOnClick(RTL_CONSTASCII_USTRINGPARAM("OnClick"));
2832 OUString
sPropertyMacroLibrary(RTL_CONSTASCII_USTRINGPARAM("MacroLibrary"));
2834 aAny
<<= (bDescriptionOK
? sDescription
: GetContent());
2835 xPropertySet
->setPropertyValue(sPropertyHint
, aAny
);
2837 // if we have an events child element, we'll look for the OnClick
2838 // event if not, it may be an old (pre-638i) document. Then, we'll
2839 // have to look at the name attribute.
2840 OUString sMacroName
;
2841 OUString sLibraryName
;
2842 OUString sScriptURL
;
2844 if ( xEventContext
.Is() )
2846 // get event sequence
2847 XMLEventsImportContext
* pEvents
=
2848 (XMLEventsImportContext
*)&xEventContext
;
2849 Sequence
<PropertyValue
> aValues
;
2850 pEvents
->GetEventSequence( sOnClick
, aValues
);
2852 sal_Int32 nLength
= aValues
.getLength();
2853 for( sal_Int32 i
= 0; i
< nLength
; i
++ )
2855 if ( aValues
[i
].Name
.equalsAsciiL( "ScriptType",
2856 sizeof("ScriptType")-1 ) )
2858 // ignore ScriptType
2860 else if ( aValues
[i
].Name
.equalsAsciiL( "Library",
2861 sizeof("Library")-1 ) )
2863 aValues
[i
].Value
>>= sLibraryName
;
2865 else if ( aValues
[i
].Name
.equalsAsciiL( "MacroName",
2866 sizeof("MacroName")-1 ) )
2868 aValues
[i
].Value
>>= sMacroName
;
2870 if ( aValues
[i
].Name
.equalsAsciiL( "Script",
2871 sizeof("Script")-1 ) )
2873 aValues
[i
].Value
>>= sScriptURL
;
2879 // disassemble old-style macro-name: Everything before the
2880 // third-last dot is the library
2881 sal_Int32 nPos
= sMacro
.getLength() + 1; // the loop starts with nPos--
2882 const sal_Unicode
* pBuf
= sMacro
.getStr();
2883 for( sal_Int32 i
= 0; (i
< 3) && (nPos
> 0); i
++ )
2886 while ( (pBuf
[nPos
] != '.') && (nPos
> 0) )
2892 sLibraryName
= sMacro
.copy(0, nPos
);
2893 sMacroName
= sMacro
.copy(nPos
+1);
2896 sMacroName
= sMacro
;
2899 aAny
<<= sScriptURL
;
2900 xPropertySet
->setPropertyValue(sPropertyScriptURL
, aAny
);
2902 aAny
<<= sMacroName
;
2903 xPropertySet
->setPropertyValue(sPropertyMacroName
, aAny
);
2905 aAny
<<= sLibraryName
;
2906 xPropertySet
->setPropertyValue(sPropertyMacroLibrary
, aAny
);
2912 // reference field import
2915 TYPEINIT1( XMLReferenceFieldImportContext
, XMLTextFieldImportContext
);
2917 XMLReferenceFieldImportContext::XMLReferenceFieldImportContext(
2918 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
2919 sal_uInt16 nToken
, sal_uInt16 nPrfx
, const OUString
& sLocalName
)
2920 : XMLTextFieldImportContext(rImport
, rHlp
, sAPI_get_reference
, nPrfx
, sLocalName
)
2921 , sPropertyReferenceFieldPart(RTL_CONSTASCII_USTRINGPARAM(sAPI_reference_field_part
))
2922 , sPropertyReferenceFieldSource(RTL_CONSTASCII_USTRINGPARAM(sAPI_reference_field_source
))
2923 , sPropertySourceName(RTL_CONSTASCII_USTRINGPARAM(sAPI_source_name
))
2924 , sPropertyCurrentPresentation(RTL_CONSTASCII_USTRINGPARAM(sAPI_current_presentation
))
2925 , nElementToken(nToken
)
2926 , nType(ReferenceFieldPart::PAGE_DESC
)
2927 , bNameOK(sal_False
)
2928 , bTypeOK(sal_False
)
2929 , bSeqNumberOK(sal_False
)
2933 static SvXMLEnumMapEntry __READONLY_DATA lcl_aReferenceTypeTokenMap
[] =
2935 { XML_PAGE
, ReferenceFieldPart::PAGE
},
2936 { XML_CHAPTER
, ReferenceFieldPart::CHAPTER
},
2937 { XML_TEXT
, ReferenceFieldPart::TEXT
},
2938 { XML_DIRECTION
, ReferenceFieldPart::UP_DOWN
},
2939 { XML_CATEGORY_AND_VALUE
, ReferenceFieldPart::CATEGORY_AND_NUMBER
},
2940 { XML_CAPTION
, ReferenceFieldPart::ONLY_CAPTION
},
2941 { XML_VALUE
, ReferenceFieldPart::ONLY_SEQUENCE_NUMBER
},
2942 // --> OD 2007-09-14 #i81002#
2943 { XML_NUMBER
, ReferenceFieldPart::NUMBER
},
2944 { XML_NUMBER_NO_SUPERIOR
, ReferenceFieldPart::NUMBER_NO_CONTEXT
},
2945 { XML_NUMBER_ALL_SUPERIOR
, ReferenceFieldPart::NUMBER_FULL_CONTEXT
},
2947 { XML_TOKEN_INVALID
, 0 }
2950 void XMLReferenceFieldImportContext::StartElement(
2951 const Reference
<XAttributeList
> & xAttrList
)
2954 switch (nElementToken
)
2956 case XML_TOK_TEXT_REFERENCE_REF
:
2957 nSource
= ReferenceFieldSource::REFERENCE_MARK
;
2959 case XML_TOK_TEXT_BOOKMARK_REF
:
2960 nSource
= ReferenceFieldSource::BOOKMARK
;
2962 case XML_TOK_TEXT_NOTE_REF
:
2963 nSource
= ReferenceFieldSource::FOOTNOTE
;
2965 case XML_TOK_TEXT_SEQUENCE_REF
:
2966 nSource
= ReferenceFieldSource::SEQUENCE_FIELD
;
2969 bTypeOK
= sal_False
;
2970 DBG_ERROR("unknown reference field");
2974 XMLTextFieldImportContext::StartElement(xAttrList
);
2978 void XMLReferenceFieldImportContext::ProcessAttribute(
2979 sal_uInt16 nAttrToken
,
2980 const OUString
& sAttrValue
)
2984 case XML_TOK_TEXTFIELD_NOTE_CLASS
:
2985 if( IsXMLToken( sAttrValue
, XML_ENDNOTE
) )
2986 nSource
= ReferenceFieldSource::ENDNOTE
;
2988 case XML_TOK_TEXTFIELD_REF_NAME
:
2992 case XML_TOK_TEXTFIELD_REFERENCE_FORMAT
:
2995 if (SvXMLUnitConverter::convertEnum(nToken
, sAttrValue
,
2996 lcl_aReferenceTypeTokenMap
))
3001 // check for sequence-only-attributes
3002 if ( (XML_TOK_TEXT_SEQUENCE_REF
!= nElementToken
) &&
3003 ( (nType
== ReferenceFieldPart::CATEGORY_AND_NUMBER
) ||
3004 (nType
== ReferenceFieldPart::ONLY_CAPTION
) ||
3005 (nType
== ReferenceFieldPart::ONLY_SEQUENCE_NUMBER
) ) )
3007 nType
= ReferenceFieldPart::PAGE_DESC
;
3014 // bValid: we need proper element type and name
3015 bValid
= bTypeOK
&& bNameOK
;
3018 void XMLReferenceFieldImportContext::PrepareField(
3019 const Reference
<XPropertySet
> & xPropertySet
)
3024 xPropertySet
->setPropertyValue(sPropertyReferenceFieldPart
, aAny
);
3027 xPropertySet
->setPropertyValue(sPropertyReferenceFieldSource
, aAny
);
3029 switch (nElementToken
)
3031 case XML_TOK_TEXT_REFERENCE_REF
:
3032 case XML_TOK_TEXT_BOOKMARK_REF
:
3034 xPropertySet
->setPropertyValue(sPropertySourceName
, aAny
);
3037 case XML_TOK_TEXT_NOTE_REF
:
3038 GetImportHelper().ProcessFootnoteReference(sName
, xPropertySet
);
3041 case XML_TOK_TEXT_SEQUENCE_REF
:
3042 GetImportHelper().ProcessSequenceReference(sName
, xPropertySet
);
3046 aAny
<<= GetContent();
3047 xPropertySet
->setPropertyValue(sPropertyCurrentPresentation
, aAny
);
3053 // field declarations container
3056 enum DdeFieldDeclAttrs
3058 XML_TOK_DDEFIELD_NAME
,
3059 XML_TOK_DDEFIELD_APPLICATION
,
3060 XML_TOK_DDEFIELD_TOPIC
,
3061 XML_TOK_DDEFIELD_ITEM
,
3062 XML_TOK_DDEFIELD_UPDATE
3065 static __FAR_DATA SvXMLTokenMapEntry aDdeDeclAttrTokenMap
[] =
3067 { XML_NAMESPACE_OFFICE
, XML_NAME
, XML_TOK_DDEFIELD_NAME
},
3068 { XML_NAMESPACE_OFFICE
, XML_DDE_APPLICATION
, XML_TOK_DDEFIELD_APPLICATION
},
3069 { XML_NAMESPACE_OFFICE
, XML_DDE_TOPIC
, XML_TOK_DDEFIELD_TOPIC
},
3070 { XML_NAMESPACE_OFFICE
, XML_DDE_ITEM
, XML_TOK_DDEFIELD_ITEM
},
3071 { XML_NAMESPACE_OFFICE
, XML_AUTOMATIC_UPDATE
, XML_TOK_DDEFIELD_UPDATE
},
3075 TYPEINIT1( XMLDdeFieldDeclsImportContext
, SvXMLImportContext
);
3077 XMLDdeFieldDeclsImportContext::XMLDdeFieldDeclsImportContext(
3078 SvXMLImport
& rImport
, sal_uInt16 nPrfx
, const OUString
& sLocalName
) :
3079 SvXMLImportContext(rImport
, nPrfx
, sLocalName
),
3080 aTokenMap(aDdeDeclAttrTokenMap
)
3084 SvXMLImportContext
* XMLDdeFieldDeclsImportContext::CreateChildContext(
3086 const OUString
& rLocalName
,
3087 const Reference
<XAttributeList
> & xAttrList
)
3089 if ( (XML_NAMESPACE_TEXT
== nPrefix
) &&
3090 (IsXMLToken(rLocalName
, XML_DDE_CONNECTION_DECL
)) )
3092 return new XMLDdeFieldDeclImportContext(GetImport(), nPrefix
,
3093 rLocalName
, aTokenMap
);
3097 return SvXMLImportContext::CreateChildContext(nPrefix
,
3106 // import dde field declaration
3109 TYPEINIT1( XMLDdeFieldDeclImportContext
, SvXMLImportContext
);
3111 XMLDdeFieldDeclImportContext::XMLDdeFieldDeclImportContext(
3112 SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
3113 const OUString
& sLocalName
, const SvXMLTokenMap
& rMap
)
3114 : SvXMLImportContext(rImport
, nPrfx
, sLocalName
)
3115 , sPropertyIsAutomaticUpdate(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_automatic_update
))
3116 , sPropertyName(RTL_CONSTASCII_USTRINGPARAM(sAPI_name
))
3117 , sPropertyDDECommandType(RTL_CONSTASCII_USTRINGPARAM(sAPI_dde_command_type
))
3118 , sPropertyDDECommandFile(RTL_CONSTASCII_USTRINGPARAM(sAPI_dde_command_file
))
3119 , sPropertyDDECommandElement(RTL_CONSTASCII_USTRINGPARAM(sAPI_dde_command_element
))
3122 DBG_ASSERT(XML_NAMESPACE_TEXT
== nPrfx
, "wrong prefix");
3123 DBG_ASSERT(IsXMLToken(sLocalName
, XML_DDE_CONNECTION_DECL
), "wrong name");
3126 void XMLDdeFieldDeclImportContext::StartElement(
3127 const Reference
<XAttributeList
> & xAttrList
)
3130 OUString sCommandApplication
;
3131 OUString sCommandTopic
;
3132 OUString sCommandItem
;
3134 sal_Bool bUpdate
= sal_False
;
3135 sal_Bool bNameOK
= sal_False
;
3136 sal_Bool bCommandApplicationOK
= sal_False
;
3137 sal_Bool bCommandTopicOK
= sal_False
;
3138 sal_Bool bCommandItemOK
= sal_False
;
3140 // process attributes
3141 sal_Int16 nLength
= xAttrList
->getLength();
3142 for(sal_Int16 i
=0; i
<nLength
; i
++)
3145 OUString sLocalName
;
3146 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().
3147 GetKeyByAttrName( xAttrList
->getNameByIndex(i
), &sLocalName
);
3149 switch (rTokenMap
.Get(nPrefix
, sLocalName
))
3151 case XML_TOK_DDEFIELD_NAME
:
3152 sName
= xAttrList
->getValueByIndex(i
);
3155 case XML_TOK_DDEFIELD_APPLICATION
:
3156 sCommandApplication
= xAttrList
->getValueByIndex(i
);
3157 bCommandApplicationOK
= sal_True
;
3159 case XML_TOK_DDEFIELD_TOPIC
:
3160 sCommandTopic
= xAttrList
->getValueByIndex(i
);
3161 bCommandTopicOK
= sal_True
;
3163 case XML_TOK_DDEFIELD_ITEM
:
3164 sCommandItem
= xAttrList
->getValueByIndex(i
);
3165 bCommandItemOK
= sal_True
;
3167 case XML_TOK_DDEFIELD_UPDATE
:
3170 if ( SvXMLUnitConverter::convertBool(
3171 bTmp
, xAttrList
->getValueByIndex(i
)) )
3181 if (bNameOK
&& bCommandApplicationOK
&& bCommandTopicOK
&& bCommandItemOK
)
3183 // make service name
3184 OUStringBuffer sBuf
;
3185 sBuf
.appendAscii(sAPI_fieldmaster_prefix
);
3186 sBuf
.appendAscii(sAPI_dde
);
3188 // create DDE TextFieldMaster
3189 Reference
<XMultiServiceFactory
> xFactory(GetImport().GetModel(),
3193 /* #i6432# There might be multiple occurances of one DDE
3194 declaration if it is used in more than one of
3195 header/footer/body. createInstance will throw an exception if we
3196 try to create the second, third, etc. instance of such a
3197 declaration. Thus we ignore the exception. Otherwise this will
3198 lead to an unloadable document. */
3201 Reference
<XInterface
> xIfc
=
3202 xFactory
->createInstance(sBuf
.makeStringAndClear());
3205 Reference
<XPropertySet
> xPropSet( xIfc
, UNO_QUERY
);
3206 if (xPropSet
.is() &&
3207 xPropSet
->getPropertySetInfo()->hasPropertyByName(
3208 sPropertyDDECommandType
))
3213 xPropSet
->setPropertyValue(sPropertyName
, aAny
);
3215 aAny
<<= sCommandApplication
;
3216 xPropSet
->setPropertyValue(sPropertyDDECommandType
, aAny
);
3218 aAny
<<= sCommandTopic
;
3219 xPropSet
->setPropertyValue(sPropertyDDECommandFile
, aAny
);
3221 aAny
<<= sCommandItem
;
3222 xPropSet
->setPropertyValue(sPropertyDDECommandElement
,
3225 aAny
.setValue(&bUpdate
, ::getBooleanCppuType());
3226 xPropSet
->setPropertyValue(sPropertyIsAutomaticUpdate
,
3229 // else: ignore (can't get XPropertySet, or DDE
3230 // properties are not supported)
3234 catch ( const Exception
& )
3250 TYPEINIT1( XMLDdeFieldImportContext
, XMLTextFieldImportContext
);
3252 XMLDdeFieldImportContext::XMLDdeFieldImportContext(
3253 SvXMLImport
& rImport
, XMLTextImportHelper
& rHlp
,
3254 sal_uInt16 nPrfx
, const OUString
& sLocalName
) :
3255 XMLTextFieldImportContext(rImport
, rHlp
, sAPI_dde
,
3258 ,sPropertyContent(RTL_CONSTASCII_USTRINGPARAM(sAPI_content
))
3262 void XMLDdeFieldImportContext::ProcessAttribute(
3263 sal_uInt16 nAttrToken
,
3264 const ::rtl::OUString
& sAttrValue
)
3266 if (XML_TOK_TEXTFIELD_CONNECTION_NAME
== nAttrToken
)
3273 void XMLDdeFieldImportContext::EndElement()
3278 OUStringBuffer sBuf
;
3279 sBuf
.appendAscii(sAPI_fieldmaster_prefix
);
3280 sBuf
.appendAscii(sAPI_dde
);
3281 sBuf
.append(sal_Unicode('.'));
3283 OUString sMasterName
= sBuf
.makeStringAndClear();
3285 Reference
<XTextFieldsSupplier
> xTextFieldsSupp(GetImport().GetModel(),
3287 Reference
<container::XNameAccess
> xFieldMasterNameAccess(
3288 xTextFieldsSupp
->getTextFieldMasters(), UNO_QUERY
);
3290 if (xFieldMasterNameAccess
->hasByName(sMasterName
))
3292 Reference
<XPropertySet
> xMaster
;
3293 Any aAny
= xFieldMasterNameAccess
->getByName(sMasterName
);
3295 //apply the content to the master
3296 xMaster
->setPropertyValue( sPropertyContent
, uno::makeAny( GetContent()));
3297 // master exists: create text field and attach
3298 Reference
<XPropertySet
> xField
;
3299 sBuf
.appendAscii(sAPI_textfield_prefix
);
3300 sBuf
.appendAscii(sAPI_dde
);
3301 if (CreateField(xField
, sBuf
.makeStringAndClear()))
3303 Reference
<XDependentTextField
> xDepTextField(xField
,UNO_QUERY
);
3304 xDepTextField
->attachTextFieldMaster(xMaster
);
3306 // attach field to document
3307 Reference
<XTextContent
> xTextContent(xField
, UNO_QUERY
);
3308 if (xTextContent
.is())
3310 GetImportHelper().InsertTextContent(xTextContent
);
3312 // we're lucky. nothing else to prepare.
3314 // else: fail, because text content could not be created
3316 // else: fail, because field could not be created
3318 // else: fail, because no master was found (faulty document?!)
3320 // not valid: ignore
3323 void XMLDdeFieldImportContext::PrepareField(
3324 const Reference
<XPropertySet
> &)
3326 // empty, since not needed.
3331 // sheet name fields
3334 TYPEINIT1(XMLSheetNameImportContext
, XMLTextFieldImportContext
);
3336 XMLSheetNameImportContext::XMLSheetNameImportContext(
3337 SvXMLImport
& rImport
,
3338 XMLTextImportHelper
& rHlp
,
3340 const OUString
& sLocalName
) :
3341 XMLTextFieldImportContext(rImport
, rHlp
, sAPI_sheet_name
,
3344 bValid
= sal_True
; // always valid!
3347 void XMLSheetNameImportContext::ProcessAttribute(
3349 const ::rtl::OUString
& )
3351 // no attributes -> nothing to be done
3354 void XMLSheetNameImportContext::PrepareField(
3355 const Reference
<XPropertySet
> &)
3357 // no attributes -> nothing to be done
3362 // URL fields (Calc, Impress, Draw)
3365 TYPEINIT1(XMLUrlFieldImportContext
, XMLTextFieldImportContext
);
3367 XMLUrlFieldImportContext::XMLUrlFieldImportContext(
3368 SvXMLImport
& rImport
,
3369 XMLTextImportHelper
& rHlp
,
3371 const OUString
& sLocalName
) :
3372 XMLTextFieldImportContext(rImport
, rHlp
, sAPI_url
,
3374 sPropertyURL(RTL_CONSTASCII_USTRINGPARAM(sAPI_url
)),
3375 sPropertyTargetFrame(RTL_CONSTASCII_USTRINGPARAM(sAPI_target_frame
)),
3376 sPropertyRepresentation(RTL_CONSTASCII_USTRINGPARAM(
3377 sAPI_representation
)),
3382 void XMLUrlFieldImportContext::ProcessAttribute(
3383 sal_uInt16 nAttrToken
,
3384 const OUString
& sAttrValue
)
3388 case XML_TOK_TEXTFIELD_HREF
:
3389 sURL
= GetImport().GetAbsoluteReference( sAttrValue
);
3392 case XML_TOK_TEXTFIELD_TARGET_FRAME
:
3393 sFrame
= sAttrValue
;
3394 bFrameOK
= sal_True
;
3402 void XMLUrlFieldImportContext::PrepareField(
3403 const Reference
<XPropertySet
> & xPropertySet
)
3408 xPropertySet
->setPropertyValue(sPropertyURL
, aAny
);
3413 xPropertySet
->setPropertyValue(sPropertyTargetFrame
, aAny
);
3416 aAny
<<= GetContent();
3417 xPropertySet
->setPropertyValue(sPropertyRepresentation
, aAny
);
3421 TYPEINIT1(XMLBibliographyFieldImportContext
, XMLTextFieldImportContext
);
3424 XMLBibliographyFieldImportContext::XMLBibliographyFieldImportContext(
3425 SvXMLImport
& rImport
,
3426 XMLTextImportHelper
& rHlp
,
3428 const OUString
& sLocalName
) :
3429 XMLTextFieldImportContext(rImport
, rHlp
, sAPI_bibliography
,
3431 sPropertyFields(RTL_CONSTASCII_USTRINGPARAM("Fields")),
3437 // TODO: this is the same map as is used in the text field export
3438 SvXMLEnumMapEntry __READONLY_DATA aBibliographyDataTypeMap
[] =
3440 { XML_ARTICLE
, BibliographyDataType::ARTICLE
},
3441 { XML_BOOK
, BibliographyDataType::BOOK
},
3442 { XML_BOOKLET
, BibliographyDataType::BOOKLET
},
3443 { XML_CONFERENCE
, BibliographyDataType::CONFERENCE
},
3444 { XML_CUSTOM1
, BibliographyDataType::CUSTOM1
},
3445 { XML_CUSTOM2
, BibliographyDataType::CUSTOM2
},
3446 { XML_CUSTOM3
, BibliographyDataType::CUSTOM3
},
3447 { XML_CUSTOM4
, BibliographyDataType::CUSTOM4
},
3448 { XML_CUSTOM5
, BibliographyDataType::CUSTOM5
},
3449 { XML_EMAIL
, BibliographyDataType::EMAIL
},
3450 { XML_INBOOK
, BibliographyDataType::INBOOK
},
3451 { XML_INCOLLECTION
, BibliographyDataType::INCOLLECTION
},
3452 { XML_INPROCEEDINGS
, BibliographyDataType::INPROCEEDINGS
},
3453 { XML_JOURNAL
, BibliographyDataType::JOURNAL
},
3454 { XML_MANUAL
, BibliographyDataType::MANUAL
},
3455 { XML_MASTERSTHESIS
, BibliographyDataType::MASTERSTHESIS
},
3456 { XML_MISC
, BibliographyDataType::MISC
},
3457 { XML_PHDTHESIS
, BibliographyDataType::PHDTHESIS
},
3458 { XML_PROCEEDINGS
, BibliographyDataType::PROCEEDINGS
},
3459 { XML_TECHREPORT
, BibliographyDataType::TECHREPORT
},
3460 { XML_UNPUBLISHED
, BibliographyDataType::UNPUBLISHED
},
3461 { XML_WWW
, BibliographyDataType::WWW
},
3462 { XML_TOKEN_INVALID
, 0 }
3466 // we'll process attributes on our own and forfit the standard
3467 // tecfield mechanism, because our attributes have zero overlp with
3468 // all the oher textfields.
3469 void XMLBibliographyFieldImportContext::StartElement(
3470 const Reference
<XAttributeList
> & xAttrList
)
3472 // iterate over attributes
3473 sal_Int16 nLength
= xAttrList
->getLength();
3474 for(sal_Int16 i
=0; i
<nLength
; i
++) {
3476 OUString sLocalName
;
3477 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().
3478 GetKeyByAttrName( xAttrList
->getNameByIndex(i
), &sLocalName
);
3480 if (nPrefix
== XML_NAMESPACE_TEXT
)
3482 PropertyValue aValue
;
3483 aValue
.Name
= OUString::createFromAscii(
3484 MapBibliographyFieldName(sLocalName
));
3487 // special treatment for bibliography type
3488 // biblio vs bibilio: #96658#; also read old documents
3489 if (IsXMLToken(sLocalName
, XML_BIBILIOGRAPHIC_TYPE
) ||
3490 IsXMLToken(sLocalName
, XML_BIBLIOGRAPHY_TYPE
) )
3493 if (SvXMLUnitConverter::convertEnum(
3494 nTmp
, xAttrList
->getValueByIndex(i
),
3495 aBibliographyDataTypeMap
))
3497 aAny
<<= (sal_Int16
)nTmp
;
3498 aValue
.Value
= aAny
;
3500 aValues
.push_back(aValue
);
3505 aAny
<<= xAttrList
->getValueByIndex(i
);
3506 aValue
.Value
= aAny
;
3508 aValues
.push_back(aValue
);
3511 // else: unknown namespace -> ignore
3515 void XMLBibliographyFieldImportContext::ProcessAttribute(
3519 // attributes are handled in StartElement
3520 DBG_ERROR("This should not have happened.");
3524 void XMLBibliographyFieldImportContext::PrepareField(
3525 const Reference
<XPropertySet
> & xPropertySet
)
3527 // convert vector into sequence
3528 sal_Int32 nCount
= aValues
.size();
3529 Sequence
<PropertyValue
> aValueSequence(nCount
);
3530 for(sal_Int32 i
= 0; i
< nCount
; i
++)
3532 aValueSequence
[i
] = aValues
[i
];
3537 aAny
<<= aValueSequence
;
3538 xPropertySet
->setPropertyValue(sPropertyFields
, aAny
);
3541 const sal_Char
* XMLBibliographyFieldImportContext::MapBibliographyFieldName(
3544 const sal_Char
* pName
= NULL
;
3546 if (IsXMLToken(sName
, XML_IDENTIFIER
))
3548 pName
= "Identifier";
3550 else if (IsXMLToken(sName
, XML_BIBILIOGRAPHIC_TYPE
) ||
3551 IsXMLToken(sName
, XML_BIBLIOGRAPHY_TYPE
) )
3553 // biblio... vs bibilio...: #96658#: also read old documents
3554 pName
= "BibiliographicType";
3556 else if (IsXMLToken(sName
, XML_ADDRESS
))
3560 else if (IsXMLToken(sName
, XML_ANNOTE
))
3564 else if (IsXMLToken(sName
, XML_AUTHOR
))
3568 else if (IsXMLToken(sName
, XML_BOOKTITLE
))
3570 pName
= "Booktitle";
3572 else if (IsXMLToken(sName
, XML_CHAPTER
))
3576 else if (IsXMLToken(sName
, XML_EDITION
))
3580 else if (IsXMLToken(sName
, XML_EDITOR
))
3584 else if (IsXMLToken(sName
, XML_HOWPUBLISHED
))
3586 pName
= "Howpublished";
3588 else if (IsXMLToken(sName
, XML_INSTITUTION
))
3590 pName
= "Institution";
3592 else if (IsXMLToken(sName
, XML_JOURNAL
))
3596 else if (IsXMLToken(sName
, XML_MONTH
))
3600 else if (IsXMLToken(sName
, XML_NOTE
))
3604 else if (IsXMLToken(sName
, XML_NUMBER
))
3608 else if (IsXMLToken(sName
, XML_ORGANIZATIONS
))
3610 pName
= "Organizations";
3612 else if (IsXMLToken(sName
, XML_PAGES
))
3616 else if (IsXMLToken(sName
, XML_PUBLISHER
))
3618 pName
= "Publisher";
3620 else if (IsXMLToken(sName
, XML_SCHOOL
))
3624 else if (IsXMLToken(sName
, XML_SERIES
))
3628 else if (IsXMLToken(sName
, XML_TITLE
))
3632 else if (IsXMLToken(sName
, XML_REPORT_TYPE
))
3634 pName
= "Report_Type";
3636 else if (IsXMLToken(sName
, XML_VOLUME
))
3640 else if (IsXMLToken(sName
, XML_YEAR
))
3644 else if (IsXMLToken(sName
, XML_URL
))
3648 else if (IsXMLToken(sName
, XML_CUSTOM1
))
3652 else if (IsXMLToken(sName
, XML_CUSTOM2
))
3656 else if (IsXMLToken(sName
, XML_CUSTOM3
))
3660 else if (IsXMLToken(sName
, XML_CUSTOM4
))
3664 else if (IsXMLToken(sName
, XML_CUSTOM5
))
3668 else if (IsXMLToken(sName
, XML_ISBN
))
3674 DBG_ERROR("Unknown bibliography info data");
3686 TYPEINIT1(XMLAnnotationImportContext
, XMLTextFieldImportContext
);
3688 XMLAnnotationImportContext::XMLAnnotationImportContext(
3689 SvXMLImport
& rImport
,
3690 XMLTextImportHelper
& rHlp
,
3692 const OUString
& sLocalName
) :
3693 XMLTextFieldImportContext(rImport
, rHlp
, sAPI_annotation
,
3695 sPropertyAuthor(RTL_CONSTASCII_USTRINGPARAM(sAPI_author
)),
3696 sPropertyContent(RTL_CONSTASCII_USTRINGPARAM(sAPI_content
)),
3697 // why is there no UNO_NAME_DATE_TIME, but only UNO_NAME_DATE_TIME_VALUE?
3698 sPropertyDate(RTL_CONSTASCII_USTRINGPARAM(sAPI_date_time_value
)),
3699 sPropertyTextRange(RTL_CONSTASCII_USTRINGPARAM(sAPI_TextRange
))
3703 // remember old list item and block (#91964#) and reset them
3704 // for the text frame
3705 // do this in the constructor, not in CreateChildContext (#i93392#)
3706 GetImport().GetTextImport()->PushListContext();
3709 void XMLAnnotationImportContext::ProcessAttribute(
3716 SvXMLImportContext
* XMLAnnotationImportContext::CreateChildContext(
3718 const OUString
& rLocalName
,
3719 const Reference
<XAttributeList
>& xAttrList
)
3721 SvXMLImportContext
*pContext
= 0;
3722 if( XML_NAMESPACE_DC
== nPrefix
)
3724 if( IsXMLToken( rLocalName
, XML_CREATOR
) )
3725 pContext
= new XMLStringBufferImportContext(GetImport(), nPrefix
,
3726 rLocalName
, aAuthorBuffer
);
3727 else if( IsXMLToken( rLocalName
, XML_DATE
) )
3728 pContext
= new XMLStringBufferImportContext(GetImport(), nPrefix
,
3729 rLocalName
, aDateBuffer
);
3736 if ( !mxField
.is() )
3737 CreateField( mxField
, sServicePrefix
+ GetServiceName() );
3738 Any aAny
= mxField
->getPropertyValue( sPropertyTextRange
);
3739 Reference
< XText
> xText
;
3743 UniReference
< XMLTextImportHelper
> xTxtImport
= GetImport().GetTextImport();
3744 if( !mxCursor
.is() )
3746 mxOldCursor
= xTxtImport
->GetCursor();
3747 mxCursor
= xText
->createTextCursor();
3752 xTxtImport
->SetCursor( mxCursor
);
3753 pContext
= xTxtImport
->CreateTextChildContext( GetImport(), nPrefix
, rLocalName
, xAttrList
);
3757 catch ( Exception
& )
3761 pContext
= new XMLStringBufferImportContext(GetImport(), nPrefix
, rLocalName
, aTextBuffer
);
3767 void XMLAnnotationImportContext::EndElement()
3769 DBG_ASSERT(GetServiceName().getLength()>0, "no service name for element!");
3772 // delete addition newline
3773 const OUString aEmpty
;
3774 mxCursor
->gotoEnd( sal_False
);
3775 mxCursor
->goLeft( 1, sal_True
);
3776 mxCursor
->setString( aEmpty
);
3779 GetImport().GetTextImport()->ResetCursor();
3782 if( mxOldCursor
.is() )
3783 GetImport().GetTextImport()->SetCursor( mxOldCursor
);
3785 // reinstall old list item #91964#
3786 GetImport().GetTextImport()->PopListContext();
3790 if ( mxField
.is() || CreateField( mxField
, sServicePrefix
+ GetServiceName() ) )
3792 // set field properties
3793 PrepareField( mxField
);
3795 // attach field to document
3796 Reference
< XTextContent
> xTextContent( mxField
, UNO_QUERY
);
3798 // workaround for #80606#
3801 GetImportHelper().InsertTextContent( xTextContent
);
3803 catch (lang::IllegalArgumentException
)
3810 GetImportHelper().InsertString(GetContent());
3813 void XMLAnnotationImportContext::PrepareField(
3814 const Reference
<XPropertySet
> & xPropertySet
)
3816 // import (possibly empty) author
3817 OUString
sAuthor( aAuthorBuffer
.makeStringAndClear() );
3818 xPropertySet
->setPropertyValue(sPropertyAuthor
, makeAny(sAuthor
));
3821 if (SvXMLUnitConverter::convertDateTime(aDateTime
,
3822 aDateBuffer
.makeStringAndClear()))
3826 aDate.Year = aDateTime.Year;
3827 aDate.Month = aDateTime.Month;
3828 aDate.Day = aDateTime.Day;
3829 xPropertySet->setPropertyValue(sPropertyDate, makeAny(aDate));
3831 xPropertySet
->setPropertyValue(sPropertyDate
, makeAny(aDateTime
));
3834 OUString sBuffer
= aTextBuffer
.makeStringAndClear();
3835 if ( sBuffer
.getLength() )
3837 // delete last paragraph mark (if necessary)
3838 if (sal_Char(0x0a) == sBuffer
.getStr()[sBuffer
.getLength()-1])
3839 sBuffer
= sBuffer
.copy(0, sBuffer
.getLength()-1);
3840 xPropertySet
->setPropertyValue(sPropertyContent
, makeAny(sBuffer
));
3850 TYPEINIT1(XMLScriptImportContext
, XMLTextFieldImportContext
);
3852 XMLScriptImportContext::XMLScriptImportContext(
3853 SvXMLImport
& rImport
,
3854 XMLTextImportHelper
& rHlp
,
3856 const OUString
& sLocalName
)
3857 : XMLTextFieldImportContext(rImport
, rHlp
, sAPI_script
, nPrfx
, sLocalName
)
3858 , sPropertyScriptType(RTL_CONSTASCII_USTRINGPARAM(sAPI_script_type
))
3859 , sPropertyURLContent(RTL_CONSTASCII_USTRINGPARAM(sAPI_url_content
))
3860 , sPropertyContent(RTL_CONSTASCII_USTRINGPARAM(sAPI_content
))
3861 , bContentOK(sal_False
)
3862 , bScriptTypeOK(sal_False
)
3863 , bUrlContent(sal_False
)
3867 void XMLScriptImportContext::ProcessAttribute(
3868 sal_uInt16 nAttrToken
,
3869 const OUString
& sAttrValue
)
3873 case XML_TOK_TEXTFIELD_HREF
:
3874 sContent
= GetImport().GetAbsoluteReference( sAttrValue
);
3875 bContentOK
= sal_True
;
3878 case XML_TOK_TEXTFIELD_LANGUAGE
:
3879 sScriptType
= sAttrValue
;
3880 bScriptTypeOK
= sal_True
;
3888 // always valid (even without ScriptType; cf- #96531#)
3892 void XMLScriptImportContext::PrepareField(
3893 const Reference
<XPropertySet
> & xPropertySet
)
3897 // if href attribute was present, we use it. Else we use element content
3900 sContent
= GetContent();
3903 xPropertySet
->setPropertyValue(sPropertyContent
, aAny
);
3905 // URL or script text? We use URL if we have an href-attribute
3906 aAny
.setValue(&bContentOK
, ::getBooleanCppuType());
3907 xPropertySet
->setPropertyValue(sPropertyURLContent
, aAny
);
3909 aAny
<<= sScriptType
;
3910 xPropertySet
->setPropertyValue(sPropertyScriptType
, aAny
);
3917 TYPEINIT1(XMLMeasureFieldImportContext
, XMLTextFieldImportContext
);
3919 XMLMeasureFieldImportContext::XMLMeasureFieldImportContext(
3920 SvXMLImport
& rImport
,
3921 XMLTextImportHelper
& rHlp
,
3923 const OUString
& sLocalName
) :
3924 XMLTextFieldImportContext(rImport
, rHlp
, sAPI_measure
,
3930 void XMLMeasureFieldImportContext::ProcessAttribute(
3931 sal_uInt16 nAttrToken
,
3932 const OUString
& sAttrValue
)
3936 case XML_TOK_TEXTFIELD_MEASURE_KIND
:
3937 if( IsXMLToken( sAttrValue
, XML_VALUE
) )
3939 mnKind
= 0; bValid
= sal_True
;
3941 else if( IsXMLToken( sAttrValue
, XML_UNIT
) )
3943 mnKind
= 1; bValid
= sal_True
;
3945 else if( IsXMLToken( sAttrValue
, XML_GAP
) )
3947 mnKind
= 2; bValid
= sal_True
;
3953 void XMLMeasureFieldImportContext::PrepareField(
3954 const Reference
<XPropertySet
> & xPropertySet
)
3958 xPropertySet
->setPropertyValue(OUString::createFromAscii("Kind"), aAny
);
3968 TYPEINIT1( XMLDropDownFieldImportContext
, XMLTextFieldImportContext
);
3970 XMLDropDownFieldImportContext::XMLDropDownFieldImportContext(
3971 SvXMLImport
& rImport
,
3972 XMLTextImportHelper
& rHlp
,
3974 const ::rtl::OUString
& sLocalName
) :
3975 XMLTextFieldImportContext( rImport
, rHlp
, sAPI_drop_down
,
3976 nPrfx
, sLocalName
),
3983 sPropertyItems( RTL_CONSTASCII_USTRINGPARAM( "Items" ) ),
3984 sPropertySelectedItem( RTL_CONSTASCII_USTRINGPARAM( "SelectedItem" ) ),
3985 sPropertyName( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ),
3986 sPropertyHelp( RTL_CONSTASCII_USTRINGPARAM( "Help" ) ),
3987 sPropertyToolTip( RTL_CONSTASCII_USTRINGPARAM( "Tooltip" ) )
3992 bool lcl_ProcessLabel( const SvXMLImport
& rImport
,
3993 const Reference
<XAttributeList
>& xAttrList
,
3997 bool bValid
= false;
3998 sal_Int16 nLength
= xAttrList
->getLength();
3999 for( sal_Int16 n
= 0; n
< nLength
; n
++ )
4001 OUString sLocalName
;
4002 sal_uInt16 nPrefix
= rImport
.GetNamespaceMap().
4003 GetKeyByAttrName( xAttrList
->getNameByIndex(n
), &sLocalName
);
4004 OUString sValue
= xAttrList
->getValueByIndex(n
);
4006 if( nPrefix
== XML_NAMESPACE_TEXT
)
4008 if( IsXMLToken( sLocalName
, XML_VALUE
) )
4013 else if( IsXMLToken( sLocalName
, XML_CURRENT_SELECTED
) )
4016 if( SvXMLUnitConverter::convertBool( bTmp
, sValue
) )
4024 SvXMLImportContext
* XMLDropDownFieldImportContext::CreateChildContext(
4026 const OUString
& rLocalName
,
4027 const Reference
<XAttributeList
>& xAttrList
)
4029 if( nPrefix
== XML_NAMESPACE_TEXT
&&
4030 IsXMLToken( rLocalName
, XML_LABEL
) )
4033 bool bIsSelected
= sal_False
;
4034 if( lcl_ProcessLabel( GetImport(), xAttrList
, sLabel
, bIsSelected
) )
4037 nSelected
= static_cast<sal_Int32
>( aLabels
.size() );
4038 aLabels
.push_back( sLabel
);
4041 return new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
4044 void XMLDropDownFieldImportContext::ProcessAttribute(
4045 sal_uInt16 nAttrToken
,
4046 const ::rtl::OUString
& sAttrValue
)
4048 if( nAttrToken
== XML_TOK_TEXTFIELD_NAME
)
4053 else if (nAttrToken
== XML_TOK_TEXTFIELD_HELP
)
4058 else if (nAttrToken
== XML_TOK_TEXTFIELD_HINT
)
4065 void XMLDropDownFieldImportContext::PrepareField(
4066 const Reference
<XPropertySet
>& xPropertySet
)
4069 sal_Int32 nLength
= static_cast<sal_Int32
>( aLabels
.size() );
4070 Sequence
<OUString
> aSequence( nLength
);
4071 OUString
* pSequence
= aSequence
.getArray();
4072 for( sal_Int32 n
= 0; n
< nLength
; n
++ )
4073 pSequence
[n
] = aLabels
[n
];
4079 xPropertySet
->setPropertyValue( sPropertyItems
, aAny
);
4081 if( nSelected
>= 0 && nSelected
< nLength
)
4083 aAny
<<= pSequence
[nSelected
];
4084 xPropertySet
->setPropertyValue( sPropertySelectedItem
, aAny
);
4091 xPropertySet
->setPropertyValue( sPropertyName
, aAny
);
4097 xPropertySet
->setPropertyValue( sPropertyHelp
, aAny
);
4103 xPropertySet
->setPropertyValue( sPropertyToolTip
, aAny
);
4108 /** import header fields (<draw:header>) */
4109 TYPEINIT1( XMLHeaderFieldImportContext
, XMLTextFieldImportContext
);
4111 XMLHeaderFieldImportContext::XMLHeaderFieldImportContext(
4112 SvXMLImport
& rImport
, /// XML Import
4113 XMLTextImportHelper
& rHlp
, /// Text import helper
4114 sal_uInt16 nPrfx
, /// namespace prefix
4115 const ::rtl::OUString
& sLocalName
) /// element name w/o prefix
4116 : XMLTextFieldImportContext(rImport
, rHlp
, sAPI_header
, nPrfx
, sLocalName
)
4118 sServicePrefix
= OUString::createFromAscii( sAPI_presentation_prefix
);
4122 /// process attribute values
4123 void XMLHeaderFieldImportContext::ProcessAttribute( sal_uInt16
, const ::rtl::OUString
& )
4127 /// prepare XTextField for insertion into document
4128 void XMLHeaderFieldImportContext::PrepareField(const Reference
<XPropertySet
> &)
4132 /** import footer fields (<draw:footer>) */
4133 TYPEINIT1( XMLFooterFieldImportContext
, XMLTextFieldImportContext
);
4135 XMLFooterFieldImportContext::XMLFooterFieldImportContext(
4136 SvXMLImport
& rImport
, /// XML Import
4137 XMLTextImportHelper
& rHlp
, /// Text import helper
4138 sal_uInt16 nPrfx
, /// namespace prefix
4139 const ::rtl::OUString
& sLocalName
) /// element name w/o prefix
4140 : XMLTextFieldImportContext(rImport
, rHlp
, sAPI_footer
, nPrfx
, sLocalName
)
4142 sServicePrefix
= OUString::createFromAscii( sAPI_presentation_prefix
);
4146 /// process attribute values
4147 void XMLFooterFieldImportContext::ProcessAttribute( sal_uInt16
, const ::rtl::OUString
& )
4151 /// prepare XTextField for insertion into document
4152 void XMLFooterFieldImportContext::PrepareField(const Reference
<XPropertySet
> &)
4157 /** import footer fields (<draw:date-and-time>) */
4158 TYPEINIT1( XMLDateTimeFieldImportContext
, XMLTextFieldImportContext
);
4160 XMLDateTimeFieldImportContext::XMLDateTimeFieldImportContext(
4161 SvXMLImport
& rImport
, /// XML Import
4162 XMLTextImportHelper
& rHlp
, /// Text import helper
4163 sal_uInt16 nPrfx
, /// namespace prefix
4164 const ::rtl::OUString
& sLocalName
) /// element name w/o prefix
4165 : XMLTextFieldImportContext(rImport
, rHlp
, sAPI_datetime
, nPrfx
, sLocalName
)
4167 sServicePrefix
= OUString::createFromAscii( sAPI_presentation_prefix
);
4171 /// process attribute values
4172 void XMLDateTimeFieldImportContext::ProcessAttribute( sal_uInt16
,
4173 const ::rtl::OUString
& )
4177 /// prepare XTextField for insertion into document
4178 void XMLDateTimeFieldImportContext::PrepareField(
4179 const ::com::sun::star::uno::Reference
<
4180 ::com::sun::star::beans::XPropertySet
> &)