LCOV - code coverage report
Current view: top level - xmloff/source/meta - MetaImportComponent.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 22 25 88.0 %
Date: 2015-06-13 12:38:46 Functions: 8 8 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 "MetaImportComponent.hxx"
      21             : #include <xmloff/xmlnmspe.hxx>
      22             : 
      23             : #include <xmloff/xmltoken.hxx>
      24             : #include <xmloff/xmlmetai.hxx>
      25             : #include <xmloff/nmspmap.hxx>
      26             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      27             : #include <comphelper/processfactory.hxx>
      28             : 
      29             : using namespace ::com::sun::star;
      30             : using namespace ::xmloff::token;
      31             : 
      32             : // #110680#
      33           4 : XMLMetaImportComponent::XMLMetaImportComponent(
      34             :     const uno::Reference< uno::XComponentContext >& xContext) throw()
      35           4 :     :   SvXMLImport(xContext, ""), mxDocProps()
      36             : {
      37           4 : }
      38             : 
      39           8 : XMLMetaImportComponent::~XMLMetaImportComponent() throw()
      40             : {
      41           8 : }
      42             : 
      43           4 : SvXMLImportContext* XMLMetaImportComponent::CreateContext(
      44             :     sal_uInt16 nPrefix,
      45             :     const OUString& rLocalName,
      46             :     const uno::Reference<xml::sax::XAttributeList > & xAttrList )
      47             : {
      48           8 :     if (  (XML_NAMESPACE_OFFICE == nPrefix) &&
      49           4 :          IsXMLToken(rLocalName, XML_DOCUMENT_META) )
      50             :     {
      51           4 :         if (!mxDocProps.is()) {
      52             :             throw uno::RuntimeException(OUString(
      53             :                 "XMLMetaImportComponent::CreateContext: setTargetDocument "
      54           0 :                 "has not been called"), *this);
      55             :         }
      56             :         return new SvXMLMetaDocumentContext(
      57           4 :                         *this, nPrefix, rLocalName, mxDocProps);
      58             :     }
      59             :     else
      60             :     {
      61           0 :         return SvXMLImport::CreateContext(nPrefix, rLocalName, xAttrList);
      62             :     }
      63             : }
      64             : 
      65           4 : void SAL_CALL XMLMetaImportComponent::setTargetDocument(
      66             :     const uno::Reference< lang::XComponent >& xDoc )
      67             :     throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
      68             : {
      69           4 :     mxDocProps = uno::Reference< document::XDocumentProperties >::query( xDoc );
      70           4 :     if( !mxDocProps.is() )
      71             :         throw lang::IllegalArgumentException(OUString(
      72             :             "XMLMetaImportComponent::setTargetDocument: argument is no "
      73           0 :             "XDocumentProperties"), uno::Reference<uno::XInterface>(*this), 0);
      74           4 : }
      75             : 
      76             : uno::Sequence< OUString > SAL_CALL
      77           1 :     XMLMetaImportComponent_getSupportedServiceNames()
      78             :         throw()
      79             : {
      80           1 :     const OUString aServiceName( "com.sun.star.document.XMLOasisMetaImporter" );
      81           1 :     const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
      82           1 :     return aSeq;
      83             : }
      84             : 
      85           2 : OUString SAL_CALL XMLMetaImportComponent_getImplementationName() throw()
      86             : {
      87           2 :     return OUString( "XMLMetaImportComponent" );
      88             : }
      89             : 
      90           4 : uno::Reference< uno::XInterface > SAL_CALL XMLMetaImportComponent_createInstance(
      91             :         const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
      92             :     throw( uno::Exception )
      93             : {
      94             :     // #110680#
      95           4 :     return static_cast<cppu::OWeakObject*>(new XMLMetaImportComponent( comphelper::getComponentContext(rSMgr)));
      96             : }
      97             : 
      98             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11