LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLSectionSourceImportContext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 44 0.0 %
Date: 2014-11-03 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 "XMLSectionSourceImportContext.hxx"
      21             : #include "XMLSectionImportContext.hxx"
      22             : #include <com/sun/star/text/SectionFileLink.hpp>
      23             : #include <xmloff/xmlictxt.hxx>
      24             : #include <xmloff/xmlimp.hxx>
      25             : #include <xmloff/txtimp.hxx>
      26             : #include <xmloff/nmspmap.hxx>
      27             : #include <xmloff/xmlnmspe.hxx>
      28             : #include <xmloff/xmltoken.hxx>
      29             : #include <com/sun/star/uno/Reference.h>
      30             : #include <com/sun/star/beans/XPropertySet.hpp>
      31             : 
      32             : 
      33             : using ::com::sun::star::beans::XPropertySet;
      34             : using ::com::sun::star::uno::Reference;
      35             : using ::com::sun::star::xml::sax::XAttributeList;
      36             : 
      37             : using namespace ::com::sun::star::uno;
      38             : using namespace ::com::sun::star::text;
      39             : using namespace ::xmloff::token;
      40             : 
      41             : 
      42           0 : TYPEINIT1(XMLSectionSourceImportContext, SvXMLImportContext);
      43             : 
      44           0 : XMLSectionSourceImportContext::XMLSectionSourceImportContext(
      45             :     SvXMLImport& rImport,
      46             :     sal_uInt16 nPrfx,
      47             :     const OUString& rLocalName,
      48             :     Reference<XPropertySet> & rSectPropSet) :
      49             :         SvXMLImportContext(rImport, nPrfx, rLocalName),
      50           0 :         rSectionPropertySet(rSectPropSet)
      51             : {
      52           0 : }
      53             : 
      54           0 : XMLSectionSourceImportContext::~XMLSectionSourceImportContext()
      55             : {
      56           0 : }
      57             : 
      58             : enum XMLSectionSourceToken
      59             : {
      60             :     XML_TOK_SECTION_XLINK_HREF,
      61             :     XML_TOK_SECTION_TEXT_FILTER_NAME,
      62             :     XML_TOK_SECTION_TEXT_SECTION_NAME
      63             : };
      64             : 
      65             : static const SvXMLTokenMapEntry aSectionSourceTokenMap[] =
      66             : {
      67             :     { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_SECTION_XLINK_HREF },
      68             :     { XML_NAMESPACE_TEXT, XML_FILTER_NAME, XML_TOK_SECTION_TEXT_FILTER_NAME },
      69             :     { XML_NAMESPACE_TEXT, XML_SECTION_NAME,
      70             :                                         XML_TOK_SECTION_TEXT_SECTION_NAME },
      71             :     XML_TOKEN_MAP_END
      72             : };
      73             : 
      74             : 
      75           0 : void XMLSectionSourceImportContext::StartElement(
      76             :     const Reference<XAttributeList> & xAttrList)
      77             : {
      78           0 :     SvXMLTokenMap aTokenMap(aSectionSourceTokenMap);
      79           0 :     OUString sURL;
      80           0 :     OUString sFilterName;
      81           0 :     OUString sSectionName;
      82             : 
      83           0 :     sal_Int16 nLength = xAttrList->getLength();
      84           0 :     for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
      85             :     {
      86           0 :         OUString sLocalName;
      87           0 :         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
      88           0 :             GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
      89           0 :                               &sLocalName );
      90             : 
      91           0 :         switch (aTokenMap.Get(nPrefix, sLocalName))
      92             :         {
      93             :             case XML_TOK_SECTION_XLINK_HREF:
      94           0 :                 sURL = xAttrList->getValueByIndex(nAttr);
      95           0 :                 break;
      96             : 
      97             :             case XML_TOK_SECTION_TEXT_FILTER_NAME:
      98           0 :                 sFilterName = xAttrList->getValueByIndex(nAttr);
      99           0 :                 break;
     100             : 
     101             :             case XML_TOK_SECTION_TEXT_SECTION_NAME:
     102           0 :                 sSectionName = xAttrList->getValueByIndex(nAttr);
     103           0 :                 break;
     104             : 
     105             :             default:
     106             :                 ; // ignore
     107           0 :                 break;
     108             :         }
     109           0 :     }
     110             : 
     111             :     // we only need them once
     112           0 :     const OUString sFileLink("FileLink");
     113           0 :     const OUString sLinkRegion("LinkRegion");
     114             : 
     115           0 :     Any aAny;
     116           0 :     if (!sURL.isEmpty() || !sFilterName.isEmpty())
     117             :     {
     118           0 :         SectionFileLink aFileLink;
     119           0 :         aFileLink.FileURL = GetImport().GetAbsoluteReference( sURL );
     120           0 :         aFileLink.FilterName = sFilterName;
     121             : 
     122           0 :         aAny <<= aFileLink;
     123           0 :         rSectionPropertySet->setPropertyValue(sFileLink, aAny);
     124             :     }
     125             : 
     126           0 :     if (!sSectionName.isEmpty())
     127             :     {
     128           0 :         aAny <<= sSectionName;
     129           0 :         rSectionPropertySet->setPropertyValue(sLinkRegion, aAny);
     130           0 :     }
     131           0 : }
     132             : 
     133           0 : void XMLSectionSourceImportContext::EndElement()
     134             : {
     135             :     // this space intentionally left blank.
     136           0 : }
     137             : 
     138           0 : SvXMLImportContext* XMLSectionSourceImportContext::CreateChildContext(
     139             :     sal_uInt16 nPrefix,
     140             :     const OUString& rLocalName,
     141             :     const Reference<XAttributeList> & )
     142             : {
     143             :     // ignore -> default context
     144           0 :     return new SvXMLImportContext(GetImport(), nPrefix, rLocalName);
     145             : }
     146             : 
     147             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10