bump product version to 4.1.6.2
[LibreOffice.git] / xmloff / source / meta / MetaImportComponent.cxx
blob07bf460122be450a1bdcb7b3e0f46e48aaa1bb18
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 .
21 #include "MetaImportComponent.hxx"
22 #include "xmloff/xmlnmspe.hxx"
24 #include <xmloff/xmltoken.hxx>
25 #include <xmloff/xmlmetai.hxx>
26 #include <xmloff/nmspmap.hxx>
27 #include <comphelper/processfactory.hxx>
29 using namespace ::com::sun::star;
30 using namespace ::xmloff::token;
33 //===========================================================================
35 // #110680#
36 XMLMetaImportComponent::XMLMetaImportComponent(
37 const uno::Reference< uno::XComponentContext >& xContext) throw()
38 : SvXMLImport(xContext), mxDocProps()
42 XMLMetaImportComponent::~XMLMetaImportComponent() throw()
47 SvXMLImportContext* XMLMetaImportComponent::CreateContext(
48 sal_uInt16 nPrefix,
49 const OUString& rLocalName,
50 const uno::Reference<xml::sax::XAttributeList > & xAttrList )
52 if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
53 IsXMLToken(rLocalName, XML_DOCUMENT_META) )
55 if (!mxDocProps.is()) {
56 throw uno::RuntimeException(OUString(
57 "XMLMetaImportComponent::CreateContext: setTargetDocument "
58 "has not been called"), *this);
60 return new SvXMLMetaDocumentContext(
61 *this, nPrefix, rLocalName, mxDocProps);
63 else
65 return SvXMLImport::CreateContext(nPrefix, rLocalName, xAttrList);
69 void SAL_CALL XMLMetaImportComponent::setTargetDocument(
70 const uno::Reference< lang::XComponent >& xDoc )
71 throw(lang::IllegalArgumentException, uno::RuntimeException)
73 mxDocProps = uno::Reference< document::XDocumentProperties >::query( xDoc );
74 if( !mxDocProps.is() )
75 throw lang::IllegalArgumentException(OUString(
76 "XMLMetaImportComponent::setTargetDocument: argument is no "
77 "XDocumentProperties"), uno::Reference<uno::XInterface>(*this), 0);
80 uno::Sequence< OUString > SAL_CALL
81 XMLMetaImportComponent_getSupportedServiceNames()
82 throw()
84 const OUString aServiceName( "com.sun.star.document.XMLOasisMetaImporter" );
85 const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
86 return aSeq;
89 OUString SAL_CALL XMLMetaImportComponent_getImplementationName() throw()
91 return OUString( "XMLMetaImportComponent" );
94 uno::Reference< uno::XInterface > SAL_CALL XMLMetaImportComponent_createInstance(
95 const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
96 throw( uno::Exception )
98 // #110680#
99 return (cppu::OWeakObject*)new XMLMetaImportComponent( comphelper::getComponentContext(rSMgr));
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */