update dev300-m58
[ooovba.git] / framework / source / tabwin / tabwinfactory.cxx
blobbde6ef7524523637b0578b2c5920a236d7ae0a11
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tabwinfactory.cxx,v $
10 * $Revision: 1.4 $
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_framework.hxx"
33 #include <tabwin/tabwinfactory.hxx>
34 #include <tabwin/tabwindow.hxx>
36 //_________________________________________________________________________________________________________________
37 // my own includes
38 //_________________________________________________________________________________________________________________
39 #include <threadhelp/resetableguard.hxx>
41 //_________________________________________________________________________________________________________________
42 // interface includes
43 //_________________________________________________________________________________________________________________
44 #include <com/sun/star/util/XURLTransformer.hpp>
45 #include <com/sun/star/lang/XInitialization.hpp>
46 #include <com/sun/star/awt/XTopWindow.hpp>
47 #include <com/sun/star/awt/WindowAttribute.hpp>
49 //_________________________________________________________________________________________________________________
50 // includes of other projects
51 //_________________________________________________________________________________________________________________
52 #include <vcl/svapp.hxx>
53 #include <tools/urlobj.hxx>
54 #include <rtl/ustrbuf.hxx>
56 //_________________________________________________________________________________________________________________
57 // Defines
58 //_________________________________________________________________________________________________________________
61 using namespace rtl;
62 using namespace com::sun::star::uno;
63 using namespace com::sun::star::lang;
64 using namespace com::sun::star::beans;
65 using namespace com::sun::star::util;
67 namespace framework
70 //*****************************************************************************************************************
71 // XInterface, XTypeProvider, XServiceInfo
72 //*****************************************************************************************************************
73 DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( TabWinFactory ,
74 ::cppu::OWeakObject ,
75 SERVICENAME_TABWINFACTORY ,
76 IMPLEMENTATIONNAME_TABWINFACTORY
79 DEFINE_INIT_SERVICE ( TabWinFactory, {} )
81 TabWinFactory::TabWinFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) :
82 ThreadHelpBase( &Application::GetSolarMutex() )
83 , m_xServiceManager( xServiceManager )
87 TabWinFactory::~TabWinFactory()
91 css::uno::Reference< css::uno::XInterface > SAL_CALL TabWinFactory::createInstanceWithContext(
92 const css::uno::Reference< css::uno::XComponentContext >& Context )
93 throw ( css::uno::Exception, css::uno::RuntimeException )
95 css::uno::Sequence< css::uno::Any > aArgs;
97 return createInstanceWithArgumentsAndContext( aArgs, Context );
100 css::uno::Reference< css::uno::XInterface > SAL_CALL TabWinFactory::createInstanceWithArgumentsAndContext(
101 const css::uno::Sequence< css::uno::Any >& Arguments, const css::uno::Reference< css::uno::XComponentContext >& )
102 throw ( css::uno::Exception, css::uno::RuntimeException )
104 const rtl::OUString aTopWindowArgName( RTL_CONSTASCII_USTRINGPARAM( "TopWindow" ));
106 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
107 ResetableGuard aLock( m_aLock );
108 css::uno::Reference< css::awt::XToolkit > xToolkit = m_xToolkit;
109 css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR( m_xServiceManager );
110 aLock.unlock();
111 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
113 css::uno::Reference< css::uno::XInterface > xReturn;
114 css::uno::Reference< css::awt::XTopWindow > xTopWindow;
115 css::beans::PropertyValue aPropValue;
117 for ( sal_Int32 i = 0; i < Arguments.getLength(); i++ )
119 if ( Arguments[i] >>= aPropValue )
121 if ( aPropValue.Name == aTopWindowArgName )
122 aPropValue.Value >>= xTopWindow;
126 if ( !xToolkit.is() && xSMGR.is() )
128 xToolkit = css::uno::Reference< css::awt::XToolkit >( xSMGR->createInstance( SERVICENAME_VCLTOOLKIT ), css::uno::UNO_QUERY );
129 if ( xToolkit.is() )
131 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
132 aLock.lock();
133 m_xToolkit = xToolkit;
134 aLock.unlock();
135 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
139 if ( !xTopWindow.is() )
141 if ( xToolkit.is() )
143 // describe window properties.
144 css::awt::WindowDescriptor aDescriptor;
145 aDescriptor.Type = css::awt::WindowClass_TOP ;
146 aDescriptor.ParentIndex = -1 ;
147 aDescriptor.Parent = css::uno::Reference< css::awt::XWindowPeer >() ;
148 aDescriptor.Bounds = css::awt::Rectangle(0,0,0,0) ;
149 aDescriptor.WindowAttributes = css::awt::WindowAttribute::BORDER|
150 css::awt::WindowAttribute::SIZEABLE|
151 css::awt::WindowAttribute::MOVEABLE|
152 css::awt::WindowAttribute::CLOSEABLE|
153 css::awt::WindowAttribute::MINSIZE;
155 // create a parent window
156 xTopWindow = css::uno::Reference< css::awt::XTopWindow >(
157 xToolkit->createWindow( aDescriptor ), css::uno::UNO_QUERY );
161 if ( xTopWindow.is() )
163 TabWindow* pTabWindow = new TabWindow( xSMGR );
165 css::uno::Sequence< css::uno::Any > aArgs( 1 );
167 aPropValue.Name = aTopWindowArgName;
168 aPropValue.Value = css::uno::makeAny( xTopWindow );
169 aArgs[0] = css::uno::makeAny( aPropValue );
170 pTabWindow->initialize( aArgs );
172 xReturn = css::uno::Reference< css::uno::XInterface >(
173 static_cast< OWeakObject* >( pTabWindow ), css::uno::UNO_QUERY );
176 return xReturn;