LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/xmloff/source/text - XMLIndexObjectSourceContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 41 47 87.2 %
Date: 2013-07-09 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_CreateFromStarImage[] = "CreateFromStarImage";
      53             : const sal_Char sAPI_CreateFromStarMath[] = "CreateFromStarMath";
      54             : const sal_Char sAPI_CreateFromOtherEmbeddedObjects[] = "CreateFromOtherEmbeddedObjects";
      55             : 
      56             : 
      57           0 : TYPEINIT1( XMLIndexObjectSourceContext, XMLIndexSourceBaseContext );
      58             : 
      59           2 : XMLIndexObjectSourceContext::XMLIndexObjectSourceContext(
      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             :         sCreateFromStarCalc(sAPI_CreateFromStarCalc),
      67             :         sCreateFromStarChart(sAPI_CreateFromStarChart),
      68             :         sCreateFromStarDraw(sAPI_CreateFromStarDraw),
      69             :         sCreateFromStarMath(sAPI_CreateFromStarMath),
      70             :         sCreateFromOtherEmbeddedObjects(sAPI_CreateFromOtherEmbeddedObjects),
      71             :         bUseCalc(sal_False),
      72             :         bUseChart(sal_False),
      73             :         bUseDraw(sal_False),
      74             :         bUseMath(sal_False),
      75           2 :         bUseOtherObjects(sal_False)
      76             : {
      77           2 : }
      78             : 
      79           4 : XMLIndexObjectSourceContext::~XMLIndexObjectSourceContext()
      80             : {
      81           4 : }
      82             : 
      83           8 : void XMLIndexObjectSourceContext::ProcessAttribute(
      84             :     enum IndexSourceParamEnum eParam,
      85             :     const OUString& rValue)
      86             : {
      87           8 :     bool bTmp(false);
      88             : 
      89           8 :     switch (eParam)
      90             :     {
      91             :         case XML_TOK_INDEXSOURCE_USE_OTHER_OBJECTS:
      92           0 :             if (::sax::Converter::convertBool(bTmp, rValue))
      93             :             {
      94           0 :                 bUseOtherObjects = bTmp;
      95             :             }
      96           0 :             break;
      97             : 
      98             :         case XML_TOK_INDEXSOURCE_USE_SHEET:
      99           2 :             if (::sax::Converter::convertBool(bTmp, rValue))
     100             :             {
     101           2 :                 bUseCalc = bTmp;
     102             :             }
     103           2 :             break;
     104             : 
     105             :         case XML_TOK_INDEXSOURCE_USE_CHART:
     106           2 :             if (::sax::Converter::convertBool(bTmp, rValue))
     107             :             {
     108           2 :                 bUseChart = bTmp;
     109             :             }
     110           2 :             break;
     111             : 
     112             :         case XML_TOK_INDEXSOURCE_USE_DRAW:
     113           2 :             if (::sax::Converter::convertBool(bTmp, rValue))
     114             :             {
     115           2 :                 bUseDraw = bTmp;
     116             :             }
     117           2 :             break;
     118             : 
     119             :         case XML_TOK_INDEXSOURCE_USE_MATH:
     120           2 :             if (::sax::Converter::convertBool(bTmp, rValue))
     121             :             {
     122           2 :                 bUseMath = bTmp;
     123             :             }
     124           2 :             break;
     125             : 
     126             :         default:
     127           0 :             XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
     128           0 :             break;
     129             :     }
     130           8 : }
     131             : 
     132           2 : void XMLIndexObjectSourceContext::EndElement()
     133             : {
     134           2 :     Any aAny;
     135             : 
     136           2 :     aAny.setValue(&bUseCalc, ::getBooleanCppuType());
     137           2 :     rIndexPropertySet->setPropertyValue(sCreateFromStarCalc, aAny);
     138             : 
     139           2 :     aAny.setValue(&bUseChart, ::getBooleanCppuType());
     140           2 :     rIndexPropertySet->setPropertyValue(sCreateFromStarChart, aAny);
     141             : 
     142           2 :     aAny.setValue(&bUseDraw, ::getBooleanCppuType());
     143           2 :     rIndexPropertySet->setPropertyValue(sCreateFromStarDraw, aAny);
     144             : 
     145           2 :     aAny.setValue(&bUseMath, ::getBooleanCppuType());
     146           2 :     rIndexPropertySet->setPropertyValue(sCreateFromStarMath, aAny);
     147             : 
     148           2 :     aAny.setValue(&bUseOtherObjects, ::getBooleanCppuType());
     149           2 :     rIndexPropertySet->setPropertyValue(sCreateFromOtherEmbeddedObjects, aAny);
     150             : 
     151           2 :     XMLIndexSourceBaseContext::EndElement();
     152           2 : }
     153             : 
     154           4 : SvXMLImportContext* XMLIndexObjectSourceContext::CreateChildContext(
     155             :     sal_uInt16 nPrefix,
     156             :     const OUString& rLocalName,
     157             :     const Reference<XAttributeList> & xAttrList )
     158             : {
     159           8 :     if ( (XML_NAMESPACE_TEXT == nPrefix) &&
     160           4 :          (IsXMLToken(rLocalName, XML_OBJECT_INDEX_ENTRY_TEMPLATE)) )
     161             :     {
     162           2 :         return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
     163             :                                            nPrefix, rLocalName,
     164             :                                            aLevelNameTableMap,
     165             :                                            XML_TOKEN_INVALID, // no outline-level attr
     166             :                                            aLevelStylePropNameTableMap,
     167           2 :                                            aAllowedTokenTypesTable);
     168             :     }
     169             :     else
     170             :     {
     171             :         return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
     172             :                                                              rLocalName,
     173           2 :                                                              xAttrList);
     174             :     }
     175             : 
     176             : }
     177             : 
     178             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10