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