1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svgimport.cxx,v $
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_filter.hxx"
34 #include "svgfilter.hxx"
35 #include "svgreader.hxx"
37 #include "rtl/ref.hxx"
39 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
41 #include <com/sun/star/lang/XComponent.hpp>
43 #include <com/sun/star/uno/Any.hxx>
44 #include <com/sun/star/uno/Type.hxx>
46 #include <com/sun/star/beans/PropertyValue.hpp>
48 #include <com/sun/star/xml/sax/XParser.hpp>
49 #include <com/sun/star/xml/sax/InputSource.hpp>
50 #include <com/sun/star/xml/XImportFilter.hpp>
52 #include <com/sun/star/io/XActiveDataSource.hpp>
53 #include <com/sun/star/task/XStatusIndicator.hpp>
55 using namespace ::com::sun::star
;
56 using namespace ::svgi
;
58 sal_Bool
SVGFilter::implImport( const Sequence
< PropertyValue
>& rDescriptor
)
59 throw (RuntimeException
)
62 uno::Reference
< io::XInputStream
> xInputStream
;
63 uno::Reference
< task::XStatusIndicator
> xStatus
;
64 const sal_Int32 nLength
= rDescriptor
.getLength();
65 const beans::PropertyValue
* pAttribs
= rDescriptor
.getConstArray();
66 for ( sal_Int32 i
=0 ; i
<nLength
; ++i
, ++pAttribs
)
68 if( pAttribs
->Name
.equalsAscii( "InputStream" ) )
70 pAttribs
->Value
>>= xInputStream
;
72 else if( pAttribs
->Name
.equalsAscii( "StatusIndicator" ) )
73 pAttribs
->Value
>>= xStatus
;
76 OSL_ASSERT(xInputStream
.is());
77 if(!xInputStream
.is())
80 rtl::OUString
sXMLImportService ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.XMLOasisImporter" ) );
81 Reference
< XDocumentHandler
> xInternalHandler( mxMSF
->createInstance( sXMLImportService
), UNO_QUERY
);
83 // The XImporter sets up an empty target document for XDocumentHandler to write to..
84 uno::Reference
< XImporter
> xImporter(xInternalHandler
, UNO_QUERY
);
85 xImporter
->setTargetDocument(mxDstDoc
);
87 SVGReader
aReader(mxMSF
, xInputStream
, xInternalHandler
);
88 return aReader
.parseAndConvert();