1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hatchwindowfactory.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
34 #include "hatchwindowfactory.hxx"
35 #include "hatchwindow.hxx"
36 #include "cppuhelper/factory.hxx"
38 #include "documentcloser.hxx"
40 using namespace ::com::sun::star
;
42 //-------------------------------------------------------------------------
43 uno::Sequence
< ::rtl::OUString
> SAL_CALL
OHatchWindowFactory::impl_staticGetSupportedServiceNames()
45 uno::Sequence
< ::rtl::OUString
> aRet(2);
46 aRet
[0] = ::rtl::OUString::createFromAscii("com.sun.star.embed.HatchWindowFactory");
47 aRet
[1] = ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.HatchWindowFactory");
51 //-------------------------------------------------------------------------
52 ::rtl::OUString SAL_CALL
OHatchWindowFactory::impl_staticGetImplementationName()
54 return ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.HatchWindowFactory");
57 //-------------------------------------------------------------------------
58 uno::Reference
< uno::XInterface
> SAL_CALL
OHatchWindowFactory::impl_staticCreateSelfInstance(
59 const uno::Reference
< lang::XMultiServiceFactory
>& xServiceManager
)
61 return uno::Reference
< uno::XInterface
>( *new OHatchWindowFactory( xServiceManager
) );
65 //-------------------------------------------------------------------------
66 uno::Reference
< embed::XHatchWindow
> SAL_CALL
OHatchWindowFactory::createHatchWindowInstance(
67 const uno::Reference
< awt::XWindowPeer
>& xParent
,
68 const awt::Rectangle
& aBounds
,
69 const awt::Size
& aHandlerSize
)
70 throw (uno::RuntimeException
)
73 throw lang::IllegalArgumentException(); // TODO
75 VCLXHatchWindow
* pResult
= new VCLXHatchWindow();
76 pResult
->initializeWindow( xParent
, aBounds
, aHandlerSize
);
77 return uno::Reference
< embed::XHatchWindow
>( static_cast< embed::XHatchWindow
* >( pResult
) );
80 //-------------------------------------------------------------------------
81 ::rtl::OUString SAL_CALL
OHatchWindowFactory::getImplementationName()
82 throw ( uno::RuntimeException
)
84 return impl_staticGetImplementationName();
87 //-------------------------------------------------------------------------
88 sal_Bool SAL_CALL
OHatchWindowFactory::supportsService( const ::rtl::OUString
& ServiceName
)
89 throw ( uno::RuntimeException
)
91 uno::Sequence
< ::rtl::OUString
> aSeq
= impl_staticGetSupportedServiceNames();
93 for ( sal_Int32 nInd
= 0; nInd
< aSeq
.getLength(); nInd
++ )
94 if ( ServiceName
.compareTo( aSeq
[nInd
] ) == 0 )
100 //-------------------------------------------------------------------------
101 uno::Sequence
< ::rtl::OUString
> SAL_CALL
OHatchWindowFactory::getSupportedServiceNames()
102 throw ( uno::RuntimeException
)
104 return impl_staticGetSupportedServiceNames();
107 //-------------------------------------------------------------------------
112 SAL_DLLPUBLIC_EXPORT
void SAL_CALL
component_getImplementationEnvironment (
113 const sal_Char
** ppEnvTypeName
, uno_Environment
** /* ppEnv */)
115 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
118 SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL
component_writeInfo (
119 void * /* pServiceManager */, void * pRegistryKey
)
123 uno::Reference
< registry::XRegistryKey
> xRegistryKey (
124 reinterpret_cast< registry::XRegistryKey
* >(pRegistryKey
));
125 uno::Reference
< registry::XRegistryKey
> xNewKey
;
127 // OHatchWindowFactory registration
129 xNewKey
= xRegistryKey
->createKey (
130 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
131 OHatchWindowFactory::impl_staticGetImplementationName() +
132 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") ) );
134 uno::Sequence
< ::rtl::OUString
> aServices
=
135 OHatchWindowFactory::impl_staticGetSupportedServiceNames();
136 for (sal_Int32 i
= 0, n
= aServices
.getLength(); i
< n
; i
++ )
137 xNewKey
->createKey( aServices
.getConstArray()[i
] );
140 // ODocumentCloser registration
142 xNewKey
= xRegistryKey
->createKey (
143 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
144 ODocumentCloser::impl_staticGetImplementationName() +
145 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") ) );
147 aServices
= ODocumentCloser::impl_staticGetSupportedServiceNames();
148 for (sal_Int32 i
= 0, n
= aServices
.getLength(); i
< n
; i
++ )
149 xNewKey
->createKey( aServices
.getConstArray()[i
] );
157 SAL_DLLPUBLIC_EXPORT
void * SAL_CALL
component_getFactory (
158 const sal_Char
* pImplementationName
, void * pServiceManager
, void * /* pRegistryKey */)
163 uno::Reference
< lang::XSingleServiceFactory
> xFactory
;
164 if (OHatchWindowFactory::impl_staticGetImplementationName().compareToAscii (pImplementationName
) == 0)
166 xFactory
= cppu::createOneInstanceFactory(
167 reinterpret_cast< lang::XMultiServiceFactory
* >(pServiceManager
),
168 OHatchWindowFactory::impl_staticGetImplementationName(),
169 OHatchWindowFactory::impl_staticCreateSelfInstance
,
170 OHatchWindowFactory::impl_staticGetSupportedServiceNames());
172 else if (ODocumentCloser::impl_staticGetImplementationName().compareToAscii (pImplementationName
) == 0)
174 xFactory
= cppu::createSingleFactory(
175 reinterpret_cast< lang::XMultiServiceFactory
* >( pServiceManager
),
176 ODocumentCloser::impl_staticGetImplementationName(),
177 ODocumentCloser::impl_staticCreateSelfInstance
,
178 ODocumentCloser::impl_staticGetSupportedServiceNames() );
184 pResult
= xFactory
.get();