bump product version to 4.1.6.2
[LibreOffice.git] / filter / source / placeware / filter.cxx
blob20f7f86a69262f3e1c9b1269c5df25171462adad
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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 <comphelper/processfactory.hxx>
27 #include "exporter.hxx"
29 using namespace ::com::sun::star::uno;
30 using namespace ::com::sun::star::lang;
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;
37 namespace pwp {
39 // -----------------------------------------------------------------------------
41 class PlaceWareExportFilter : public cppu::WeakImplHelper4
43 com::sun::star::document::XFilter,
44 com::sun::star::document::XExporter,
45 com::sun::star::lang::XInitialization,
46 com::sun::star::lang::XServiceInfo
49 Reference< XComponent > mxDoc;
50 Reference< XComponentContext > mxContext;
52 public:
53 PlaceWareExportFilter( const Reference< XComponentContext > &rxContext);
55 // XFilter
56 virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& aDescriptor ) throw(RuntimeException);
57 virtual void SAL_CALL cancel( ) throw (RuntimeException);
59 // XExporter
60 virtual void SAL_CALL setSourceDocument( const Reference< XComponent >& xDoc ) throw(IllegalArgumentException, RuntimeException);
62 // XInitialization
63 virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException);
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);
71 // -----------------------------------------------------------------------------
73 PlaceWareExportFilter::PlaceWareExportFilter(const Reference< XComponentContext > &rxContext)
74 : mxContext( rxContext )
78 // -----------------------------------------------------------------------------
80 sal_Bool SAL_CALL PlaceWareExportFilter::filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
81 throw (RuntimeException)
83 sal_Int32 nLength = aDescriptor.getLength();
84 const PropertyValue * pValue = aDescriptor.getConstArray();
85 OUString sURL;
86 Reference < XInterface > xInteractionHandler;
87 Reference < XOutputStream > xOutputStream;
88 Reference < XStatusIndicator > xStatusIndicator;
89 for ( sal_Int32 i = 0 ; i < nLength; i++)
91 if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "OutputStream" ) ) )
93 pValue[i].Value >>= xOutputStream;
95 else if( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "URL" ) ) )
97 pValue[i].Value >>= sURL;
99 else if( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "InteractionHandler" ) ) )
101 pValue[i].Value >>= xInteractionHandler;
103 else if ( pValue[i].Name == "StatusIndicator" )
105 pValue[i].Value >>= xStatusIndicator;
108 if ( !xOutputStream.is() )
110 OSL_ASSERT ( 0 );
111 return sal_False;
114 PlaceWareExporter aExporter( mxContext );
115 return aExporter.doExport( mxDoc, xOutputStream, sURL, xInteractionHandler, xStatusIndicator );
118 // -----------------------------------------------------------------------------
120 void SAL_CALL PlaceWareExportFilter::cancel( )
121 throw (RuntimeException)
125 // -----------------------------------------------------------------------------
127 // XExporter
128 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)
131 mxDoc = xDoc;
134 // -----------------------------------------------------------------------------
136 // XInitialization
137 void SAL_CALL PlaceWareExportFilter::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& /* aArguments */ )
138 throw (Exception, RuntimeException)
142 // -----------------------------------------------------------------------------
144 OUString PlaceWareExportFilter_getImplementationName ()
145 throw (RuntimeException)
147 return OUString( "com.sun.star.comp.Impress.PlaceWareExportFilter" );
150 // -----------------------------------------------------------------------------
152 #define SERVICE_NAME "com.sun.star.document.ExportFilter"
154 sal_Bool SAL_CALL PlaceWareExportFilter_supportsService( const OUString& ServiceName )
155 throw (RuntimeException)
157 return ServiceName == SERVICE_NAME;
160 // -----------------------------------------------------------------------------
162 Sequence< OUString > SAL_CALL PlaceWareExportFilter_getSupportedServiceNames( )
163 throw (RuntimeException)
165 Sequence < OUString > aRet(1);
166 OUString* pArray = aRet.getArray();
167 pArray[0] = OUString ( SERVICE_NAME );
168 return aRet;
170 #undef SERVICE_NAME
172 // -----------------------------------------------------------------------------
174 Reference< XInterface > SAL_CALL PlaceWareExportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
175 throw( Exception )
177 return (cppu::OWeakObject*) new PlaceWareExportFilter( comphelper::getComponentContext(rSMgr) );
180 // -----------------------------------------------------------------------------
182 // XServiceInfo
183 OUString SAL_CALL PlaceWareExportFilter::getImplementationName( )
184 throw (RuntimeException)
186 return PlaceWareExportFilter_getImplementationName();
189 // -----------------------------------------------------------------------------
191 sal_Bool SAL_CALL PlaceWareExportFilter::supportsService( const OUString& rServiceName )
192 throw (RuntimeException)
194 return PlaceWareExportFilter_supportsService( rServiceName );
197 // -----------------------------------------------------------------------------
199 ::com::sun::star::uno::Sequence< OUString > SAL_CALL PlaceWareExportFilter::getSupportedServiceNames( )
200 throw (RuntimeException)
202 return PlaceWareExportFilter_getSupportedServiceNames();
205 // -----------------------------------------------------------------------------
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */