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;
40  mbPresentationVisible = false;
41  mbPresentationFull = false;
42  mbFullScreenMode = false;
43 
44  maLayoutIdle.SetDebugName( "vcl::WorkWindow maLayoutIdle" );
45 }
46 
47 void WorkWindow::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData )
48 {
50  if ( nStyle & WB_APP )
51  nFrameStyle |= BorderWindowStyle::App;
52 
53  VclPtrInstance<ImplBorderWindow> pBorderWin( pParent, pSystemParentData, nStyle, nFrameStyle );
54  Window::ImplInit( pBorderWin, nStyle & (WB_3DLOOK | WB_CLIPCHILDREN | WB_DIALOGCONTROL | WB_SYSTEMFLOATWIN), nullptr );
55  pBorderWin->mpWindowImpl->mpClientWindow = this;
56  pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
57  mpWindowImpl->mpBorderWindow = pBorderWin;
58 
59  // mpWindowImpl->mpRealParent = pParent; // should actually be set, but is not set due to errors with the menubar!!
60 
61  if ( nStyle & WB_APP )
62  {
63  ImplSVData* pSVData = ImplGetSVData();
64  SAL_WARN_IF(pSVData->maFrameData.mpAppWin, "vcl",
65  "WorkWindow::WorkWindow(): More than one window with style WB_APP");
66  pSVData->maFrameData.mpAppWin = this;
67  }
68 
70 }
71 
72 void WorkWindow::ImplInit( vcl::Window* pParent, WinBits nStyle, const css::uno::Any& aSystemWorkWindowToken )
73 {
74  if( aSystemWorkWindowToken.hasValue() )
75  {
76  css::uno::Sequence< sal_Int8 > aSeq;
77  aSystemWorkWindowToken >>= aSeq;
78  SystemParentData* pData = reinterpret_cast<SystemParentData*>(aSeq.getArray());
79  SAL_WARN_IF( aSeq.getLength() != sizeof( SystemParentData ) || pData->nSize != sizeof( SystemParentData ), "vcl", "WorkWindow::WorkWindow( vcl::Window*, const Any&, WinBits ) called with invalid Any" );
80  // init with style 0 as does WorkWindow::WorkWindow( SystemParentData* );
81  ImplInit( pParent, 0, pData );
82  }
83  else
84  ImplInit( pParent, nStyle );
85 }
86 
88  SystemWindow( nType )
89 {
91 }
92 
95 {
97  ImplInit( pParent, nStyle );
98 }
99 
100 WorkWindow::WorkWindow( vcl::Window* pParent, const css::uno::Any& aSystemWorkWindowToken, WinBits nStyle ) :
102 {
104  mbSysChild = true;
105  ImplInit( pParent, nStyle, aSystemWorkWindowToken );
106 }
107 
110 {
112  mbSysChild = true;
113  ImplInit( nullptr, 0, pParent );
114 }
115 
117 {
118  disposeOnce();
119 }
120 
122 {
123  ImplSVData* pSVData = ImplGetSVData();
124  if (pSVData->maFrameData.mpAppWin == this)
125  {
126  pSVData->maFrameData.mpAppWin = nullptr;
128  }
130 }
131 
132 void WorkWindow::ShowFullScreenMode( bool bFullScreenMode )
133 {
134  return ShowFullScreenMode( bFullScreenMode, GetScreenNumber());
135 }
136 
137 void WorkWindow::ShowFullScreenMode( bool bFullScreenMode, sal_Int32 nDisplayScreen )
138 {
139  if ( !mbFullScreenMode == !bFullScreenMode )
140  return;
141 
142  mbFullScreenMode = bFullScreenMode;
143  if ( !mbSysChild )
144  {
145  // Dispose of the canvas implementation, which might rely on
146  // screen-specific system data.
147  css::uno::Reference< css::rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas );
148  if( xCanvas.is() )
149  {
150  css::uno::Reference< css::lang::XComponent > xCanvasComponent( xCanvas, css::uno::UNO_QUERY );
151  if( xCanvasComponent.is() )
152  xCanvasComponent->dispose();
153  }
154 
155  mpWindowImpl->mpFrameWindow->mpWindowImpl->mbWaitSystemResize = true;
156  ImplGetFrame()->ShowFullScreen( bFullScreenMode, nDisplayScreen );
157  }
158 }
159 
161 {
162  return StartPresentationMode( false/*bPresentation*/, nFlags, GetScreenNumber());
163 }
164 
165 void WorkWindow::StartPresentationMode( bool bPresentation, PresentationFlags nFlags, sal_Int32 nDisplayScreen )
166 {
167  if ( !bPresentation == !mbPresentationMode )
168  return;
169 
170  if ( bPresentation )
171  {
172  mbPresentationMode = true;
175  mnPresentationFlags = nFlags;
176 
177  ShowFullScreenMode( true, nDisplayScreen );
178  if ( !mbSysChild )
179  {
181  mpWindowImpl->mpFrame->SetAlwaysOnTop( true );
182  ToTop();
183  mpWindowImpl->mpFrame->StartPresentation( true );
184  }
185 
186  Show();
187  }
188  else
189  {
191  if ( !mbSysChild )
192  {
193  mpWindowImpl->mpFrame->StartPresentation( false );
195  mpWindowImpl->mpFrame->SetAlwaysOnTop( false );
196  }
197  ShowFullScreenMode( mbPresentationFull, nDisplayScreen );
198 
199  mbPresentationMode = false;
200  mbPresentationVisible = false;
201  mbPresentationFull = false;
203  }
204 }
205 
207 {
208  //return mpWindowImpl->mpFrameData->mbMinimized;
209  SalFrameState aState;
210  if (mpWindowImpl->mpFrame->GetWindowState(&aState))
211  return bool(aState.mnState & WindowStateState::Minimized);
212  else
213  return false;
214 }
215 
217 {
218  SAL_WARN_IF( mbPresentationMode || mbFullScreenMode, "vcl", "SetPluginParent in fullscreen or presentation mode !" );
219 
220  bool bWasDnd = Window::ImplStopDnd();
221 
222  bool bShown = IsVisible();
223  Show( false );
224  mpWindowImpl->mpFrame->SetPluginParent( pParent );
225  Show( bShown );
226 
227  if( bWasDnd )
228  Window::ImplStartDnd();
229 }
230 
232 {
233  SalFrameState aState;
235  aState.mnState = aFrameState;
236  mpWindowImpl->mpFrame->SetWindowState( &aState );
237 }
238 
240 {
242 }
243 
245 {
247 }
248 
250 {
251  bool bCanClose = SystemWindow::Close();
252 
253  // if it's the application window then close the application
254  if (bCanClose && (ImplGetSVData()->maFrameData.mpAppWin == this))
256 
257  return bCanClose;
258 }
259 
260 void WorkWindow::Maximize( bool bMaximize )
261 {
263 }
264 
266 {
267  bool bRet = false;
268 
269  SalFrameState aState;
270  if( mpWindowImpl->mpFrame->GetWindowState( &aState ) )
271  {
272  if( aState.mnState & (WindowStateState::Maximized |
275  bRet = true;
276  }
277  return bRet;
278 }
279 
280 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
WinBits const WB_APP
SAL_DLLPRIVATE void ImplInitWorkWindowData()
Definition: wrkwin.cxx:34
WindowStateState mnState
Definition: salwtype.hxx:238
std::unique_ptr< ContentProperties > pData
virtual ~WorkWindow() override
Definition: wrkwin.cxx:116
void StartPresentationMode(bool bPresentation, PresentationFlags nFlags, sal_Int32 nDisplayScreen)
Definition: wrkwin.cxx:165
void Maximize(bool bMaximize=true)
Definition: wrkwin.cxx:260
void Restore()
Definition: wrkwin.cxx:244
sal_Int64 WinBits
virtual bool Close() override
Definition: wrkwin.cxx:249
bool mbPresentationFull
Definition: wrkwin.hxx:48
WorkWindow(const WorkWindow &rWin)=delete
bool mbPresentationVisible
Definition: wrkwin.hxx:48
static void Quit()
Quit the program.
Definition: svapp.cxx:518
WinBits const WB_SYSTEMFLOATWIN
Idle maLayoutIdle
Definition: syswin.hxx:80
sal_uInt32 nSize
Definition: sysdata.hxx:105
SAL_DLLPRIVATE void ImplSetFrameState(WindowStateState aFrameState)
Definition: wrkwin.cxx:231
void SetDebugName(const char *pDebugName)
Definition: task.hxx:81
virtual bool Close()
Definition: syswin.cxx:264
WinBits const WB_DIALOGCONTROL
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:75
bool mbFullScreenMode
Definition: wrkwin.hxx:48
unsigned int GetScreenNumber() const
Returns the screen number the window is on.
Definition: syswin.cxx:1014
void SetActivateMode(ActivateModeFlags nMode)
Definition: window.cxx:2651
void ToTop(ToTopFlags nFlags=ToTopFlags::NONE)
Definition: stacking.cxx:420
PresentationFlags
Definition: wrkwin.hxx:32
VclPtr< WorkWindow > mpAppWin
Definition: svdata.hxx:202
bool IsMinimized() const
Definition: wrkwin.cxx:206
sal_uInt16 mnIcon
Definition: syswin.hxx:78
std::unique_ptr< WindowImpl > mpWindowImpl
Definition: window.hxx:511
virtual void ShowFullScreen(bool bFullScreen, sal_Int32 nDisplay)=0
WinBits const WB_3DLOOK
A construction helper for a temporary VclPtr.
Definition: vclptr.hxx:275
SalFrame * ImplGetFrame() const
Definition: window2.cxx:848
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: syswin.cxx:99
WindowType
bool mbPresentationMode
Definition: wrkwin.hxx:48
#define SAL_WARN_IF(condition, area, stream)
void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const
Definition: brdwin.cxx:2032
ImplSVFrameData maFrameData
Definition: svdata.hxx:357
bool IsVisible() const
Definition: window2.cxx:1097
bool IsMaximized() const
Definition: wrkwin.cxx:265
PresentationFlags mnPresentationFlags
Definition: wrkwin.hxx:47
Sequence< sal_Int8 > aSeq
BorderWindowStyle
Definition: brdwin.hxx:33
void Minimize()
Definition: wrkwin.cxx:239
void ShowFullScreenMode(bool bFullScreenMode, sal_Int32 nDisplayScreen)
Definition: wrkwin.cxx:137
WindowStateState
Definition: vclenum.hxx:301
void SetPluginParent(SystemParentData *pParent)
Definition: wrkwin.cxx:216
WindowStateMask mnMask
Definition: salwtype.hxx:229
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, const css::uno::Any &aSystemWorkWindowToken)
Definition: wrkwin.cxx:72
WinBits const WB_CLIPCHILDREN
bool mbSysChild
Definition: syswin.hxx:74
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: wrkwin.cxx:121
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2151