LibreOffice Module toolkit (master) 1
vclxtopwindow.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <sal/config.h>
21
22#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
23#include <com/sun/star/lang/SystemDependent.hpp>
24#include <com/sun/star/awt/SystemDependentXWindow.hpp>
25
26#if defined ( MACOSX )
27#include <premac.h>
28#include <Cocoa/Cocoa.h>
29#include <postmac.h>
30#endif
31
32#include <vcl/sysdata.hxx>
33#include <o3tl/safeint.hxx>
34
35#include <awt/vclxtopwindow.hxx>
37
38#include <vcl/wrkwin.hxx>
39#include <vcl/syswin.hxx>
40#include <vcl/menu.hxx>
41#include <vcl/svapp.hxx>
42
43using ::com::sun::star::uno::Sequence;
44using ::com::sun::star::uno::Any;
45using ::com::sun::star::lang::IndexOutOfBoundsException;
46
47
48css::uno::Any VCLXTopWindow::getWindowHandle( const css::uno::Sequence< sal_Int8 >& /*ProcessId*/, sal_Int16 SystemType )
49{
50 SolarMutexGuard aGuard;
51
52 // TODO, check the process id
53 css::uno::Any aRet;
54 vcl::Window* pWindow = VCLXContainer::GetWindow();
55 if ( pWindow )
56 {
57 const SystemEnvData* pSysData = static_cast<SystemWindow *>(pWindow)->GetSystemData();
58 if( pSysData )
59 {
60#if defined (_WIN32)
61 if( SystemType == css::lang::SystemDependent::SYSTEM_WIN32 )
62 {
63 aRet <<= reinterpret_cast<sal_IntPtr>(pSysData->hWnd);
64 }
65#elif defined(MACOSX)
66 if( SystemType == css::lang::SystemDependent::SYSTEM_MAC )
67 {
68 aRet <<= reinterpret_cast<sal_IntPtr>(pSysData->mpNSView);
69 }
70#elif defined(ANDROID)
71 // Nothing
72 (void) SystemType;
73#elif defined(IOS)
74 // Nothing
75 (void) SystemType;
76#elif defined(UNX)
77 if( SystemType == css::lang::SystemDependent::SYSTEM_XWINDOW )
78 {
79 css::awt::SystemDependentXWindow aSD;
80 aSD.DisplayPointer = sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_IntPtr >(pSysData->pDisplay));
81 aSD.WindowHandle = pSysData->GetWindowHandle(pWindow->ImplGetFrame());
82 aRet <<= aSD;
83 }
84#endif
85 }
86 }
87 return aRet;
88}
89
90void VCLXTopWindow::addTopWindowListener( const css::uno::Reference< css::awt::XTopWindowListener >& rxListener )
91{
92 SolarMutexGuard aGuard;
93
94 if (!IsDisposed())
95 GetTopWindowListeners().addInterface( rxListener );
96}
97
98void VCLXTopWindow::removeTopWindowListener( const css::uno::Reference< css::awt::XTopWindowListener >& rxListener )
99{
100 SolarMutexGuard aGuard;
101
102 if (!IsDisposed())
103 GetTopWindowListeners().removeInterface( rxListener );
104}
105
107{
108 SolarMutexGuard aGuard;
109
110 vcl::Window* pWindow = VCLXContainer::GetWindow();
111 if (pWindow)
112 pWindow->ToTop( ToTopFlags::RestoreWhenMin );
113}
114
116{
117}
118
119void VCLXTopWindow::setMenuBar( const css::uno::Reference< css::awt::XMenuBar >& rxMenu )
120{
121 SolarMutexGuard aGuard;
122
123 vcl::Window* pWindow = VCLXContainer::GetWindow();
124 if ( pWindow )
125 {
126 SystemWindow* pSystemWindow = static_cast<SystemWindow*>( pWindow );
127 pSystemWindow->SetMenuBar( nullptr );
128 if ( rxMenu.is() )
129 {
130 VCLXMenu* pMenu = dynamic_cast<VCLXMenu*>( rxMenu.get() );
131 if ( pMenu && !pMenu->IsPopupMenu() )
132 pSystemWindow->SetMenuBar( static_cast<MenuBar*>( pMenu->GetMenu() ));
133 }
134 }
135}
136
137
139{
140 SolarMutexGuard aGuard;
141
142 const WorkWindow* pWindow = VCLXContainer::GetAsDynamic<WorkWindow>();
143 if ( !pWindow )
144 return false;
145
146 return pWindow->IsMaximized();
147}
148
149
150void SAL_CALL VCLXTopWindow::setIsMaximized( sal_Bool _ismaximized )
151{
152 SolarMutexGuard aGuard;
153
154 WorkWindow* pWindow = VCLXContainer::GetAsDynamic<WorkWindow>();
155 if ( !pWindow )
156 return;
157
158 pWindow->Maximize( _ismaximized );
159}
160
161
163{
164 SolarMutexGuard aGuard;
165
166 const WorkWindow* pWindow = VCLXContainer::GetAsDynamic<WorkWindow>();
167 if ( !pWindow )
168 return false;
169
170 return pWindow->IsMinimized();
171}
172
173
174void SAL_CALL VCLXTopWindow::setIsMinimized( sal_Bool _isMinimized )
175{
176 SolarMutexGuard aGuard;
177
178 WorkWindow* pWindow = VCLXContainer::GetAsDynamic<WorkWindow>();
179 if ( !pWindow )
180 return;
181
182 _isMinimized ? pWindow->Minimize() : pWindow->Restore();
183}
184
185
186::sal_Int32 SAL_CALL VCLXTopWindow::getDisplay()
187{
188 SolarMutexGuard aGuard;
189
190 const SystemWindow* pWindow = VCLXContainer::GetAsDynamic<SystemWindow>();
191 if ( !pWindow )
192 return 0;
193
194 return pWindow->GetScreenNumber();
195}
196
197
198void SAL_CALL VCLXTopWindow::setDisplay( ::sal_Int32 _display )
199{
200 SolarMutexGuard aGuard;
201
202 if ( ( _display < 0 ) || ( o3tl::make_unsigned(_display) >= Application::GetScreenCount() ) )
203 throw IndexOutOfBoundsException();
204
205 SystemWindow* pWindow = VCLXContainer::GetAsDynamic<SystemWindow>();
206 if ( !pWindow )
207 return;
208
209 pWindow->SetScreenNumber( _display );
210}
211
212
213
214
215void VCLXTopWindow::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
216{
218}
219
221{
222}
223
225{
226}
227
228
229/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static unsigned int GetScreenCount()
void SetScreenNumber(unsigned int nNewScreen)
unsigned int GetScreenNumber() const
void SetMenuBar(MenuBar *pMenuBar)
static void ImplGetPropertyIds(std::vector< sal_uInt16 > &aIds)
bool IsPopupMenu() const
Definition: vclxmenu.cxx:64
Menu * GetMenu() const
Definition: vclxmenu.hxx:78
virtual void SAL_CALL setDisplay(::sal_Int32 _display) override
virtual void SAL_CALL setIsMaximized(sal_Bool _ismaximized) override
virtual ::sal_Int32 SAL_CALL getDisplay() override
static void ImplGetPropertyIds(std::vector< sal_uInt16 > &aIds)
virtual ~VCLXTopWindow() override
virtual sal_Bool SAL_CALL getIsMinimized() override
void SAL_CALL toFront() override
void SAL_CALL setMenuBar(const css::uno::Reference< css::awt::XMenuBar > &xMenu) override
void SAL_CALL removeTopWindowListener(const css::uno::Reference< css::awt::XTopWindowListener > &rxListener) override
css::uno::Any SAL_CALL getWindowHandle(const css::uno::Sequence< sal_Int8 > &ProcessId, sal_Int16 SystemType) override
virtual void SAL_CALL setIsMinimized(sal_Bool _isminimized) override
void SAL_CALL toBack() override
void SAL_CALL addTopWindowListener(const css::uno::Reference< css::awt::XTopWindowListener > &rxListener) override
virtual sal_Bool SAL_CALL getIsMaximized() override
void Restore()
void Minimize()
bool IsMaximized() const
void Maximize(bool bMaximize=true)
bool IsMinimized() const
void ToTop(ToTopFlags nFlags=ToTopFlags::NONE)
SalFrame * ImplGetFrame() const
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
sal_uIntPtr GetWindowHandle(const SalFrame *pReference) const
unsigned char sal_Bool