1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "svgdialog.hxx"
21 #include "impsvgdialog.hxx"
23 #include <vcl/svapp.hxx>
24 #include <vcl/dialog.hxx>
25 #include <comphelper/processfactory.hxx>
27 #include <com/sun/star/view/XRenderable.hpp>
28 #include <com/sun/star/frame/XController.hpp>
29 #include <com/sun/star/view/XSelectionSupplier.hpp>
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"
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
;
45 // -----------------------
46 // - SVGDialog functions -
47 // -----------------------
49 OUString
SVGDialog_getImplementationName ()
50 throw (RuntimeException
)
52 return OUString ( SVG_DIALOG_IMPLEMENTATION_NAME
);
55 // -----------------------------------------------------------------------------
57 Sequence
< sal_Int8
> SAL_CALL
SVGDialog_getImplementationId()
58 throw(RuntimeException
)
60 static const ::cppu::OImplementationId aId
;
62 return( aId
.getImplementationId() );
65 // -----------------------------------------------------------------------------
67 Sequence
< OUString
> SAL_CALL
SVGDialog_getSupportedServiceNames()
68 throw (RuntimeException
)
70 Sequence
< OUString
> aRet( 1 );
72 aRet
.getArray()[ 0 ] = OUString ( SVG_DIALOG_SERVICE_NAME
);
77 // -----------------------------------------------------------------------------
79 Reference
< XInterface
> SAL_CALL
SVGDialog_createInstance( const Reference
< XMultiServiceFactory
> & rSMgr
)
82 return( static_cast< cppu::OWeakObject
* >( new SVGDialog( comphelper::getComponentContext(rSMgr
) ) ) );
89 SVGDialog::SVGDialog( const Reference
< XComponentContext
> &rxContext
) :
90 OGenericUnoDialog( rxContext
)
94 // -----------------------------------------------------------------------------
96 SVGDialog::~SVGDialog()
100 // -----------------------------------------------------------------------------
102 Any SAL_CALL
SVGDialog::queryInterface( const Type
& rType
)
103 throw (RuntimeException
)
105 Any
aReturn( OGenericUnoDialog::queryInterface( rType
) );
107 if( !aReturn
.hasValue() )
109 aReturn
= ::cppu::queryInterface( rType
, static_cast< XPropertyAccess
* >( this ),
110 static_cast< XExporter
* >( this ) );
116 // -----------------------------------------------------------------------------
118 void SAL_CALL
SVGDialog::acquire()
121 OWeakObject::acquire();
124 // -----------------------------------------------------------------------------
126 void SAL_CALL
SVGDialog::release()
129 OWeakObject::release();
132 // -----------------------------------------------------------------------------
134 Sequence
< sal_Int8
> SAL_CALL
SVGDialog::getImplementationId()
135 throw(RuntimeException
)
137 return SVGDialog_getImplementationId();
140 // -----------------------------------------------------------------------------
142 OUString SAL_CALL
SVGDialog::getImplementationName()
143 throw (RuntimeException
)
145 return SVGDialog_getImplementationName();
148 // -----------------------------------------------------------------------------
150 Sequence
< OUString
> SAL_CALL
SVGDialog::getSupportedServiceNames()
151 throw (RuntimeException
)
153 return SVGDialog_getSupportedServiceNames();
156 // -----------------------------------------------------------------------------
158 Dialog
* SVGDialog::createDialog( Window
* pParent
)
160 return( ( /*KA: *mapResMgr.get() &&*/ mxSrcDoc
.is() ) ?
161 new ImpSVGDialog( pParent
/*KA: , *mapResMgr*/, maFilterData
) :
165 // -----------------------------------------------------------------------------
167 void SVGDialog::executedDialog( sal_Int16 nExecutionResult
)
169 if( nExecutionResult
&& m_pDialog
)
170 maFilterData
= static_cast< ImpSVGDialog
* >( m_pDialog
)->GetFilterData();
175 // -----------------------------------------------------------------------------
177 Reference
< XPropertySetInfo
> SAL_CALL
SVGDialog::getPropertySetInfo()
178 throw(RuntimeException
)
180 return( Reference
< XPropertySetInfo
>( createPropertySetInfo( getInfoHelper() ) ) );
183 //-------------------------------------------------------------------------
184 ::cppu::IPropertyArrayHelper
& SVGDialog::getInfoHelper()
186 return( *const_cast< SVGDialog
*>(this)->getArrayHelper() );
189 //------------------------------------------------------------------------------
190 ::cppu::IPropertyArrayHelper
* SVGDialog::createArrayHelper() const
192 Sequence
< Property
> aProps
;
194 describeProperties(aProps
);
196 return new ::cppu::OPropertyArrayHelper( aProps
);
199 // -----------------------------------------------------------------------------
201 Sequence
< PropertyValue
> SAL_CALL
SVGDialog::getPropertyValues()
202 throw ( RuntimeException
)
206 for( i
= 0, nCount
= maMediaDescriptor
.getLength(); i
< nCount
; ++i
)
208 if( maMediaDescriptor
[ i
].Name
.equalsAscii( SVG_FILTER_DATA_NAME
) )
214 maMediaDescriptor
.realloc( ++nCount
);
215 maMediaDescriptor
[ i
].Name
= String( RTL_CONSTASCII_USTRINGPARAM( SVG_FILTER_DATA_NAME
) );
218 maMediaDescriptor
[ i
].Value
<<= maFilterData
;
220 return( maMediaDescriptor
);
223 // -----------------------------------------------------------------------------
225 void SAL_CALL
SVGDialog::setPropertyValues( const Sequence
< PropertyValue
>& rProps
)
226 throw ( UnknownPropertyException
, PropertyVetoException
, IllegalArgumentException
, WrappedTargetException
, RuntimeException
)
228 maMediaDescriptor
= rProps
;
230 for( sal_Int32 i
= 0, nCount
= maMediaDescriptor
.getLength(); i
< nCount
; i
++ )
232 if( maMediaDescriptor
[ i
].Name
.equalsAscii( SVG_FILTER_DATA_NAME
) )
234 maMediaDescriptor
[ i
].Value
>>= maFilterData
;
240 // -----------------------------------------------------------------------------
242 void SAL_CALL
SVGDialog::setSourceDocument( const Reference
< XComponent
>& xDoc
)
243 throw(IllegalArgumentException
, RuntimeException
)
248 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */