LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/text - txtfldi.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 313 1608 19.5 %
Date: 2012-12-17 Functions: 38 344 11.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10