1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: swfdialog.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_filter.hxx"
34 #include "swfdialog.hxx"
35 #include "impswfdialog.hxx"
36 #include <vcl/svapp.hxx>
37 #include <vcl/dialog.hxx>
38 #include <svtools/solar.hrc>
39 #include <com/sun/star/view/XRenderable.hpp>
40 #include <com/sun/star/frame/XController.hpp>
41 #include <com/sun/star/view/XSelectionSupplier.hpp>
43 using namespace ::rtl
;
44 using namespace ::vcl
;
45 using namespace ::com::sun::star
;
46 using namespace ::com::sun::star::uno
;
47 using namespace ::com::sun::star::lang
;
48 using namespace ::com::sun::star::beans
;
49 using namespace ::com::sun::star::frame
;
50 using namespace ::com::sun::star::view
;
51 using namespace ::com::sun::star::document
;
53 // -----------------------
54 // - PDFDialog functions -
55 // -----------------------
57 #define SERVICE_NAME "com.sun.star.Impress.FlashExportDialog"
59 // -----------------------------------------------------------------------------
61 OUString
SWFDialog_getImplementationName ()
62 throw (RuntimeException
)
64 return OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME
) );
67 // -----------------------------------------------------------------------------
69 Sequence
< sal_Int8
> SAL_CALL
SWFDialog_getImplementationId()
70 throw(RuntimeException
)
72 static ::cppu::OImplementationId aId
;
73 return aId
.getImplementationId();
76 // -----------------------------------------------------------------------------
78 Sequence
< OUString
> SAL_CALL
SWFDialog_getSupportedServiceNames()
79 throw (RuntimeException
)
81 Sequence
< OUString
> aRet(1);
82 OUString
* pArray
= aRet
.getArray();
83 pArray
[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME
) );
87 // -----------------------------------------------------------------------------
89 Reference
< XInterface
> SAL_CALL
SWFDialog_createInstance( const Reference
< XMultiServiceFactory
> & rSMgr
)
92 return (cppu::OWeakObject
*) new SWFDialog( rSMgr
);
95 // -----------------------------------------------------------------------------
103 SWFDialog::SWFDialog( const Reference
< XMultiServiceFactory
> &rxMSF
) :
104 OGenericUnoDialog( rxMSF
)
106 ByteString
aResMgrName( "flash" );
108 mpResMgr
= ResMgr::CreateResMgr( aResMgrName
.GetBuffer(), Application::GetSettings().GetUILocale() );
111 // -----------------------------------------------------------------------------
113 SWFDialog::~SWFDialog()
118 // -----------------------------------------------------------------------------
120 Any SAL_CALL
SWFDialog::queryInterface( const Type
& rType
)
121 throw (RuntimeException
)
123 Any aReturn
= OGenericUnoDialog::queryInterface( rType
);
125 if( !aReturn
.hasValue() )
126 aReturn
= ::cppu::queryInterface( rType
,
127 static_cast< XPropertyAccess
* >( this ),
128 static_cast< XExporter
* >( this ) );
133 // -----------------------------------------------------------------------------
135 void SAL_CALL
SWFDialog::acquire()
138 OWeakObject::acquire();
141 // -----------------------------------------------------------------------------
143 void SAL_CALL
SWFDialog::release()
146 OWeakObject::release();
149 // -----------------------------------------------------------------------------
151 Sequence
< sal_Int8
> SAL_CALL
SWFDialog::getImplementationId()
152 throw(RuntimeException
)
154 return SWFDialog_getImplementationId();
157 // -----------------------------------------------------------------------------
159 OUString SAL_CALL
SWFDialog::getImplementationName()
160 throw (RuntimeException
)
162 return SWFDialog_getImplementationName();
165 // -----------------------------------------------------------------------------
167 Sequence
< OUString
> SAL_CALL
SWFDialog::getSupportedServiceNames()
168 throw (RuntimeException
)
170 return SWFDialog_getSupportedServiceNames();
173 // -----------------------------------------------------------------------------
175 Dialog
* SWFDialog::createDialog( Window
* pParent
)
179 if( mpResMgr
&& mxSrcDoc
.is() )
181 /* TODO: From the controler we may get information what page is visible and what shapes
182 are selected, if we optionaly want to limit output to that
187 Reference< XController > xController( Reference< XModel >( mxSrcDoc, UNO_QUERY )->getCurrentController() );
189 if( xController.is() )
191 Reference< XSelectionSupplier > xView( xController, UNO_QUERY );
194 xView->getSelection() >>= aSelection;
197 catch( RuntimeException )
201 ImpSWFDialog
* pDlg
= new ImpSWFDialog( pParent
, *mpResMgr
, maFilterData
);
208 // -----------------------------------------------------------------------------
210 void SWFDialog::executedDialog( sal_Int16 nExecutionResult
)
212 if( nExecutionResult
&& m_pDialog
)
213 maFilterData
= static_cast< ImpSWFDialog
* >( m_pDialog
)->GetFilterData();
218 // -----------------------------------------------------------------------------
220 Reference
< XPropertySetInfo
> SAL_CALL
SWFDialog::getPropertySetInfo()
221 throw(RuntimeException
)
223 Reference
< XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
227 //-------------------------------------------------------------------------
228 ::cppu::IPropertyArrayHelper
& SWFDialog::getInfoHelper()
230 return *const_cast<SWFDialog
*>(this)->getArrayHelper();
233 //------------------------------------------------------------------------------
234 ::cppu::IPropertyArrayHelper
* SWFDialog::createArrayHelper() const
236 Sequence
< Property
> aProps
;
237 describeProperties(aProps
);
238 return new ::cppu::OPropertyArrayHelper( aProps
);
241 // -----------------------------------------------------------------------------
243 Sequence
< PropertyValue
> SAL_CALL
SWFDialog::getPropertyValues()
244 throw ( RuntimeException
)
248 for( i
= 0, nCount
= maMediaDescriptor
.getLength(); i
< nCount
; i
++ )
250 if( maMediaDescriptor
[ i
].Name
.equalsAscii( "FilterData" ) )
255 maMediaDescriptor
.realloc( ++nCount
);
257 maMediaDescriptor
[ i
].Name
= String( RTL_CONSTASCII_USTRINGPARAM( "FilterData" ) );
258 maMediaDescriptor
[ i
].Value
<<= maFilterData
;
260 return maMediaDescriptor
;
263 // -----------------------------------------------------------------------------
265 void SAL_CALL
SWFDialog::setPropertyValues( const Sequence
< PropertyValue
>& rProps
)
266 throw ( UnknownPropertyException
, PropertyVetoException
, IllegalArgumentException
, WrappedTargetException
, RuntimeException
)
268 maMediaDescriptor
= rProps
;
270 for( sal_Int32 i
= 0, nCount
= maMediaDescriptor
.getLength(); i
< nCount
; i
++ )
272 if( maMediaDescriptor
[ i
].Name
.equalsAscii( "FilterData" ) )
274 maMediaDescriptor
[ i
].Value
>>= maFilterData
;
280 // -----------------------------------------------------------------------------
282 void SAL_CALL
SWFDialog::setSourceDocument( const Reference
< XComponent
>& xDoc
)
283 throw(IllegalArgumentException
, RuntimeException
)