LCOV - code coverage report
Current view: top level - xmloff/source/script - XMLScriptContextFactory.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 23 23 100.0 %
Date: 2012-08-25 Functions: 4 4 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 25 46 54.3 %

           Branch data     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 ::rtl::OUString;
      31                 :            : using ::com::sun::star::xml::sax::XAttributeList;
      32                 :            : using ::com::sun::star::beans::PropertyValue;
      33                 :            : using ::com::sun::star::uno::Reference;
      34                 :            : using ::com::sun::star::uno::Sequence;
      35                 :            : using ::com::sun::star::uno::Any;
      36                 :            : 
      37                 :         12 : XMLScriptContextFactory::XMLScriptContextFactory() :
      38                 :            :     sEventType("EventType"),
      39                 :            :     sScript("Script"),
      40                 :         12 :     sURL("Script")
      41                 :            : {
      42                 :         12 : }
      43                 :            : 
      44                 :         12 : XMLScriptContextFactory::~XMLScriptContextFactory()
      45                 :            : {
      46         [ -  + ]:         24 : }
      47                 :            : 
      48                 :          8 : SvXMLImportContext * XMLScriptContextFactory::CreateContext
      49                 :            : (SvXMLImport & rImport,
      50                 :            :  sal_uInt16 p_nPrefix,
      51                 :            :  const OUString & rLocalName,
      52                 :            :  const Reference<XAttributeList> & xAttrList,
      53                 :            :  XMLEventsImportContext * rEvents,
      54                 :            :  const OUString & rApiEventName,
      55                 :            :  const OUString & /*rApiLanguage*/)
      56                 :            : {
      57                 :          8 :     OUString sURLVal;
      58                 :            : 
      59 [ +  - ][ +  - ]:          8 :     sal_Int16 nCount = xAttrList->getLength();
      60         [ +  + ]:         32 :     for (sal_Int16 nAttr = 0; nAttr < nCount; nAttr++)
      61                 :            :     {
      62                 :         24 :         OUString sLocalName;
      63                 :         24 :         sal_uInt16 nPrefix = rImport.GetNamespaceMap().
      64   [ +  -  +  - ]:         48 :             GetKeyByAttrName(xAttrList->getNameByIndex(nAttr), &sLocalName);
                 [ +  - ]
      65                 :            : 
      66         [ +  + ]:         24 :         if (XML_NAMESPACE_XLINK == nPrefix)
      67                 :            :         {
      68 [ +  - ][ +  - ]:          8 :             if (IsXMLToken(sLocalName, XML_HREF))
      69 [ +  - ][ +  - ]:          8 :                 sURLVal = xAttrList->getValueByIndex(nAttr);
      70                 :            :             // else: ignore
      71                 :            :         }
      72                 :            :         // else ignore
      73                 :         24 :     }
      74                 :            : 
      75         [ +  - ]:          8 :     Sequence<PropertyValue> aValues(2);
      76                 :            : 
      77                 :            :     // EventType
      78         [ +  - ]:          8 :     aValues[0].Name = sEventType;
      79 [ +  - ][ +  - ]:          8 :     aValues[0].Value <<= sScript;
      80                 :            : 
      81                 :            :     // URL
      82         [ +  - ]:          8 :     aValues[1].Name = sURL;
      83 [ +  - ][ +  - ]:          8 :     aValues[1].Value <<= sURLVal;
      84                 :            : 
      85                 :            :     // add values for event now
      86         [ +  - ]:          8 :     rEvents->AddEventValues(rApiEventName, aValues);
      87                 :            : 
      88                 :            :     // return dummy context
      89 [ +  - ][ +  - ]:          8 :     return new SvXMLImportContext(rImport, p_nPrefix, rLocalName);
                 [ +  - ]
      90                 :            : }
      91                 :            : 
      92                 :            : 
      93                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10