LCOV - code coverage report
Current view: top level - xmloff/source/text - txtvfldi.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 133 521 25.5 %
Date: 2012-08-25 Functions: 8 109 7.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 118 777 15.2 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : /** @#file
      31                 :            :  *
      32                 :            :  *  export of all variable related text fields (and database display field)
      33                 :            :  */
      34                 :            : #include "txtvfldi.hxx"
      35                 :            : #include <xmloff/xmltoken.hxx>
      36                 :            : #include <xmloff/txtimp.hxx>
      37                 :            : #include <xmloff/xmlnumi.hxx>
      38                 :            : #include "xmloff/xmlnmspe.hxx"
      39                 :            : #include <xmloff/nmspmap.hxx>
      40                 :            : #include "xmloff/i18nmap.hxx"
      41                 :            : #include <xmloff/xmlimp.hxx>
      42                 :            : #include <xmloff/xmluconv.hxx>
      43                 :            : #include <xmloff/xmlement.hxx>
      44                 :            : #include <com/sun/star/text/SetVariableType.hpp>
      45                 :            : #include <com/sun/star/text/XTextField.hpp>
      46                 :            : #include <com/sun/star/text/XDependentTextField.hpp>
      47                 :            : #include <com/sun/star/text/XTextFieldsSupplier.hpp>
      48                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      49                 :            : #include <com/sun/star/beans/XPropertySetInfo.hpp>
      50                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      51                 :            : #include <com/sun/star/xml/sax/XAttributeList.hpp>
      52                 :            : 
      53                 :            : #include <sax/tools/converter.hxx>
      54                 :            : 
      55                 :            : #include <rtl/ustring.hxx>
      56                 :            : 
      57                 :            : #include <tools/debug.hxx>
      58                 :            : 
      59                 :            : 
      60                 :            : // service names
      61                 :            : static const sal_Char sAPI_textfield_prefix[]   = "com.sun.star.text.TextField.";
      62                 :            : static const sal_Char sAPI_fieldmaster_prefix[] = "com.sun.star.text.FieldMaster.";
      63                 :            : static const sal_Char sAPI_input[]              = "Input";
      64                 :            : static const sal_Char sAPI_input_user[]         = "InputUser";
      65                 :            : static const sal_Char sAPI_get_expression[]     = "GetExpression";
      66                 :            : static const sal_Char sAPI_set_expression[]     = "SetExpression";
      67                 :            : static const sal_Char sAPI_user[]               = "User";
      68                 :            : static const sal_Char sAPI_table_formula[]      = "TableFormula";
      69                 :            : static const sal_Char sAPI_database[]           = "com.sun.star.text.TextField.Database";
      70                 :            : static const sal_Char sAPI_fieldmaster_database[] = "com.sun.star.text.FieldMaster.Database";
      71                 :            : 
      72                 :            : // property names
      73                 :            : static const sal_Char sAPI_hint[]               = "Hint";
      74                 :            : static const sal_Char sAPI_help[]               = "Help";
      75                 :            : static const sal_Char sAPI_tooltip[]            = "Tooltip";
      76                 :            : static const sal_Char sAPI_content[]            = "Content";
      77                 :            : static const sal_Char sAPI_sub_type[]           = "SubType";
      78                 :            : static const sal_Char sAPI_is_expression[]      = "IsExpression";
      79                 :            : static const sal_Char sAPI_is_input[]           = "Input";
      80                 :            : static const sal_Char sAPI_is_show_formula[]    = "IsShowFormula";
      81                 :            : static const sal_Char sAPI_numbering_type[]     = "NumberingType";
      82                 :            : static const sal_Char sAPI_number_format[]      = "NumberFormat";
      83                 :            : static const sal_Char sAPI_name[]               = "Name";
      84                 :            : static const sal_Char sAPI_numbering_separator[]    = "NumberingSeparator";
      85                 :            : static const sal_Char sAPI_chapter_numbering_level[]= "ChapterNumberingLevel";
      86                 :            : static const sal_Char sAPI_value[]              = "Value";
      87                 :            : static const sal_Char sAPI_is_visible[]         = "IsVisible";
      88                 :            : static const sal_Char sAPI_variable_subtype[]   = "VariableSubtype";
      89                 :            : static const sal_Char sAPI_data_column_name[]   = "DataColumnName";
      90                 :            : static const sal_Char sAPI_is_data_base_format[]    = "DataBaseFormat";
      91                 :            : static const sal_Char sAPI_current_presentation[]   = "CurrentPresentation";
      92                 :            : static const sal_Char sAPI_sequence_value[]     = "SequenceValue";
      93                 :            : static const sal_Char sAPI_is_fixed_language[] = "IsFixedLanguage";
      94                 :            : 
      95                 :            : 
      96                 :            : using ::rtl::OUString;
      97                 :            : using ::rtl::OUStringBuffer;
      98                 :            : 
      99                 :            : using namespace ::com::sun::star;
     100                 :            : using namespace ::com::sun::star::uno;
     101                 :            : using namespace ::com::sun::star::beans;
     102                 :            : using namespace ::com::sun::star::text;
     103                 :            : using namespace ::com::sun::star::style;
     104                 :            : using namespace ::xmloff::token;
     105                 :            : 
     106                 :            : 
     107                 :            : 
     108                 :            : //
     109                 :            : // XMLVarFieldImportContext: superclass for all variable related fields
     110                 :            : //
     111                 :            : 
     112 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLVarFieldImportContext, XMLTextFieldImportContext );
     113                 :            : 
     114                 :          0 : XMLVarFieldImportContext::XMLVarFieldImportContext(
     115                 :            :     SvXMLImport& rImport, XMLTextImportHelper& rHlp,
     116                 :            :     const sal_Char* pServiceName, sal_uInt16 nPrfx,
     117                 :            :     const OUString& rLocalName,
     118                 :            :     sal_Bool bFormula, sal_Bool bFormulaDefault,
     119                 :            :     sal_Bool bDescription, sal_Bool bHelp, sal_Bool bHint, sal_Bool bVisible,
     120                 :            :     sal_Bool bIsDisplayFormula,
     121                 :            :     sal_Bool bType, sal_Bool bStyle, sal_Bool bValue,
     122                 :            :     sal_Bool bPresentation) :
     123                 :            :         XMLTextFieldImportContext(rImport, rHlp, pServiceName, nPrfx, rLocalName),
     124                 :            :         sPropertyContent(sAPI_content),
     125                 :            :         sPropertyHint(sAPI_hint),
     126                 :            :         sPropertyHelp(sAPI_help),
     127                 :            :         sPropertyTooltip(sAPI_tooltip),
     128                 :            :         sPropertyIsVisible(sAPI_is_visible),
     129                 :            :         sPropertyIsDisplayFormula(sAPI_is_show_formula),
     130                 :            :         sPropertyCurrentPresentation(sAPI_current_presentation),
     131                 :            :         aValueHelper(rImport, rHlp, bType, bStyle, bValue, sal_False),
     132                 :            :         bDisplayFormula(sal_False),
     133                 :            :         bDisplayNone(sal_False),
     134                 :            :         bNameOK(sal_False),
     135                 :            :         bFormulaOK(sal_False),
     136                 :            :         bDescriptionOK(sal_False),
     137                 :            :         bHelpOK(sal_False),
     138                 :            :         bHintOK(sal_False),
     139                 :            :         bDisplayOK(sal_False),
     140                 :            :         bSetFormula(bFormula),
     141                 :            :         bSetFormulaDefault(bFormulaDefault),
     142                 :            :         bSetDescription(bDescription),
     143                 :            :         bSetHelp(bHelp),
     144                 :            :         bSetHint(bHint),
     145                 :            :         bSetVisible(bVisible),
     146                 :            :         bSetDisplayFormula(bIsDisplayFormula),
     147         [ #  # ]:          0 :         bSetPresentation(bPresentation)
     148                 :            : {
     149                 :          0 : }
     150                 :            : 
     151                 :          0 : void XMLVarFieldImportContext::ProcessAttribute(
     152                 :            :     sal_uInt16 nAttrToken,
     153                 :            :     const OUString& sAttrValue )
     154                 :            : {
     155   [ #  #  #  #  :          0 :     switch (nAttrToken)
                #  #  # ]
     156                 :            :         {
     157                 :            :         case XML_TOK_TEXTFIELD_NAME:
     158                 :          0 :             sName = sAttrValue;
     159                 :          0 :             bNameOK = sal_True;
     160                 :          0 :             bValid = sal_True;      // we assume: field with name is valid!
     161                 :          0 :             break;
     162                 :            :         case XML_TOK_TEXTFIELD_DESCRIPTION:
     163                 :          0 :             sDescription = sAttrValue;
     164                 :          0 :             bDescriptionOK = sal_True;
     165                 :          0 :             break;
     166                 :            :         case XML_TOK_TEXTFIELD_HELP:
     167                 :          0 :             sHelp = sAttrValue;
     168                 :          0 :             bHelpOK = true;
     169                 :          0 :             break;
     170                 :            :         case XML_TOK_TEXTFIELD_HINT:
     171                 :          0 :             sHint = sAttrValue;
     172                 :          0 :             bHintOK = true;
     173                 :          0 :             break;
     174                 :            :         case XML_TOK_TEXTFIELD_FORMULA:
     175                 :            :             {
     176                 :          0 :                 OUString sTmp;
     177                 :          0 :                 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
     178         [ #  # ]:          0 :                         _GetKeyByAttrName( sAttrValue, &sTmp, sal_False );
     179         [ #  # ]:          0 :                 if( XML_NAMESPACE_OOOW == nPrefix )
     180                 :            :                 {
     181                 :          0 :                     sFormula = sTmp;
     182                 :          0 :                     bFormulaOK = sal_True;
     183                 :            :                 }
     184                 :            :                 else
     185                 :          0 :                     sFormula = sAttrValue;
     186                 :            :             }
     187                 :          0 :             break;
     188                 :            :         case XML_TOK_TEXTFIELD_DISPLAY:
     189         [ #  # ]:          0 :             if (IsXMLToken(sAttrValue, XML_FORMULA))
     190                 :            :             {
     191                 :          0 :                 bDisplayFormula = sal_True;
     192                 :          0 :                 bDisplayNone = sal_False;
     193                 :          0 :                 bDisplayOK = sal_True;
     194                 :            :             }
     195         [ #  # ]:          0 :             else if (IsXMLToken(sAttrValue, XML_VALUE))
     196                 :            :             {
     197                 :          0 :                 bDisplayFormula = sal_False;
     198                 :          0 :                 bDisplayNone = sal_False;
     199                 :          0 :                 bDisplayOK = sal_True;
     200                 :            :             }
     201         [ #  # ]:          0 :             else if (IsXMLToken(sAttrValue, XML_NONE))
     202                 :            :             {
     203                 :          0 :                 bDisplayFormula = sal_False;
     204                 :          0 :                 bDisplayNone = sal_True;
     205                 :          0 :                 bDisplayOK = sal_True;
     206                 :            :             } // else: no change
     207                 :            :             DBG_ASSERT(!(bDisplayFormula && bDisplayNone),
     208                 :            :                        "illegal display values");
     209                 :          0 :             break;
     210                 :            :         default:
     211                 :            :             // delegate all others to value helper
     212                 :          0 :             aValueHelper.ProcessAttribute(nAttrToken, sAttrValue);
     213                 :          0 :             break;
     214                 :            :         }
     215                 :          0 : }
     216                 :            : 
     217                 :          0 : void XMLVarFieldImportContext::PrepareField(
     218                 :            :     const Reference<XPropertySet> & xPropertySet)
     219                 :            : {
     220                 :            :     // bSetName: not implemented
     221                 :            : 
     222         [ #  # ]:          0 :     if (bSetFormula)
     223                 :            :     {
     224 [ #  # ][ #  # ]:          0 :         if (!bFormulaOK && bSetFormulaDefault)
     225                 :            :         {
     226                 :          0 :             sFormula = GetContent();
     227                 :          0 :             bFormulaOK = sal_True;
     228                 :            :         }
     229                 :            : 
     230         [ #  # ]:          0 :         if (bFormulaOK)
     231                 :            :         {
     232                 :          0 :             Any aAny;
     233         [ #  # ]:          0 :             aAny <<= sFormula;
     234 [ #  # ][ #  # ]:          0 :             xPropertySet->setPropertyValue(sPropertyContent, aAny);
     235                 :            :         }
     236                 :            :     }
     237                 :            : 
     238 [ #  # ][ #  # ]:          0 :     if (bSetDescription && bDescriptionOK)
     239                 :            :     {
     240                 :          0 :         Any aAny;
     241         [ #  # ]:          0 :         aAny <<= sDescription;
     242 [ #  # ][ #  # ]:          0 :         xPropertySet->setPropertyValue(sPropertyHint, aAny);
     243                 :            :     }
     244                 :            : 
     245 [ #  # ][ #  # ]:          0 :     if (bSetHelp && bHelpOK)
     246                 :            :     {
     247                 :          0 :         Any aAny;
     248         [ #  # ]:          0 :         aAny <<= sHelp;
     249 [ #  # ][ #  # ]:          0 :         xPropertySet->setPropertyValue(sPropertyHelp, aAny);
     250                 :            :     }
     251                 :            : 
     252 [ #  # ][ #  # ]:          0 :     if (bSetHint && bHintOK)
     253                 :            :     {
     254                 :          0 :         Any aAny;
     255         [ #  # ]:          0 :         aAny <<= sHint;
     256 [ #  # ][ #  # ]:          0 :         xPropertySet->setPropertyValue(sPropertyTooltip, aAny);
     257                 :            :     }
     258                 :            : 
     259 [ #  # ][ #  # ]:          0 :     if (bSetVisible && bDisplayOK)
     260                 :            :     {
     261                 :          0 :         Any aAny;
     262 [ #  # ][ #  # ]:          0 :         sal_Bool bTmp = ! (bDisplayNone && bDisplayOK);
     263         [ #  # ]:          0 :         aAny.setValue( &bTmp, ::getBooleanCppuType());
     264 [ #  # ][ #  # ]:          0 :         xPropertySet->setPropertyValue(sPropertyIsVisible, aAny);
     265                 :            :     }
     266                 :            : 
     267                 :            :     // workaround for #no-bug#: display formula by default
     268 [ #  # ][ #  # ]:          0 :     if (xPropertySet->getPropertySetInfo()->
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     269         [ #  # ]:          0 :                 hasPropertyByName(sPropertyIsDisplayFormula) &&
     270                 :          0 :         !bSetDisplayFormula)
     271                 :            :     {
     272                 :          0 :         bDisplayFormula = sal_False;
     273                 :          0 :         bSetDisplayFormula = sal_True;
     274                 :            :     }
     275                 :            : 
     276                 :            : 
     277         [ #  # ]:          0 :     if (bSetDisplayFormula)
     278                 :            :     {
     279                 :          0 :         Any aAny;
     280 [ #  # ][ #  # ]:          0 :         sal_Bool bTmp = bDisplayFormula && bDisplayOK;
     281         [ #  # ]:          0 :         aAny.setValue( &bTmp, ::getBooleanCppuType());
     282 [ #  # ][ #  # ]:          0 :         xPropertySet->setPropertyValue(sPropertyIsDisplayFormula, aAny);
     283                 :            :     }
     284                 :            : 
     285                 :            :     // delegate to value helper
     286                 :          0 :     aValueHelper.SetDefault(GetContent());
     287                 :          0 :     aValueHelper.PrepareField(xPropertySet);
     288                 :            : 
     289                 :            :     // finally, set the curren presentation
     290         [ #  # ]:          0 :     if (bSetPresentation)
     291                 :            :     {
     292                 :          0 :         Any aAny;
     293 [ #  # ][ #  # ]:          0 :         aAny <<= GetContent();
     294 [ #  # ][ #  # ]:          0 :         xPropertySet->setPropertyValue(sPropertyCurrentPresentation, aAny);
     295                 :            :     }
     296                 :          0 : }
     297                 :            : 
     298                 :            : 
     299                 :            : 
     300                 :            : 
     301                 :            : 
     302                 :            : //
     303                 :            : // variable set fields
     304                 :            : //
     305                 :            : 
     306 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLSetVarFieldImportContext, XMLVarFieldImportContext );
     307                 :            : 
     308                 :          0 : XMLSetVarFieldImportContext::XMLSetVarFieldImportContext(
     309                 :            :     SvXMLImport& rImport, XMLTextImportHelper& rHlp,
     310                 :            :     const sal_Char* pServiceName, sal_uInt16 nPrfx,
     311                 :            :     const OUString& rLocalName, VarType eVarType,
     312                 :            :     sal_Bool bFormula, sal_Bool bFormulaDefault,
     313                 :            :     sal_Bool bDescription, sal_Bool bHelp, sal_Bool bHint, sal_Bool bVisible, sal_Bool bIsDisplayFormula,
     314                 :            :     sal_Bool bType, sal_Bool bStyle, sal_Bool bValue, sal_Bool bPresentation) :
     315                 :            :         XMLVarFieldImportContext(rImport, rHlp, pServiceName,
     316                 :            :                                  nPrfx, rLocalName,
     317                 :            :                                  bFormula, bFormulaDefault,
     318                 :            :                                  bDescription, bHelp, bHint, bVisible, bIsDisplayFormula,
     319                 :            :                                  bType, bStyle, bValue, bPresentation),
     320                 :          0 :         eFieldType(eVarType)
     321                 :            : {
     322                 :          0 : }
     323                 :            : 
     324                 :          0 : void XMLSetVarFieldImportContext::EndElement()
     325                 :            : {
     326                 :            :     // should we call PrepareField on the field, or rather on it's master?
     327                 :            :     // currently: call on field (just like superclass)
     328                 :            :     // possible alternatives: call on master
     329                 :            :     //                        call field or master depending on variable
     330                 :            :     //                        PrepareMaster() in addition to PrepareField()
     331                 :            : 
     332                 :            :     DBG_ASSERT(!GetServiceName().isEmpty(), "no service name for element!");
     333                 :            : 
     334         [ #  # ]:          0 :     if (bValid)
     335                 :            :     {
     336                 :            :         DBG_ASSERT(!GetName().isEmpty(), "variable name needed!");
     337                 :            : 
     338                 :            :         // find field master
     339                 :          0 :         Reference<XPropertySet> xMaster;
     340 [ #  # ][ #  # ]:          0 :         if (FindFieldMaster(xMaster))
     341                 :            :         {
     342                 :            :             // create field/Service
     343                 :          0 :             Reference<XPropertySet> xPropSet;
     344   [ #  #  #  # ]:          0 :             if (CreateField(xPropSet, OUString(sAPI_textfield_prefix) + GetServiceName()))
                 [ #  # ]
     345                 :            :             {
     346         [ #  # ]:          0 :                 Reference<XDependentTextField> xDepTextField(xPropSet, UNO_QUERY);
     347         [ #  # ]:          0 :                 if (xDepTextField.is())
     348                 :            :                 {
     349                 :            :                     // attach field to field master
     350 [ #  # ][ #  # ]:          0 :                     xDepTextField->attachTextFieldMaster(xMaster);
     351                 :            : 
     352                 :            :                     // attach field to document
     353         [ #  # ]:          0 :                     Reference<XTextContent> xTextContent(xPropSet, UNO_QUERY);
     354         [ #  # ]:          0 :                     if (xTextContent.is())
     355                 :            :                     {
     356                 :            :                         try {
     357                 :            :                         // insert, set field properties and exit!
     358         [ #  # ]:          0 :                         GetImportHelper().InsertTextContent(xTextContent);
     359         [ #  # ]:          0 :                         PrepareField(xPropSet);
     360         [ #  # ]:          0 :                         } catch (lang::IllegalArgumentException & /*e*/)
     361                 :            :                         {
     362                 :            :                             // ignore e: #i54023#
     363                 :            :                         };
     364                 :          0 :                         return;
     365         [ #  # ]:          0 :                     }
     366         [ #  # ]:          0 :                 }
     367         [ #  # ]:          0 :             }
     368         [ #  # ]:          0 :         }
     369                 :            :     }
     370                 :            : 
     371                 :            :     // above: exit on success; so for all error cases we end up here!
     372                 :            :     // write element content
     373         [ #  # ]:          0 :     GetImportHelper().InsertString(GetContent());
     374                 :            : }
     375                 :            : 
     376                 :          0 : sal_Bool XMLSetVarFieldImportContext::FindFieldMaster(
     377                 :            :     Reference<XPropertySet> & xMaster)
     378                 :            : {
     379                 :            :     // currently: delegate to XMLVariableDeclImportContext;
     380                 :            :     // shoud eventually go here
     381                 :            :     return XMLVariableDeclImportContext::FindFieldMaster(xMaster,
     382                 :          0 :                                                          GetImport(),
     383                 :          0 :                                                          GetImportHelper(),
     384                 :            :                                                          GetName(),
     385         [ #  # ]:          0 :                                                          eFieldType);
     386                 :            : }
     387                 :            : 
     388                 :            : 
     389                 :            : 
     390                 :            : //
     391                 :            : // sequence field
     392                 :            : //
     393                 :            : 
     394 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLSequenceFieldImportContext, XMLSetVarFieldImportContext );
     395                 :            : 
     396                 :          0 : XMLSequenceFieldImportContext::XMLSequenceFieldImportContext(
     397                 :            :     SvXMLImport& rImport, XMLTextImportHelper& rHlp,
     398                 :            :     sal_uInt16 nPrfx, const OUString& rLocalName) :
     399                 :            :         XMLSetVarFieldImportContext(rImport, rHlp, sAPI_set_expression,
     400                 :            :                                     nPrfx, rLocalName, VarTypeSequence,
     401                 :            :                                     // formula
     402                 :            :                                     sal_True, sal_True,
     403                 :            :                                     sal_False, sal_False, sal_False, sal_False,
     404                 :            :                                     sal_False,
     405                 :            :                                     sal_False, sal_False, sal_False, sal_True),
     406                 :            : 
     407                 :            :         sPropertyNumberFormat(sAPI_number_format),
     408                 :            :         sPropertySequenceValue(sAPI_sequence_value),
     409                 :            :         sNumFormat(OUString::valueOf(sal_Unicode('1'))),
     410         [ #  # ]:          0 :         sNumFormatSync(GetXMLToken(XML_FALSE)),
     411                 :          0 :         bRefNameOK(sal_False)
     412                 :            : {
     413                 :          0 : }
     414                 :            : 
     415                 :          0 : void XMLSequenceFieldImportContext::ProcessAttribute(
     416                 :            :     sal_uInt16 nAttrToken, const OUString& sAttrValue )
     417                 :            : {
     418   [ #  #  #  # ]:          0 :     switch (nAttrToken)
     419                 :            :     {
     420                 :            :         case XML_TOK_TEXTFIELD_NUM_FORMAT:
     421                 :          0 :             sNumFormat = sAttrValue;
     422                 :          0 :             break;
     423                 :            :         case XML_TOK_TEXTFIELD_NUM_LETTER_SYNC:
     424                 :          0 :             sNumFormatSync = sAttrValue;
     425                 :          0 :             break;
     426                 :            :         case XML_TOK_TEXTFIELD_REF_NAME:
     427                 :          0 :             sRefName = sAttrValue;
     428                 :          0 :             bRefNameOK = sal_True;
     429                 :          0 :             break;
     430                 :            :         default:
     431                 :            :             // delegate to super class (name, formula)
     432                 :            :             XMLSetVarFieldImportContext::ProcessAttribute(nAttrToken,
     433                 :          0 :                                                           sAttrValue);
     434                 :          0 :             break;
     435                 :            :     } // switch
     436                 :          0 : }
     437                 :            : 
     438                 :          0 : void XMLSequenceFieldImportContext::PrepareField(
     439                 :            :     const Reference<XPropertySet> & xPropertySet)
     440                 :            : {
     441                 :            :     // delegate to super class (formula)
     442         [ #  # ]:          0 :     XMLSetVarFieldImportContext::PrepareField(xPropertySet);
     443                 :            : 
     444                 :            :     // set format
     445                 :          0 :     sal_Int16 nNumType = NumberingType::ARABIC;
     446         [ #  # ]:          0 :     GetImport().GetMM100UnitConverter().convertNumFormat( nNumType, sNumFormat, sNumFormatSync );
     447                 :          0 :     Any aAny;
     448         [ #  # ]:          0 :     aAny <<= nNumType;
     449 [ #  # ][ #  # ]:          0 :     xPropertySet->setPropertyValue(sPropertyNumberFormat, aAny);
     450                 :            : 
     451                 :            :     // handle reference name
     452         [ #  # ]:          0 :     if (bRefNameOK)
     453                 :            :     {
     454 [ #  # ][ #  # ]:          0 :         aAny = xPropertySet->getPropertyValue(sPropertySequenceValue);
     455                 :          0 :         sal_Int16 nValue = 0;
     456                 :          0 :         aAny >>= nValue;
     457         [ #  # ]:          0 :         GetImportHelper().InsertSequenceID(sRefName, GetName(), nValue);
     458                 :          0 :     }
     459                 :          0 : }
     460                 :            : 
     461                 :            : 
     462                 :            : 
     463                 :            : //
     464                 :            : // variable set field
     465                 :            : //
     466                 :            : 
     467 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLVariableSetFieldImportContext, XMLSetVarFieldImportContext );
     468                 :            : 
     469                 :          0 : XMLVariableSetFieldImportContext::XMLVariableSetFieldImportContext(
     470                 :            :     SvXMLImport& rImport, XMLTextImportHelper& rHlp,
     471                 :            :     sal_uInt16 nPrfx, const OUString& rLocalName) :
     472                 :            :         XMLSetVarFieldImportContext(rImport, rHlp, sAPI_set_expression,
     473                 :            :                                     nPrfx, rLocalName, VarTypeSimple,
     474                 :            :                                     // formula, value&type, style,
     475                 :            :                                     // display none
     476                 :            :                                     sal_True, sal_True,
     477                 :            :                                     sal_False, sal_False, sal_False,
     478                 :            :                                     sal_True, sal_False,
     479                 :            :                                     sal_True, sal_True, sal_True,
     480                 :            :                                     sal_True),
     481                 :          0 :         sPropertySubType(sAPI_sub_type)
     482                 :            : {
     483                 :          0 : }
     484                 :            : 
     485                 :          0 : void XMLVariableSetFieldImportContext::PrepareField(
     486                 :            :         const Reference<XPropertySet> & xPropertySet)
     487                 :            : {
     488                 :            :     // set type
     489                 :          0 :     Any aAny;
     490 [ #  # ][ #  # ]:          0 :     aAny <<= (IsStringValue()? SetVariableType::STRING : SetVariableType::VAR);
     491 [ #  # ][ #  # ]:          0 :     xPropertySet->setPropertyValue(sPropertySubType, aAny);
     492                 :            : 
     493                 :            :     // the remainder is handled by super class
     494         [ #  # ]:          0 :     XMLSetVarFieldImportContext::PrepareField(xPropertySet);
     495                 :          0 : }
     496                 :            : 
     497                 :            : 
     498                 :            : 
     499                 :            : //
     500                 :            : // variable input field
     501                 :            : //
     502                 :            : 
     503 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLVariableInputFieldImportContext, XMLSetVarFieldImportContext );
     504                 :            : 
     505                 :          0 : XMLVariableInputFieldImportContext::XMLVariableInputFieldImportContext(
     506                 :            :     SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx,
     507                 :            :     const OUString& rLocalName) :
     508                 :            :         XMLSetVarFieldImportContext(rImport, rHlp, sAPI_set_expression,
     509                 :            :                                     nPrfx, rLocalName, VarTypeSimple,
     510                 :            :                                     // description, display none/formula,
     511                 :            :                                     // value&type, style, formula
     512                 :            :                                     sal_True, sal_True,
     513                 :            :                                     sal_True, sal_True, sal_True,
     514                 :            :                                     sal_True, sal_False,
     515                 :            :                                     sal_True, sal_True, sal_True,
     516                 :            :                                     sal_True),
     517                 :            :         sPropertySubType(sAPI_sub_type),
     518                 :          0 :         sPropertyIsInput(sAPI_is_input)
     519                 :            : {
     520                 :          0 : }
     521                 :            : 
     522                 :          0 : void XMLVariableInputFieldImportContext::PrepareField(
     523                 :            :         const Reference<XPropertySet> & xPropertySet)
     524                 :            : {
     525                 :            :     // set type (input field)
     526                 :          0 :     Any aAny;
     527                 :          0 :     sal_Bool bTrue = sal_True;
     528         [ #  # ]:          0 :     aAny.setValue( &bTrue, ::getBooleanCppuType() );
     529 [ #  # ][ #  # ]:          0 :     xPropertySet->setPropertyValue(sPropertyIsInput, aAny);
     530                 :            : 
     531                 :            :     // set type
     532 [ #  # ][ #  # ]:          0 :     aAny <<= (IsStringValue()? SetVariableType::STRING : SetVariableType::VAR);
     533 [ #  # ][ #  # ]:          0 :     xPropertySet->setPropertyValue(sPropertySubType, aAny);
     534                 :            : 
     535                 :            :     // the remainder is handled by super class
     536         [ #  # ]:          0 :     XMLSetVarFieldImportContext::PrepareField(xPropertySet);
     537                 :          0 : }
     538                 :            : 
     539                 :            : 
     540                 :            : 
     541                 :            : //
     542                 :            : // user field
     543                 :            : //
     544                 :            : 
     545 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLUserFieldImportContext, XMLSetVarFieldImportContext );
     546                 :            : 
     547                 :          0 : XMLUserFieldImportContext::XMLUserFieldImportContext(
     548                 :            :     SvXMLImport& rImport, XMLTextImportHelper& rHlp,
     549                 :            :     sal_uInt16 nPrfx, const OUString& rLocalName) :
     550                 :            :         XMLSetVarFieldImportContext(rImport, rHlp, sAPI_user, nPrfx,
     551                 :            :                                     rLocalName, VarTypeUserField,
     552                 :            :                                     // display none/formula, style
     553                 :            :                                     sal_False, sal_False,
     554                 :            :                                     sal_False, sal_False, sal_False, sal_True,
     555                 :            :                                     sal_True,
     556                 :            :                                     sal_False, sal_True, sal_False,
     557                 :          0 :                                     sal_False)
     558                 :            : {
     559                 :          0 : }
     560                 :            : 
     561                 :            : 
     562                 :            : 
     563                 :            : //
     564                 :            : // user input field
     565                 :            : //
     566                 :            : 
     567 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLUserFieldInputImportContext, XMLVarFieldImportContext );
     568                 :            : 
     569                 :            : // bug: doesn't work (SO API lacking)
     570                 :          0 : XMLUserFieldInputImportContext::XMLUserFieldInputImportContext(
     571                 :            :     SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx,
     572                 :            :     const OUString& rLocalName) :
     573                 :            :         XMLVarFieldImportContext(rImport, rHlp, sAPI_input_user,
     574                 :            :                                  nPrfx, rLocalName,
     575                 :            :                                  // description, style
     576                 :            :                                  sal_False, sal_False,
     577                 :            :                                  sal_True, sal_False, sal_False,
     578                 :            :                                  sal_False, sal_False,
     579                 :            :                                  sal_False /*???*/, sal_True, sal_False,
     580                 :          0 :                                  sal_False)
     581                 :            : {
     582                 :          0 : }
     583                 :            : 
     584                 :          0 : void XMLUserFieldInputImportContext::PrepareField(
     585                 :            :     const Reference<XPropertySet> & xPropertySet)
     586                 :            : {
     587                 :          0 :     Any aAny;
     588         [ #  # ]:          0 :     aAny <<= GetName();
     589 [ #  # ][ #  # ]:          0 :     xPropertySet->setPropertyValue(sPropertyContent, aAny);
     590                 :            : 
     591                 :            :     // delegate to super class
     592         [ #  # ]:          0 :     XMLVarFieldImportContext::PrepareField(xPropertySet);
     593                 :          0 : }
     594                 :            : 
     595                 :            : 
     596                 :            : //
     597                 :            : // variable get field
     598                 :            : //
     599                 :            : 
     600 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLVariableGetFieldImportContext, XMLVarFieldImportContext );
     601                 :            : 
     602                 :          0 : XMLVariableGetFieldImportContext::XMLVariableGetFieldImportContext(
     603                 :            :     SvXMLImport& rImport, XMLTextImportHelper& rHlp,
     604                 :            :     sal_uInt16 nPrfx, const OUString& rLocalName) :
     605                 :            :         XMLVarFieldImportContext(rImport, rHlp, sAPI_get_expression,
     606                 :            :                                  nPrfx, rLocalName,
     607                 :            :                                  // style, display formula
     608                 :            :                                  sal_False, sal_False,
     609                 :            :                                  sal_False, sal_False, sal_False,
     610                 :            :                                  sal_False, sal_True,
     611                 :            :                                  sal_True, sal_True, sal_False,
     612                 :            :                                  sal_True),
     613                 :          0 :         sPropertySubType(sAPI_sub_type)
     614                 :            : {
     615                 :          0 : }
     616                 :            : 
     617                 :          0 : void XMLVariableGetFieldImportContext::PrepareField(
     618                 :            :         const Reference<XPropertySet> & xPropertySet)
     619                 :            : {
     620                 :            :     // set name
     621                 :          0 :       Any aAny;
     622         [ #  # ]:          0 :     aAny <<= GetName();
     623 [ #  # ][ #  # ]:          0 :     xPropertySet->setPropertyValue(sPropertyContent, aAny);
     624                 :            : 
     625                 :            :     // the remainder is handled by super class
     626         [ #  # ]:          0 :     XMLVarFieldImportContext::PrepareField(xPropertySet);
     627                 :          0 : }
     628                 :            : 
     629                 :            : 
     630                 :            : 
     631                 :            : //
     632                 :            : // expression field
     633                 :            : //
     634                 :            : 
     635 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLExpressionFieldImportContext, XMLVarFieldImportContext );
     636                 :            : 
     637                 :          0 : XMLExpressionFieldImportContext::XMLExpressionFieldImportContext(
     638                 :            :     SvXMLImport& rImport, XMLTextImportHelper& rHlp,
     639                 :            :     sal_uInt16 nPrfx, const OUString& rLocalName) :
     640                 :            :         XMLVarFieldImportContext(rImport, rHlp, sAPI_get_expression,
     641                 :            :                                  nPrfx, rLocalName,
     642                 :            :                                  // formula, type, style, display formula
     643                 :            :                                  sal_True, sal_True,
     644                 :            :                                  sal_False, sal_False, sal_False,
     645                 :            :                                  sal_False, sal_True,
     646                 :            :                                  sal_True, sal_True, sal_False,
     647                 :            :                                  sal_True),
     648                 :          0 :         sPropertySubType(sAPI_sub_type)
     649                 :            : {
     650                 :          0 :     bValid = sal_True;  // always valid
     651                 :          0 : }
     652                 :            : 
     653                 :            : 
     654                 :          0 : void XMLExpressionFieldImportContext::PrepareField(
     655                 :            :     const Reference<XPropertySet> & xPropertySet)
     656                 :            : {
     657                 :          0 :     sal_Int16 nSubType = SetVariableType::FORMULA;
     658                 :          0 :     Any aAny;
     659         [ #  # ]:          0 :     aAny <<= nSubType;
     660 [ #  # ][ #  # ]:          0 :     xPropertySet->setPropertyValue(sPropertySubType, aAny);
     661                 :            : 
     662                 :            :     // delegate to super class
     663         [ #  # ]:          0 :     XMLVarFieldImportContext::PrepareField(xPropertySet);
     664                 :          0 : }
     665                 :            : 
     666                 :            : 
     667                 :            : 
     668                 :            : //
     669                 :            : // text input field
     670                 :            : //
     671                 :            : 
     672 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLTextInputFieldImportContext, XMLVarFieldImportContext );
     673                 :            : 
     674                 :          0 : XMLTextInputFieldImportContext::XMLTextInputFieldImportContext(
     675                 :            :     SvXMLImport& rImport, XMLTextImportHelper& rHlp,
     676                 :            :     sal_uInt16 nPrfx, const OUString& sLocalName) :
     677                 :            :         XMLVarFieldImportContext(rImport, rHlp, sAPI_input,
     678                 :            :                                  nPrfx, sLocalName,
     679                 :            :                                  // description
     680                 :            :                                  sal_False, sal_False,
     681                 :            :                                  sal_True, sal_True, sal_True,
     682                 :            :                                  sal_False, sal_False,
     683                 :            :                                  sal_False, sal_False, sal_False,
     684                 :            :                                  sal_False),
     685                 :          0 :         sPropertyContent(sAPI_content)
     686                 :            : {
     687                 :          0 :     bValid = sal_True;  // always valid
     688                 :          0 : }
     689                 :            : 
     690                 :          0 : void XMLTextInputFieldImportContext::PrepareField(
     691                 :            :     const Reference<XPropertySet> & xPropertySet)
     692                 :            : {
     693         [ #  # ]:          0 :     XMLVarFieldImportContext::PrepareField(xPropertySet);
     694                 :            : 
     695                 :          0 :     Any aAny;
     696 [ #  # ][ #  # ]:          0 :     aAny <<= GetContent();
     697 [ #  # ][ #  # ]:          0 :     xPropertySet->setPropertyValue(sPropertyContent, aAny);
     698                 :          0 : }
     699                 :            : 
     700                 :            : 
     701                 :            : //
     702                 :            : // table formula field
     703                 :            : //
     704                 :            : 
     705 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLTableFormulaImportContext, XMLTextFieldImportContext );
     706                 :            : 
     707                 :          0 : XMLTableFormulaImportContext::XMLTableFormulaImportContext(
     708                 :            :     SvXMLImport& rImport,
     709                 :            :     XMLTextImportHelper& rHlp,
     710                 :            :     sal_uInt16 nPrfx,
     711                 :            :     const OUString& rLocalName) :
     712                 :            :         XMLTextFieldImportContext(rImport, rHlp, sAPI_table_formula,
     713                 :            :                                   nPrfx, rLocalName),
     714                 :            :         sPropertyIsShowFormula("IsShowFormula"),
     715                 :            :         sPropertyCurrentPresentation(
     716                 :            :             "CurrentPresentation"),
     717                 :            :         aValueHelper(rImport, rHlp, sal_False, sal_True, sal_False, sal_True),
     718                 :            :         sFormula(),
     719         [ #  # ]:          0 :         bIsShowFormula(sal_False)
     720                 :            : {
     721                 :          0 : }
     722                 :            : 
     723                 :          0 : XMLTableFormulaImportContext::~XMLTableFormulaImportContext()
     724                 :            : {
     725         [ #  # ]:          0 : }
     726                 :            : 
     727                 :          0 : void XMLTableFormulaImportContext::ProcessAttribute(
     728                 :            :     sal_uInt16 nAttrToken,
     729                 :            :     const OUString& sAttrValue )
     730                 :            : {
     731   [ #  #  #  # ]:          0 :     switch (nAttrToken)
     732                 :            :     {
     733                 :            :         case XML_TOK_TEXTFIELD_FORMULA:
     734                 :          0 :             aValueHelper.ProcessAttribute( nAttrToken, sAttrValue );
     735                 :          0 :             bValid = sal_True;  // we need a formula!
     736                 :          0 :             break;
     737                 :            : 
     738                 :            :         case XML_TOK_TEXTFIELD_DATA_STYLE_NAME:
     739                 :          0 :             aValueHelper.ProcessAttribute( nAttrToken, sAttrValue );
     740                 :          0 :             break;
     741                 :            :         case XML_TOK_TEXTFIELD_DISPLAY:
     742         [ #  # ]:          0 :             if ( sAttrValue == "formula" )
     743                 :          0 :                  bIsShowFormula = sal_True;
     744                 :          0 :             break;
     745                 :            :         default:
     746                 :            :             // unknown attribute -> ignore
     747                 :          0 :             break;
     748                 :            :     }
     749                 :          0 : }
     750                 :            : 
     751                 :          0 : void XMLTableFormulaImportContext::PrepareField(
     752                 :            :     const Reference<XPropertySet> & xPropertySet)
     753                 :            : {
     754                 :            :     // set format and formula
     755         [ #  # ]:          0 :     aValueHelper.PrepareField( xPropertySet );
     756                 :            : 
     757                 :          0 :     Any aAny;
     758                 :            : 
     759                 :            :     // set 'show formula' and presentation
     760         [ #  # ]:          0 :     aAny.setValue( &bIsShowFormula, ::getBooleanCppuType() );
     761 [ #  # ][ #  # ]:          0 :     xPropertySet->setPropertyValue( sPropertyIsShowFormula, aAny );
     762                 :            : 
     763 [ #  # ][ #  # ]:          0 :     aAny <<= GetContent();
     764 [ #  # ][ #  # ]:          0 :     xPropertySet->setPropertyValue( sPropertyCurrentPresentation, aAny );
     765                 :          0 : }
     766                 :            : 
     767                 :            : 
     768                 :            : 
     769                 :            : //
     770                 :            : // variable declarations
     771                 :            : //
     772                 :            : // Should be adapted to XMLVarField-/XMLSetVarFieldImportContext scheme!
     773                 :            : //
     774                 :            : 
     775                 :            : 
     776                 :            : 
     777                 :            : //
     778                 :            : // declaration containter import (<variable/user-field/sequence-decls>)
     779                 :            : //
     780                 :            : 
     781 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLVariableDeclsImportContext, SvXMLImportContext );
     782                 :            : 
     783                 :         71 : XMLVariableDeclsImportContext::XMLVariableDeclsImportContext(
     784                 :            :     SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx,
     785                 :            :     const OUString& rLocalName, enum VarType eVarType) :
     786                 :            :         SvXMLImportContext(rImport, nPrfx, rLocalName),
     787                 :            :         eVarDeclsContextType(eVarType),
     788                 :         71 :         rImportHelper(rHlp)
     789                 :            : {
     790                 :         71 : }
     791                 :            : 
     792                 :        306 : SvXMLImportContext* XMLVariableDeclsImportContext::CreateChildContext(
     793                 :            :     sal_uInt16 nPrefix, const OUString& rLocalName,
     794                 :            :     const Reference<xml::sax::XAttributeList> & xAttrList )
     795                 :            : {
     796                 :            :     enum XMLTokenEnum eElementName;
     797                 :        306 :     SvXMLImportContext* pImportContext = NULL;
     798                 :            : 
     799         [ +  - ]:        306 :     if( XML_NAMESPACE_TEXT == nPrefix )
     800                 :            :     {
     801   [ +  -  +  - ]:        306 :         switch (eVarDeclsContextType)
     802                 :            :         {
     803                 :            :             case VarTypeSequence:
     804                 :        252 :                 eElementName = XML_SEQUENCE_DECL;
     805                 :        252 :                 break;
     806                 :            :             case VarTypeSimple:
     807                 :          0 :                 eElementName = XML_VARIABLE_DECL;
     808                 :          0 :                 break;
     809                 :            :             case VarTypeUserField:
     810                 :         54 :                 eElementName = XML_USER_FIELD_DECL;
     811                 :         54 :                 break;
     812                 :            :             default:
     813                 :            :                 OSL_FAIL("unknown field type!");
     814                 :          0 :                 eElementName = XML_SEQUENCE_DECL;
     815                 :          0 :                 break;
     816                 :            :         }
     817                 :            : 
     818         [ +  - ]:        306 :         if( IsXMLToken( rLocalName, eElementName ) )
     819                 :            :         {
     820                 :            :             pImportContext = new XMLVariableDeclImportContext(
     821                 :        306 :                 GetImport(), rImportHelper, nPrefix, rLocalName, xAttrList,
     822         [ +  - ]:        306 :                 eVarDeclsContextType);
     823                 :            :         }
     824                 :            :     }
     825                 :            : 
     826                 :            :     // if no context was created, use default context
     827         [ -  + ]:        306 :     if (NULL == pImportContext) {
     828                 :            :         pImportContext = SvXMLImportContext::CreateChildContext(nPrefix,
     829                 :            :                                                                 rLocalName,
     830                 :          0 :                                                                 xAttrList);
     831                 :            :     }
     832                 :            : 
     833                 :        306 :     return pImportContext;
     834                 :            : }
     835                 :            : 
     836                 :            : 
     837                 :            : 
     838                 :            : //
     839                 :            : // declaration import (<variable/user-field/sequence-decl> elements)
     840                 :            : //
     841                 :            : 
     842 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLVariableDeclImportContext, SvXMLImportContext );
     843                 :            : 
     844                 :        306 : XMLVariableDeclImportContext::XMLVariableDeclImportContext(
     845                 :            :     SvXMLImport& rImport, XMLTextImportHelper& rHlp,
     846                 :            :     sal_uInt16 nPrfx, const OUString& rLocalName,
     847                 :            :     const Reference<xml::sax::XAttributeList> & xAttrList,
     848                 :            :     enum VarType eVarType) :
     849                 :            :         SvXMLImportContext(rImport, nPrfx, rLocalName),
     850                 :            :         // bug?? which properties for userfield/userfieldmaster
     851                 :            :         sPropertyName(sAPI_name),
     852                 :            :         sPropertySubType(sAPI_sub_type),
     853                 :            :         sPropertyNumberingLevel(sAPI_chapter_numbering_level),
     854                 :            :         sPropertyNumberingSeparator(sAPI_numbering_separator),
     855                 :            :         sPropertyIsExpression(sAPI_is_expression),
     856                 :            :         aValueHelper(rImport, rHlp, sal_True, sal_False, sal_True, sal_False),
     857         [ +  - ]:        306 :         nNumLevel(-1), cSeparationChar('.')
     858                 :            : {
     859 [ +  - ][ +  + ]:        720 :     if ( (XML_NAMESPACE_TEXT == nPrfx) &&
         [ +  - ][ +  - ]
                 [ +  - ]
     860         [ +  - ]:        306 :          ( ( IsXMLToken( rLocalName, XML_SEQUENCE_DECL )) ||
     861         [ +  - ]:         54 :            ( IsXMLToken( rLocalName, XML_VARIABLE_DECL)) ||
     862         [ +  - ]:         54 :            ( IsXMLToken( rLocalName, XML_USER_FIELD_DECL))    )) {
     863                 :            : 
     864                 :            :         // TODO: check validity (need name!)
     865                 :            : 
     866                 :            :         // parse attributes
     867 [ +  - ][ +  - ]:        306 :         sal_Int16 nLength = xAttrList->getLength();
     868         [ +  + ]:        972 :         for(sal_Int16 i=0; i<nLength; i++) {
     869                 :            : 
     870                 :        666 :             OUString sLocalName;
     871                 :        666 :             sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
     872   [ +  -  +  - ]:       1332 :                 GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName );
                 [ +  - ]
     873                 :            : 
     874                 :            :             sal_uInt16 nToken = rHlp.
     875 [ +  - ][ +  - ]:        666 :                 GetTextFieldAttrTokenMap().Get(nPrefix, sLocalName);
     876                 :            : 
     877   [ +  +  -  + ]:        666 :             switch (nToken)
     878                 :            :             {
     879                 :            :                 case XML_TOK_TEXTFIELD_NAME:
     880 [ +  - ][ +  - ]:        306 :                     sName = xAttrList->getValueByIndex(i);
     881                 :        306 :                     break;
     882                 :            :                 case XML_TOK_TEXTFIELD_NUMBERING_LEVEL:
     883                 :            :                 {
     884                 :            :                     sal_Int32 nLevel;
     885                 :            :                     bool const bRet = ::sax::Converter::convertNumber(
     886         [ +  - ]:        252 :                         nLevel, xAttrList->getValueByIndex(i), 0,
     887 [ +  - ][ +  - ]:        504 :                         GetImport().GetTextImport()->GetChapterNumbering()->
                 [ +  - ]
           [ +  -  +  - ]
     888 [ +  - ][ +  - ]:        504 :                                                                    getCount());
                 [ +  - ]
     889         [ +  - ]:        252 :                     if (bRet)
     890                 :            :                     {
     891                 :        252 :                         nNumLevel = static_cast< sal_Int8 >( nLevel-1 ); // API numbers -1..9
     892                 :            :                     }
     893                 :            :                     break;
     894                 :            :                 }
     895                 :            :                 case XML_TOK_TEXTFIELD_NUMBERING_SEPARATOR:
     896                 :            :                     cSeparationChar =
     897 [ #  # ][ #  # ]:          0 :                         (sal_Char)xAttrList->getValueByIndex(i).toChar();
     898                 :          0 :                     break;
     899                 :            : 
     900                 :            :                 default:
     901                 :            :                     // delegate to value helper
     902                 :            :                     aValueHelper.ProcessAttribute(nToken,
     903 [ +  - ][ +  - ]:        108 :                                                   xAttrList->getValueByIndex(i));
                 [ +  - ]
     904                 :        108 :                     break;
     905                 :            :             }
     906                 :        666 :         }
     907                 :            : 
     908                 :        306 :         Reference<XPropertySet> xFieldMaster;
     909         [ +  - ]:        612 :         if (FindFieldMaster(xFieldMaster, GetImport(), rHlp,
     910         [ +  - ]:        306 :                             sName, eVarType))
     911                 :            :         {
     912                 :            :             // now we have a field master: process attributes!
     913                 :        306 :             Any aAny;
     914                 :            : 
     915   [ +  -  +  - ]:        306 :             switch (eVarType)
     916                 :            :             {
     917                 :            :             case VarTypeSequence:
     918         [ +  - ]:        252 :                 aAny <<= nNumLevel;
     919 [ +  - ][ +  - ]:        252 :                 xFieldMaster->setPropertyValue(sPropertyNumberingLevel, aAny);
     920                 :            : 
     921         [ -  + ]:        252 :                 if (nNumLevel >= 0)
     922                 :            :                 {
     923                 :          0 :                     OUString sStr(&cSeparationChar, 1);
     924         [ #  # ]:          0 :                     aAny <<= sStr;
     925         [ #  # ]:          0 :                     xFieldMaster->setPropertyValue(
     926         [ #  # ]:          0 :                         sPropertyNumberingSeparator, aAny);
     927                 :            :                 }
     928                 :        252 :                 break;
     929                 :            :             case VarTypeSimple:
     930                 :            :                 {
     931                 :            :                     // set string or non-string SubType (#93192#)
     932                 :            :                     // The SubType was already set in the FindFieldMaster
     933                 :            :                     // method, but it needs to be adjusted if it's a string.
     934                 :          0 :                     aAny <<= aValueHelper.IsStringValue()
     935 [ #  # ][ #  # ]:          0 :                         ? SetVariableType::STRING : SetVariableType::VAR;
     936 [ #  # ][ #  # ]:          0 :                     xFieldMaster->setPropertyValue(sPropertySubType, aAny);
     937                 :            :                 }
     938                 :          0 :                 break;
     939                 :            :             case VarTypeUserField:
     940                 :            :             {
     941                 :         54 :                 sal_Bool bTmp = !aValueHelper.IsStringValue();
     942         [ +  - ]:         54 :                 aAny.setValue(&bTmp, ::getBooleanCppuType());
     943 [ +  - ][ +  - ]:         54 :                 xFieldMaster->setPropertyValue(sPropertyIsExpression, aAny);
     944         [ +  - ]:         54 :                 aValueHelper.PrepareField(xFieldMaster);
     945                 :            :                 break;
     946                 :            :             }
     947                 :            :             default:
     948                 :            :                 OSL_FAIL("unkown varfield type");
     949                 :        306 :             } // switch
     950                 :        306 :         } // else: no field master found/constructed
     951                 :            :     } // else: no sequence-decl
     952                 :        306 : }
     953                 :            : 
     954                 :            : 
     955                 :            : 
     956                 :        306 : sal_Bool XMLVariableDeclImportContext::FindFieldMaster(
     957                 :            :     Reference<XPropertySet> & xMaster, SvXMLImport& rImport,
     958                 :            :     XMLTextImportHelper& rImportHelper,
     959                 :            :     const OUString& sVarName, enum VarType eVarType)
     960                 :            : {
     961                 :            :     static sal_Int32 nCollisionCount = 0;
     962                 :            : 
     963                 :            :     // rename field
     964                 :            :     // currently: no family in use! Use 0.
     965         [ +  - ]:        306 :     OUString sName = rImportHelper.GetRenameMap().Get(
     966         [ +  - ]:        612 :         sal::static_int_cast< sal_uInt16 >(eVarType), sVarName);
     967                 :            : 
     968                 :            :     // get text fields supplier and field masters
     969                 :        306 :     Reference<XTextFieldsSupplier> xTextFieldsSupp(rImport.GetModel(),
     970         [ +  - ]:        306 :                                                    UNO_QUERY);
     971                 :            :     Reference<container::XNameAccess> xFieldMasterNameAccess(
     972 [ +  - ][ +  - ]:        306 :         xTextFieldsSupp->getTextFieldMasters(), UNO_QUERY);
                 [ +  - ]
     973                 :            : 
     974                 :        306 :     OUStringBuffer sBuffer;
     975         [ +  - ]:        306 :     sBuffer.appendAscii(sAPI_fieldmaster_prefix);
     976         [ +  - ]:        306 :     sBuffer.appendAscii(sAPI_set_expression);
     977         [ +  - ]:        306 :     sBuffer.appendAscii(".");
     978         [ +  - ]:        306 :     sBuffer.append(sName);
     979         [ +  - ]:        306 :     OUString sVarServiceName = sBuffer.makeStringAndClear();
     980                 :            : 
     981         [ +  - ]:        306 :     sBuffer.appendAscii(sAPI_fieldmaster_prefix);
     982         [ +  - ]:        306 :     sBuffer.appendAscii(sAPI_user);
     983         [ +  - ]:        306 :     sBuffer.appendAscii(".");
     984         [ +  - ]:        306 :     sBuffer.append(sName);
     985         [ +  - ]:        306 :     OUString sUserServiceName = sBuffer.makeStringAndClear();
     986                 :            : 
     987 [ +  - ][ +  - ]:        306 :     if (xFieldMasterNameAccess->hasByName(sVarServiceName)) {
                 [ +  + ]
     988                 :            :         // variable field master already in document
     989                 :            : 
     990 [ +  - ][ +  - ]:        252 :         Any aAny = xFieldMasterNameAccess->getByName(sVarServiceName);
     991         [ +  - ]:        252 :         aAny >>= xMaster;
     992                 :            : 
     993         [ +  - ]:        252 :         aAny = xMaster->getPropertyValue(
     994                 :            :             // sPropertySubType
     995                 :            :             OUString(sAPI_sub_type)
     996         [ +  - ]:        252 :             );
     997                 :        252 :         sal_Int16 nType = 0;
     998                 :        252 :         aAny >>= nType;
     999                 :            : 
    1000                 :            :         enum VarType eFMVarType =
    1001                 :            :             (SetVariableType::SEQUENCE == nType) ?
    1002         [ +  - ]:        252 :                 VarTypeSequence : VarTypeSimple;
    1003                 :            : 
    1004         [ -  + ]:        252 :         if (eFMVarType != eVarType)
    1005                 :            :         {
    1006                 :          0 :             OUString sNew;
    1007                 :            : 
    1008                 :            :             // FIXME! cant find if name is taken already!!!!
    1009                 :            : 
    1010                 :          0 :             nCollisionCount++;
    1011                 :          0 :             OUStringBuffer aBuf;
    1012         [ #  # ]:          0 :             aBuf.append(sName);
    1013         [ #  # ]:          0 :             aBuf.appendAscii("_renamed_");
    1014         [ #  # ]:          0 :             aBuf.append(nCollisionCount);
    1015         [ #  # ]:          0 :             sNew = aBuf.makeStringAndClear();
    1016                 :            : 
    1017         [ #  # ]:          0 :             rImportHelper.GetRenameMap().Add(
    1018         [ #  # ]:          0 :                 sal::static_int_cast< sal_uInt16 >(eVarType), sName, sNew);
    1019                 :            : 
    1020                 :            :             // call FindFieldMaster recursively to create new master
    1021                 :            :             return FindFieldMaster(xMaster, rImport, rImportHelper,
    1022         [ #  # ]:        252 :                                    sNew, eVarType);
    1023         [ +  - ]:        252 :         }
    1024 [ +  - ][ +  - ]:         54 :     } else if (xFieldMasterNameAccess->hasByName(sUserServiceName)) {
                 [ -  + ]
    1025                 :            :         // user field: get field master
    1026 [ #  # ][ #  # ]:          0 :         Any aAny = xFieldMasterNameAccess->getByName(sUserServiceName);
    1027         [ #  # ]:          0 :         aAny >>= xMaster;
    1028                 :            : 
    1029         [ #  # ]:          0 :         if (VarTypeUserField != eVarType) {
    1030                 :            :             // find new name that is not taken
    1031                 :          0 :             OUString sNew;
    1032                 :            : 
    1033                 :            :             // FIXME! cant find if name is taken already!!!!
    1034                 :            : 
    1035                 :          0 :             nCollisionCount++;
    1036                 :          0 :             OUStringBuffer aBuf;
    1037         [ #  # ]:          0 :             aBuf.append(sName);
    1038         [ #  # ]:          0 :             aBuf.appendAscii("_renamed_");
    1039         [ #  # ]:          0 :             aBuf.append(nCollisionCount);
    1040         [ #  # ]:          0 :             sNew = aBuf.makeStringAndClear();
    1041                 :            : 
    1042         [ #  # ]:          0 :             rImportHelper.GetRenameMap().Add(
    1043         [ #  # ]:          0 :                 sal::static_int_cast< sal_uInt16 >(eVarType), sName, sNew);
    1044                 :            : 
    1045                 :            :             // call FindFieldMaster recursively to create new master
    1046                 :            :             return FindFieldMaster(xMaster, rImport, rImportHelper,
    1047         [ #  # ]:          0 :                                    sNew, eVarType);
    1048         [ #  # ]:          0 :         }
    1049                 :            :     } else {
    1050                 :            :         // field name not used: create field master
    1051                 :            : 
    1052                 :            :         // import -> model is MultiServiceFactory -> createInstance
    1053                 :            :         Reference<lang::XMultiServiceFactory>
    1054         [ +  - ]:         54 :             xFactory(rImport.GetModel(),UNO_QUERY);
    1055         [ +  - ]:         54 :         if( xFactory.is() ) {
    1056                 :            : 
    1057                 :         54 :             OUStringBuffer sService;
    1058         [ +  - ]:         54 :             sService.appendAscii(sAPI_fieldmaster_prefix);
    1059                 :            :             sService.appendAscii((eVarType==VarTypeUserField) ?
    1060 [ +  - ][ +  - ]:         54 :                                  sAPI_user : sAPI_set_expression);
    1061                 :            :             Reference<XInterface> xIfc =
    1062 [ +  - ][ +  - ]:         54 :                 xFactory->createInstance( sService.makeStringAndClear() );
                 [ +  - ]
    1063         [ +  - ]:         54 :             if (xIfc.is()) {
    1064         [ +  - ]:         54 :                 Reference<XPropertySet> xTmp( xIfc, UNO_QUERY );
    1065         [ +  - ]:         54 :                 xMaster = xTmp;
    1066                 :            : 
    1067                 :            :                 // set name
    1068                 :         54 :                 Any aAny;
    1069         [ +  - ]:         54 :                 aAny <<= sName;
    1070         [ +  - ]:         54 :                 xMaster->setPropertyValue(
    1071                 :            :                     // sPropertyName
    1072                 :            :                     OUString(sAPI_name)
    1073         [ +  - ]:         54 :                     , aAny);
    1074                 :            : 
    1075         [ -  + ]:         54 :                 if (eVarType != VarTypeUserField) {
    1076                 :            :                     // set subtype for setexp field
    1077                 :            : 
    1078                 :            :                     aAny <<= ((eVarType == VarTypeSimple) ?
    1079                 :            :                               SetVariableType::VAR :
    1080 [ #  # ][ #  # ]:          0 :                               SetVariableType::SEQUENCE);
    1081         [ #  # ]:          0 :                     xMaster->setPropertyValue(
    1082                 :            :                         // sPropertySubType
    1083                 :            :                         OUString(sAPI_sub_type)
    1084         [ #  # ]:          0 :                         , aAny);
    1085                 :         54 :                 } // else : user field: no subtype
    1086                 :            : 
    1087                 :            :             } else {
    1088                 :          0 :                 return sal_False;
    1089 [ -  + ][ +  - ]:         54 :             }
    1090                 :            :         } else {
    1091                 :          0 :             return sal_False;
    1092         [ +  - ]:         54 :         }
    1093                 :            :     }
    1094                 :            : 
    1095                 :            :     DBG_ASSERT(xMaster.is(), "no field master found!?!");
    1096                 :        306 :     return sal_True;
    1097                 :            : }
    1098                 :            : 
    1099                 :            : 
    1100                 :            : //
    1101                 :            : // Database Display field import
    1102                 :            : //
    1103                 :            : 
    1104                 :            : 
    1105 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLDatabaseDisplayImportContext, XMLDatabaseFieldImportContext );
    1106                 :            : 
    1107                 :          0 : XMLDatabaseDisplayImportContext::XMLDatabaseDisplayImportContext(
    1108                 :            :     SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx,
    1109                 :            :     const OUString& rLocalName) :
    1110                 :            :         XMLDatabaseFieldImportContext(rImport, rHlp, sAPI_database,
    1111                 :            :                                       nPrfx, rLocalName, false),
    1112                 :            :         sPropertyColumnName(sAPI_data_column_name),
    1113                 :            :         sPropertyDatabaseFormat(sAPI_is_data_base_format),
    1114                 :            :         sPropertyCurrentPresentation(sAPI_current_presentation),
    1115                 :            :         sPropertyIsVisible(sAPI_is_visible),
    1116                 :            :         aValueHelper(rImport, rHlp, sal_False, sal_True, sal_False, sal_False),
    1117                 :            :         bColumnOK(sal_False),
    1118                 :            :         bDisplay( sal_True ),
    1119         [ #  # ]:          0 :         bDisplayOK( sal_False )
    1120                 :            : {
    1121                 :          0 : }
    1122                 :            : 
    1123                 :          0 : void XMLDatabaseDisplayImportContext::ProcessAttribute(
    1124                 :            :     sal_uInt16 nAttrToken, const OUString& sAttrValue )
    1125                 :            : {
    1126   [ #  #  #  # ]:          0 :     switch (nAttrToken)
    1127                 :            :     {
    1128                 :            :         case XML_TOK_TEXTFIELD_COLUMN_NAME:
    1129                 :          0 :             sColumnName = sAttrValue;
    1130                 :          0 :             bColumnOK = sal_True;
    1131                 :          0 :             break;
    1132                 :            :         case XML_TOK_TEXTFIELD_DISPLAY:
    1133                 :            :             {
    1134                 :          0 :                 sal_Bool bNone = IsXMLToken( sAttrValue, XML_NONE );
    1135                 :          0 :                 sal_Bool bValue = IsXMLToken( sAttrValue, XML_VALUE );
    1136                 :          0 :                 bDisplay = bValue;
    1137 [ #  # ][ #  # ]:          0 :                 bDisplayOK = bNone || bValue;
    1138                 :            :             }
    1139                 :          0 :             break;
    1140                 :            :         case XML_TOK_TEXTFIELD_DATABASE_NAME:
    1141                 :            :         case XML_TOK_TEXTFIELD_TABLE_NAME:
    1142                 :            :         case XML_TOK_TEXTFIELD_TABLE_TYPE:
    1143                 :            :             // handled by super class
    1144                 :            :             XMLDatabaseFieldImportContext::ProcessAttribute(nAttrToken,
    1145                 :          0 :                                                             sAttrValue);
    1146                 :          0 :             break;
    1147                 :            :         default:
    1148                 :            :             // remainder handled by value helper
    1149                 :          0 :             aValueHelper.ProcessAttribute(nAttrToken, sAttrValue);
    1150                 :          0 :             break;
    1151                 :            :     }
    1152                 :            : 
    1153 [ #  # ][ #  # ]:          0 :     bValid = bTableOK && bDatabaseOK && bColumnOK;
                 [ #  # ]
    1154                 :          0 : }
    1155                 :            : 
    1156                 :          0 : void XMLDatabaseDisplayImportContext::EndElement()
    1157                 :            : {
    1158                 :            :     // we have an EndElement of our own, because database fields need
    1159                 :            :     // to be attached to a field master before they can be inserted into
    1160                 :            :     // the document. Database stuff (database, table, column) all goes
    1161                 :            :     // to the field master, value & style go to the field.
    1162                 :            : 
    1163         [ #  # ]:          0 :     if (bValid)
    1164                 :            :     {
    1165                 :            : 
    1166                 :            :         // so here goes: we start with the master
    1167                 :          0 :         Reference<XPropertySet> xMaster;
    1168                 :            : 
    1169                 :            :         // create and prepare field master first
    1170         [ #  # ]:          0 :         if (CreateField(xMaster,
    1171                 :            :                         OUString(
    1172         [ #  # ]:          0 :                             sAPI_fieldmaster_database)))
    1173                 :            :         {
    1174                 :          0 :             Any aAny;
    1175         [ #  # ]:          0 :             aAny <<= sColumnName;
    1176 [ #  # ][ #  # ]:          0 :             xMaster->setPropertyValue(sPropertyColumnName, aAny);
    1177                 :            : 
    1178                 :            :             // fieldmaster takes database, table and column name
    1179         [ #  # ]:          0 :             XMLDatabaseFieldImportContext::PrepareField(xMaster);
    1180                 :            : 
    1181                 :            :             // create field
    1182                 :          0 :             Reference<XPropertySet> xField;
    1183         [ #  # ]:          0 :             if (CreateField(xField,
    1184                 :            :                             OUString(
    1185         [ #  # ]:          0 :                                 sAPI_database)))
    1186                 :            :             {
    1187                 :            :                 // attach field master
    1188         [ #  # ]:          0 :                 Reference<XDependentTextField> xDepField(xField, UNO_QUERY);
    1189         [ #  # ]:          0 :                 if (xDepField.is())
    1190                 :            :                 {
    1191                 :            :                     // attach field to field master
    1192 [ #  # ][ #  # ]:          0 :                     xDepField->attachTextFieldMaster(xMaster);
    1193                 :            : 
    1194                 :            :                     // attach field to document
    1195         [ #  # ]:          0 :                     Reference<XTextContent> xTextContent(xField, UNO_QUERY);
    1196         [ #  # ]:          0 :                     if (xTextContent.is())
    1197                 :            :                     {
    1198                 :            :                         // insert, set field properties and exit!
    1199         [ #  # ]:          0 :                         GetImportHelper().InsertTextContent(xTextContent);
    1200                 :            : 
    1201                 :            :                         // prepare field: format from database?
    1202                 :          0 :                         sal_Bool bTmp = !aValueHelper.IsFormatOK();
    1203         [ #  # ]:          0 :                         aAny.setValue( &bTmp, ::getBooleanCppuType() );
    1204 [ #  # ][ #  # ]:          0 :                         xField->setPropertyValue(sPropertyDatabaseFormat,aAny);
    1205                 :            : 
    1206                 :            :                         // value, value-type and format done by value helper
    1207         [ #  # ]:          0 :                         aValueHelper.PrepareField(xField);
    1208                 :            : 
    1209                 :            :                         // visibility
    1210         [ #  # ]:          0 :                         if( bDisplayOK )
    1211                 :            :                         {
    1212         [ #  # ]:          0 :                             aAny.setValue( &bDisplay, ::getBooleanCppuType() );
    1213 [ #  # ][ #  # ]:          0 :                             xField->setPropertyValue(sPropertyIsVisible, aAny);
    1214                 :            :                         }
    1215                 :            : 
    1216                 :            :                         // set presentation
    1217 [ #  # ][ #  # ]:          0 :                         aAny <<= GetContent();
    1218         [ #  # ]:          0 :                         xField->setPropertyValue(sPropertyCurrentPresentation,
    1219         [ #  # ]:          0 :                                                     aAny);
    1220                 :            : 
    1221                 :            :                         // success!
    1222                 :          0 :                         return;
    1223         [ #  # ]:          0 :                     }
    1224         [ #  # ]:          0 :                 }
    1225 [ #  # ][ #  # ]:          0 :             }
    1226         [ #  # ]:          0 :         }
    1227                 :            :     }
    1228                 :            : 
    1229                 :            :     // above: exit on success; so for all error cases we end up here!
    1230                 :            :     // write element content
    1231         [ #  # ]:          0 :     GetImportHelper().InsertString(GetContent());
    1232                 :            : }
    1233                 :            : 
    1234                 :            : 
    1235                 :            : //
    1236                 :            : // value import helper
    1237                 :            : //
    1238                 :            : 
    1239                 :            : enum ValueType
    1240                 :            : {
    1241                 :            :     XML_VALUE_TYPE_STRING,
    1242                 :            :     XML_VALUE_TYPE_FLOAT,
    1243                 :            :     XML_VALUE_TYPE_CURRENCY,
    1244                 :            :     XML_VALUE_TYPE_PERCENTAGE,
    1245                 :            :     XML_VALUE_TYPE_DATE,
    1246                 :            :     XML_VALUE_TYPE_TIME,
    1247                 :            :     XML_VALUE_TYPE_BOOLEAN
    1248                 :            : };
    1249                 :            : 
    1250                 :            : static SvXMLEnumMapEntry const aValueTypeMap[] =
    1251                 :            : {
    1252                 :            :     { XML_FLOAT,        XML_VALUE_TYPE_FLOAT },
    1253                 :            :     { XML_CURRENCY,     XML_VALUE_TYPE_CURRENCY },
    1254                 :            :     { XML_PERCENTAGE,   XML_VALUE_TYPE_PERCENTAGE },
    1255                 :            :     { XML_DATE,         XML_VALUE_TYPE_DATE },
    1256                 :            :     { XML_TIME,         XML_VALUE_TYPE_TIME },
    1257                 :            :     { XML_BOOLEAN,      XML_VALUE_TYPE_BOOLEAN },
    1258                 :            :     { XML_STRING,       XML_VALUE_TYPE_STRING },
    1259                 :            :     { XML_TOKEN_INVALID, 0 }
    1260                 :            : };
    1261                 :            : 
    1262                 :        306 : XMLValueImportHelper::XMLValueImportHelper(
    1263                 :            :     SvXMLImport& rImprt,
    1264                 :            :     XMLTextImportHelper& rHlp,
    1265                 :            :     sal_Bool bType, sal_Bool bStyle, sal_Bool bValue, sal_Bool bFormula) :
    1266                 :            :         sPropertyContent(sAPI_content),
    1267                 :            :         sPropertyValue(sAPI_value),
    1268                 :            :         sPropertyNumberFormat(sAPI_number_format),
    1269                 :            :         sPropertyIsFixedLanguage(sAPI_is_fixed_language),
    1270                 :            : 
    1271                 :            :         rImport(rImprt),
    1272                 :            :         rHelper(rHlp),
    1273                 :            : 
    1274                 :            :         fValue(0.0),
    1275                 :            :         nFormatKey(0),
    1276                 :            :         bIsDefaultLanguage(sal_True),
    1277                 :            : 
    1278                 :            :         bStringType(sal_False),
    1279                 :            :         bFormatOK(sal_False),
    1280                 :            :         bTypeOK(sal_False),
    1281                 :            :         bStringValueOK(sal_False),
    1282                 :            :         bFloatValueOK(sal_False),
    1283                 :            :         bFormulaOK(sal_False),
    1284                 :            : 
    1285                 :            :         bSetType(bType),
    1286                 :            :         bSetValue(bValue),
    1287                 :            :         bSetStyle(bStyle),
    1288                 :            :         bSetFormula(bFormula),
    1289                 :            : 
    1290                 :            :         bStringDefault(sal_True),
    1291                 :        306 :         bFormulaDefault(sal_True)
    1292                 :            : {
    1293                 :        306 : }
    1294                 :            : 
    1295                 :        306 : XMLValueImportHelper::~XMLValueImportHelper()
    1296                 :            : {
    1297         [ -  + ]:        306 : }
    1298                 :            : 
    1299                 :        108 : void XMLValueImportHelper::ProcessAttribute(
    1300                 :            :     sal_uInt16 nAttrToken, const OUString& sAttrValue )
    1301                 :            : {
    1302   [ +  -  -  -  :        108 :     switch (nAttrToken)
             -  +  -  -  
                      - ]
    1303                 :            :     {
    1304                 :            :         case XML_TOK_TEXTFIELD_VALUE_TYPE:
    1305                 :            :         {
    1306                 :            :             // convert enum
    1307                 :         54 :             sal_uInt16 nTmp = 0;
    1308                 :            :             sal_Bool bRet = SvXMLUnitConverter::convertEnum(
    1309         [ +  - ]:         54 :                 nTmp, sAttrValue, aValueTypeMap);
    1310                 :            : 
    1311         [ +  - ]:         54 :             if (bRet) {
    1312                 :         54 :                 ValueType eValueType = (ValueType)nTmp;
    1313                 :            : 
    1314                 :         54 :                 bTypeOK = sal_True;
    1315                 :            : 
    1316      [ +  -  - ]:         54 :                 switch (eValueType)
    1317                 :            :                 {
    1318                 :            :                     case XML_VALUE_TYPE_STRING:
    1319                 :         54 :                         bStringType = sal_True;
    1320                 :         54 :                         break;
    1321                 :            :                     case XML_VALUE_TYPE_FLOAT:
    1322                 :            :                     case XML_VALUE_TYPE_CURRENCY:
    1323                 :            :                     case XML_VALUE_TYPE_PERCENTAGE:
    1324                 :            :                     case XML_VALUE_TYPE_DATE:
    1325                 :            :                     case XML_VALUE_TYPE_TIME:
    1326                 :            :                     case XML_VALUE_TYPE_BOOLEAN:
    1327                 :          0 :                         bStringType = sal_False;
    1328                 :          0 :                         break;
    1329                 :            : 
    1330                 :            :                     default:
    1331                 :            :                         OSL_FAIL("unknown value type");
    1332                 :         54 :                         bTypeOK = sal_False;
    1333                 :            :                 }
    1334                 :            :             }
    1335                 :            :             break;
    1336                 :            :         }
    1337                 :            : 
    1338                 :            :         case XML_TOK_TEXTFIELD_VALUE:
    1339                 :            :         {
    1340                 :            :             double fTmp;
    1341         [ #  # ]:          0 :             bool const bRet = ::sax::Converter::convertDouble(fTmp,sAttrValue);
    1342         [ #  # ]:          0 :             if (bRet) {
    1343                 :          0 :                 bFloatValueOK = sal_True;
    1344                 :          0 :                 fValue = fTmp;
    1345                 :            :             }
    1346                 :            :             break;
    1347                 :            :         }
    1348                 :            : 
    1349                 :            :         case XML_TOK_TEXTFIELD_TIME_VALUE:
    1350                 :            :         {
    1351                 :            :             double fTmp;
    1352                 :            :             bool const bRet =
    1353         [ #  # ]:          0 :                 ::sax::Converter::convertDuration(fTmp, sAttrValue);
    1354         [ #  # ]:          0 :             if (bRet) {
    1355                 :          0 :                 bFloatValueOK = sal_True;
    1356                 :          0 :                 fValue = fTmp;
    1357                 :            :             }
    1358                 :            :             break;
    1359                 :            :         }
    1360                 :            : 
    1361                 :            :         case XML_TOK_TEXTFIELD_DATE_VALUE:
    1362                 :            :         {
    1363                 :            :             double fTmp;
    1364                 :          0 :             sal_Bool bRet = rImport.GetMM100UnitConverter().
    1365         [ #  # ]:          0 :                 convertDateTime(fTmp,sAttrValue);
    1366         [ #  # ]:          0 :             if (bRet) {
    1367                 :          0 :                 bFloatValueOK = sal_True;
    1368                 :          0 :                 fValue = fTmp;
    1369                 :            :             }
    1370                 :            :             break;
    1371                 :            :         }
    1372                 :            : 
    1373                 :            :         case XML_TOK_TEXTFIELD_BOOL_VALUE:
    1374                 :            :         {
    1375                 :          0 :             bool bTmp(false);
    1376         [ #  # ]:          0 :             bool bRet = ::sax::Converter::convertBool(bTmp, sAttrValue);
    1377         [ #  # ]:          0 :             if (bRet) {
    1378                 :          0 :                 bFloatValueOK = sal_True;
    1379         [ #  # ]:          0 :                 fValue = (bTmp ? 1.0 : 0.0);
    1380                 :            :             }
    1381                 :            :             else
    1382                 :            :             {
    1383                 :            :                 double fTmp;
    1384         [ #  # ]:          0 :                 bRet = ::sax::Converter::convertDouble(fTmp, sAttrValue);
    1385         [ #  # ]:          0 :                 if (bRet) {
    1386                 :          0 :                     bFloatValueOK = sal_True;
    1387                 :          0 :                     fValue = fTmp;
    1388                 :            :                 }
    1389                 :            :             }
    1390                 :            :             break;
    1391                 :            :         }
    1392                 :            : 
    1393                 :            :         case XML_TOK_TEXTFIELD_STRING_VALUE:
    1394                 :         54 :             sValue = sAttrValue;
    1395                 :         54 :             bStringValueOK = sal_True;
    1396                 :         54 :             break;
    1397                 :            : 
    1398                 :            :         case XML_TOK_TEXTFIELD_FORMULA:
    1399                 :            :             {
    1400                 :          0 :                 OUString sTmp;
    1401                 :          0 :                 sal_uInt16 nPrefix = rImport.GetNamespaceMap().
    1402         [ #  # ]:          0 :                         _GetKeyByAttrName( sAttrValue, &sTmp, sal_False );
    1403         [ #  # ]:          0 :                 if( XML_NAMESPACE_OOOW == nPrefix )
    1404                 :            :                 {
    1405                 :          0 :                     sFormula = sTmp;
    1406                 :          0 :                     bFormulaOK = sal_True;
    1407                 :            :                 }
    1408                 :            :                 else
    1409                 :          0 :                     sFormula = sAttrValue;
    1410                 :            :             }
    1411                 :          0 :             break;
    1412                 :            : 
    1413                 :            :         case XML_TOK_TEXTFIELD_DATA_STYLE_NAME:
    1414                 :            :         {
    1415                 :            :             sal_Int32 nKey = rHelper.GetDataStyleKey(
    1416                 :          0 :                                           sAttrValue, &bIsDefaultLanguage);
    1417         [ #  # ]:          0 :             if (-1 != nKey)
    1418                 :            :             {
    1419                 :          0 :                 nFormatKey = nKey;
    1420                 :          0 :                 bFormatOK = sal_True;
    1421                 :            :             }
    1422                 :          0 :             break;
    1423                 :            :         }
    1424                 :            :     } // switch
    1425                 :        108 : }
    1426                 :            : 
    1427                 :         54 : void XMLValueImportHelper::PrepareField(
    1428                 :            :     const Reference<XPropertySet> & xPropertySet)
    1429                 :            : {
    1430                 :         54 :     Any aAny;
    1431                 :            : 
    1432                 :         54 :     if (bSetType)
    1433                 :            :     {
    1434                 :            :         // ??? how to set type?
    1435                 :            :     }
    1436                 :            : 
    1437         [ -  + ]:         54 :     if (bSetFormula)
    1438                 :            :     {
    1439 [ #  # ][ #  # ]:          0 :         aAny <<= (!bFormulaOK && bFormulaDefault) ? sDefault : sFormula;
                 [ #  # ]
    1440 [ #  # ][ #  # ]:          0 :         xPropertySet->setPropertyValue(sPropertyContent, aAny);
    1441                 :            :     }
    1442                 :            : 
    1443                 :            :     // format/style
    1444 [ -  + ][ #  # ]:         54 :     if (bSetStyle && bFormatOK)
    1445                 :            :     {
    1446         [ #  # ]:          0 :         aAny <<= nFormatKey;
    1447 [ #  # ][ #  # ]:          0 :         xPropertySet->setPropertyValue(sPropertyNumberFormat, aAny);
    1448                 :            : 
    1449 [ #  # ][ #  # ]:          0 :         if( xPropertySet->getPropertySetInfo()->
         [ #  # ][ #  # ]
    1450         [ #  # ]:          0 :                 hasPropertyByName( sPropertyIsFixedLanguage ) )
    1451                 :            :         {
    1452                 :          0 :             sal_Bool bIsFixedLanguage = ! bIsDefaultLanguage;
    1453         [ #  # ]:          0 :             aAny.setValue( &bIsFixedLanguage, ::getBooleanCppuType() );
    1454 [ #  # ][ #  # ]:          0 :             xPropertySet->setPropertyValue( sPropertyIsFixedLanguage, aAny );
    1455                 :            :         }
    1456                 :            :     }
    1457                 :            : 
    1458                 :            :     // value: string or float
    1459         [ +  - ]:         54 :     if (bSetValue)
    1460                 :            :     {
    1461         [ +  - ]:         54 :         if (bStringType)
    1462                 :            :         {
    1463 [ -  + ][ #  # ]:         54 :             aAny <<= (!bStringValueOK && bStringDefault) ? sDefault : sValue;
                 [ +  - ]
    1464 [ +  - ][ +  - ]:         54 :             xPropertySet->setPropertyValue(sPropertyContent, aAny);
    1465                 :            :         }
    1466                 :            :         else
    1467                 :            :         {
    1468         [ #  # ]:          0 :             aAny <<= fValue;
    1469 [ #  # ][ #  # ]:          0 :             xPropertySet->setPropertyValue(sPropertyValue, aAny);
    1470                 :            :         }
    1471                 :         54 :     }
    1472                 :         54 : }
    1473                 :            : 
    1474                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10