LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLIndexObjectSourceContext.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 41 47 87.2 %
Date: 2015-06-13 12:38:46 Functions: 6 11 54.5 %
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 "XMLIndexObjectSourceContext.hxx"
      22             : 
      23             : #include <rtl/ustring.hxx>
      24             : 
      25             : #include <com/sun/star/beans/XPropertySet.hpp>
      26             : #include <com/sun/star/container/XIndexReplace.hpp>
      27             : 
      28             : #include <sax/tools/converter.hxx>
      29             : 
      30             : #include "XMLIndexTemplateContext.hxx"
      31             : #include "XMLIndexTitleTemplateContext.hxx"
      32             : #include "XMLIndexTOCStylesContext.hxx"
      33             : #include <xmloff/xmlictxt.hxx>
      34             : #include <xmloff/xmlimp.hxx>
      35             : #include <xmloff/txtimp.hxx>
      36             : #include <xmloff/xmlnmspe.hxx>
      37             : #include <xmloff/nmspmap.hxx>
      38             : #include <xmloff/xmltoken.hxx>
      39             : 
      40             : 
      41             : using ::com::sun::star::beans::XPropertySet;
      42             : using ::com::sun::star::uno::Reference;
      43             : using ::com::sun::star::uno::Any;
      44             : using ::com::sun::star::xml::sax::XAttributeList;
      45             : using ::xmloff::token::IsXMLToken;
      46             : using ::xmloff::token::XML_OBJECT_INDEX_ENTRY_TEMPLATE;
      47             : using ::xmloff::token::XML_TOKEN_INVALID;
      48             : 
      49             : const sal_Char sAPI_CreateFromStarCalc[] = "CreateFromStarCalc";
      50             : const sal_Char sAPI_CreateFromStarChart[] = "CreateFromStarChart";
      51             : const sal_Char sAPI_CreateFromStarDraw[] = "CreateFromStarDraw";
      52             : const sal_Char sAPI_CreateFromStarMath[] = "CreateFromStarMath";
      53             : const sal_Char sAPI_CreateFromOtherEmbeddedObjects[] = "CreateFromOtherEmbeddedObjects";
      54             : 
      55             : 
      56           0 : TYPEINIT1( XMLIndexObjectSourceContext, XMLIndexSourceBaseContext );
      57             : 
      58           2 : XMLIndexObjectSourceContext::XMLIndexObjectSourceContext(
      59             :     SvXMLImport& rImport,
      60             :     sal_uInt16 nPrfx,
      61             :     const OUString& rLocalName,
      62             :     Reference<XPropertySet> & rPropSet) :
      63             :         XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName,
      64             :                                   rPropSet, false),
      65             :         sCreateFromStarCalc(sAPI_CreateFromStarCalc),
      66             :         sCreateFromStarChart(sAPI_CreateFromStarChart),
      67             :         sCreateFromStarDraw(sAPI_CreateFromStarDraw),
      68             :         sCreateFromStarMath(sAPI_CreateFromStarMath),
      69             :         sCreateFromOtherEmbeddedObjects(sAPI_CreateFromOtherEmbeddedObjects),
      70             :         bUseCalc(false),
      71             :         bUseChart(false),
      72             :         bUseDraw(false),
      73             :         bUseMath(false),
      74           2 :         bUseOtherObjects(false)
      75             : {
      76           2 : }
      77             : 
      78           4 : XMLIndexObjectSourceContext::~XMLIndexObjectSourceContext()
      79             : {
      80           4 : }
      81             : 
      82           8 : void XMLIndexObjectSourceContext::ProcessAttribute(
      83             :     enum IndexSourceParamEnum eParam,
      84             :     const OUString& rValue)
      85             : {
      86           8 :     bool bTmp(false);
      87             : 
      88           8 :     switch (eParam)
      89             :     {
      90             :         case XML_TOK_INDEXSOURCE_USE_OTHER_OBJECTS:
      91           0 :             if (::sax::Converter::convertBool(bTmp, rValue))
      92             :             {
      93           0 :                 bUseOtherObjects = bTmp;
      94             :             }
      95           0 :             break;
      96             : 
      97             :         case XML_TOK_INDEXSOURCE_USE_SHEET:
      98           2 :             if (::sax::Converter::convertBool(bTmp, rValue))
      99             :             {
     100           2 :                 bUseCalc = bTmp;
     101             :             }
     102           2 :             break;
     103             : 
     104             :         case XML_TOK_INDEXSOURCE_USE_CHART:
     105           2 :             if (::sax::Converter::convertBool(bTmp, rValue))
     106             :             {
     107           2 :                 bUseChart = bTmp;
     108             :             }
     109           2 :             break;
     110             : 
     111             :         case XML_TOK_INDEXSOURCE_USE_DRAW:
     112           2 :             if (::sax::Converter::convertBool(bTmp, rValue))
     113             :             {
     114           2 :                 bUseDraw = bTmp;
     115             :             }
     116           2 :             break;
     117             : 
     118             :         case XML_TOK_INDEXSOURCE_USE_MATH:
     119           2 :             if (::sax::Converter::convertBool(bTmp, rValue))
     120             :             {
     121           2 :                 bUseMath = bTmp;
     122             :             }
     123           2 :             break;
     124             : 
     125             :         default:
     126           0 :             XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
     127           0 :             break;
     128             :     }
     129           8 : }
     130             : 
     131           2 : void XMLIndexObjectSourceContext::EndElement()
     132             : {
     133           2 :     Any aAny;
     134             : 
     135           2 :     aAny.setValue(&bUseCalc, cppu::UnoType<bool>::get());
     136           2 :     rIndexPropertySet->setPropertyValue(sCreateFromStarCalc, aAny);
     137             : 
     138           2 :     aAny.setValue(&bUseChart, cppu::UnoType<bool>::get());
     139           2 :     rIndexPropertySet->setPropertyValue(sCreateFromStarChart, aAny);
     140             : 
     141           2 :     aAny.setValue(&bUseDraw, cppu::UnoType<bool>::get());
     142           2 :     rIndexPropertySet->setPropertyValue(sCreateFromStarDraw, aAny);
     143             : 
     144           2 :     aAny.setValue(&bUseMath, cppu::UnoType<bool>::get());
     145           2 :     rIndexPropertySet->setPropertyValue(sCreateFromStarMath, aAny);
     146             : 
     147           2 :     aAny.setValue(&bUseOtherObjects, cppu::UnoType<bool>::get());
     148           2 :     rIndexPropertySet->setPropertyValue(sCreateFromOtherEmbeddedObjects, aAny);
     149             : 
     150           2 :     XMLIndexSourceBaseContext::EndElement();
     151           2 : }
     152             : 
     153           4 : SvXMLImportContext* XMLIndexObjectSourceContext::CreateChildContext(
     154             :     sal_uInt16 nPrefix,
     155             :     const OUString& rLocalName,
     156             :     const Reference<XAttributeList> & xAttrList )
     157             : {
     158           8 :     if ( (XML_NAMESPACE_TEXT == nPrefix) &&
     159           4 :          (IsXMLToken(rLocalName, XML_OBJECT_INDEX_ENTRY_TEMPLATE)) )
     160             :     {
     161           2 :         return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
     162             :                                            nPrefix, rLocalName,
     163             :                                            aLevelNameTableMap,
     164             :                                            XML_TOKEN_INVALID, // no outline-level attr
     165             :                                            aLevelStylePropNameTableMap,
     166           2 :                                            aAllowedTokenTypesTable);
     167             :     }
     168             :     else
     169             :     {
     170             :         return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
     171             :                                                              rLocalName,
     172           2 :                                                              xAttrList);
     173             :     }
     174             : 
     175             : }
     176             : 
     177             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11