LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLIndexTableSourceContext.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 40 0.0 %
Date: 2014-04-14 Functions: 0 11 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "XMLIndexTableSourceContext.hxx"
      22             : 
      23             : #include <com/sun/star/beans/XPropertySet.hpp>
      24             : #include <com/sun/star/container/XIndexReplace.hpp>
      25             : #include <com/sun/star/text/ReferenceFieldPart.hpp>
      26             : 
      27             : #include <sax/tools/converter.hxx>
      28             : 
      29             : #include "XMLIndexTemplateContext.hxx"
      30             : #include "XMLIndexTitleTemplateContext.hxx"
      31             : #include "XMLIndexTOCStylesContext.hxx"
      32             : #include <xmloff/xmlictxt.hxx>
      33             : #include <xmloff/xmlimp.hxx>
      34             : #include <xmloff/txtimp.hxx>
      35             : #include <xmloff/xmlnmspe.hxx>
      36             : #include <xmloff/nmspmap.hxx>
      37             : #include <xmloff/xmltoken.hxx>
      38             : #include <xmloff/xmluconv.hxx>
      39             : #include <rtl/ustring.hxx>
      40             : 
      41             : 
      42             : using namespace ::com::sun::star::text;
      43             : using namespace ::xmloff::token;
      44             : 
      45             : using ::com::sun::star::beans::XPropertySet;
      46             : using ::com::sun::star::uno::Reference;
      47             : using ::com::sun::star::uno::Any;
      48             : using ::com::sun::star::xml::sax::XAttributeList;
      49             : 
      50             : const sal_Char sAPI_CreateFromLabels[] = "CreateFromLabels";
      51             : const sal_Char sAPI_LabelCategory[] = "LabelCategory";
      52             : const sal_Char sAPI_LabelDisplayType[] = "LabelDisplayType";
      53             : 
      54             : 
      55           0 : TYPEINIT1(XMLIndexTableSourceContext, XMLIndexSourceBaseContext);
      56             : 
      57             : 
      58           0 : XMLIndexTableSourceContext::XMLIndexTableSourceContext(
      59             :     SvXMLImport& rImport, sal_uInt16 nPrfx,
      60             :     const OUString& rLocalName, Reference<XPropertySet> & rPropSet)
      61             :     : XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName,
      62             :                                   rPropSet, sal_False)
      63             :     , sCreateFromLabels(sAPI_CreateFromLabels)
      64             :     , sLabelCategory(sAPI_LabelCategory)
      65             :     , sLabelDisplayType(sAPI_LabelDisplayType)
      66             :     , nDisplayFormat(0)
      67             :     , bSequenceOK(sal_False)
      68             :     , bDisplayFormatOK(sal_False)
      69           0 :     , bUseCaption(sal_True)
      70             : {
      71           0 : }
      72             : 
      73           0 : XMLIndexTableSourceContext::~XMLIndexTableSourceContext()
      74             : {
      75           0 : }
      76             : 
      77             : static SvXMLEnumMapEntry const lcl_aReferenceTypeTokenMap[] =
      78             : {
      79             : 
      80             :     { XML_TEXT,                 ReferenceFieldPart::TEXT },
      81             :     { XML_CATEGORY_AND_VALUE,   ReferenceFieldPart::CATEGORY_AND_NUMBER },
      82             :     { XML_CAPTION,              ReferenceFieldPart::ONLY_CAPTION },
      83             : 
      84             :     // wrong values that previous versions wrote:
      85             :     { XML_CHAPTER,              ReferenceFieldPart::CATEGORY_AND_NUMBER },
      86             :     { XML_PAGE,                 ReferenceFieldPart::ONLY_CAPTION },
      87             : 
      88             :     { XML_TOKEN_INVALID,        0 }
      89             : };
      90             : 
      91           0 : void XMLIndexTableSourceContext::ProcessAttribute(
      92             :     enum IndexSourceParamEnum eParam,
      93             :     const OUString& rValue)
      94             : {
      95           0 :     bool bTmp(false);
      96             : 
      97           0 :     switch (eParam)
      98             :     {
      99             :         case XML_TOK_INDEXSOURCE_USE_CAPTION:
     100           0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     101             :             {
     102           0 :                 bUseCaption = bTmp;
     103             :             }
     104           0 :             break;
     105             : 
     106             :         case XML_TOK_INDEXSOURCE_SEQUENCE_NAME:
     107           0 :             sSequence = rValue;
     108           0 :             bSequenceOK = sal_True;
     109           0 :             break;
     110             : 
     111             :         case XML_TOK_INDEXSOURCE_SEQUENCE_FORMAT:
     112             :         {
     113             :              sal_uInt16 nTmp;
     114           0 :              if (SvXMLUnitConverter::convertEnum(nTmp, rValue,
     115             :                                                  lcl_aReferenceTypeTokenMap))
     116             :             {
     117           0 :                  nDisplayFormat = nTmp;
     118           0 :                  bDisplayFormatOK = sal_True;
     119             :              }
     120           0 :             break;
     121             :         }
     122             : 
     123             :         default:
     124           0 :             XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
     125           0 :             break;
     126             :     }
     127           0 : }
     128             : 
     129             : 
     130           0 : void XMLIndexTableSourceContext::EndElement()
     131             : {
     132           0 :     Any aAny;
     133             : 
     134           0 :     aAny.setValue(&bUseCaption, ::getBooleanCppuType());
     135           0 :     rIndexPropertySet->setPropertyValue(sCreateFromLabels, aAny);
     136             : 
     137           0 :     if (bSequenceOK)
     138             :     {
     139           0 :         aAny <<= sSequence;
     140           0 :         rIndexPropertySet->setPropertyValue(sLabelCategory, aAny);
     141             :     }
     142             : 
     143           0 :     if (bDisplayFormatOK)
     144             :     {
     145           0 :         aAny <<= nDisplayFormat;
     146           0 :         rIndexPropertySet->setPropertyValue(sLabelDisplayType, aAny);
     147             :     }
     148             : 
     149           0 :     XMLIndexSourceBaseContext::EndElement();
     150           0 : }
     151             : 
     152             : 
     153           0 : SvXMLImportContext* XMLIndexTableSourceContext::CreateChildContext(
     154             :     sal_uInt16 nPrefix,
     155             :     const OUString& rLocalName,
     156             :     const Reference<XAttributeList> & xAttrList )
     157             : {
     158           0 :     if ( ( XML_NAMESPACE_TEXT == nPrefix ) &&
     159           0 :          ( IsXMLToken( rLocalName, XML_TABLE_INDEX_ENTRY_TEMPLATE ) ) )
     160             :     {
     161           0 :         return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
     162             :                                            nPrefix, rLocalName,
     163             :                                            aLevelNameTableMap,
     164             :                                            XML_TOKEN_INVALID, // no outline-level attr
     165             :                                            aLevelStylePropNameTableMap,
     166           0 :                                            aAllowedTokenTypesTable);
     167             :     }
     168             :     else
     169             :     {
     170             :         return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
     171             :                                                              rLocalName,
     172           0 :                                                              xAttrList);
     173             :     }
     174             : 
     175             : }
     176             : 
     177             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10