1*5900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*5900e8ecSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*5900e8ecSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*5900e8ecSAndrew Rist * distributed with this work for additional information
6*5900e8ecSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*5900e8ecSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*5900e8ecSAndrew Rist * "License"); you may not use this file except in compliance
9*5900e8ecSAndrew Rist * with the License. You may obtain a copy of the License at
10*5900e8ecSAndrew Rist *
11*5900e8ecSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*5900e8ecSAndrew Rist *
13*5900e8ecSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*5900e8ecSAndrew Rist * software distributed under the License is distributed on an
15*5900e8ecSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5900e8ecSAndrew Rist * KIND, either express or implied. See the License for the
17*5900e8ecSAndrew Rist * specific language governing permissions and limitations
18*5900e8ecSAndrew Rist * under the License.
19*5900e8ecSAndrew Rist *
20*5900e8ecSAndrew Rist *************************************************************/
21*5900e8ecSAndrew Rist
22*5900e8ecSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "hatchwindowfactory.hxx"
28cdf0e10cSrcweir #include "hatchwindow.hxx"
29cdf0e10cSrcweir #include "cppuhelper/factory.hxx"
30cdf0e10cSrcweir #include <vcl/svapp.hxx>
31cdf0e10cSrcweir
32cdf0e10cSrcweir #include "documentcloser.hxx"
33cdf0e10cSrcweir
34cdf0e10cSrcweir using namespace ::com::sun::star;
35cdf0e10cSrcweir
36cdf0e10cSrcweir //-------------------------------------------------------------------------
impl_staticGetSupportedServiceNames()37cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL OHatchWindowFactory::impl_staticGetSupportedServiceNames()
38cdf0e10cSrcweir {
39cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aRet(2);
40cdf0e10cSrcweir aRet[0] = ::rtl::OUString::createFromAscii("com.sun.star.embed.HatchWindowFactory");
41cdf0e10cSrcweir aRet[1] = ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.HatchWindowFactory");
42cdf0e10cSrcweir return aRet;
43cdf0e10cSrcweir }
44cdf0e10cSrcweir
45cdf0e10cSrcweir //-------------------------------------------------------------------------
impl_staticGetImplementationName()46cdf0e10cSrcweir ::rtl::OUString SAL_CALL OHatchWindowFactory::impl_staticGetImplementationName()
47cdf0e10cSrcweir {
48cdf0e10cSrcweir return ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.HatchWindowFactory");
49cdf0e10cSrcweir }
50cdf0e10cSrcweir
51cdf0e10cSrcweir //-------------------------------------------------------------------------
impl_staticCreateSelfInstance(const uno::Reference<lang::XMultiServiceFactory> & xServiceManager)52cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL OHatchWindowFactory::impl_staticCreateSelfInstance(
53cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& xServiceManager )
54cdf0e10cSrcweir {
55cdf0e10cSrcweir return uno::Reference< uno::XInterface >( *new OHatchWindowFactory( xServiceManager ) );
56cdf0e10cSrcweir }
57cdf0e10cSrcweir
58cdf0e10cSrcweir
59cdf0e10cSrcweir //-------------------------------------------------------------------------
createHatchWindowInstance(const uno::Reference<awt::XWindowPeer> & xParent,const awt::Rectangle & aBounds,const awt::Size & aHandlerSize)60cdf0e10cSrcweir uno::Reference< embed::XHatchWindow > SAL_CALL OHatchWindowFactory::createHatchWindowInstance(
61cdf0e10cSrcweir const uno::Reference< awt::XWindowPeer >& xParent,
62cdf0e10cSrcweir const awt::Rectangle& aBounds,
63cdf0e10cSrcweir const awt::Size& aHandlerSize )
64cdf0e10cSrcweir throw (uno::RuntimeException)
65cdf0e10cSrcweir {
66cdf0e10cSrcweir if ( !xParent.is() )
67cdf0e10cSrcweir throw lang::IllegalArgumentException(); // TODO
68cdf0e10cSrcweir
69cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() );
70cdf0e10cSrcweir VCLXHatchWindow* pResult = new VCLXHatchWindow();
71cdf0e10cSrcweir pResult->initializeWindow( xParent, aBounds, aHandlerSize );
72cdf0e10cSrcweir return uno::Reference< embed::XHatchWindow >( static_cast< embed::XHatchWindow* >( pResult ) );
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
75cdf0e10cSrcweir //-------------------------------------------------------------------------
getImplementationName()76cdf0e10cSrcweir ::rtl::OUString SAL_CALL OHatchWindowFactory::getImplementationName()
77cdf0e10cSrcweir throw ( uno::RuntimeException )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir return impl_staticGetImplementationName();
80cdf0e10cSrcweir }
81cdf0e10cSrcweir
82cdf0e10cSrcweir //-------------------------------------------------------------------------
supportsService(const::rtl::OUString & ServiceName)83cdf0e10cSrcweir sal_Bool SAL_CALL OHatchWindowFactory::supportsService( const ::rtl::OUString& ServiceName )
84cdf0e10cSrcweir throw ( uno::RuntimeException )
85cdf0e10cSrcweir {
86cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aSeq = impl_staticGetSupportedServiceNames();
87cdf0e10cSrcweir
88cdf0e10cSrcweir for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
89cdf0e10cSrcweir if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
90cdf0e10cSrcweir return sal_True;
91cdf0e10cSrcweir
92cdf0e10cSrcweir return sal_False;
93cdf0e10cSrcweir }
94cdf0e10cSrcweir
95cdf0e10cSrcweir //-------------------------------------------------------------------------
getSupportedServiceNames()96cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL OHatchWindowFactory::getSupportedServiceNames()
97cdf0e10cSrcweir throw ( uno::RuntimeException )
98cdf0e10cSrcweir {
99cdf0e10cSrcweir return impl_staticGetSupportedServiceNames();
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
102cdf0e10cSrcweir //-------------------------------------------------------------------------
103cdf0e10cSrcweir
104cdf0e10cSrcweir extern "C"
105cdf0e10cSrcweir {
106cdf0e10cSrcweir
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment **)107cdf0e10cSrcweir SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment (
108cdf0e10cSrcweir const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */)
109cdf0e10cSrcweir {
110cdf0e10cSrcweir *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
111cdf0e10cSrcweir }
112cdf0e10cSrcweir
component_getFactory(const sal_Char * pImplementationName,void * pServiceManager,void *)113cdf0e10cSrcweir SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory (
114cdf0e10cSrcweir const sal_Char * pImplementationName, void * pServiceManager, void * /* pRegistryKey */)
115cdf0e10cSrcweir {
116cdf0e10cSrcweir void * pResult = 0;
117cdf0e10cSrcweir if (pServiceManager)
118cdf0e10cSrcweir {
119cdf0e10cSrcweir uno::Reference< lang::XSingleServiceFactory > xFactory;
120cdf0e10cSrcweir if (OHatchWindowFactory::impl_staticGetImplementationName().compareToAscii (pImplementationName ) == 0)
121cdf0e10cSrcweir {
122cdf0e10cSrcweir xFactory = cppu::createOneInstanceFactory(
123cdf0e10cSrcweir reinterpret_cast< lang::XMultiServiceFactory* >(pServiceManager),
124cdf0e10cSrcweir OHatchWindowFactory::impl_staticGetImplementationName(),
125cdf0e10cSrcweir OHatchWindowFactory::impl_staticCreateSelfInstance,
126cdf0e10cSrcweir OHatchWindowFactory::impl_staticGetSupportedServiceNames());
127cdf0e10cSrcweir }
128cdf0e10cSrcweir else if (ODocumentCloser::impl_staticGetImplementationName().compareToAscii (pImplementationName ) == 0)
129cdf0e10cSrcweir {
130cdf0e10cSrcweir xFactory = cppu::createSingleFactory(
131cdf0e10cSrcweir reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ),
132cdf0e10cSrcweir ODocumentCloser::impl_staticGetImplementationName(),
133cdf0e10cSrcweir ODocumentCloser::impl_staticCreateSelfInstance,
134cdf0e10cSrcweir ODocumentCloser::impl_staticGetSupportedServiceNames() );
135cdf0e10cSrcweir }
136cdf0e10cSrcweir
137cdf0e10cSrcweir if (xFactory.is())
138cdf0e10cSrcweir {
139cdf0e10cSrcweir xFactory->acquire();
140cdf0e10cSrcweir pResult = xFactory.get();
141cdf0e10cSrcweir }
142cdf0e10cSrcweir }
143cdf0e10cSrcweir return pResult;
144cdf0e10cSrcweir }
145cdf0e10cSrcweir
146cdf0e10cSrcweir } // extern "C"
147