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 <tabwin/tabwinfactory.hxx>
30 : : #include <tabwin/tabwindow.hxx>
31 : :
32 : : #include <threadhelp/resetableguard.hxx>
33 : :
34 : : #include <com/sun/star/util/XURLTransformer.hpp>
35 : : #include <com/sun/star/lang/XInitialization.hpp>
36 : : #include <com/sun/star/awt/XTopWindow.hpp>
37 : : #include <com/sun/star/awt/WindowAttribute.hpp>
38 : :
39 : : #include <vcl/svapp.hxx>
40 : : #include <rtl/ustrbuf.hxx>
41 : :
42 : : //_________________________________________________________________________________________________________________
43 : : // Defines
44 : : //_________________________________________________________________________________________________________________
45 : :
46 : : using ::rtl::OUString;
47 : : using namespace com::sun::star::uno;
48 : : using namespace com::sun::star::lang;
49 : : using namespace com::sun::star::beans;
50 : : using namespace com::sun::star::util;
51 : :
52 : : namespace framework
53 : : {
54 : :
55 : : //*****************************************************************************************************************
56 : : // XInterface, XTypeProvider, XServiceInfo
57 : : //*****************************************************************************************************************
58 : 0 : DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( TabWinFactory ,
59 : : ::cppu::OWeakObject ,
60 : : SERVICENAME_TABWINFACTORY ,
61 : : IMPLEMENTATIONNAME_TABWINFACTORY
62 : : )
63 : :
64 : 0 : DEFINE_INIT_SERVICE ( TabWinFactory, {} )
65 : :
66 : 0 : TabWinFactory::TabWinFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) :
67 : 0 : ThreadHelpBase( &Application::GetSolarMutex() )
68 : 0 : , m_xServiceManager( xServiceManager )
69 : : {
70 : 0 : }
71 : :
72 : 0 : TabWinFactory::~TabWinFactory()
73 : : {
74 : 0 : }
75 : :
76 : 0 : css::uno::Reference< css::uno::XInterface > SAL_CALL TabWinFactory::createInstanceWithContext(
77 : : const css::uno::Reference< css::uno::XComponentContext >& Context )
78 : : throw ( css::uno::Exception, css::uno::RuntimeException )
79 : : {
80 : 0 : css::uno::Sequence< css::uno::Any > aArgs;
81 : :
82 : 0 : return createInstanceWithArgumentsAndContext( aArgs, Context );
83 : : }
84 : :
85 : 0 : css::uno::Reference< css::uno::XInterface > SAL_CALL TabWinFactory::createInstanceWithArgumentsAndContext(
86 : : const css::uno::Sequence< css::uno::Any >& Arguments, const css::uno::Reference< css::uno::XComponentContext >& )
87 : : throw ( css::uno::Exception, css::uno::RuntimeException )
88 : : {
89 : 0 : const rtl::OUString aTopWindowArgName( RTL_CONSTASCII_USTRINGPARAM( "TopWindow" ));
90 : :
91 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
92 : 0 : ResetableGuard aLock( m_aLock );
93 : 0 : css::uno::Reference< css::awt::XToolkit > xToolkit = m_xToolkit;
94 : 0 : css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR( m_xServiceManager );
95 : 0 : aLock.unlock();
96 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
97 : :
98 : 0 : css::uno::Reference< css::uno::XInterface > xReturn;
99 : 0 : css::uno::Reference< css::awt::XTopWindow > xTopWindow;
100 : 0 : css::beans::PropertyValue aPropValue;
101 : :
102 : 0 : for ( sal_Int32 i = 0; i < Arguments.getLength(); i++ )
103 : : {
104 : 0 : if ( Arguments[i] >>= aPropValue )
105 : : {
106 : 0 : if ( aPropValue.Name == aTopWindowArgName )
107 : 0 : aPropValue.Value >>= xTopWindow;
108 : : }
109 : : }
110 : :
111 : 0 : if ( !xToolkit.is() && xSMGR.is() )
112 : : {
113 : 0 : xToolkit = css::uno::Reference< css::awt::XToolkit >( xSMGR->createInstance( SERVICENAME_VCLTOOLKIT ), css::uno::UNO_QUERY );
114 : 0 : if ( xToolkit.is() )
115 : : {
116 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
117 : 0 : aLock.lock();
118 : 0 : m_xToolkit = xToolkit;
119 : 0 : aLock.unlock();
120 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
121 : : }
122 : : }
123 : :
124 : 0 : if ( !xTopWindow.is() )
125 : : {
126 : 0 : if ( xToolkit.is() )
127 : : {
128 : : // describe window properties.
129 : 0 : css::awt::WindowDescriptor aDescriptor;
130 : 0 : aDescriptor.Type = css::awt::WindowClass_TOP ;
131 : 0 : aDescriptor.ParentIndex = -1 ;
132 : 0 : aDescriptor.Parent = css::uno::Reference< css::awt::XWindowPeer >() ;
133 : 0 : aDescriptor.Bounds = css::awt::Rectangle(0,0,0,0) ;
134 : : aDescriptor.WindowAttributes = css::awt::WindowAttribute::BORDER|
135 : : css::awt::WindowAttribute::SIZEABLE|
136 : : css::awt::WindowAttribute::MOVEABLE|
137 : : css::awt::WindowAttribute::CLOSEABLE|
138 : 0 : css::awt::WindowAttribute::MINSIZE;
139 : :
140 : : // create a parent window
141 : : xTopWindow = css::uno::Reference< css::awt::XTopWindow >(
142 : 0 : xToolkit->createWindow( aDescriptor ), css::uno::UNO_QUERY );
143 : : }
144 : : }
145 : :
146 : 0 : if ( xTopWindow.is() )
147 : : {
148 : 0 : TabWindow* pTabWindow = new TabWindow( xSMGR );
149 : :
150 : 0 : css::uno::Sequence< css::uno::Any > aArgs( 1 );
151 : :
152 : 0 : aPropValue.Name = aTopWindowArgName;
153 : 0 : aPropValue.Value = css::uno::makeAny( xTopWindow );
154 : 0 : aArgs[0] = css::uno::makeAny( aPropValue );
155 : 0 : pTabWindow->initialize( aArgs );
156 : :
157 : : xReturn = css::uno::Reference< css::uno::XInterface >(
158 : 0 : static_cast< OWeakObject* >( pTabWindow ), css::uno::UNO_QUERY );
159 : : }
160 : :
161 : 0 : return xReturn;
162 : : }
163 : :
164 : : }
165 : :
166 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|