LCOV - code coverage report
Current view: top level - vcl/source/window - wrkwin.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 40 142 28.2 %
Date: 2015-06-13 12:38:46 Functions: 7 22 31.8 %
Legend: Lines: hit not hit

          Line data    Source code
       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 <tools/debug.hxx>
      21             : #include <tools/rc.h>
      22             : 
      23             : #include <vcl/svapp.hxx>
      24             : #include <vcl/wrkwin.hxx>
      25             : // declare system types in sysdata.hxx
      26             : #include <vcl/sysdata.hxx>
      27             : #include <com/sun/star/lang/XComponent.hpp>
      28             : #include <com/sun/star/rendering/XCanvas.hpp>
      29             : 
      30             : #include <svdata.hxx>
      31             : #include <salframe.hxx>
      32             : #include <brdwin.hxx>
      33             : #include <window.h>
      34             : 
      35        3631 : void WorkWindow::ImplInitWorkWindowData()
      36             : {
      37        3631 :     mnIcon                  = 0; // Should be removed in the next top level update - now in SystemWindow
      38             : 
      39        3631 :     mnPresentationFlags     = PresentationFlags::NONE;
      40        3631 :     mbPresentationMode      = false;
      41        3631 :     mbPresentationVisible   = false;
      42        3631 :     mbPresentationFull      = false;
      43        3631 :     mbFullScreenMode        = false;
      44        3631 : }
      45             : 
      46        3631 : void WorkWindow::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData )
      47             : {
      48        3631 :     sal_uInt16 nFrameStyle = BORDERWINDOW_STYLE_FRAME;
      49        3631 :     if ( nStyle & WB_APP )
      50           6 :         nFrameStyle |= BORDERWINDOW_STYLE_APP;
      51             : 
      52        3631 :     VclPtrInstance<ImplBorderWindow> pBorderWin( pParent, pSystemParentData, nStyle, nFrameStyle );
      53        3631 :     Window::ImplInit( pBorderWin, nStyle & (WB_3DLOOK | WB_CLIPCHILDREN | WB_DIALOGCONTROL | WB_SYSTEMFLOATWIN), NULL );
      54        3631 :     pBorderWin->mpWindowImpl->mpClientWindow = this;
      55        3631 :     pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
      56        3631 :     mpWindowImpl->mpBorderWindow  = pBorderWin;
      57             : 
      58             :     // mpWindowImpl->mpRealParent    = pParent; // should actually be set, but is not set due to errors with the menubar!!
      59             : 
      60        3631 :     if ( nStyle & WB_APP )
      61             :     {
      62           6 :         ImplSVData* pSVData = ImplGetSVData();
      63             :         DBG_ASSERT( !pSVData->maWinData.mpAppWin, "WorkWindow::WorkWindow(): More than one window with style WB_APP" );
      64           6 :         pSVData->maWinData.mpAppWin = this;
      65             :     }
      66             : 
      67        3631 :     SetActivateMode( ActivateModeFlags::GrabFocus );
      68        3631 : }
      69             : 
      70           0 : void WorkWindow::ImplInit( vcl::Window* pParent, WinBits nStyle, const ::com::sun::star::uno::Any& aSystemWorkWindowToken )
      71             : {
      72           0 :     if( aSystemWorkWindowToken.hasValue() )
      73             :     {
      74           0 :         ::com::sun::star::uno::Sequence< sal_Int8 > aSeq;
      75           0 :         aSystemWorkWindowToken >>= aSeq;
      76           0 :         SystemParentData* pData = reinterpret_cast<SystemParentData*>(aSeq.getArray());
      77             :         DBG_ASSERT( aSeq.getLength() == sizeof( SystemParentData ) && pData->nSize == sizeof( SystemParentData ), "WorkWindow::WorkWindow( vcl::Window*, const Any&, WinBits ) called with invalid Any" );
      78             :         // init with style 0 as does WorkWindow::WorkWindow( SystemParentData* );
      79           0 :         ImplInit( pParent, 0, pData );
      80             :     }
      81             :     else
      82           0 :         ImplInit( pParent, nStyle, NULL );
      83           0 : }
      84             : 
      85           0 : WorkWindow::WorkWindow( WindowType nType ) :
      86           0 :     SystemWindow( nType )
      87             : {
      88           0 :     ImplInitWorkWindowData();
      89           0 : }
      90             : 
      91        3631 : WorkWindow::WorkWindow( vcl::Window* pParent, WinBits nStyle ) :
      92        3631 :     SystemWindow( WINDOW_WORKWINDOW )
      93             : {
      94        3631 :     ImplInitWorkWindowData();
      95        3631 :     ImplInit( pParent, nStyle, NULL );
      96        3631 : }
      97             : 
      98           0 : WorkWindow::WorkWindow( vcl::Window* pParent, const ::com::sun::star::uno::Any& aSystemWorkWindowToken, WinBits nStyle ) :
      99           0 :     SystemWindow( WINDOW_WORKWINDOW )
     100             : {
     101           0 :     ImplInitWorkWindowData();
     102           0 :     mbSysChild = true;
     103           0 :     ImplInit( pParent, nStyle, aSystemWorkWindowToken );
     104           0 : }
     105             : 
     106           0 : WorkWindow::WorkWindow( SystemParentData* pParent ) :
     107           0 :     SystemWindow( WINDOW_WORKWINDOW )
     108             : {
     109           0 :     ImplInitWorkWindowData();
     110           0 :     mbSysChild = true;
     111           0 :     ImplInit( NULL, 0, pParent );
     112           0 : }
     113             : 
     114       10844 : WorkWindow::~WorkWindow()
     115             : {
     116        3615 :     disposeOnce();
     117        7229 : }
     118             : 
     119        3615 : void WorkWindow::dispose()
     120             : {
     121        3615 :     ImplSVData* pSVData = ImplGetSVData();
     122        3615 :     if ( pSVData->maWinData.mpAppWin == this )
     123             :     {
     124           6 :         pSVData->maWinData.mpAppWin = NULL;
     125           6 :         Application::Quit();
     126             :     }
     127        3615 :     SystemWindow::dispose();
     128        3615 : }
     129             : 
     130           0 : void WorkWindow::ShowFullScreenMode( bool bFullScreenMode )
     131             : {
     132           0 :     return ShowFullScreenMode( bFullScreenMode, GetScreenNumber());
     133             : }
     134             : 
     135           0 : void WorkWindow::ShowFullScreenMode( bool bFullScreenMode, sal_Int32 nDisplayScreen )
     136             : {
     137           0 :     if ( !mbFullScreenMode == !bFullScreenMode )
     138           0 :         return;
     139             : 
     140           0 :     mbFullScreenMode = bFullScreenMode;
     141           0 :     if ( !mbSysChild )
     142             :     {
     143             :         // Dispose of the canvas implementation, which might rely on
     144             :         // screen-specific system data.
     145           0 :         com::sun::star::uno::Reference< com::sun::star::rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas );
     146           0 :         if( xCanvas.is() )
     147             :         {
     148             :             com::sun::star::uno::Reference< com::sun::star::lang::XComponent >
     149             :                 xCanvasComponent( xCanvas,
     150           0 :                                   com::sun::star::uno::UNO_QUERY );
     151           0 :             if( xCanvasComponent.is() )
     152           0 :                 xCanvasComponent->dispose();
     153             :         }
     154             : 
     155           0 :         mpWindowImpl->mpFrameWindow->mpWindowImpl->mbWaitSystemResize = true;
     156           0 :         ImplGetFrame()->ShowFullScreen( bFullScreenMode, nDisplayScreen );
     157             :     }
     158             : }
     159             : 
     160           0 : void WorkWindow::StartPresentationMode( bool bPresentation, PresentationFlags nFlags )
     161             : {
     162           0 :     return StartPresentationMode( bPresentation, nFlags, GetScreenNumber());
     163             : }
     164             : 
     165           0 : void WorkWindow::StartPresentationMode( bool bPresentation, PresentationFlags nFlags, sal_Int32 nDisplayScreen )
     166             : {
     167           0 :     if ( !bPresentation == !mbPresentationMode )
     168           0 :         return;
     169             : 
     170           0 :     if ( bPresentation )
     171             :     {
     172           0 :         mbPresentationMode      = true;
     173           0 :         mbPresentationVisible   = IsVisible();
     174           0 :         mbPresentationFull      = mbFullScreenMode;
     175           0 :         mnPresentationFlags     = nFlags;
     176             : 
     177           0 :         if ( !(mnPresentationFlags & PresentationFlags::NoFullScreen) )
     178           0 :             ShowFullScreenMode( true, nDisplayScreen );
     179           0 :         if ( !mbSysChild )
     180             :         {
     181           0 :             if ( mnPresentationFlags & PresentationFlags::HideAllApps )
     182           0 :                 mpWindowImpl->mpFrame->SetAlwaysOnTop( true );
     183           0 :             if ( !(mnPresentationFlags & PresentationFlags::NoAutoShow) )
     184           0 :                 ToTop();
     185           0 :             mpWindowImpl->mpFrame->StartPresentation( true );
     186             :         }
     187             : 
     188           0 :         if ( !(mnPresentationFlags & PresentationFlags::NoAutoShow) )
     189           0 :             Show();
     190             :     }
     191             :     else
     192             :     {
     193           0 :         Show( mbPresentationVisible );
     194           0 :         if ( !mbSysChild )
     195             :         {
     196           0 :             mpWindowImpl->mpFrame->StartPresentation( false );
     197           0 :             if ( mnPresentationFlags & PresentationFlags::HideAllApps )
     198           0 :                 mpWindowImpl->mpFrame->SetAlwaysOnTop( false );
     199             :         }
     200           0 :         ShowFullScreenMode( mbPresentationFull, nDisplayScreen );
     201             : 
     202           0 :         mbPresentationMode      = false;
     203           0 :         mbPresentationVisible   = false;
     204           0 :         mbPresentationFull      = false;
     205           0 :         mnPresentationFlags     = PresentationFlags::NONE;
     206             :     }
     207             : }
     208             : 
     209        6464 : bool WorkWindow::IsMinimized() const
     210             : {
     211             :     //return mpWindowImpl->mpFrameData->mbMinimized;
     212             :     SalFrameState aState;
     213        6464 :     mpWindowImpl->mpFrame->GetWindowState(&aState);
     214        6464 :     return (( aState.mnState & WINDOWSTATE_STATE_MINIMIZED ) != 0);
     215             : }
     216             : 
     217           0 : bool WorkWindow::SetPluginParent( SystemParentData* pParent )
     218             : {
     219             :     DBG_ASSERT( ! mbPresentationMode && ! mbFullScreenMode, "SetPluginParent in fullscreen or presentation mode !" );
     220             : 
     221           0 :     bool bWasDnd = Window::ImplStopDnd();
     222             : 
     223           0 :     bool bShown = IsVisible();
     224           0 :     Show( false );
     225           0 :     bool bRet = mpWindowImpl->mpFrame->SetPluginParent( pParent );
     226           0 :     Show( bShown );
     227             : 
     228           0 :     if( bWasDnd )
     229           0 :         Window::ImplStartDnd();
     230             : 
     231           0 :     return bRet;
     232             : }
     233             : 
     234           0 : void WorkWindow::ImplSetFrameState( sal_uLong aFrameState )
     235             : {
     236             :     SalFrameState   aState;
     237           0 :     aState.mnMask   = WINDOWSTATE_MASK_STATE;
     238           0 :     aState.mnState  = aFrameState;
     239           0 :     mpWindowImpl->mpFrame->SetWindowState( &aState );
     240           0 : }
     241             : 
     242           0 : void WorkWindow::Minimize()
     243             : {
     244           0 :     ImplSetFrameState( WINDOWSTATE_STATE_MINIMIZED );
     245           0 : }
     246             : 
     247           0 : void WorkWindow::Restore()
     248             : {
     249           0 :     ImplSetFrameState( WINDOWSTATE_STATE_NORMAL );
     250           0 : }
     251             : 
     252           0 : bool WorkWindow::Close()
     253             : {
     254           0 :     bool bCanClose = SystemWindow::Close();
     255             : 
     256             :     // Ist es das Applikationsfenster, dann beende die Applikation
     257           0 :     if ( bCanClose && ( ImplGetSVData()->maWinData.mpAppWin == this ) )
     258           0 :         Application::Quit();
     259             : 
     260           0 :     return bCanClose;
     261             : }
     262             : 
     263           0 : void WorkWindow::Maximize( bool bMaximize )
     264             : {
     265           0 :     ImplSetFrameState( bMaximize ? WINDOWSTATE_STATE_MAXIMIZED : WINDOWSTATE_STATE_NORMAL );
     266           0 : }
     267             : 
     268           0 : bool WorkWindow::IsMaximized() const
     269             : {
     270           0 :     bool bRet = false;
     271             : 
     272             :     SalFrameState aState;
     273           0 :     if( mpWindowImpl->mpFrame->GetWindowState( &aState ) )
     274             :     {
     275           0 :         if( aState.mnState & (WINDOWSTATE_STATE_MAXIMIZED          |
     276             :                               WINDOWSTATE_STATE_MAXIMIZED_HORZ     |
     277             :                               WINDOWSTATE_STATE_MAXIMIZED_VERT ) )
     278           0 :             bRet = true;
     279             :     }
     280           0 :     return bRet;
     281             : }
     282             : 
     283             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11