1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
;
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
;
53 PlaceWareExportFilter( const Reference
< XComponentContext
> &rxContext
);
56 virtual sal_Bool SAL_CALL
filter( const Sequence
< PropertyValue
>& aDescriptor
) throw(RuntimeException
);
57 virtual void SAL_CALL
cancel( ) throw (RuntimeException
);
60 virtual void SAL_CALL
setSourceDocument( const Reference
< XComponent
>& xDoc
) throw(IllegalArgumentException
, RuntimeException
);
63 virtual void SAL_CALL
initialize( const Sequence
< Any
>& aArguments
) throw(Exception
, RuntimeException
);
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();
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() )
114 PlaceWareExporter
aExporter( mxContext
);
115 return aExporter
.doExport( mxDoc
, xOutputStream
, sURL
, xInteractionHandler
, xStatusIndicator
);
118 // -----------------------------------------------------------------------------
120 void SAL_CALL
PlaceWareExportFilter::cancel( )
121 throw (RuntimeException
)
125 // -----------------------------------------------------------------------------
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
)
134 // -----------------------------------------------------------------------------
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
);
172 // -----------------------------------------------------------------------------
174 Reference
< XInterface
> SAL_CALL
PlaceWareExportFilter_createInstance( const Reference
< XMultiServiceFactory
> & rSMgr
)
177 return (cppu::OWeakObject
*) new PlaceWareExportFilter( comphelper::getComponentContext(rSMgr
) );
180 // -----------------------------------------------------------------------------
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: */