tdf#164803 sw: Revert use ext leading for grid spacing on DOC import
[LibreOffice.git] / filter / source / pdf / pdfdialog.cxx
bloba1737a04d6f40f2ad7ec1eca751553e4b8dc15d1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 u"com.sun.star.comp.PDF.PDFDialog"_ustr;
53 Sequence< OUString > SAL_CALL PDFDialog::getSupportedServiceNames()
55 return { u"com.sun.star.document.PDFDialog"_ustr };
58 std::unique_ptr<weld::DialogController> PDFDialog::createDialog(const css::uno::Reference<css::awt::XWindow>& rParent)
60 if( mxSrcDoc.is() )
61 return std::make_unique<ImpPDFTabDialog>(Application::GetFrameWeld(rParent), maFilterData, mxSrcDoc);
62 return nullptr;
65 std::shared_ptr<SfxTabDialogController> PDFDialog::createAsyncDialog(const css::uno::Reference<css::awt::XWindow>& rParent)
67 if( mxSrcDoc.is() )
68 return std::make_shared<ImpPDFTabDialog>(Application::GetFrameWeld(rParent), maFilterData, mxSrcDoc);
69 return nullptr;
72 void PDFDialog::executedDialog( sal_Int16 nExecutionResult )
74 if (nExecutionResult && m_xDialog)
75 maFilterData = static_cast<ImpPDFTabDialog*>(m_xDialog.get())->GetFilterData();
76 destroyDialog();
79 void PDFDialog::runAsync(const css::uno::Reference< css::ui::dialogs::XDialogClosedListener >& xListener)
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 });
91 void PDFDialog::executedAsyncDialog( std::shared_ptr<SfxTabDialogController> xAsyncDialog, sal_Int32 nExecutionResult )
93 if (nExecutionResult && xAsyncDialog)
94 maFilterData = static_cast<ImpPDFTabDialog*>(xAsyncDialog.get())->GetFilterData();
97 Reference< XPropertySetInfo > SAL_CALL PDFDialog::getPropertySetInfo()
99 Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
100 return xInfo;
103 ::cppu::IPropertyArrayHelper& PDFDialog::getInfoHelper()
105 return *getArrayHelper();
108 ::cppu::IPropertyArrayHelper* PDFDialog::createArrayHelper() const
110 Sequence< Property > aProps;
111 describeProperties(aProps);
112 return new ::cppu::OPropertyArrayHelper( aProps );
116 Sequence< PropertyValue > SAL_CALL PDFDialog::getPropertyValues()
118 sal_Int32 i, nCount;
120 for( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
122 if ( maMediaDescriptor[ i ].Name == "FilterData" )
123 break;
126 if( i == nCount )
127 maMediaDescriptor.realloc( ++nCount );
128 auto pMediaDescriptor = maMediaDescriptor.getArray();
130 pMediaDescriptor[ i ].Name = "FilterData";
131 pMediaDescriptor[ i ].Value <<= maFilterData;
133 return maMediaDescriptor;
137 void SAL_CALL PDFDialog::setPropertyValues( const Sequence< PropertyValue >& rProps )
139 maMediaDescriptor = rProps;
141 for (const PropertyValue& rProp : maMediaDescriptor)
143 if ( rProp.Name == "FilterData" )
145 rProp.Value >>= maFilterData;
146 break;
152 void SAL_CALL PDFDialog::setSourceDocument( const Reference< XComponent >& xDoc )
154 mxSrcDoc = xDoc;
157 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
158 filter_PDFDialog_get_implementation(
159 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
161 return cppu::acquire(new PDFDialog(context));
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */