Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <unotools/pathoptions.hxx>
30 : : #include <com/sun/star/lang/XServiceInfo.hpp>
31 : : #include <com/sun/star/container/XNameContainer.hpp>
32 : : #include <cppuhelper/implbase2.hxx>
33 : :
34 : : #include "../customshapes/EnhancedCustomShapeEngine.hxx"
35 : :
36 : : #include <svx/xtable.hxx>
37 : : #include "svx/unoshcol.hxx"
38 : : #include "recoveryui.hxx"
39 : : #include "svx/xmlgrhlp.hxx"
40 : : #include "tbunocontroller.hxx"
41 : : #include "tbunosearchcontrollers.hxx"
42 : :
43 : : using namespace ::com::sun::star;
44 : : using namespace ::rtl;
45 : : using namespace ::cppu;
46 : :
47 : : class SvxUnoColorTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo >
48 : : {
49 : : private:
50 : : XColorListRef pList;
51 : :
52 : : public:
53 : : SvxUnoColorTable() throw();
54 : : virtual ~SvxUnoColorTable() throw();
55 : :
56 : : // XServiceInfo
57 : : virtual OUString SAL_CALL getImplementationName() throw( uno::RuntimeException );
58 : : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( uno::RuntimeException);
59 : : virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( uno::RuntimeException);
60 : :
61 : 0 : static OUString getImplementationName_Static() throw()
62 : : {
63 : 0 : return OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.SvxUnoColorTable"));
64 : : }
65 : :
66 : : static uno::Sequence< OUString > getSupportedServiceNames_Static(void) throw();
67 : :
68 : : // XNameContainer
69 : : virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException);
70 : : virtual void SAL_CALL removeByName( const OUString& Name ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
71 : :
72 : : // XNameReplace
73 : : virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
74 : :
75 : : // XNameAccess
76 : : virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
77 : :
78 : : virtual uno::Sequence< OUString > SAL_CALL getElementNames() throw( uno::RuntimeException);
79 : :
80 : : virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw( uno::RuntimeException);
81 : :
82 : : // XElementAccess
83 : : virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException);
84 : : virtual sal_Bool SAL_CALL hasElements() throw( uno::RuntimeException);
85 : : };
86 : :
87 : 0 : SvxUnoColorTable::SvxUnoColorTable() throw()
88 : : {
89 [ # # ][ # # ]: 0 : pList = XPropertyList::CreatePropertyList( XCOLOR_LIST, SvtPathOptions().GetPalettePath() )->AsColorList();
[ # # ][ # # ]
[ # # ][ # # ]
90 : 0 : }
91 : :
92 : 0 : SvxUnoColorTable::~SvxUnoColorTable() throw()
93 : : {
94 [ # # ]: 0 : }
95 : :
96 : 0 : sal_Bool SAL_CALL SvxUnoColorTable::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
97 : : {
98 [ # # ]: 0 : uno::Sequence< OUString > aSNL( getSupportedServiceNames() );
99 : 0 : const OUString * pArray = aSNL.getConstArray();
100 : :
101 [ # # ]: 0 : for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
102 [ # # ]: 0 : if( pArray[i] == ServiceName )
103 : 0 : return sal_True;
104 : :
105 [ # # ]: 0 : return sal_False;
106 : : }
107 : :
108 : 0 : OUString SAL_CALL SvxUnoColorTable::getImplementationName() throw( uno::RuntimeException )
109 : : {
110 : 0 : return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoColorTable") );
111 : : }
112 : :
113 : 0 : uno::Sequence< OUString > SAL_CALL SvxUnoColorTable::getSupportedServiceNames()
114 : : throw( uno::RuntimeException )
115 : : {
116 : 0 : return getSupportedServiceNames_Static();
117 : : }
118 : :
119 : 0 : uno::Sequence< OUString > SvxUnoColorTable::getSupportedServiceNames_Static(void) throw()
120 : : {
121 : 0 : uno::Sequence< OUString > aSNS( 1 );
122 [ # # ][ # # ]: 0 : aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ColorTable" ));
123 : 0 : return aSNS;
124 : : }
125 : :
126 : : // XNameContainer
127 : 0 : void SAL_CALL SvxUnoColorTable::insertByName( const OUString& aName, const uno::Any& aElement )
128 : : throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException )
129 : : {
130 [ # # ][ # # ]: 0 : if( hasByName( aName ) )
131 [ # # ]: 0 : throw container::ElementExistException();
132 : :
133 : 0 : sal_Int32 nColor = 0;
134 [ # # ]: 0 : if( !(aElement >>= nColor) )
135 [ # # ]: 0 : throw lang::IllegalArgumentException();
136 : :
137 [ # # ]: 0 : if( pList.is() )
138 : : {
139 [ # # ][ # # ]: 0 : XColorEntry* pEntry = new XColorEntry( Color( (ColorData)nColor ), aName );
[ # # ][ # # ]
140 [ # # ][ # # ]: 0 : pList->Insert( pEntry, pList->Count() );
141 : : }
142 : 0 : }
143 : :
144 : 0 : void SAL_CALL SvxUnoColorTable::removeByName( const OUString& Name )
145 : : throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
146 : : {
147 [ # # ][ # # ]: 0 : long nIndex = pList.is() ? pList->Get( Name ) : -1;
[ # # ][ # # ]
[ # # ]
148 [ # # ]: 0 : if( nIndex == -1 )
149 [ # # ]: 0 : throw container::NoSuchElementException();
150 : :
151 : 0 : pList->Remove( nIndex );
152 : 0 : }
153 : :
154 : : // XNameReplace
155 : 0 : void SAL_CALL SvxUnoColorTable::replaceByName( const OUString& aName, const uno::Any& aElement )
156 : : throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
157 : : {
158 : 0 : sal_Int32 nColor = 0;
159 [ # # ]: 0 : if( !(aElement >>= nColor) )
160 [ # # ]: 0 : throw lang::IllegalArgumentException();
161 : :
162 [ # # ][ # # ]: 0 : long nIndex = pList.is() ? pList->Get( aName ) : -1;
[ # # ][ # # ]
[ # # ][ # # ]
163 [ # # ]: 0 : if( nIndex == -1 )
164 [ # # ]: 0 : throw container::NoSuchElementException();
165 : :
166 [ # # ][ # # ]: 0 : XColorEntry* pEntry = new XColorEntry( Color( (ColorData)nColor ), aName );
[ # # ][ # # ]
167 [ # # ][ # # ]: 0 : delete pList->Replace( nIndex, pEntry );
[ # # ]
168 : 0 : }
169 : :
170 : : // XNameAccess
171 : 0 : uno::Any SAL_CALL SvxUnoColorTable::getByName( const OUString& aName )
172 : : throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
173 : : {
174 [ # # ][ # # ]: 0 : long nIndex = pList.is() ? pList->Get( aName ) : -1;
[ # # ][ # # ]
[ # # ]
175 [ # # ]: 0 : if( nIndex == -1 )
176 [ # # ]: 0 : throw container::NoSuchElementException();
177 : :
178 : 0 : XColorEntry* pEntry = pList->GetColor( nIndex );
179 [ # # ]: 0 : return uno::Any( (sal_Int32) pEntry->GetColor().GetRGBColor() );
180 : : }
181 : :
182 : 0 : uno::Sequence< OUString > SAL_CALL SvxUnoColorTable::getElementNames()
183 : : throw( uno::RuntimeException )
184 : : {
185 [ # # ]: 0 : const long nCount = pList.is() ? pList->Count() : 0;
186 : :
187 : 0 : uno::Sequence< OUString > aSeq( nCount );
188 [ # # ]: 0 : OUString* pStrings = aSeq.getArray();
189 : :
190 [ # # ]: 0 : for( long nIndex = 0; nIndex < nCount; nIndex++ )
191 : : {
192 [ # # ]: 0 : XColorEntry* pEntry = pList->GetColor( (long)nIndex );
193 [ # # ]: 0 : pStrings[nIndex] = pEntry->GetName();
194 : : }
195 : :
196 : 0 : return aSeq;
197 : : }
198 : :
199 : 0 : sal_Bool SAL_CALL SvxUnoColorTable::hasByName( const OUString& aName )
200 : : throw( uno::RuntimeException )
201 : : {
202 [ # # ][ # # ]: 0 : long nIndex = pList.is() ? pList->Get( aName ) : -1;
[ # # ][ # # ]
[ # # ]
203 : 0 : return nIndex != -1;
204 : : }
205 : :
206 : : // XElementAccess
207 : 0 : uno::Type SAL_CALL SvxUnoColorTable::getElementType()
208 : : throw( uno::RuntimeException )
209 : : {
210 : 0 : return ::getCppuType((const sal_Int32*)0);
211 : : }
212 : :
213 : 0 : sal_Bool SAL_CALL SvxUnoColorTable::hasElements()
214 : : throw( uno::RuntimeException )
215 : : {
216 [ # # ][ # # ]: 0 : return pList.is() && pList->Count() != 0;
217 : : }
218 : :
219 : : /**
220 : : * Create a colortable
221 : : */
222 : 0 : uno::Reference< uno::XInterface > SAL_CALL SvxUnoColorTable_createInstance(const uno::Reference< lang::XMultiServiceFactory > & ) throw(uno::Exception)
223 : : {
224 : 0 : return *new SvxUnoColorTable();
225 : : }
226 : 0 : uno::Reference< uno::XInterface > SAL_CALL create_EnhancedCustomShapeEngine( const uno::Reference< lang::XMultiServiceFactory >& rxFact ) throw(uno::Exception)
227 : : {
228 [ # # ]: 0 : return *new EnhancedCustomShapeEngine( rxFact );
229 : : }
230 : :
231 : : //
232 : : // export this service
233 : : //
234 : :
235 : : #include "UnoGraphicExporter.hxx"
236 : : #include "unogalthemeprovider.hxx"
237 : : #include <com/sun/star/registry/XRegistryKey.hpp>
238 : : #include "sal/types.h"
239 : : #include "osl/diagnose.h"
240 : : #include "cppuhelper/factory.hxx"
241 : : #include "uno/lbnames.h"
242 : : #include <svx/sdr/primitive2d/primitiveFactory2d.hxx>
243 : :
244 : : extern "C"
245 : : {
246 : :
247 : 72 : SAL_DLLPUBLIC_EXPORT void * SAL_CALL svx_component_getFactory (
248 : : const sal_Char * pImplName, void * pServiceManager, void * )
249 : : {
250 : 72 : void * pRet = 0;
251 [ + - ]: 72 : if( pServiceManager )
252 : : {
253 : 72 : uno::Reference< lang::XSingleServiceFactory > xFactory;
254 : :
255 [ - + ]: 72 : if( rtl_str_compare( pImplName, "com.sun.star.drawing.SvxUnoColorTable" ) == 0 )
256 : : {
257 : : xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
258 : : SvxUnoColorTable::getImplementationName_Static(),
259 : : SvxUnoColorTable_createInstance,
260 [ # # ][ # # ]: 0 : SvxUnoColorTable::getSupportedServiceNames_Static() );
[ # # ][ # # ]
261 : : }
262 [ - + ]: 72 : else if ( rtl_str_compare( pImplName, "com.sun.star.drawing.EnhancedCustomShapeEngine" ) == 0 )
263 : : {
264 : : xFactory = createSingleFactory( reinterpret_cast< NMSP_LANG::XMultiServiceFactory* >( pServiceManager ),
265 : : EnhancedCustomShapeEngine_getImplementationName(),
266 : : create_EnhancedCustomShapeEngine,
267 [ # # ][ # # ]: 0 : EnhancedCustomShapeEngine_getSupportedServiceNames() );
[ # # ][ # # ]
[ # # ][ # # ]
268 : : }
269 [ + + ]: 72 : else if( rtl_str_compare( pImplName, "com.sun.star.drawing.SvxShapeCollection" ) == 0 )
270 : : {
271 : : xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
272 : : SvxShapeCollection::getImplementationName_Static(),
273 : : SvxShapeCollection_createInstance,
274 [ + - ][ + - ]: 2 : SvxShapeCollection::getSupportedServiceNames_Static() );
[ + - ][ + - ]
[ + - ][ + - ]
275 : : }
276 [ + - ][ - + ]: 70 : else if( svx::RecoveryUI::st_getImplementationName().equalsAscii( pImplName ) )
277 : : {
278 : : xFactory = ::cppu::createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
279 : : svx::RecoveryUI::st_getImplementationName(),
280 : : svx::RecoveryUI::st_createInstance,
281 [ # # ][ # # ]: 0 : svx::RecoveryUI::st_getSupportedServiceNames() );
[ # # ][ # # ]
[ # # ][ # # ]
282 : : }
283 [ + + ]: 70 : else if( svx::GraphicExporter_getImplementationName().equalsAscii( pImplName ) )
284 : : {
285 : : xFactory = ::cppu::createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
286 : : svx::GraphicExporter_getImplementationName(),
287 : : svx::GraphicExporter_createInstance,
288 [ + - ][ + - ]: 9 : svx::GraphicExporter_getSupportedServiceNames() );
[ + - ][ + - ]
289 : : }
290 [ + + ]: 61 : else if ( svx::FontHeightToolBoxControl::getImplementationName_Static().equalsAscii( pImplName ) )
291 : : {
292 : : xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
293 : : svx::FontHeightToolBoxControl::getImplementationName_Static(),
294 : : svx::FontHeightToolBoxControl_createInstance,
295 [ + - ][ + - ]: 52 : svx::FontHeightToolBoxControl::getSupportedServiceNames_Static() );
[ + - ][ + - ]
296 : : }
297 [ - + ]: 9 : else if ( svx::FindTextToolbarController::getImplementationName_Static().equalsAscii( pImplName ) )
298 : : {
299 : : xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
300 : : svx::FindTextToolbarController::getImplementationName_Static(),
301 : : svx::FindTextToolbarController_createInstance,
302 [ # # ][ # # ]: 0 : svx::FindTextToolbarController::getSupportedServiceNames_Static() );
[ # # ][ # # ]
303 : : }
304 [ - + ]: 9 : else if ( svx::UpDownSearchToolboxController::getImplementationName_Static( svx::UpDownSearchToolboxController::DOWN ).equalsAscii( pImplName ) )
305 : : {
306 : : xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
307 : : svx::UpDownSearchToolboxController::getImplementationName_Static( svx::UpDownSearchToolboxController::DOWN ),
308 : : svx::DownSearchToolboxController_createInstance,
309 [ # # ][ # # ]: 0 : svx::UpDownSearchToolboxController::getSupportedServiceNames_Static() );
[ # # ][ # # ]
310 : : }
311 [ - + ]: 9 : else if ( svx::UpDownSearchToolboxController::getImplementationName_Static( svx::UpDownSearchToolboxController::UP ).equalsAscii( pImplName ) )
312 : : {
313 : : xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
314 : : svx::UpDownSearchToolboxController::getImplementationName_Static( svx::UpDownSearchToolboxController::UP ),
315 : : svx::UpSearchToolboxController_createInstance,
316 [ # # ][ # # ]: 0 : svx::UpDownSearchToolboxController::getSupportedServiceNames_Static() );
[ # # ][ # # ]
317 : : }
318 [ + + ]: 9 : else if ( svx::FindbarDispatcher::getImplementationName_Static().equalsAscii( pImplName ) )
319 : : {
320 : : xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
321 : : svx::FindbarDispatcher::getImplementationName_Static(),
322 : : svx::FindbarDispatcher_createInstance,
323 [ + - ][ + - ]: 2 : svx::FindbarDispatcher::getSupportedServiceNames_Static() );
[ + - ][ + - ]
324 : : }
325 [ - + ]: 7 : else if( ::unogallery::GalleryThemeProvider_getImplementationName().equalsAscii( pImplName ) )
326 : : {
327 : : xFactory = ::cppu::createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
328 : : ::unogallery::GalleryThemeProvider_getImplementationName(),
329 : : ::unogallery::GalleryThemeProvider_createInstance,
330 [ # # ][ # # ]: 0 : ::unogallery::GalleryThemeProvider_getSupportedServiceNames() );
[ # # ][ # # ]
331 : : }
332 [ + - ][ - + ]: 7 : else if( drawinglayer::primitive2d::PrimitiveFactory2D::getImplementationName_Static().equalsAscii( pImplName ) )
333 : : {
334 : : // XPrimitiveFactory2D
335 : : xFactory = ::cppu::createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
336 : : drawinglayer::primitive2d::PrimitiveFactory2D::getImplementationName_Static(),
337 : : drawinglayer::primitive2d::XPrimitiveFactory2DProvider_createInstance,
338 [ # # ][ # # ]: 0 : drawinglayer::primitive2d::PrimitiveFactory2D::getSupportedServiceNames_Static() );
[ # # ][ # # ]
[ # # ][ # # ]
339 : : }
340 [ + + ]: 7 : else if( ::svx::SvXMLGraphicImportHelper_getImplementationName().equalsAscii( pImplName ) )
341 : : {
342 : : xFactory = ::cppu::createSingleFactory(
343 : : reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
344 : : ::svx::SvXMLGraphicImportHelper_getImplementationName(),
345 : : ::svx::SvXMLGraphicImportHelper_createInstance,
346 [ + - ][ + - ]: 2 : ::svx::SvXMLGraphicImportHelper_getSupportedServiceNames() );
[ + - ][ + - ]
347 : : }
348 [ + - ]: 5 : else if( ::svx::SvXMLGraphicExportHelper_getImplementationName().equalsAscii( pImplName ) )
349 : : {
350 : : xFactory = ::cppu::createSingleFactory(
351 : : reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
352 : : ::svx::SvXMLGraphicExportHelper_getImplementationName(),
353 : : ::svx::SvXMLGraphicExportHelper_createInstance,
354 [ + - ][ + - ]: 5 : ::svx::SvXMLGraphicExportHelper_getSupportedServiceNames() );
[ + - ][ + - ]
355 : : }
356 [ + - ]: 72 : if( xFactory.is())
357 : : {
358 [ + - ]: 72 : xFactory->acquire();
359 [ + - ]: 72 : pRet = xFactory.get();
360 : 72 : }
361 : : }
362 : :
363 : 72 : return pRet;
364 : : }
365 : :
366 : : }
367 : :
368 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|