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

Generated by: LCOV version 1.10