LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLIndexObjectSourceContext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 41 47 87.2 %
Date: 2014-11-03 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           4 : 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           4 :         bUseOtherObjects(false)
      75             : {
      76           4 : }
      77             : 
      78           8 : XMLIndexObjectSourceContext::~XMLIndexObjectSourceContext()
      79             : {
      80           8 : }
      81             : 
      82          16 : void XMLIndexObjectSourceContext::ProcessAttribute(
      83             :     enum IndexSourceParamEnum eParam,
      84             :     const OUString& rValue)
      85             : {
      86          16 :     bool bTmp(false);
      87             : 
      88          16 :     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           4 :             if (::sax::Converter::convertBool(bTmp, rValue))
      99             :             {
     100           4 :                 bUseCalc = bTmp;
     101             :             }
     102           4 :             break;
     103             : 
     104             :         case XML_TOK_INDEXSOURCE_USE_CHART:
     105           4 :             if (::sax::Converter::convertBool(bTmp, rValue))
     106             :             {
     107           4 :                 bUseChart = bTmp;
     108             :             }
     109           4 :             break;
     110             : 
     111             :         case XML_TOK_INDEXSOURCE_USE_DRAW:
     112           4 :             if (::sax::Converter::convertBool(bTmp, rValue))
     113             :             {
     114           4 :                 bUseDraw = bTmp;
     115             :             }
     116           4 :             break;
     117             : 
     118             :         case XML_TOK_INDEXSOURCE_USE_MATH:
     119           4 :             if (::sax::Converter::convertBool(bTmp, rValue))
     120             :             {
     121           4 :                 bUseMath = bTmp;
     122             :             }
     123           4 :             break;
     124             : 
     125             :         default:
     126           0 :             XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
     127           0 :             break;
     128             :     }
     129          16 : }
     130             : 
     131           4 : void XMLIndexObjectSourceContext::EndElement()
     132             : {
     133           4 :     Any aAny;
     134             : 
     135           4 :     aAny.setValue(&bUseCalc, ::getBooleanCppuType());
     136           4 :     rIndexPropertySet->setPropertyValue(sCreateFromStarCalc, aAny);
     137             : 
     138           4 :     aAny.setValue(&bUseChart, ::getBooleanCppuType());
     139           4 :     rIndexPropertySet->setPropertyValue(sCreateFromStarChart, aAny);
     140             : 
     141           4 :     aAny.setValue(&bUseDraw, ::getBooleanCppuType());
     142           4 :     rIndexPropertySet->setPropertyValue(sCreateFromStarDraw, aAny);
     143             : 
     144           4 :     aAny.setValue(&bUseMath, ::getBooleanCppuType());
     145           4 :     rIndexPropertySet->setPropertyValue(sCreateFromStarMath, aAny);
     146             : 
     147           4 :     aAny.setValue(&bUseOtherObjects, ::getBooleanCppuType());
     148           4 :     rIndexPropertySet->setPropertyValue(sCreateFromOtherEmbeddedObjects, aAny);
     149             : 
     150           4 :     XMLIndexSourceBaseContext::EndElement();
     151           4 : }
     152             : 
     153           8 : SvXMLImportContext* XMLIndexObjectSourceContext::CreateChildContext(
     154             :     sal_uInt16 nPrefix,
     155             :     const OUString& rLocalName,
     156             :     const Reference<XAttributeList> & xAttrList )
     157             : {
     158          16 :     if ( (XML_NAMESPACE_TEXT == nPrefix) &&
     159           8 :          (IsXMLToken(rLocalName, XML_OBJECT_INDEX_ENTRY_TEMPLATE)) )
     160             :     {
     161           4 :         return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
     162             :                                            nPrefix, rLocalName,
     163             :                                            aLevelNameTableMap,
     164             :                                            XML_TOKEN_INVALID, // no outline-level attr
     165             :                                            aLevelStylePropNameTableMap,
     166           4 :                                            aAllowedTokenTypesTable);
     167             :     }
     168             :     else
     169             :     {
     170             :         return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
     171             :                                                              rLocalName,
     172           4 :                                                              xAttrList);
     173             :     }
     174             : 
     175             : }
     176             : 
     177             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10