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