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 : #include <com/sun/star/document/XFilter.hpp>
21 : #include <com/sun/star/document/XExporter.hpp>
22 : #include <com/sun/star/lang/XInitialization.hpp>
23 : #include <com/sun/star/lang/XServiceInfo.hpp>
24 : #include <cppuhelper/implbase4.hxx>
25 :
26 : #include "exporter.hxx"
27 :
28 : using namespace ::com::sun::star::uno;
29 : using namespace ::com::sun::star::lang;
30 :
31 : using ::rtl::OUString;
32 : using ::com::sun::star::lang::XComponent;
33 : using ::com::sun::star::beans::PropertyValue;
34 : using ::com::sun::star::io::XOutputStream;
35 : using ::com::sun::star::task::XStatusIndicator;
36 :
37 : namespace pwp {
38 :
39 : // -----------------------------------------------------------------------------
40 :
41 0 : class PlaceWareExportFilter : public cppu::WeakImplHelper4
42 : <
43 : com::sun::star::document::XFilter,
44 : com::sun::star::document::XExporter,
45 : com::sun::star::lang::XInitialization,
46 : com::sun::star::lang::XServiceInfo
47 : >
48 : {
49 : Reference< XComponent > mxDoc;
50 : Reference< XMultiServiceFactory > mxMSF;
51 :
52 : public:
53 : PlaceWareExportFilter( const Reference< XMultiServiceFactory > &rxMSF);
54 :
55 : // XFilter
56 : virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& aDescriptor ) throw(RuntimeException);
57 : virtual void SAL_CALL cancel( ) throw (RuntimeException);
58 :
59 : // XExporter
60 : virtual void SAL_CALL setSourceDocument( const Reference< XComponent >& xDoc ) throw(IllegalArgumentException, RuntimeException);
61 :
62 : // XInitialization
63 : virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException);
64 :
65 : // XServiceInfo
66 : virtual OUString SAL_CALL getImplementationName() throw(RuntimeException);
67 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException);
68 : virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException);
69 : };
70 :
71 : // -----------------------------------------------------------------------------
72 :
73 0 : PlaceWareExportFilter::PlaceWareExportFilter(const Reference< XMultiServiceFactory > &rxMSF)
74 0 : : mxMSF( rxMSF )
75 : {
76 0 : }
77 :
78 : // -----------------------------------------------------------------------------
79 :
80 0 : sal_Bool SAL_CALL PlaceWareExportFilter::filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
81 : throw (RuntimeException)
82 : {
83 0 : sal_Int32 nLength = aDescriptor.getLength();
84 0 : const PropertyValue * pValue = aDescriptor.getConstArray();
85 0 : OUString sURL;
86 0 : Reference < XInterface > xInteractionHandler;
87 0 : Reference < XOutputStream > xOutputStream;
88 0 : Reference < XStatusIndicator > xStatusIndicator;
89 0 : for ( sal_Int32 i = 0 ; i < nLength; i++)
90 : {
91 0 : if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "OutputStream" ) ) )
92 : {
93 0 : pValue[i].Value >>= xOutputStream;
94 : }
95 0 : else if( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "URL" ) ) )
96 : {
97 0 : pValue[i].Value >>= sURL;
98 : }
99 0 : else if( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "InteractionHandler" ) ) )
100 : {
101 0 : pValue[i].Value >>= xInteractionHandler;
102 : }
103 0 : else if ( pValue[i].Name == "StatusIndicator" )
104 : {
105 0 : pValue[i].Value >>= xStatusIndicator;
106 : }
107 : }
108 0 : if ( !xOutputStream.is() )
109 : {
110 : OSL_ASSERT ( 0 );
111 0 : return sal_False;
112 : }
113 :
114 0 : PlaceWareExporter aExporter( mxMSF );
115 0 : return aExporter.doExport( mxDoc, xOutputStream, sURL, xInteractionHandler, xStatusIndicator );
116 : }
117 :
118 : // -----------------------------------------------------------------------------
119 :
120 0 : void SAL_CALL PlaceWareExportFilter::cancel( )
121 : throw (RuntimeException)
122 : {
123 0 : }
124 :
125 : // -----------------------------------------------------------------------------
126 :
127 : // XExporter
128 0 : void SAL_CALL PlaceWareExportFilter::setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
129 : throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException)
130 : {
131 0 : mxDoc = xDoc;
132 0 : }
133 :
134 : // -----------------------------------------------------------------------------
135 :
136 : // XInitialization
137 0 : void SAL_CALL PlaceWareExportFilter::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& /* aArguments */ )
138 : throw (Exception, RuntimeException)
139 : {
140 0 : }
141 :
142 : // -----------------------------------------------------------------------------
143 :
144 0 : OUString PlaceWareExportFilter_getImplementationName ()
145 : throw (RuntimeException)
146 : {
147 0 : return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Impress.PlaceWareExportFilter" ) );
148 : }
149 :
150 : // -----------------------------------------------------------------------------
151 :
152 : #define SERVICE_NAME "com.sun.star.document.ExportFilter"
153 :
154 0 : sal_Bool SAL_CALL PlaceWareExportFilter_supportsService( const OUString& ServiceName )
155 : throw (RuntimeException)
156 : {
157 0 : return ServiceName == SERVICE_NAME;
158 : }
159 :
160 : // -----------------------------------------------------------------------------
161 :
162 0 : Sequence< OUString > SAL_CALL PlaceWareExportFilter_getSupportedServiceNames( )
163 : throw (RuntimeException)
164 : {
165 0 : Sequence < OUString > aRet(1);
166 0 : OUString* pArray = aRet.getArray();
167 0 : pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
168 0 : return aRet;
169 : }
170 : #undef SERVICE_NAME
171 :
172 : // -----------------------------------------------------------------------------
173 :
174 0 : Reference< XInterface > SAL_CALL PlaceWareExportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
175 : throw( Exception )
176 : {
177 0 : return (cppu::OWeakObject*) new PlaceWareExportFilter( rSMgr );
178 : }
179 :
180 : // -----------------------------------------------------------------------------
181 :
182 : // XServiceInfo
183 0 : OUString SAL_CALL PlaceWareExportFilter::getImplementationName( )
184 : throw (RuntimeException)
185 : {
186 0 : return PlaceWareExportFilter_getImplementationName();
187 : }
188 :
189 : // -----------------------------------------------------------------------------
190 :
191 0 : sal_Bool SAL_CALL PlaceWareExportFilter::supportsService( const OUString& rServiceName )
192 : throw (RuntimeException)
193 : {
194 0 : return PlaceWareExportFilter_supportsService( rServiceName );
195 : }
196 :
197 : // -----------------------------------------------------------------------------
198 :
199 0 : ::com::sun::star::uno::Sequence< OUString > SAL_CALL PlaceWareExportFilter::getSupportedServiceNames( )
200 : throw (RuntimeException)
201 : {
202 0 : return PlaceWareExportFilter_getSupportedServiceNames();
203 : }
204 :
205 : // -----------------------------------------------------------------------------
206 :
207 : }
208 :
209 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|