LibreOffice Module vcl (master) 1
wrkwin.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
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>
28
29#include <svdata.hxx>
30#include <salframe.hxx>
31#include <brdwin.hxx>
32#include <window.h>
33
35{
36 mnIcon = 0; // Should be removed in the next top level update - now in SystemWindow
37
39 mbPresentationMode = false;
41 mbPresentationFull = false;
42 mbFullScreenMode = false;
43}
44
45void WorkWindow::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData )
46{
48 if ( nStyle & WB_APP )
49 nFrameStyle |= BorderWindowStyle::App;
50
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;
56
57 // mpWindowImpl->mpRealParent = pParent; // should actually be set, but is not set due to errors with the menubar!!
58
59 if ( nStyle & WB_APP )
60 {
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;
65 }
66
68}
69
70void WorkWindow::ImplInit( vcl::Window* pParent, WinBits nStyle, const css::uno::Any& aSystemWorkWindowToken )
71{
72 if( aSystemWorkWindowToken.hasValue() )
73 {
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 );
80 }
81 else
82 ImplInit( pParent, nStyle );
83}
84
86 SystemWindow( nType, "vcl::WorkWindow maLayoutIdle" )
87{
89}
90
92 SystemWindow( WindowType::WORKWINDOW, "vcl::WorkWindow maLayoutIdle" )
93{
95 ImplInit( pParent, nStyle );
96}
97
98WorkWindow::WorkWindow( vcl::Window* pParent, const css::uno::Any& aSystemWorkWindowToken, WinBits nStyle ) :
99 SystemWindow( WindowType::WORKWINDOW, "vcl::WorkWindow maLayoutIdle" )
100{
102 mbSysChild = true;
103 ImplInit( pParent, nStyle, aSystemWorkWindowToken );
104}
105
107 SystemWindow( WindowType::WORKWINDOW, "vcl::WorkWindow maLayoutIdle" )
108{
110 mbSysChild = true;
111 ImplInit( nullptr, 0, pParent );
112}
113
115{
116 disposeOnce();
117}
118
120{
121 ImplSVData* pSVData = ImplGetSVData();
122 if (pSVData->maFrameData.mpAppWin == this)
123 {
124 pSVData->maFrameData.mpAppWin = nullptr;
126 }
128}
129
130void WorkWindow::ShowFullScreenMode( bool bFullScreenMode )
131{
132 return ShowFullScreenMode( bFullScreenMode, GetScreenNumber());
133}
134
135void WorkWindow::ShowFullScreenMode( bool bFullScreenMode, sal_Int32 nDisplayScreen )
136{
137 if ( !mbFullScreenMode == !bFullScreenMode )
138 return;
139
140 mbFullScreenMode = bFullScreenMode;
141 if ( mbSysChild )
142 return;
143
144 // Dispose of the canvas implementation, which might rely on
145 // screen-specific system data.
147
148 mpWindowImpl->mpFrameWindow->mpWindowImpl->mbWaitSystemResize = true;
149 ImplGetFrame()->ShowFullScreen( bFullScreenMode, nDisplayScreen );
150}
151
153{
154 return StartPresentationMode( false/*bPresentation*/, nFlags, GetScreenNumber());
155}
156
157void WorkWindow::StartPresentationMode( bool bPresentation, PresentationFlags nFlags, sal_Int32 nDisplayScreen )
158{
159 if ( !bPresentation == !mbPresentationMode )
160 return;
161
162 if ( bPresentation )
163 {
164 mbPresentationMode = true;
167 mnPresentationFlags = nFlags;
168
169 ShowFullScreenMode( true, nDisplayScreen );
170 if ( !mbSysChild )
171 {
173 mpWindowImpl->mpFrame->SetAlwaysOnTop( true );
174 ToTop();
175 mpWindowImpl->mpFrame->StartPresentation( true );
176 }
177
178 Show();
179 }
180 else
181 {
183 if ( !mbSysChild )
184 {
185 mpWindowImpl->mpFrame->StartPresentation( false );
187 mpWindowImpl->mpFrame->SetAlwaysOnTop( false );
188 }
189 ShowFullScreenMode( mbPresentationFull, nDisplayScreen );
190
191 mbPresentationMode = false;
192 mbPresentationVisible = false;
193 mbPresentationFull = false;
195 }
196}
197
199{
201 if (mpWindowImpl->mpFrame->GetWindowState(&aData))
202 return bool(aData.state() & vcl::WindowState::Minimized);
203 else
204 return false;
205}
206
208{
209 SAL_WARN_IF( mbPresentationMode || mbFullScreenMode, "vcl", "SetPluginParent in fullscreen or presentation mode !" );
210
211 bool bWasDnd = Window::ImplStopDnd();
212
213 bool bShown = IsVisible();
214 Show( false );
215 mpWindowImpl->mpFrame->SetPluginParent( pParent );
216 Show( bShown );
217
218 if( bWasDnd )
219 Window::ImplStartDnd();
220}
221
223{
224 vcl::WindowData aState;
226 aState.setState(aFrameState);
227 mpWindowImpl->mpFrame->SetWindowState(&aState);
228}
229
231{
233}
234
236{
238}
239
241{
242 bool bCanClose = SystemWindow::Close();
243
244 // if it's the application window then close the application
245 if (bCanClose && (ImplGetSVData()->maFrameData.mpAppWin == this))
247
248 return bCanClose;
249}
250
251void WorkWindow::Maximize( bool bMaximize )
252{
254}
255
257{
258 bool bRet = false;
259
260 vcl::WindowData aState;
261 if( mpWindowImpl->mpFrame->GetWindowState( &aState ) )
262 {
263 if( aState.state() & (vcl::WindowState::Maximized |
266 bRet = true;
267 }
268 return bRet;
269}
270
271/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
BorderWindowStyle
Definition: brdwin.hxx:33
static void Quit()
Quit the program.
Definition: svapp.cxx:445
SAL_DLLPRIVATE void ImplDisposeCanvas()
Definition: outdev.cxx:809
virtual void ShowFullScreen(bool bFullScreen, sal_Int32 nDisplay)=0
bool mbSysChild
Definition: syswin.hxx:104
sal_uInt16 mnIcon
Definition: syswin.hxx:109
virtual bool Close()
Definition: syswin.cxx:262
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: syswin.cxx:103
unsigned int GetScreenNumber() const
Returns the screen number the window is on.
Definition: syswin.cxx:956
friend class WorkWindow
Definition: syswin.hxx:96
A construction helper for a temporary VclPtr.
Definition: vclptr.hxx:277
void Restore()
Definition: wrkwin.cxx:235
virtual bool Close() override
Definition: wrkwin.cxx:240
SAL_DLLPRIVATE void ImplInitWorkWindowData()
Definition: wrkwin.cxx:34
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: wrkwin.cxx:119
bool mbPresentationMode
Definition: wrkwin.hxx:48
bool mbPresentationVisible
Definition: wrkwin.hxx:49
PresentationFlags mnPresentationFlags
Definition: wrkwin.hxx:47
bool mbPresentationFull
Definition: wrkwin.hxx:50
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, const css::uno::Any &aSystemWorkWindowToken)
Definition: wrkwin.cxx:70
void Minimize()
Definition: wrkwin.cxx:230
bool mbFullScreenMode
Definition: wrkwin.hxx:51
bool IsMaximized() const
Definition: wrkwin.cxx:256
void ShowFullScreenMode(bool bFullScreenMode, sal_Int32 nDisplayScreen)
Definition: wrkwin.cxx:135
void Maximize(bool bMaximize=true)
Definition: wrkwin.cxx:251
void StartPresentationMode(bool bPresentation, PresentationFlags nFlags, sal_Int32 nDisplayScreen)
Definition: wrkwin.cxx:157
bool IsMinimized() const
Definition: wrkwin.cxx:198
void SetPluginParent(SystemParentData *pParent)
Definition: wrkwin.cxx:207
virtual ~WorkWindow() override
Definition: wrkwin.cxx:114
SAL_DLLPRIVATE void ImplSetFrameState(vcl::WindowState)
Definition: wrkwin.cxx:222
WindowState state() const
Definition: windowstate.hxx:89
void setMask(WindowDataMask nMask)
Definition: windowstate.hxx:92
void setState(WindowState nState)
Definition: windowstate.hxx:88
void SetActivateMode(ActivateModeFlags nMode)
Definition: window.cxx:2635
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2187
void ToTop(ToTopFlags nFlags=ToTopFlags::NONE)
Definition: stacking.cxx:419
::OutputDevice const * GetOutDev() const
Definition: window.cxx:567
std::unique_ptr< WindowImpl > mpWindowImpl
Definition: window.hxx:484
SalFrame * ImplGetFrame() const
Definition: window2.cxx:879
bool IsVisible() const
Definition: window2.cxx:1128
Sequence< sal_Int8 > aSeq
#define SAL_WARN_IF(condition, area, stream)
std::unique_ptr< sal_Int32[]> pData
constexpr OUStringLiteral aData
WindowState
Definition: windowstate.hxx:28
QPRO_FUNC_TYPE nType
ImplSVFrameData maFrameData
Definition: svdata.hxx:399
VclPtr< WorkWindow > mpAppWin
Definition: svdata.hxx:243
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:77
sal_Int64 WinBits
Definition: wintypes.hxx:109
WinBits const WB_DIALOGCONTROL
Definition: wintypes.hxx:113
WindowType
Definition: wintypes.hxx:27
WinBits const WB_APP
Definition: wintypes.hxx:125
WinBits const WB_3DLOOK
Definition: wintypes.hxx:118
WinBits const WB_SYSTEMFLOATWIN
Definition: wintypes.hxx:169
WinBits const WB_CLIPCHILDREN
Definition: wintypes.hxx:112
PresentationFlags
Definition: wrkwin.hxx:33