1*b0724fc6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b0724fc6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b0724fc6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b0724fc6SAndrew Rist * distributed with this work for additional information 6*b0724fc6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b0724fc6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b0724fc6SAndrew Rist * "License"); you may not use this file except in compliance 9*b0724fc6SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*b0724fc6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*b0724fc6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b0724fc6SAndrew Rist * software distributed under the License is distributed on an 15*b0724fc6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b0724fc6SAndrew Rist * KIND, either express or implied. See the License for the 17*b0724fc6SAndrew Rist * specific language governing permissions and limitations 18*b0724fc6SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*b0724fc6SAndrew Rist *************************************************************/ 21*b0724fc6SAndrew Rist 22*b0724fc6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_toolkit.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <toolkit/awt/vclxcontainer.hxx> 29cdf0e10cSrcweir #include <toolkit/helper/macros.hxx> 30cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 31cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 32cdf0e10cSrcweir #include <rtl/memory.h> 33cdf0e10cSrcweir #include <rtl/uuid.h> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include <vcl/window.hxx> 36cdf0e10cSrcweir #include <tools/debug.hxx> 37cdf0e10cSrcweir 38cdf0e10cSrcweir // ---------------------------------------------------- 39cdf0e10cSrcweir // class VCLXContainer 40cdf0e10cSrcweir // ---------------------------------------------------- 41cdf0e10cSrcweir 42cdf0e10cSrcweir void VCLXContainer::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 43cdf0e10cSrcweir { 44cdf0e10cSrcweir VCLXWindow::ImplGetPropertyIds( rIds ); 45cdf0e10cSrcweir } 46cdf0e10cSrcweir 47cdf0e10cSrcweir VCLXContainer::VCLXContainer() 48cdf0e10cSrcweir { 49cdf0e10cSrcweir } 50cdf0e10cSrcweir 51cdf0e10cSrcweir VCLXContainer::~VCLXContainer() 52cdf0e10cSrcweir { 53cdf0e10cSrcweir } 54cdf0e10cSrcweir 55cdf0e10cSrcweir // ::com::sun::star::uno::XInterface 56cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXContainer::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 57cdf0e10cSrcweir { 58cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 59cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XVclContainer*, this ), 60cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XVclContainerPeer*, this ) ); 61cdf0e10cSrcweir return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); 62cdf0e10cSrcweir } 63cdf0e10cSrcweir 64cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 65cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXContainer ) 66cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainer>* ) NULL ), 67cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainerPeer>* ) NULL ), 68cdf0e10cSrcweir VCLXWindow::getTypes() 69cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 70cdf0e10cSrcweir 71cdf0e10cSrcweir 72cdf0e10cSrcweir // ::com::sun::star::awt::XVclContainer 73cdf0e10cSrcweir void VCLXContainer::addVclContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainerListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) 74cdf0e10cSrcweir { 75cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 76cdf0e10cSrcweir 77cdf0e10cSrcweir GetContainerListeners().addInterface( rxListener ); 78cdf0e10cSrcweir } 79cdf0e10cSrcweir 80cdf0e10cSrcweir void VCLXContainer::removeVclContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainerListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) 81cdf0e10cSrcweir { 82cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 83cdf0e10cSrcweir 84cdf0e10cSrcweir GetContainerListeners().removeInterface( rxListener ); 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > > VCLXContainer::getWindows( ) throw(::com::sun::star::uno::RuntimeException) 88cdf0e10cSrcweir { 89cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 90cdf0e10cSrcweir 91cdf0e10cSrcweir // Bei allen Childs das Container-Interface abfragen... 92cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > > aSeq; 93cdf0e10cSrcweir Window* pWindow = GetWindow(); 94cdf0e10cSrcweir if ( pWindow ) 95cdf0e10cSrcweir { 96cdf0e10cSrcweir sal_uInt16 nChilds = pWindow->GetChildCount(); 97cdf0e10cSrcweir if ( nChilds ) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir aSeq = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > >( nChilds ); 100cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > * pChildRefs = aSeq.getArray(); 101cdf0e10cSrcweir for ( sal_uInt16 n = 0; n < nChilds; n++ ) 102cdf0e10cSrcweir { 103cdf0e10cSrcweir Window* pChild = pWindow->GetChild( n ); 104cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xWP = pChild->GetComponentInterface( sal_True ); 105cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xW( xWP, ::com::sun::star::uno::UNO_QUERY ); 106cdf0e10cSrcweir pChildRefs[n] = xW; 107cdf0e10cSrcweir } 108cdf0e10cSrcweir } 109cdf0e10cSrcweir } 110cdf0e10cSrcweir return aSeq; 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113cdf0e10cSrcweir 114cdf0e10cSrcweir // ::com::sun::star::awt::XVclContainerPeer 115cdf0e10cSrcweir void VCLXContainer::enableDialogControl( sal_Bool bEnable ) throw(::com::sun::star::uno::RuntimeException) 116cdf0e10cSrcweir { 117cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 118cdf0e10cSrcweir 119cdf0e10cSrcweir Window* pWindow = GetWindow(); 120cdf0e10cSrcweir if ( pWindow ) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir WinBits nStyle = pWindow->GetStyle(); 123cdf0e10cSrcweir if ( bEnable ) 124cdf0e10cSrcweir nStyle |= WB_DIALOGCONTROL; 125cdf0e10cSrcweir else 126cdf0e10cSrcweir nStyle &= (~WB_DIALOGCONTROL); 127cdf0e10cSrcweir pWindow->SetStyle( nStyle ); 128cdf0e10cSrcweir } 129cdf0e10cSrcweir } 130cdf0e10cSrcweir 131cdf0e10cSrcweir 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) 132cdf0e10cSrcweir { 133cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 134cdf0e10cSrcweir 135cdf0e10cSrcweir sal_uInt32 nCount = Components.getLength(); 136cdf0e10cSrcweir DBG_ASSERT( nCount == (sal_uInt32)Tabs.getLength(), "setTabOrder: TabCount != ComponentCount" ); 137cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > * pComps = Components.getConstArray(); 138cdf0e10cSrcweir const ::com::sun::star::uno::Any* pTabs = Tabs.getConstArray(); 139cdf0e10cSrcweir 140cdf0e10cSrcweir Window* pPrevWin = NULL; 141cdf0e10cSrcweir for ( sal_uInt32 n = 0; n < nCount; n++ ) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir // ::com::sun::star::style::TabStop 144cdf0e10cSrcweir Window* pWin = VCLUnoHelper::GetWindow( pComps[n] ); 145cdf0e10cSrcweir // NULL kann vorkommen, wenn die ::com::sun::star::uno::Sequence vom TabController kommt und eine Peer fehlt! 146cdf0e10cSrcweir if ( pWin ) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir // Reihenfolge der Fenster vor der Manipulation des Styles, 149cdf0e10cSrcweir // weil z.B. der RadioButton in StateChanged das PREV-Window beruecksichtigt. 150cdf0e10cSrcweir if ( pPrevWin ) 151cdf0e10cSrcweir pWin->SetZOrder( pPrevWin, WINDOW_ZORDER_BEHIND ); 152cdf0e10cSrcweir 153cdf0e10cSrcweir WinBits nStyle = pWin->GetStyle(); 154cdf0e10cSrcweir nStyle &= ~(WB_TABSTOP|WB_NOTABSTOP|WB_GROUP); 155cdf0e10cSrcweir if ( pTabs[n].getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_BOOLEAN ) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir sal_Bool bTab = false; 158cdf0e10cSrcweir pTabs[n] >>= bTab; 159cdf0e10cSrcweir nStyle |= ( bTab ? WB_TABSTOP : WB_NOTABSTOP ); 160cdf0e10cSrcweir } 161cdf0e10cSrcweir pWin->SetStyle( nStyle ); 162cdf0e10cSrcweir 163cdf0e10cSrcweir if ( bGroupControl ) 164cdf0e10cSrcweir { 165cdf0e10cSrcweir if ( n == 0 ) 166cdf0e10cSrcweir pWin->SetDialogControlStart( sal_True ); 167cdf0e10cSrcweir else 168cdf0e10cSrcweir pWin->SetDialogControlStart( sal_False ); 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir pPrevWin = pWin; 172cdf0e10cSrcweir } 173cdf0e10cSrcweir } 174cdf0e10cSrcweir } 175cdf0e10cSrcweir 176cdf0e10cSrcweir 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) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 179cdf0e10cSrcweir 180cdf0e10cSrcweir sal_uInt32 nCount = Components.getLength(); 181cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > * pComps = Components.getConstArray(); 182cdf0e10cSrcweir 183cdf0e10cSrcweir Window* pPrevWin = NULL; 184cdf0e10cSrcweir Window* pPrevRadio = NULL; 185cdf0e10cSrcweir for ( sal_uInt32 n = 0; n < nCount; n++ ) 186cdf0e10cSrcweir { 187cdf0e10cSrcweir Window* pWin = VCLUnoHelper::GetWindow( pComps[n] ); 188cdf0e10cSrcweir if ( pWin ) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir Window* pSortBehind = pPrevWin; 191cdf0e10cSrcweir // #57096# Alle Radios hintereinander sortieren... 192cdf0e10cSrcweir sal_Bool bNewPrevWin = sal_True; 193cdf0e10cSrcweir if ( pWin->GetType() == WINDOW_RADIOBUTTON ) 194cdf0e10cSrcweir { 195cdf0e10cSrcweir if ( pPrevRadio ) 196cdf0e10cSrcweir { 197cdf0e10cSrcweir bNewPrevWin = ( pPrevWin == pPrevRadio ); // Radio-Button wurde vor das PreWin sortiert.... 198cdf0e10cSrcweir pSortBehind = pPrevRadio; 199cdf0e10cSrcweir } 200cdf0e10cSrcweir pPrevRadio = pWin; 201cdf0e10cSrcweir } 202cdf0e10cSrcweir 203cdf0e10cSrcweir // Z-Order 204cdf0e10cSrcweir if ( pSortBehind ) 205cdf0e10cSrcweir pWin->SetZOrder( pSortBehind, WINDOW_ZORDER_BEHIND ); 206cdf0e10cSrcweir 207cdf0e10cSrcweir WinBits nStyle = pWin->GetStyle(); 208cdf0e10cSrcweir if ( n == 0 ) 209cdf0e10cSrcweir nStyle |= WB_GROUP; 210cdf0e10cSrcweir else 211cdf0e10cSrcweir nStyle &= (~WB_GROUP); 212cdf0e10cSrcweir pWin->SetStyle( nStyle ); 213cdf0e10cSrcweir 214cdf0e10cSrcweir // Ein WB_GROUP hinter die Gruppe, falls keine Gruppe mehr folgt. 215cdf0e10cSrcweir if ( n == ( nCount - 1 ) ) 216cdf0e10cSrcweir { 217cdf0e10cSrcweir Window* pBehindLast = pWin->GetWindow( WINDOW_NEXT ); 218cdf0e10cSrcweir if ( pBehindLast ) 219cdf0e10cSrcweir { 220cdf0e10cSrcweir WinBits nLastStyle = pBehindLast->GetStyle(); 221cdf0e10cSrcweir nLastStyle |= WB_GROUP; 222cdf0e10cSrcweir pBehindLast->SetStyle( nLastStyle ); 223cdf0e10cSrcweir } 224cdf0e10cSrcweir } 225cdf0e10cSrcweir 226cdf0e10cSrcweir if ( bNewPrevWin ) 227cdf0e10cSrcweir pPrevWin = pWin; 228cdf0e10cSrcweir } 229cdf0e10cSrcweir } 230cdf0e10cSrcweir } 231cdf0e10cSrcweir 232cdf0e10cSrcweir 233cdf0e10cSrcweir 234cdf0e10cSrcweir 235cdf0e10cSrcweir 236