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 "svgfilter.hxx"
22 : #include "svgreader.hxx"
23 :
24 : #include "rtl/ref.hxx"
25 :
26 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 :
28 : #include <com/sun/star/lang/XComponent.hpp>
29 :
30 : #include <com/sun/star/uno/Any.hxx>
31 : #include <com/sun/star/uno/Type.hxx>
32 :
33 : #include <com/sun/star/beans/PropertyValue.hpp>
34 :
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>
38 :
39 : #include <com/sun/star/io/XActiveDataSource.hpp>
40 : #include <com/sun/star/task/XStatusIndicator.hpp>
41 :
42 : using namespace ::com::sun::star;
43 : using namespace ::svgi;
44 :
45 0 : sal_Bool SVGFilter::implImport( const Sequence< PropertyValue >& rDescriptor )
46 : throw (RuntimeException)
47 : {
48 0 : uno::Reference< io::XInputStream > xInputStream;
49 0 : uno::Reference< task::XStatusIndicator > xStatus;
50 0 : const sal_Int32 nLength = rDescriptor.getLength();
51 0 : const beans::PropertyValue* pAttribs = rDescriptor.getConstArray();
52 0 : for ( sal_Int32 i=0 ; i<nLength; ++i, ++pAttribs )
53 : {
54 0 : if ( pAttribs->Name == "InputStream" )
55 : {
56 0 : pAttribs->Value >>= xInputStream;
57 : }
58 0 : else if ( pAttribs->Name == "StatusIndicator" )
59 0 : pAttribs->Value >>= xStatus;
60 : }
61 :
62 : OSL_ASSERT(xInputStream.is());
63 0 : if(!xInputStream.is())
64 0 : return sal_False;
65 :
66 0 : rtl::OUString sXMLImportService ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.XMLOasisImporter" ) );
67 0 : Reference < XDocumentHandler > xInternalHandler( mxContext->getServiceManager()->createInstanceWithContext( sXMLImportService, mxContext ), UNO_QUERY );
68 :
69 : // The XImporter sets up an empty target document for XDocumentHandler to write to..
70 0 : uno::Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY);
71 0 : xImporter->setTargetDocument(mxDstDoc);
72 :
73 0 : SVGReader aReader(uno::Reference<lang::XMultiServiceFactory>(mxContext->getServiceManager(), uno::UNO_QUERY_THROW), xInputStream, xInternalHandler);
74 0 : return aReader.parseAndConvert();
75 0 : }
76 :
77 :
78 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|