LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLIndexTOCSourceContext.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 50 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             : #include "XMLIndexTOCSourceContext.hxx"
      21             : #include <com/sun/star/beans/XPropertySet.hpp>
      22             : #include <com/sun/star/container/XIndexReplace.hpp>
      23             : #include <sax/tools/converter.hxx>
      24             : #include "XMLIndexTemplateContext.hxx"
      25             : #include "XMLIndexTitleTemplateContext.hxx"
      26             : #include "XMLIndexTOCStylesContext.hxx"
      27             : #include <xmloff/xmlictxt.hxx>
      28             : #include <xmloff/xmlimp.hxx>
      29             : #include <xmloff/txtimp.hxx>
      30             : #include <xmloff/xmlnmspe.hxx>
      31             : #include <xmloff/nmspmap.hxx>
      32             : #include <xmloff/xmltoken.hxx>
      33             : #include <rtl/ustring.hxx>
      34             : 
      35             : 
      36             : 
      37             : using namespace ::xmloff::token;
      38             : 
      39             : using ::com::sun::star::beans::XPropertySet;
      40             : using ::com::sun::star::uno::Reference;
      41             : using ::com::sun::star::uno::Any;
      42             : using ::com::sun::star::xml::sax::XAttributeList;
      43             : 
      44             : const sal_Char sAPI_CreateFromOutline[] = "CreateFromOutline";
      45             : const sal_Char sAPI_CreateFromMarks[] = "CreateFromMarks";
      46             : const sal_Char sAPI_Level[] = "Level";
      47             : const sal_Char sAPI_CreateFromLevelParagraphStyles[] = "CreateFromLevelParagraphStyles";
      48             : 
      49             : 
      50           0 : TYPEINIT1( XMLIndexTOCSourceContext, XMLIndexSourceBaseContext );
      51             : 
      52           0 : XMLIndexTOCSourceContext::XMLIndexTOCSourceContext(
      53             :     SvXMLImport& rImport,
      54             :     sal_uInt16 nPrfx,
      55             :     const OUString& rLocalName,
      56             :     Reference<XPropertySet> & rPropSet)
      57             : :   XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName, rPropSet, sal_True)
      58             : ,   sCreateFromMarks(sAPI_CreateFromMarks)
      59             : ,   sLevel(sAPI_Level)
      60             : ,   sCreateFromOutline(sAPI_CreateFromOutline)
      61             : ,   sCreateFromLevelParagraphStyles(sAPI_CreateFromLevelParagraphStyles)
      62             :     // use all chapters by default
      63           0 : ,   nOutlineLevel(rImport.GetTextImport()->GetChapterNumbering()->getCount())
      64             : ,   bUseOutline(sal_True)
      65             : ,   bUseMarks(sal_True)
      66           0 : ,   bUseParagraphStyles(sal_False)
      67             : {
      68           0 : }
      69             : 
      70           0 : XMLIndexTOCSourceContext::~XMLIndexTOCSourceContext()
      71             : {
      72           0 : }
      73             : 
      74           0 : void XMLIndexTOCSourceContext::ProcessAttribute(
      75             :     enum IndexSourceParamEnum eParam,
      76             :     const OUString& rValue)
      77             : {
      78           0 :     switch (eParam)
      79             :     {
      80             :         case XML_TOK_INDEXSOURCE_OUTLINE_LEVEL:
      81           0 :             if ( IsXMLToken( rValue, XML_NONE ) )
      82             :             {
      83             :                 // #104651# use OUTLINE_LEVEL and USE_OUTLINE_LEVEL instead of
      84             :                 // OUTLINE_LEVEL with values none|1..10. For backwards
      85             :                 // compatibility, 'none' must still be read.
      86           0 :                 bUseOutline = sal_False;
      87             :             }
      88             :             else
      89             :             {
      90             :                 sal_Int32 nTmp;
      91           0 :                 if (::sax::Converter::convertNumber(
      92           0 :                     nTmp, rValue, 1, GetImport().GetTextImport()->
      93           0 :                     GetChapterNumbering()->getCount()))
      94             :                 {
      95           0 :                     bUseOutline = sal_True;
      96           0 :                     nOutlineLevel = nTmp;
      97             :                 }
      98             :             }
      99           0 :             break;
     100             : 
     101             :         case XML_TOK_INDEXSOURCE_USE_OUTLINE_LEVEL:
     102             :         {
     103           0 :             bool bTmp(false);
     104           0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     105             :             {
     106           0 :                 bUseOutline = bTmp;
     107             :             }
     108           0 :             break;
     109             :         }
     110             : 
     111             : 
     112             :         case XML_TOK_INDEXSOURCE_USE_INDEX_MARKS:
     113             :         {
     114           0 :             bool bTmp(false);
     115           0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     116             :             {
     117           0 :                 bUseMarks = bTmp;
     118             :             }
     119           0 :             break;
     120             :         }
     121             : 
     122             :         case XML_TOK_INDEXSOURCE_USE_INDEX_SOURCE_STYLES:
     123             :         {
     124           0 :             bool bTmp(false);
     125           0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     126             :             {
     127           0 :                 bUseParagraphStyles = bTmp;
     128             :             }
     129           0 :             break;
     130             :         }
     131             : 
     132             :         default:
     133             :             // default: ask superclass
     134           0 :             XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
     135           0 :             break;
     136             :     }
     137           0 : }
     138             : 
     139           0 : void XMLIndexTOCSourceContext::EndElement()
     140             : {
     141           0 :     Any aAny;
     142             : 
     143           0 :     aAny.setValue(&bUseMarks, ::getBooleanCppuType());
     144           0 :     rIndexPropertySet->setPropertyValue(sCreateFromMarks, aAny);
     145             : 
     146           0 :     aAny.setValue(&bUseOutline, ::getBooleanCppuType());
     147           0 :     rIndexPropertySet->setPropertyValue(sCreateFromOutline, aAny);
     148             : 
     149           0 :     aAny.setValue(&bUseParagraphStyles, ::getBooleanCppuType());
     150           0 :     rIndexPropertySet->setPropertyValue(sCreateFromLevelParagraphStyles, aAny);
     151             : 
     152           0 :     aAny <<= (sal_Int16)nOutlineLevel;
     153           0 :     rIndexPropertySet->setPropertyValue(sLevel, aAny);
     154             : 
     155             :     // process common attributes
     156           0 :     XMLIndexSourceBaseContext::EndElement();
     157           0 : }
     158             : 
     159             : 
     160           0 : SvXMLImportContext* XMLIndexTOCSourceContext::CreateChildContext(
     161             :     sal_uInt16 nPrefix,
     162             :     const OUString& rLocalName,
     163             :     const Reference<XAttributeList> & xAttrList )
     164             : {
     165           0 :     if ( (XML_NAMESPACE_TEXT == nPrefix) &&
     166           0 :          IsXMLToken(rLocalName, XML_TABLE_OF_CONTENT_ENTRY_TEMPLATE) )
     167             :     {
     168           0 :         return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
     169             :                                            nPrefix, rLocalName,
     170             :                                            aSvLevelNameTOCMap,
     171             :                                            XML_OUTLINE_LEVEL,
     172             :                                            aLevelStylePropNameTOCMap,
     173           0 :                                            aAllowedTokenTypesTOC, sal_True );
     174             :     }
     175             :     else
     176             :     {
     177             :         return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
     178             :                                                              rLocalName,
     179           0 :                                                              xAttrList);
     180             :     }
     181             : }
     182             : 
     183             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10