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_toolkit.hxx" 26 27 28 #include <toolkit/awt/vclxcontainer.hxx> 29 #include <toolkit/helper/macros.hxx> 30 #include <toolkit/helper/vclunohelper.hxx> 31 #include <cppuhelper/typeprovider.hxx> 32 #include <rtl/memory.h> 33 #include <rtl/uuid.h> 34 35 #include <vcl/window.hxx> 36 #include <tools/debug.hxx> 37 38 // ---------------------------------------------------- 39 // class VCLXContainer 40 // ---------------------------------------------------- 41 42 void VCLXContainer::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 43 { 44 VCLXWindow::ImplGetPropertyIds( rIds ); 45 } 46 47 VCLXContainer::VCLXContainer() 48 { 49 } 50 51 VCLXContainer::~VCLXContainer() 52 { 53 } 54 55 // ::com::sun::star::uno::XInterface 56 ::com::sun::star::uno::Any VCLXContainer::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 57 { 58 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 59 SAL_STATIC_CAST( ::com::sun::star::awt::XVclContainer*, this ), 60 SAL_STATIC_CAST( ::com::sun::star::awt::XVclContainerPeer*, this ) ); 61 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); 62 } 63 64 // ::com::sun::star::lang::XTypeProvider 65 IMPL_XTYPEPROVIDER_START( VCLXContainer ) 66 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainer>* ) NULL ), 67 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainerPeer>* ) NULL ), 68 VCLXWindow::getTypes() 69 IMPL_XTYPEPROVIDER_END 70 71 72 // ::com::sun::star::awt::XVclContainer 73 void VCLXContainer::addVclContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainerListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) 74 { 75 ::vos::OGuard aGuard( GetMutex() ); 76 77 GetContainerListeners().addInterface( rxListener ); 78 } 79 80 void VCLXContainer::removeVclContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainerListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) 81 { 82 ::vos::OGuard aGuard( GetMutex() ); 83 84 GetContainerListeners().removeInterface( rxListener ); 85 } 86 87 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > > VCLXContainer::getWindows( ) throw(::com::sun::star::uno::RuntimeException) 88 { 89 ::vos::OGuard aGuard( GetMutex() ); 90 91 // Bei allen Childs das Container-Interface abfragen... 92 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > > aSeq; 93 Window* pWindow = GetWindow(); 94 if ( pWindow ) 95 { 96 sal_uInt16 nChilds = pWindow->GetChildCount(); 97 if ( nChilds ) 98 { 99 aSeq = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > >( nChilds ); 100 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > * pChildRefs = aSeq.getArray(); 101 for ( sal_uInt16 n = 0; n < nChilds; n++ ) 102 { 103 Window* pChild = pWindow->GetChild( n ); 104 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xWP = pChild->GetComponentInterface( sal_True ); 105 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xW( xWP, ::com::sun::star::uno::UNO_QUERY ); 106 pChildRefs[n] = xW; 107 } 108 } 109 } 110 return aSeq; 111 } 112 113 114 // ::com::sun::star::awt::XVclContainerPeer 115 void VCLXContainer::enableDialogControl( sal_Bool bEnable ) throw(::com::sun::star::uno::RuntimeException) 116 { 117 ::vos::OGuard aGuard( GetMutex() ); 118 119 Window* pWindow = GetWindow(); 120 if ( pWindow ) 121 { 122 WinBits nStyle = pWindow->GetStyle(); 123 if ( bEnable ) 124 nStyle |= WB_DIALOGCONTROL; 125 else 126 nStyle &= (~WB_DIALOGCONTROL); 127 pWindow->SetStyle( nStyle ); 128 } 129 } 130 131 void VCLXContainer::setTabOrder( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > >& Components, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Tabs, sal_Bool bGroupControl ) throw(::com::sun::star::uno::RuntimeException) 132 { 133 ::vos::OGuard aGuard( GetMutex() ); 134 135 sal_uInt32 nCount = Components.getLength(); 136 DBG_ASSERT( nCount == (sal_uInt32)Tabs.getLength(), "setTabOrder: TabCount != ComponentCount" ); 137 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > * pComps = Components.getConstArray(); 138 const ::com::sun::star::uno::Any* pTabs = Tabs.getConstArray(); 139 140 Window* pPrevWin = NULL; 141 for ( sal_uInt32 n = 0; n < nCount; n++ ) 142 { 143 // ::com::sun::star::style::TabStop 144 Window* pWin = VCLUnoHelper::GetWindow( pComps[n] ); 145 // NULL kann vorkommen, wenn die ::com::sun::star::uno::Sequence vom TabController kommt und eine Peer fehlt! 146 if ( pWin ) 147 { 148 // Reihenfolge der Fenster vor der Manipulation des Styles, 149 // weil z.B. der RadioButton in StateChanged das PREV-Window beruecksichtigt. 150 if ( pPrevWin ) 151 pWin->SetZOrder( pPrevWin, WINDOW_ZORDER_BEHIND ); 152 153 WinBits nStyle = pWin->GetStyle(); 154 nStyle &= ~(WB_TABSTOP|WB_NOTABSTOP|WB_GROUP); 155 if ( pTabs[n].getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_BOOLEAN ) 156 { 157 sal_Bool bTab = false; 158 pTabs[n] >>= bTab; 159 nStyle |= ( bTab ? WB_TABSTOP : WB_NOTABSTOP ); 160 } 161 pWin->SetStyle( nStyle ); 162 163 if ( bGroupControl ) 164 { 165 if ( n == 0 ) 166 pWin->SetDialogControlStart( sal_True ); 167 else 168 pWin->SetDialogControlStart( sal_False ); 169 } 170 171 pPrevWin = pWin; 172 } 173 } 174 } 175 176 void VCLXContainer::setGroup( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > >& Components ) throw(::com::sun::star::uno::RuntimeException) 177 { 178 ::vos::OGuard aGuard( GetMutex() ); 179 180 sal_uInt32 nCount = Components.getLength(); 181 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > * pComps = Components.getConstArray(); 182 183 Window* pPrevWin = NULL; 184 Window* pPrevRadio = NULL; 185 for ( sal_uInt32 n = 0; n < nCount; n++ ) 186 { 187 Window* pWin = VCLUnoHelper::GetWindow( pComps[n] ); 188 if ( pWin ) 189 { 190 Window* pSortBehind = pPrevWin; 191 // #57096# Alle Radios hintereinander sortieren... 192 sal_Bool bNewPrevWin = sal_True; 193 if ( pWin->GetType() == WINDOW_RADIOBUTTON ) 194 { 195 if ( pPrevRadio ) 196 { 197 bNewPrevWin = ( pPrevWin == pPrevRadio ); // Radio-Button wurde vor das PreWin sortiert.... 198 pSortBehind = pPrevRadio; 199 } 200 pPrevRadio = pWin; 201 } 202 203 // Z-Order 204 if ( pSortBehind ) 205 pWin->SetZOrder( pSortBehind, WINDOW_ZORDER_BEHIND ); 206 207 WinBits nStyle = pWin->GetStyle(); 208 if ( n == 0 ) 209 nStyle |= WB_GROUP; 210 else 211 nStyle &= (~WB_GROUP); 212 pWin->SetStyle( nStyle ); 213 214 // Ein WB_GROUP hinter die Gruppe, falls keine Gruppe mehr folgt. 215 if ( n == ( nCount - 1 ) ) 216 { 217 Window* pBehindLast = pWin->GetWindow( WINDOW_NEXT ); 218 if ( pBehindLast ) 219 { 220 WinBits nLastStyle = pBehindLast->GetStyle(); 221 nLastStyle |= WB_GROUP; 222 pBehindLast->SetStyle( nLastStyle ); 223 } 224 } 225 226 if ( bNewPrevWin ) 227 pPrevWin = pWin; 228 } 229 } 230 } 231 232 233 234 235 236