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 .
21 #include "pdfdialog.hxx"
22 #include "impdialog.hxx"
23 #include <vcl/svapp.hxx>
25 using namespace ::com::sun::star
;
26 using namespace ::com::sun::star::uno
;
27 using namespace ::com::sun::star::lang
;
28 using namespace ::com::sun::star::beans
;
30 PDFDialog::PDFDialog( const Reference
< XComponentContext
> &rxContext
)
31 : PDFDialog_Base( rxContext
)
36 PDFDialog::~PDFDialog()
41 Sequence
< sal_Int8
> SAL_CALL
PDFDialog::getImplementationId()
43 return css::uno::Sequence
<sal_Int8
>();
47 OUString SAL_CALL
PDFDialog::getImplementationName()
49 return "com.sun.star.comp.PDF.PDFDialog";
53 Sequence
< OUString
> SAL_CALL
PDFDialog::getSupportedServiceNames()
55 return { "com.sun.star.document.PDFDialog" };
58 std::unique_ptr
<weld::DialogController
> PDFDialog::createDialog(const css::uno::Reference
<css::awt::XWindow
>& rParent
)
61 return std::make_unique
<ImpPDFTabDialog
>(Application::GetFrameWeld(rParent
), maFilterData
, mxSrcDoc
);
65 std::shared_ptr
<SfxTabDialogController
> PDFDialog::createAsyncDialog(const css::uno::Reference
<css::awt::XWindow
>& rParent
)
68 return std::make_shared
<ImpPDFTabDialog
>(Application::GetFrameWeld(rParent
), maFilterData
, mxSrcDoc
);
72 void PDFDialog::executedDialog( sal_Int16 nExecutionResult
)
74 if (nExecutionResult
&& m_xDialog
)
75 maFilterData
= static_cast<ImpPDFTabDialog
*>(m_xDialog
.get())->GetFilterData();
79 void PDFDialog::runAsync(const css::uno::Reference
< css::ui::dialogs::XDialogClosedListener
>& xListener
)
81 SfxTabDialogController::runAsync(m_xAsyncDialog
, [this, xListener
](sal_Int32 nResponse
) {
82 executedAsyncDialog( m_xAsyncDialog
, nResponse
);
83 css::ui::dialogs::DialogClosedEvent aEvent
;
84 aEvent
.DialogResult
= nResponse
;
85 xListener
->dialogClosed( aEvent
);
90 void PDFDialog::executedAsyncDialog( std::shared_ptr
<SfxTabDialogController
> xAsyncDialog
, sal_Int32 nExecutionResult
)
92 if (nExecutionResult
&& xAsyncDialog
)
93 maFilterData
= static_cast<ImpPDFTabDialog
*>(xAsyncDialog
.get())->GetFilterData();
96 Reference
< XPropertySetInfo
> SAL_CALL
PDFDialog::getPropertySetInfo()
98 Reference
< XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
102 ::cppu::IPropertyArrayHelper
& PDFDialog::getInfoHelper()
104 return *getArrayHelper();
107 ::cppu::IPropertyArrayHelper
* PDFDialog::createArrayHelper() const
109 Sequence
< Property
> aProps
;
110 describeProperties(aProps
);
111 return new ::cppu::OPropertyArrayHelper( aProps
);
115 Sequence
< PropertyValue
> SAL_CALL
PDFDialog::getPropertyValues()
119 for( i
= 0, nCount
= maMediaDescriptor
.getLength(); i
< nCount
; i
++ )
121 if ( maMediaDescriptor
[ i
].Name
== "FilterData" )
126 maMediaDescriptor
.realloc( ++nCount
);
127 auto pMediaDescriptor
= maMediaDescriptor
.getArray();
129 pMediaDescriptor
[ i
].Name
= "FilterData";
130 pMediaDescriptor
[ i
].Value
<<= maFilterData
;
132 return maMediaDescriptor
;
136 void SAL_CALL
PDFDialog::setPropertyValues( const Sequence
< PropertyValue
>& rProps
)
138 maMediaDescriptor
= rProps
;
140 for( const PropertyValue
& rProp
: std::as_const(maMediaDescriptor
) )
142 if ( rProp
.Name
== "FilterData" )
144 rProp
.Value
>>= maFilterData
;
151 void SAL_CALL
PDFDialog::setSourceDocument( const Reference
< XComponent
>& xDoc
)
156 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
157 filter_PDFDialog_get_implementation(
158 css::uno::XComponentContext
* context
, css::uno::Sequence
<css::uno::Any
> const&)
160 return cppu::acquire(new PDFDialog(context
));
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */