xref: /AOO41X/main/framework/source/uielement/panelwrapper.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir 
2*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
3*cdf0e10cSrcweir #include "precompiled_framework.hxx"
4*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
5*cdf0e10cSrcweir //	my own includes
6*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
7*cdf0e10cSrcweir 
8*cdf0e10cSrcweir #include <services.h>
9*cdf0e10cSrcweir #include <uielement/panelwrapper.hxx>
10*cdf0e10cSrcweir #include <threadhelp/resetableguard.hxx>
11*cdf0e10cSrcweir #include <uielement/constitemcontainer.hxx>
12*cdf0e10cSrcweir #include <uielement/rootitemcontainer.hxx>
13*cdf0e10cSrcweir #include <uielement/panelwindow.hxx>
14*cdf0e10cSrcweir #include <services/modelwinservice.hxx>
15*cdf0e10cSrcweir 
16*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
17*cdf0e10cSrcweir //	interface includes
18*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
19*cdf0e10cSrcweir 
20*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
21*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
22*cdf0e10cSrcweir #include <com/sun/star/awt/XSystemDependentMenuPeer.hpp>
23*cdf0e10cSrcweir #include <com/sun/star/awt/XMenuBar.hpp>
24*cdf0e10cSrcweir #include <com/sun/star/container/XIndexContainer.hpp>
25*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
26*cdf0e10cSrcweir #include <com/sun/star/ui/UIElementType.hpp>
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
29*cdf0e10cSrcweir //	other includes
30*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include <toolkit/unohlp.hxx>
33*cdf0e10cSrcweir #include <toolkit/awt/vclxwindow.hxx>
34*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
35*cdf0e10cSrcweir #include <svtools/miscopt.hxx>
36*cdf0e10cSrcweir #include <vcl/svapp.hxx>
37*cdf0e10cSrcweir #include <rtl/logfile.hxx>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir using namespace com::sun::star;
40*cdf0e10cSrcweir using namespace com::sun::star::uno;
41*cdf0e10cSrcweir using namespace com::sun::star::beans;
42*cdf0e10cSrcweir using namespace com::sun::star::frame;
43*cdf0e10cSrcweir using namespace com::sun::star::lang;
44*cdf0e10cSrcweir using namespace com::sun::star::container;
45*cdf0e10cSrcweir using namespace com::sun::star::awt;
46*cdf0e10cSrcweir using namespace ::com::sun::star::ui;
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir namespace framework
49*cdf0e10cSrcweir {
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir PanelWrapper::PanelWrapper( const Reference< XMultiServiceFactory >& xServiceManager ) :
52*cdf0e10cSrcweir     UIElementWrapperBase( UIElementType::DOCKINGWINDOW ),
53*cdf0e10cSrcweir     m_xServiceManager( xServiceManager ),
54*cdf0e10cSrcweir     m_bNoClose(false)
55*cdf0e10cSrcweir {
56*cdf0e10cSrcweir }
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir PanelWrapper::~PanelWrapper()
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir }
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir // XInterface
63*cdf0e10cSrcweir void SAL_CALL PanelWrapper::acquire() throw()
64*cdf0e10cSrcweir {
65*cdf0e10cSrcweir     UIElementWrapperBase::acquire();
66*cdf0e10cSrcweir }
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir void SAL_CALL PanelWrapper::release() throw()
69*cdf0e10cSrcweir {
70*cdf0e10cSrcweir     UIElementWrapperBase::release();
71*cdf0e10cSrcweir }
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir uno::Any SAL_CALL PanelWrapper::queryInterface( const uno::Type & rType )
74*cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException )
75*cdf0e10cSrcweir {
76*cdf0e10cSrcweir 	return UIElementWrapperBase::queryInterface( rType );
77*cdf0e10cSrcweir }
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir // XComponent
80*cdf0e10cSrcweir void SAL_CALL PanelWrapper::dispose() throw ( RuntimeException )
81*cdf0e10cSrcweir {
82*cdf0e10cSrcweir     Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
83*cdf0e10cSrcweir     Reference< XMultiServiceFactory > xSMGR( m_xServiceManager );
84*cdf0e10cSrcweir     Reference< XWindow > xWindow;
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 	{
87*cdf0e10cSrcweir 		ResetableGuard aLock( m_aLock );
88*cdf0e10cSrcweir 		if ( m_bDisposed )
89*cdf0e10cSrcweir 			return;
90*cdf0e10cSrcweir         xSMGR = m_xServiceManager;
91*cdf0e10cSrcweir 	}
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 	com::sun::star::lang::EventObject aEvent( xThis );
94*cdf0e10cSrcweir     m_aListenerContainer.disposeAndClear( aEvent );
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir     rtl::OUString aModelWinService( SERVICENAME_MODELWINSERVICE );
97*cdf0e10cSrcweir     Reference< XNameAccess > xNameAccess( xSMGR->createInstance( aModelWinService ), UNO_QUERY );
98*cdf0e10cSrcweir     if ( xNameAccess.is() )
99*cdf0e10cSrcweir     {
100*cdf0e10cSrcweir         ModelWinService* pService = dynamic_cast< ModelWinService* >( xNameAccess.get() );
101*cdf0e10cSrcweir         if ( pService != 0 )
102*cdf0e10cSrcweir         {
103*cdf0e10cSrcweir             vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
104*cdf0e10cSrcweir             PanelWindow* pPanelWindow = dynamic_cast< PanelWindow* >( m_xPanelWindow.get() );
105*cdf0e10cSrcweir             if ( pPanelWindow != NULL )
106*cdf0e10cSrcweir             {
107*cdf0e10cSrcweir                 xWindow = VCLUnoHelper::GetInterface( pPanelWindow->getContentWindow() );
108*cdf0e10cSrcweir                 pService->deregisterModelForXWindow( xWindow );
109*cdf0e10cSrcweir             }
110*cdf0e10cSrcweir         }
111*cdf0e10cSrcweir     }
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
114*cdf0e10cSrcweir     m_xPanelWindow.clear();
115*cdf0e10cSrcweir     m_bDisposed = sal_True;
116*cdf0e10cSrcweir }
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir // XInitialization
119*cdf0e10cSrcweir void SAL_CALL PanelWrapper::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException )
120*cdf0e10cSrcweir {
121*cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir     if ( m_bDisposed )
124*cdf0e10cSrcweir         throw DisposedException();
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir     if ( !m_bInitialized )
127*cdf0e10cSrcweir     {
128*cdf0e10cSrcweir         UIElementWrapperBase::initialize( aArguments );
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir         sal_Bool bPopupMode( sal_False );
131*cdf0e10cSrcweir         Reference< XWindow > xContentWindow;
132*cdf0e10cSrcweir         for ( sal_Int32 i = 0; i < aArguments.getLength(); i++ )
133*cdf0e10cSrcweir         {
134*cdf0e10cSrcweir             PropertyValue aPropValue;
135*cdf0e10cSrcweir             if ( aArguments[i] >>= aPropValue )
136*cdf0e10cSrcweir             {
137*cdf0e10cSrcweir                 if ( aPropValue.Name.equalsAsciiL( "PopupMode", 9 ))
138*cdf0e10cSrcweir                     aPropValue.Value >>= bPopupMode;
139*cdf0e10cSrcweir                 else if ( aPropValue.Name.equalsAsciiL( "ContentWindow", 13 ))
140*cdf0e10cSrcweir                     aPropValue.Value >>= xContentWindow;
141*cdf0e10cSrcweir             }
142*cdf0e10cSrcweir         }
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir         Reference< XFrame > xFrame( m_xWeakFrame );
145*cdf0e10cSrcweir         if ( xFrame.is() )
146*cdf0e10cSrcweir         {
147*cdf0e10cSrcweir             PanelWindow* pPanelWindow(0);
148*cdf0e10cSrcweir             Window*      pContentWindow(0);
149*cdf0e10cSrcweir             {
150*cdf0e10cSrcweir                 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
151*cdf0e10cSrcweir                 Window* pWindow = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
152*cdf0e10cSrcweir                 pContentWindow  = VCLUnoHelper::GetWindow( xContentWindow );
153*cdf0e10cSrcweir                 if ( pWindow )
154*cdf0e10cSrcweir                 {
155*cdf0e10cSrcweir                     sal_uInt32 nStyles = WB_LINESPACING | WB_BORDER | WB_SCROLL | WB_MOVEABLE | WB_3DLOOK | WB_DOCKABLE | WB_SIZEABLE | WB_CLOSEABLE;
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir                     pPanelWindow = new PanelWindow( pWindow, nStyles );
158*cdf0e10cSrcweir                     m_xPanelWindow = VCLUnoHelper::GetInterface( pPanelWindow );
159*cdf0e10cSrcweir 					pPanelWindow->setResourceURL( m_aResourceURL );
160*cdf0e10cSrcweir                     pPanelWindow->setContentWindow( pContentWindow );
161*cdf0e10cSrcweir                 }
162*cdf0e10cSrcweir             }
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir             try
165*cdf0e10cSrcweir             {
166*cdf0e10cSrcweir             }
167*cdf0e10cSrcweir             catch ( NoSuchElementException& )
168*cdf0e10cSrcweir             {
169*cdf0e10cSrcweir             }
170*cdf0e10cSrcweir         }
171*cdf0e10cSrcweir     }
172*cdf0e10cSrcweir }
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir // XEventListener
175*cdf0e10cSrcweir void SAL_CALL PanelWrapper::disposing( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException)
176*cdf0e10cSrcweir {
177*cdf0e10cSrcweir     // nothing todo
178*cdf0e10cSrcweir }
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir // XUpdatable
181*cdf0e10cSrcweir void SAL_CALL PanelWrapper::update() throw (::com::sun::star::uno::RuntimeException)
182*cdf0e10cSrcweir {
183*cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir     if ( m_bDisposed )
186*cdf0e10cSrcweir         throw DisposedException();
187*cdf0e10cSrcweir }
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir // XUIElement interface
190*cdf0e10cSrcweir Reference< XInterface > SAL_CALL PanelWrapper::getRealInterface(  ) throw (::com::sun::star::uno::RuntimeException)
191*cdf0e10cSrcweir {
192*cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
193*cdf0e10cSrcweir     return m_xPanelWindow;
194*cdf0e10cSrcweir }
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir void SAL_CALL PanelWrapper::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const com::sun::star::uno::Any&  aValue ) throw( com::sun::star::uno::Exception )
197*cdf0e10cSrcweir {
198*cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
199*cdf0e10cSrcweir     sal_Bool bNoClose( m_bNoClose );
200*cdf0e10cSrcweir     aLock.unlock();
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir     UIElementWrapperBase::setFastPropertyValue_NoBroadcast( nHandle, aValue );
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir     aLock.lock();
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir     sal_Bool bNewNoClose( m_bNoClose );
207*cdf0e10cSrcweir     if ( m_xPanelWindow.is() && !m_bDisposed && ( bNewNoClose != bNoClose ))
208*cdf0e10cSrcweir     {
209*cdf0e10cSrcweir         PanelWindow* pPanelWindow = dynamic_cast< PanelWindow* >( VCLUnoHelper::GetWindow( m_xPanelWindow ) );
210*cdf0e10cSrcweir         if ( pPanelWindow )
211*cdf0e10cSrcweir         {
212*cdf0e10cSrcweir             if ( bNewNoClose )
213*cdf0e10cSrcweir             {
214*cdf0e10cSrcweir                 pPanelWindow->SetStyle( pPanelWindow->GetStyle() & ~WB_CLOSEABLE );
215*cdf0e10cSrcweir                 pPanelWindow->SetFloatStyle( pPanelWindow->GetFloatStyle() & ~WB_CLOSEABLE );
216*cdf0e10cSrcweir             }
217*cdf0e10cSrcweir             else
218*cdf0e10cSrcweir             {
219*cdf0e10cSrcweir                 pPanelWindow->SetStyle( pPanelWindow->GetStyle() | WB_CLOSEABLE );
220*cdf0e10cSrcweir                 pPanelWindow->SetFloatStyle( pPanelWindow->GetFloatStyle() | WB_CLOSEABLE );
221*cdf0e10cSrcweir             }
222*cdf0e10cSrcweir         }
223*cdf0e10cSrcweir     }
224*cdf0e10cSrcweir }
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir } // namespace framework
227