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