LCOV - code coverage report
Current view: top level - xmloff/source/meta - MetaImportComponent.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 26 28 92.9 %
Date: 2012-08-25 Functions: 8 8 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 16 44 36.4 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "MetaImportComponent.hxx"
      31                 :            : #include "xmloff/xmlnmspe.hxx"
      32                 :            : 
      33                 :            : #include <xmloff/xmltoken.hxx>
      34                 :            : #include <xmloff/xmlmetai.hxx>
      35                 :            : #include <xmloff/nmspmap.hxx>
      36                 :            : 
      37                 :            : 
      38                 :            : using namespace ::com::sun::star;
      39                 :            : using namespace ::xmloff::token;
      40                 :            : 
      41                 :            : 
      42                 :            : //===========================================================================
      43                 :            : 
      44                 :            : // #110680#
      45                 :         28 : XMLMetaImportComponent::XMLMetaImportComponent(
      46                 :            :     const uno::Reference< lang::XMultiServiceFactory >& xServiceFactory) throw()
      47                 :         28 :     :   SvXMLImport(xServiceFactory), mxDocProps()
      48                 :            : {
      49                 :         28 : }
      50                 :            : 
      51                 :         28 : XMLMetaImportComponent::~XMLMetaImportComponent() throw()
      52                 :            : {
      53         [ -  + ]:         56 : }
      54                 :            : 
      55                 :            : 
      56                 :         28 : SvXMLImportContext* XMLMetaImportComponent::CreateContext(
      57                 :            :     sal_uInt16 nPrefix,
      58                 :            :     const rtl::OUString& rLocalName,
      59                 :            :     const uno::Reference<xml::sax::XAttributeList > & xAttrList )
      60                 :            : {
      61   [ +  -  +  - ]:         56 :     if (  (XML_NAMESPACE_OFFICE == nPrefix) &&
                 [ +  - ]
      62                 :         28 :          IsXMLToken(rLocalName, XML_DOCUMENT_META) )
      63                 :            :     {
      64         [ -  + ]:         28 :         if (!mxDocProps.is()) {
      65                 :            :             throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
      66                 :            :                 "XMLMetaImportComponent::CreateContext: setTargetDocument "
      67 [ #  # ][ #  # ]:          0 :                 "has not been called")), *this);
                 [ #  # ]
      68                 :            :         }
      69                 :            :         uno::Reference<xml::sax::XDocumentHandler> xDocBuilder(
      70         [ +  - ]:         28 :             mxServiceFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
      71                 :         28 :                     "com.sun.star.xml.dom.SAXDocumentBuilder"))),
      72 [ +  - ][ +  - ]:         28 :                  uno::UNO_QUERY_THROW);
                 [ +  - ]
      73                 :            :         return new SvXMLMetaDocumentContext(
      74 [ +  - ][ +  - ]:         28 :                         *this, nPrefix, rLocalName, mxDocProps, xDocBuilder);
                 [ +  - ]
      75                 :            :     }
      76                 :            :     else
      77                 :            :     {
      78                 :         28 :         return SvXMLImport::CreateContext(nPrefix, rLocalName, xAttrList);
      79                 :            :     }
      80                 :            : }
      81                 :            : 
      82                 :         28 : void SAL_CALL XMLMetaImportComponent::setTargetDocument(
      83                 :            :     const uno::Reference< lang::XComponent >& xDoc )
      84                 :            :     throw(lang::IllegalArgumentException, uno::RuntimeException)
      85                 :            : {
      86         [ +  - ]:         28 :     mxDocProps = uno::Reference< document::XDocumentProperties >::query( xDoc );
      87         [ -  + ]:         28 :     if( !mxDocProps.is() )
      88                 :            :         throw lang::IllegalArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
      89                 :            :             "XMLMetaImportComponent::setTargetDocument: argument is no "
      90 [ #  # ][ #  # ]:          0 :             "XDocumentProperties")), uno::Reference<uno::XInterface>(*this), 0);
                 [ #  # ]
      91                 :         28 : }
      92                 :            : 
      93                 :            : uno::Sequence< rtl::OUString > SAL_CALL
      94                 :          4 :     XMLMetaImportComponent_getSupportedServiceNames()
      95                 :            :         throw()
      96                 :            : {
      97                 :            :     const rtl::OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM(
      98         [ +  - ]:          4 :         "com.sun.star.document.XMLOasisMetaImporter" ) );
      99         [ +  - ]:          4 :     const uno::Sequence< rtl::OUString > aSeq( &aServiceName, 1 );
     100                 :          4 :     return aSeq;
     101                 :            : }
     102                 :            : 
     103                 :         38 : rtl::OUString SAL_CALL XMLMetaImportComponent_getImplementationName() throw()
     104                 :            : {
     105                 :         38 :     return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XMLMetaImportComponent" ) );
     106                 :            : }
     107                 :            : 
     108                 :         28 : uno::Reference< uno::XInterface > SAL_CALL XMLMetaImportComponent_createInstance(
     109                 :            :         const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
     110                 :            :     throw( uno::Exception )
     111                 :            : {
     112                 :            :     // #110680#
     113                 :         28 :     return (cppu::OWeakObject*)new XMLMetaImportComponent(rSMgr);
     114                 :            : }
     115                 :            : 
     116                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10