bump product version to 6.4.0.3
[LibreOffice.git] / vcl / source / window / wrkwin.cxx
blob0fd563ecb5870a0a8ea513e2ca959bfbc2202b1b
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;
44 maLayoutIdle.SetDebugName( "vcl::WorkWindow maLayoutIdle" );
47 void WorkWindow::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData )
49 BorderWindowStyle nFrameStyle = BorderWindowStyle::Frame;
50 if ( nStyle & WB_APP )
51 nFrameStyle |= BorderWindowStyle::App;
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;
59 // mpWindowImpl->mpRealParent = pParent; // should actually be set, but is not set due to errors with the menubar!!
61 if ( nStyle & WB_APP )
63 ImplSVData* pSVData = ImplGetSVData();
64 SAL_WARN_IF( pSVData->maWinData.mpAppWin, "vcl", "WorkWindow::WorkWindow(): More than one window with style WB_APP" );
65 pSVData->maWinData.mpAppWin = this;
68 SetActivateMode( ActivateModeFlags::GrabFocus );
71 void WorkWindow::ImplInit( vcl::Window* pParent, WinBits nStyle, const css::uno::Any& aSystemWorkWindowToken )
73 if( aSystemWorkWindowToken.hasValue() )
75 css::uno::Sequence< sal_Int8 > aSeq;
76 aSystemWorkWindowToken >>= aSeq;
77 SystemParentData* pData = reinterpret_cast<SystemParentData*>(aSeq.getArray());
78 SAL_WARN_IF( aSeq.getLength() != sizeof( SystemParentData ) || pData->nSize != sizeof( SystemParentData ), "vcl", "WorkWindow::WorkWindow( vcl::Window*, const Any&, WinBits ) called with invalid Any" );
79 // init with style 0 as does WorkWindow::WorkWindow( SystemParentData* );
80 ImplInit( pParent, 0, pData );
82 else
83 ImplInit( pParent, nStyle );
86 WorkWindow::WorkWindow( WindowType nType ) :
87 SystemWindow( nType )
89 ImplInitWorkWindowData();
92 WorkWindow::WorkWindow( vcl::Window* pParent, WinBits nStyle ) :
93 SystemWindow( WindowType::WORKWINDOW )
95 ImplInitWorkWindowData();
96 ImplInit( pParent, nStyle );
99 WorkWindow::WorkWindow( vcl::Window* pParent, const css::uno::Any& aSystemWorkWindowToken, WinBits nStyle ) :
100 SystemWindow( WindowType::WORKWINDOW )
102 ImplInitWorkWindowData();
103 mbSysChild = true;
104 ImplInit( pParent, nStyle, aSystemWorkWindowToken );
107 WorkWindow::WorkWindow( SystemParentData* pParent ) :
108 SystemWindow( WindowType::WORKWINDOW )
110 ImplInitWorkWindowData();
111 mbSysChild = true;
112 ImplInit( nullptr, 0, pParent );
115 WorkWindow::~WorkWindow()
117 disposeOnce();
120 void WorkWindow::dispose()
122 ImplSVData* pSVData = ImplGetSVData();
123 if ( pSVData->maWinData.mpAppWin == this )
125 pSVData->maWinData.mpAppWin = nullptr;
126 Application::Quit();
128 SystemWindow::dispose();
131 void WorkWindow::ShowFullScreenMode( bool bFullScreenMode )
133 return ShowFullScreenMode( bFullScreenMode, GetScreenNumber());
136 void WorkWindow::ShowFullScreenMode( bool bFullScreenMode, sal_Int32 nDisplayScreen )
138 if ( !mbFullScreenMode == !bFullScreenMode )
139 return;
141 mbFullScreenMode = bFullScreenMode;
142 if ( !mbSysChild )
144 // Dispose of the canvas implementation, which might rely on
145 // screen-specific system data.
146 css::uno::Reference< css::rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas );
147 if( xCanvas.is() )
149 css::uno::Reference< css::lang::XComponent > xCanvasComponent( xCanvas, css::uno::UNO_QUERY );
150 if( xCanvasComponent.is() )
151 xCanvasComponent->dispose();
154 mpWindowImpl->mpFrameWindow->mpWindowImpl->mbWaitSystemResize = true;
155 ImplGetFrame()->ShowFullScreen( bFullScreenMode, nDisplayScreen );
159 void WorkWindow::StartPresentationMode( PresentationFlags nFlags )
161 return StartPresentationMode( false/*bPresentation*/, nFlags, GetScreenNumber());
164 void WorkWindow::StartPresentationMode( bool bPresentation, PresentationFlags nFlags, sal_Int32 nDisplayScreen )
166 if ( !bPresentation == !mbPresentationMode )
167 return;
169 if ( bPresentation )
171 mbPresentationMode = true;
172 mbPresentationVisible = IsVisible();
173 mbPresentationFull = mbFullScreenMode;
174 mnPresentationFlags = nFlags;
176 ShowFullScreenMode( true, nDisplayScreen );
177 if ( !mbSysChild )
179 if ( mnPresentationFlags & PresentationFlags::HideAllApps )
180 mpWindowImpl->mpFrame->SetAlwaysOnTop( true );
181 ToTop();
182 mpWindowImpl->mpFrame->StartPresentation( true );
185 Show();
187 else
189 Show( mbPresentationVisible );
190 if ( !mbSysChild )
192 mpWindowImpl->mpFrame->StartPresentation( false );
193 if ( mnPresentationFlags & PresentationFlags::HideAllApps )
194 mpWindowImpl->mpFrame->SetAlwaysOnTop( false );
196 ShowFullScreenMode( mbPresentationFull, nDisplayScreen );
198 mbPresentationMode = false;
199 mbPresentationVisible = false;
200 mbPresentationFull = false;
201 mnPresentationFlags = PresentationFlags::NONE;
205 bool WorkWindow::IsMinimized() const
207 //return mpWindowImpl->mpFrameData->mbMinimized;
208 SalFrameState aState;
209 if (mpWindowImpl->mpFrame->GetWindowState(&aState))
210 return bool(aState.mnState & WindowStateState::Minimized);
211 else
212 return false;
215 void WorkWindow::SetPluginParent( SystemParentData* pParent )
217 SAL_WARN_IF( mbPresentationMode || mbFullScreenMode, "vcl", "SetPluginParent in fullscreen or presentation mode !" );
219 bool bWasDnd = Window::ImplStopDnd();
221 bool bShown = IsVisible();
222 Show( false );
223 mpWindowImpl->mpFrame->SetPluginParent( pParent );
224 Show( bShown );
226 if( bWasDnd )
227 Window::ImplStartDnd();
230 void WorkWindow::ImplSetFrameState( WindowStateState aFrameState )
232 SalFrameState aState;
233 aState.mnMask = WindowStateMask::State;
234 aState.mnState = aFrameState;
235 mpWindowImpl->mpFrame->SetWindowState( &aState );
238 void WorkWindow::Minimize()
240 ImplSetFrameState( WindowStateState::Minimized );
243 void WorkWindow::Restore()
245 ImplSetFrameState( WindowStateState::Normal );
248 bool WorkWindow::Close()
250 bool bCanClose = SystemWindow::Close();
252 // if it's the application window then close the application
253 if ( bCanClose && ( ImplGetSVData()->maWinData.mpAppWin == this ) )
254 Application::Quit();
256 return bCanClose;
259 void WorkWindow::Maximize( bool bMaximize )
261 ImplSetFrameState( bMaximize ? WindowStateState::Maximized : WindowStateState::Normal );
264 bool WorkWindow::IsMaximized() const
266 bool bRet = false;
268 SalFrameState aState;
269 if( mpWindowImpl->mpFrame->GetWindowState( &aState ) )
271 if( aState.mnState & (WindowStateState::Maximized |
272 WindowStateState::MaximizedHorz |
273 WindowStateState::MaximizedVert ) )
274 bRet = true;
276 return bRet;
279 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */