LibreOffice Module sd (master) 1
HtmlOptionsDialog.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#include <com/sun/star/lang/XServiceInfo.hpp>
21#include <com/sun/star/uno/Sequence.h>
22#include <com/sun/star/uno/Any.h>
23#include <com/sun/star/lang/XInitialization.hpp>
24#include <com/sun/star/beans/XPropertyAccess.hpp>
25#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
26#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
27#include <com/sun/star/document/XExporter.hpp>
30#include <vcl/svapp.hxx>
31
32using namespace com::sun::star::uno;
33using namespace com::sun::star::lang;
34using namespace com::sun::star::document;
35using namespace com::sun::star::beans;
36using namespace com::sun::star::ui::dialogs;
37
38#include <pres.hxx>
39#include <sdabstdlg.hxx>
40
41namespace {
42
43class SdHtmlOptionsDialog : public cppu::WeakImplHelper
44<
45 XExporter,
46 XExecutableDialog,
47 XPropertyAccess,
48 XInitialization,
49 XServiceInfo
50>
51{
52 Sequence< PropertyValue > maMediaDescriptor;
53 Sequence< PropertyValue > maFilterDataSequence;
54 DocumentType meDocType;
55
56public:
57
58 SdHtmlOptionsDialog();
59
60 // XInterface
61 virtual void SAL_CALL acquire() noexcept override;
62 virtual void SAL_CALL release() noexcept override;
63
64 // XInitialization
65 virtual void SAL_CALL initialize( const Sequence< Any > & aArguments ) override;
66
67 // XServiceInfo
68 virtual OUString SAL_CALL getImplementationName() override;
69 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
70 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
71
72 // XPropertyAccess
73 virtual Sequence< PropertyValue > SAL_CALL getPropertyValues() override;
74 virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue > & aProps ) override;
75
76 // XExecuteDialog
77 virtual sal_Int16 SAL_CALL execute() override;
78 virtual void SAL_CALL setTitle( const OUString& aTitle ) override;
79
80 // XExporter
81 virtual void SAL_CALL setSourceDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
82
83};
84
85}
86
87SdHtmlOptionsDialog::SdHtmlOptionsDialog() :
88 meDocType ( DocumentType::Draw )
89{
90}
91
92void SAL_CALL SdHtmlOptionsDialog::acquire() noexcept
93{
94 OWeakObject::acquire();
95}
96
97void SAL_CALL SdHtmlOptionsDialog::release() noexcept
98{
99 OWeakObject::release();
100}
101
102// XInitialization
103void SAL_CALL SdHtmlOptionsDialog::initialize( const Sequence< Any > & )
104{
105}
106
107// XServiceInfo
108OUString SAL_CALL SdHtmlOptionsDialog::getImplementationName()
109{
110 return "com.sun.star.comp.draw.SdHtmlOptionsDialog";
111}
112
113sal_Bool SAL_CALL SdHtmlOptionsDialog::supportsService( const OUString& rServiceName )
114{
115 return cppu::supportsService(this, rServiceName);
116}
117
118Sequence< OUString > SAL_CALL SdHtmlOptionsDialog::getSupportedServiceNames()
119{
120 return { "com.sun.star.ui.dialog.FilterOptionsDialog" };
121}
122
123// XPropertyAccess
124Sequence< PropertyValue > SdHtmlOptionsDialog::getPropertyValues()
125{
126 auto pProp = std::find_if(std::cbegin(maMediaDescriptor), std::cend(maMediaDescriptor),
127 [](const PropertyValue& rProp) { return rProp.Name == "FilterData"; });
128 auto i = static_cast<sal_Int32>(std::distance(std::cbegin(maMediaDescriptor), pProp));
129 sal_Int32 nCount = maMediaDescriptor.getLength();
130 if ( i == nCount )
131 maMediaDescriptor.realloc( ++nCount );
132
133 // the "FilterData" Property is an Any that will contain our PropertySequence of Values
134 auto& el = maMediaDescriptor.getArray()[ i ];
135 el.Name = "FilterData";
136 el.Value <<= maFilterDataSequence;
137 return maMediaDescriptor;
138}
139
140void SdHtmlOptionsDialog::setPropertyValues( const Sequence< PropertyValue > & aProps )
141{
142 maMediaDescriptor = aProps;
143
144 auto pProp = std::find_if(std::cbegin(maMediaDescriptor), std::cend(maMediaDescriptor),
145 [](const PropertyValue& rProp) { return rProp.Name == "FilterData"; });
146 if (pProp != std::cend(maMediaDescriptor))
147 pProp->Value >>= maFilterDataSequence;
148}
149
150// XExecutableDialog
151void SdHtmlOptionsDialog::setTitle( const OUString& )
152{
153}
154
155sal_Int16 SdHtmlOptionsDialog::execute()
156{
157 sal_Int16 nRet = ExecutableDialogResults::CANCEL;
158
160 ScopedVclPtr<AbstractSdPublishingDlg> pDlg(pFact->CreateSdPublishingDlg(nullptr /*TODO*/, meDocType));
161 if( pDlg->Execute() )
162 {
163 pDlg->GetParameterSequence( maFilterDataSequence );
164 nRet = ExecutableDialogResults::OK;
165 }
166 else
167 {
168 nRet = ExecutableDialogResults::CANCEL;
169 }
170 return nRet;
171}
172
173// XEmporter
174void SdHtmlOptionsDialog::setSourceDocument( const Reference< XComponent >& xDoc )
175{
176 // try to set the corresponding metric unit
177 Reference< XServiceInfo > xServiceInfo(xDoc, UNO_QUERY);
178 if ( xServiceInfo.is() )
179 {
180 if ( xServiceInfo->supportsService( "com.sun.star.presentation.PresentationDocument" ) )
181 {
182 meDocType = DocumentType::Impress;
183 return;
184 }
185 else if ( xServiceInfo->supportsService( "com.sun.star.drawing.DrawingDocument" ) )
186 {
187 meDocType = DocumentType::Draw;
188 return;
189 }
190 }
191 throw IllegalArgumentException();
192}
193
194
195extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
197 css::uno::Sequence<css::uno::Any> const &)
198{
199 return cppu::acquire(new SdHtmlOptionsDialog());
200}
201
202
203/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_draw_SdHtmlOptionsDialog_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
virtual VclPtr< AbstractSdPublishingDlg > CreateSdPublishingDlg(weld::Window *pWindow, DocumentType eDocType)=0
static SD_DLLPUBLIC SdAbstractDialogFactory * Create()
Definition: sdabstdlg.cxx:38
int nCount
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
int i
DocumentType
unsigned char sal_Bool