Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : /** @#file
22 : *
23 : * Import of all text fields except those from txtvfldi.cxx
24 : * (variable related text fields and database display fields)
25 : */
26 : #include "txtfldi.hxx"
27 : #include "txtvfldi.hxx"
28 : #include <xmloff/xmlimp.hxx>
29 : #include <xmloff/xmlnumi.hxx>
30 : #include <xmloff/txtimp.hxx>
31 : #include <xmloff/xmlnmspe.hxx>
32 : #include <xmloff/nmspmap.hxx>
33 : #include <xmloff/xmltoken.hxx>
34 : #include <xmloff/xmluconv.hxx>
35 : #include <xmloff/xmlement.hxx>
36 : #include "XMLStringBufferImportContext.hxx"
37 : #include <xmloff/XMLEventsImportContext.hxx>
38 : #include <com/sun/star/xml/sax/XAttributeList.hpp>
39 : #include <com/sun/star/text/UserDataPart.hpp>
40 : #include <com/sun/star/style/NumberingType.hpp>
41 : #include <com/sun/star/text/PlaceholderType.hpp>
42 : #include <com/sun/star/text/ReferenceFieldPart.hpp>
43 : #include <com/sun/star/text/ReferenceFieldSource.hpp>
44 : #include <com/sun/star/text/XTextField.hpp>
45 : #include <com/sun/star/text/XTextContent.hpp>
46 : #include <com/sun/star/beans/XPropertySet.hpp>
47 : #include <com/sun/star/beans/XPropertySetInfo.hpp>
48 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
49 : #include <com/sun/star/text/XTextFieldsSupplier.hpp>
50 : #include <com/sun/star/text/XDependentTextField.hpp>
51 : #include <com/sun/star/text/SetVariableType.hpp>
52 : #include <com/sun/star/text/FilenameDisplayFormat.hpp>
53 : #include <com/sun/star/text/ChapterFormat.hpp>
54 : #include <com/sun/star/text/TemplateDisplayFormat.hpp>
55 : #include <com/sun/star/beans/PropertyValue.hpp>
56 : #include <com/sun/star/text/BibliographyDataType.hpp>
57 : #include <com/sun/star/text/BibliographyDataField.hpp>
58 : #include <com/sun/star/util/XUpdatable.hpp>
59 : #include <com/sun/star/sdb/CommandType.hpp>
60 :
61 : #include <sax/tools/converter.hxx>
62 :
63 : #include <rtl/ustring.hxx>
64 : #include <rtl/ustrbuf.hxx>
65 : #include <rtl/math.hxx>
66 : #include <tools/debug.hxx>
67 :
68 :
69 :
70 : using namespace ::com::sun::star;
71 : using namespace ::com::sun::star::uno;
72 : using namespace ::com::sun::star::text;
73 : using namespace ::com::sun::star::lang;
74 : using namespace ::com::sun::star::beans;
75 : using namespace ::com::sun::star::document;
76 : using namespace ::com::sun::star::util;
77 : using namespace ::com::sun::star::xml::sax;
78 : using namespace ::xmloff::token;
79 :
80 :
81 :
82 : // SO API string constants
83 :
84 :
85 : // service prefix and service anems
86 : const sal_Char sAPI_textfield_prefix[] = "com.sun.star.text.TextField.";
87 : const sal_Char sAPI_fieldmaster_prefix[] = "com.sun.star.text.FieldMaster.";
88 : const sal_Char sAPI_presentation_prefix[] = "com.sun.star.presentation.TextField.";
89 :
90 : const sal_Char sAPI_extended_user[] = "ExtendedUser";
91 : const sal_Char sAPI_user_data_type[] = "UserDataType";
92 : const sal_Char sAPI_jump_edit[] = "JumpEdit";
93 : const sal_Char sAPI_date_time[] = "DateTime";
94 : const sal_Char sAPI_page_number[] = "PageNumber";
95 : const sal_Char sAPI_database_next[] = "DatabaseNextSet";
96 : const sal_Char sAPI_database_select[] = "DatabaseNumberOfSet";
97 : const sal_Char sAPI_database_number[] = "DatabaseSetNumber";
98 : const sal_Char sAPI_database_name[] = "DatabaseName";
99 : const sal_Char sAPI_docinfo_change_author[] = "DocInfo.ChangeAuthor";
100 : const sal_Char sAPI_docinfo_change_date_time[] = "DocInfo.ChangeDateTime";
101 : const sal_Char sAPI_docinfo_edit_time[] = "DocInfo.EditTime";
102 : const sal_Char sAPI_docinfo_description[] = "DocInfo.Description";
103 : const sal_Char sAPI_docinfo_create_author[] = "DocInfo.CreateAuthor";
104 : const sal_Char sAPI_docinfo_create_date_time[] = "DocInfo.CreateDateTime";
105 : const sal_Char sAPI_docinfo_custom[] = "DocInfo.Custom";
106 : const sal_Char sAPI_docinfo_print_author[] = "DocInfo.PrintAuthor";
107 : const sal_Char sAPI_docinfo_print_date_time[] = "DocInfo.PrintDateTime";
108 : const sal_Char sAPI_docinfo_keywords[] = "DocInfo.KeyWords";
109 : const sal_Char sAPI_docinfo_subject[] = "DocInfo.Subject";
110 : const sal_Char sAPI_docinfo_title[] = "DocInfo.Title";
111 : const sal_Char sAPI_docinfo_revision[] = "DocInfo.Revision";
112 : const sal_Char sAPI_hidden_paragraph[] = "HiddenParagraph";
113 : const sal_Char sAPI_hidden_text[] = "HiddenText";
114 : const sal_Char sAPI_conditional_text[] = "ConditionalText";
115 : const sal_Char sAPI_file_name[] = "FileName";
116 : const sal_Char sAPI_chapter[] = "Chapter";
117 : const sal_Char sAPI_template_name[] = "TemplateName";
118 : const sal_Char sAPI_page_count[] = "PageCount";
119 : const sal_Char sAPI_paragraph_count[] = "ParagraphCount";
120 : const sal_Char sAPI_word_count[] = "WordCount";
121 : const sal_Char sAPI_character_count[] = "CharacterCount";
122 : const sal_Char sAPI_table_count[] = "TableCount";
123 : const sal_Char sAPI_graphic_object_count[] = "GraphicObjectCount";
124 : const sal_Char sAPI_embedded_object_count[] = "EmbeddedObjectCount";
125 : const sal_Char sAPI_reference_page_set[] = "ReferencePageSet";
126 : const sal_Char sAPI_reference_page_get[] = "ReferencePageGet";
127 : const sal_Char sAPI_macro[] = "Macro";
128 : const sal_Char sAPI_dde[] = "DDE";
129 : const sal_Char sAPI_get_reference[] = "GetReference";
130 : const sal_Char sAPI_sheet_name[] = "SheetName";
131 : const sal_Char sAPI_url[] = "URL";
132 : const sal_Char sAPI_bibliography[] = "Bibliography";
133 : const sal_Char sAPI_annotation[] = "Annotation";
134 : const sal_Char sAPI_script[] = "Script";
135 : const sal_Char sAPI_measure[] = "Measure";
136 : const sal_Char sAPI_drop_down[] = "DropDown";
137 : const sal_Char sAPI_header[] = "Header";
138 : const sal_Char sAPI_footer[] = "Footer";
139 : const sal_Char sAPI_datetime[] = "DateTime";
140 :
141 : // property names
142 : const sal_Char sAPI_is_fixed[] = "IsFixed";
143 : const sal_Char sAPI_content[] = "Content";
144 : const sal_Char sAPI_author[] = "Author";
145 : const sal_Char sAPI_initials[] = "Initials";
146 : const sal_Char sAPI_full_name[] = "FullName";
147 : const sal_Char sAPI_place_holder_type[] = "PlaceHolderType";
148 : const sal_Char sAPI_place_holder[] = "PlaceHolder";
149 : const sal_Char sAPI_hint[] = "Hint";
150 : const sal_Char sAPI_name[] = "Name";
151 : const sal_Char sAPI_sub_type[] = "SubType";
152 : const sal_Char sAPI_date_time_value[] = "DateTimeValue";
153 : const sal_Char sAPI_number_format[] = "NumberFormat";
154 : const sal_Char sAPI_user_text[] = "UserText";
155 : const sal_Char sAPI_numbering_type[] = "NumberingType";
156 : const sal_Char sAPI_offset[] = "Offset";
157 : const sal_Char sAPI_data_base_name[] = "DataBaseName";
158 : const sal_Char sAPI_data_base_u_r_l[] = "DataBaseURL";
159 : const sal_Char sAPI_data_table_name[] = "DataTableName";
160 : const sal_Char sAPI_condition[] = "Condition";
161 : const sal_Char sAPI_set_number[] = "SetNumber";
162 : const sal_Char sAPI_true_content[] = "TrueContent";
163 : const sal_Char sAPI_false_content[] = "FalseContent";
164 : const sal_Char sAPI_revision[] = "Revision";
165 : const sal_Char sAPI_file_format[] = "FileFormat";
166 : const sal_Char sAPI_chapter_format[] = "ChapterFormat";
167 : const sal_Char sAPI_level[] = "Level";
168 : const sal_Char sAPI_is_date[] = "IsDate";
169 : const sal_Char sAPI_adjust[] = "Adjust";
170 : const sal_Char sAPI_on[] = "On";
171 : const sal_Char sAPI_is_automatic_update[] = "IsAutomaticUpdate";
172 : const sal_Char sAPI_source_name[] = "SourceName";
173 : const sal_Char sAPI_current_presentation[] = "CurrentPresentation";
174 : const sal_Char sAPI_reference_field_part[] = "ReferenceFieldPart";
175 : const sal_Char sAPI_reference_field_source[] = "ReferenceFieldSource";
176 : const sal_Char sAPI_dde_command_type[] = "DDECommandType";
177 : const sal_Char sAPI_dde_command_file[] = "DDECommandFile";
178 : const sal_Char sAPI_dde_command_element[] = "DDECommandElement";
179 : // sAPI_url: also used as service name
180 : const sal_Char sAPI_target_frame[] = "TargetFrame";
181 : const sal_Char sAPI_representation[] = "Representation";
182 : const sal_Char sAPI_url_content[] = "URLContent";
183 : const sal_Char sAPI_script_type[] = "ScriptType";
184 : const sal_Char sAPI_is_hidden[] = "IsHidden";
185 : const sal_Char sAPI_is_condition_true[] = "IsConditionTrue";
186 : const sal_Char sAPI_data_command_type[] = "DataCommandType";
187 : const sal_Char sAPI_is_fixed_language[] = "IsFixedLanguage";
188 : const sal_Char sAPI_is_visible[] = "IsVisible";
189 : const sal_Char sAPI_TextRange[] = "TextRange";
190 :
191 : const sal_Char sAPI_true[] = "TRUE";
192 :
193 :
194 0 : TYPEINIT1( XMLTextFieldImportContext, SvXMLImportContext);
195 :
196 0 : XMLTextFieldImportContext::XMLTextFieldImportContext(
197 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
198 : const sal_Char* pService,
199 : sal_uInt16 nPrefix, const OUString& rElementName)
200 : : SvXMLImportContext( rImport, nPrefix, rElementName )
201 : , sIsFixed(sAPI_is_fixed)
202 : , rTextImportHelper(rHlp)
203 : , sServicePrefix(sAPI_textfield_prefix)
204 0 : , bValid(sal_False)
205 : {
206 : DBG_ASSERT(NULL != pService, "Need service name!");
207 0 : sServiceName = OUString::createFromAscii(pService);
208 0 : }
209 :
210 0 : void XMLTextFieldImportContext::StartElement(
211 : const Reference<XAttributeList> & xAttrList)
212 : {
213 : // process attributes
214 0 : sal_Int16 nLength = xAttrList->getLength();
215 0 : for(sal_Int16 i=0; i<nLength; i++) {
216 :
217 0 : OUString sLocalName;
218 0 : sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
219 0 : GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName );
220 :
221 0 : ProcessAttribute(rTextImportHelper.GetTextFieldAttrTokenMap().
222 0 : Get(nPrefix, sLocalName),
223 0 : xAttrList->getValueByIndex(i) );
224 0 : }
225 0 : }
226 :
227 0 : XMLTextFieldImportContext::~XMLTextFieldImportContext() {
228 0 : }
229 :
230 0 : OUString XMLTextFieldImportContext::GetContent()
231 : {
232 0 : if (sContent.isEmpty())
233 : {
234 0 : sContent = sContentBuffer.makeStringAndClear();
235 : }
236 :
237 0 : return sContent;
238 : }
239 :
240 0 : void XMLTextFieldImportContext::EndElement()
241 : {
242 : DBG_ASSERT(!GetServiceName().isEmpty(), "no service name for element!");
243 0 : if (bValid)
244 : {
245 :
246 : // create field/Service
247 0 : Reference<XPropertySet> xPropSet;
248 0 : if (CreateField(xPropSet, sServicePrefix + GetServiceName()))
249 : {
250 : // set field properties
251 0 : PrepareField(xPropSet);
252 :
253 : // attach field to document
254 0 : Reference<XTextContent> xTextContent(xPropSet, UNO_QUERY);
255 :
256 : // workaround for #80606#
257 : try
258 : {
259 0 : rTextImportHelper.InsertTextContent(xTextContent);
260 : }
261 0 : catch (const lang::IllegalArgumentException&)
262 : {
263 : // ignore
264 : }
265 0 : return;
266 0 : }
267 : }
268 :
269 : // in case of error: write element content
270 0 : rTextImportHelper.InsertString(GetContent());
271 : }
272 :
273 0 : void XMLTextFieldImportContext::Characters(const OUString& rContent)
274 : {
275 0 : sContentBuffer.append(rContent);
276 0 : }
277 :
278 0 : sal_Bool XMLTextFieldImportContext::CreateField(
279 : Reference<XPropertySet> & xField,
280 : const OUString& rServiceName)
281 : {
282 : // instantiate new XTextField:
283 : // ask import for model, model is factory, ask factory to create service
284 :
285 0 : Reference<XMultiServiceFactory> xFactory(GetImport().GetModel(),UNO_QUERY);
286 0 : if( xFactory.is() )
287 : {
288 0 : Reference<XInterface> xIfc = xFactory->createInstance(rServiceName);
289 0 : if( xIfc.is() )
290 : {
291 0 : Reference<XPropertySet> xTmp( xIfc, UNO_QUERY );
292 :
293 0 : xField = xTmp;
294 : } else {
295 0 : return sal_False; // can't create instance
296 0 : }
297 : } else {
298 0 : return sal_False; // can't get MultiServiceFactory
299 : }
300 :
301 0 : return sal_True;
302 : }
303 :
304 : /// create the appropriate field context from
305 : XMLTextFieldImportContext*
306 0 : XMLTextFieldImportContext::CreateTextFieldImportContext(
307 : SvXMLImport& rImport,
308 : XMLTextImportHelper& rHlp,
309 : sal_uInt16 nPrefix,
310 : const OUString& rName,
311 : sal_uInt16 nToken)
312 : {
313 0 : XMLTextFieldImportContext* pContext = NULL;
314 :
315 0 : switch (nToken)
316 : {
317 : case XML_TOK_TEXT_SENDER_FIRSTNAME:
318 : case XML_TOK_TEXT_SENDER_LASTNAME:
319 : case XML_TOK_TEXT_SENDER_INITIALS:
320 : case XML_TOK_TEXT_SENDER_TITLE:
321 : case XML_TOK_TEXT_SENDER_POSITION:
322 : case XML_TOK_TEXT_SENDER_EMAIL:
323 : case XML_TOK_TEXT_SENDER_PHONE_PRIVATE:
324 : case XML_TOK_TEXT_SENDER_FAX:
325 : case XML_TOK_TEXT_SENDER_COMPANY:
326 : case XML_TOK_TEXT_SENDER_PHONE_WORK:
327 : case XML_TOK_TEXT_SENDER_STREET:
328 : case XML_TOK_TEXT_SENDER_CITY:
329 : case XML_TOK_TEXT_SENDER_POSTAL_CODE:
330 : case XML_TOK_TEXT_SENDER_COUNTRY:
331 : case XML_TOK_TEXT_SENDER_STATE_OR_PROVINCE:
332 : pContext =
333 : new XMLSenderFieldImportContext( rImport, rHlp,
334 0 : nPrefix, rName, nToken );
335 0 : break;
336 :
337 : case XML_TOK_TEXT_AUTHOR_NAME:
338 : case XML_TOK_TEXT_AUTHOR_INITIALS:
339 : pContext =
340 : new XMLAuthorFieldImportContext( rImport, rHlp,
341 0 : nPrefix, rName, nToken );
342 0 : break;
343 :
344 : case XML_TOK_TEXT_PLACEHOLDER:
345 : pContext =
346 : new XMLPlaceholderFieldImportContext( rImport, rHlp,
347 0 : nPrefix, rName);
348 0 : break;
349 : case XML_TOK_TEXT_SEQUENCE:
350 : pContext =
351 : new XMLSequenceFieldImportContext( rImport, rHlp,
352 0 : nPrefix, rName );
353 0 : break;
354 : case XML_TOK_TEXT_TEXT_INPUT:
355 : pContext =
356 : new XMLTextInputFieldImportContext( rImport, rHlp,
357 0 : nPrefix, rName );
358 0 : break;
359 : case XML_TOK_TEXT_EXPRESSION:
360 : pContext =
361 : new XMLExpressionFieldImportContext( rImport, rHlp,
362 0 : nPrefix, rName );
363 0 : break;
364 : case XML_TOK_TEXT_VARIABLE_SET:
365 : pContext =
366 : new XMLVariableSetFieldImportContext( rImport, rHlp,
367 0 : nPrefix, rName );
368 0 : break;
369 : case XML_TOK_TEXT_VARIABLE_INPUT:
370 : pContext =
371 : new XMLVariableInputFieldImportContext( rImport, rHlp,
372 0 : nPrefix, rName );
373 0 : break;
374 : case XML_TOK_TEXT_VARIABLE_GET:
375 : pContext =
376 : new XMLVariableGetFieldImportContext( rImport, rHlp,
377 0 : nPrefix, rName );
378 0 : break;
379 : case XML_TOK_TEXT_USER_FIELD_GET:
380 : pContext = new XMLUserFieldImportContext( rImport, rHlp,
381 0 : nPrefix, rName );
382 0 : break;
383 : case XML_TOK_TEXT_USER_FIELD_INPUT:
384 : pContext = new XMLUserFieldInputImportContext( rImport, rHlp,
385 0 : nPrefix, rName );
386 0 : break;
387 : case XML_TOK_TEXT_TIME:
388 : pContext = new XMLTimeFieldImportContext( rImport, rHlp,
389 0 : nPrefix, rName );
390 0 : break;
391 : case XML_TOK_TEXT_PAGE_CONTINUATION_STRING:
392 : case XML_TOK_TEXT_PAGE_CONTINUATION:
393 : pContext = new XMLPageContinuationImportContext( rImport, rHlp,
394 0 : nPrefix, rName );
395 0 : break;
396 :
397 : case XML_TOK_TEXT_PAGE_NUMBER:
398 : pContext = new XMLPageNumberImportContext( rImport, rHlp,
399 0 : nPrefix, rName );
400 0 : break;
401 :
402 : case XML_TOK_TEXT_DATE:
403 : pContext = new XMLDateFieldImportContext( rImport, rHlp,
404 0 : nPrefix, rName );
405 0 : break;
406 :
407 : case XML_TOK_TEXT_DATABASE_NAME:
408 : pContext = new XMLDatabaseNameImportContext( rImport, rHlp,
409 0 : nPrefix, rName );
410 0 : break;
411 : case XML_TOK_TEXT_DATABASE_NEXT:
412 : pContext = new XMLDatabaseNextImportContext( rImport, rHlp,
413 0 : nPrefix, rName );
414 0 : break;
415 : case XML_TOK_TEXT_DATABASE_SELECT:
416 : pContext = new XMLDatabaseSelectImportContext( rImport, rHlp,
417 0 : nPrefix, rName );
418 0 : break;
419 : case XML_TOK_TEXT_DATABASE_ROW_NUMBER:
420 : pContext = new XMLDatabaseNumberImportContext( rImport, rHlp,
421 0 : nPrefix, rName );
422 0 : break;
423 : case XML_TOK_TEXT_DATABASE_DISPLAY:
424 : pContext = new XMLDatabaseDisplayImportContext( rImport, rHlp,
425 0 : nPrefix, rName );
426 0 : break;
427 : case XML_TOK_TEXT_CONDITIONAL_TEXT:
428 : pContext = new XMLConditionalTextImportContext( rImport, rHlp,
429 0 : nPrefix, rName );
430 0 : break;
431 : case XML_TOK_TEXT_HIDDEN_TEXT:
432 : pContext = new XMLHiddenTextImportContext( rImport, rHlp,
433 0 : nPrefix, rName );
434 0 : break;
435 : case XML_TOK_TEXT_HIDDEN_PARAGRAPH:
436 : pContext = new XMLHiddenParagraphImportContext( rImport, rHlp,
437 0 : nPrefix, rName );
438 0 : break;
439 : case XML_TOK_TEXT_DOCUMENT_DESCRIPTION:
440 : case XML_TOK_TEXT_DOCUMENT_TITLE:
441 : case XML_TOK_TEXT_DOCUMENT_SUBJECT:
442 : case XML_TOK_TEXT_DOCUMENT_KEYWORDS:
443 : pContext = new XMLSimpleDocInfoImportContext( rImport, rHlp,
444 : nPrefix, rName,
445 : nToken, sal_True,
446 0 : sal_False );
447 0 : break;
448 : case XML_TOK_TEXT_DOCUMENT_CREATION_AUTHOR:
449 : case XML_TOK_TEXT_DOCUMENT_PRINT_AUTHOR:
450 : case XML_TOK_TEXT_DOCUMENT_SAVE_AUTHOR:
451 : pContext = new XMLSimpleDocInfoImportContext( rImport, rHlp,
452 : nPrefix, rName,
453 : nToken, sal_False,
454 0 : sal_True );
455 0 : break;
456 :
457 : case XML_TOK_TEXT_DOCUMENT_CREATION_DATE:
458 : case XML_TOK_TEXT_DOCUMENT_CREATION_TIME:
459 : case XML_TOK_TEXT_DOCUMENT_PRINT_DATE:
460 : case XML_TOK_TEXT_DOCUMENT_PRINT_TIME:
461 : case XML_TOK_TEXT_DOCUMENT_SAVE_DATE:
462 : case XML_TOK_TEXT_DOCUMENT_SAVE_TIME:
463 : case XML_TOK_TEXT_DOCUMENT_EDIT_DURATION:
464 : pContext = new XMLDateTimeDocInfoImportContext( rImport, rHlp,
465 : nPrefix, rName,
466 0 : nToken );
467 0 : break;
468 :
469 : case XML_TOK_TEXT_DOCUMENT_REVISION:
470 : pContext = new XMLRevisionDocInfoImportContext( rImport, rHlp,
471 : nPrefix, rName,
472 0 : nToken );
473 0 : break;
474 :
475 : case XML_TOK_TEXT_DOCUMENT_USER_DEFINED:
476 : pContext = new XMLUserDocInfoImportContext( rImport, rHlp,
477 : nPrefix, rName,
478 0 : nToken );
479 0 : break;
480 :
481 : case XML_TOK_TEXT_FILENAME:
482 : pContext = new XMLFileNameImportContext( rImport, rHlp,
483 0 : nPrefix, rName );
484 0 : break;
485 :
486 : case XML_TOK_TEXT_CHAPTER:
487 : pContext = new XMLChapterImportContext( rImport, rHlp,
488 0 : nPrefix, rName );
489 0 : break;
490 :
491 : case XML_TOK_TEXT_TEMPLATENAME:
492 : pContext = new XMLTemplateNameImportContext( rImport, rHlp,
493 0 : nPrefix, rName );
494 0 : break;
495 :
496 : case XML_TOK_TEXT_WORD_COUNT:
497 : case XML_TOK_TEXT_PARAGRAPH_COUNT:
498 : case XML_TOK_TEXT_TABLE_COUNT:
499 : case XML_TOK_TEXT_CHARACTER_COUNT:
500 : case XML_TOK_TEXT_IMAGE_COUNT:
501 : case XML_TOK_TEXT_OBJECT_COUNT:
502 : case XML_TOK_TEXT_PAGE_COUNT:
503 : pContext = new XMLCountFieldImportContext( rImport, rHlp,
504 0 : nPrefix, rName, nToken);
505 0 : break;
506 :
507 : case XML_TOK_TEXT_GET_PAGE_VAR:
508 : pContext = new XMLPageVarGetFieldImportContext( rImport, rHlp,
509 0 : nPrefix, rName );
510 0 : break;
511 :
512 : case XML_TOK_TEXT_SET_PAGE_VAR:
513 : pContext = new XMLPageVarSetFieldImportContext( rImport, rHlp,
514 0 : nPrefix, rName );
515 0 : break;
516 :
517 : case XML_TOK_TEXT_MACRO:
518 : pContext = new XMLMacroFieldImportContext( rImport, rHlp,
519 0 : nPrefix, rName );
520 0 : break;
521 :
522 : case XML_TOK_TEXT_DDE:
523 : pContext = new XMLDdeFieldImportContext( rImport, rHlp,
524 0 : nPrefix, rName );
525 0 : break;
526 :
527 : case XML_TOK_TEXT_REFERENCE_REF:
528 : case XML_TOK_TEXT_BOOKMARK_REF:
529 : case XML_TOK_TEXT_NOTE_REF:
530 : case XML_TOK_TEXT_SEQUENCE_REF:
531 : pContext = new XMLReferenceFieldImportContext( rImport, rHlp,
532 : nToken,
533 0 : nPrefix, rName );
534 0 : break;
535 :
536 : case XML_TOK_TEXT_SHEET_NAME:
537 : pContext = new XMLSheetNameImportContext( rImport, rHlp,
538 0 : nPrefix, rName );
539 0 : break;
540 :
541 : case XML_TOK_TEXT_BIBLIOGRAPHY_MARK:
542 : pContext = new XMLBibliographyFieldImportContext( rImport, rHlp,
543 0 : nPrefix, rName );
544 0 : break;
545 :
546 : case XML_TOK_TEXT_ANNOTATION:
547 : case XML_TOK_TEXT_ANNOTATION_END:
548 : pContext = new XMLAnnotationImportContext( rImport, rHlp,
549 : nToken,
550 0 : nPrefix, rName);
551 0 : break;
552 :
553 : case XML_TOK_TEXT_SCRIPT:
554 : pContext = new XMLScriptImportContext( rImport, rHlp,
555 0 : nPrefix, rName);
556 0 : break;
557 :
558 : case XML_TOK_TEXT_MEASURE:
559 : pContext = new XMLMeasureFieldImportContext( rImport, rHlp,
560 0 : nPrefix, rName );
561 0 : break;
562 :
563 : case XML_TOK_TEXT_TABLE_FORMULA:
564 : pContext = new XMLTableFormulaImportContext( rImport, rHlp,
565 0 : nPrefix, rName );
566 0 : break;
567 : case XML_TOK_TEXT_DROPDOWN:
568 : pContext = new XMLDropDownFieldImportContext( rImport, rHlp,
569 0 : nPrefix, rName );
570 0 : break;
571 : case XML_TOK_DRAW_HEADER:
572 : pContext = new XMLHeaderFieldImportContext( rImport, rHlp,
573 0 : nPrefix, rName );
574 0 : break;
575 : case XML_TOK_DRAW_FOOTER:
576 : pContext = new XMLFooterFieldImportContext( rImport, rHlp,
577 0 : nPrefix, rName );
578 0 : break;
579 : case XML_TOK_DRAW_DATE_TIME:
580 : pContext = new XMLDateTimeFieldImportContext( rImport, rHlp,
581 0 : nPrefix, rName );
582 0 : break;
583 :
584 : default:
585 : // ignore! May not even be a textfield.
586 : // (Reminder: This method is called inside default:-branch)
587 0 : pContext = NULL;
588 0 : break;
589 : }
590 :
591 0 : return pContext;
592 : }
593 :
594 :
595 0 : void XMLTextFieldImportContext::ForceUpdate(
596 : const Reference<XPropertySet> & rPropertySet)
597 : {
598 : // force update
599 0 : Reference<XUpdatable> xUpdate(rPropertySet, UNO_QUERY);
600 0 : if (xUpdate.is())
601 : {
602 0 : xUpdate->update();
603 : }
604 : else
605 : {
606 : OSL_FAIL("Expected XUpdatable support!");
607 0 : }
608 0 : }
609 :
610 :
611 :
612 :
613 : // XMLSenderFieldImportContext
614 :
615 :
616 0 : TYPEINIT1( XMLSenderFieldImportContext, XMLTextFieldImportContext);
617 :
618 0 : XMLSenderFieldImportContext::XMLSenderFieldImportContext(
619 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
620 : sal_uInt16 nPrfx, const OUString& sLocalName,
621 : sal_uInt16 nToken)
622 : : XMLTextFieldImportContext(rImport, rHlp, sAPI_extended_user,nPrfx, sLocalName)
623 : , nSubType(0)
624 : , sPropertyFixed(sAPI_is_fixed)
625 : , sPropertyFieldSubType(sAPI_user_data_type)
626 : , sPropertyContent(sAPI_content)
627 : , bFixed(sal_True)
628 0 : , nElementToken(nToken)
629 : {
630 0 : }
631 :
632 0 : void XMLSenderFieldImportContext::StartElement(
633 : const Reference<XAttributeList> & xAttrList)
634 : {
635 0 : bValid = sal_True;
636 0 : switch (nElementToken) {
637 : case XML_TOK_TEXT_SENDER_FIRSTNAME:
638 0 : nSubType = UserDataPart::FIRSTNAME;
639 0 : break;
640 : case XML_TOK_TEXT_SENDER_LASTNAME:
641 0 : nSubType = UserDataPart::NAME;
642 0 : break;
643 : case XML_TOK_TEXT_SENDER_INITIALS:
644 0 : nSubType = UserDataPart::SHORTCUT;
645 0 : break;
646 : case XML_TOK_TEXT_SENDER_TITLE:
647 0 : nSubType = UserDataPart::TITLE;
648 0 : break;
649 : case XML_TOK_TEXT_SENDER_POSITION:
650 0 : nSubType = UserDataPart::POSITION;
651 0 : break;
652 : case XML_TOK_TEXT_SENDER_EMAIL:
653 0 : nSubType = UserDataPart::EMAIL;
654 0 : break;
655 : case XML_TOK_TEXT_SENDER_PHONE_PRIVATE:
656 0 : nSubType = UserDataPart::PHONE_PRIVATE;
657 0 : break;
658 : case XML_TOK_TEXT_SENDER_FAX:
659 0 : nSubType = UserDataPart::FAX;
660 0 : break;
661 : case XML_TOK_TEXT_SENDER_COMPANY:
662 0 : nSubType = UserDataPart::COMPANY;
663 0 : break;
664 : case XML_TOK_TEXT_SENDER_PHONE_WORK:
665 0 : nSubType = UserDataPart::PHONE_COMPANY;
666 0 : break;
667 : case XML_TOK_TEXT_SENDER_STREET:
668 0 : nSubType = UserDataPart::STREET;
669 0 : break;
670 : case XML_TOK_TEXT_SENDER_CITY:
671 0 : nSubType = UserDataPart::CITY;
672 0 : break;
673 : case XML_TOK_TEXT_SENDER_POSTAL_CODE:
674 0 : nSubType = UserDataPart::ZIP;
675 0 : break;
676 : case XML_TOK_TEXT_SENDER_COUNTRY:
677 0 : nSubType = UserDataPart::COUNTRY;
678 0 : break;
679 : case XML_TOK_TEXT_SENDER_STATE_OR_PROVINCE:
680 0 : nSubType = UserDataPart::STATE;
681 0 : break;
682 : default:
683 0 : bValid = sal_False;
684 0 : break;
685 : }
686 :
687 : // process Attributes
688 0 : XMLTextFieldImportContext::StartElement(xAttrList);
689 0 : }
690 :
691 0 : void XMLSenderFieldImportContext::ProcessAttribute(
692 : sal_uInt16 nAttrToken,
693 : const OUString& sAttrValue)
694 : {
695 0 : if (XML_TOK_TEXTFIELD_FIXED == nAttrToken) {
696 :
697 : // set bVal
698 0 : bool bVal(false);
699 0 : bool const bRet = ::sax::Converter::convertBool(bVal, sAttrValue);
700 :
701 : // set bFixed if successful
702 0 : if (bRet) {
703 0 : bFixed = bVal;
704 : }
705 : }
706 0 : }
707 :
708 0 : void XMLSenderFieldImportContext::PrepareField(
709 : const Reference<XPropertySet> & rPropSet)
710 : {
711 : // set members
712 0 : Any aAny;
713 0 : aAny <<= nSubType;
714 0 : rPropSet->setPropertyValue(sPropertyFieldSubType, aAny);
715 :
716 : // set fixed
717 0 : aAny.setValue( &bFixed, ::getBooleanCppuType() );
718 0 : rPropSet->setPropertyValue(sPropertyFixed, aAny);
719 :
720 : // set content if fixed
721 0 : if (bFixed)
722 : {
723 : // in organizer or styles-only mode: force update
724 0 : if (GetImport().GetTextImport()->IsOrganizerMode() ||
725 0 : GetImport().GetTextImport()->IsStylesOnlyMode() )
726 : {
727 0 : ForceUpdate(rPropSet);
728 : }
729 : else
730 : {
731 0 : aAny <<= GetContent();
732 0 : rPropSet->setPropertyValue(sPropertyContent, aAny);
733 : }
734 0 : }
735 0 : }
736 :
737 :
738 :
739 :
740 : // XMLAuthorFieldImportContext
741 :
742 :
743 0 : TYPEINIT1( XMLAuthorFieldImportContext, XMLSenderFieldImportContext);
744 :
745 0 : XMLAuthorFieldImportContext::XMLAuthorFieldImportContext(
746 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
747 : sal_uInt16 nPrfx, const OUString& sLocalName,
748 : sal_uInt16 nToken)
749 : : XMLSenderFieldImportContext(rImport, rHlp, nPrfx, sLocalName, nToken)
750 : , bAuthorFullName(sal_True)
751 : , sServiceAuthor(sAPI_author)
752 : , sPropertyAuthorFullName(sAPI_full_name)
753 : , sPropertyFixed(sAPI_is_fixed)
754 0 : , sPropertyContent(sAPI_content)
755 : {
756 : // overwrite service name from XMLSenderFieldImportContext
757 0 : SetServiceName(sServiceAuthor);
758 0 : }
759 :
760 0 : void XMLAuthorFieldImportContext::StartElement(
761 : const Reference<XAttributeList> & xAttrList) {
762 :
763 0 : bAuthorFullName = (XML_TOK_TEXT_AUTHOR_INITIALS != nElementToken);
764 0 : bValid = sal_True;
765 :
766 : // process Attributes
767 0 : XMLTextFieldImportContext::StartElement(xAttrList);
768 0 : }
769 :
770 0 : void XMLAuthorFieldImportContext::PrepareField(
771 : const Reference<XPropertySet> & rPropSet)
772 : {
773 : // set members
774 0 : Any aAny;
775 0 : aAny.setValue( &bAuthorFullName, ::getBooleanCppuType() );
776 0 : rPropSet->setPropertyValue(sPropertyAuthorFullName, aAny);
777 :
778 0 : aAny.setValue( &bFixed, ::getBooleanCppuType() );
779 0 : rPropSet->setPropertyValue(sPropertyFixed, aAny);
780 :
781 : // set content if fixed
782 0 : if (bFixed)
783 : {
784 : // organizer or styles-only mode: force update
785 0 : if (GetImport().GetTextImport()->IsOrganizerMode() ||
786 0 : GetImport().GetTextImport()->IsStylesOnlyMode() )
787 : {
788 0 : ForceUpdate(rPropSet);
789 : }
790 : else
791 : {
792 0 : aAny <<= GetContent();
793 0 : rPropSet->setPropertyValue(sPropertyContent, aAny);
794 : }
795 0 : }
796 0 : }
797 :
798 :
799 :
800 : // page continuation string
801 :
802 :
803 0 : TYPEINIT1( XMLPageContinuationImportContext, XMLTextFieldImportContext );
804 :
805 : static SvXMLEnumMapEntry const lcl_aSelectPageAttrMap[] =
806 : {
807 : { XML_PREVIOUS, PageNumberType_PREV },
808 : { XML_CURRENT, PageNumberType_CURRENT },
809 : { XML_NEXT, PageNumberType_NEXT },
810 : { XML_TOKEN_INVALID, 0 },
811 : };
812 :
813 0 : XMLPageContinuationImportContext::XMLPageContinuationImportContext(
814 : SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx,
815 : const OUString& sLocalName)
816 : : XMLTextFieldImportContext(rImport, rHlp, sAPI_page_number, nPrfx, sLocalName)
817 : , sPropertySubType(sAPI_sub_type)
818 : , sPropertyUserText(sAPI_user_text)
819 : , sPropertyNumberingType(sAPI_numbering_type)
820 : , eSelectPage(PageNumberType_CURRENT)
821 0 : , sStringOK(sal_False)
822 : {
823 0 : bValid = sal_True;
824 0 : }
825 :
826 0 : void XMLPageContinuationImportContext::ProcessAttribute(
827 : sal_uInt16 nAttrToken, const OUString& sAttrValue )
828 : {
829 0 : switch(nAttrToken)
830 : {
831 : case XML_TOK_TEXTFIELD_SELECT_PAGE:
832 : {
833 : sal_uInt16 nTmp;
834 0 : if (SvXMLUnitConverter::convertEnum(nTmp, sAttrValue,
835 0 : lcl_aSelectPageAttrMap)
836 0 : && (PageNumberType_CURRENT != nTmp) )
837 : {
838 0 : eSelectPage = (PageNumberType)nTmp;
839 : }
840 0 : break;
841 : }
842 : case XML_TOK_TEXTFIELD_STRING_VALUE:
843 0 : sString = sAttrValue;
844 0 : sStringOK = sal_True;
845 0 : break;
846 : }
847 0 : }
848 :
849 0 : void XMLPageContinuationImportContext::PrepareField(
850 : const Reference<XPropertySet> & xPropertySet)
851 : {
852 0 : Any aAny;
853 :
854 0 : aAny <<= eSelectPage;
855 0 : xPropertySet->setPropertyValue(sPropertySubType, aAny);
856 :
857 0 : aAny <<= (sStringOK ? sString : GetContent());
858 0 : xPropertySet->setPropertyValue(sPropertyUserText, aAny);
859 :
860 0 : aAny <<= style::NumberingType::CHAR_SPECIAL;
861 0 : xPropertySet->setPropertyValue(sPropertyNumberingType, aAny);
862 0 : }
863 :
864 :
865 :
866 :
867 : // page number field
868 :
869 :
870 0 : TYPEINIT1( XMLPageNumberImportContext, XMLTextFieldImportContext );
871 :
872 0 : XMLPageNumberImportContext::XMLPageNumberImportContext(
873 : SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx,
874 : const OUString& sLocalName)
875 : : XMLTextFieldImportContext(rImport, rHlp, sAPI_page_number, nPrfx, sLocalName)
876 : , sPropertySubType(sAPI_sub_type)
877 : , sPropertyNumberingType(sAPI_numbering_type)
878 : , sPropertyOffset(sAPI_offset)
879 0 : , sNumberSync(GetXMLToken(XML_FALSE))
880 : , nPageAdjust(0)
881 : , eSelectPage(PageNumberType_CURRENT)
882 0 : , sNumberFormatOK(sal_False)
883 : {
884 0 : bValid = sal_True;
885 0 : }
886 :
887 0 : void XMLPageNumberImportContext::ProcessAttribute(
888 : sal_uInt16 nAttrToken,
889 : const OUString& sAttrValue )
890 : {
891 0 : switch (nAttrToken)
892 : {
893 : case XML_TOK_TEXTFIELD_NUM_FORMAT:
894 0 : sNumberFormat = sAttrValue;
895 0 : sNumberFormatOK = sal_True;
896 0 : break;
897 : case XML_TOK_TEXTFIELD_NUM_LETTER_SYNC:
898 0 : sNumberSync = sAttrValue;
899 0 : break;
900 : case XML_TOK_TEXTFIELD_SELECT_PAGE:
901 : {
902 : sal_uInt16 nTmp;
903 0 : if (SvXMLUnitConverter::convertEnum(nTmp, sAttrValue,
904 : lcl_aSelectPageAttrMap))
905 : {
906 0 : eSelectPage = (PageNumberType)nTmp;
907 : }
908 0 : break;
909 : }
910 : case XML_TOK_TEXTFIELD_PAGE_ADJUST:
911 : {
912 : sal_Int32 nTmp;
913 0 : if (::sax::Converter::convertNumber(nTmp, sAttrValue))
914 : {
915 0 : nPageAdjust = (sal_Int16)nTmp;
916 : }
917 0 : break;
918 : }
919 : }
920 0 : }
921 :
922 0 : void XMLPageNumberImportContext::PrepareField(
923 : const Reference<XPropertySet> & xPropertySet)
924 : {
925 0 : Any aAny;
926 :
927 : // all properties are optional
928 : Reference<XPropertySetInfo> xPropertySetInfo(
929 0 : xPropertySet->getPropertySetInfo());
930 :
931 0 : if (xPropertySetInfo->hasPropertyByName(sPropertyNumberingType))
932 : {
933 : sal_Int16 nNumType;
934 0 : if( sNumberFormatOK )
935 : {
936 0 : nNumType= style::NumberingType::ARABIC;
937 0 : GetImport().GetMM100UnitConverter().convertNumFormat( nNumType,
938 : sNumberFormat,
939 0 : sNumberSync );
940 : }
941 : else
942 0 : nNumType = style::NumberingType::PAGE_DESCRIPTOR;
943 :
944 0 : aAny <<= nNumType;
945 0 : xPropertySet->setPropertyValue(sPropertyNumberingType, aAny);
946 : }
947 :
948 0 : if (xPropertySetInfo->hasPropertyByName(sPropertyOffset))
949 : {
950 : // adjust offset
951 0 : switch (eSelectPage)
952 : {
953 : case PageNumberType_PREV:
954 0 : nPageAdjust--;
955 0 : break;
956 : case PageNumberType_CURRENT:
957 0 : break;
958 : case PageNumberType_NEXT:
959 0 : nPageAdjust++;
960 0 : break;
961 : default:
962 : DBG_WARNING("unknown page number type");
963 : }
964 0 : aAny <<= nPageAdjust;
965 0 : xPropertySet->setPropertyValue(sPropertyOffset, aAny);
966 : }
967 :
968 0 : if (xPropertySetInfo->hasPropertyByName(sPropertySubType))
969 : {
970 0 : aAny <<= eSelectPage;
971 0 : xPropertySet->setPropertyValue(sPropertySubType, aAny);
972 0 : }
973 0 : }
974 :
975 :
976 :
977 :
978 : // Placeholder
979 :
980 :
981 0 : TYPEINIT1( XMLPlaceholderFieldImportContext, XMLTextFieldImportContext);
982 :
983 0 : XMLPlaceholderFieldImportContext::XMLPlaceholderFieldImportContext(
984 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
985 : sal_uInt16 nPrfx, const OUString& sLocalName)
986 : : XMLTextFieldImportContext(rImport, rHlp, sAPI_jump_edit,nPrfx, sLocalName)
987 : , sPropertyPlaceholderType(sAPI_place_holder_type)
988 : , sPropertyPlaceholder(sAPI_place_holder)
989 : , sPropertyHint(sAPI_hint)
990 0 : , nPlaceholderType(PlaceholderType::TEXT)
991 : {
992 0 : }
993 :
994 : /// process attribute values
995 0 : void XMLPlaceholderFieldImportContext::ProcessAttribute(
996 : sal_uInt16 nAttrToken, const OUString& sAttrValue )
997 : {
998 0 : switch (nAttrToken) {
999 : case XML_TOK_TEXTFIELD_DESCRIPTION:
1000 0 : sDescription = sAttrValue;
1001 0 : break;
1002 :
1003 : case XML_TOK_TEXTFIELD_PLACEHOLDER_TYPE:
1004 0 : bValid = sal_True;
1005 0 : if (IsXMLToken(sAttrValue, XML_TABLE))
1006 : {
1007 0 : nPlaceholderType = PlaceholderType::TABLE;
1008 : }
1009 0 : else if (IsXMLToken(sAttrValue, XML_TEXT))
1010 : {
1011 0 : nPlaceholderType = PlaceholderType::TEXT;
1012 : }
1013 0 : else if (IsXMLToken(sAttrValue, XML_TEXT_BOX))
1014 : {
1015 0 : nPlaceholderType = PlaceholderType::TEXTFRAME;
1016 : }
1017 0 : else if (IsXMLToken(sAttrValue, XML_IMAGE))
1018 : {
1019 0 : nPlaceholderType = PlaceholderType::GRAPHIC;
1020 : }
1021 0 : else if (IsXMLToken(sAttrValue, XML_OBJECT))
1022 : {
1023 0 : nPlaceholderType = PlaceholderType::OBJECT;
1024 : }
1025 : else
1026 : {
1027 0 : bValid = sal_False;
1028 : }
1029 0 : break;
1030 :
1031 : default:
1032 : ; // ignore
1033 : }
1034 0 : }
1035 :
1036 0 : void XMLPlaceholderFieldImportContext::PrepareField(
1037 : const Reference<XPropertySet> & xPropertySet) {
1038 :
1039 0 : Any aAny;
1040 0 : aAny <<= sDescription;
1041 0 : xPropertySet->setPropertyValue(sPropertyHint, aAny);
1042 :
1043 : // remove <...> around content (if present)
1044 0 : OUString aContent = GetContent();
1045 0 : sal_Int32 nStart = 0;
1046 0 : sal_Int32 nLength = aContent.getLength();
1047 0 : if (aContent.startsWith("<"))
1048 : {
1049 0 : --nLength;
1050 0 : ++nStart;
1051 : }
1052 0 : if (aContent.endsWith(">"))
1053 : {
1054 0 : --nLength;
1055 : }
1056 0 : aAny <<= aContent.copy(nStart, nLength);
1057 0 : xPropertySet->setPropertyValue(sPropertyPlaceholder, aAny);
1058 :
1059 0 : aAny <<= nPlaceholderType;
1060 0 : xPropertySet->setPropertyValue(sPropertyPlaceholderType, aAny);
1061 0 : }
1062 :
1063 :
1064 :
1065 : // time field
1066 :
1067 :
1068 0 : TYPEINIT1( XMLTimeFieldImportContext, XMLTextFieldImportContext);
1069 :
1070 0 : XMLTimeFieldImportContext::XMLTimeFieldImportContext(
1071 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
1072 : sal_uInt16 nPrfx, const OUString& sLocalName)
1073 : : XMLTextFieldImportContext(rImport, rHlp, sAPI_date_time, nPrfx, sLocalName)
1074 : , sPropertyNumberFormat(sAPI_number_format)
1075 : , sPropertyFixed(sAPI_is_fixed)
1076 : , sPropertyDateTimeValue(sAPI_date_time_value)
1077 : , sPropertyDateTime(sAPI_date_time)
1078 : , sPropertyAdjust(sAPI_adjust)
1079 : , sPropertyIsDate(sAPI_is_date)
1080 : , sPropertyIsFixedLanguage(sAPI_is_fixed_language)
1081 : , nAdjust(0)
1082 : , nFormatKey(0)
1083 : , bTimeOK(sal_False)
1084 : , bFormatOK(sal_False)
1085 : , bFixed(sal_False)
1086 : , bIsDate(sal_False)
1087 0 : , bIsDefaultLanguage( true )
1088 : {
1089 0 : bValid = sal_True; // always valid!
1090 0 : }
1091 :
1092 0 : void XMLTimeFieldImportContext::ProcessAttribute(
1093 : sal_uInt16 nAttrToken, const OUString& sAttrValue )
1094 : {
1095 0 : switch (nAttrToken)
1096 : {
1097 : case XML_TOK_TEXTFIELD_TIME_VALUE:
1098 : {
1099 0 : if (::sax::Converter::parseTimeOrDateTime(aDateTimeValue, 0,
1100 0 : sAttrValue))
1101 : {
1102 0 : bTimeOK = sal_True;
1103 : }
1104 0 : break;
1105 : }
1106 : case XML_TOK_TEXTFIELD_FIXED:
1107 : {
1108 0 : bool bTmp(false);
1109 0 : if (::sax::Converter::convertBool(bTmp, sAttrValue))
1110 : {
1111 0 : bFixed = bTmp;
1112 : }
1113 0 : break;
1114 : }
1115 : case XML_TOK_TEXTFIELD_DATA_STYLE_NAME:
1116 : {
1117 0 : sal_Int32 nKey = GetImportHelper().GetDataStyleKey(
1118 0 : sAttrValue, &bIsDefaultLanguage);
1119 0 : if (-1 != nKey)
1120 : {
1121 0 : nFormatKey = nKey;
1122 0 : bFormatOK = sal_True;
1123 : }
1124 0 : break;
1125 : }
1126 : case XML_TOK_TEXTFIELD_TIME_ADJUST:
1127 : {
1128 : double fTmp;
1129 :
1130 0 : if (::sax::Converter::convertDuration(fTmp, sAttrValue))
1131 : {
1132 : // convert to minutes
1133 0 : nAdjust = (sal_Int32)::rtl::math::approxFloor(fTmp * 60 * 24);
1134 : }
1135 0 : break;
1136 : }
1137 : }
1138 0 : }
1139 :
1140 0 : void XMLTimeFieldImportContext::PrepareField(
1141 : const Reference<XPropertySet> & rPropertySet)
1142 : {
1143 0 : Any aAny;
1144 :
1145 : // all properties are optional (except IsDate)
1146 : Reference<XPropertySetInfo> xPropertySetInfo(
1147 0 : rPropertySet->getPropertySetInfo());
1148 :
1149 0 : if (xPropertySetInfo->hasPropertyByName(sPropertyFixed))
1150 : {
1151 0 : aAny.setValue( &bFixed, ::getBooleanCppuType() );
1152 0 : rPropertySet->setPropertyValue(sPropertyFixed, aAny);
1153 : }
1154 :
1155 0 : aAny.setValue( &bIsDate, ::getBooleanCppuType() );
1156 0 : rPropertySet->setPropertyValue(sPropertyIsDate, aAny);
1157 :
1158 0 : if (xPropertySetInfo->hasPropertyByName(sPropertyAdjust))
1159 : {
1160 0 : aAny <<= nAdjust;
1161 0 : rPropertySet->setPropertyValue(sPropertyAdjust, aAny);
1162 : }
1163 :
1164 : // set value
1165 0 : if (bFixed)
1166 : {
1167 : // organizer or styles-only mode: force update
1168 0 : if (GetImport().GetTextImport()->IsOrganizerMode() ||
1169 0 : GetImport().GetTextImport()->IsStylesOnlyMode() )
1170 : {
1171 0 : ForceUpdate(rPropertySet);
1172 : }
1173 : else
1174 : {
1175 : // normal mode: set value (if present)
1176 0 : if (bTimeOK)
1177 : {
1178 0 : if (xPropertySetInfo->hasPropertyByName(sPropertyDateTimeValue))
1179 : {
1180 0 : aAny <<= aDateTimeValue;
1181 0 : rPropertySet->setPropertyValue(sPropertyDateTimeValue,aAny);
1182 : }
1183 0 : else if (xPropertySetInfo->hasPropertyByName(sPropertyDateTime))
1184 : {
1185 0 : aAny <<= aDateTimeValue;
1186 0 : rPropertySet->setPropertyValue(sPropertyDateTime, aAny);
1187 : }
1188 : }
1189 : }
1190 : }
1191 :
1192 0 : if (bFormatOK &&
1193 0 : xPropertySetInfo->hasPropertyByName(sPropertyNumberFormat))
1194 : {
1195 0 : aAny <<= nFormatKey;
1196 0 : rPropertySet->setPropertyValue(sPropertyNumberFormat, aAny);
1197 :
1198 0 : if( xPropertySetInfo->hasPropertyByName( sPropertyIsFixedLanguage ) )
1199 : {
1200 0 : sal_Bool bIsFixedLanguage = ! bIsDefaultLanguage;
1201 0 : aAny.setValue( &bIsFixedLanguage, ::getBooleanCppuType() );
1202 0 : rPropertySet->setPropertyValue( sPropertyIsFixedLanguage, aAny );
1203 : }
1204 0 : }
1205 0 : }
1206 :
1207 :
1208 :
1209 :
1210 : // date field
1211 :
1212 :
1213 0 : TYPEINIT1( XMLDateFieldImportContext, XMLTimeFieldImportContext );
1214 :
1215 0 : XMLDateFieldImportContext::XMLDateFieldImportContext(
1216 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
1217 : sal_uInt16 nPrfx, const OUString& sLocalName) :
1218 0 : XMLTimeFieldImportContext(rImport, rHlp, nPrfx, sLocalName)
1219 : {
1220 0 : bIsDate = sal_True; // always a date!
1221 0 : }
1222 :
1223 0 : void XMLDateFieldImportContext::ProcessAttribute(
1224 : sal_uInt16 nAttrToken,
1225 : const OUString& sAttrValue )
1226 : {
1227 0 : switch (nAttrToken)
1228 : {
1229 : case XML_TOK_TEXTFIELD_DATE_VALUE:
1230 : {
1231 0 : if (::sax::Converter::parseDateTime(aDateTimeValue, 0, sAttrValue))
1232 : {
1233 0 : bTimeOK = sal_True;
1234 : }
1235 0 : break;
1236 : }
1237 : case XML_TOK_TEXTFIELD_DATE_ADJUST:
1238 : // delegate to superclass, pretending it was a time-adjust attr.
1239 : XMLTimeFieldImportContext::ProcessAttribute(
1240 : XML_TOK_TEXTFIELD_TIME_ADJUST,
1241 0 : sAttrValue);
1242 0 : break;
1243 : case XML_TOK_TEXTFIELD_TIME_VALUE:
1244 : case XML_TOK_TEXTFIELD_TIME_ADJUST:
1245 : ; // ignore time-adjust and time-value attributes
1246 0 : break;
1247 : default:
1248 : // all others: delegate to super-class
1249 : XMLTimeFieldImportContext::ProcessAttribute(nAttrToken,
1250 0 : sAttrValue);
1251 0 : break;
1252 : }
1253 0 : }
1254 :
1255 :
1256 :
1257 :
1258 :
1259 : // database field superclass
1260 :
1261 :
1262 0 : TYPEINIT1( XMLDatabaseFieldImportContext, XMLTextFieldImportContext );
1263 :
1264 0 : XMLDatabaseFieldImportContext::XMLDatabaseFieldImportContext(
1265 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
1266 : const sal_Char* pServiceName, sal_uInt16 nPrfx,
1267 : const OUString& sLocalName, bool bUseDisply)
1268 : : XMLTextFieldImportContext(rImport, rHlp, pServiceName, nPrfx, sLocalName)
1269 : , sPropertyDataBaseName(sAPI_data_base_name)
1270 : , sPropertyDataBaseURL(sAPI_data_base_u_r_l)
1271 : , sPropertyTableName(sAPI_data_table_name)
1272 : , sPropertyDataCommandType(sAPI_data_command_type)
1273 : , sPropertyIsVisible(sAPI_is_visible)
1274 : , nCommandType( sdb::CommandType::TABLE )
1275 : , bCommandTypeOK(sal_False)
1276 : , bDisplay( sal_True )
1277 : , bDisplayOK( false )
1278 : , bUseDisplay( bUseDisply )
1279 : , bDatabaseOK(sal_False)
1280 : , bDatabaseNameOK(sal_False)
1281 : , bDatabaseURLOK(sal_False)
1282 0 : , bTableOK(sal_False)
1283 : {
1284 0 : }
1285 :
1286 0 : void XMLDatabaseFieldImportContext::ProcessAttribute(
1287 : sal_uInt16 nAttrToken, const OUString& sAttrValue )
1288 : {
1289 0 : switch (nAttrToken)
1290 : {
1291 : case XML_TOK_TEXTFIELD_DATABASE_NAME:
1292 0 : sDatabaseName = sAttrValue;
1293 0 : bDatabaseOK = sal_True;
1294 0 : bDatabaseNameOK = sal_True;
1295 0 : break;
1296 : case XML_TOK_TEXTFIELD_TABLE_NAME:
1297 0 : sTableName = sAttrValue;
1298 0 : bTableOK = sal_True;
1299 0 : break;
1300 : case XML_TOK_TEXTFIELD_TABLE_TYPE:
1301 0 : if( IsXMLToken( sAttrValue, XML_TABLE ) )
1302 : {
1303 0 : nCommandType = sdb::CommandType::TABLE;
1304 0 : bCommandTypeOK = sal_True;
1305 : }
1306 0 : else if( IsXMLToken( sAttrValue, XML_QUERY ) )
1307 : {
1308 0 : nCommandType = sdb::CommandType::QUERY;
1309 0 : bCommandTypeOK = sal_True;
1310 : }
1311 0 : else if( IsXMLToken( sAttrValue, XML_COMMAND ) )
1312 : {
1313 0 : nCommandType = sdb::CommandType::COMMAND;
1314 0 : bCommandTypeOK = sal_True;
1315 : }
1316 0 : break;
1317 : case XML_TOK_TEXTFIELD_DISPLAY:
1318 0 : if( IsXMLToken( sAttrValue, XML_NONE ) )
1319 : {
1320 0 : bDisplay = sal_False;
1321 0 : bDisplayOK = true;
1322 : }
1323 0 : else if( IsXMLToken( sAttrValue, XML_VALUE ) )
1324 : {
1325 0 : bDisplay = sal_True;
1326 0 : bDisplayOK = true;
1327 : }
1328 0 : break;
1329 : }
1330 0 : }
1331 :
1332 0 : SvXMLImportContext* XMLDatabaseFieldImportContext::CreateChildContext(
1333 : sal_uInt16 p_nPrefix,
1334 : const OUString& rLocalName,
1335 : const Reference<XAttributeList>& xAttrList )
1336 : {
1337 0 : if( ( p_nPrefix == XML_NAMESPACE_FORM ) &&
1338 0 : IsXMLToken( rLocalName, XML_CONNECTION_RESOURCE ) )
1339 : {
1340 : // process attribute list directly
1341 0 : sal_Int16 nLength = xAttrList->getLength();
1342 0 : for( sal_Int16 n = 0; n < nLength; n++ )
1343 : {
1344 0 : OUString sLocalName;
1345 0 : sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
1346 0 : GetKeyByAttrName( xAttrList->getNameByIndex(n), &sLocalName );
1347 :
1348 0 : if( ( nPrefix == XML_NAMESPACE_XLINK ) &&
1349 0 : IsXMLToken( sLocalName, XML_HREF ) )
1350 : {
1351 0 : sDatabaseURL = xAttrList->getValueByIndex(n);
1352 0 : bDatabaseOK = sal_True;
1353 0 : bDatabaseURLOK = sal_True;
1354 : }
1355 0 : }
1356 :
1357 : // we call ProcessAttribute in order to set bValid appropriatly
1358 0 : ProcessAttribute( XML_TOKEN_INVALID, OUString() );
1359 : }
1360 :
1361 : return SvXMLImportContext::CreateChildContext(p_nPrefix, rLocalName,
1362 0 : xAttrList);
1363 : }
1364 :
1365 :
1366 0 : void XMLDatabaseFieldImportContext::PrepareField(
1367 : const Reference<XPropertySet> & xPropertySet)
1368 : {
1369 0 : Any aAny;
1370 :
1371 0 : aAny <<= sTableName;
1372 0 : xPropertySet->setPropertyValue(sPropertyTableName, aAny);
1373 :
1374 0 : if( bDatabaseNameOK )
1375 : {
1376 0 : aAny <<= sDatabaseName;
1377 0 : xPropertySet->setPropertyValue(sPropertyDataBaseName, aAny);
1378 : }
1379 0 : else if( bDatabaseURLOK )
1380 : {
1381 0 : aAny <<= sDatabaseURL;
1382 0 : xPropertySet->setPropertyValue(sPropertyDataBaseURL, aAny);
1383 : }
1384 :
1385 : // #99980# load/save command type for all fields; also load
1386 : // old documents without command type
1387 0 : if( bCommandTypeOK )
1388 : {
1389 0 : aAny <<= nCommandType;
1390 0 : xPropertySet->setPropertyValue( sPropertyDataCommandType, aAny );
1391 : }
1392 :
1393 0 : if( bUseDisplay && bDisplayOK )
1394 : {
1395 0 : aAny.setValue( &bDisplay, ::getBooleanCppuType() );
1396 0 : xPropertySet->setPropertyValue( sPropertyIsVisible, aAny );
1397 0 : }
1398 0 : }
1399 :
1400 :
1401 :
1402 :
1403 : // database name field
1404 :
1405 :
1406 0 : TYPEINIT1( XMLDatabaseNameImportContext, XMLDatabaseFieldImportContext );
1407 :
1408 0 : XMLDatabaseNameImportContext::XMLDatabaseNameImportContext(
1409 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
1410 : sal_uInt16 nPrfx, const OUString& sLocalName) :
1411 : XMLDatabaseFieldImportContext(rImport, rHlp, sAPI_database_name,
1412 0 : nPrfx, sLocalName, true)
1413 : {
1414 0 : }
1415 :
1416 0 : void XMLDatabaseNameImportContext::ProcessAttribute(
1417 : sal_uInt16 nAttrToken, const OUString& sAttrValue )
1418 : {
1419 : // delegate to superclass and check for success
1420 0 : XMLDatabaseFieldImportContext::ProcessAttribute(nAttrToken, sAttrValue);
1421 0 : bValid = bDatabaseOK && bTableOK;
1422 0 : }
1423 :
1424 :
1425 :
1426 :
1427 : // database next field
1428 :
1429 :
1430 0 : TYPEINIT1( XMLDatabaseNextImportContext, XMLDatabaseFieldImportContext );
1431 :
1432 0 : XMLDatabaseNextImportContext::XMLDatabaseNextImportContext(
1433 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
1434 : const sal_Char* pServiceName, sal_uInt16 nPrfx,
1435 : const OUString& sLocalName) :
1436 : XMLDatabaseFieldImportContext(rImport, rHlp, pServiceName,
1437 : nPrfx, sLocalName, false),
1438 : sPropertyCondition(sAPI_condition),
1439 : sTrue(sAPI_true),
1440 : sCondition(),
1441 0 : bConditionOK(sal_False)
1442 : {
1443 0 : }
1444 :
1445 0 : XMLDatabaseNextImportContext::XMLDatabaseNextImportContext(
1446 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
1447 : sal_uInt16 nPrfx, const OUString& sLocalName)
1448 : : XMLDatabaseFieldImportContext(rImport, rHlp, sAPI_database_next, nPrfx, sLocalName, false)
1449 : , sPropertyCondition(sAPI_condition)
1450 : , sTrue(sAPI_true)
1451 0 : , bConditionOK(sal_False)
1452 : {
1453 0 : }
1454 :
1455 0 : void XMLDatabaseNextImportContext::ProcessAttribute(
1456 : sal_uInt16 nAttrToken, const OUString& sAttrValue )
1457 : {
1458 0 : if (XML_TOK_TEXTFIELD_CONDITION == nAttrToken)
1459 : {
1460 0 : OUString sTmp;
1461 0 : sal_uInt16 nPrefix = GetImport().GetNamespaceMap()._GetKeyByAttrName(
1462 0 : sAttrValue, &sTmp, false );
1463 0 : if( XML_NAMESPACE_OOOW == nPrefix )
1464 : {
1465 0 : sCondition = sTmp;
1466 0 : bConditionOK = sal_True;
1467 : }
1468 : else
1469 0 : sCondition = sAttrValue;
1470 : }
1471 : else
1472 : {
1473 : XMLDatabaseFieldImportContext::ProcessAttribute(nAttrToken,
1474 0 : sAttrValue);
1475 : }
1476 :
1477 0 : bValid = bDatabaseOK && bTableOK;
1478 0 : }
1479 :
1480 0 : void XMLDatabaseNextImportContext::PrepareField(
1481 : const Reference<XPropertySet> & xPropertySet)
1482 : {
1483 0 : Any aAny;
1484 :
1485 0 : aAny <<= bConditionOK ? sCondition : sTrue;
1486 0 : xPropertySet->setPropertyValue(sPropertyCondition, aAny);
1487 :
1488 0 : XMLDatabaseFieldImportContext::PrepareField(xPropertySet);
1489 0 : }
1490 :
1491 :
1492 :
1493 :
1494 : // database select field
1495 :
1496 :
1497 0 : TYPEINIT1( XMLDatabaseSelectImportContext, XMLDatabaseNextImportContext );
1498 :
1499 0 : XMLDatabaseSelectImportContext::XMLDatabaseSelectImportContext(
1500 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
1501 : sal_uInt16 nPrfx, const OUString& sLocalName) :
1502 : XMLDatabaseNextImportContext(rImport, rHlp, sAPI_database_select,
1503 : nPrfx, sLocalName),
1504 : sPropertySetNumber(sAPI_set_number),
1505 : nNumber(0),
1506 0 : bNumberOK(sal_False)
1507 : {
1508 0 : }
1509 :
1510 0 : void XMLDatabaseSelectImportContext::ProcessAttribute(
1511 : sal_uInt16 nAttrToken,
1512 : const OUString& sAttrValue )
1513 : {
1514 0 : if (XML_TOK_TEXTFIELD_ROW_NUMBER == nAttrToken)
1515 : {
1516 : sal_Int32 nTmp;
1517 0 : if (::sax::Converter::convertNumber( nTmp, sAttrValue
1518 : /* , nMin, nMax ??? */ ))
1519 : {
1520 0 : nNumber = nTmp;
1521 0 : bNumberOK = sal_True;
1522 : }
1523 : }
1524 : else
1525 : {
1526 0 : XMLDatabaseNextImportContext::ProcessAttribute(nAttrToken, sAttrValue);
1527 : }
1528 :
1529 0 : bValid = bTableOK && bDatabaseOK && bNumberOK;
1530 0 : }
1531 :
1532 0 : void XMLDatabaseSelectImportContext::PrepareField(
1533 : const Reference<XPropertySet> & xPropertySet)
1534 : {
1535 0 : Any aAny;
1536 :
1537 0 : aAny <<= nNumber;
1538 0 : xPropertySet->setPropertyValue(sPropertySetNumber, aAny);
1539 :
1540 0 : XMLDatabaseNextImportContext::PrepareField(xPropertySet);
1541 0 : }
1542 :
1543 :
1544 :
1545 :
1546 : // database display row number field
1547 :
1548 :
1549 0 : TYPEINIT1( XMLDatabaseNumberImportContext, XMLDatabaseFieldImportContext );
1550 :
1551 0 : XMLDatabaseNumberImportContext::XMLDatabaseNumberImportContext(
1552 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
1553 : sal_uInt16 nPrfx, const OUString& sLocalName) :
1554 : XMLDatabaseFieldImportContext(rImport, rHlp, sAPI_database_number,
1555 : nPrfx, sLocalName, true),
1556 : sPropertyNumberingType(
1557 : sAPI_numbering_type),
1558 : sPropertySetNumber(sAPI_set_number),
1559 : sNumberFormat("1"),
1560 0 : sNumberSync(GetXMLToken(XML_FALSE)),
1561 : nValue(0),
1562 0 : bValueOK(sal_False)
1563 : {
1564 0 : }
1565 :
1566 0 : void XMLDatabaseNumberImportContext::ProcessAttribute(
1567 : sal_uInt16 nAttrToken,
1568 : const OUString& sAttrValue )
1569 : {
1570 0 : switch (nAttrToken)
1571 : {
1572 : case XML_TOK_TEXTFIELD_NUM_FORMAT:
1573 0 : sNumberFormat = sAttrValue;
1574 0 : break;
1575 : case XML_TOK_TEXTFIELD_NUM_LETTER_SYNC:
1576 0 : sNumberSync = sAttrValue;
1577 0 : break;
1578 : case XML_TOK_TEXTFIELD_VALUE:
1579 : {
1580 : sal_Int32 nTmp;
1581 0 : if (::sax::Converter::convertNumber( nTmp, sAttrValue ))
1582 : {
1583 0 : nValue = nTmp;
1584 0 : bValueOK = sal_True;
1585 : }
1586 0 : break;
1587 : }
1588 : default:
1589 : XMLDatabaseFieldImportContext::ProcessAttribute(nAttrToken,
1590 0 : sAttrValue);
1591 0 : break;
1592 : }
1593 :
1594 0 : bValid = bTableOK && bDatabaseOK;
1595 0 : }
1596 :
1597 0 : void XMLDatabaseNumberImportContext::PrepareField(
1598 : const Reference<XPropertySet> & xPropertySet)
1599 : {
1600 0 : Any aAny;
1601 :
1602 0 : sal_Int16 nNumType = style::NumberingType::ARABIC;
1603 0 : GetImport().GetMM100UnitConverter().convertNumFormat( nNumType,
1604 : sNumberFormat,
1605 0 : sNumberSync );
1606 0 : aAny <<= nNumType;
1607 0 : xPropertySet->setPropertyValue(sPropertyNumberingType, aAny);
1608 :
1609 0 : if (bValueOK)
1610 : {
1611 0 : aAny <<= nValue;
1612 0 : xPropertySet->setPropertyValue(sPropertySetNumber, aAny);
1613 : }
1614 :
1615 0 : XMLDatabaseFieldImportContext::PrepareField(xPropertySet);
1616 0 : }
1617 :
1618 :
1619 :
1620 :
1621 : // Simple doc info fields
1622 :
1623 :
1624 0 : TYPEINIT1( XMLSimpleDocInfoImportContext, XMLTextFieldImportContext );
1625 :
1626 0 : XMLSimpleDocInfoImportContext::XMLSimpleDocInfoImportContext(
1627 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
1628 : sal_uInt16 nPrfx, const OUString& sLocalName, sal_uInt16 nToken,
1629 : sal_Bool bContent, sal_Bool bAuthor)
1630 : : XMLTextFieldImportContext(rImport, rHlp, MapTokenToServiceName(nToken),nPrfx, sLocalName)
1631 : , sPropertyFixed(sAPI_is_fixed)
1632 : , sPropertyContent(sAPI_content)
1633 : , sPropertyAuthor(sAPI_author)
1634 : , sPropertyCurrentPresentation(sAPI_current_presentation)
1635 : , bFixed(sal_False)
1636 : , bHasAuthor(bAuthor)
1637 0 : , bHasContent(bContent)
1638 : {
1639 0 : bValid = sal_True;
1640 0 : }
1641 :
1642 0 : void XMLSimpleDocInfoImportContext::ProcessAttribute(
1643 : sal_uInt16 nAttrToken,
1644 : const OUString& sAttrValue )
1645 : {
1646 0 : if (XML_TOK_TEXTFIELD_FIXED == nAttrToken)
1647 : {
1648 0 : bool bTmp(false);
1649 0 : if (::sax::Converter::convertBool(bTmp, sAttrValue))
1650 : {
1651 0 : bFixed = bTmp;
1652 : }
1653 : }
1654 0 : }
1655 :
1656 0 : void XMLSimpleDocInfoImportContext::PrepareField(
1657 : const Reference<XPropertySet> & rPropertySet)
1658 : {
1659 : // title field in Calc has no Fixed property
1660 0 : Reference<XPropertySetInfo> xPropertySetInfo(rPropertySet->getPropertySetInfo());
1661 0 : if (xPropertySetInfo->hasPropertyByName(sPropertyFixed))
1662 : {
1663 0 : Any aAny;
1664 0 : aAny.setValue(&bFixed, ::getBooleanCppuType() );
1665 0 : rPropertySet->setPropertyValue(sPropertyFixed, aAny);
1666 :
1667 : // set Content and CurrentPresentation (if fixed)
1668 0 : if (bFixed)
1669 : {
1670 : // in organizer-mode or styles-only-mode, only force update
1671 0 : if (GetImport().GetTextImport()->IsOrganizerMode() ||
1672 0 : GetImport().GetTextImport()->IsStylesOnlyMode() )
1673 : {
1674 0 : ForceUpdate(rPropertySet);
1675 : }
1676 : else
1677 : {
1678 : // set content (author, if that's the name) and current
1679 : // presentation
1680 0 : aAny <<= GetContent();
1681 :
1682 0 : if (bFixed && bHasAuthor)
1683 : {
1684 0 : rPropertySet->setPropertyValue(sPropertyAuthor, aAny);
1685 : }
1686 :
1687 0 : if (bFixed && bHasContent)
1688 : {
1689 0 : rPropertySet->setPropertyValue(sPropertyContent, aAny);
1690 : }
1691 :
1692 0 : rPropertySet->setPropertyValue(sPropertyCurrentPresentation, aAny);
1693 : }
1694 0 : }
1695 0 : }
1696 0 : }
1697 :
1698 0 : const sal_Char* XMLSimpleDocInfoImportContext::MapTokenToServiceName(
1699 : sal_uInt16 nToken)
1700 : {
1701 0 : const sal_Char* pServiceName = NULL;
1702 :
1703 0 : switch(nToken)
1704 : {
1705 : case XML_TOK_TEXT_DOCUMENT_CREATION_AUTHOR:
1706 0 : pServiceName = sAPI_docinfo_create_author;
1707 0 : break;
1708 : case XML_TOK_TEXT_DOCUMENT_CREATION_DATE:
1709 0 : pServiceName = sAPI_docinfo_create_date_time;
1710 0 : break;
1711 : case XML_TOK_TEXT_DOCUMENT_CREATION_TIME:
1712 0 : pServiceName = sAPI_docinfo_create_date_time;
1713 0 : break;
1714 : case XML_TOK_TEXT_DOCUMENT_DESCRIPTION:
1715 0 : pServiceName = sAPI_docinfo_description;
1716 0 : break;
1717 : case XML_TOK_TEXT_DOCUMENT_EDIT_DURATION:
1718 0 : pServiceName = sAPI_docinfo_edit_time;
1719 0 : break;
1720 : case XML_TOK_TEXT_DOCUMENT_USER_DEFINED:
1721 0 : pServiceName = sAPI_docinfo_custom;
1722 0 : break;
1723 : case XML_TOK_TEXT_DOCUMENT_PRINT_AUTHOR:
1724 0 : pServiceName = sAPI_docinfo_print_author;
1725 0 : break;
1726 : case XML_TOK_TEXT_DOCUMENT_PRINT_DATE:
1727 0 : pServiceName = sAPI_docinfo_print_date_time;
1728 0 : break;
1729 : case XML_TOK_TEXT_DOCUMENT_PRINT_TIME:
1730 0 : pServiceName = sAPI_docinfo_print_date_time;
1731 0 : break;
1732 : case XML_TOK_TEXT_DOCUMENT_KEYWORDS:
1733 0 : pServiceName = sAPI_docinfo_keywords;
1734 0 : break;
1735 : case XML_TOK_TEXT_DOCUMENT_SUBJECT:
1736 0 : pServiceName = sAPI_docinfo_subject;
1737 0 : break;
1738 : case XML_TOK_TEXT_DOCUMENT_REVISION:
1739 0 : pServiceName = sAPI_docinfo_revision;
1740 0 : break;
1741 : case XML_TOK_TEXT_DOCUMENT_SAVE_AUTHOR:
1742 0 : pServiceName = sAPI_docinfo_change_author;
1743 0 : break;
1744 : case XML_TOK_TEXT_DOCUMENT_SAVE_DATE:
1745 0 : pServiceName = sAPI_docinfo_change_date_time;
1746 0 : break;
1747 : case XML_TOK_TEXT_DOCUMENT_SAVE_TIME:
1748 0 : pServiceName = sAPI_docinfo_change_date_time;
1749 0 : break;
1750 : case XML_TOK_TEXT_DOCUMENT_TITLE:
1751 0 : pServiceName = sAPI_docinfo_title;
1752 0 : break;
1753 :
1754 : default:
1755 : OSL_FAIL("no docinfo field token");
1756 0 : pServiceName = NULL;
1757 0 : break;
1758 : }
1759 :
1760 0 : return pServiceName;
1761 : }
1762 :
1763 :
1764 :
1765 : // revision field
1766 :
1767 :
1768 0 : TYPEINIT1( XMLRevisionDocInfoImportContext, XMLSimpleDocInfoImportContext );
1769 :
1770 0 : XMLRevisionDocInfoImportContext::XMLRevisionDocInfoImportContext(
1771 : SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx,
1772 : const OUString& sLocalName, sal_uInt16 nToken) :
1773 : XMLSimpleDocInfoImportContext(rImport, rHlp, nPrfx, sLocalName,
1774 : nToken, sal_False, sal_False),
1775 0 : sPropertyRevision(sAPI_revision)
1776 : {
1777 0 : bValid = sal_True;
1778 0 : }
1779 :
1780 0 : void XMLRevisionDocInfoImportContext::PrepareField(
1781 : const Reference<XPropertySet> & rPropertySet)
1782 : {
1783 0 : XMLSimpleDocInfoImportContext::PrepareField(rPropertySet);
1784 :
1785 : // set revision number
1786 : // if fixed, if not in organizer-mode, if not in styles-only-mode
1787 0 : if (bFixed)
1788 : {
1789 0 : if ( GetImport().GetTextImport()->IsOrganizerMode() ||
1790 0 : GetImport().GetTextImport()->IsStylesOnlyMode() )
1791 : {
1792 0 : ForceUpdate(rPropertySet);
1793 : }
1794 : else
1795 : {
1796 : sal_Int32 nTmp;
1797 0 : if (::sax::Converter::convertNumber(nTmp, GetContent()))
1798 : {
1799 0 : Any aAny;
1800 0 : aAny <<= nTmp;
1801 0 : rPropertySet->setPropertyValue(sPropertyRevision, aAny);
1802 : }
1803 : }
1804 : }
1805 0 : }
1806 :
1807 :
1808 :
1809 :
1810 : // DocInfo fields with date/time attributes
1811 :
1812 :
1813 0 : TYPEINIT1( XMLDateTimeDocInfoImportContext, XMLSimpleDocInfoImportContext );
1814 :
1815 0 : XMLDateTimeDocInfoImportContext::XMLDateTimeDocInfoImportContext(
1816 : SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx,
1817 : const OUString& sLocalName, sal_uInt16 nToken)
1818 : : XMLSimpleDocInfoImportContext(rImport, rHlp, nPrfx, sLocalName,nToken, sal_False, sal_False)
1819 : , sPropertyNumberFormat(sAPI_number_format)
1820 : , sPropertyIsDate(sAPI_is_date)
1821 : , sPropertyIsFixedLanguage(sAPI_is_fixed_language)
1822 : , nFormat(0)
1823 : , bFormatOK(sal_False)
1824 : , bIsDate(false)
1825 : , bHasDateTime(false)
1826 0 : , bIsDefaultLanguage(true)
1827 : {
1828 : // we allow processing of EDIT_DURATION here, because import of actual
1829 : // is not supported anyway. If it was, we'd need an extra import class
1830 : // because times and time durations are presented differently!
1831 :
1832 0 : bValid = sal_True;
1833 0 : switch (nToken)
1834 : {
1835 : case XML_TOK_TEXT_DOCUMENT_CREATION_DATE:
1836 : case XML_TOK_TEXT_DOCUMENT_PRINT_DATE:
1837 : case XML_TOK_TEXT_DOCUMENT_SAVE_DATE:
1838 0 : bIsDate = sal_True;
1839 0 : bHasDateTime = sal_True;
1840 0 : break;
1841 : case XML_TOK_TEXT_DOCUMENT_CREATION_TIME:
1842 : case XML_TOK_TEXT_DOCUMENT_PRINT_TIME:
1843 : case XML_TOK_TEXT_DOCUMENT_SAVE_TIME:
1844 0 : bIsDate = sal_False;
1845 0 : bHasDateTime = sal_True;
1846 0 : break;
1847 : case XML_TOK_TEXT_DOCUMENT_EDIT_DURATION:
1848 0 : bIsDate = sal_False;
1849 0 : bHasDateTime = sal_False;
1850 0 : break;
1851 : default:
1852 : OSL_FAIL(
1853 : "XMLDateTimeDocInfoImportContext needs date/time doc. fields");
1854 0 : bValid = sal_False;
1855 0 : break;
1856 : }
1857 0 : }
1858 :
1859 0 : void XMLDateTimeDocInfoImportContext::ProcessAttribute(
1860 : sal_uInt16 nAttrToken,
1861 : const OUString& sAttrValue )
1862 : {
1863 0 : switch (nAttrToken)
1864 : {
1865 : case XML_TOK_TEXTFIELD_DATA_STYLE_NAME:
1866 : {
1867 0 : sal_Int32 nKey = GetImportHelper().GetDataStyleKey(
1868 0 : sAttrValue, &bIsDefaultLanguage);
1869 0 : if (-1 != nKey)
1870 : {
1871 0 : nFormat = nKey;
1872 0 : bFormatOK = sal_True;
1873 : }
1874 0 : break;
1875 : }
1876 : case XML_TOK_TEXTFIELD_FIXED:
1877 : XMLSimpleDocInfoImportContext::ProcessAttribute(nAttrToken,
1878 0 : sAttrValue);
1879 0 : break;
1880 : default:
1881 : // ignore -> we can't set date/time value anyway!
1882 0 : break;
1883 : }
1884 0 : }
1885 :
1886 0 : void XMLDateTimeDocInfoImportContext::PrepareField(
1887 : const Reference<XPropertySet> & xPropertySet)
1888 : {
1889 : // process fixed and presentation
1890 0 : XMLSimpleDocInfoImportContext::PrepareField(xPropertySet);
1891 :
1892 0 : Any aAny;
1893 :
1894 0 : if (bHasDateTime)
1895 : {
1896 0 : aAny.setValue( &bIsDate, ::getBooleanCppuType());
1897 0 : xPropertySet->setPropertyValue(sPropertyIsDate, aAny);
1898 : }
1899 :
1900 0 : if (bFormatOK)
1901 : {
1902 0 : aAny <<= nFormat;
1903 0 : xPropertySet->setPropertyValue(sPropertyNumberFormat, aAny);
1904 :
1905 0 : if( xPropertySet->getPropertySetInfo()->
1906 0 : hasPropertyByName( sPropertyIsFixedLanguage ) )
1907 : {
1908 0 : sal_Bool bIsFixedLanguage = ! bIsDefaultLanguage;
1909 0 : aAny.setValue( &bIsFixedLanguage, ::getBooleanCppuType() );
1910 0 : xPropertySet->setPropertyValue( sPropertyIsFixedLanguage, aAny );
1911 : }
1912 0 : }
1913 :
1914 : // can't set date/time/duration value! Sorry.
1915 0 : }
1916 :
1917 :
1918 :
1919 : // user defined docinfo fields
1920 :
1921 :
1922 0 : TYPEINIT1( XMLUserDocInfoImportContext, XMLSimpleDocInfoImportContext );
1923 :
1924 0 : XMLUserDocInfoImportContext::XMLUserDocInfoImportContext(
1925 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
1926 : sal_uInt16 nPrfx, const OUString& sLocalName, sal_uInt16 nToken) :
1927 : XMLSimpleDocInfoImportContext(rImport, rHlp, nPrfx,
1928 : sLocalName, nToken,
1929 : sal_False, sal_False)
1930 : , sPropertyName(sAPI_name)
1931 : , sPropertyNumberFormat(sAPI_number_format)
1932 : , sPropertyIsFixedLanguage(sAPI_is_fixed_language)
1933 : , nFormat(0)
1934 : , bFormatOK(sal_False)
1935 0 : , bIsDefaultLanguage( true )
1936 : {
1937 0 : bValid = sal_False;
1938 0 : }
1939 :
1940 0 : void XMLUserDocInfoImportContext::ProcessAttribute(
1941 : sal_uInt16 nAttrToken,
1942 : const OUString& sAttrValue )
1943 : {
1944 0 : switch (nAttrToken)
1945 : {
1946 : case XML_TOK_TEXTFIELD_DATA_STYLE_NAME:
1947 : {
1948 0 : sal_Int32 nKey = GetImportHelper().GetDataStyleKey(
1949 0 : sAttrValue, &bIsDefaultLanguage);
1950 0 : if (-1 != nKey)
1951 : {
1952 0 : nFormat = nKey;
1953 0 : bFormatOK = sal_True;
1954 : }
1955 0 : break;
1956 : }
1957 : case XML_TOK_TEXTFIELD_NAME:
1958 : {
1959 0 : if (!bValid)
1960 : {
1961 0 : SetServiceName(OUString(sAPI_docinfo_custom ) );
1962 0 : aName = sAttrValue;
1963 0 : bValid = sal_True;
1964 : }
1965 0 : break;
1966 : }
1967 :
1968 : default:
1969 : XMLSimpleDocInfoImportContext::ProcessAttribute(nAttrToken,
1970 0 : sAttrValue);
1971 0 : break;
1972 : }
1973 0 : }
1974 :
1975 0 : void XMLUserDocInfoImportContext::PrepareField(
1976 : const ::com::sun::star::uno::Reference<
1977 : ::com::sun::star::beans::XPropertySet> & xPropertySet)
1978 : {
1979 0 : uno::Any aAny;
1980 0 : if ( !aName.isEmpty() )
1981 : {
1982 0 : aAny <<= aName;
1983 0 : xPropertySet->setPropertyValue(sPropertyName, aAny);
1984 : }
1985 : Reference<XPropertySetInfo> xPropertySetInfo(
1986 0 : xPropertySet->getPropertySetInfo());
1987 0 : if (bFormatOK &&
1988 0 : xPropertySetInfo->hasPropertyByName(sPropertyNumberFormat))
1989 : {
1990 0 : aAny <<= nFormat;
1991 0 : xPropertySet->setPropertyValue(sPropertyNumberFormat, aAny);
1992 :
1993 0 : if( xPropertySetInfo->hasPropertyByName( sPropertyIsFixedLanguage ) )
1994 : {
1995 0 : sal_Bool bIsFixedLanguage = ! bIsDefaultLanguage;
1996 0 : aAny.setValue( &bIsFixedLanguage, ::getBooleanCppuType() );
1997 0 : xPropertySet->setPropertyValue( sPropertyIsFixedLanguage, aAny );
1998 : }
1999 : }
2000 :
2001 : // call superclass to handle "fixed"
2002 0 : XMLSimpleDocInfoImportContext::PrepareField(xPropertySet);
2003 0 : }
2004 :
2005 :
2006 :
2007 : // import hidden paragraph fields
2008 :
2009 :
2010 0 : TYPEINIT1( XMLHiddenParagraphImportContext, XMLTextFieldImportContext );
2011 :
2012 0 : XMLHiddenParagraphImportContext::XMLHiddenParagraphImportContext(
2013 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
2014 : sal_uInt16 nPrfx, const OUString& sLocalName) :
2015 : XMLTextFieldImportContext(rImport, rHlp, sAPI_hidden_paragraph,
2016 : nPrfx, sLocalName),
2017 : sPropertyCondition(sAPI_condition),
2018 : sPropertyIsHidden(sAPI_is_hidden),
2019 : sCondition(),
2020 0 : bIsHidden(sal_False)
2021 : {
2022 0 : }
2023 :
2024 0 : void XMLHiddenParagraphImportContext::ProcessAttribute(
2025 : sal_uInt16 nAttrToken,
2026 : const OUString& sAttrValue )
2027 : {
2028 0 : if (XML_TOK_TEXTFIELD_CONDITION == nAttrToken)
2029 : {
2030 0 : OUString sTmp;
2031 0 : sal_uInt16 nPrefix = GetImport().GetNamespaceMap()._GetKeyByAttrName(
2032 0 : sAttrValue, &sTmp, false );
2033 0 : if( XML_NAMESPACE_OOOW == nPrefix )
2034 : {
2035 0 : sCondition = sTmp;
2036 0 : bValid = sal_True;
2037 : }
2038 : else
2039 0 : sCondition = sAttrValue;
2040 : }
2041 0 : else if (XML_TOK_TEXTFIELD_IS_HIDDEN == nAttrToken)
2042 : {
2043 0 : bool bTmp(false);
2044 0 : if (::sax::Converter::convertBool(bTmp, sAttrValue))
2045 : {
2046 0 : bIsHidden = bTmp;
2047 : }
2048 : }
2049 0 : }
2050 :
2051 0 : void XMLHiddenParagraphImportContext::PrepareField(
2052 : const Reference<XPropertySet> & xPropertySet)
2053 : {
2054 0 : Any aAny;
2055 0 : aAny <<= sCondition;
2056 0 : xPropertySet->setPropertyValue(sPropertyCondition, aAny);
2057 :
2058 0 : aAny.setValue( &bIsHidden, ::getBooleanCppuType() );
2059 0 : xPropertySet->setPropertyValue(sPropertyIsHidden, aAny);
2060 0 : }
2061 :
2062 :
2063 :
2064 :
2065 : // import conditional text (<text:conditional-text>)
2066 :
2067 :
2068 0 : TYPEINIT1( XMLConditionalTextImportContext, XMLTextFieldImportContext );
2069 :
2070 0 : XMLConditionalTextImportContext::XMLConditionalTextImportContext(
2071 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
2072 : sal_uInt16 nPrfx, const OUString& sLocalName) :
2073 : XMLTextFieldImportContext(rImport, rHlp, sAPI_conditional_text,
2074 : nPrfx, sLocalName),
2075 : sPropertyCondition(sAPI_condition),
2076 : sPropertyTrueContent(sAPI_true_content),
2077 : sPropertyFalseContent(sAPI_false_content),
2078 : sPropertyIsConditionTrue(sAPI_is_condition_true),
2079 : sPropertyCurrentPresentation(sAPI_current_presentation),
2080 : bConditionOK(sal_False),
2081 : bTrueOK(sal_False),
2082 : bFalseOK(sal_False),
2083 0 : bCurrentValue(sal_False)
2084 : {
2085 0 : }
2086 :
2087 0 : void XMLConditionalTextImportContext::ProcessAttribute(
2088 : sal_uInt16 nAttrToken,
2089 : const OUString& sAttrValue )
2090 : {
2091 0 : switch (nAttrToken)
2092 : {
2093 : case XML_TOK_TEXTFIELD_CONDITION:
2094 : {
2095 0 : OUString sTmp;
2096 0 : sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
2097 0 : _GetKeyByAttrName( sAttrValue, &sTmp, false );
2098 0 : if( XML_NAMESPACE_OOOW == nPrefix )
2099 : {
2100 0 : sCondition = sTmp;
2101 0 : bConditionOK = sal_True;
2102 : }
2103 : else
2104 0 : sCondition = sAttrValue;
2105 : }
2106 0 : break;
2107 : case XML_TOK_TEXTFIELD_STRING_VALUE_IF_FALSE:
2108 0 : sFalseContent = sAttrValue;
2109 0 : bFalseOK = sal_True;
2110 0 : break;
2111 : case XML_TOK_TEXTFIELD_STRING_VALUE_IF_TRUE:
2112 0 : sTrueContent = sAttrValue;
2113 0 : bTrueOK = sal_True;
2114 0 : break;
2115 : case XML_TOK_TEXTFIELD_CURRENT_VALUE:
2116 : {
2117 0 : bool bTmp(false);
2118 0 : if (::sax::Converter::convertBool(bTmp, sAttrValue))
2119 : {
2120 0 : bCurrentValue = bTmp;
2121 : }
2122 0 : break;
2123 : }
2124 : }
2125 :
2126 0 : bValid = bConditionOK && bFalseOK && bTrueOK;
2127 0 : }
2128 :
2129 0 : void XMLConditionalTextImportContext::PrepareField(
2130 : const Reference<XPropertySet> & xPropertySet)
2131 : {
2132 0 : Any aAny;
2133 :
2134 0 : aAny <<= sCondition;
2135 0 : xPropertySet->setPropertyValue(sPropertyCondition, aAny);
2136 :
2137 0 : aAny <<= sFalseContent;
2138 0 : xPropertySet->setPropertyValue(sPropertyFalseContent, aAny);
2139 :
2140 0 : aAny <<= sTrueContent;
2141 0 : xPropertySet->setPropertyValue(sPropertyTrueContent, aAny);
2142 :
2143 0 : aAny.setValue( &bCurrentValue, ::getBooleanCppuType() );
2144 0 : xPropertySet->setPropertyValue(sPropertyIsConditionTrue, aAny);
2145 :
2146 0 : aAny <<= GetContent();
2147 0 : xPropertySet->setPropertyValue(sPropertyCurrentPresentation, aAny);
2148 0 : }
2149 :
2150 :
2151 :
2152 :
2153 : // hidden text
2154 :
2155 :
2156 0 : TYPEINIT1( XMLHiddenTextImportContext, XMLTextFieldImportContext);
2157 :
2158 0 : XMLHiddenTextImportContext::XMLHiddenTextImportContext(
2159 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
2160 : sal_uInt16 nPrfx, const OUString& sLocalName) :
2161 : XMLTextFieldImportContext(rImport, rHlp, sAPI_hidden_text,
2162 : nPrfx, sLocalName),
2163 : sPropertyCondition(sAPI_condition),
2164 : sPropertyContent(sAPI_content),
2165 : sPropertyIsHidden(sAPI_is_hidden),
2166 : bConditionOK(sal_False),
2167 : bStringOK(sal_False),
2168 0 : bIsHidden(sal_False)
2169 : {
2170 0 : }
2171 :
2172 0 : void XMLHiddenTextImportContext::ProcessAttribute(
2173 : sal_uInt16 nAttrToken,
2174 : const OUString& sAttrValue )
2175 : {
2176 0 : switch (nAttrToken)
2177 : {
2178 : case XML_TOK_TEXTFIELD_CONDITION:
2179 : {
2180 0 : OUString sTmp;
2181 0 : sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
2182 0 : _GetKeyByAttrName( sAttrValue, &sTmp, false );
2183 0 : if( XML_NAMESPACE_OOOW == nPrefix )
2184 : {
2185 0 : sCondition = sTmp;
2186 0 : bConditionOK = sal_True;
2187 : }
2188 : else
2189 0 : sCondition = sAttrValue;
2190 : }
2191 0 : break;
2192 : case XML_TOK_TEXTFIELD_STRING_VALUE:
2193 0 : sString = sAttrValue;
2194 0 : bStringOK = sal_True;
2195 0 : break;
2196 : case XML_TOK_TEXTFIELD_IS_HIDDEN:
2197 : {
2198 0 : bool bTmp(false);
2199 0 : if (::sax::Converter::convertBool(bTmp, sAttrValue))
2200 : {
2201 0 : bIsHidden = bTmp;
2202 : }
2203 0 : break;
2204 : }
2205 : }
2206 :
2207 0 : bValid = bConditionOK && bStringOK;
2208 0 : }
2209 :
2210 0 : void XMLHiddenTextImportContext::PrepareField(
2211 : const Reference<XPropertySet> & xPropertySet)
2212 : {
2213 0 : Any aAny;
2214 :
2215 0 : aAny <<= sCondition;
2216 0 : xPropertySet->setPropertyValue(sPropertyCondition, aAny);
2217 :
2218 0 : aAny <<= sString;
2219 0 : xPropertySet->setPropertyValue(sPropertyContent, aAny);
2220 :
2221 0 : aAny.setValue( &bIsHidden, ::getBooleanCppuType() );
2222 0 : xPropertySet->setPropertyValue(sPropertyIsHidden, aAny);
2223 0 : }
2224 :
2225 :
2226 :
2227 :
2228 : // file name fields
2229 :
2230 :
2231 0 : TYPEINIT1( XMLFileNameImportContext, XMLTextFieldImportContext );
2232 :
2233 : static const SvXMLEnumMapEntry aFilenameDisplayMap[] =
2234 : {
2235 : { XML_PATH, FilenameDisplayFormat::PATH },
2236 : { XML_NAME, FilenameDisplayFormat::NAME },
2237 : { XML_NAME_AND_EXTENSION, FilenameDisplayFormat::NAME_AND_EXT },
2238 : { XML_FULL, FilenameDisplayFormat::FULL },
2239 : { XML_TOKEN_INVALID, 0 }
2240 : };
2241 :
2242 0 : XMLFileNameImportContext::XMLFileNameImportContext(
2243 : SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx,
2244 : const OUString& sLocalName) :
2245 : XMLTextFieldImportContext(rImport, rHlp, sAPI_file_name,
2246 : nPrfx, sLocalName),
2247 : sPropertyFixed(sAPI_is_fixed),
2248 : sPropertyFileFormat(sAPI_file_format),
2249 : sPropertyCurrentPresentation(
2250 : sAPI_current_presentation),
2251 : nFormat(FilenameDisplayFormat::FULL),
2252 0 : bFixed(sal_False)
2253 : {
2254 0 : bValid = sal_True;
2255 0 : }
2256 :
2257 0 : void XMLFileNameImportContext::ProcessAttribute(
2258 : sal_uInt16 nAttrToken,
2259 : const OUString& sAttrValue )
2260 : {
2261 0 : switch (nAttrToken)
2262 : {
2263 : case XML_TOK_TEXTFIELD_FIXED:
2264 : {
2265 0 : bool bTmp(false);
2266 0 : if (::sax::Converter::convertBool(bTmp, sAttrValue))
2267 : {
2268 0 : bFixed = bTmp;
2269 : }
2270 0 : break;
2271 : }
2272 : case XML_TOK_TEXTFIELD_DISPLAY:
2273 : {
2274 : sal_uInt16 nTmp;
2275 0 : if (SvXMLUnitConverter::convertEnum(nTmp, sAttrValue,
2276 : aFilenameDisplayMap))
2277 : {
2278 0 : nFormat = (sal_uInt16)nTmp;
2279 : }
2280 0 : break;
2281 : }
2282 : default:
2283 : ; // unknown attribute: ignore
2284 0 : break;
2285 : }
2286 0 : }
2287 :
2288 0 : void XMLFileNameImportContext::PrepareField(
2289 : const Reference<XPropertySet> & xPropertySet)
2290 : {
2291 0 : Any aAny;
2292 :
2293 : // properties are optional
2294 : Reference<XPropertySetInfo> xPropertySetInfo(
2295 0 : xPropertySet->getPropertySetInfo());
2296 :
2297 0 : if (xPropertySetInfo->hasPropertyByName(sPropertyFixed))
2298 : {
2299 0 : aAny <<= bFixed;
2300 0 : xPropertySet->setPropertyValue(sPropertyFixed, aAny);
2301 : }
2302 :
2303 0 : if (xPropertySetInfo->hasPropertyByName(sPropertyFileFormat))
2304 : {
2305 0 : aAny <<= nFormat;
2306 0 : xPropertySet->setPropertyValue(sPropertyFileFormat, aAny);
2307 : }
2308 :
2309 0 : if (xPropertySetInfo->hasPropertyByName(sPropertyCurrentPresentation))
2310 : {
2311 0 : aAny <<= GetContent();
2312 0 : xPropertySet->setPropertyValue(sPropertyCurrentPresentation, aAny);
2313 0 : }
2314 0 : }
2315 :
2316 :
2317 :
2318 : // template name field
2319 :
2320 :
2321 : static const SvXMLEnumMapEntry aTemplateDisplayMap[] =
2322 : {
2323 : { XML_FULL, TemplateDisplayFormat::FULL },
2324 : { XML_PATH, TemplateDisplayFormat::PATH },
2325 : { XML_NAME, TemplateDisplayFormat::NAME },
2326 : { XML_NAME_AND_EXTENSION, TemplateDisplayFormat::NAME_AND_EXT },
2327 : { XML_AREA, TemplateDisplayFormat::AREA },
2328 : { XML_TITLE, TemplateDisplayFormat::TITLE },
2329 : { XML_TOKEN_INVALID, 0 }
2330 : };
2331 :
2332 0 : TYPEINIT1( XMLTemplateNameImportContext, XMLTextFieldImportContext );
2333 :
2334 0 : XMLTemplateNameImportContext::XMLTemplateNameImportContext(
2335 : SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx,
2336 : const OUString& sLocalName) :
2337 : XMLTextFieldImportContext(rImport, rHlp, sAPI_template_name,
2338 : nPrfx, sLocalName),
2339 : sPropertyFileFormat(sAPI_file_format),
2340 0 : nFormat(TemplateDisplayFormat::FULL)
2341 : {
2342 0 : bValid = sal_True;
2343 0 : }
2344 :
2345 0 : void XMLTemplateNameImportContext::ProcessAttribute(
2346 : sal_uInt16 nAttrToken,
2347 : const OUString& sAttrValue )
2348 : {
2349 0 : switch (nAttrToken)
2350 : {
2351 : case XML_TOK_TEXTFIELD_DISPLAY:
2352 : {
2353 : sal_uInt16 nTmp;
2354 0 : if (SvXMLUnitConverter::convertEnum(nTmp, sAttrValue,
2355 : aTemplateDisplayMap))
2356 : {
2357 0 : nFormat = (sal_uInt16)nTmp;
2358 : }
2359 0 : break;
2360 : }
2361 : default:
2362 : ; // unknown attribute: ignore
2363 0 : break;
2364 : }
2365 0 : }
2366 :
2367 0 : void XMLTemplateNameImportContext::PrepareField(
2368 : const Reference<XPropertySet> & xPropertySet)
2369 : {
2370 0 : Any aAny;
2371 :
2372 0 : aAny <<= nFormat;
2373 0 : xPropertySet->setPropertyValue(sPropertyFileFormat, aAny);
2374 0 : }
2375 :
2376 :
2377 :
2378 : // import chapter fields
2379 :
2380 :
2381 0 : TYPEINIT1( XMLChapterImportContext, XMLTextFieldImportContext );
2382 :
2383 : static const SvXMLEnumMapEntry aChapterDisplayMap[] =
2384 : {
2385 : { XML_NAME, ChapterFormat::NAME },
2386 : { XML_NUMBER, ChapterFormat::NUMBER },
2387 : { XML_NUMBER_AND_NAME, ChapterFormat::NAME_NUMBER },
2388 : { XML_PLAIN_NUMBER_AND_NAME, ChapterFormat::NO_PREFIX_SUFFIX },
2389 : { XML_PLAIN_NUMBER, ChapterFormat::DIGIT },
2390 : { XML_TOKEN_INVALID, 0 }
2391 : };
2392 :
2393 0 : XMLChapterImportContext::XMLChapterImportContext(
2394 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
2395 : sal_uInt16 nPrfx, const OUString& sLocalName) :
2396 : XMLTextFieldImportContext(rImport, rHlp, sAPI_chapter,
2397 : nPrfx, sLocalName),
2398 : sPropertyChapterFormat(
2399 : sAPI_chapter_format),
2400 : sPropertyLevel(sAPI_level),
2401 : nFormat(ChapterFormat::NAME_NUMBER),
2402 0 : nLevel(0)
2403 : {
2404 0 : bValid = sal_True;
2405 0 : }
2406 :
2407 0 : void XMLChapterImportContext::ProcessAttribute(
2408 : sal_uInt16 nAttrToken,
2409 : const OUString& sAttrValue )
2410 : {
2411 0 : switch (nAttrToken)
2412 : {
2413 : case XML_TOK_TEXTFIELD_DISPLAY:
2414 : {
2415 : sal_uInt16 nTmp;
2416 0 : if (SvXMLUnitConverter::convertEnum(nTmp, sAttrValue,
2417 : aChapterDisplayMap))
2418 : {
2419 0 : nFormat = (sal_Int16)nTmp;
2420 : }
2421 0 : break;
2422 : }
2423 : case XML_TOK_TEXTFIELD_OUTLINE_LEVEL:
2424 : {
2425 : sal_Int32 nTmp;
2426 0 : if (::sax::Converter::convertNumber(
2427 : nTmp, sAttrValue, 1,
2428 0 : GetImport().GetTextImport()->GetChapterNumbering()->getCount()
2429 0 : ))
2430 : {
2431 : // API numbers 0..9, we number 1..10
2432 0 : nLevel = (sal_Int8)nTmp;
2433 0 : nLevel--;
2434 : }
2435 0 : break;
2436 : }
2437 : default:
2438 : ; // unknown attribute: ignore
2439 0 : break;
2440 : }
2441 0 : }
2442 :
2443 0 : void XMLChapterImportContext::PrepareField(
2444 : const Reference<XPropertySet> & xPropertySet)
2445 : {
2446 0 : Any aAny;
2447 :
2448 0 : aAny <<= nFormat;
2449 0 : xPropertySet->setPropertyValue(sPropertyChapterFormat, aAny);
2450 :
2451 0 : aAny <<= nLevel;
2452 0 : xPropertySet->setPropertyValue(sPropertyLevel, aAny);
2453 0 : }
2454 :
2455 :
2456 :
2457 : // counting fields
2458 :
2459 :
2460 0 : TYPEINIT1( XMLCountFieldImportContext, XMLTextFieldImportContext );
2461 :
2462 0 : XMLCountFieldImportContext::XMLCountFieldImportContext(
2463 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
2464 : sal_uInt16 nPrfx, const OUString& sLocalName, sal_uInt16 nToken) :
2465 : XMLTextFieldImportContext(rImport, rHlp, MapTokenToServiceName(nToken),
2466 : nPrfx, sLocalName),
2467 : sPropertyNumberingType(
2468 : sAPI_numbering_type),
2469 : sNumberFormat(),
2470 : sLetterSync(),
2471 0 : bNumberFormatOK(sal_False)
2472 : {
2473 0 : bValid = sal_True;
2474 0 : }
2475 :
2476 0 : void XMLCountFieldImportContext::ProcessAttribute(
2477 : sal_uInt16 nAttrToken,
2478 : const OUString& sAttrValue )
2479 : {
2480 0 : switch (nAttrToken)
2481 : {
2482 : case XML_TOK_TEXTFIELD_NUM_FORMAT:
2483 0 : sNumberFormat = sAttrValue;
2484 0 : bNumberFormatOK = sal_True;
2485 0 : break;
2486 : case XML_TOK_TEXTFIELD_NUM_LETTER_SYNC:
2487 0 : sLetterSync = sAttrValue;
2488 0 : break;
2489 : }
2490 0 : }
2491 :
2492 0 : void XMLCountFieldImportContext::PrepareField(
2493 : const Reference<XPropertySet> & xPropertySet)
2494 : {
2495 0 : Any aAny;
2496 :
2497 : // properties optional
2498 : // (only page count, but do for all to save common implementation)
2499 :
2500 0 : if (xPropertySet->getPropertySetInfo()->
2501 0 : hasPropertyByName(sPropertyNumberingType))
2502 : {
2503 : sal_Int16 nNumType;
2504 0 : if( bNumberFormatOK )
2505 : {
2506 0 : nNumType= style::NumberingType::ARABIC;
2507 0 : GetImport().GetMM100UnitConverter().convertNumFormat( nNumType,
2508 : sNumberFormat,
2509 0 : sLetterSync );
2510 : }
2511 : else
2512 0 : nNumType = style::NumberingType::PAGE_DESCRIPTOR;
2513 0 : aAny <<= nNumType;
2514 0 : xPropertySet->setPropertyValue(sPropertyNumberingType, aAny);
2515 0 : }
2516 0 : }
2517 :
2518 0 : const sal_Char* XMLCountFieldImportContext::MapTokenToServiceName(
2519 : sal_uInt16 nToken)
2520 : {
2521 0 : const sal_Char* pServiceName = NULL;
2522 :
2523 0 : switch (nToken)
2524 : {
2525 : case XML_TOK_TEXT_WORD_COUNT:
2526 0 : pServiceName = sAPI_word_count;
2527 0 : break;
2528 : case XML_TOK_TEXT_PARAGRAPH_COUNT:
2529 0 : pServiceName = sAPI_paragraph_count;
2530 0 : break;
2531 : case XML_TOK_TEXT_TABLE_COUNT:
2532 0 : pServiceName = sAPI_table_count;
2533 0 : break;
2534 : case XML_TOK_TEXT_CHARACTER_COUNT:
2535 0 : pServiceName = sAPI_character_count;
2536 0 : break;
2537 : case XML_TOK_TEXT_IMAGE_COUNT:
2538 0 : pServiceName = sAPI_graphic_object_count;
2539 0 : break;
2540 : case XML_TOK_TEXT_OBJECT_COUNT:
2541 0 : pServiceName = sAPI_embedded_object_count;
2542 0 : break;
2543 : case XML_TOK_TEXT_PAGE_COUNT:
2544 0 : pServiceName = sAPI_page_count;
2545 0 : break;
2546 : default:
2547 0 : pServiceName = NULL;
2548 : OSL_FAIL("unknown count field!");
2549 0 : break;
2550 : }
2551 :
2552 0 : return pServiceName;
2553 : }
2554 :
2555 :
2556 :
2557 :
2558 : // page variable import
2559 :
2560 :
2561 0 : TYPEINIT1( XMLPageVarGetFieldImportContext, XMLTextFieldImportContext );
2562 :
2563 0 : XMLPageVarGetFieldImportContext::XMLPageVarGetFieldImportContext(
2564 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
2565 : sal_uInt16 nPrfx, const OUString& sLocalName) :
2566 : XMLTextFieldImportContext(rImport, rHlp, sAPI_reference_page_get,
2567 : nPrfx, sLocalName),
2568 : sPropertyNumberingType(
2569 : sAPI_numbering_type),
2570 : sNumberFormat(),
2571 : sLetterSync(),
2572 0 : bNumberFormatOK(sal_False)
2573 : {
2574 0 : bValid = sal_True;
2575 0 : }
2576 :
2577 0 : void XMLPageVarGetFieldImportContext::ProcessAttribute(
2578 : sal_uInt16 nAttrToken,
2579 : const OUString& sAttrValue )
2580 : {
2581 0 : switch (nAttrToken)
2582 : {
2583 : case XML_TOK_TEXTFIELD_NUM_FORMAT:
2584 0 : sNumberFormat = sAttrValue;
2585 0 : bNumberFormatOK = sal_True;
2586 0 : break;
2587 : case XML_TOK_TEXTFIELD_NUM_LETTER_SYNC:
2588 0 : sLetterSync = sAttrValue;
2589 0 : break;
2590 : }
2591 0 : }
2592 :
2593 0 : void XMLPageVarGetFieldImportContext::PrepareField(
2594 : const Reference<XPropertySet> & xPropertySet)
2595 : {
2596 0 : Any aAny;
2597 :
2598 : sal_Int16 nNumType;
2599 0 : if( bNumberFormatOK )
2600 : {
2601 0 : nNumType= style::NumberingType::ARABIC;
2602 0 : GetImport().GetMM100UnitConverter().convertNumFormat( nNumType,
2603 : sNumberFormat,
2604 0 : sLetterSync );
2605 : }
2606 : else
2607 0 : nNumType = style::NumberingType::PAGE_DESCRIPTOR;
2608 0 : aAny <<= nNumType;
2609 0 : xPropertySet->setPropertyValue(sPropertyNumberingType, aAny);
2610 :
2611 : // display old content (#96657#)
2612 0 : aAny <<= GetContent();
2613 0 : xPropertySet->setPropertyValue(
2614 : OUString(sAPI_current_presentation),
2615 0 : aAny );
2616 0 : }
2617 :
2618 :
2619 :
2620 :
2621 : // page variable set fields
2622 :
2623 :
2624 0 : TYPEINIT1(XMLPageVarSetFieldImportContext, XMLTextFieldImportContext);
2625 :
2626 0 : XMLPageVarSetFieldImportContext::XMLPageVarSetFieldImportContext(
2627 : SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx,
2628 : const OUString& sLocalName) :
2629 : XMLTextFieldImportContext(rImport, rHlp, sAPI_reference_page_set,
2630 : nPrfx, sLocalName),
2631 : sPropertyOn(sAPI_on),
2632 : sPropertyOffset(sAPI_offset),
2633 : nAdjust(0),
2634 0 : bActive(sal_True)
2635 : {
2636 0 : bValid = sal_True;
2637 0 : }
2638 :
2639 0 : void XMLPageVarSetFieldImportContext::ProcessAttribute(
2640 : sal_uInt16 nAttrToken,
2641 : const OUString& sAttrValue )
2642 : {
2643 0 : switch (nAttrToken)
2644 : {
2645 : case XML_TOK_TEXTFIELD_ACTIVE:
2646 : {
2647 0 : bool bTmp(false);
2648 0 : if (::sax::Converter::convertBool(bTmp, sAttrValue))
2649 : {
2650 0 : bActive = bTmp;
2651 : }
2652 0 : break;
2653 : }
2654 : case XML_TOK_TEXTFIELD_PAGE_ADJUST:
2655 : {
2656 0 : sal_Int32 nTmp(0);
2657 0 : if (::sax::Converter::convertNumber(nTmp, sAttrValue))
2658 : {
2659 0 : nAdjust = (sal_Int16)nTmp;
2660 : }
2661 0 : break;
2662 : }
2663 : default:
2664 0 : break;
2665 : }
2666 0 : }
2667 :
2668 0 : void XMLPageVarSetFieldImportContext::PrepareField(
2669 : const Reference<XPropertySet> & xPropertySet)
2670 : {
2671 0 : Any aAny;
2672 :
2673 0 : aAny.setValue(&bActive, ::getBooleanCppuType());
2674 0 : xPropertySet->setPropertyValue(sPropertyOn, aAny);
2675 :
2676 0 : aAny <<= nAdjust;
2677 0 : xPropertySet->setPropertyValue(sPropertyOffset, aAny);
2678 0 : }
2679 :
2680 :
2681 :
2682 :
2683 : // macro fields
2684 :
2685 :
2686 0 : TYPEINIT1( XMLMacroFieldImportContext, XMLTextFieldImportContext );
2687 :
2688 0 : XMLMacroFieldImportContext::XMLMacroFieldImportContext(
2689 : SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx,
2690 : const OUString& sLocalName) :
2691 : XMLTextFieldImportContext(rImport, rHlp, sAPI_macro,
2692 : nPrfx, sLocalName),
2693 : sPropertyHint(sAPI_hint),
2694 : sPropertyMacroName("MacroName"),
2695 : sPropertyScriptURL("ScriptURL"),
2696 0 : bDescriptionOK(sal_False)
2697 : {
2698 0 : }
2699 :
2700 0 : SvXMLImportContext* XMLMacroFieldImportContext::CreateChildContext(
2701 : sal_uInt16 nPrefix,
2702 : const OUString& rLocalName,
2703 : const Reference<XAttributeList> & xAttrList )
2704 : {
2705 0 : SvXMLImportContext* pContext = NULL;
2706 :
2707 0 : if ( (nPrefix == XML_NAMESPACE_OFFICE) &&
2708 0 : IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) )
2709 : {
2710 : // create events context and remember it!
2711 : pContext = new XMLEventsImportContext(
2712 0 : GetImport(), nPrefix, rLocalName );
2713 0 : xEventContext = pContext;
2714 0 : bValid = sal_True;
2715 : }
2716 : else
2717 : pContext = SvXMLImportContext::CreateChildContext(
2718 0 : nPrefix, rLocalName, xAttrList);
2719 :
2720 0 : return pContext;
2721 : }
2722 :
2723 :
2724 0 : void XMLMacroFieldImportContext::ProcessAttribute(
2725 : sal_uInt16 nAttrToken,
2726 : const OUString& sAttrValue )
2727 : {
2728 0 : switch (nAttrToken)
2729 : {
2730 : case XML_TOK_TEXTFIELD_DESCRIPTION:
2731 0 : sDescription = sAttrValue;
2732 0 : bDescriptionOK = sal_True;
2733 0 : break;
2734 : case XML_TOK_TEXTFIELD_NAME:
2735 0 : sMacro = sAttrValue;
2736 0 : bValid = sal_True;
2737 0 : break;
2738 : }
2739 0 : }
2740 :
2741 0 : void XMLMacroFieldImportContext::PrepareField(
2742 : const Reference<XPropertySet> & xPropertySet)
2743 : {
2744 0 : Any aAny;
2745 :
2746 0 : OUString sOnClick("OnClick");
2747 0 : OUString sPropertyMacroLibrary("MacroLibrary");
2748 :
2749 0 : aAny <<= (bDescriptionOK ? sDescription : GetContent());
2750 0 : xPropertySet->setPropertyValue(sPropertyHint, aAny);
2751 :
2752 : // if we have an events child element, we'll look for the OnClick
2753 : // event if not, it may be an old (pre-638i) document. Then, we'll
2754 : // have to look at the name attribute.
2755 0 : OUString sMacroName;
2756 0 : OUString sLibraryName;
2757 0 : OUString sScriptURL;
2758 :
2759 0 : if ( xEventContext.Is() )
2760 : {
2761 : // get event sequence
2762 : XMLEventsImportContext* pEvents =
2763 0 : (XMLEventsImportContext*)&xEventContext;
2764 0 : Sequence<PropertyValue> aValues;
2765 0 : pEvents->GetEventSequence( sOnClick, aValues );
2766 :
2767 0 : sal_Int32 nLength = aValues.getLength();
2768 0 : for( sal_Int32 i = 0; i < nLength; i++ )
2769 : {
2770 0 : if ( aValues[i].Name == "ScriptType" )
2771 : {
2772 : // ignore ScriptType
2773 : }
2774 0 : else if ( aValues[i].Name == "Library" )
2775 : {
2776 0 : aValues[i].Value >>= sLibraryName;
2777 : }
2778 0 : else if ( aValues[i].Name == "MacroName" )
2779 : {
2780 0 : aValues[i].Value >>= sMacroName;
2781 : }
2782 0 : if ( aValues[i].Name == "Script" )
2783 : {
2784 0 : aValues[i].Value >>= sScriptURL;
2785 : }
2786 0 : }
2787 : }
2788 : else
2789 : {
2790 : // disassemble old-style macro-name: Everything before the
2791 : // third-last dot is the library
2792 0 : sal_Int32 nPos = sMacro.getLength() + 1; // the loop starts with nPos--
2793 0 : const sal_Unicode* pBuf = sMacro.getStr();
2794 0 : for( sal_Int32 i = 0; (i < 3) && (nPos > 0); i++ )
2795 : {
2796 0 : nPos--;
2797 0 : while ( (pBuf[nPos] != '.') && (nPos > 0) )
2798 0 : nPos--;
2799 : }
2800 :
2801 0 : if (nPos > 0)
2802 : {
2803 0 : sLibraryName = sMacro.copy(0, nPos);
2804 0 : sMacroName = sMacro.copy(nPos+1);
2805 : }
2806 : else
2807 0 : sMacroName = sMacro;
2808 : }
2809 :
2810 0 : aAny <<= sScriptURL;
2811 0 : xPropertySet->setPropertyValue(sPropertyScriptURL, aAny);
2812 :
2813 0 : aAny <<= sMacroName;
2814 0 : xPropertySet->setPropertyValue(sPropertyMacroName, aAny);
2815 :
2816 0 : aAny <<= sLibraryName;
2817 0 : xPropertySet->setPropertyValue(sPropertyMacroLibrary, aAny);
2818 0 : }
2819 :
2820 :
2821 :
2822 :
2823 : // reference field import
2824 :
2825 :
2826 0 : TYPEINIT1( XMLReferenceFieldImportContext, XMLTextFieldImportContext );
2827 :
2828 0 : XMLReferenceFieldImportContext::XMLReferenceFieldImportContext(
2829 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
2830 : sal_uInt16 nToken, sal_uInt16 nPrfx, const OUString& sLocalName)
2831 : : XMLTextFieldImportContext(rImport, rHlp, sAPI_get_reference, nPrfx, sLocalName)
2832 : , sPropertyReferenceFieldPart(sAPI_reference_field_part)
2833 : , sPropertyReferenceFieldSource(sAPI_reference_field_source)
2834 : , sPropertySourceName(sAPI_source_name)
2835 : , sPropertyCurrentPresentation(sAPI_current_presentation)
2836 : , nElementToken(nToken)
2837 : , nSource(0)
2838 : , nType(ReferenceFieldPart::PAGE_DESC)
2839 : , bNameOK(sal_False)
2840 0 : , bTypeOK(sal_False)
2841 : {
2842 0 : }
2843 :
2844 : static SvXMLEnumMapEntry const lcl_aReferenceTypeTokenMap[] =
2845 : {
2846 : { XML_PAGE, ReferenceFieldPart::PAGE},
2847 : { XML_CHAPTER, ReferenceFieldPart::CHAPTER },
2848 : { XML_TEXT, ReferenceFieldPart::TEXT },
2849 : { XML_DIRECTION, ReferenceFieldPart::UP_DOWN },
2850 : { XML_CATEGORY_AND_VALUE, ReferenceFieldPart::CATEGORY_AND_NUMBER },
2851 : { XML_CAPTION, ReferenceFieldPart::ONLY_CAPTION },
2852 : { XML_VALUE, ReferenceFieldPart::ONLY_SEQUENCE_NUMBER },
2853 : // Core implementation for direct cross-references (#i81002#)
2854 : { XML_NUMBER, ReferenceFieldPart::NUMBER },
2855 : { XML_NUMBER_NO_SUPERIOR, ReferenceFieldPart::NUMBER_NO_CONTEXT },
2856 : { XML_NUMBER_ALL_SUPERIOR, ReferenceFieldPart::NUMBER_FULL_CONTEXT },
2857 : { XML_TOKEN_INVALID, 0 }
2858 : };
2859 :
2860 0 : void XMLReferenceFieldImportContext::StartElement(
2861 : const Reference<XAttributeList> & xAttrList)
2862 : {
2863 0 : bTypeOK = sal_True;
2864 0 : switch (nElementToken)
2865 : {
2866 : case XML_TOK_TEXT_REFERENCE_REF:
2867 0 : nSource = ReferenceFieldSource::REFERENCE_MARK;
2868 0 : break;
2869 : case XML_TOK_TEXT_BOOKMARK_REF:
2870 0 : nSource = ReferenceFieldSource::BOOKMARK;
2871 0 : break;
2872 : case XML_TOK_TEXT_NOTE_REF:
2873 0 : nSource = ReferenceFieldSource::FOOTNOTE;
2874 0 : break;
2875 : case XML_TOK_TEXT_SEQUENCE_REF:
2876 0 : nSource = ReferenceFieldSource::SEQUENCE_FIELD;
2877 0 : break;
2878 : default:
2879 0 : bTypeOK = sal_False;
2880 : OSL_FAIL("unknown reference field");
2881 0 : break;
2882 : }
2883 :
2884 0 : XMLTextFieldImportContext::StartElement(xAttrList);
2885 0 : }
2886 :
2887 :
2888 0 : void XMLReferenceFieldImportContext::ProcessAttribute(
2889 : sal_uInt16 nAttrToken,
2890 : const OUString& sAttrValue )
2891 : {
2892 0 : switch (nAttrToken)
2893 : {
2894 : case XML_TOK_TEXTFIELD_NOTE_CLASS:
2895 0 : if( IsXMLToken( sAttrValue, XML_ENDNOTE ) )
2896 0 : nSource = ReferenceFieldSource::ENDNOTE;
2897 0 : break;
2898 : case XML_TOK_TEXTFIELD_REF_NAME:
2899 0 : sName = sAttrValue;
2900 0 : bNameOK = sal_True;
2901 0 : break;
2902 : case XML_TOK_TEXTFIELD_REFERENCE_FORMAT:
2903 : {
2904 : sal_uInt16 nToken;
2905 0 : if (SvXMLUnitConverter::convertEnum(nToken, sAttrValue,
2906 : lcl_aReferenceTypeTokenMap))
2907 : {
2908 0 : nType = nToken;
2909 : }
2910 :
2911 : // check for sequence-only-attributes
2912 0 : if ( (XML_TOK_TEXT_SEQUENCE_REF != nElementToken) &&
2913 0 : ( (nType == ReferenceFieldPart::CATEGORY_AND_NUMBER) ||
2914 0 : (nType == ReferenceFieldPart::ONLY_CAPTION) ||
2915 0 : (nType == ReferenceFieldPart::ONLY_SEQUENCE_NUMBER) ) )
2916 : {
2917 0 : nType = ReferenceFieldPart::PAGE_DESC;
2918 : }
2919 :
2920 0 : break;
2921 : }
2922 : }
2923 :
2924 : // bValid: we need proper element type and name
2925 0 : bValid = bTypeOK && bNameOK;
2926 0 : }
2927 :
2928 0 : void XMLReferenceFieldImportContext::PrepareField(
2929 : const Reference<XPropertySet> & xPropertySet)
2930 : {
2931 0 : Any aAny;
2932 :
2933 0 : aAny <<= nType;
2934 0 : xPropertySet->setPropertyValue(sPropertyReferenceFieldPart, aAny);
2935 :
2936 0 : aAny <<= nSource;
2937 0 : xPropertySet->setPropertyValue(sPropertyReferenceFieldSource, aAny);
2938 :
2939 0 : switch (nElementToken)
2940 : {
2941 : case XML_TOK_TEXT_REFERENCE_REF:
2942 : case XML_TOK_TEXT_BOOKMARK_REF:
2943 0 : aAny <<= sName;
2944 0 : xPropertySet->setPropertyValue(sPropertySourceName, aAny);
2945 0 : break;
2946 :
2947 : case XML_TOK_TEXT_NOTE_REF:
2948 0 : GetImportHelper().ProcessFootnoteReference(sName, xPropertySet);
2949 0 : break;
2950 :
2951 : case XML_TOK_TEXT_SEQUENCE_REF:
2952 0 : GetImportHelper().ProcessSequenceReference(sName, xPropertySet);
2953 0 : break;
2954 : }
2955 :
2956 0 : aAny <<= GetContent();
2957 0 : xPropertySet->setPropertyValue(sPropertyCurrentPresentation, aAny);
2958 0 : }
2959 :
2960 :
2961 :
2962 :
2963 : // field declarations container
2964 :
2965 :
2966 : enum DdeFieldDeclAttrs
2967 : {
2968 : XML_TOK_DDEFIELD_NAME,
2969 : XML_TOK_DDEFIELD_APPLICATION,
2970 : XML_TOK_DDEFIELD_TOPIC,
2971 : XML_TOK_DDEFIELD_ITEM,
2972 : XML_TOK_DDEFIELD_UPDATE
2973 : };
2974 :
2975 : static const SvXMLTokenMapEntry aDdeDeclAttrTokenMap[] =
2976 : {
2977 : { XML_NAMESPACE_OFFICE, XML_NAME, XML_TOK_DDEFIELD_NAME },
2978 : { XML_NAMESPACE_OFFICE, XML_DDE_APPLICATION, XML_TOK_DDEFIELD_APPLICATION },
2979 : { XML_NAMESPACE_OFFICE, XML_DDE_TOPIC, XML_TOK_DDEFIELD_TOPIC },
2980 : { XML_NAMESPACE_OFFICE, XML_DDE_ITEM, XML_TOK_DDEFIELD_ITEM },
2981 : { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_UPDATE, XML_TOK_DDEFIELD_UPDATE },
2982 : XML_TOKEN_MAP_END
2983 : };
2984 :
2985 0 : TYPEINIT1( XMLDdeFieldDeclsImportContext, SvXMLImportContext );
2986 :
2987 0 : XMLDdeFieldDeclsImportContext::XMLDdeFieldDeclsImportContext(
2988 : SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& sLocalName) :
2989 : SvXMLImportContext(rImport, nPrfx, sLocalName),
2990 0 : aTokenMap(aDdeDeclAttrTokenMap)
2991 : {
2992 0 : }
2993 :
2994 0 : SvXMLImportContext * XMLDdeFieldDeclsImportContext::CreateChildContext(
2995 : sal_uInt16 nPrefix,
2996 : const OUString& rLocalName,
2997 : const Reference<XAttributeList> & xAttrList )
2998 : {
2999 0 : if ( (XML_NAMESPACE_TEXT == nPrefix) &&
3000 0 : (IsXMLToken(rLocalName, XML_DDE_CONNECTION_DECL)) )
3001 : {
3002 0 : return new XMLDdeFieldDeclImportContext(GetImport(), nPrefix,
3003 0 : rLocalName, aTokenMap);
3004 : }
3005 : else
3006 : {
3007 : return SvXMLImportContext::CreateChildContext(nPrefix,
3008 : rLocalName,
3009 0 : xAttrList);
3010 : }
3011 : }
3012 :
3013 :
3014 :
3015 :
3016 : // import dde field declaration
3017 :
3018 :
3019 0 : TYPEINIT1( XMLDdeFieldDeclImportContext, SvXMLImportContext );
3020 :
3021 0 : XMLDdeFieldDeclImportContext::XMLDdeFieldDeclImportContext(
3022 : SvXMLImport& rImport, sal_uInt16 nPrfx,
3023 : const OUString& sLocalName, const SvXMLTokenMap& rMap)
3024 : : SvXMLImportContext(rImport, nPrfx, sLocalName)
3025 : , sPropertyIsAutomaticUpdate(sAPI_is_automatic_update)
3026 : , sPropertyName(sAPI_name)
3027 : , sPropertyDDECommandType(sAPI_dde_command_type)
3028 : , sPropertyDDECommandFile(sAPI_dde_command_file)
3029 : , sPropertyDDECommandElement(sAPI_dde_command_element)
3030 0 : , rTokenMap(rMap)
3031 : {
3032 : DBG_ASSERT(XML_NAMESPACE_TEXT == nPrfx, "wrong prefix");
3033 : DBG_ASSERT(IsXMLToken(sLocalName, XML_DDE_CONNECTION_DECL), "wrong name");
3034 0 : }
3035 :
3036 0 : void XMLDdeFieldDeclImportContext::StartElement(
3037 : const Reference<XAttributeList> & xAttrList)
3038 : {
3039 0 : OUString sName;
3040 0 : OUString sCommandApplication;
3041 0 : OUString sCommandTopic;
3042 0 : OUString sCommandItem;
3043 :
3044 0 : sal_Bool bUpdate = sal_False;
3045 0 : bool bNameOK = false;
3046 0 : bool bCommandApplicationOK = false;
3047 0 : bool bCommandTopicOK = false;
3048 0 : bool bCommandItemOK = false;
3049 :
3050 : // process attributes
3051 0 : sal_Int16 nLength = xAttrList->getLength();
3052 0 : for(sal_Int16 i=0; i<nLength; i++)
3053 : {
3054 :
3055 0 : OUString sLocalName;
3056 0 : sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
3057 0 : GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName );
3058 :
3059 0 : switch (rTokenMap.Get(nPrefix, sLocalName))
3060 : {
3061 : case XML_TOK_DDEFIELD_NAME:
3062 0 : sName = xAttrList->getValueByIndex(i);
3063 0 : bNameOK = true;
3064 0 : break;
3065 : case XML_TOK_DDEFIELD_APPLICATION:
3066 0 : sCommandApplication = xAttrList->getValueByIndex(i);
3067 0 : bCommandApplicationOK = true;
3068 0 : break;
3069 : case XML_TOK_DDEFIELD_TOPIC:
3070 0 : sCommandTopic = xAttrList->getValueByIndex(i);
3071 0 : bCommandTopicOK = true;
3072 0 : break;
3073 : case XML_TOK_DDEFIELD_ITEM:
3074 0 : sCommandItem = xAttrList->getValueByIndex(i);
3075 0 : bCommandItemOK = true;
3076 0 : break;
3077 : case XML_TOK_DDEFIELD_UPDATE:
3078 : {
3079 0 : bool bTmp(false);
3080 0 : if (::sax::Converter::convertBool(
3081 0 : bTmp, xAttrList->getValueByIndex(i)) )
3082 : {
3083 0 : bUpdate = bTmp;
3084 : }
3085 0 : break;
3086 : }
3087 : }
3088 0 : }
3089 :
3090 : // valid data?
3091 0 : if (bNameOK && bCommandApplicationOK && bCommandTopicOK && bCommandItemOK)
3092 : {
3093 : // make service name
3094 0 : OUStringBuffer sBuf;
3095 0 : sBuf.appendAscii(sAPI_fieldmaster_prefix);
3096 0 : sBuf.appendAscii(sAPI_dde);
3097 :
3098 : // create DDE TextFieldMaster
3099 0 : Reference<XMultiServiceFactory> xFactory(GetImport().GetModel(),
3100 0 : UNO_QUERY);
3101 0 : if( xFactory.is() )
3102 : {
3103 : /* #i6432# There might be multiple occurrences of one DDE
3104 : declaration if it is used in more than one of
3105 : header/footer/body. createInstance will throw an exception if we
3106 : try to create the second, third, etc. instance of such a
3107 : declaration. Thus we ignore the exception. Otherwise this will
3108 : lead to an unloadable document. */
3109 : try
3110 : {
3111 : Reference<XInterface> xIfc =
3112 0 : xFactory->createInstance(sBuf.makeStringAndClear());
3113 0 : if( xIfc.is() )
3114 : {
3115 0 : Reference<XPropertySet> xPropSet( xIfc, UNO_QUERY );
3116 0 : if (xPropSet.is() &&
3117 0 : xPropSet->getPropertySetInfo()->hasPropertyByName(
3118 0 : sPropertyDDECommandType))
3119 : {
3120 0 : Any aAny;
3121 :
3122 0 : aAny <<= sName;
3123 0 : xPropSet->setPropertyValue(sPropertyName, aAny);
3124 :
3125 0 : aAny <<= sCommandApplication;
3126 0 : xPropSet->setPropertyValue(sPropertyDDECommandType, aAny);
3127 :
3128 0 : aAny <<= sCommandTopic;
3129 0 : xPropSet->setPropertyValue(sPropertyDDECommandFile, aAny);
3130 :
3131 0 : aAny <<= sCommandItem;
3132 0 : xPropSet->setPropertyValue(sPropertyDDECommandElement,
3133 0 : aAny);
3134 :
3135 0 : aAny.setValue(&bUpdate, ::getBooleanCppuType());
3136 0 : xPropSet->setPropertyValue(sPropertyIsAutomaticUpdate,
3137 0 : aAny);
3138 0 : }
3139 : // else: ignore (can't get XPropertySet, or DDE
3140 : // properties are not supported)
3141 0 : }
3142 : // else: ignore
3143 : }
3144 0 : catch (const Exception&)
3145 : {
3146 : //ignore
3147 : }
3148 0 : }
3149 : // else: ignore
3150 0 : }
3151 : // else: ignore
3152 0 : }
3153 :
3154 :
3155 :
3156 :
3157 : // DDE field import
3158 :
3159 :
3160 0 : TYPEINIT1( XMLDdeFieldImportContext, XMLTextFieldImportContext );
3161 :
3162 0 : XMLDdeFieldImportContext::XMLDdeFieldImportContext(
3163 : SvXMLImport& rImport, XMLTextImportHelper& rHlp,
3164 : sal_uInt16 nPrfx, const OUString& sLocalName) :
3165 : XMLTextFieldImportContext(rImport, rHlp, sAPI_dde,
3166 : nPrfx, sLocalName),
3167 : sName()
3168 0 : ,sPropertyContent(sAPI_content)
3169 : {
3170 0 : }
3171 :
3172 0 : void XMLDdeFieldImportContext::ProcessAttribute(
3173 : sal_uInt16 nAttrToken,
3174 : const OUString& sAttrValue )
3175 : {
3176 0 : if (XML_TOK_TEXTFIELD_CONNECTION_NAME == nAttrToken)
3177 : {
3178 0 : sName = sAttrValue;
3179 0 : bValid = sal_True;
3180 : }
3181 0 : }
3182 :
3183 0 : void XMLDdeFieldImportContext::EndElement()
3184 : {
3185 0 : if (bValid)
3186 : {
3187 : // find master
3188 0 : OUStringBuffer sBuf;
3189 0 : sBuf.appendAscii(sAPI_fieldmaster_prefix);
3190 0 : sBuf.appendAscii(sAPI_dde);
3191 0 : sBuf.append('.');
3192 0 : sBuf.append(sName);
3193 0 : OUString sMasterName = sBuf.makeStringAndClear();
3194 :
3195 0 : Reference<XTextFieldsSupplier> xTextFieldsSupp(GetImport().GetModel(),
3196 0 : UNO_QUERY);
3197 : Reference<container::XNameAccess> xFieldMasterNameAccess(
3198 0 : xTextFieldsSupp->getTextFieldMasters(), UNO_QUERY);
3199 :
3200 0 : if (xFieldMasterNameAccess->hasByName(sMasterName))
3201 : {
3202 0 : Reference<XPropertySet> xMaster;
3203 0 : Any aAny = xFieldMasterNameAccess->getByName(sMasterName);
3204 0 : aAny >>= xMaster;
3205 : //apply the content to the master
3206 0 : xMaster->setPropertyValue( sPropertyContent, uno::makeAny( GetContent()));
3207 : // master exists: create text field and attach
3208 0 : Reference<XPropertySet> xField;
3209 0 : sBuf.appendAscii(sAPI_textfield_prefix);
3210 0 : sBuf.appendAscii(sAPI_dde);
3211 0 : if (CreateField(xField, sBuf.makeStringAndClear()))
3212 : {
3213 0 : Reference<XDependentTextField> xDepTextField(xField,UNO_QUERY);
3214 0 : xDepTextField->attachTextFieldMaster(xMaster);
3215 :
3216 : // attach field to document
3217 0 : Reference<XTextContent> xTextContent(xField, UNO_QUERY);
3218 0 : if (xTextContent.is())
3219 : {
3220 0 : GetImportHelper().InsertTextContent(xTextContent);
3221 :
3222 : // we're lucky. nothing else to prepare.
3223 0 : }
3224 : // else: fail, because text content could not be created
3225 0 : }
3226 : // else: fail, because field could not be created
3227 0 : }
3228 : // else: fail, because no master was found (faulty document?!)
3229 : }
3230 : // not valid: ignore
3231 0 : }
3232 :
3233 0 : void XMLDdeFieldImportContext::PrepareField(
3234 : const Reference<XPropertySet> &)
3235 : {
3236 : // empty, since not needed.
3237 0 : }
3238 :
3239 :
3240 :
3241 : // sheet name fields
3242 :
3243 :
3244 0 : TYPEINIT1(XMLSheetNameImportContext, XMLTextFieldImportContext);
3245 :
3246 0 : XMLSheetNameImportContext::XMLSheetNameImportContext(
3247 : SvXMLImport& rImport,
3248 : XMLTextImportHelper& rHlp,
3249 : sal_uInt16 nPrfx,
3250 : const OUString& sLocalName) :
3251 : XMLTextFieldImportContext(rImport, rHlp, sAPI_sheet_name,
3252 0 : nPrfx, sLocalName)
3253 : {
3254 0 : bValid = sal_True; // always valid!
3255 0 : }
3256 :
3257 0 : void XMLSheetNameImportContext::ProcessAttribute(
3258 : sal_uInt16,
3259 : const OUString& )
3260 : {
3261 : // no attributes -> nothing to be done
3262 0 : }
3263 :
3264 0 : void XMLSheetNameImportContext::PrepareField(
3265 : const Reference<XPropertySet> &)
3266 : {
3267 : // no attributes -> nothing to be done
3268 0 : }
3269 :
3270 :
3271 :
3272 : // URL fields (Calc, Impress, Draw)
3273 :
3274 :
3275 0 : TYPEINIT1(XMLUrlFieldImportContext, XMLTextFieldImportContext);
3276 :
3277 0 : XMLUrlFieldImportContext::XMLUrlFieldImportContext(
3278 : SvXMLImport& rImport,
3279 : XMLTextImportHelper& rHlp,
3280 : sal_uInt16 nPrfx,
3281 : const OUString& sLocalName) :
3282 : XMLTextFieldImportContext(rImport, rHlp, sAPI_url,
3283 : nPrfx, sLocalName),
3284 : sPropertyURL(sAPI_url),
3285 : sPropertyTargetFrame(sAPI_target_frame),
3286 : sPropertyRepresentation(
3287 : sAPI_representation),
3288 0 : bFrameOK(sal_False)
3289 : {
3290 0 : }
3291 :
3292 0 : void XMLUrlFieldImportContext::ProcessAttribute(
3293 : sal_uInt16 nAttrToken,
3294 : const OUString& sAttrValue )
3295 : {
3296 0 : switch (nAttrToken)
3297 : {
3298 : case XML_TOK_TEXTFIELD_HREF:
3299 0 : sURL = GetImport().GetAbsoluteReference( sAttrValue );
3300 0 : bValid = sal_True;
3301 0 : break;
3302 : case XML_TOK_TEXTFIELD_TARGET_FRAME:
3303 0 : sFrame = sAttrValue;
3304 0 : bFrameOK = sal_True;
3305 0 : break;
3306 : default:
3307 : // ignore
3308 0 : break;
3309 : }
3310 0 : }
3311 :
3312 0 : void XMLUrlFieldImportContext::PrepareField(
3313 : const Reference<XPropertySet> & xPropertySet)
3314 : {
3315 0 : Any aAny;
3316 :
3317 0 : aAny <<= sURL;
3318 0 : xPropertySet->setPropertyValue(sPropertyURL, aAny);
3319 :
3320 0 : if (bFrameOK)
3321 : {
3322 0 : aAny <<= sFrame;
3323 0 : xPropertySet->setPropertyValue(sPropertyTargetFrame, aAny);
3324 : }
3325 :
3326 0 : aAny <<= GetContent();
3327 0 : xPropertySet->setPropertyValue(sPropertyRepresentation, aAny);
3328 0 : }
3329 :
3330 :
3331 0 : TYPEINIT1(XMLBibliographyFieldImportContext, XMLTextFieldImportContext);
3332 :
3333 :
3334 0 : XMLBibliographyFieldImportContext::XMLBibliographyFieldImportContext(
3335 : SvXMLImport& rImport,
3336 : XMLTextImportHelper& rHlp,
3337 : sal_uInt16 nPrfx,
3338 : const OUString& sLocalName) :
3339 : XMLTextFieldImportContext(rImport, rHlp, sAPI_bibliography,
3340 : nPrfx, sLocalName),
3341 : sPropertyFields("Fields"),
3342 0 : aValues()
3343 : {
3344 0 : bValid = sal_True;
3345 0 : }
3346 :
3347 : // TODO: this is the same map as is used in the text field export
3348 : static SvXMLEnumMapEntry const aBibliographyDataTypeMap[] =
3349 : {
3350 : { XML_ARTICLE, BibliographyDataType::ARTICLE },
3351 : { XML_BOOK, BibliographyDataType::BOOK },
3352 : { XML_BOOKLET, BibliographyDataType::BOOKLET },
3353 : { XML_CONFERENCE, BibliographyDataType::CONFERENCE },
3354 : { XML_CUSTOM1, BibliographyDataType::CUSTOM1 },
3355 : { XML_CUSTOM2, BibliographyDataType::CUSTOM2 },
3356 : { XML_CUSTOM3, BibliographyDataType::CUSTOM3 },
3357 : { XML_CUSTOM4, BibliographyDataType::CUSTOM4 },
3358 : { XML_CUSTOM5, BibliographyDataType::CUSTOM5 },
3359 : { XML_EMAIL, BibliographyDataType::EMAIL },
3360 : { XML_INBOOK, BibliographyDataType::INBOOK },
3361 : { XML_INCOLLECTION, BibliographyDataType::INCOLLECTION },
3362 : { XML_INPROCEEDINGS, BibliographyDataType::INPROCEEDINGS },
3363 : { XML_JOURNAL, BibliographyDataType::JOURNAL },
3364 : { XML_MANUAL, BibliographyDataType::MANUAL },
3365 : { XML_MASTERSTHESIS, BibliographyDataType::MASTERSTHESIS },
3366 : { XML_MISC, BibliographyDataType::MISC },
3367 : { XML_PHDTHESIS, BibliographyDataType::PHDTHESIS },
3368 : { XML_PROCEEDINGS, BibliographyDataType::PROCEEDINGS },
3369 : { XML_TECHREPORT, BibliographyDataType::TECHREPORT },
3370 : { XML_UNPUBLISHED, BibliographyDataType::UNPUBLISHED },
3371 : { XML_WWW, BibliographyDataType::WWW },
3372 : { XML_TOKEN_INVALID, 0 }
3373 : };
3374 :
3375 :
3376 : // we'll process attributes on our own and forfit the standard
3377 : // tecfield mechanism, because our attributes have zero overlp with
3378 : // all the oher textfields.
3379 0 : void XMLBibliographyFieldImportContext::StartElement(
3380 : const Reference<XAttributeList> & xAttrList)
3381 : {
3382 : // iterate over attributes
3383 0 : sal_Int16 nLength = xAttrList->getLength();
3384 0 : for(sal_Int16 i=0; i<nLength; i++) {
3385 :
3386 0 : OUString sLocalName;
3387 0 : sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
3388 0 : GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName );
3389 :
3390 0 : if (nPrefix == XML_NAMESPACE_TEXT)
3391 : {
3392 0 : PropertyValue aValue;
3393 0 : aValue.Name = OUString::createFromAscii(
3394 0 : MapBibliographyFieldName(sLocalName));
3395 0 : Any aAny;
3396 :
3397 : // special treatment for bibliography type
3398 : // biblio vs bibilio: #96658#; also read old documents
3399 0 : if (IsXMLToken(sLocalName, XML_BIBILIOGRAPHIC_TYPE) ||
3400 0 : IsXMLToken(sLocalName, XML_BIBLIOGRAPHY_TYPE) )
3401 : {
3402 : sal_uInt16 nTmp;
3403 0 : if (SvXMLUnitConverter::convertEnum(
3404 0 : nTmp, xAttrList->getValueByIndex(i),
3405 0 : aBibliographyDataTypeMap))
3406 : {
3407 0 : aAny <<= (sal_Int16)nTmp;
3408 0 : aValue.Value = aAny;
3409 :
3410 0 : aValues.push_back(aValue);
3411 : }
3412 : }
3413 : else
3414 : {
3415 0 : aAny <<= xAttrList->getValueByIndex(i);
3416 0 : aValue.Value = aAny;
3417 :
3418 0 : aValues.push_back(aValue);
3419 0 : }
3420 : }
3421 : // else: unknown namespace -> ignore
3422 0 : }
3423 0 : }
3424 :
3425 0 : void XMLBibliographyFieldImportContext::ProcessAttribute(
3426 : sal_uInt16,
3427 : const OUString& )
3428 : {
3429 : // attributes are handled in StartElement
3430 : OSL_FAIL("This should not have happened.");
3431 0 : }
3432 :
3433 :
3434 0 : void XMLBibliographyFieldImportContext::PrepareField(
3435 : const Reference<XPropertySet> & xPropertySet)
3436 : {
3437 : // convert vector into sequence
3438 0 : sal_Int32 nCount = aValues.size();
3439 0 : Sequence<PropertyValue> aValueSequence(nCount);
3440 0 : for(sal_Int32 i = 0; i < nCount; i++)
3441 : {
3442 0 : aValueSequence[i] = aValues[i];
3443 : }
3444 :
3445 : // set sequence
3446 0 : Any aAny;
3447 0 : aAny <<= aValueSequence;
3448 0 : xPropertySet->setPropertyValue(sPropertyFields, aAny);
3449 0 : }
3450 :
3451 0 : const sal_Char* XMLBibliographyFieldImportContext::MapBibliographyFieldName(
3452 : const OUString& sName)
3453 : {
3454 0 : const sal_Char* pName = NULL;
3455 :
3456 0 : if (IsXMLToken(sName, XML_IDENTIFIER))
3457 : {
3458 0 : pName = "Identifier";
3459 : }
3460 0 : else if (IsXMLToken(sName, XML_BIBILIOGRAPHIC_TYPE) ||
3461 0 : IsXMLToken(sName, XML_BIBLIOGRAPHY_TYPE) )
3462 : {
3463 : // biblio... vs bibilio...: #96658#: also read old documents
3464 0 : pName = "BibiliographicType";
3465 : }
3466 0 : else if (IsXMLToken(sName, XML_ADDRESS))
3467 : {
3468 0 : pName = "Address";
3469 : }
3470 0 : else if (IsXMLToken(sName, XML_ANNOTE))
3471 : {
3472 0 : pName = "Annote";
3473 : }
3474 0 : else if (IsXMLToken(sName, XML_AUTHOR))
3475 : {
3476 0 : pName = "Author";
3477 : }
3478 0 : else if (IsXMLToken(sName, XML_BOOKTITLE))
3479 : {
3480 0 : pName = "Booktitle";
3481 : }
3482 0 : else if (IsXMLToken(sName, XML_CHAPTER))
3483 : {
3484 0 : pName = "Chapter";
3485 : }
3486 0 : else if (IsXMLToken(sName, XML_EDITION))
3487 : {
3488 0 : pName = "Edition";
3489 : }
3490 0 : else if (IsXMLToken(sName, XML_EDITOR))
3491 : {
3492 0 : pName = "Editor";
3493 : }
3494 0 : else if (IsXMLToken(sName, XML_HOWPUBLISHED))
3495 : {
3496 0 : pName = "Howpublished";
3497 : }
3498 0 : else if (IsXMLToken(sName, XML_INSTITUTION))
3499 : {
3500 0 : pName = "Institution";
3501 : }
3502 0 : else if (IsXMLToken(sName, XML_JOURNAL))
3503 : {
3504 0 : pName = "Journal";
3505 : }
3506 0 : else if (IsXMLToken(sName, XML_MONTH))
3507 : {
3508 0 : pName = "Month";
3509 : }
3510 0 : else if (IsXMLToken(sName, XML_NOTE))
3511 : {
3512 0 : pName = "Note";
3513 : }
3514 0 : else if (IsXMLToken(sName, XML_NUMBER))
3515 : {
3516 0 : pName = "Number";
3517 : }
3518 0 : else if (IsXMLToken(sName, XML_ORGANIZATIONS))
3519 : {
3520 0 : pName = "Organizations";
3521 : }
3522 0 : else if (IsXMLToken(sName, XML_PAGES))
3523 : {
3524 0 : pName = "Pages";
3525 : }
3526 0 : else if (IsXMLToken(sName, XML_PUBLISHER))
3527 : {
3528 0 : pName = "Publisher";
3529 : }
3530 0 : else if (IsXMLToken(sName, XML_SCHOOL))
3531 : {
3532 0 : pName = "School";
3533 : }
3534 0 : else if (IsXMLToken(sName, XML_SERIES))
3535 : {
3536 0 : pName = "Series";
3537 : }
3538 0 : else if (IsXMLToken(sName, XML_TITLE))
3539 : {
3540 0 : pName = "Title";
3541 : }
3542 0 : else if (IsXMLToken(sName, XML_REPORT_TYPE))
3543 : {
3544 0 : pName = "Report_Type";
3545 : }
3546 0 : else if (IsXMLToken(sName, XML_VOLUME))
3547 : {
3548 0 : pName = "Volume";
3549 : }
3550 0 : else if (IsXMLToken(sName, XML_YEAR))
3551 : {
3552 0 : pName = "Year";
3553 : }
3554 0 : else if (IsXMLToken(sName, XML_URL))
3555 : {
3556 0 : pName = "URL";
3557 : }
3558 0 : else if (IsXMLToken(sName, XML_CUSTOM1))
3559 : {
3560 0 : pName = "Custom1";
3561 : }
3562 0 : else if (IsXMLToken(sName, XML_CUSTOM2))
3563 : {
3564 0 : pName = "Custom2";
3565 : }
3566 0 : else if (IsXMLToken(sName, XML_CUSTOM3))
3567 : {
3568 0 : pName = "Custom3";
3569 : }
3570 0 : else if (IsXMLToken(sName, XML_CUSTOM4))
3571 : {
3572 0 : pName = "Custom4";
3573 : }
3574 0 : else if (IsXMLToken(sName, XML_CUSTOM5))
3575 : {
3576 0 : pName = "Custom5";
3577 : }
3578 0 : else if (IsXMLToken(sName, XML_ISBN))
3579 : {
3580 0 : pName = "ISBN";
3581 : }
3582 : else
3583 : {
3584 : OSL_FAIL("Unknown bibliography info data");
3585 0 : pName = NULL;
3586 : }
3587 :
3588 0 : return pName;
3589 : }
3590 :
3591 :
3592 :
3593 : // Annotation Field
3594 :
3595 :
3596 0 : TYPEINIT1(XMLAnnotationImportContext, XMLTextFieldImportContext);
3597 :
3598 0 : XMLAnnotationImportContext::XMLAnnotationImportContext(
3599 : SvXMLImport& rImport,
3600 : XMLTextImportHelper& rHlp,
3601 : sal_uInt16 nToken,
3602 : sal_uInt16 nPrfx,
3603 : const OUString& sLocalName) :
3604 : XMLTextFieldImportContext(rImport, rHlp, sAPI_annotation,
3605 : nPrfx, sLocalName),
3606 : sPropertyAuthor(sAPI_author),
3607 : sPropertyInitials(sAPI_initials),
3608 : sPropertyContent(sAPI_content),
3609 : // why is there no UNO_NAME_DATE_TIME, but only UNO_NAME_DATE_TIME_VALUE?
3610 : sPropertyDate(sAPI_date_time_value),
3611 : sPropertyTextRange(sAPI_TextRange),
3612 : sPropertyName(sAPI_name),
3613 0 : m_nToken(nToken)
3614 : {
3615 0 : bValid = sal_True;
3616 :
3617 : // remember old list item and block (#91964#) and reset them
3618 : // for the text frame
3619 : // do this in the constructor, not in CreateChildContext (#i93392#)
3620 0 : GetImport().GetTextImport()->PushListContext();
3621 0 : }
3622 :
3623 0 : void XMLAnnotationImportContext::ProcessAttribute(
3624 : sal_uInt16 nToken,
3625 : const OUString& rValue )
3626 : {
3627 0 : if (nToken == XML_TOK_TEXT_NAME)
3628 0 : aName = rValue;
3629 0 : }
3630 :
3631 0 : SvXMLImportContext* XMLAnnotationImportContext::CreateChildContext(
3632 : sal_uInt16 nPrefix,
3633 : const OUString& rLocalName,
3634 : const Reference<XAttributeList >& xAttrList )
3635 : {
3636 0 : SvXMLImportContext *pContext = 0;
3637 0 : if( XML_NAMESPACE_DC == nPrefix )
3638 : {
3639 0 : if( IsXMLToken( rLocalName, XML_CREATOR ) )
3640 0 : pContext = new XMLStringBufferImportContext(GetImport(), nPrefix,
3641 0 : rLocalName, aAuthorBuffer);
3642 0 : else if( IsXMLToken( rLocalName, XML_DATE ) )
3643 0 : pContext = new XMLStringBufferImportContext(GetImport(), nPrefix,
3644 0 : rLocalName, aDateBuffer);
3645 : }
3646 0 : else if( XML_NAMESPACE_TEXT == nPrefix || XML_NAMESPACE_LO_EXT == nPrefix )
3647 : {
3648 0 : if( IsXMLToken( rLocalName, XML_SENDER_INITIALS ) )
3649 0 : pContext = new XMLStringBufferImportContext(GetImport(), nPrefix,
3650 0 : rLocalName, aInitialsBuffer);
3651 : }
3652 :
3653 0 : if( !pContext )
3654 : {
3655 : try
3656 : {
3657 0 : bool bOK = true;
3658 0 : if ( !mxField.is() )
3659 0 : bOK = CreateField( mxField, sServicePrefix + GetServiceName() );
3660 0 : if (bOK)
3661 : {
3662 0 : Any aAny = mxField->getPropertyValue( sPropertyTextRange );
3663 0 : Reference< XText > xText;
3664 0 : aAny >>= xText;
3665 0 : if( xText.is() )
3666 : {
3667 0 : UniReference < XMLTextImportHelper > xTxtImport = GetImport().GetTextImport();
3668 0 : if( !mxCursor.is() )
3669 : {
3670 0 : mxOldCursor = xTxtImport->GetCursor();
3671 0 : mxCursor = xText->createTextCursor();
3672 : }
3673 :
3674 0 : if( mxCursor.is() )
3675 : {
3676 0 : xTxtImport->SetCursor( mxCursor );
3677 0 : pContext = xTxtImport->CreateTextChildContext( GetImport(), nPrefix, rLocalName, xAttrList );
3678 0 : }
3679 0 : }
3680 : }
3681 : }
3682 0 : catch (const Exception&)
3683 : {
3684 : }
3685 :
3686 0 : if( !pContext )
3687 0 : pContext = new XMLStringBufferImportContext(GetImport(), nPrefix, rLocalName, aTextBuffer);
3688 : }
3689 :
3690 0 : return pContext;
3691 : }
3692 :
3693 0 : void XMLAnnotationImportContext::EndElement()
3694 : {
3695 : DBG_ASSERT(!GetServiceName().isEmpty(), "no service name for element!");
3696 0 : if( mxCursor.is() )
3697 : {
3698 : // delete addition newline
3699 0 : const OUString aEmpty;
3700 0 : mxCursor->gotoEnd( sal_False );
3701 0 : mxCursor->goLeft( 1, sal_True );
3702 0 : mxCursor->setString( aEmpty );
3703 :
3704 : // reset cursor
3705 0 : GetImport().GetTextImport()->ResetCursor();
3706 : }
3707 :
3708 0 : if( mxOldCursor.is() )
3709 0 : GetImport().GetTextImport()->SetCursor( mxOldCursor );
3710 :
3711 : // reinstall old list item #91964#
3712 0 : GetImport().GetTextImport()->PopListContext();
3713 :
3714 0 : if ( bValid )
3715 : {
3716 0 : if ( m_nToken == XML_TOK_TEXT_ANNOTATION_END )
3717 : {
3718 : // Search for a previous annotation with the same name.
3719 0 : uno::Reference< text::XTextContent > xPrevField;
3720 : {
3721 0 : Reference<XTextFieldsSupplier> xTextFieldsSupplier(GetImport().GetModel(), UNO_QUERY);
3722 0 : uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
3723 0 : uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
3724 0 : while (xFields->hasMoreElements())
3725 : {
3726 0 : uno::Reference<beans::XPropertySet> xCurrField(xFields->nextElement(), uno::UNO_QUERY);
3727 : uno::Reference<beans::XPropertySetInfo> const xInfo(
3728 0 : xCurrField->getPropertySetInfo());
3729 0 : if (xInfo->hasPropertyByName(sPropertyName))
3730 : {
3731 0 : OUString aFieldName;
3732 0 : xCurrField->getPropertyValue(sPropertyName) >>= aFieldName;
3733 0 : if (aFieldName == aName)
3734 : {
3735 0 : xPrevField.set( xCurrField, uno::UNO_QUERY );
3736 0 : break;
3737 0 : }
3738 : }
3739 0 : }
3740 : }
3741 0 : if ( xPrevField.is() )
3742 : {
3743 : // So we are ending a previous annotation,
3744 : // let's create a text range covering the old and the current position.
3745 0 : uno::Reference<text::XText> xText = GetImportHelper().GetText();
3746 : uno::Reference<text::XTextCursor> xCursor =
3747 0 : xText->createTextCursorByRange(GetImportHelper().GetCursorAsRange());
3748 0 : xCursor->gotoRange(xPrevField->getAnchor(), true);
3749 0 : uno::Reference<text::XTextRange> xTextRange(xCursor, uno::UNO_QUERY);
3750 :
3751 0 : xText->insertTextContent(xTextRange, xPrevField, !xCursor->isCollapsed());
3752 0 : }
3753 : }
3754 : else
3755 : {
3756 0 : if ( mxField.is() || CreateField( mxField, sServicePrefix + GetServiceName() ) )
3757 : {
3758 : // set field properties
3759 0 : PrepareField( mxField );
3760 :
3761 : // attach field to document
3762 0 : Reference < XTextContent > xTextContent( mxField, UNO_QUERY );
3763 :
3764 : // workaround for #80606#
3765 : try
3766 : {
3767 0 : GetImportHelper().InsertTextContent( xTextContent );
3768 : }
3769 0 : catch (lang::IllegalArgumentException)
3770 : {
3771 : // ignore
3772 0 : }
3773 : }
3774 : }
3775 : }
3776 : else
3777 0 : GetImportHelper().InsertString(GetContent());
3778 0 : }
3779 :
3780 0 : void XMLAnnotationImportContext::PrepareField(
3781 : const Reference<XPropertySet> & xPropertySet )
3782 : {
3783 : // import (possibly empty) author
3784 0 : OUString sAuthor( aAuthorBuffer.makeStringAndClear() );
3785 0 : xPropertySet->setPropertyValue(sPropertyAuthor, makeAny(sAuthor));
3786 :
3787 : // import (possibly empty) initials
3788 0 : OUString sInitials( aInitialsBuffer.makeStringAndClear() );
3789 0 : xPropertySet->setPropertyValue(sPropertyInitials, makeAny(sInitials));
3790 :
3791 0 : util::DateTime aDateTime;
3792 0 : if (::sax::Converter::parseDateTime(aDateTime, 0,
3793 0 : aDateBuffer.makeStringAndClear()))
3794 : {
3795 : /*
3796 : Date aDate;
3797 : aDate.Year = aDateTime.Year;
3798 : aDate.Month = aDateTime.Month;
3799 : aDate.Day = aDateTime.Day;
3800 : xPropertySet->setPropertyValue(sPropertyDate, makeAny(aDate));
3801 : */
3802 0 : xPropertySet->setPropertyValue(sPropertyDate, makeAny(aDateTime));
3803 : }
3804 :
3805 0 : OUString sBuffer = aTextBuffer.makeStringAndClear();
3806 0 : if ( sBuffer.getLength() )
3807 : {
3808 : // delete last paragraph mark (if necessary)
3809 0 : if (sal_Char(0x0a) == sBuffer[sBuffer.getLength()-1])
3810 0 : sBuffer = sBuffer.copy(0, sBuffer.getLength()-1);
3811 0 : xPropertySet->setPropertyValue(sPropertyContent, makeAny(sBuffer));
3812 : }
3813 :
3814 0 : if (!aName.isEmpty())
3815 0 : xPropertySet->setPropertyValue(sPropertyName, makeAny(aName));
3816 0 : }
3817 :
3818 :
3819 :
3820 :
3821 : // script field
3822 :
3823 :
3824 0 : TYPEINIT1(XMLScriptImportContext, XMLTextFieldImportContext);
3825 :
3826 0 : XMLScriptImportContext::XMLScriptImportContext(
3827 : SvXMLImport& rImport,
3828 : XMLTextImportHelper& rHlp,
3829 : sal_uInt16 nPrfx,
3830 : const OUString& sLocalName)
3831 : : XMLTextFieldImportContext(rImport, rHlp, sAPI_script, nPrfx, sLocalName)
3832 : , sPropertyScriptType(sAPI_script_type)
3833 : , sPropertyURLContent(sAPI_url_content)
3834 : , sPropertyContent(sAPI_content)
3835 : , bContentOK(sal_False)
3836 0 : , bScriptTypeOK(sal_False)
3837 : {
3838 0 : }
3839 :
3840 0 : void XMLScriptImportContext::ProcessAttribute(
3841 : sal_uInt16 nAttrToken,
3842 : const OUString& sAttrValue )
3843 : {
3844 0 : switch (nAttrToken)
3845 : {
3846 : case XML_TOK_TEXTFIELD_HREF:
3847 0 : sContent = GetImport().GetAbsoluteReference( sAttrValue );
3848 0 : bContentOK = sal_True;
3849 0 : break;
3850 :
3851 : case XML_TOK_TEXTFIELD_LANGUAGE:
3852 0 : sScriptType = sAttrValue;
3853 0 : bScriptTypeOK = sal_True;
3854 0 : break;
3855 :
3856 : default:
3857 : // ignore
3858 0 : break;
3859 : }
3860 :
3861 : // always valid (even without ScriptType; cf- #96531#)
3862 0 : bValid = sal_True;
3863 0 : }
3864 :
3865 0 : void XMLScriptImportContext::PrepareField(
3866 : const Reference<XPropertySet> & xPropertySet)
3867 : {
3868 0 : Any aAny;
3869 :
3870 : // if href attribute was present, we use it. Else we use element content
3871 0 : if (! bContentOK)
3872 : {
3873 0 : sContent = GetContent();
3874 : }
3875 0 : aAny <<= sContent;
3876 0 : xPropertySet->setPropertyValue(sPropertyContent, aAny);
3877 :
3878 : // URL or script text? We use URL if we have an href-attribute
3879 0 : aAny.setValue(&bContentOK, ::getBooleanCppuType());
3880 0 : xPropertySet->setPropertyValue(sPropertyURLContent, aAny);
3881 :
3882 0 : aAny <<= sScriptType;
3883 0 : xPropertySet->setPropertyValue(sPropertyScriptType, aAny);
3884 0 : }
3885 :
3886 :
3887 : // measure field
3888 :
3889 :
3890 0 : TYPEINIT1(XMLMeasureFieldImportContext, XMLTextFieldImportContext);
3891 :
3892 0 : XMLMeasureFieldImportContext::XMLMeasureFieldImportContext(
3893 : SvXMLImport& rImport,
3894 : XMLTextImportHelper& rHlp,
3895 : sal_uInt16 nPrfx,
3896 : const OUString& sLocalName) :
3897 : XMLTextFieldImportContext(rImport, rHlp, sAPI_measure,
3898 : nPrfx, sLocalName),
3899 0 : mnKind( 0 )
3900 : {
3901 0 : }
3902 :
3903 0 : void XMLMeasureFieldImportContext::ProcessAttribute(
3904 : sal_uInt16 nAttrToken,
3905 : const OUString& sAttrValue )
3906 : {
3907 0 : switch (nAttrToken)
3908 : {
3909 : case XML_TOK_TEXTFIELD_MEASURE_KIND:
3910 0 : if( IsXMLToken( sAttrValue, XML_VALUE ) )
3911 : {
3912 0 : mnKind = 0; bValid = sal_True;
3913 : }
3914 0 : else if( IsXMLToken( sAttrValue, XML_UNIT ) )
3915 : {
3916 0 : mnKind = 1; bValid = sal_True;
3917 : }
3918 0 : else if( IsXMLToken( sAttrValue, XML_GAP ) )
3919 : {
3920 0 : mnKind = 2; bValid = sal_True;
3921 : }
3922 0 : break;
3923 : }
3924 0 : }
3925 :
3926 0 : void XMLMeasureFieldImportContext::PrepareField(
3927 : const Reference<XPropertySet> & xPropertySet)
3928 : {
3929 0 : Any aAny;
3930 0 : aAny <<= mnKind;
3931 0 : xPropertySet->setPropertyValue("Kind", aAny);
3932 0 : }
3933 :
3934 :
3935 :
3936 :
3937 : // dropdown field
3938 :
3939 :
3940 :
3941 0 : TYPEINIT1( XMLDropDownFieldImportContext, XMLTextFieldImportContext );
3942 :
3943 0 : XMLDropDownFieldImportContext::XMLDropDownFieldImportContext(
3944 : SvXMLImport& rImport,
3945 : XMLTextImportHelper& rHlp,
3946 : sal_uInt16 nPrfx,
3947 : const OUString& sLocalName) :
3948 : XMLTextFieldImportContext( rImport, rHlp, sAPI_drop_down,
3949 : nPrfx, sLocalName ),
3950 : aLabels(),
3951 : sName(),
3952 : nSelected( -1 ),
3953 : bNameOK( false ),
3954 : bHelpOK(false),
3955 : bHintOK(false),
3956 : sPropertyItems( "Items" ),
3957 : sPropertySelectedItem( "SelectedItem" ),
3958 : sPropertyName( "Name" ),
3959 : sPropertyHelp( "Help" ),
3960 0 : sPropertyToolTip( "Tooltip" )
3961 : {
3962 0 : bValid = sal_True;
3963 0 : }
3964 :
3965 0 : static bool lcl_ProcessLabel( const SvXMLImport& rImport,
3966 : const Reference<XAttributeList>& xAttrList,
3967 : OUString& rLabel,
3968 : bool& rIsSelected )
3969 : {
3970 0 : bool bValid = false;
3971 0 : sal_Int16 nLength = xAttrList->getLength();
3972 0 : for( sal_Int16 n = 0; n < nLength; n++ )
3973 : {
3974 0 : OUString sLocalName;
3975 0 : sal_uInt16 nPrefix = rImport.GetNamespaceMap().
3976 0 : GetKeyByAttrName( xAttrList->getNameByIndex(n), &sLocalName );
3977 0 : OUString sValue = xAttrList->getValueByIndex(n);
3978 :
3979 0 : if( nPrefix == XML_NAMESPACE_TEXT )
3980 : {
3981 0 : if( IsXMLToken( sLocalName, XML_VALUE ) )
3982 : {
3983 0 : rLabel = sValue;
3984 0 : bValid = true;
3985 : }
3986 0 : else if( IsXMLToken( sLocalName, XML_CURRENT_SELECTED ) )
3987 : {
3988 0 : bool bTmp(false);
3989 0 : if (::sax::Converter::convertBool( bTmp, sValue ))
3990 0 : rIsSelected = bTmp;
3991 : }
3992 : }
3993 0 : }
3994 0 : return bValid;
3995 : }
3996 :
3997 0 : SvXMLImportContext* XMLDropDownFieldImportContext::CreateChildContext(
3998 : sal_uInt16 nPrefix,
3999 : const OUString& rLocalName,
4000 : const Reference<XAttributeList>& xAttrList )
4001 : {
4002 0 : if( nPrefix == XML_NAMESPACE_TEXT &&
4003 0 : IsXMLToken( rLocalName, XML_LABEL ) )
4004 : {
4005 0 : OUString sLabel;
4006 0 : bool bIsSelected = false;
4007 0 : if( lcl_ProcessLabel( GetImport(), xAttrList, sLabel, bIsSelected ) )
4008 : {
4009 0 : if( bIsSelected )
4010 0 : nSelected = static_cast<sal_Int32>( aLabels.size() );
4011 0 : aLabels.push_back( sLabel );
4012 0 : }
4013 : }
4014 0 : return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
4015 : }
4016 :
4017 0 : void XMLDropDownFieldImportContext::ProcessAttribute(
4018 : sal_uInt16 nAttrToken,
4019 : const OUString& sAttrValue )
4020 : {
4021 0 : if( nAttrToken == XML_TOK_TEXTFIELD_NAME )
4022 : {
4023 0 : sName = sAttrValue;
4024 0 : bNameOK = true;
4025 : }
4026 0 : else if (nAttrToken == XML_TOK_TEXTFIELD_HELP)
4027 : {
4028 0 : sHelp = sAttrValue;
4029 0 : bHelpOK = true;
4030 : }
4031 0 : else if (nAttrToken == XML_TOK_TEXTFIELD_HINT)
4032 : {
4033 0 : sHint = sAttrValue;
4034 0 : bHintOK = true;
4035 : }
4036 0 : }
4037 :
4038 0 : void XMLDropDownFieldImportContext::PrepareField(
4039 : const Reference<XPropertySet>& xPropertySet)
4040 : {
4041 : // create sequence
4042 0 : sal_Int32 nLength = static_cast<sal_Int32>( aLabels.size() );
4043 0 : Sequence<OUString> aSequence( nLength );
4044 0 : OUString* pSequence = aSequence.getArray();
4045 0 : for( sal_Int32 n = 0; n < nLength; n++ )
4046 0 : pSequence[n] = aLabels[n];
4047 :
4048 : // now set values:
4049 0 : Any aAny;
4050 :
4051 0 : aAny <<= aSequence;
4052 0 : xPropertySet->setPropertyValue( sPropertyItems, aAny );
4053 :
4054 0 : if( nSelected >= 0 && nSelected < nLength )
4055 : {
4056 0 : aAny <<= pSequence[nSelected];
4057 0 : xPropertySet->setPropertyValue( sPropertySelectedItem, aAny );
4058 : }
4059 :
4060 : // set name
4061 0 : if( bNameOK )
4062 : {
4063 0 : aAny <<= sName;
4064 0 : xPropertySet->setPropertyValue( sPropertyName, aAny );
4065 : }
4066 : // set help
4067 0 : if( bHelpOK )
4068 : {
4069 0 : aAny <<= sHelp;
4070 0 : xPropertySet->setPropertyValue( sPropertyHelp, aAny );
4071 : }
4072 : // set hint
4073 0 : if( bHintOK )
4074 : {
4075 0 : aAny <<= sHint;
4076 0 : xPropertySet->setPropertyValue( sPropertyToolTip, aAny );
4077 0 : }
4078 :
4079 0 : }
4080 :
4081 : /** import header fields (<draw:header>) */
4082 0 : TYPEINIT1( XMLHeaderFieldImportContext, XMLTextFieldImportContext );
4083 :
4084 0 : XMLHeaderFieldImportContext::XMLHeaderFieldImportContext(
4085 : SvXMLImport& rImport, /// XML Import
4086 : XMLTextImportHelper& rHlp, /// Text import helper
4087 : sal_uInt16 nPrfx, /// namespace prefix
4088 : const OUString& sLocalName) /// element name w/o prefix
4089 0 : : XMLTextFieldImportContext(rImport, rHlp, sAPI_header, nPrfx, sLocalName )
4090 : {
4091 0 : sServicePrefix = OUString(sAPI_presentation_prefix );
4092 0 : bValid = sal_True;
4093 0 : }
4094 :
4095 : /// process attribute values
4096 0 : void XMLHeaderFieldImportContext::ProcessAttribute( sal_uInt16, const OUString& )
4097 : {
4098 0 : }
4099 :
4100 : /// prepare XTextField for insertion into document
4101 0 : void XMLHeaderFieldImportContext::PrepareField(const Reference<XPropertySet> &)
4102 : {
4103 0 : }
4104 :
4105 : /** import footer fields (<draw:footer>) */
4106 0 : TYPEINIT1( XMLFooterFieldImportContext, XMLTextFieldImportContext );
4107 :
4108 0 : XMLFooterFieldImportContext::XMLFooterFieldImportContext(
4109 : SvXMLImport& rImport, /// XML Import
4110 : XMLTextImportHelper& rHlp, /// Text import helper
4111 : sal_uInt16 nPrfx, /// namespace prefix
4112 : const OUString& sLocalName) /// element name w/o prefix
4113 0 : : XMLTextFieldImportContext(rImport, rHlp, sAPI_footer, nPrfx, sLocalName )
4114 : {
4115 0 : sServicePrefix = OUString(sAPI_presentation_prefix );
4116 0 : bValid = sal_True;
4117 0 : }
4118 :
4119 : /// process attribute values
4120 0 : void XMLFooterFieldImportContext::ProcessAttribute( sal_uInt16, const OUString& )
4121 : {
4122 0 : }
4123 :
4124 : /// prepare XTextField for insertion into document
4125 0 : void XMLFooterFieldImportContext::PrepareField(const Reference<XPropertySet> &)
4126 : {
4127 0 : }
4128 :
4129 :
4130 : /** import footer fields (<draw:date-and-time>) */
4131 0 : TYPEINIT1( XMLDateTimeFieldImportContext, XMLTextFieldImportContext );
4132 :
4133 0 : XMLDateTimeFieldImportContext::XMLDateTimeFieldImportContext(
4134 : SvXMLImport& rImport, /// XML Import
4135 : XMLTextImportHelper& rHlp, /// Text import helper
4136 : sal_uInt16 nPrfx, /// namespace prefix
4137 : const OUString& sLocalName) /// element name w/o prefix
4138 0 : : XMLTextFieldImportContext(rImport, rHlp, sAPI_datetime, nPrfx, sLocalName )
4139 : {
4140 0 : sServicePrefix = OUString(sAPI_presentation_prefix );
4141 0 : bValid = sal_True;
4142 0 : }
4143 :
4144 : /// process attribute values
4145 0 : void XMLDateTimeFieldImportContext::ProcessAttribute( sal_uInt16,
4146 : const OUString& )
4147 : {
4148 0 : }
4149 :
4150 : /// prepare XTextField for insertion into document
4151 0 : void XMLDateTimeFieldImportContext::PrepareField(
4152 : const ::com::sun::star::uno::Reference<
4153 : ::com::sun::star::beans::XPropertySet> &)
4154 : {
4155 0 : }
4156 :
4157 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|