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 <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>
28 #include <cppuhelper/implbase.hxx>
29 #include <cppuhelper/supportsservice.hxx>
30 #include <vcl/svapp.hxx>
32 using namespace com::sun::star::uno
;
33 using namespace com::sun::star::lang
;
34 using namespace com::sun::star::document
;
35 using namespace com::sun::star::beans
;
36 using namespace com::sun::star::ui::dialogs
;
39 #include <sdabstdlg.hxx>
41 class SdHtmlOptionsDialog
: public cppu::WeakImplHelper
50 Sequence
< PropertyValue
> maMediaDescriptor
;
51 Sequence
< PropertyValue
> maFilterDataSequence
;
52 DocumentType meDocType
;
56 SdHtmlOptionsDialog();
59 virtual void SAL_CALL
acquire() throw() override
;
60 virtual void SAL_CALL
release() throw() override
;
63 virtual void SAL_CALL
initialize( const Sequence
< Any
> & aArguments
) override
;
66 virtual OUString SAL_CALL
getImplementationName() override
;
67 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
68 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
71 virtual Sequence
< PropertyValue
> SAL_CALL
getPropertyValues() override
;
72 virtual void SAL_CALL
setPropertyValues( const css::uno::Sequence
< css::beans::PropertyValue
> & aProps
) override
;
75 virtual sal_Int16 SAL_CALL
execute() override
;
76 virtual void SAL_CALL
setTitle( const OUString
& aTitle
) override
;
79 virtual void SAL_CALL
setSourceDocument( const css::uno::Reference
< css::lang::XComponent
>& xDoc
) override
;
83 SdHtmlOptionsDialog::SdHtmlOptionsDialog() :
84 meDocType ( DocumentType::Draw
)
88 void SAL_CALL
SdHtmlOptionsDialog::acquire() throw()
90 OWeakObject::acquire();
93 void SAL_CALL
SdHtmlOptionsDialog::release() throw()
95 OWeakObject::release();
99 void SAL_CALL
SdHtmlOptionsDialog::initialize( const Sequence
< Any
> & )
104 OUString SAL_CALL
SdHtmlOptionsDialog::getImplementationName()
106 return OUString( "com.sun.star.comp.draw.SdHtmlOptionsDialog" );
109 sal_Bool SAL_CALL
SdHtmlOptionsDialog::supportsService( const OUString
& rServiceName
)
111 return cppu::supportsService(this, rServiceName
);
114 Sequence
< OUString
> SAL_CALL
SdHtmlOptionsDialog::getSupportedServiceNames()
116 Sequence
< OUString
> aRet
{ "com.sun.star.ui.dialog.FilterOptionsDialog" };
121 Sequence
< PropertyValue
> SdHtmlOptionsDialog::getPropertyValues()
124 for ( i
= 0, nCount
= maMediaDescriptor
.getLength(); i
< nCount
; i
++ )
126 if ( maMediaDescriptor
[ i
].Name
== "FilterData" )
130 maMediaDescriptor
.realloc( ++nCount
);
132 // the "FilterData" Property is an Any that will contain our PropertySequence of Values
133 maMediaDescriptor
[ i
].Name
= "FilterData";
134 maMediaDescriptor
[ i
].Value
<<= maFilterDataSequence
;
135 return maMediaDescriptor
;
138 void SdHtmlOptionsDialog::setPropertyValues( const Sequence
< PropertyValue
> & aProps
)
140 maMediaDescriptor
= aProps
;
143 for ( i
= 0, nCount
= maMediaDescriptor
.getLength(); i
< nCount
; i
++ )
145 if ( maMediaDescriptor
[ i
].Name
== "FilterData" )
147 maMediaDescriptor
[ i
].Value
>>= maFilterDataSequence
;
154 void SdHtmlOptionsDialog::setTitle( const OUString
& )
158 sal_Int16
SdHtmlOptionsDialog::execute()
160 sal_Int16 nRet
= ExecutableDialogResults::CANCEL
;
162 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
163 ScopedVclPtr
<AbstractSdPublishingDlg
> pDlg(pFact
->CreateSdPublishingDlg( Application::GetDefDialogParent(), meDocType
));
164 if( pDlg
->Execute() )
166 pDlg
->GetParameterSequence( maFilterDataSequence
);
167 nRet
= ExecutableDialogResults::OK
;
171 nRet
= ExecutableDialogResults::CANCEL
;
177 void SdHtmlOptionsDialog::setSourceDocument( const Reference
< XComponent
>& xDoc
)
179 // try to set the corresponding metric unit
180 Reference
< XServiceInfo
> xServiceInfo(xDoc
, UNO_QUERY
);
181 if ( xServiceInfo
.is() )
183 if ( xServiceInfo
->supportsService( "com.sun.star.presentation.PresentationDocument" ) )
185 meDocType
= DocumentType::Impress
;
188 else if ( xServiceInfo
->supportsService( "com.sun.star.drawing.DrawingDocument" ) )
190 meDocType
= DocumentType::Draw
;
194 throw IllegalArgumentException();
198 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
199 com_sun_star_comp_draw_SdHtmlOptionsDialog_get_implementation(css::uno::XComponentContext
*,
200 css::uno::Sequence
<css::uno::Any
> const &)
202 return cppu::acquire(new SdHtmlOptionsDialog());
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */