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

Generated by: LCOV version 1.10