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 <osl/file.hxx>
22 #include <osl/module.hxx>
23 #include <com/sun/star/frame/XModel.hpp>
24 #include <com/sun/star/document/XViewDataSupplier.hpp>
25 #include <com/sun/star/container/XIndexAccess.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/uno/Sequence.h>
28 #include <com/sun/star/uno/Any.h>
29 #include <com/sun/star/lang/XInitialization.hpp>
30 #include <com/sun/star/beans/XPropertyAccess.hpp>
31 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
32 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
33 #include <com/sun/star/document/XExporter.hpp>
34 #include <cppuhelper/implbase5.hxx>
35 #include <vcl/svapp.hxx>
37 using namespace com::sun::star::uno
;
38 using namespace com::sun::star::lang
;
39 using namespace com::sun::star::document
;
40 using namespace com::sun::star::beans
;
41 using namespace com::sun::star::container
;
42 using namespace com::sun::star::frame
;
43 using namespace com::sun::star::ui::dialogs
;
46 #include "sdabstdlg.hxx"
47 class SdHtmlOptionsDialog
: public cppu::WeakImplHelper5
56 Sequence
< PropertyValue
> maMediaDescriptor
;
57 Sequence
< PropertyValue
> maFilterDataSequence
;
58 OUString aDialogTitle
;
59 DocumentType meDocType
;
63 SdHtmlOptionsDialog();
64 ~SdHtmlOptionsDialog();
67 virtual void SAL_CALL
acquire() throw();
68 virtual void SAL_CALL
release() throw();
71 virtual void SAL_CALL
initialize( const Sequence
< Any
> & aArguments
) throw ( Exception
, RuntimeException
);
74 virtual OUString SAL_CALL
getImplementationName() throw ( RuntimeException
);
75 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw ( RuntimeException
);
76 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() throw ( RuntimeException
);
79 virtual Sequence
< PropertyValue
> SAL_CALL
getPropertyValues() throw ( RuntimeException
);
80 virtual void SAL_CALL
setPropertyValues( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> & aProps
)
81 throw ( ::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
,
82 ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
,
83 ::com::sun::star::uno::RuntimeException
);
86 virtual sal_Int16 SAL_CALL
execute()
87 throw ( com::sun::star::uno::RuntimeException
);
88 virtual void SAL_CALL
setTitle( const OUString
& aTitle
)
89 throw ( ::com::sun::star::uno::RuntimeException
);
92 virtual void SAL_CALL
setSourceDocument( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
>& xDoc
)
93 throw ( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
97 // -------------------------
98 // - SdHtmlOptionsDialog -
99 // -------------------------
101 Reference
< XInterface
>
102 SAL_CALL
SdHtmlOptionsDialog_CreateInstance(
103 SAL_UNUSED_PARAMETER
const Reference
< XMultiServiceFactory
> & )
105 return static_cast< ::cppu::OWeakObject
* > ( new SdHtmlOptionsDialog
);
108 OUString
SdHtmlOptionsDialog_getImplementationName()
109 throw( RuntimeException
)
111 return OUString( "com.sun.star.comp.draw.SdHtmlOptionsDialog" );
114 sal_Bool SAL_CALL
SdHtmlOptionsDialog_supportsService( const OUString
& ServiceName
)
115 throw( RuntimeException
)
117 return ServiceName
.equals("com.sun.star.ui.dialog.FilterOptionsDialog");
120 Sequence
< OUString
> SAL_CALL
SdHtmlOptionsDialog_getSupportedServiceNames()
121 throw( RuntimeException
)
123 Sequence
< OUString
> aRet(1);
124 OUString
* pArray
= aRet
.getArray();
125 pArray
[0] = OUString("com.sun.star.ui.dialog.FilterOptionsDialog");
129 // -----------------------------------------------------------------------------
131 SdHtmlOptionsDialog::SdHtmlOptionsDialog() :
132 meDocType ( DOCUMENT_TYPE_DRAW
)
136 // -----------------------------------------------------------------------------
138 SdHtmlOptionsDialog::~SdHtmlOptionsDialog()
142 // -----------------------------------------------------------------------------
144 void SAL_CALL
SdHtmlOptionsDialog::acquire() throw()
146 OWeakObject::acquire();
149 // -----------------------------------------------------------------------------
151 void SAL_CALL
SdHtmlOptionsDialog::release() throw()
153 OWeakObject::release();
157 void SAL_CALL
SdHtmlOptionsDialog::initialize( const Sequence
< Any
> & )
158 throw ( Exception
, RuntimeException
)
163 OUString SAL_CALL
SdHtmlOptionsDialog::getImplementationName()
164 throw( RuntimeException
)
166 return SdHtmlOptionsDialog_getImplementationName();
168 sal_Bool SAL_CALL
SdHtmlOptionsDialog::supportsService( const OUString
& rServiceName
)
169 throw( RuntimeException
)
171 return SdHtmlOptionsDialog_supportsService( rServiceName
);
173 Sequence
< OUString
> SAL_CALL
SdHtmlOptionsDialog::getSupportedServiceNames()
174 throw ( RuntimeException
)
176 return SdHtmlOptionsDialog_getSupportedServiceNames();
181 Sequence
< PropertyValue
> SdHtmlOptionsDialog::getPropertyValues()
182 throw ( RuntimeException
)
185 for ( i
= 0, nCount
= maMediaDescriptor
.getLength(); i
< nCount
; i
++ )
187 if ( maMediaDescriptor
[ i
].Name
== "FilterData" )
191 maMediaDescriptor
.realloc( ++nCount
);
193 // the "FilterData" Property is an Any that will contain our PropertySequence of Values
194 maMediaDescriptor
[ i
].Name
= "FilterData";
195 maMediaDescriptor
[ i
].Value
<<= maFilterDataSequence
;
196 return maMediaDescriptor
;
199 void SdHtmlOptionsDialog::setPropertyValues( const Sequence
< PropertyValue
> & aProps
)
200 throw ( UnknownPropertyException
, PropertyVetoException
,
201 IllegalArgumentException
, WrappedTargetException
,
204 maMediaDescriptor
= aProps
;
207 for ( i
= 0, nCount
= maMediaDescriptor
.getLength(); i
< nCount
; i
++ )
209 if ( maMediaDescriptor
[ i
].Name
== "FilterData" )
211 maMediaDescriptor
[ i
].Value
>>= maFilterDataSequence
;
218 void SdHtmlOptionsDialog::setTitle( const OUString
& aTitle
)
219 throw ( RuntimeException
)
221 aDialogTitle
= aTitle
;
224 sal_Int16
SdHtmlOptionsDialog::execute()
225 throw ( RuntimeException
)
227 sal_Int16 nRet
= ExecutableDialogResults::CANCEL
;
229 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
232 AbstractSdPublishingDlg
* pDlg
= pFact
->CreateSdPublishingDlg( Application::GetDefDialogParent(), meDocType
);
235 if( pDlg
->Execute() )
237 pDlg
->GetParameterSequence( maFilterDataSequence
);
238 nRet
= ExecutableDialogResults::OK
;
242 nRet
= ExecutableDialogResults::CANCEL
;
251 void SdHtmlOptionsDialog::setSourceDocument( const Reference
< XComponent
>& xDoc
)
252 throw ( IllegalArgumentException
, RuntimeException
)
254 // try to set the corresponding metric unit
255 Reference
< XServiceInfo
> xServiceInfo(xDoc
, UNO_QUERY
);
256 if ( xServiceInfo
.is() )
258 if ( xServiceInfo
->supportsService( "com.sun.star.presentation.PresentationDocument" ) )
260 meDocType
= DOCUMENT_TYPE_IMPRESS
;
263 else if ( xServiceInfo
->supportsService( "com.sun.star.drawing.DrawingDocument" ) )
265 meDocType
= DOCUMENT_TYPE_DRAW
;
269 throw IllegalArgumentException();
272 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */