20#include <com/sun/star/frame/DoubleInitializationException.hpp>
21#include <com/sun/star/document/XFilter.hpp>
22#include <com/sun/star/lang/XServiceInfo.hpp>
23#include <com/sun/star/lang/IllegalArgumentException.hpp>
24#include <com/sun/star/uno/XComponentContext.hpp>
25#include <com/sun/star/frame/XModel.hpp>
26#include <com/sun/star/io/XStream.hpp>
36class OwnSubFilterService :
public cppu::WeakImplHelper < document::XFilter
39 uno::Reference< frame::XModel >
m_xModel;
46 explicit OwnSubFilterService(
const css::uno::Sequence< css::uno::Any >& aArguments);
49 virtual sal_Bool SAL_CALL
filter(
const uno::Sequence< beans::PropertyValue >& aDescriptor )
override;
50 virtual void SAL_CALL cancel()
override;
58OwnSubFilterService::OwnSubFilterService(
const css::uno::Sequence< css::uno::Any >& aArguments)
59 : m_pObjectShell( nullptr )
62 throw lang::IllegalArgumentException();
65 throw frame::DoubleInitializationException();
67 if ( ( aArguments[1] >>= m_xStream ) &&
m_xStream.is()
68 && ( aArguments[0] >>= m_xModel ) &&
m_xModel.is() )
73 if ( !m_pObjectShell )
74 throw lang::IllegalArgumentException();
77sal_Bool SAL_CALL OwnSubFilterService::filter(
const uno::Sequence< beans::PropertyValue >& aDescriptor )
79 if ( !m_pObjectShell )
80 throw uno::RuntimeException();
82 return m_pObjectShell->ImportFromGeneratedStream_Impl( m_xStream, aDescriptor );
85void SAL_CALL OwnSubFilterService::cancel()
90OUString SAL_CALL OwnSubFilterService::getImplementationName()
92 return "com.sun.star.comp.document.OwnSubFilter";
95sal_Bool SAL_CALL OwnSubFilterService::supportsService(
const OUString& ServiceName )
100uno::Sequence< OUString > SAL_CALL OwnSubFilterService::getSupportedServiceNames()
102 return {
"com.sun.star.document.OwnSubFilter",
"com.sun.star.comp.document.OwnSubFilter" };
107extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
109 css::uno::XComponentContext *,
110 css::uno::Sequence<css::uno::Any>
const &arguments)
112 return cppu::acquire(
new OwnSubFilterService(arguments));
static SfxObjectShell * GetShellFromComponent(const css::uno::Reference< css::uno::XInterface > &xComp)
Reference< frame::XModel > m_xModel
Sequence< PropertyValue > aArguments
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_document_OwnSubFilter_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &arguments)
Reference< XStream > m_xStream