Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / toolkit / source / awt / vclxcontainer.cxx
blob7f48b8d0a849bf2a132e8e1e842013d62be316b2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
31 #include <toolkit/awt/vclxcontainer.hxx>
32 #include <toolkit/helper/macros.hxx>
33 #include <toolkit/helper/vclunohelper.hxx>
34 #include <cppuhelper/typeprovider.hxx>
35 #include <rtl/memory.h>
36 #include <rtl/uuid.h>
38 #include <vcl/svapp.hxx>
39 #include <vcl/window.hxx>
40 #include <tools/debug.hxx>
42 // ----------------------------------------------------
43 // class VCLXContainer
44 // ----------------------------------------------------
46 void VCLXContainer::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
48 VCLXWindow::ImplGetPropertyIds( rIds );
51 VCLXContainer::VCLXContainer()
55 VCLXContainer::~VCLXContainer()
59 // ::com::sun::star::uno::XInterface
60 ::com::sun::star::uno::Any VCLXContainer::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
62 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
63 (static_cast< ::com::sun::star::awt::XVclContainer* >(this)),
64 (static_cast< ::com::sun::star::awt::XVclContainerPeer* >(this)) );
65 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
68 // ::com::sun::star::lang::XTypeProvider
69 IMPL_XTYPEPROVIDER_START( VCLXContainer )
70 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainer>* ) NULL ),
71 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainerPeer>* ) NULL ),
72 VCLXWindow::getTypes()
73 IMPL_XTYPEPROVIDER_END
76 // ::com::sun::star::awt::XVclContainer
77 void VCLXContainer::addVclContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainerListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
79 SolarMutexGuard aGuard;
81 GetContainerListeners().addInterface( rxListener );
84 void VCLXContainer::removeVclContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainerListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
86 SolarMutexGuard aGuard;
88 GetContainerListeners().removeInterface( rxListener );
91 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > > VCLXContainer::getWindows( ) throw(::com::sun::star::uno::RuntimeException)
93 SolarMutexGuard aGuard;
95 // Bei allen Children das Container-Interface abfragen...
96 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > > aSeq;
97 Window* pWindow = GetWindow();
98 if ( pWindow )
100 sal_uInt16 nChildren = pWindow->GetChildCount();
101 if ( nChildren )
103 aSeq = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > >( nChildren );
104 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > * pChildRefs = aSeq.getArray();
105 for ( sal_uInt16 n = 0; n < nChildren; n++ )
107 Window* pChild = pWindow->GetChild( n );
108 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xWP = pChild->GetComponentInterface( sal_True );
109 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xW( xWP, ::com::sun::star::uno::UNO_QUERY );
110 pChildRefs[n] = xW;
114 return aSeq;
118 // ::com::sun::star::awt::XVclContainerPeer
119 void VCLXContainer::enableDialogControl( sal_Bool bEnable ) throw(::com::sun::star::uno::RuntimeException)
121 SolarMutexGuard aGuard;
123 Window* pWindow = GetWindow();
124 if ( pWindow )
126 WinBits nStyle = pWindow->GetStyle();
127 if ( bEnable )
128 nStyle |= WB_DIALOGCONTROL;
129 else
130 nStyle &= (~WB_DIALOGCONTROL);
131 pWindow->SetStyle( nStyle );
135 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)
137 SolarMutexGuard aGuard;
139 sal_uInt32 nCount = Components.getLength();
140 DBG_ASSERT( nCount == (sal_uInt32)Tabs.getLength(), "setTabOrder: TabCount != ComponentCount" );
141 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > * pComps = Components.getConstArray();
142 const ::com::sun::star::uno::Any* pTabs = Tabs.getConstArray();
144 Window* pPrevWin = NULL;
145 for ( sal_uInt32 n = 0; n < nCount; n++ )
147 // ::com::sun::star::style::TabStop
148 Window* pWin = VCLUnoHelper::GetWindow( pComps[n] );
149 // NULL kann vorkommen, wenn die ::com::sun::star::uno::Sequence vom TabController kommt und eine Peer fehlt!
150 if ( pWin )
152 // Reihenfolge der Fenster vor der Manipulation des Styles,
153 // weil z.B. der RadioButton in StateChanged das PREV-Window beruecksichtigt.
154 if ( pPrevWin )
155 pWin->SetZOrder( pPrevWin, WINDOW_ZORDER_BEHIND );
157 WinBits nStyle = pWin->GetStyle();
158 nStyle &= ~(WB_TABSTOP|WB_NOTABSTOP|WB_GROUP);
159 if ( pTabs[n].getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_BOOLEAN )
161 sal_Bool bTab = false;
162 pTabs[n] >>= bTab;
163 nStyle |= ( bTab ? WB_TABSTOP : WB_NOTABSTOP );
165 pWin->SetStyle( nStyle );
167 if ( bGroupControl )
169 if ( n == 0 )
170 pWin->SetDialogControlStart( sal_True );
171 else
172 pWin->SetDialogControlStart( sal_False );
175 pPrevWin = pWin;
180 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)
182 SolarMutexGuard aGuard;
184 sal_uInt32 nCount = Components.getLength();
185 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > * pComps = Components.getConstArray();
187 Window* pPrevWin = NULL;
188 Window* pPrevRadio = NULL;
189 for ( sal_uInt32 n = 0; n < nCount; n++ )
191 Window* pWin = VCLUnoHelper::GetWindow( pComps[n] );
192 if ( pWin )
194 Window* pSortBehind = pPrevWin;
195 // #57096# Alle Radios hintereinander sortieren...
196 sal_Bool bNewPrevWin = sal_True;
197 if ( pWin->GetType() == WINDOW_RADIOBUTTON )
199 if ( pPrevRadio )
201 bNewPrevWin = ( pPrevWin == pPrevRadio ); // Radio-Button wurde vor das PreWin sortiert....
202 pSortBehind = pPrevRadio;
204 pPrevRadio = pWin;
207 // Z-Order
208 if ( pSortBehind )
209 pWin->SetZOrder( pSortBehind, WINDOW_ZORDER_BEHIND );
211 WinBits nStyle = pWin->GetStyle();
212 if ( n == 0 )
213 nStyle |= WB_GROUP;
214 else
215 nStyle &= (~WB_GROUP);
216 pWin->SetStyle( nStyle );
218 // Ein WB_GROUP hinter die Gruppe, falls keine Gruppe mehr folgt.
219 if ( n == ( nCount - 1 ) )
221 Window* pBehindLast = pWin->GetWindow( WINDOW_NEXT );
222 if ( pBehindLast )
224 WinBits nLastStyle = pBehindLast->GetStyle();
225 nLastStyle |= WB_GROUP;
226 pBehindLast->SetStyle( nLastStyle );
230 if ( bNewPrevWin )
231 pPrevWin = pWin;
236 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */