fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / toolkit / source / awt / vclxtopwindow.cxx
blob48b593eb37fb757649dba637e6e992f0f88d2652
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/lang/SystemDependent.hpp>
21 #include <com/sun/star/awt/SystemDependentXWindow.hpp>
23 #if defined ( MACOSX )
24 #include "premac.h"
25 #include <Cocoa/Cocoa.h>
26 #include "postmac.h"
27 #endif
29 #include <vcl/syschild.hxx>
30 #include <vcl/sysdata.hxx>
31 #include <cppuhelper/typeprovider.hxx>
32 #include <comphelper/sequence.hxx>
34 #include <toolkit/awt/vclxtopwindow.hxx>
35 #include <toolkit/awt/vclxmenu.hxx>
36 #include <toolkit/helper/macros.hxx>
38 #include <vcl/wrkwin.hxx>
39 #include <vcl/syswin.hxx>
40 #include <vcl/menu.hxx>
41 #include <vcl/svapp.hxx>
43 using ::com::sun::star::uno::RuntimeException;
44 using ::com::sun::star::uno::Sequence;
45 using ::com::sun::star::uno::Type;
46 using ::com::sun::star::uno::Any;
47 using ::com::sun::star::lang::IndexOutOfBoundsException;
49 VCLXTopWindow_Base::VCLXTopWindow_Base( const bool _bSupportSystemWindowPeer )
50 :m_bWHWND( _bSupportSystemWindowPeer )
54 VCLXTopWindow_Base::~VCLXTopWindow_Base()
58 Any VCLXTopWindow_Base::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
60 ::com::sun::star::uno::Any aRet( VCLXTopWindow_XBase::queryInterface( rType ) );
62 // do not expose XSystemDependentWindowPeer if we do not have a system window handle
63 if ( !aRet.hasValue() && m_bWHWND )
64 aRet = VCLXTopWindow_SBase::queryInterface( rType );
66 return aRet;
69 Sequence< Type > VCLXTopWindow_Base::getTypes() throw(RuntimeException, std::exception)
71 Sequence< Type > aTypes( VCLXTopWindow_XBase::getTypes() );
72 if ( m_bWHWND )
73 aTypes = ::comphelper::concatSequences( aTypes, VCLXTopWindow_SBase::getTypes() );
74 return aTypes;
77 ::com::sun::star::uno::Any VCLXTopWindow_Base::getWindowHandle( const ::com::sun::star::uno::Sequence< sal_Int8 >& /*ProcessId*/, sal_Int16 SystemType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
79 SolarMutexGuard aGuard;
81 // TODO, check the process id
82 ::com::sun::star::uno::Any aRet;
83 vcl::Window* pWindow = GetWindowImpl();
84 if ( pWindow )
86 const SystemEnvData* pSysData = static_cast<SystemWindow *>(pWindow)->GetSystemData();
87 if( pSysData )
89 #if (defined WNT)
90 if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_WIN32 )
92 aRet <<= reinterpret_cast<sal_IntPtr>(pSysData->hWnd);
94 #elif (defined MACOSX)
95 if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_MAC )
97 aRet <<= reinterpret_cast<sal_IntPtr>(pSysData->mpNSView);
99 #elif (defined ANDROID)
100 // Nothing
101 (void) SystemType;
102 #elif (defined IOS)
103 // Nothing
104 (void) SystemType;
105 #elif (defined UNX)
106 if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_XWINDOW )
108 ::com::sun::star::awt::SystemDependentXWindow aSD;
109 aSD.DisplayPointer = sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_IntPtr >(pSysData->pDisplay));
110 aSD.WindowHandle = pSysData->aWindow;
111 aRet <<= aSD;
113 #endif
116 return aRet;
119 void VCLXTopWindow_Base::addTopWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTopWindowListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception)
121 SolarMutexGuard aGuard;
123 GetTopWindowListenersImpl().addInterface( rxListener );
126 void VCLXTopWindow_Base::removeTopWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTopWindowListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception)
128 SolarMutexGuard aGuard;
130 GetTopWindowListenersImpl().removeInterface( rxListener );
133 void VCLXTopWindow_Base::toFront( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
135 SolarMutexGuard aGuard;
137 vcl::Window* pWindow = GetWindowImpl();
138 if ( pWindow )
139 static_cast<WorkWindow*>(pWindow)->ToTop( TOTOP_RESTOREWHENMIN );
142 void VCLXTopWindow_Base::toBack( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
146 void VCLXTopWindow_Base::setMenuBar( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuBar >& rxMenu ) throw(::com::sun::star::uno::RuntimeException, std::exception)
148 SolarMutexGuard aGuard;
150 vcl::Window* pWindow = GetWindowImpl();
151 if ( pWindow )
153 SystemWindow* pSystemWindow = static_cast<SystemWindow*>( pWindow );
154 pSystemWindow->SetMenuBar( NULL );
155 if ( rxMenu.is() )
157 VCLXMenu* pMenu = VCLXMenu::GetImplementation( rxMenu );
158 if ( pMenu && !pMenu->IsPopupMenu() )
159 pSystemWindow->SetMenuBar( static_cast<MenuBar*>( pMenu->GetMenu() ));
162 mxMenuBar = rxMenu;
166 sal_Bool SAL_CALL VCLXTopWindow_Base::getIsMaximized() throw (RuntimeException, std::exception)
168 SolarMutexGuard aGuard;
170 const WorkWindow* pWindow = dynamic_cast< const WorkWindow* >( GetWindowImpl() );
171 if ( !pWindow )
172 return sal_False;
174 return pWindow->IsMaximized();
178 void SAL_CALL VCLXTopWindow_Base::setIsMaximized( sal_Bool _ismaximized ) throw (RuntimeException, std::exception)
180 SolarMutexGuard aGuard;
182 WorkWindow* pWindow = dynamic_cast< WorkWindow* >( GetWindowImpl() );
183 if ( !pWindow )
184 return;
186 pWindow->Maximize( _ismaximized );
190 sal_Bool SAL_CALL VCLXTopWindow_Base::getIsMinimized() throw (RuntimeException, std::exception)
192 SolarMutexGuard aGuard;
194 const WorkWindow* pWindow = dynamic_cast< const WorkWindow* >( GetWindowImpl() );
195 if ( !pWindow )
196 return sal_False;
198 return pWindow->IsMinimized();
202 void SAL_CALL VCLXTopWindow_Base::setIsMinimized( sal_Bool _isMinimized ) throw (RuntimeException, std::exception)
204 SolarMutexGuard aGuard;
206 WorkWindow* pWindow = dynamic_cast< WorkWindow* >( GetWindowImpl() );
207 if ( !pWindow )
208 return;
210 _isMinimized ? pWindow->Minimize() : pWindow->Restore();
214 ::sal_Int32 SAL_CALL VCLXTopWindow_Base::getDisplay() throw (RuntimeException, std::exception)
216 SolarMutexGuard aGuard;
218 const SystemWindow* pWindow = dynamic_cast< const SystemWindow* >( GetWindowImpl() );
219 if ( !pWindow )
220 return 0;
222 return pWindow->GetScreenNumber();
226 void SAL_CALL VCLXTopWindow_Base::setDisplay( ::sal_Int32 _display ) throw (RuntimeException, IndexOutOfBoundsException, std::exception)
228 SolarMutexGuard aGuard;
230 if ( ( _display < 0 ) || ( _display >= (sal_Int32)Application::GetScreenCount() ) )
231 throw IndexOutOfBoundsException();
233 SystemWindow* pWindow = dynamic_cast< SystemWindow* >( GetWindowImpl() );
234 if ( !pWindow )
235 return;
237 pWindow->SetScreenNumber( _display );
241 // class VCLXTopWindow
244 void VCLXTopWindow::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
246 VCLXContainer::ImplGetPropertyIds( rIds );
249 VCLXTopWindow::VCLXTopWindow(bool bWHWND)
250 : VCLXTopWindow_Base( bWHWND )
254 VCLXTopWindow::~VCLXTopWindow()
258 vcl::Window* VCLXTopWindow::GetWindowImpl()
260 return VCLXContainer::GetWindow();
263 ::cppu::OInterfaceContainerHelper& VCLXTopWindow::GetTopWindowListenersImpl()
265 return GetTopWindowListeners();
268 // ::com::sun::star::uno::XInterface
269 ::com::sun::star::uno::Any VCLXTopWindow::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
271 ::com::sun::star::uno::Any aRet( VCLXTopWindow_Base::queryInterface( rType ) );
273 if ( !aRet.hasValue() )
274 aRet = VCLXContainer::queryInterface( rType );
276 return aRet;
279 ::com::sun::star::uno::Sequence< sal_Int8 > VCLXTopWindow::getImplementationId() throw(::com::sun::star::uno::RuntimeException, std::exception)
281 return css::uno::Sequence<sal_Int8>();
284 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > VCLXTopWindow::getTypes() throw(::com::sun::star::uno::RuntimeException, std::exception)
286 return ::comphelper::concatSequences( VCLXTopWindow_Base::getTypes(), VCLXContainer::getTypes() );
289 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */