bump product version to 7.6.3.2-android
[LibreOffice.git] / vcl / source / window / wrkwin.cxx
bloba04c46ae290ea51731afed1fc438b077ad027e6c
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 .
21 #include <sal/log.hxx>
22 #include <vcl/svapp.hxx>
23 #include <vcl/wrkwin.hxx>
24 // declare system types in sysdata.hxx
25 #include <vcl/sysdata.hxx>
26 #include <com/sun/star/lang/XComponent.hpp>
27 #include <com/sun/star/rendering/XCanvas.hpp>
29 #include <svdata.hxx>
30 #include <salframe.hxx>
31 #include <brdwin.hxx>
32 #include <window.h>
34 void WorkWindow::ImplInitWorkWindowData()
36 mnIcon = 0; // Should be removed in the next top level update - now in SystemWindow
38 mnPresentationFlags = PresentationFlags::NONE;
39 mbPresentationMode = false;
40 mbPresentationVisible = false;
41 mbPresentationFull = false;
42 mbFullScreenMode = false;
45 void WorkWindow::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData )
47 BorderWindowStyle nFrameStyle = BorderWindowStyle::Frame;
48 if ( nStyle & WB_APP )
49 nFrameStyle |= BorderWindowStyle::App;
51 VclPtrInstance<ImplBorderWindow> pBorderWin( pParent, pSystemParentData, nStyle, nFrameStyle );
52 Window::ImplInit( pBorderWin, nStyle & (WB_3DLOOK | WB_CLIPCHILDREN | WB_DIALOGCONTROL | WB_SYSTEMFLOATWIN), nullptr );
53 pBorderWin->mpWindowImpl->mpClientWindow = this;
54 pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
55 mpWindowImpl->mpBorderWindow = pBorderWin;
57 // mpWindowImpl->mpRealParent = pParent; // should actually be set, but is not set due to errors with the menubar!!
59 if ( nStyle & WB_APP )
61 ImplSVData* pSVData = ImplGetSVData();
62 SAL_WARN_IF(pSVData->maFrameData.mpAppWin, "vcl",
63 "WorkWindow::WorkWindow(): More than one window with style WB_APP");
64 pSVData->maFrameData.mpAppWin = this;
67 SetActivateMode( ActivateModeFlags::GrabFocus );
70 void WorkWindow::ImplInit( vcl::Window* pParent, WinBits nStyle, const css::uno::Any& aSystemWorkWindowToken )
72 if( aSystemWorkWindowToken.hasValue() )
74 css::uno::Sequence< sal_Int8 > aSeq;
75 aSystemWorkWindowToken >>= aSeq;
76 SystemParentData* pData = reinterpret_cast<SystemParentData*>(aSeq.getArray());
77 SAL_WARN_IF( aSeq.getLength() != sizeof( SystemParentData ) || pData->nSize != sizeof( SystemParentData ), "vcl", "WorkWindow::WorkWindow( vcl::Window*, const Any&, WinBits ) called with invalid Any" );
78 // init with style 0 as does WorkWindow::WorkWindow( SystemParentData* );
79 ImplInit( pParent, 0, pData );
81 else
82 ImplInit( pParent, nStyle );
85 WorkWindow::WorkWindow( WindowType nType ) :
86 SystemWindow( nType, "vcl::WorkWindow maLayoutIdle" )
88 ImplInitWorkWindowData();
91 WorkWindow::WorkWindow( vcl::Window* pParent, WinBits nStyle ) :
92 SystemWindow( WindowType::WORKWINDOW, "vcl::WorkWindow maLayoutIdle" )
94 ImplInitWorkWindowData();
95 ImplInit( pParent, nStyle );
98 WorkWindow::WorkWindow( vcl::Window* pParent, const css::uno::Any& aSystemWorkWindowToken, WinBits nStyle ) :
99 SystemWindow( WindowType::WORKWINDOW, "vcl::WorkWindow maLayoutIdle" )
101 ImplInitWorkWindowData();
102 mbSysChild = true;
103 ImplInit( pParent, nStyle, aSystemWorkWindowToken );
106 WorkWindow::WorkWindow( SystemParentData* pParent ) :
107 SystemWindow( WindowType::WORKWINDOW, "vcl::WorkWindow maLayoutIdle" )
109 ImplInitWorkWindowData();
110 mbSysChild = true;
111 ImplInit( nullptr, 0, pParent );
114 WorkWindow::~WorkWindow()
116 disposeOnce();
119 void WorkWindow::dispose()
121 ImplSVData* pSVData = ImplGetSVData();
122 if (pSVData->maFrameData.mpAppWin == this)
124 pSVData->maFrameData.mpAppWin = nullptr;
125 Application::Quit();
127 SystemWindow::dispose();
130 void WorkWindow::ShowFullScreenMode( bool bFullScreenMode )
132 return ShowFullScreenMode( bFullScreenMode, GetScreenNumber());
135 void WorkWindow::ShowFullScreenMode( bool bFullScreenMode, sal_Int32 nDisplayScreen )
137 if ( !mbFullScreenMode == !bFullScreenMode )
138 return;
140 mbFullScreenMode = bFullScreenMode;
141 if ( mbSysChild )
142 return;
144 // Dispose of the canvas implementation, which might rely on
145 // screen-specific system data.
146 GetOutDev()->ImplDisposeCanvas();
148 mpWindowImpl->mpFrameWindow->mpWindowImpl->mbWaitSystemResize = true;
149 ImplGetFrame()->ShowFullScreen( bFullScreenMode, nDisplayScreen );
152 void WorkWindow::StartPresentationMode( PresentationFlags nFlags )
154 return StartPresentationMode( false/*bPresentation*/, nFlags, GetScreenNumber());
157 void WorkWindow::StartPresentationMode( bool bPresentation, PresentationFlags nFlags, sal_Int32 nDisplayScreen )
159 if ( !bPresentation == !mbPresentationMode )
160 return;
162 if ( bPresentation )
164 mbPresentationMode = true;
165 mbPresentationVisible = IsVisible();
166 mbPresentationFull = mbFullScreenMode;
167 mnPresentationFlags = nFlags;
169 ShowFullScreenMode( true, nDisplayScreen );
170 if ( !mbSysChild )
172 if ( mnPresentationFlags & PresentationFlags::HideAllApps )
173 mpWindowImpl->mpFrame->SetAlwaysOnTop( true );
174 ToTop();
175 mpWindowImpl->mpFrame->StartPresentation( true );
178 Show();
180 else
182 Show( mbPresentationVisible );
183 if ( !mbSysChild )
185 mpWindowImpl->mpFrame->StartPresentation( false );
186 if ( mnPresentationFlags & PresentationFlags::HideAllApps )
187 mpWindowImpl->mpFrame->SetAlwaysOnTop( false );
189 ShowFullScreenMode( mbPresentationFull, nDisplayScreen );
191 mbPresentationMode = false;
192 mbPresentationVisible = false;
193 mbPresentationFull = false;
194 mnPresentationFlags = PresentationFlags::NONE;
198 bool WorkWindow::IsMinimized() const
200 vcl::WindowData aData;
201 if (mpWindowImpl->mpFrame->GetWindowState(&aData))
202 return bool(aData.state() & vcl::WindowState::Minimized);
203 else
204 return false;
207 void WorkWindow::SetPluginParent( SystemParentData* pParent )
209 SAL_WARN_IF( mbPresentationMode || mbFullScreenMode, "vcl", "SetPluginParent in fullscreen or presentation mode !" );
211 bool bWasDnd = Window::ImplStopDnd();
213 bool bShown = IsVisible();
214 Show( false );
215 mpWindowImpl->mpFrame->SetPluginParent( pParent );
216 Show( bShown );
218 if( bWasDnd )
219 Window::ImplStartDnd();
222 void WorkWindow::ImplSetFrameState(vcl::WindowState aFrameState )
224 vcl::WindowData aState;
225 aState.setMask(vcl::WindowDataMask::State);
226 aState.setState(aFrameState);
227 mpWindowImpl->mpFrame->SetWindowState(&aState);
230 void WorkWindow::Minimize()
232 ImplSetFrameState( vcl::WindowState::Minimized );
235 void WorkWindow::Restore()
237 ImplSetFrameState( vcl::WindowState::Normal );
240 bool WorkWindow::Close()
242 bool bCanClose = SystemWindow::Close();
244 // if it's the application window then close the application
245 if (bCanClose && (ImplGetSVData()->maFrameData.mpAppWin == this))
246 Application::Quit();
248 return bCanClose;
251 void WorkWindow::Maximize( bool bMaximize )
253 ImplSetFrameState( bMaximize ? vcl::WindowState::Maximized : vcl::WindowState::Normal );
256 bool WorkWindow::IsMaximized() const
258 bool bRet = false;
260 vcl::WindowData aState;
261 if( mpWindowImpl->mpFrame->GetWindowState( &aState ) )
263 if( aState.state() & (vcl::WindowState::Maximized |
264 vcl::WindowState::MaximizedHorz |
265 vcl::WindowState::MaximizedVert ) )
266 bRet = true;
268 return bRet;
271 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */