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

Generated by: LCOV version 1.10