LibreOffice Module filter (master) 1
pdfdialog.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
21#include "pdfdialog.hxx"
22#include "impdialog.hxx"
23#include <vcl/svapp.hxx>
24
25using namespace ::com::sun::star;
26using namespace ::com::sun::star::uno;
27using namespace ::com::sun::star::lang;
28using namespace ::com::sun::star::beans;
29
30PDFDialog::PDFDialog( const Reference< XComponentContext > &rxContext )
31: PDFDialog_Base( rxContext )
32{
33}
34
35
37{
38}
39
40
42{
43 return css::uno::Sequence<sal_Int8>();
44}
45
46
48{
49 return "com.sun.star.comp.PDF.PDFDialog";
50}
51
52
53Sequence< OUString > SAL_CALL PDFDialog::getSupportedServiceNames()
54{
55 return { "com.sun.star.document.PDFDialog" };
56}
57
58std::unique_ptr<weld::DialogController> PDFDialog::createDialog(const css::uno::Reference<css::awt::XWindow>& rParent)
59{
60 if( mxSrcDoc.is() )
61 return std::make_unique<ImpPDFTabDialog>(Application::GetFrameWeld(rParent), maFilterData, mxSrcDoc);
62 return nullptr;
63}
64
65std::shared_ptr<SfxTabDialogController> PDFDialog::createAsyncDialog(const css::uno::Reference<css::awt::XWindow>& rParent)
66{
67 if( mxSrcDoc.is() )
68 return std::make_shared<ImpPDFTabDialog>(Application::GetFrameWeld(rParent), maFilterData, mxSrcDoc);
69 return nullptr;
70}
71
72void PDFDialog::executedDialog( sal_Int16 nExecutionResult )
73{
74 if (nExecutionResult && m_xDialog)
75 maFilterData = static_cast<ImpPDFTabDialog*>(m_xDialog.get())->GetFilterData();
76 destroyDialog();
77}
78
79void PDFDialog::runAsync(const css::uno::Reference< css::ui::dialogs::XDialogClosedListener >& xListener)
80{
81 SfxTabDialogController::runAsync(m_xAsyncDialog, [this, xListener](sal_Int32 nResponse) {
82 rtl::Reference<PDFDialog> xThis(this); // keep alive for scope, dialogClosed can cause owner to drop this
83 executedAsyncDialog( m_xAsyncDialog, nResponse );
84 css::ui::dialogs::DialogClosedEvent aEvent;
85 aEvent.DialogResult = nResponse;
86 xListener->dialogClosed( aEvent );
87 destroyAsyncDialog();
88 });
89}
90
91void PDFDialog::executedAsyncDialog( std::shared_ptr<SfxTabDialogController> xAsyncDialog, sal_Int32 nExecutionResult )
92{
93 if (nExecutionResult && xAsyncDialog)
94 maFilterData = static_cast<ImpPDFTabDialog*>(xAsyncDialog.get())->GetFilterData();
95}
96
97Reference< XPropertySetInfo > SAL_CALL PDFDialog::getPropertySetInfo()
98{
99 Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
100 return xInfo;
101}
102
104{
105 return *getArrayHelper();
106}
107
109{
110 Sequence< Property > aProps;
111 describeProperties(aProps);
112 return new ::cppu::OPropertyArrayHelper( aProps );
113}
114
115
116Sequence< PropertyValue > SAL_CALL PDFDialog::getPropertyValues()
117{
118 sal_Int32 i, nCount;
119
120 for( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
121 {
122 if ( maMediaDescriptor[ i ].Name == "FilterData" )
123 break;
124 }
125
126 if( i == nCount )
127 maMediaDescriptor.realloc( ++nCount );
128 auto pMediaDescriptor = maMediaDescriptor.getArray();
129
130 pMediaDescriptor[ i ].Name = "FilterData";
131 pMediaDescriptor[ i ].Value <<= maFilterData;
132
133 return maMediaDescriptor;
134}
135
136
137void SAL_CALL PDFDialog::setPropertyValues( const Sequence< PropertyValue >& rProps )
138{
139 maMediaDescriptor = rProps;
140
141 for( const PropertyValue& rProp : std::as_const(maMediaDescriptor) )
142 {
143 if ( rProp.Name == "FilterData" )
144 {
145 rProp.Value >>= maFilterData;
146 break;
147 }
148 }
149}
150
151
152void SAL_CALL PDFDialog::setSourceDocument( const Reference< XComponent >& xDoc )
153{
154 mxSrcDoc = xDoc;
155}
156
157extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
159 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
160{
161 return cppu::acquire(new PDFDialog(context));
162}
163
164/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XExecutableDialog > m_xDialog
AnyEventRef aEvent
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
Class tabbed dialog.
Definition: impdialog.hxx:60
Sequence< PropertyValue > maFilterData
Definition: pdfdialog.hxx:46
virtual void runAsync(const css::uno::Reference< css::ui::dialogs::XDialogClosedListener > &xListener) override
Definition: pdfdialog.cxx:79
virtual void executedDialog(sal_Int16 nExecutionResult) override
Definition: pdfdialog.cxx:72
virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: pdfdialog.cxx:41
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
Definition: pdfdialog.cxx:108
virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: pdfdialog.cxx:53
virtual ~PDFDialog() override
Definition: pdfdialog.cxx:36
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
Definition: pdfdialog.cxx:103
Sequence< PropertyValue > maMediaDescriptor
Definition: pdfdialog.hxx:45
Reference< XComponent > mxSrcDoc
Definition: pdfdialog.hxx:47
virtual OUString SAL_CALL getImplementationName() override
Definition: pdfdialog.cxx:47
virtual Sequence< PropertyValue > SAL_CALL getPropertyValues() override
Definition: pdfdialog.cxx:116
virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: pdfdialog.cxx:97
PDFDialog(const Reference< XComponentContext > &rxContext)
Definition: pdfdialog.cxx:30
virtual std::shared_ptr< SfxTabDialogController > createAsyncDialog(const css::uno::Reference< css::awt::XWindow > &rParent) override
Definition: pdfdialog.cxx:65
virtual std::unique_ptr< weld::DialogController > createDialog(const css::uno::Reference< css::awt::XWindow > &rParent) override
Definition: pdfdialog.cxx:58
virtual void SAL_CALL setSourceDocument(const Reference< XComponent > &xDoc) override
Definition: pdfdialog.cxx:152
virtual void executedAsyncDialog(std::shared_ptr< SfxTabDialogController > xAsyncDialog, sal_Int32 nExecutionResult) override
Definition: pdfdialog.cxx:91
virtual void SAL_CALL setPropertyValues(const Sequence< PropertyValue > &aProps) override
Definition: pdfdialog.cxx:137
static bool runAsync(const std::shared_ptr< SfxTabDialogController > &rController, const std::function< void(sal_Int32)> &)
::cppu::IPropertyArrayHelper * getArrayHelper()
int nCount
Shape IDs per cluster in DGG atom.
int i
Definition: gentoken.py:48
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * filter_PDFDialog_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: pdfdialog.cxx:158
::cppu::ImplInheritanceHelper< ::svt::OGenericUnoAsyncDialog< SfxTabDialogController >, XPropertyAccess, XExporter > PDFDialog_Base
Definition: pdfdialog.hxx:38
OUString Name