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 0 : XMLMetaImportComponent::XMLMetaImportComponent(
33 : const uno::Reference< uno::XComponentContext >& xContext) throw()
34 0 : : SvXMLImport(xContext, ""), mxDocProps()
35 : {
36 0 : }
37 :
38 0 : XMLMetaImportComponent::~XMLMetaImportComponent() throw()
39 : {
40 0 : }
41 :
42 0 : SvXMLImportContext* XMLMetaImportComponent::CreateContext(
43 : sal_uInt16 nPrefix,
44 : const OUString& rLocalName,
45 : const uno::Reference<xml::sax::XAttributeList > & xAttrList )
46 : {
47 0 : if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
48 0 : IsXMLToken(rLocalName, XML_DOCUMENT_META) )
49 : {
50 0 : 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 0 : *this, nPrefix, rLocalName, mxDocProps);
57 : }
58 : else
59 : {
60 0 : return SvXMLImport::CreateContext(nPrefix, rLocalName, xAttrList);
61 : }
62 : }
63 :
64 0 : void SAL_CALL XMLMetaImportComponent::setTargetDocument(
65 : const uno::Reference< lang::XComponent >& xDoc )
66 : throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
67 : {
68 0 : mxDocProps = uno::Reference< document::XDocumentProperties >::query( xDoc );
69 0 : if( !mxDocProps.is() )
70 : throw lang::IllegalArgumentException(OUString(
71 : "XMLMetaImportComponent::setTargetDocument: argument is no "
72 0 : "XDocumentProperties"), uno::Reference<uno::XInterface>(*this), 0);
73 0 : }
74 :
75 : uno::Sequence< OUString > SAL_CALL
76 0 : XMLMetaImportComponent_getSupportedServiceNames()
77 : throw()
78 : {
79 0 : const OUString aServiceName( "com.sun.star.document.XMLOasisMetaImporter" );
80 0 : const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
81 0 : return aSeq;
82 : }
83 :
84 0 : OUString SAL_CALL XMLMetaImportComponent_getImplementationName() throw()
85 : {
86 0 : return OUString( "XMLMetaImportComponent" );
87 : }
88 :
89 0 : uno::Reference< uno::XInterface > SAL_CALL XMLMetaImportComponent_createInstance(
90 : const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
91 : throw( uno::Exception )
92 : {
93 : // #110680#
94 0 : return (cppu::OWeakObject*)new XMLMetaImportComponent( comphelper::getComponentContext(rSMgr));
95 : }
96 :
97 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|