bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / meta / MetaImportComponent.cxx
blob0e271094a778cf77c0f080f056b3dd877d39181b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "MetaImportComponent.hxx"
21 #include <xmloff/xmlnmspe.hxx>
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>
29 using namespace ::com::sun::star;
30 using namespace ::xmloff::token;
32 // #110680#
33 XMLMetaImportComponent::XMLMetaImportComponent(
34 const uno::Reference< uno::XComponentContext >& xContext) throw()
35 : SvXMLImport(xContext, ""), mxDocProps()
39 XMLMetaImportComponent::~XMLMetaImportComponent() throw()
43 SvXMLImportContext* XMLMetaImportComponent::CreateContext(
44 sal_uInt16 nPrefix,
45 const OUString& rLocalName,
46 const uno::Reference<xml::sax::XAttributeList > & xAttrList )
48 if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
49 IsXMLToken(rLocalName, XML_DOCUMENT_META) )
51 if (!mxDocProps.is()) {
52 throw uno::RuntimeException(OUString(
53 "XMLMetaImportComponent::CreateContext: setTargetDocument "
54 "has not been called"), *this);
56 return new SvXMLMetaDocumentContext(
57 *this, nPrefix, rLocalName, mxDocProps);
59 else
61 return SvXMLImport::CreateContext(nPrefix, rLocalName, xAttrList);
65 void SAL_CALL XMLMetaImportComponent::setTargetDocument(
66 const uno::Reference< lang::XComponent >& xDoc )
67 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
69 mxDocProps = uno::Reference< document::XDocumentProperties >::query( xDoc );
70 if( !mxDocProps.is() )
71 throw lang::IllegalArgumentException(OUString(
72 "XMLMetaImportComponent::setTargetDocument: argument is no "
73 "XDocumentProperties"), uno::Reference<uno::XInterface>(*this), 0);
76 uno::Sequence< OUString > SAL_CALL
77 XMLMetaImportComponent_getSupportedServiceNames()
78 throw()
80 const OUString aServiceName( "com.sun.star.document.XMLOasisMetaImporter" );
81 const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
82 return aSeq;
85 OUString SAL_CALL XMLMetaImportComponent_getImplementationName() throw()
87 return OUString( "XMLMetaImportComponent" );
90 uno::Reference< uno::XInterface > SAL_CALL XMLMetaImportComponent_createInstance(
91 const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
92 throw( uno::Exception )
94 // #110680#
95 return (cppu::OWeakObject*)new XMLMetaImportComponent( comphelper::getComponentContext(rSMgr));
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */