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