1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_filter.hxx"
26 #include "pptimporter.hxx"
27
28 #ifdef DBG_DUMP_PPT_IMPORT
29 #ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HDL_
30 #include <com/sun/star/io/XActiveDataSource.hpp>
31 #endif
32 #include <unotools/streamwrap.hxx>
33 #include <comphelper/processfactory.hxx>
34 #endif
35
36 #include <uno/mapping.hxx>
37
38 // -----------------
39 // - PptImporter -
40 // -----------------
41
PptImporter_getImplementationName()42 NMSP_RTL::OUString PptImporter_getImplementationName()
43 throw( NMSP_UNO::RuntimeException )
44 {
45 return B2UCONST( "com.sun.star.presentation.PptImporter" );
46 }
47 #define SERVICE_NAME "com.sun.star.document.ImportFilter"
PptImporter_supportsService(const NMSP_RTL::OUString & ServiceName)48 sal_Bool SAL_CALL PptImporter_supportsService( const NMSP_RTL::OUString& ServiceName )
49 throw( NMSP_UNO::RuntimeException )
50 {
51 return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SERVICE_NAME ) );
52 }
53
SEQ(NMSP_RTL::OUString)54 SEQ( NMSP_RTL::OUString ) SAL_CALL PptImporter_getSupportedServiceNames()
55 throw( NMSP_UNO::RuntimeException )
56 {
57 SEQ( NMSP_RTL::OUString ) aRet(1);
58 NMSP_RTL::OUString* pArray = aRet.getArray();
59 pArray[0] = B2UCONST( SERVICE_NAME );
60 return aRet;
61 }
62 #undef SERVICE_NAME
63
64 // -----------------------------------------------------------------------------
65
PptImporter(const REF (NMSP_LANG::XMultiServiceFactory)& rxMgr)66 PptImporter::PptImporter( const REF( NMSP_LANG::XMultiServiceFactory )& rxMgr ) :
67 xFact( rxMgr )
68 {
69 NMSP_RTL::OUString sService( B2UCONST( "com.sun.star.comp.Impress.XMLImporter" ) );
70 try
71 {
72 xHdl = REF( NMSP_SAX::XDocumentHandler ) ( xFact->createInstance( sService ), NMSP_UNO::UNO_QUERY );
73 xImporter = REF( NMSP_DOCUMENT::XImporter )( xHdl, NMSP_UNO::UNO_QUERY );
74 }
75 catch( NMSP_UNO::Exception & )
76 {
77 }
78 }
79
80 // -----------------------------------------------------------------------------
81
~PptImporter()82 PptImporter::~PptImporter()
83 {
84 }
85
86 // -----------------------------------------------------------------------------
87
acquire()88 void SAL_CALL PptImporter::acquire() throw()
89 {
90 OWeakObject::acquire();
91 }
92
93 // -----------------------------------------------------------------------------
94
release()95 void SAL_CALL PptImporter::release() throw()
96 {
97 OWeakObject::release();
98 }
99
100 // XFilter
filter(const SEQ (NMSP_BEANS::PropertyValue)& aDescriptor)101 sal_Bool SAL_CALL PptImporter::filter( const SEQ( NMSP_BEANS::PropertyValue )& aDescriptor )
102 throw ( NMSP_UNO::RuntimeException )
103 {
104
105
106 #ifdef DBG_DUMP_PPT_IMPORT
107
108 REF( NMSP_LANG::XMultiServiceFactory ) xServiceFactory( NMSP_COMPHELPER::getProcessServiceFactory() );
109 REF( NMSP_UNO::XInterface ) xWriter( xServiceFactory->createInstance( B2UCONST( "com.sun.star.xml.sax.Writer" ) ) );
110 SvFileStream aStrm( B2UCONST( "d:\\test2.xml" ), STREAM_READ | STREAM_WRITE | STREAM_TRUNC );
111 REF( NMSP_IO::XOutputStream ) xOutStream( (::cppu::OWeakObject*) new NMSP_UTL::OOutputStreamWrapper( aStrm ), NMSP_UNO::UNO_QUERY );
112 REF( NMSP_IO::XActiveDataSource ) xDataSource( xWriter , NMSP_UNO::UNO_QUERY );
113 xDataSource->setOutputStream( xOutStream );
114 aFilter.filter( aDescriptor, REF( NMSP_SAX::XDocumentHandler )( xWriter, NMSP_UNO::UNO_QUERY ) );
115
116 // REF( NMSP_BEANS::XPropertySet ) xPropSet( xServiceFactory->createInstance( B2UCONST( "com.sun.star.beans.PropertySet" ) ) );
117 // Any aAny;
118 // aAny <<= (sal_Bool)sal_True;
119 // xPropSet->setPropertyValue( B2UCONST( "UsePrettyPrinting" ), aAny );
120
121 #endif
122
123 return aFilter.filter( aDescriptor, xHdl );
124 }
cancel()125 void SAL_CALL PptImporter::cancel()
126 throw ( NMSP_UNO::RuntimeException )
127 {
128 aFilter.cancel();
129 }
130
131 // XImporter
setTargetDocument(const REF (NMSP_LANG::XComponent)& xDoc)132 void SAL_CALL PptImporter::setTargetDocument( const REF( NMSP_LANG::XComponent )& xDoc )
133 throw ( NMSP_LANG::IllegalArgumentException, NMSP_UNO::RuntimeException)
134 {
135 xImporter->setTargetDocument( xDoc );
136 }
137
138 // XInitialization
initialize(const SEQ (NMSP_UNO::Any)&)139 void SAL_CALL PptImporter::initialize( const SEQ( NMSP_UNO::Any )& /* aArguments */ )
140 throw ( NMSP_UNO::Exception, NMSP_UNO::RuntimeException )
141 {
142 }
143
144 // XServiceInfo
getImplementationName()145 NMSP_RTL::OUString SAL_CALL PptImporter::getImplementationName()
146 throw( NMSP_UNO::RuntimeException )
147 {
148 return PptImporter_getImplementationName();
149 }
supportsService(const NMSP_RTL::OUString & rServiceName)150 sal_Bool SAL_CALL PptImporter::supportsService( const NMSP_RTL::OUString& rServiceName )
151 throw( NMSP_UNO::RuntimeException )
152 {
153 return PptImporter_supportsService( rServiceName );
154 }
SEQ(NMSP_RTL::OUString)155 SEQ( NMSP_RTL::OUString ) SAL_CALL PptImporter::getSupportedServiceNames()
156 throw ( NMSP_UNO::RuntimeException )
157 {
158 return PptImporter_getSupportedServiceNames();
159 }
160