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