LCOV - code coverage report
Current view: top level - xmloff/source/script - XMLScriptContextFactory.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 23 23 100.0 %
Date: 2014-11-03 Functions: 4 4 100.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 "XMLScriptContextFactory.hxx"
      21             : #include <xmloff/XMLEventsImportContext.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 namespace ::xmloff::token;
      29             : 
      30             : using ::com::sun::star::xml::sax::XAttributeList;
      31             : using ::com::sun::star::beans::PropertyValue;
      32             : using ::com::sun::star::uno::Reference;
      33             : using ::com::sun::star::uno::Sequence;
      34             : using ::com::sun::star::uno::Any;
      35             : 
      36          24 : XMLScriptContextFactory::XMLScriptContextFactory() :
      37             :     sEventType("EventType"),
      38             :     sScript("Script"),
      39          24 :     sURL("Script")
      40             : {
      41          24 : }
      42             : 
      43          48 : XMLScriptContextFactory::~XMLScriptContextFactory()
      44             : {
      45          48 : }
      46             : 
      47          16 : SvXMLImportContext * XMLScriptContextFactory::CreateContext
      48             : (SvXMLImport & rImport,
      49             :  sal_uInt16 p_nPrefix,
      50             :  const OUString & rLocalName,
      51             :  const Reference<XAttributeList> & xAttrList,
      52             :  XMLEventsImportContext * rEvents,
      53             :  const OUString & rApiEventName,
      54             :  const OUString & /*rApiLanguage*/)
      55             : {
      56          16 :     OUString sURLVal;
      57             : 
      58          16 :     sal_Int16 nCount = xAttrList->getLength();
      59          80 :     for (sal_Int16 nAttr = 0; nAttr < nCount; nAttr++)
      60             :     {
      61          64 :         OUString sLocalName;
      62          64 :         sal_uInt16 nPrefix = rImport.GetNamespaceMap().
      63         128 :             GetKeyByAttrName(xAttrList->getNameByIndex(nAttr), &sLocalName);
      64             : 
      65          64 :         if (XML_NAMESPACE_XLINK == nPrefix)
      66             :         {
      67          32 :             if (IsXMLToken(sLocalName, XML_HREF))
      68          16 :                 sURLVal = xAttrList->getValueByIndex(nAttr);
      69             :             // else: ignore
      70             :         }
      71             :         // else ignore
      72          64 :     }
      73             : 
      74          32 :     Sequence<PropertyValue> aValues(2);
      75             : 
      76             :     // EventType
      77          16 :     aValues[0].Name = sEventType;
      78          16 :     aValues[0].Value <<= sScript;
      79             : 
      80             :     // URL
      81          16 :     aValues[1].Name = sURL;
      82          16 :     aValues[1].Value <<= sURLVal;
      83             : 
      84             :     // add values for event now
      85          16 :     rEvents->AddEventValues(rApiEventName, aValues);
      86             : 
      87             :     // return dummy context
      88          32 :     return new SvXMLImportContext(rImport, p_nPrefix, rLocalName);
      89             : }
      90             : 
      91             : 
      92             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10