Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "pptimporter.hxx"
30 : :
31 : : #ifdef DBG_DUMP_PPT_IMPORT
32 : : #include <com/sun/star/io/XActiveDataSource.hpp>
33 : : #include <unotools/streamwrap.hxx>
34 : : #include <comphelper/processfactory.hxx>
35 : : #endif
36 : :
37 : : #include <uno/mapping.hxx>
38 : :
39 : 0 : NMSP_RTL::OUString PptImporter_getImplementationName()
40 : : throw( NMSP_UNO::RuntimeException )
41 : : {
42 : 0 : return B2UCONST( "com.sun.star.presentation.PptImporter" );
43 : : }
44 : : #define SERVICE_NAME "com.sun.star.document.ImportFilter"
45 : 0 : sal_Bool SAL_CALL PptImporter_supportsService( const NMSP_RTL::OUString& ServiceName )
46 : : throw( NMSP_UNO::RuntimeException )
47 : : {
48 : 0 : return ServiceName == SERVICE_NAME;
49 : : }
50 : :
51 : 0 : SEQ( NMSP_RTL::OUString ) SAL_CALL PptImporter_getSupportedServiceNames()
52 : : throw( NMSP_UNO::RuntimeException )
53 : : {
54 : 0 : SEQ( NMSP_RTL::OUString ) aRet(1);
55 : 0 : NMSP_RTL::OUString* pArray = aRet.getArray();
56 : 0 : pArray[0] = B2UCONST( SERVICE_NAME );
57 : 0 : return aRet;
58 : : }
59 : : #undef SERVICE_NAME
60 : :
61 : 0 : PptImporter::PptImporter( const REF( NMSP_LANG::XMultiServiceFactory )& rxMgr ) :
62 : 0 : xFact( rxMgr )
63 : : {
64 : 0 : NMSP_RTL::OUString sService( B2UCONST( "com.sun.star.comp.Impress.XMLImporter" ) );
65 : : try
66 : : {
67 : 0 : xHdl = REF( NMSP_SAX::XDocumentHandler ) ( xFact->createInstance( sService ), NMSP_UNO::UNO_QUERY );
68 : 0 : xImporter = REF( NMSP_DOCUMENT::XImporter )( xHdl, NMSP_UNO::UNO_QUERY );
69 : : }
70 : 0 : catch( const NMSP_UNO::Exception & )
71 : : {
72 : 0 : }
73 : 0 : }
74 : :
75 : 0 : PptImporter::~PptImporter()
76 : : {
77 : 0 : }
78 : :
79 : 0 : void SAL_CALL PptImporter::acquire() throw()
80 : : {
81 : 0 : OWeakObject::acquire();
82 : 0 : }
83 : :
84 : 0 : void SAL_CALL PptImporter::release() throw()
85 : : {
86 : 0 : OWeakObject::release();
87 : 0 : }
88 : :
89 : : // XFilter
90 : 0 : sal_Bool SAL_CALL PptImporter::filter( const SEQ( NMSP_BEANS::PropertyValue )& aDescriptor )
91 : : throw ( NMSP_UNO::RuntimeException )
92 : : {
93 : :
94 : :
95 : : #ifdef DBG_DUMP_PPT_IMPORT
96 : :
97 : : REF( NMSP_LANG::XMultiServiceFactory ) xServiceFactory( NMSP_COMPHELPER::getProcessServiceFactory() );
98 : : REF( NMSP_UNO::XInterface ) xWriter( xServiceFactory->createInstance( B2UCONST( "com.sun.star.xml.sax.Writer" ) ) );
99 : : SvFileStream aStrm( B2UCONST( "d:\\test2.xml" ), STREAM_READ | STREAM_WRITE | STREAM_TRUNC );
100 : : REF( NMSP_IO::XOutputStream ) xOutStream( (::cppu::OWeakObject*) new NMSP_UTL::OOutputStreamWrapper( aStrm ), NMSP_UNO::UNO_QUERY );
101 : : REF( NMSP_IO::XActiveDataSource ) xDataSource( xWriter , NMSP_UNO::UNO_QUERY );
102 : : xDataSource->setOutputStream( xOutStream );
103 : : aFilter.filter( aDescriptor, REF( NMSP_SAX::XDocumentHandler )( xWriter, NMSP_UNO::UNO_QUERY ) );
104 : :
105 : : #endif
106 : :
107 : 0 : return aFilter.filter( aDescriptor, xHdl );
108 : : }
109 : :
110 : 0 : void SAL_CALL PptImporter::cancel()
111 : : throw ( NMSP_UNO::RuntimeException )
112 : : {
113 : 0 : aFilter.cancel();
114 : 0 : }
115 : :
116 : : // XImporter
117 : 0 : void SAL_CALL PptImporter::setTargetDocument( const REF( NMSP_LANG::XComponent )& xDoc )
118 : : throw ( NMSP_LANG::IllegalArgumentException, NMSP_UNO::RuntimeException)
119 : : {
120 : 0 : xImporter->setTargetDocument( xDoc );
121 : 0 : }
122 : :
123 : : // XInitialization
124 : 0 : void SAL_CALL PptImporter::initialize( const SEQ( NMSP_UNO::Any )& /* aArguments */ )
125 : : throw ( NMSP_UNO::Exception, NMSP_UNO::RuntimeException )
126 : : {
127 : 0 : }
128 : :
129 : : // XServiceInfo
130 : 0 : NMSP_RTL::OUString SAL_CALL PptImporter::getImplementationName()
131 : : throw( NMSP_UNO::RuntimeException )
132 : : {
133 : 0 : return PptImporter_getImplementationName();
134 : : }
135 : :
136 : 0 : sal_Bool SAL_CALL PptImporter::supportsService( const NMSP_RTL::OUString& rServiceName )
137 : : throw( NMSP_UNO::RuntimeException )
138 : : {
139 : 0 : return PptImporter_supportsService( rServiceName );
140 : : }
141 : :
142 : 0 : SEQ( NMSP_RTL::OUString ) SAL_CALL PptImporter::getSupportedServiceNames()
143 : : throw ( NMSP_UNO::RuntimeException )
144 : : {
145 : 0 : return PptImporter_getSupportedServiceNames();
146 : : }
147 : :
148 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|