Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <osl/file.hxx>
31 : : #include <osl/module.hxx>
32 : : #include <com/sun/star/frame/XModel.hpp>
33 : : #include <com/sun/star/document/XViewDataSupplier.hpp>
34 : : #include <com/sun/star/container/XIndexAccess.hpp>
35 : : #include <com/sun/star/lang/XServiceInfo.hpp>
36 : : #include <com/sun/star/uno/Sequence.h>
37 : : #include <com/sun/star/uno/Any.h>
38 : : #include <com/sun/star/lang/XInitialization.hpp>
39 : : #include <com/sun/star/beans/XPropertyAccess.hpp>
40 : : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
41 : : #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
42 : : #include <com/sun/star/document/XExporter.hpp>
43 : : #include <cppuhelper/implbase5.hxx>
44 : : #include <vcl/svapp.hxx>
45 : :
46 : : using namespace com::sun::star::uno;
47 : : using namespace com::sun::star::lang;
48 : : using namespace com::sun::star::document;
49 : : using namespace com::sun::star::beans;
50 : : using namespace com::sun::star::container;
51 : : using namespace com::sun::star::frame;
52 : : using namespace com::sun::star::ui::dialogs;
53 : :
54 : : #include "pres.hxx"
55 : : #include "sdabstdlg.hxx"
56 : : class SdHtmlOptionsDialog : public cppu::WeakImplHelper5
57 : : <
58 : : XExporter,
59 : : XExecutableDialog,
60 : : XPropertyAccess,
61 : : XInitialization,
62 : : XServiceInfo
63 : : >
64 : : {
65 : : const Reference< XMultiServiceFactory > &mrxMgr;
66 : : Sequence< PropertyValue > maMediaDescriptor;
67 : : Sequence< PropertyValue > maFilterDataSequence;
68 : : ::rtl::OUString aDialogTitle;
69 : : DocumentType meDocType;
70 : :
71 : : public:
72 : :
73 : : SdHtmlOptionsDialog( const Reference< XMultiServiceFactory >& _rxORB );
74 : : ~SdHtmlOptionsDialog();
75 : :
76 : : // XInterface
77 : : virtual void SAL_CALL acquire() throw();
78 : : virtual void SAL_CALL release() throw();
79 : :
80 : : // XInitialization
81 : : virtual void SAL_CALL initialize( const Sequence< Any > & aArguments ) throw ( Exception, RuntimeException );
82 : :
83 : : // XServiceInfo
84 : : virtual ::rtl::OUString SAL_CALL getImplementationName() throw ( RuntimeException );
85 : : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw ( RuntimeException );
86 : : virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw ( RuntimeException );
87 : :
88 : : // XPropertyAccess
89 : : virtual Sequence< PropertyValue > SAL_CALL getPropertyValues() throw ( RuntimeException );
90 : : virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & aProps )
91 : : throw ( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException,
92 : : ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException,
93 : : ::com::sun::star::uno::RuntimeException );
94 : :
95 : : // XExecuteDialog
96 : : virtual sal_Int16 SAL_CALL execute()
97 : : throw ( com::sun::star::uno::RuntimeException );
98 : : virtual void SAL_CALL setTitle( const ::rtl::OUString& aTitle )
99 : : throw ( ::com::sun::star::uno::RuntimeException );
100 : :
101 : : // XExporter
102 : : virtual void SAL_CALL setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
103 : : throw ( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
104 : :
105 : : };
106 : :
107 : : // -------------------------
108 : : // - SdHtmlOptionsDialog -
109 : : // -------------------------
110 : :
111 : : Reference< XInterface >
112 : 0 : SAL_CALL SdHtmlOptionsDialog_CreateInstance(
113 : : const Reference< XMultiServiceFactory > & _rxFactory )
114 : : {
115 [ # # ]: 0 : return static_cast< ::cppu::OWeakObject* > ( new SdHtmlOptionsDialog( _rxFactory ) );
116 : : }
117 : :
118 : 22 : ::rtl::OUString SdHtmlOptionsDialog_getImplementationName()
119 : : throw( RuntimeException )
120 : : {
121 : 22 : return ::rtl::OUString( "com.sun.star.comp.draw.SdHtmlOptionsDialog" );
122 : : }
123 : :
124 : 0 : sal_Bool SAL_CALL SdHtmlOptionsDialog_supportsService( const ::rtl::OUString& ServiceName )
125 : : throw( RuntimeException )
126 : : {
127 : 0 : return ServiceName.equals("com.sun.star.ui.dialog.FilterOptionsDialog");
128 : : }
129 : :
130 : 0 : Sequence< ::rtl::OUString > SAL_CALL SdHtmlOptionsDialog_getSupportedServiceNames()
131 : : throw( RuntimeException )
132 : : {
133 : 0 : Sequence< ::rtl::OUString > aRet(1);
134 [ # # ]: 0 : ::rtl::OUString* pArray = aRet.getArray();
135 : 0 : pArray[0] = ::rtl::OUString("com.sun.star.ui.dialog.FilterOptionsDialog");
136 : 0 : return aRet;
137 : : }
138 : :
139 : : // -----------------------------------------------------------------------------
140 : :
141 : 0 : SdHtmlOptionsDialog::SdHtmlOptionsDialog( const Reference< XMultiServiceFactory > & xMgr ) :
142 : : mrxMgr ( xMgr ),
143 [ # # ][ # # ]: 0 : meDocType ( DOCUMENT_TYPE_DRAW )
144 : : {
145 : 0 : }
146 : :
147 : : // -----------------------------------------------------------------------------
148 : :
149 [ # # ][ # # ]: 0 : SdHtmlOptionsDialog::~SdHtmlOptionsDialog()
150 : : {
151 [ # # ]: 0 : }
152 : :
153 : : // -----------------------------------------------------------------------------
154 : :
155 : 0 : void SAL_CALL SdHtmlOptionsDialog::acquire() throw()
156 : : {
157 : 0 : OWeakObject::acquire();
158 : 0 : }
159 : :
160 : : // -----------------------------------------------------------------------------
161 : :
162 : 0 : void SAL_CALL SdHtmlOptionsDialog::release() throw()
163 : : {
164 : 0 : OWeakObject::release();
165 : 0 : }
166 : :
167 : : // XInitialization
168 : 0 : void SAL_CALL SdHtmlOptionsDialog::initialize( const Sequence< Any > & )
169 : : throw ( Exception, RuntimeException )
170 : : {
171 : 0 : }
172 : :
173 : : // XServiceInfo
174 : 0 : ::rtl::OUString SAL_CALL SdHtmlOptionsDialog::getImplementationName()
175 : : throw( RuntimeException )
176 : : {
177 : 0 : return SdHtmlOptionsDialog_getImplementationName();
178 : : }
179 : 0 : sal_Bool SAL_CALL SdHtmlOptionsDialog::supportsService( const ::rtl::OUString& rServiceName )
180 : : throw( RuntimeException )
181 : : {
182 : 0 : return SdHtmlOptionsDialog_supportsService( rServiceName );
183 : : }
184 : 0 : Sequence< ::rtl::OUString > SAL_CALL SdHtmlOptionsDialog::getSupportedServiceNames()
185 : : throw ( RuntimeException )
186 : : {
187 : 0 : return SdHtmlOptionsDialog_getSupportedServiceNames();
188 : : }
189 : :
190 : :
191 : : // XPropertyAccess
192 : 0 : Sequence< PropertyValue > SdHtmlOptionsDialog::getPropertyValues()
193 : : throw ( RuntimeException )
194 : : {
195 : : sal_Int32 i, nCount;
196 [ # # ]: 0 : for ( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
197 : : {
198 [ # # ]: 0 : if ( maMediaDescriptor[ i ].Name == "FilterData" )
199 : 0 : break;
200 : : }
201 [ # # ]: 0 : if ( i == nCount )
202 : 0 : maMediaDescriptor.realloc( ++nCount );
203 : :
204 : : // the "FilterData" Property is an Any that will contain our PropertySequence of Values
205 : 0 : maMediaDescriptor[ i ].Name = "FilterData";
206 : 0 : maMediaDescriptor[ i ].Value <<= maFilterDataSequence;
207 : 0 : return maMediaDescriptor;
208 : : }
209 : :
210 : 0 : void SdHtmlOptionsDialog::setPropertyValues( const Sequence< PropertyValue > & aProps )
211 : : throw ( UnknownPropertyException, PropertyVetoException,
212 : : IllegalArgumentException, WrappedTargetException,
213 : : RuntimeException )
214 : : {
215 : 0 : maMediaDescriptor = aProps;
216 : :
217 : : sal_Int32 i, nCount;
218 [ # # ]: 0 : for ( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
219 : : {
220 [ # # ]: 0 : if ( maMediaDescriptor[ i ].Name == "FilterData" )
221 : : {
222 : 0 : maMediaDescriptor[ i ].Value >>= maFilterDataSequence;
223 : 0 : break;
224 : : }
225 : : }
226 : 0 : }
227 : :
228 : : // XExecutableDialog
229 : 0 : void SdHtmlOptionsDialog::setTitle( const ::rtl::OUString& aTitle )
230 : : throw ( RuntimeException )
231 : : {
232 : 0 : aDialogTitle = aTitle;
233 : 0 : }
234 : :
235 : 0 : sal_Int16 SdHtmlOptionsDialog::execute()
236 : : throw ( RuntimeException )
237 : : {
238 : 0 : sal_Int16 nRet = ExecutableDialogResults::CANCEL;
239 : :
240 : 0 : SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
241 [ # # ]: 0 : if( pFact )
242 : : {
243 : 0 : AbstractSdPublishingDlg* pDlg = pFact->CreateSdPublishingDlg( Application::GetDefDialogParent(), meDocType );
244 [ # # ]: 0 : if( pDlg )
245 : : {
246 [ # # ]: 0 : if( pDlg->Execute() )
247 : : {
248 : 0 : pDlg->GetParameterSequence( maFilterDataSequence );
249 : 0 : nRet = ExecutableDialogResults::OK;
250 : : }
251 : : else
252 : : {
253 : 0 : nRet = ExecutableDialogResults::CANCEL;
254 : : }
255 [ # # ]: 0 : delete pDlg;
256 : : }
257 : : }
258 : 0 : return nRet;
259 : : }
260 : :
261 : : // XEmporter
262 : 0 : void SdHtmlOptionsDialog::setSourceDocument( const Reference< XComponent >& xDoc )
263 : : throw ( IllegalArgumentException, RuntimeException )
264 : : {
265 : : // try to set the corresponding metric unit
266 [ # # ]: 0 : String aConfigPath;
267 : : Reference< XServiceInfo > xServiceInfo
268 [ # # ]: 0 : ( xDoc, UNO_QUERY );
269 [ # # ]: 0 : if ( xServiceInfo.is() )
270 : : {
271 [ # # ][ # # ]: 0 : if ( xServiceInfo->supportsService( "com.sun.star.presentation.PresentationDocument" ) )
[ # # ]
272 : : {
273 : 0 : meDocType = DOCUMENT_TYPE_IMPRESS;
274 : : return;
275 : : }
276 [ # # ][ # # ]: 0 : else if ( xServiceInfo->supportsService( "com.sun.star.drawing.DrawingDocument" ) )
[ # # ]
277 : : {
278 : 0 : meDocType = DOCUMENT_TYPE_DRAW;
279 : : return;
280 : : }
281 : : }
282 [ # # ][ # # ]: 0 : throw IllegalArgumentException();
283 : : }
284 : :
285 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|