xref: /aoo42x/main/filter/source/svg/svgdialog.cxx (revision 4bfbcde8)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_filter.hxx"
24 
25 #include "svgdialog.hxx"
26 #include "impsvgdialog.hxx"
27 
28 #include <vcl/svapp.hxx>
29 #include <vcl/dialog.hxx>
30 
31 #ifndef _COM_SUN_STAR_VIEW_XRENDERABLE_HPP_
32 #include <com/sun/star/view/XRenderable.hpp>
33 #endif
34 #ifndef	_COM_SUN_STAR_FRAME_XCONTROLLER_HPP_
35 #include <com/sun/star/frame/XController.hpp>
36 #endif
37 #ifndef _COM_SUN_STAR_VIEW_XSELECTIONSUPPLIER_HPP_
38 #include <com/sun/star/view/XSelectionSupplier.hpp>
39 #endif
40 
41 #define SVG_DIALOG_SERVICE_NAME         "com.sun.star.comp.Draw.SVGFilterDialog"
42 #define SVG_DIALOG_IMPLEMENTATION_NAME  SVG_DIALOG_SERVICE_NAME
43 #define SVG_FILTER_DATA_NAME            "FilterData"
44 
45 using namespace ::rtl;
46 using namespace ::vcl;
47 using namespace ::com::sun::star;
48 using namespace ::com::sun::star::uno;
49 using namespace ::com::sun::star::lang;
50 using namespace ::com::sun::star::beans;
51 using namespace ::com::sun::star::frame;
52 using namespace ::com::sun::star::view;
53 using namespace ::com::sun::star::document;
54 
55 // -----------------------
56 // - SVGDialog functions -
57 // -----------------------
58 
SVGDialog_getImplementationName()59 OUString SVGDialog_getImplementationName ()
60 	throw (RuntimeException)
61 {
62 	return OUString ( RTL_CONSTASCII_USTRINGPARAM ( SVG_DIALOG_IMPLEMENTATION_NAME ) );
63 }
64 
65 // -----------------------------------------------------------------------------
66 
SVGDialog_getImplementationId()67 Sequence< sal_Int8 > SAL_CALL SVGDialog_getImplementationId()
68     throw(RuntimeException)
69 {
70     static const ::cppu::OImplementationId aId;
71 
72     return( aId.getImplementationId() );
73 }
74 
75 // -----------------------------------------------------------------------------
76 
SVGDialog_getSupportedServiceNames()77 Sequence< OUString > SAL_CALL SVGDialog_getSupportedServiceNames()
78     throw (RuntimeException)
79 {
80 	Sequence< OUString > aRet( 1 );
81 
82     aRet.getArray()[ 0 ] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SVG_DIALOG_SERVICE_NAME ) );
83 
84     return aRet;
85 }
86 
87 // -----------------------------------------------------------------------------
88 
SVGDialog_createInstance(const Reference<XMultiServiceFactory> & rSMgr)89 Reference< XInterface > SAL_CALL SVGDialog_createInstance( const Reference< XMultiServiceFactory > & rSMgr )
90     throw( Exception )
91 {
92     return( static_cast< cppu::OWeakObject* >( new SVGDialog( rSMgr ) ) );
93 }
94 
95 // -------------
96 // - SVGDialog -
97 // -------------
98 
SVGDialog(const Reference<XMultiServiceFactory> & rxMSF)99 SVGDialog::SVGDialog( const Reference< XMultiServiceFactory > &rxMSF ) :
100     OGenericUnoDialog( rxMSF )
101 {
102 	ByteString aResMgrName( "svgfilter" );
103 
104 	aResMgrName.Append( ByteString::CreateFromInt32( 0/*SOLARUPD*/ ) );
105 
106     // !!! KA: enable ResMgr
107     // mapResMgr.reset( ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() ) );
108 }
109 
110 // -----------------------------------------------------------------------------
111 
~SVGDialog()112 SVGDialog::~SVGDialog()
113 {
114 }
115 
116 // -----------------------------------------------------------------------------
117 
queryInterface(const Type & rType)118 Any SAL_CALL SVGDialog::queryInterface( const Type& rType )
119     throw (RuntimeException)
120 {
121     Any aReturn( OGenericUnoDialog::queryInterface( rType ) );
122 
123 	if( !aReturn.hasValue() )
124     {
125         aReturn = ::cppu::queryInterface( rType, static_cast< XPropertyAccess* >( this ),
126                                                  static_cast< XExporter* >( this ) );
127     }
128 
129     return( aReturn );
130 }
131 
132 // -----------------------------------------------------------------------------
133 
acquire()134 void SAL_CALL SVGDialog::acquire()
135     throw ()
136 {
137     OWeakObject::acquire();
138 }
139 
140 // -----------------------------------------------------------------------------
141 
release()142 void SAL_CALL SVGDialog::release()
143     throw ()
144 {
145     OWeakObject::release();
146 }
147 
148 // -----------------------------------------------------------------------------
149 
getImplementationId()150 Sequence< sal_Int8 > SAL_CALL SVGDialog::getImplementationId()
151     throw(RuntimeException)
152 {
153     return SVGDialog_getImplementationId();
154 }
155 
156 // -----------------------------------------------------------------------------
157 
getImplementationName()158 OUString SAL_CALL SVGDialog::getImplementationName()
159 	throw (RuntimeException)
160 {
161 	return SVGDialog_getImplementationName();
162 }
163 
164 // -----------------------------------------------------------------------------
165 
getSupportedServiceNames()166 Sequence< OUString > SAL_CALL SVGDialog::getSupportedServiceNames()
167     throw (RuntimeException)
168 {
169     return SVGDialog_getSupportedServiceNames();
170 }
171 
172 // -----------------------------------------------------------------------------
173 
createDialog(Window * pParent)174 Dialog*	SVGDialog::createDialog( Window* pParent )
175 {
176     return( ( /*KA: *mapResMgr.get() &&*/ mxSrcDoc.is() ) ?
177             new ImpSVGDialog( pParent/*KA: , *mapResMgr*/, maFilterData ) :
178             NULL );
179 }
180 
181 // -----------------------------------------------------------------------------
182 
executedDialog(sal_Int16 nExecutionResult)183 void SVGDialog::executedDialog( sal_Int16 nExecutionResult )
184 {
185     if( nExecutionResult && m_pDialog )
186         maFilterData = static_cast< ImpSVGDialog* >( m_pDialog )->GetFilterData();
187 
188     destroyDialog();
189 }
190 
191 // -----------------------------------------------------------------------------
192 
getPropertySetInfo()193 Reference< XPropertySetInfo > SAL_CALL SVGDialog::getPropertySetInfo()
194     throw(RuntimeException)
195 {
196     return( Reference< XPropertySetInfo >( createPropertySetInfo( getInfoHelper() ) ) );
197 }
198 
199 //-------------------------------------------------------------------------
getInfoHelper()200 ::cppu::IPropertyArrayHelper& SVGDialog::getInfoHelper()
201 {
202     return( *const_cast< SVGDialog *>(this)->getArrayHelper() );
203 }
204 
205 //------------------------------------------------------------------------------
createArrayHelper() const206 ::cppu::IPropertyArrayHelper* SVGDialog::createArrayHelper() const
207 {
208 	Sequence< Property > aProps;
209 
210     describeProperties(aProps);
211 
212     return new ::cppu::OPropertyArrayHelper( aProps );
213 }
214 
215 // -----------------------------------------------------------------------------
216 
getPropertyValues()217 Sequence< PropertyValue > SAL_CALL SVGDialog::getPropertyValues()
218     throw ( RuntimeException )
219 {
220     sal_Int32 i, nCount;
221 
222     for( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; ++i )
223 	{
224         if( maMediaDescriptor[ i ].Name.equalsAscii( SVG_FILTER_DATA_NAME ) )
225             break;
226 	}
227 
228     if( i == nCount )
229     {
230 		maMediaDescriptor.realloc( ++nCount );
231         maMediaDescriptor[ i ].Name = String( RTL_CONSTASCII_USTRINGPARAM( SVG_FILTER_DATA_NAME ) );
232     }
233 
234 	maMediaDescriptor[ i ].Value <<= maFilterData;
235 
236     return( maMediaDescriptor );
237 }
238 
239 // -----------------------------------------------------------------------------
240 
setPropertyValues(const Sequence<PropertyValue> & rProps)241 void SAL_CALL SVGDialog::setPropertyValues( const Sequence< PropertyValue >& rProps )
242     throw ( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException )
243 {
244     maMediaDescriptor = rProps;
245 
246 	for( sal_Int32 i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
247 	{
248         if( maMediaDescriptor[ i ].Name.equalsAscii( SVG_FILTER_DATA_NAME ) )
249 		{
250 			maMediaDescriptor[ i ].Value >>= maFilterData;
251 			break;
252 		}
253 	}
254 }
255 
256 // -----------------------------------------------------------------------------
257 
setSourceDocument(const Reference<XComponent> & xDoc)258 void SAL_CALL SVGDialog::setSourceDocument( const Reference< XComponent >& xDoc )
259     throw(IllegalArgumentException, RuntimeException)
260 {
261     mxSrcDoc = xDoc;
262 }
263