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 <SwXFilterOptions.hxx>
21 #include <shellio.hxx>
23 #include <vcl/svapp.hxx>
24 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
25 #include <comphelper/namedvaluecollection.hxx>
26 #include <comphelper/propertysequence.hxx>
27 #include <comphelper/servicehelper.hxx>
28 #include <cppuhelper/supportsservice.hxx>
29 #include <unotools/ucbstreamhelper.hxx>
30 #include <unotxdoc.hxx>
32 #include <swabstdlg.hxx>
35 using namespace ::com::sun::star
;
36 using namespace ::com::sun::star::ui::dialogs
;
37 using namespace ::com::sun::star::document
;
38 using namespace ::com::sun::star::lang
;
40 constexpr OUStringLiteral FILTER_OPTIONS_NAME
= u
"FilterOptions";
42 SwXFilterOptions::SwXFilterOptions()
46 SwXFilterOptions::~SwXFilterOptions()
50 uno::Sequence
< beans::PropertyValue
> SwXFilterOptions::getPropertyValues()
52 return comphelper::InitPropertySequence({
53 { FILTER_OPTIONS_NAME
, uno::Any(m_sFilterOptions
) }
57 void SwXFilterOptions::setPropertyValues( const uno::Sequence
<beans::PropertyValue
>& aProps
)
59 for (const beans::PropertyValue
& rProp
: aProps
)
61 OUString aPropName
= rProp
.Name
;
63 if ( aPropName
== FILTER_OPTIONS_NAME
)
64 rProp
.Value
>>= m_sFilterOptions
;
65 else if ( aPropName
== "InputStream" )
66 rProp
.Value
>>= m_xInputStream
;
70 void SwXFilterOptions::setTitle( const OUString
& /*rTitle*/ )
74 sal_Int16
SwXFilterOptions::execute()
76 sal_Int16 nRet
= ui::dialogs::ExecutableDialogResults::CANCEL
;
78 std::unique_ptr
<SvStream
> pInStream
;
79 if ( m_xInputStream
.is() )
80 pInStream
= utl::UcbStreamHelper::CreateStream( m_xInputStream
);
82 SwDocShell
* pDocShell
= nullptr;
83 if (auto pXDoc
= comphelper::getFromUnoTunnel
<SwXTextDocument
>(m_xModel
); pXDoc
)
84 pDocShell
= pXDoc
->GetDocShell();
88 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
89 ScopedVclPtr
<AbstractSwAsciiFilterDlg
> pAsciiDlg(pFact
->CreateSwAsciiFilterDlg(Application::GetFrameWeld(m_xDialogParent
), *pDocShell
,
91 if(RET_OK
== pAsciiDlg
->Execute())
93 SwAsciiOptions aOptions
;
94 pAsciiDlg
->FillOptions( aOptions
);
95 aOptions
.WriteUserData(m_sFilterOptions
);
96 nRet
= ui::dialogs::ExecutableDialogResults::OK
;
103 void SwXFilterOptions::setTargetDocument( const uno::Reference
< XComponent
>& xDoc
)
108 void SwXFilterOptions::setSourceDocument( const uno::Reference
<XComponent
>& xDoc
)
113 void SAL_CALL
SwXFilterOptions::initialize(const uno::Sequence
<uno::Any
>& rArguments
)
115 ::comphelper::NamedValueCollection
aProperties(rArguments
);
116 if (aProperties
.has("ParentWindow"))
117 aProperties
.get("ParentWindow") >>= m_xDialogParent
;
120 OUString
SwXFilterOptions::getImplementationName()
122 return "com.sun.star.comp.Writer.FilterOptionsDialog";
125 sal_Bool
SwXFilterOptions::supportsService( const OUString
& rServiceName
)
127 return cppu::supportsService(this, rServiceName
);
130 uno::Sequence
< OUString
> SwXFilterOptions::getSupportedServiceNames()
132 return { "com.sun.star.ui.dialogs.FilterOptionsDialog" };
135 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
136 com_sun_star_comp_Writer_FilterOptionsDialog_get_implementation(css::uno::XComponentContext
*,
137 css::uno::Sequence
<css::uno::Any
> const &)
139 SolarMutexGuard aGuard
;
141 //the module may not be loaded
143 return cppu::acquire(new SwXFilterOptions());
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */