LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLIndexTitleTemplateContext.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 35 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 "XMLIndexTitleTemplateContext.hxx"
      21             : #include <xmloff/xmlictxt.hxx>
      22             : #include <xmloff/xmlimp.hxx>
      23             : #include <xmloff/nmspmap.hxx>
      24             : #include <xmloff/xmlnmspe.hxx>
      25             : #include <xmloff/xmltoken.hxx>
      26             : 
      27             : 
      28             : using ::com::sun::star::beans::XPropertySet;
      29             : using ::com::sun::star::uno::Any;
      30             : using ::com::sun::star::uno::Reference;
      31             : using ::com::sun::star::xml::sax::XAttributeList;
      32             : using ::xmloff::token::IsXMLToken;
      33             : using ::xmloff::token::XML_STYLE_NAME;
      34             : 
      35             : 
      36           0 : TYPEINIT1( XMLIndexTitleTemplateContext, SvXMLImportContext );
      37             : 
      38           0 : XMLIndexTitleTemplateContext::XMLIndexTitleTemplateContext(
      39             :     SvXMLImport& rImport,
      40             :     Reference<XPropertySet> & rPropSet,
      41             :     sal_uInt16 nPrfx,
      42             :     const OUString& rLocalName)
      43             : :   SvXMLImportContext(rImport, nPrfx, rLocalName)
      44             : ,   sTitle("Title")
      45             : ,   sParaStyleHeading("ParaStyleHeading")
      46             : ,   bStyleNameOK(sal_False)
      47           0 : ,   rTOCPropertySet(rPropSet)
      48             : {
      49           0 : }
      50             : 
      51             : 
      52           0 : XMLIndexTitleTemplateContext::~XMLIndexTitleTemplateContext()
      53             : {
      54           0 : }
      55             : 
      56           0 : void XMLIndexTitleTemplateContext::StartElement(
      57             :     const Reference<XAttributeList> & xAttrList)
      58             : {
      59             :     // there's only one attribute: style-name
      60           0 :     sal_Int16 nLength = xAttrList->getLength();
      61           0 :     for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
      62             :     {
      63           0 :         OUString sLocalName;
      64           0 :         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
      65           0 :             GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
      66           0 :                               &sLocalName );
      67           0 :         if ( (XML_NAMESPACE_TEXT == nPrefix) &&
      68           0 :              (IsXMLToken(sLocalName, XML_STYLE_NAME)) )
      69             :         {
      70           0 :             sStyleName = xAttrList->getValueByIndex(nAttr);
      71           0 :             OUString sDisplayStyleName = GetImport().GetStyleDisplayName(
      72           0 :                 XML_STYLE_FAMILY_TEXT_PARAGRAPH, sStyleName );
      73             :             const Reference < ::com::sun::star::container::XNameContainer >&
      74           0 :                 rStyles = GetImport().GetTextImport()->GetParaStyles();
      75           0 :             bStyleNameOK = rStyles.is() && rStyles->hasByName( sDisplayStyleName );
      76             :         }
      77           0 :     }
      78           0 : }
      79             : 
      80           0 : void XMLIndexTitleTemplateContext::EndElement()
      81             : {
      82           0 :     Any aAny;
      83             : 
      84           0 :     aAny <<= sContent.makeStringAndClear();
      85           0 :     rTOCPropertySet->setPropertyValue(sTitle, aAny);
      86             : 
      87           0 :     if (bStyleNameOK)
      88             :     {
      89           0 :         aAny <<= GetImport().GetStyleDisplayName(
      90             :                                 XML_STYLE_FAMILY_TEXT_PARAGRAPH,
      91           0 :                                 sStyleName );
      92           0 :         rTOCPropertySet->setPropertyValue(sParaStyleHeading, aAny);
      93           0 :     }
      94           0 : }
      95             : 
      96           0 : void XMLIndexTitleTemplateContext::Characters(
      97             :     const OUString& sString)
      98             : {
      99           0 :     sContent.append(sString);
     100           0 : }
     101             : 
     102             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10