LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/text - XMLIndexTableSourceContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 40 0.0 %
Date: 2012-12-27 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 ::rtl::OUString;
      46             : using ::com::sun::star::beans::XPropertySet;
      47             : using ::com::sun::star::uno::Reference;
      48             : using ::com::sun::star::uno::Any;
      49             : using ::com::sun::star::xml::sax::XAttributeList;
      50             : 
      51             : const sal_Char sAPI_CreateFromLabels[] = "CreateFromLabels";
      52             : const sal_Char sAPI_LabelCategory[] = "LabelCategory";
      53             : const sal_Char sAPI_LabelDisplayType[] = "LabelDisplayType";
      54             : 
      55             : 
      56           0 : TYPEINIT1(XMLIndexTableSourceContext, XMLIndexSourceBaseContext);
      57             : 
      58             : 
      59           0 : XMLIndexTableSourceContext::XMLIndexTableSourceContext(
      60             :     SvXMLImport& rImport,
      61             :     sal_uInt16 nPrfx,
      62             :     const OUString& rLocalName,
      63             :     Reference<XPropertySet> & rPropSet) :
      64             :         XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName,
      65             :                                   rPropSet, sal_False),
      66             :         sCreateFromLabels(RTL_CONSTASCII_USTRINGPARAM(sAPI_CreateFromLabels)),
      67             :         sLabelCategory(RTL_CONSTASCII_USTRINGPARAM(sAPI_LabelCategory)),
      68             :         sLabelDisplayType(RTL_CONSTASCII_USTRINGPARAM(sAPI_LabelDisplayType)),
      69             :         bSequenceOK(sal_False),
      70             :         bDisplayFormatOK(sal_False),
      71           0 :         bUseCaption(sal_True)
      72             : {
      73           0 : }
      74             : 
      75           0 : XMLIndexTableSourceContext::~XMLIndexTableSourceContext()
      76             : {
      77           0 : }
      78             : 
      79             : static SvXMLEnumMapEntry const lcl_aReferenceTypeTokenMap[] =
      80             : {
      81             : 
      82             :     { XML_TEXT,                 ReferenceFieldPart::TEXT },
      83             :     { XML_CATEGORY_AND_VALUE,   ReferenceFieldPart::CATEGORY_AND_NUMBER },
      84             :     { XML_CAPTION,              ReferenceFieldPart::ONLY_CAPTION },
      85             : 
      86             :     // wrong values that previous versions wrote:
      87             :     { XML_CHAPTER,              ReferenceFieldPart::CATEGORY_AND_NUMBER },
      88             :     { XML_PAGE,                 ReferenceFieldPart::ONLY_CAPTION },
      89             : 
      90             :     { XML_TOKEN_INVALID,        0 }
      91             : };
      92             : 
      93           0 : void XMLIndexTableSourceContext::ProcessAttribute(
      94             :     enum IndexSourceParamEnum eParam,
      95             :     const OUString& rValue)
      96             : {
      97           0 :     bool bTmp(false);
      98             : 
      99           0 :     switch (eParam)
     100             :     {
     101             :         case XML_TOK_INDEXSOURCE_USE_CAPTION:
     102           0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     103             :             {
     104           0 :                 bUseCaption = bTmp;
     105             :             }
     106           0 :             break;
     107             : 
     108             :         case XML_TOK_INDEXSOURCE_SEQUENCE_NAME:
     109           0 :             sSequence = rValue;
     110           0 :             bSequenceOK = sal_True;
     111           0 :             break;
     112             : 
     113             :         case XML_TOK_INDEXSOURCE_SEQUENCE_FORMAT:
     114             :         {
     115             :              sal_uInt16 nTmp;
     116           0 :              if (SvXMLUnitConverter::convertEnum(nTmp, rValue,
     117           0 :                                                  lcl_aReferenceTypeTokenMap))
     118             :             {
     119           0 :                  nDisplayFormat = nTmp;
     120           0 :                  bDisplayFormatOK = sal_True;
     121             :              }
     122             :             break;
     123             :         }
     124             : 
     125             :         default:
     126           0 :             XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
     127           0 :             break;
     128             :     }
     129           0 : }
     130             : 
     131             : 
     132           0 : void XMLIndexTableSourceContext::EndElement()
     133             : {
     134           0 :     Any aAny;
     135             : 
     136           0 :     aAny.setValue(&bUseCaption, ::getBooleanCppuType());
     137           0 :     rIndexPropertySet->setPropertyValue(sCreateFromLabels, aAny);
     138             : 
     139           0 :     if (bSequenceOK)
     140             :     {
     141           0 :         aAny <<= sSequence;
     142           0 :         rIndexPropertySet->setPropertyValue(sLabelCategory, aAny);
     143             :     }
     144             : 
     145           0 :     if (bDisplayFormatOK)
     146             :     {
     147           0 :         aAny <<= nDisplayFormat;
     148           0 :         rIndexPropertySet->setPropertyValue(sLabelDisplayType, aAny);
     149             :     }
     150             : 
     151           0 :     XMLIndexSourceBaseContext::EndElement();
     152           0 : }
     153             : 
     154             : 
     155           0 : SvXMLImportContext* XMLIndexTableSourceContext::CreateChildContext(
     156             :     sal_uInt16 nPrefix,
     157             :     const OUString& rLocalName,
     158             :     const Reference<XAttributeList> & xAttrList )
     159             : {
     160           0 :     if ( ( XML_NAMESPACE_TEXT == nPrefix ) &&
     161           0 :          ( IsXMLToken( rLocalName, XML_TABLE_INDEX_ENTRY_TEMPLATE ) ) )
     162             :     {
     163           0 :         return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
     164             :                                            nPrefix, rLocalName,
     165             :                                            aLevelNameTableMap,
     166             :                                            XML_TOKEN_INVALID, // no outline-level attr
     167             :                                            aLevelStylePropNameTableMap,
     168           0 :                                            aAllowedTokenTypesTable);
     169             :     }
     170             :     else
     171             :     {
     172             :         return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
     173             :                                                              rLocalName,
     174           0 :                                                              xAttrList);
     175             :     }
     176             : 
     177             : }
     178             : 
     179             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10