Update ooo320-m1
[ooovba.git] / xmloff / source / meta / MetaImportComponent.cxx
blobf371054f6f519f2a94db788f265af7256d37b964
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MetaImportComponent.cxx,v $
10 * $Revision: 1.14 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
34 #include "MetaImportComponent.hxx"
35 #include "xmlnmspe.hxx"
37 #include <xmloff/xmltoken.hxx>
38 #include <xmloff/xmlmetai.hxx>
39 #include <xmloff/nmspmap.hxx>
40 #include <tools/string.hxx>
43 using namespace ::com::sun::star;
44 using namespace ::xmloff::token;
47 //===========================================================================
49 // #110680#
50 XMLMetaImportComponent::XMLMetaImportComponent(
51 const uno::Reference< lang::XMultiServiceFactory >& xServiceFactory) throw()
52 : SvXMLImport(xServiceFactory), mxDocProps()
56 XMLMetaImportComponent::~XMLMetaImportComponent() throw()
61 SvXMLImportContext* XMLMetaImportComponent::CreateContext(
62 sal_uInt16 nPrefix,
63 const rtl::OUString& rLocalName,
64 const uno::Reference<xml::sax::XAttributeList > & xAttrList )
66 if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
67 IsXMLToken(rLocalName, XML_DOCUMENT_META) )
69 if (!mxDocProps.is()) {
70 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
71 "XMLMetaImportComponent::CreateContext: setTargetDocument "
72 "has not been called"), *this);
74 uno::Reference<xml::sax::XDocumentHandler> xDocBuilder(
75 mxServiceFactory->createInstance(::rtl::OUString::createFromAscii(
76 "com.sun.star.xml.dom.SAXDocumentBuilder")),
77 uno::UNO_QUERY_THROW);
78 return new SvXMLMetaDocumentContext(
79 *this, nPrefix, rLocalName, mxDocProps, xDocBuilder);
81 else
83 return SvXMLImport::CreateContext(nPrefix, rLocalName, xAttrList);
87 void SAL_CALL XMLMetaImportComponent::setTargetDocument(
88 const uno::Reference< lang::XComponent >& xDoc )
89 throw(lang::IllegalArgumentException, uno::RuntimeException)
91 mxDocProps = uno::Reference< document::XDocumentProperties >::query( xDoc );
92 if( !mxDocProps.is() )
93 throw lang::IllegalArgumentException(::rtl::OUString::createFromAscii(
94 "XMLMetaImportComponent::setTargetDocument: argument is no "
95 "XDocumentProperties"), uno::Reference<uno::XInterface>(*this), 0);
98 uno::Sequence< rtl::OUString > SAL_CALL
99 XMLMetaImportComponent_getSupportedServiceNames()
100 throw()
102 const rtl::OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM(
103 "com.sun.star.document.XMLOasisMetaImporter" ) );
104 const uno::Sequence< rtl::OUString > aSeq( &aServiceName, 1 );
105 return aSeq;
108 rtl::OUString SAL_CALL XMLMetaImportComponent_getImplementationName() throw()
110 return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XMLMetaImportComponent" ) );
113 uno::Reference< uno::XInterface > SAL_CALL XMLMetaImportComponent_createInstance(
114 const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
115 throw( uno::Exception )
117 // #110680#
118 // return (cppu::OWeakObject*)new XMLMetaImportComponent;
119 return (cppu::OWeakObject*)new XMLMetaImportComponent(rSMgr);