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