1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "svgfilter.hxx"
22 #include "svgreader.hxx"
24 #include "rtl/ref.hxx"
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28 #include <com/sun/star/lang/XComponent.hpp>
30 #include <com/sun/star/uno/Any.hxx>
31 #include <com/sun/star/uno/Type.hxx>
33 #include <com/sun/star/beans/PropertyValue.hpp>
35 #include <com/sun/star/xml/sax/XParser.hpp>
36 #include <com/sun/star/xml/sax/InputSource.hpp>
37 #include <com/sun/star/xml/XImportFilter.hpp>
39 #include <com/sun/star/io/XActiveDataSource.hpp>
40 #include <com/sun/star/task/XStatusIndicator.hpp>
42 using namespace ::com::sun::star
;
43 using namespace ::svgi
;
45 sal_Bool
SVGFilter::implImport( const Sequence
< PropertyValue
>& rDescriptor
)
46 throw (RuntimeException
)
48 uno::Reference
< io::XInputStream
> xInputStream
;
49 uno::Reference
< task::XStatusIndicator
> xStatus
;
50 const sal_Int32 nLength
= rDescriptor
.getLength();
51 const beans::PropertyValue
* pAttribs
= rDescriptor
.getConstArray();
52 for ( sal_Int32 i
=0 ; i
<nLength
; ++i
, ++pAttribs
)
54 if ( pAttribs
->Name
== "InputStream" )
56 pAttribs
->Value
>>= xInputStream
;
58 else if ( pAttribs
->Name
== "StatusIndicator" )
59 pAttribs
->Value
>>= xStatus
;
62 OSL_ASSERT(xInputStream
.is());
63 if(!xInputStream
.is())
66 OUString
sXMLImportService ( "com.sun.star.comp.Draw.XMLOasisImporter" );
67 Reference
< XDocumentHandler
> xInternalHandler( mxContext
->getServiceManager()->createInstanceWithContext( sXMLImportService
, mxContext
), UNO_QUERY
);
69 // The XImporter sets up an empty target document for XDocumentHandler to write to..
70 uno::Reference
< XImporter
> xImporter(xInternalHandler
, UNO_QUERY
);
71 xImporter
->setTargetDocument(mxDstDoc
);
73 SVGReader
aReader(uno::Reference
<lang::XMultiServiceFactory
>(mxContext
->getServiceManager(), uno::UNO_QUERY_THROW
), xInputStream
, xInternalHandler
);
74 return aReader
.parseAndConvert();
78 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */