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

Generated by: LCOV version 1.10