1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_framework.hxx" 26 #include <tabwin/tabwinfactory.hxx> 27 #include <tabwin/tabwindow.hxx> 28 29 //_________________________________________________________________________________________________________________ 30 // my own includes 31 //_________________________________________________________________________________________________________________ 32 #include <threadhelp/resetableguard.hxx> 33 34 //_________________________________________________________________________________________________________________ 35 // interface includes 36 //_________________________________________________________________________________________________________________ 37 #include <com/sun/star/util/XURLTransformer.hpp> 38 #include <com/sun/star/lang/XInitialization.hpp> 39 #include <com/sun/star/awt/XTopWindow.hpp> 40 #include <com/sun/star/awt/WindowAttribute.hpp> 41 42 //_________________________________________________________________________________________________________________ 43 // includes of other projects 44 //_________________________________________________________________________________________________________________ 45 #include <vcl/svapp.hxx> 46 #include <tools/urlobj.hxx> 47 #include <rtl/ustrbuf.hxx> 48 49 //_________________________________________________________________________________________________________________ 50 // Defines 51 //_________________________________________________________________________________________________________________ 52 // 53 54 using namespace rtl; 55 using namespace com::sun::star::uno; 56 using namespace com::sun::star::lang; 57 using namespace com::sun::star::beans; 58 using namespace com::sun::star::util; 59 60 namespace framework 61 { 62 63 //***************************************************************************************************************** 64 // XInterface, XTypeProvider, XServiceInfo 65 //***************************************************************************************************************** 66 DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( TabWinFactory , 67 ::cppu::OWeakObject , 68 SERVICENAME_TABWINFACTORY , 69 IMPLEMENTATIONNAME_TABWINFACTORY 70 ) 71 72 DEFINE_INIT_SERVICE ( TabWinFactory, {} ) 73 74 TabWinFactory::TabWinFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) : 75 ThreadHelpBase( &Application::GetSolarMutex() ) 76 , m_xServiceManager( xServiceManager ) 77 { 78 } 79 80 TabWinFactory::~TabWinFactory() 81 { 82 } 83 84 css::uno::Reference< css::uno::XInterface > SAL_CALL TabWinFactory::createInstanceWithContext( 85 const css::uno::Reference< css::uno::XComponentContext >& Context ) 86 throw ( css::uno::Exception, css::uno::RuntimeException ) 87 { 88 css::uno::Sequence< css::uno::Any > aArgs; 89 90 return createInstanceWithArgumentsAndContext( aArgs, Context ); 91 } 92 93 css::uno::Reference< css::uno::XInterface > SAL_CALL TabWinFactory::createInstanceWithArgumentsAndContext( 94 const css::uno::Sequence< css::uno::Any >& Arguments, const css::uno::Reference< css::uno::XComponentContext >& ) 95 throw ( css::uno::Exception, css::uno::RuntimeException ) 96 { 97 const rtl::OUString aTopWindowArgName( RTL_CONSTASCII_USTRINGPARAM( "TopWindow" )); 98 99 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 100 ResetableGuard aLock( m_aLock ); 101 css::uno::Reference< css::awt::XToolkit > xToolkit = m_xToolkit; 102 css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR( m_xServiceManager ); 103 aLock.unlock(); 104 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 105 106 css::uno::Reference< css::uno::XInterface > xReturn; 107 css::uno::Reference< css::awt::XTopWindow > xTopWindow; 108 css::beans::PropertyValue aPropValue; 109 110 for ( sal_Int32 i = 0; i < Arguments.getLength(); i++ ) 111 { 112 if ( Arguments[i] >>= aPropValue ) 113 { 114 if ( aPropValue.Name == aTopWindowArgName ) 115 aPropValue.Value >>= xTopWindow; 116 } 117 } 118 119 if ( !xToolkit.is() && xSMGR.is() ) 120 { 121 xToolkit = css::uno::Reference< css::awt::XToolkit >( xSMGR->createInstance( SERVICENAME_VCLTOOLKIT ), css::uno::UNO_QUERY ); 122 if ( xToolkit.is() ) 123 { 124 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 125 aLock.lock(); 126 m_xToolkit = xToolkit; 127 aLock.unlock(); 128 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 129 } 130 } 131 132 if ( !xTopWindow.is() ) 133 { 134 if ( xToolkit.is() ) 135 { 136 // describe window properties. 137 css::awt::WindowDescriptor aDescriptor; 138 aDescriptor.Type = css::awt::WindowClass_TOP ; 139 aDescriptor.ParentIndex = -1 ; 140 aDescriptor.Parent = css::uno::Reference< css::awt::XWindowPeer >() ; 141 aDescriptor.Bounds = css::awt::Rectangle(0,0,0,0) ; 142 aDescriptor.WindowAttributes = css::awt::WindowAttribute::BORDER| 143 css::awt::WindowAttribute::SIZEABLE| 144 css::awt::WindowAttribute::MOVEABLE| 145 css::awt::WindowAttribute::CLOSEABLE| 146 css::awt::WindowAttribute::MINSIZE; 147 148 // create a parent window 149 xTopWindow = css::uno::Reference< css::awt::XTopWindow >( 150 xToolkit->createWindow( aDescriptor ), css::uno::UNO_QUERY ); 151 } 152 } 153 154 if ( xTopWindow.is() ) 155 { 156 TabWindow* pTabWindow = new TabWindow( xSMGR ); 157 158 css::uno::Sequence< css::uno::Any > aArgs( 1 ); 159 160 aPropValue.Name = aTopWindowArgName; 161 aPropValue.Value = css::uno::makeAny( xTopWindow ); 162 aArgs[0] = css::uno::makeAny( aPropValue ); 163 pTabWindow->initialize( aArgs ); 164 165 xReturn = css::uno::Reference< css::uno::XInterface >( 166 static_cast< OWeakObject* >( pTabWindow ), css::uno::UNO_QUERY ); 167 } 168 169 return xReturn; 170 } 171 172 } 173