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 : :
30 : : #include "hatchwindowfactory.hxx"
31 : : #include "hatchwindow.hxx"
32 : : #include "cppuhelper/factory.hxx"
33 : : #include <vcl/svapp.hxx>
34 : :
35 : : #include "documentcloser.hxx"
36 : :
37 : : using namespace ::com::sun::star;
38 : :
39 : : //-------------------------------------------------------------------------
40 : 2 : uno::Sequence< ::rtl::OUString > SAL_CALL OHatchWindowFactory::impl_staticGetSupportedServiceNames()
41 : : {
42 : 2 : uno::Sequence< ::rtl::OUString > aRet(2);
43 [ + - ][ + - ]: 2 : aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.embed.HatchWindowFactory" ));
44 [ + - ][ + - ]: 2 : aRet[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.embed.HatchWindowFactory" ));
45 : 2 : return aRet;
46 : : }
47 : :
48 : : //-------------------------------------------------------------------------
49 : 4 : ::rtl::OUString SAL_CALL OHatchWindowFactory::impl_staticGetImplementationName()
50 : : {
51 : 4 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.embed.HatchWindowFactory" ));
52 : : }
53 : :
54 : : //-------------------------------------------------------------------------
55 : 2 : uno::Reference< uno::XInterface > SAL_CALL OHatchWindowFactory::impl_staticCreateSelfInstance(
56 : : const uno::Reference< lang::XMultiServiceFactory >& xServiceManager )
57 : : {
58 [ + - ]: 2 : return uno::Reference< uno::XInterface >( *new OHatchWindowFactory( xServiceManager ) );
59 : : }
60 : :
61 : :
62 : : //-------------------------------------------------------------------------
63 : 2 : uno::Reference< embed::XHatchWindow > SAL_CALL OHatchWindowFactory::createHatchWindowInstance(
64 : : const uno::Reference< awt::XWindowPeer >& xParent,
65 : : const awt::Rectangle& aBounds,
66 : : const awt::Size& aHandlerSize )
67 : : throw (uno::RuntimeException)
68 : : {
69 [ - + ]: 2 : if ( !xParent.is() )
70 [ # # ]: 0 : throw lang::IllegalArgumentException(); // TODO
71 : :
72 [ + - ]: 2 : SolarMutexGuard aGuard;
73 [ + - ]: 2 : VCLXHatchWindow* pResult = new VCLXHatchWindow();
74 [ + - ]: 2 : pResult->initializeWindow( xParent, aBounds, aHandlerSize );
75 [ + - ][ + - ]: 2 : return uno::Reference< embed::XHatchWindow >( static_cast< embed::XHatchWindow* >( pResult ) );
76 : : }
77 : :
78 : : //-------------------------------------------------------------------------
79 : 0 : ::rtl::OUString SAL_CALL OHatchWindowFactory::getImplementationName()
80 : : throw ( uno::RuntimeException )
81 : : {
82 : 0 : return impl_staticGetImplementationName();
83 : : }
84 : :
85 : : //-------------------------------------------------------------------------
86 : 0 : sal_Bool SAL_CALL OHatchWindowFactory::supportsService( const ::rtl::OUString& ServiceName )
87 : : throw ( uno::RuntimeException )
88 : : {
89 [ # # ]: 0 : uno::Sequence< ::rtl::OUString > aSeq = impl_staticGetSupportedServiceNames();
90 : :
91 [ # # ]: 0 : for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
92 [ # # ][ # # ]: 0 : if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
93 : 0 : return sal_True;
94 : :
95 [ # # ]: 0 : return sal_False;
96 : : }
97 : :
98 : : //-------------------------------------------------------------------------
99 : 0 : uno::Sequence< ::rtl::OUString > SAL_CALL OHatchWindowFactory::getSupportedServiceNames()
100 : : throw ( uno::RuntimeException )
101 : : {
102 : 0 : return impl_staticGetSupportedServiceNames();
103 : : }
104 : :
105 : : //-------------------------------------------------------------------------
106 : :
107 : : extern "C"
108 : : {
109 : :
110 : 2 : SAL_DLLPUBLIC_EXPORT void * SAL_CALL hatchwindowfactory_component_getFactory (
111 : : const sal_Char * pImplementationName, void * pServiceManager, void * /* pRegistryKey */)
112 : : {
113 : 2 : void * pResult = 0;
114 [ + - ]: 2 : if (pServiceManager)
115 : : {
116 : 2 : uno::Reference< lang::XSingleServiceFactory > xFactory;
117 [ + - ][ + - ]: 2 : if (OHatchWindowFactory::impl_staticGetImplementationName().compareToAscii (pImplementationName ) == 0)
118 : : {
119 : : xFactory = cppu::createOneInstanceFactory(
120 : : reinterpret_cast< lang::XMultiServiceFactory* >(pServiceManager),
121 : : OHatchWindowFactory::impl_staticGetImplementationName(),
122 : : OHatchWindowFactory::impl_staticCreateSelfInstance,
123 [ + - ][ + - ]: 2 : OHatchWindowFactory::impl_staticGetSupportedServiceNames());
[ + - ][ + - ]
[ + - ][ + - ]
124 : : }
125 [ # # ][ # # ]: 0 : else if (ODocumentCloser::impl_staticGetImplementationName().compareToAscii (pImplementationName ) == 0)
126 : : {
127 : : xFactory = cppu::createSingleFactory(
128 : : reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ),
129 : : ODocumentCloser::impl_staticGetImplementationName(),
130 : : ODocumentCloser::impl_staticCreateSelfInstance,
131 [ # # ][ # # ]: 0 : ODocumentCloser::impl_staticGetSupportedServiceNames() );
[ # # ][ # # ]
[ # # ][ # # ]
132 : : }
133 : :
134 [ + - ]: 2 : if (xFactory.is())
135 : : {
136 [ + - ]: 2 : xFactory->acquire();
137 [ + - ]: 2 : pResult = xFactory.get();
138 : 2 : }
139 : : }
140 : 2 : return pResult;
141 : : }
142 : :
143 : : } // extern "C"
144 : :
145 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|