xref: /aoo42x/main/filter/source/flash/swfdialog.cxx (revision 07a3d7f1)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_filter.hxx"
26 
27 #include "swfdialog.hxx"
28 #include "impswfdialog.hxx"
29 #include <vcl/svapp.hxx>
30 #include <vcl/dialog.hxx>
31 #include <svl/solar.hrc>
32 #include <com/sun/star/view/XRenderable.hpp>
33 #include <com/sun/star/frame/XController.hpp>
34 #include <com/sun/star/view/XSelectionSupplier.hpp>
35 
36 using namespace ::rtl;
37 using namespace ::vcl;
38 using namespace ::com::sun::star;
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::lang;
41 using namespace ::com::sun::star::beans;
42 using namespace ::com::sun::star::frame;
43 using namespace ::com::sun::star::view;
44 using namespace ::com::sun::star::document;
45 
46 // -----------------------
47 // - PDFDialog functions -
48 // -----------------------
49 
50 #define SERVICE_NAME "com.sun.star.Impress.FlashExportDialog"
51 
52 // -----------------------------------------------------------------------------
53 
SWFDialog_getImplementationName()54 OUString SWFDialog_getImplementationName ()
55 	throw (RuntimeException)
56 {
57 	return OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
58 }
59 
60 // -----------------------------------------------------------------------------
61 
SWFDialog_getImplementationId()62 Sequence< sal_Int8 > SAL_CALL SWFDialog_getImplementationId()
63     throw(RuntimeException)
64 {
65     static ::cppu::OImplementationId aId;
66     return aId.getImplementationId();
67 }
68 
69 // -----------------------------------------------------------------------------
70 
SWFDialog_getSupportedServiceNames()71 Sequence< OUString > SAL_CALL SWFDialog_getSupportedServiceNames()
72     throw (RuntimeException)
73 {
74 	Sequence < OUString > aRet(1);
75     OUString* pArray = aRet.getArray();
76     pArray[0] =  OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
77     return aRet;
78 }
79 
80 // -----------------------------------------------------------------------------
81 
SWFDialog_createInstance(const Reference<XMultiServiceFactory> & rSMgr)82 Reference< XInterface > SAL_CALL SWFDialog_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
83     throw( Exception )
84 {
85 	return (cppu::OWeakObject*) new SWFDialog( rSMgr );
86 }
87 
88 // -----------------------------------------------------------------------------
89 
90 #undef SERVICE_NAME
91 
92 // -------------
93 // - SWFDialog -
94 // -------------
95 
SWFDialog(const Reference<XMultiServiceFactory> & rxMSF)96 SWFDialog::SWFDialog( const Reference< XMultiServiceFactory > &rxMSF ) :
97     OGenericUnoDialog( rxMSF )
98 {
99 	ByteString aResMgrName( "flash" );
100 
101 	mpResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() );
102 }
103 
104 // -----------------------------------------------------------------------------
105 
~SWFDialog()106 SWFDialog::~SWFDialog()
107 {
108     delete mpResMgr;
109 }
110 
111 // -----------------------------------------------------------------------------
112 
queryInterface(const Type & rType)113 Any SAL_CALL SWFDialog::queryInterface( const Type& rType )
114     throw (RuntimeException)
115 {
116     Any aReturn = OGenericUnoDialog::queryInterface( rType );
117 
118 	if( !aReturn.hasValue() )
119 		aReturn = ::cppu::queryInterface( rType,
120                                           static_cast< XPropertyAccess* >( this ),
121                                           static_cast< XExporter* >( this ) );
122 
123 	return aReturn;
124 }
125 
126 // -----------------------------------------------------------------------------
127 
acquire()128 void SAL_CALL SWFDialog::acquire()
129     throw ()
130 {
131     OWeakObject::acquire();
132 }
133 
134 // -----------------------------------------------------------------------------
135 
release()136 void SAL_CALL SWFDialog::release()
137     throw ()
138 {
139     OWeakObject::release();
140 }
141 
142 // -----------------------------------------------------------------------------
143 
getImplementationId()144 Sequence< sal_Int8 > SAL_CALL SWFDialog::getImplementationId()
145     throw(RuntimeException)
146 {
147     return SWFDialog_getImplementationId();
148 }
149 
150 // -----------------------------------------------------------------------------
151 
getImplementationName()152 OUString SAL_CALL SWFDialog::getImplementationName()
153 	throw (RuntimeException)
154 {
155 	return SWFDialog_getImplementationName();
156 }
157 
158 // -----------------------------------------------------------------------------
159 
getSupportedServiceNames()160 Sequence< OUString > SAL_CALL SWFDialog::getSupportedServiceNames()
161     throw (RuntimeException)
162 {
163     return SWFDialog_getSupportedServiceNames();
164 }
165 
166 // -----------------------------------------------------------------------------
167 
createDialog(Window * pParent)168 Dialog*	SWFDialog::createDialog( Window* pParent )
169 {
170     Dialog* pRet = NULL;
171 
172     if( mpResMgr && mxSrcDoc.is() )
173     {
174 /*		TODO: From the controller we may get information what page is visible and what shapes
175 			  are selected, if we optionaly want to limit output to that
176         Any aSelection;
177 
178         try
179         {
180             Reference< XController > xController( Reference< XModel >( mxSrcDoc, UNO_QUERY )->getCurrentController() );
181 
182 	        if( xController.is() )
183 	        {
184 		        Reference< XSelectionSupplier > xView( xController, UNO_QUERY );
185 
186 		        if( xView.is() )
187 			        xView->getSelection() >>= aSelection;
188             }
189         }
190         catch( RuntimeException )
191         {
192         }
193 */
194         ImpSWFDialog* pDlg = new ImpSWFDialog( pParent, *mpResMgr, maFilterData );
195         pRet = pDlg;
196     }
197 
198     return pRet;
199 }
200 
201 // -----------------------------------------------------------------------------
202 
executedDialog(sal_Int16 nExecutionResult)203 void SWFDialog::executedDialog( sal_Int16 nExecutionResult )
204 {
205     if( nExecutionResult && m_pDialog )
206         maFilterData = static_cast< ImpSWFDialog* >( m_pDialog )->GetFilterData();
207 
208     destroyDialog();
209 }
210 
211 // -----------------------------------------------------------------------------
212 
getPropertySetInfo()213 Reference< XPropertySetInfo > SAL_CALL SWFDialog::getPropertySetInfo()
214     throw(RuntimeException)
215 {
216 	Reference< XPropertySetInfo >  xInfo( createPropertySetInfo( getInfoHelper() ) );
217 	return xInfo;
218 }
219 
220 //-------------------------------------------------------------------------
getInfoHelper()221 ::cppu::IPropertyArrayHelper& SWFDialog::getInfoHelper()
222 {
223     return *const_cast<SWFDialog*>(this)->getArrayHelper();
224 }
225 
226 //------------------------------------------------------------------------------
createArrayHelper() const227 ::cppu::IPropertyArrayHelper* SWFDialog::createArrayHelper() const
228 {
229 	Sequence< Property > aProps;
230 	describeProperties(aProps);
231 	return new ::cppu::OPropertyArrayHelper( aProps );
232 }
233 
234 // -----------------------------------------------------------------------------
235 
getPropertyValues()236 Sequence< PropertyValue > SAL_CALL SWFDialog::getPropertyValues()
237     throw ( RuntimeException )
238 {
239     sal_Int32 i, nCount;
240 
241     for( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
242 	{
243 		if( maMediaDescriptor[ i ].Name.equalsAscii( "FilterData" ) )
244 			break;
245 	}
246 
247     if( i == nCount )
248 		maMediaDescriptor.realloc( ++nCount );
249 
250 	maMediaDescriptor[ i ].Name = String( RTL_CONSTASCII_USTRINGPARAM( "FilterData" ) );
251 	maMediaDescriptor[ i ].Value <<= maFilterData;
252 
253     return maMediaDescriptor;
254 }
255 
256 // -----------------------------------------------------------------------------
257 
setPropertyValues(const Sequence<PropertyValue> & rProps)258 void SAL_CALL SWFDialog::setPropertyValues( const Sequence< PropertyValue >& rProps )
259     throw ( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException )
260 {
261     maMediaDescriptor = rProps;
262 
263 	for( sal_Int32 i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
264 	{
265 		if( maMediaDescriptor[ i ].Name.equalsAscii( "FilterData" ) )
266 		{
267 			maMediaDescriptor[ i ].Value >>= maFilterData;
268 			break;
269 		}
270 	}
271 }
272 
273 // -----------------------------------------------------------------------------
274 
setSourceDocument(const Reference<XComponent> & xDoc)275 void SAL_CALL SWFDialog::setSourceDocument( const Reference< XComponent >& xDoc )
276     throw(IllegalArgumentException, RuntimeException)
277 {
278     mxSrcDoc = xDoc;
279 }
280