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