1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: vclxcontainer.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_toolkit.hxx"
35 #include <toolkit/awt/vclxcontainer.hxx>
36 #include <toolkit/helper/macros.hxx>
37 #include <toolkit/helper/vclunohelper.hxx>
38 #include <cppuhelper/typeprovider.hxx>
39 #include <rtl/memory.h>
42 #include <vcl/window.hxx>
43 #include <tools/debug.hxx>
45 // ----------------------------------------------------
46 // class VCLXContainer
47 // ----------------------------------------------------
49 void VCLXContainer::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
51 VCLXWindow::ImplGetPropertyIds( rIds
);
54 VCLXContainer::VCLXContainer()
58 VCLXContainer::~VCLXContainer()
62 // ::com::sun::star::uno::XInterface
63 ::com::sun::star::uno::Any
VCLXContainer::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
65 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
66 SAL_STATIC_CAST( ::com::sun::star::awt::XVclContainer
*, this ),
67 SAL_STATIC_CAST( ::com::sun::star::awt::XVclContainerPeer
*, this ) );
68 return (aRet
.hasValue() ? aRet
: VCLXWindow::queryInterface( rType
));
71 // ::com::sun::star::lang::XTypeProvider
72 IMPL_XTYPEPROVIDER_START( VCLXContainer
)
73 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XVclContainer
>* ) NULL
),
74 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XVclContainerPeer
>* ) NULL
),
75 VCLXWindow::getTypes()
76 IMPL_XTYPEPROVIDER_END
79 // ::com::sun::star::awt::XVclContainer
80 void VCLXContainer::addVclContainerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XVclContainerListener
>& rxListener
) throw(::com::sun::star::uno::RuntimeException
)
82 ::vos::OGuard
aGuard( GetMutex() );
84 GetContainerListeners().addInterface( rxListener
);
87 void VCLXContainer::removeVclContainerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XVclContainerListener
>& rxListener
) throw(::com::sun::star::uno::RuntimeException
)
89 ::vos::OGuard
aGuard( GetMutex() );
91 GetContainerListeners().removeInterface( rxListener
);
94 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> > VCLXContainer::getWindows( ) throw(::com::sun::star::uno::RuntimeException
)
96 ::vos::OGuard
aGuard( GetMutex() );
98 // Bei allen Childs das Container-Interface abfragen...
99 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> > aSeq
;
100 Window
* pWindow
= GetWindow();
103 sal_uInt16 nChilds
= pWindow
->GetChildCount();
106 aSeq
= ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> >( nChilds
);
107 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> * pChildRefs
= aSeq
.getArray();
108 for ( sal_uInt16 n
= 0; n
< nChilds
; n
++ )
110 Window
* pChild
= pWindow
->GetChild( n
);
111 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
> xWP
= pChild
->GetComponentInterface( sal_True
);
112 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xW( xWP
, ::com::sun::star::uno::UNO_QUERY
);
121 // ::com::sun::star::awt::XVclContainerPeer
122 void VCLXContainer::enableDialogControl( sal_Bool bEnable
) throw(::com::sun::star::uno::RuntimeException
)
124 ::vos::OGuard
aGuard( GetMutex() );
126 Window
* pWindow
= GetWindow();
129 WinBits nStyle
= pWindow
->GetStyle();
131 nStyle
|= WB_DIALOGCONTROL
;
133 nStyle
&= (~WB_DIALOGCONTROL
);
134 pWindow
->SetStyle( nStyle
);
138 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
)
140 ::vos::OGuard
aGuard( GetMutex() );
142 sal_uInt32 nCount
= Components
.getLength();
143 DBG_ASSERT( nCount
== (sal_uInt32
)Tabs
.getLength(), "setTabOrder: TabCount != ComponentCount" );
144 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> * pComps
= Components
.getConstArray();
145 const ::com::sun::star::uno::Any
* pTabs
= Tabs
.getConstArray();
147 Window
* pPrevWin
= NULL
;
148 for ( sal_uInt32 n
= 0; n
< nCount
; n
++ )
150 // ::com::sun::star::style::TabStop
151 Window
* pWin
= VCLUnoHelper::GetWindow( pComps
[n
] );
152 // NULL kann vorkommen, wenn die ::com::sun::star::uno::Sequence vom TabController kommt und eine Peer fehlt!
155 // Reihenfolge der Fenster vor der Manipulation des Styles,
156 // weil z.B. der RadioButton in StateChanged das PREV-Window beruecksichtigt.
158 pWin
->SetZOrder( pPrevWin
, WINDOW_ZORDER_BEHIND
);
160 WinBits nStyle
= pWin
->GetStyle();
161 nStyle
&= ~(WB_TABSTOP
|WB_NOTABSTOP
|WB_GROUP
);
162 if ( pTabs
[n
].getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_BOOLEAN
)
164 sal_Bool bTab
= false;
166 nStyle
|= ( bTab
? WB_TABSTOP
: WB_NOTABSTOP
);
168 pWin
->SetStyle( nStyle
);
173 pWin
->SetDialogControlStart( sal_True
);
175 pWin
->SetDialogControlStart( sal_False
);
183 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
)
185 ::vos::OGuard
aGuard( GetMutex() );
187 sal_uInt32 nCount
= Components
.getLength();
188 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> * pComps
= Components
.getConstArray();
190 Window
* pPrevWin
= NULL
;
191 Window
* pPrevRadio
= NULL
;
192 for ( sal_uInt32 n
= 0; n
< nCount
; n
++ )
194 Window
* pWin
= VCLUnoHelper::GetWindow( pComps
[n
] );
197 Window
* pSortBehind
= pPrevWin
;
198 // #57096# Alle Radios hintereinander sortieren...
199 sal_Bool bNewPrevWin
= sal_True
;
200 if ( pWin
->GetType() == WINDOW_RADIOBUTTON
)
204 bNewPrevWin
= ( pPrevWin
== pPrevRadio
); // Radio-Button wurde vor das PreWin sortiert....
205 pSortBehind
= pPrevRadio
;
212 pWin
->SetZOrder( pSortBehind
, WINDOW_ZORDER_BEHIND
);
214 WinBits nStyle
= pWin
->GetStyle();
218 nStyle
&= (~WB_GROUP
);
219 pWin
->SetStyle( nStyle
);
221 // Ein WB_GROUP hinter die Gruppe, falls keine Gruppe mehr folgt.
222 if ( n
== ( nCount
- 1 ) )
224 Window
* pBehindLast
= pWin
->GetWindow( WINDOW_NEXT
);
227 WinBits nLastStyle
= pBehindLast
->GetStyle();
228 nLastStyle
|= WB_GROUP
;
229 pBehindLast
->SetStyle( nLastStyle
);