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