1*5b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*5b190011SAndrew Rist * distributed with this work for additional information
6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance
9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at
10*5b190011SAndrew Rist *
11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*5b190011SAndrew Rist *
13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*5b190011SAndrew Rist * software distributed under the License is distributed on an
15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the
17*5b190011SAndrew Rist * specific language governing permissions and limitations
18*5b190011SAndrew Rist * under the License.
19*5b190011SAndrew Rist *
20*5b190011SAndrew Rist *************************************************************/
21*5b190011SAndrew Rist
22*5b190011SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir
25cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
26cdf0e10cSrcweir #include "precompiled_sd.hxx"
27cdf0e10cSrcweir #include <osl/file.hxx>
28cdf0e10cSrcweir #include <vos/module.hxx>
29cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp>
30cdf0e10cSrcweir #include <com/sun/star/document/XViewDataSupplier.hpp>
31cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
32cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
33cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.h>
34cdf0e10cSrcweir #include <com/sun/star/uno/Any.h>
35cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
36cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
37cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyAccess.hpp>
38cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
39cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
40cdf0e10cSrcweir #include <com/sun/star/document/XExporter.hpp>
41cdf0e10cSrcweir #include <cppuhelper/implbase5.hxx>
42cdf0e10cSrcweir #include <vcl/svapp.hxx>
43cdf0e10cSrcweir
44cdf0e10cSrcweir using namespace com::sun::star::uno;
45cdf0e10cSrcweir using namespace com::sun::star::lang;
46cdf0e10cSrcweir using namespace com::sun::star::document;
47cdf0e10cSrcweir using namespace com::sun::star::beans;
48cdf0e10cSrcweir using namespace com::sun::star::container;
49cdf0e10cSrcweir using namespace com::sun::star::frame;
50cdf0e10cSrcweir using namespace com::sun::star::ui::dialogs;
51cdf0e10cSrcweir
52cdf0e10cSrcweir #include "pres.hxx"
53cdf0e10cSrcweir #include "sdabstdlg.hxx"
54cdf0e10cSrcweir #include "tools/debug.hxx"
55cdf0e10cSrcweir class SdHtmlOptionsDialog : public cppu::WeakImplHelper5
56cdf0e10cSrcweir <
57cdf0e10cSrcweir XExporter,
58cdf0e10cSrcweir XExecutableDialog,
59cdf0e10cSrcweir XPropertyAccess,
60cdf0e10cSrcweir XInitialization,
61cdf0e10cSrcweir XServiceInfo
62cdf0e10cSrcweir >
63cdf0e10cSrcweir {
64cdf0e10cSrcweir const Reference< XMultiServiceFactory > &mrxMgr;
65cdf0e10cSrcweir Sequence< PropertyValue > maMediaDescriptor;
66cdf0e10cSrcweir Sequence< PropertyValue > maFilterDataSequence;
67cdf0e10cSrcweir ::rtl::OUString aDialogTitle;
68cdf0e10cSrcweir DocumentType meDocType;
69cdf0e10cSrcweir
70cdf0e10cSrcweir public:
71cdf0e10cSrcweir
72cdf0e10cSrcweir SdHtmlOptionsDialog( const Reference< XMultiServiceFactory >& _rxORB );
73cdf0e10cSrcweir ~SdHtmlOptionsDialog();
74cdf0e10cSrcweir
75cdf0e10cSrcweir // XInterface
76cdf0e10cSrcweir virtual void SAL_CALL acquire() throw();
77cdf0e10cSrcweir virtual void SAL_CALL release() throw();
78cdf0e10cSrcweir
79cdf0e10cSrcweir // XInitialization
80cdf0e10cSrcweir virtual void SAL_CALL initialize( const Sequence< Any > & aArguments ) throw ( Exception, RuntimeException );
81cdf0e10cSrcweir
82cdf0e10cSrcweir // XServiceInfo
83cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName() throw ( RuntimeException );
84cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw ( RuntimeException );
85cdf0e10cSrcweir virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw ( RuntimeException );
86cdf0e10cSrcweir
87cdf0e10cSrcweir // XPropertyAccess
88cdf0e10cSrcweir virtual Sequence< PropertyValue > SAL_CALL getPropertyValues() throw ( RuntimeException );
89cdf0e10cSrcweir virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & aProps )
90cdf0e10cSrcweir throw ( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException,
91cdf0e10cSrcweir ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException,
92cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException );
93cdf0e10cSrcweir
94cdf0e10cSrcweir // XExecuteDialog
95cdf0e10cSrcweir virtual sal_Int16 SAL_CALL execute()
96cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException );
97cdf0e10cSrcweir virtual void SAL_CALL setTitle( const ::rtl::OUString& aTitle )
98cdf0e10cSrcweir throw ( ::com::sun::star::uno::RuntimeException );
99cdf0e10cSrcweir
100cdf0e10cSrcweir // XExporter
101cdf0e10cSrcweir virtual void SAL_CALL setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
102cdf0e10cSrcweir throw ( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
103cdf0e10cSrcweir
104cdf0e10cSrcweir };
105cdf0e10cSrcweir
106cdf0e10cSrcweir // -------------------------
107cdf0e10cSrcweir // - SdHtmlOptionsDialog -
108cdf0e10cSrcweir // -------------------------
109cdf0e10cSrcweir
110cdf0e10cSrcweir Reference< XInterface >
SdHtmlOptionsDialog_CreateInstance(const Reference<XMultiServiceFactory> & _rxFactory)111cdf0e10cSrcweir SAL_CALL SdHtmlOptionsDialog_CreateInstance(
112cdf0e10cSrcweir const Reference< XMultiServiceFactory > & _rxFactory )
113cdf0e10cSrcweir {
114cdf0e10cSrcweir return static_cast< ::cppu::OWeakObject* > ( new SdHtmlOptionsDialog( _rxFactory ) );
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
SdHtmlOptionsDialog_getImplementationName()117cdf0e10cSrcweir ::rtl::OUString SdHtmlOptionsDialog_getImplementationName()
118cdf0e10cSrcweir throw( RuntimeException )
119cdf0e10cSrcweir {
120cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.draw.SdHtmlOptionsDialog" ) );
121cdf0e10cSrcweir }
122cdf0e10cSrcweir #define SERVICE_NAME "com.sun.star.ui.dialog.FilterOptionsDialog"
SdHtmlOptionsDialog_supportsService(const::rtl::OUString & ServiceName)123cdf0e10cSrcweir sal_Bool SAL_CALL SdHtmlOptionsDialog_supportsService( const ::rtl::OUString& ServiceName )
124cdf0e10cSrcweir throw( RuntimeException )
125cdf0e10cSrcweir {
126cdf0e10cSrcweir return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SERVICE_NAME ) );
127cdf0e10cSrcweir }
128cdf0e10cSrcweir
SdHtmlOptionsDialog_getSupportedServiceNames()129cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL SdHtmlOptionsDialog_getSupportedServiceNames()
130cdf0e10cSrcweir throw( RuntimeException )
131cdf0e10cSrcweir {
132cdf0e10cSrcweir Sequence< ::rtl::OUString > aRet(1);
133cdf0e10cSrcweir ::rtl::OUString* pArray = aRet.getArray();
134cdf0e10cSrcweir pArray[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) );
135cdf0e10cSrcweir return aRet;
136cdf0e10cSrcweir }
137cdf0e10cSrcweir #undef SERVICE_NAME
138cdf0e10cSrcweir
139cdf0e10cSrcweir // -----------------------------------------------------------------------------
140cdf0e10cSrcweir
SdHtmlOptionsDialog(const Reference<XMultiServiceFactory> & xMgr)141cdf0e10cSrcweir SdHtmlOptionsDialog::SdHtmlOptionsDialog( const Reference< XMultiServiceFactory > & xMgr ) :
142cdf0e10cSrcweir mrxMgr ( xMgr ),
143cdf0e10cSrcweir meDocType ( DOCUMENT_TYPE_DRAW )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir }
146cdf0e10cSrcweir
147cdf0e10cSrcweir // -----------------------------------------------------------------------------
148cdf0e10cSrcweir
~SdHtmlOptionsDialog()149cdf0e10cSrcweir SdHtmlOptionsDialog::~SdHtmlOptionsDialog()
150cdf0e10cSrcweir {
151cdf0e10cSrcweir }
152cdf0e10cSrcweir
153cdf0e10cSrcweir // -----------------------------------------------------------------------------
154cdf0e10cSrcweir
acquire()155cdf0e10cSrcweir void SAL_CALL SdHtmlOptionsDialog::acquire() throw()
156cdf0e10cSrcweir {
157cdf0e10cSrcweir OWeakObject::acquire();
158cdf0e10cSrcweir }
159cdf0e10cSrcweir
160cdf0e10cSrcweir // -----------------------------------------------------------------------------
161cdf0e10cSrcweir
release()162cdf0e10cSrcweir void SAL_CALL SdHtmlOptionsDialog::release() throw()
163cdf0e10cSrcweir {
164cdf0e10cSrcweir OWeakObject::release();
165cdf0e10cSrcweir }
166cdf0e10cSrcweir
167cdf0e10cSrcweir // XInitialization
initialize(const Sequence<Any> &)168cdf0e10cSrcweir void SAL_CALL SdHtmlOptionsDialog::initialize( const Sequence< Any > & )
169cdf0e10cSrcweir throw ( Exception, RuntimeException )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir }
172cdf0e10cSrcweir
173cdf0e10cSrcweir // XServiceInfo
getImplementationName()174cdf0e10cSrcweir ::rtl::OUString SAL_CALL SdHtmlOptionsDialog::getImplementationName()
175cdf0e10cSrcweir throw( RuntimeException )
176cdf0e10cSrcweir {
177cdf0e10cSrcweir return SdHtmlOptionsDialog_getImplementationName();
178cdf0e10cSrcweir }
supportsService(const::rtl::OUString & rServiceName)179cdf0e10cSrcweir sal_Bool SAL_CALL SdHtmlOptionsDialog::supportsService( const ::rtl::OUString& rServiceName )
180cdf0e10cSrcweir throw( RuntimeException )
181cdf0e10cSrcweir {
182cdf0e10cSrcweir return SdHtmlOptionsDialog_supportsService( rServiceName );
183cdf0e10cSrcweir }
getSupportedServiceNames()184cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL SdHtmlOptionsDialog::getSupportedServiceNames()
185cdf0e10cSrcweir throw ( RuntimeException )
186cdf0e10cSrcweir {
187cdf0e10cSrcweir return SdHtmlOptionsDialog_getSupportedServiceNames();
188cdf0e10cSrcweir }
189cdf0e10cSrcweir
190cdf0e10cSrcweir
191cdf0e10cSrcweir // XPropertyAccess
getPropertyValues()192cdf0e10cSrcweir Sequence< PropertyValue > SdHtmlOptionsDialog::getPropertyValues()
193cdf0e10cSrcweir throw ( RuntimeException )
194cdf0e10cSrcweir {
195cdf0e10cSrcweir sal_Int32 i, nCount;
196cdf0e10cSrcweir for ( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
197cdf0e10cSrcweir {
198cdf0e10cSrcweir if ( maMediaDescriptor[ i ].Name.equalsAscii( "FilterData" ) )
199cdf0e10cSrcweir break;
200cdf0e10cSrcweir }
201cdf0e10cSrcweir if ( i == nCount )
202cdf0e10cSrcweir maMediaDescriptor.realloc( ++nCount );
203cdf0e10cSrcweir
204cdf0e10cSrcweir // the "FilterData" Property is an Any that will contain our PropertySequence of Values
205cdf0e10cSrcweir maMediaDescriptor[ i ].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterData" ) );
206cdf0e10cSrcweir maMediaDescriptor[ i ].Value <<= maFilterDataSequence;
207cdf0e10cSrcweir return maMediaDescriptor;
208cdf0e10cSrcweir }
209cdf0e10cSrcweir
setPropertyValues(const Sequence<PropertyValue> & aProps)210cdf0e10cSrcweir void SdHtmlOptionsDialog::setPropertyValues( const Sequence< PropertyValue > & aProps )
211cdf0e10cSrcweir throw ( UnknownPropertyException, PropertyVetoException,
212cdf0e10cSrcweir IllegalArgumentException, WrappedTargetException,
213cdf0e10cSrcweir RuntimeException )
214cdf0e10cSrcweir {
215cdf0e10cSrcweir maMediaDescriptor = aProps;
216cdf0e10cSrcweir
217cdf0e10cSrcweir sal_Int32 i, nCount;
218cdf0e10cSrcweir for ( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
219cdf0e10cSrcweir {
220cdf0e10cSrcweir if ( maMediaDescriptor[ i ].Name.equalsAscii( "FilterData" ) )
221cdf0e10cSrcweir {
222cdf0e10cSrcweir maMediaDescriptor[ i ].Value >>= maFilterDataSequence;
223cdf0e10cSrcweir break;
224cdf0e10cSrcweir }
225cdf0e10cSrcweir }
226cdf0e10cSrcweir }
227cdf0e10cSrcweir
228cdf0e10cSrcweir // XExecutableDialog
setTitle(const::rtl::OUString & aTitle)229cdf0e10cSrcweir void SdHtmlOptionsDialog::setTitle( const ::rtl::OUString& aTitle )
230cdf0e10cSrcweir throw ( RuntimeException )
231cdf0e10cSrcweir {
232cdf0e10cSrcweir aDialogTitle = aTitle;
233cdf0e10cSrcweir }
234cdf0e10cSrcweir
execute()235cdf0e10cSrcweir sal_Int16 SdHtmlOptionsDialog::execute()
236cdf0e10cSrcweir throw ( RuntimeException )
237cdf0e10cSrcweir {
238cdf0e10cSrcweir sal_Int16 nRet = ExecutableDialogResults::CANCEL;
239cdf0e10cSrcweir
240cdf0e10cSrcweir SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
241cdf0e10cSrcweir if( pFact )
242cdf0e10cSrcweir {
243cdf0e10cSrcweir AbstractSdPublishingDlg* pDlg = pFact->CreateSdPublishingDlg( Application::GetDefDialogParent(), meDocType );
244cdf0e10cSrcweir if( pDlg )
245cdf0e10cSrcweir {
246cdf0e10cSrcweir if( pDlg->Execute() )
247cdf0e10cSrcweir {
248cdf0e10cSrcweir pDlg->GetParameterSequence( maFilterDataSequence );
249cdf0e10cSrcweir nRet = ExecutableDialogResults::OK;
250cdf0e10cSrcweir }
251cdf0e10cSrcweir else
252cdf0e10cSrcweir {
253cdf0e10cSrcweir nRet = ExecutableDialogResults::CANCEL;
254cdf0e10cSrcweir }
255cdf0e10cSrcweir delete pDlg;
256cdf0e10cSrcweir }
257cdf0e10cSrcweir }
258cdf0e10cSrcweir return nRet;
259cdf0e10cSrcweir }
260cdf0e10cSrcweir
261cdf0e10cSrcweir // XEmporter
setSourceDocument(const Reference<XComponent> & xDoc)262cdf0e10cSrcweir void SdHtmlOptionsDialog::setSourceDocument( const Reference< XComponent >& xDoc )
263cdf0e10cSrcweir throw ( IllegalArgumentException, RuntimeException )
264cdf0e10cSrcweir {
265cdf0e10cSrcweir // try to set the corresponding metric unit
266cdf0e10cSrcweir String aConfigPath;
267cdf0e10cSrcweir Reference< XServiceInfo > xServiceInfo
268cdf0e10cSrcweir ( xDoc, UNO_QUERY );
269cdf0e10cSrcweir if ( xServiceInfo.is() )
270cdf0e10cSrcweir {
271cdf0e10cSrcweir if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.PresentationDocument" ) ) ) )
272cdf0e10cSrcweir {
273cdf0e10cSrcweir meDocType = DOCUMENT_TYPE_IMPRESS;
274cdf0e10cSrcweir return;
275cdf0e10cSrcweir }
276cdf0e10cSrcweir else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.DrawingDocument" ) ) ) )
277cdf0e10cSrcweir {
278cdf0e10cSrcweir meDocType = DOCUMENT_TYPE_DRAW;
279cdf0e10cSrcweir return;
280cdf0e10cSrcweir }
281cdf0e10cSrcweir }
282cdf0e10cSrcweir throw IllegalArgumentException();
283cdf0e10cSrcweir }
284