Line data Source code
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 :
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>
36 :
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;
44 :
45 : #include "pres.hxx"
46 : #include "sdabstdlg.hxx"
47 : class SdHtmlOptionsDialog : public cppu::WeakImplHelper5
48 : <
49 : XExporter,
50 : XExecutableDialog,
51 : XPropertyAccess,
52 : XInitialization,
53 : XServiceInfo
54 : >
55 : {
56 : Sequence< PropertyValue > maMediaDescriptor;
57 : Sequence< PropertyValue > maFilterDataSequence;
58 : ::rtl::OUString aDialogTitle;
59 : DocumentType meDocType;
60 :
61 : public:
62 :
63 : SdHtmlOptionsDialog();
64 : ~SdHtmlOptionsDialog();
65 :
66 : // XInterface
67 : virtual void SAL_CALL acquire() throw();
68 : virtual void SAL_CALL release() throw();
69 :
70 : // XInitialization
71 : virtual void SAL_CALL initialize( const Sequence< Any > & aArguments ) throw ( Exception, RuntimeException );
72 :
73 : // XServiceInfo
74 : virtual ::rtl::OUString SAL_CALL getImplementationName() throw ( RuntimeException );
75 : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw ( RuntimeException );
76 : virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw ( RuntimeException );
77 :
78 : // XPropertyAccess
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 );
84 :
85 : // XExecuteDialog
86 : virtual sal_Int16 SAL_CALL execute()
87 : throw ( com::sun::star::uno::RuntimeException );
88 : virtual void SAL_CALL setTitle( const ::rtl::OUString& aTitle )
89 : throw ( ::com::sun::star::uno::RuntimeException );
90 :
91 : // XExporter
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 );
94 :
95 : };
96 :
97 : // -------------------------
98 : // - SdHtmlOptionsDialog -
99 : // -------------------------
100 :
101 : Reference< XInterface >
102 0 : SAL_CALL SdHtmlOptionsDialog_CreateInstance(
103 : SAL_UNUSED_PARAMETER const Reference< XMultiServiceFactory > & )
104 : {
105 0 : return static_cast< ::cppu::OWeakObject* > ( new SdHtmlOptionsDialog );
106 : }
107 :
108 2 : ::rtl::OUString SdHtmlOptionsDialog_getImplementationName()
109 : throw( RuntimeException )
110 : {
111 2 : return ::rtl::OUString( "com.sun.star.comp.draw.SdHtmlOptionsDialog" );
112 : }
113 :
114 0 : sal_Bool SAL_CALL SdHtmlOptionsDialog_supportsService( const ::rtl::OUString& ServiceName )
115 : throw( RuntimeException )
116 : {
117 0 : return ServiceName.equals("com.sun.star.ui.dialog.FilterOptionsDialog");
118 : }
119 :
120 0 : Sequence< ::rtl::OUString > SAL_CALL SdHtmlOptionsDialog_getSupportedServiceNames()
121 : throw( RuntimeException )
122 : {
123 0 : Sequence< ::rtl::OUString > aRet(1);
124 0 : ::rtl::OUString* pArray = aRet.getArray();
125 0 : pArray[0] = ::rtl::OUString("com.sun.star.ui.dialog.FilterOptionsDialog");
126 0 : return aRet;
127 : }
128 :
129 : // -----------------------------------------------------------------------------
130 :
131 0 : SdHtmlOptionsDialog::SdHtmlOptionsDialog() :
132 0 : meDocType ( DOCUMENT_TYPE_DRAW )
133 : {
134 0 : }
135 :
136 : // -----------------------------------------------------------------------------
137 :
138 0 : SdHtmlOptionsDialog::~SdHtmlOptionsDialog()
139 : {
140 0 : }
141 :
142 : // -----------------------------------------------------------------------------
143 :
144 0 : void SAL_CALL SdHtmlOptionsDialog::acquire() throw()
145 : {
146 0 : OWeakObject::acquire();
147 0 : }
148 :
149 : // -----------------------------------------------------------------------------
150 :
151 0 : void SAL_CALL SdHtmlOptionsDialog::release() throw()
152 : {
153 0 : OWeakObject::release();
154 0 : }
155 :
156 : // XInitialization
157 0 : void SAL_CALL SdHtmlOptionsDialog::initialize( const Sequence< Any > & )
158 : throw ( Exception, RuntimeException )
159 : {
160 0 : }
161 :
162 : // XServiceInfo
163 0 : ::rtl::OUString SAL_CALL SdHtmlOptionsDialog::getImplementationName()
164 : throw( RuntimeException )
165 : {
166 0 : return SdHtmlOptionsDialog_getImplementationName();
167 : }
168 0 : sal_Bool SAL_CALL SdHtmlOptionsDialog::supportsService( const ::rtl::OUString& rServiceName )
169 : throw( RuntimeException )
170 : {
171 0 : return SdHtmlOptionsDialog_supportsService( rServiceName );
172 : }
173 0 : Sequence< ::rtl::OUString > SAL_CALL SdHtmlOptionsDialog::getSupportedServiceNames()
174 : throw ( RuntimeException )
175 : {
176 0 : return SdHtmlOptionsDialog_getSupportedServiceNames();
177 : }
178 :
179 :
180 : // XPropertyAccess
181 0 : Sequence< PropertyValue > SdHtmlOptionsDialog::getPropertyValues()
182 : throw ( RuntimeException )
183 : {
184 : sal_Int32 i, nCount;
185 0 : for ( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
186 : {
187 0 : if ( maMediaDescriptor[ i ].Name == "FilterData" )
188 0 : break;
189 : }
190 0 : if ( i == nCount )
191 0 : maMediaDescriptor.realloc( ++nCount );
192 :
193 : // the "FilterData" Property is an Any that will contain our PropertySequence of Values
194 0 : maMediaDescriptor[ i ].Name = "FilterData";
195 0 : maMediaDescriptor[ i ].Value <<= maFilterDataSequence;
196 0 : return maMediaDescriptor;
197 : }
198 :
199 0 : void SdHtmlOptionsDialog::setPropertyValues( const Sequence< PropertyValue > & aProps )
200 : throw ( UnknownPropertyException, PropertyVetoException,
201 : IllegalArgumentException, WrappedTargetException,
202 : RuntimeException )
203 : {
204 0 : maMediaDescriptor = aProps;
205 :
206 : sal_Int32 i, nCount;
207 0 : for ( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
208 : {
209 0 : if ( maMediaDescriptor[ i ].Name == "FilterData" )
210 : {
211 0 : maMediaDescriptor[ i ].Value >>= maFilterDataSequence;
212 0 : break;
213 : }
214 : }
215 0 : }
216 :
217 : // XExecutableDialog
218 0 : void SdHtmlOptionsDialog::setTitle( const ::rtl::OUString& aTitle )
219 : throw ( RuntimeException )
220 : {
221 0 : aDialogTitle = aTitle;
222 0 : }
223 :
224 0 : sal_Int16 SdHtmlOptionsDialog::execute()
225 : throw ( RuntimeException )
226 : {
227 0 : sal_Int16 nRet = ExecutableDialogResults::CANCEL;
228 :
229 0 : SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
230 0 : if( pFact )
231 : {
232 0 : AbstractSdPublishingDlg* pDlg = pFact->CreateSdPublishingDlg( Application::GetDefDialogParent(), meDocType );
233 0 : if( pDlg )
234 : {
235 0 : if( pDlg->Execute() )
236 : {
237 0 : pDlg->GetParameterSequence( maFilterDataSequence );
238 0 : nRet = ExecutableDialogResults::OK;
239 : }
240 : else
241 : {
242 0 : nRet = ExecutableDialogResults::CANCEL;
243 : }
244 0 : delete pDlg;
245 : }
246 : }
247 0 : return nRet;
248 : }
249 :
250 : // XEmporter
251 0 : void SdHtmlOptionsDialog::setSourceDocument( const Reference< XComponent >& xDoc )
252 : throw ( IllegalArgumentException, RuntimeException )
253 : {
254 : // try to set the corresponding metric unit
255 0 : Reference< XServiceInfo > xServiceInfo(xDoc, UNO_QUERY);
256 0 : if ( xServiceInfo.is() )
257 : {
258 0 : if ( xServiceInfo->supportsService( "com.sun.star.presentation.PresentationDocument" ) )
259 : {
260 0 : meDocType = DOCUMENT_TYPE_IMPRESS;
261 : return;
262 : }
263 0 : else if ( xServiceInfo->supportsService( "com.sun.star.drawing.DrawingDocument" ) )
264 : {
265 0 : meDocType = DOCUMENT_TYPE_DRAW;
266 : return;
267 : }
268 : }
269 0 : throw IllegalArgumentException();
270 9 : }
271 :
272 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|