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/implbase.hxx>
25 #include <cppuhelper/supportsservice.hxx>
26 #include <osl/diagnose.h>
27 #include <comphelper/processfactory.hxx>
29 #include "exporter.hxx"
32 using namespace ::com::sun::star::uno
;
33 using namespace ::com::sun::star::lang
;
35 using ::com::sun::star::lang::XComponent
;
36 using ::com::sun::star::beans::PropertyValue
;
37 using ::com::sun::star::io::XOutputStream
;
38 using ::com::sun::star::task::XStatusIndicator
;
43 class PlaceWareExportFilter
: public cppu::WeakImplHelper
45 css::document::XFilter
,
46 css::document::XExporter
,
47 css::lang::XInitialization
,
48 css::lang::XServiceInfo
51 Reference
< XComponent
> mxDoc
;
52 Reference
< XComponentContext
> mxContext
;
55 explicit PlaceWareExportFilter( const Reference
< XComponentContext
> &rxContext
);
58 virtual sal_Bool SAL_CALL
filter( const Sequence
< PropertyValue
>& aDescriptor
) throw(RuntimeException
, std::exception
) override
;
59 virtual void SAL_CALL
cancel( ) throw (RuntimeException
, std::exception
) override
;
62 virtual void SAL_CALL
setSourceDocument( const Reference
< XComponent
>& xDoc
) throw(IllegalArgumentException
, RuntimeException
, std::exception
) override
;
65 virtual void SAL_CALL
initialize( const Sequence
< Any
>& aArguments
) throw(Exception
, RuntimeException
, std::exception
) override
;
68 virtual OUString SAL_CALL
getImplementationName() throw(RuntimeException
, std::exception
) override
;
69 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw(RuntimeException
, std::exception
) override
;
70 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() throw(RuntimeException
, std::exception
) override
;
74 PlaceWareExportFilter::PlaceWareExportFilter(const Reference
< XComponentContext
> &rxContext
)
75 : mxContext( rxContext
)
80 sal_Bool SAL_CALL
PlaceWareExportFilter::filter( const css::uno::Sequence
< css::beans::PropertyValue
>& aDescriptor
)
81 throw (RuntimeException
, std::exception
)
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
== "OutputStream" )
93 pValue
[i
].Value
>>= xOutputStream
;
95 else if( pValue
[i
].Name
== "URL" )
97 pValue
[i
].Value
>>= sURL
;
99 else if( pValue
[i
].Name
== "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 ( false );
114 PlaceWareExporter
aExporter( mxContext
);
115 return aExporter
.doExport( mxDoc
, xOutputStream
, sURL
, xInteractionHandler
, xStatusIndicator
);
119 void SAL_CALL
PlaceWareExportFilter::cancel( )
120 throw (RuntimeException
, std::exception
)
126 void SAL_CALL
PlaceWareExportFilter::setSourceDocument( const css::uno::Reference
< css::lang::XComponent
>& xDoc
)
127 throw (css::lang::IllegalArgumentException
, RuntimeException
, std::exception
)
134 void SAL_CALL
PlaceWareExportFilter::initialize( const css::uno::Sequence
< css::uno::Any
>& /* aArguments */ )
135 throw (Exception
, RuntimeException
, std::exception
)
139 OUString
PlaceWareExportFilter_getImplementationName ()
140 throw (RuntimeException
)
142 return OUString( "com.sun.star.comp.Impress.PlaceWareExportFilter" );
145 Sequence
< OUString
> SAL_CALL
PlaceWareExportFilter_getSupportedServiceNames( )
146 throw (RuntimeException
)
148 Sequence
<OUString
> aRet
{ "com.sun.star.document.ExportFilter" };
152 Reference
< XInterface
> SAL_CALL
PlaceWareExportFilter_createInstance( const Reference
< XMultiServiceFactory
> & rSMgr
)
155 return static_cast<cppu::OWeakObject
*>(new PlaceWareExportFilter( comphelper::getComponentContext(rSMgr
) ));
159 OUString SAL_CALL
PlaceWareExportFilter::getImplementationName( )
160 throw (RuntimeException
, std::exception
)
162 return PlaceWareExportFilter_getImplementationName();
165 sal_Bool SAL_CALL
PlaceWareExportFilter::supportsService( const OUString
& rServiceName
)
166 throw (RuntimeException
, std::exception
)
168 return cppu::supportsService( this, rServiceName
);
171 css::uno::Sequence
< OUString
> SAL_CALL
PlaceWareExportFilter::getSupportedServiceNames( )
172 throw (RuntimeException
, std::exception
)
174 return PlaceWareExportFilter_getSupportedServiceNames();
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */