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