LCOV - code coverage report
Current view: top level - vcl/source/window - wrkwin.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 31 151 20.5 %
Date: 2012-08-25 Functions: 6 21 28.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 8 108 7.4 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <tools/debug.hxx>
      31                 :            : #include <tools/rc.h>
      32                 :            : 
      33                 :            : #include <vcl/svapp.hxx>
      34                 :            : #include <vcl/wrkwin.hxx>
      35                 :            : // declare system types in sysdata.hxx
      36                 :            : #include <svsys.h>
      37                 :            : #include <vcl/sysdata.hxx>
      38                 :            : #include <com/sun/star/lang/XComponent.hpp>
      39                 :            : #include <com/sun/star/rendering/XCanvas.hpp>
      40                 :            : 
      41                 :            : #include <svdata.hxx>
      42                 :            : #include <salframe.hxx>
      43                 :            : #include <brdwin.hxx>
      44                 :            : #include <window.h>
      45                 :            : 
      46                 :            : // =======================================================================
      47                 :            : 
      48                 :       2130 : void WorkWindow::ImplInitWorkWindowData()
      49                 :            : {
      50                 :       2130 :     mnIcon                  = 0; // Should be removed in the next top level update - now in SystemWindow
      51                 :            : 
      52                 :       2130 :     mnPresentationFlags     = 0;
      53                 :       2130 :     mbPresentationMode      = sal_False;
      54                 :       2130 :     mbPresentationVisible   = sal_False;
      55                 :       2130 :     mbPresentationFull      = sal_False;
      56                 :       2130 :     mbFullScreenMode        = sal_False;
      57                 :       2130 : }
      58                 :            : 
      59                 :            : // -----------------------------------------------------------------------
      60                 :            : 
      61                 :       2130 : void WorkWindow::ImplInit( Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData )
      62                 :            : {
      63                 :       2130 :     sal_uInt16 nFrameStyle = BORDERWINDOW_STYLE_FRAME;
      64         [ -  + ]:       2130 :     if ( nStyle & WB_APP )
      65                 :          0 :         nFrameStyle |= BORDERWINDOW_STYLE_APP;
      66                 :            : 
      67         [ +  - ]:       2130 :     ImplBorderWindow* pBorderWin = new ImplBorderWindow( pParent, pSystemParentData, nStyle, nFrameStyle );
      68                 :       2130 :     Window::ImplInit( pBorderWin, nStyle & (WB_3DLOOK | WB_CLIPCHILDREN | WB_DIALOGCONTROL | WB_SYSTEMFLOATWIN), NULL );
      69                 :       2130 :     pBorderWin->mpWindowImpl->mpClientWindow = this;
      70                 :       2130 :     pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
      71                 :       2130 :     mpWindowImpl->mpBorderWindow  = pBorderWin;
      72                 :            : 
      73                 :            :     // mpWindowImpl->mpRealParent    = pParent; // should actually be set, but is not set due to errors with the menubar!!
      74                 :            : 
      75         [ -  + ]:       2130 :     if ( nStyle & WB_APP )
      76                 :            :     {
      77                 :          0 :         ImplSVData* pSVData = ImplGetSVData();
      78                 :            :         DBG_ASSERT( !pSVData->maWinData.mpAppWin, "WorkWindow::WorkWindow(): More than one window with style WB_APP" );
      79                 :          0 :         pSVData->maWinData.mpAppWin = this;
      80                 :            :     }
      81                 :            : 
      82                 :       2130 :     SetActivateMode( ACTIVATE_MODE_GRABFOCUS );
      83                 :       2130 : }
      84                 :            : 
      85                 :            : // -----------------------------------------------------------------------
      86                 :            : 
      87                 :          0 : void WorkWindow::ImplInit( Window* pParent, WinBits nStyle, const ::com::sun::star::uno::Any& aSystemWorkWindowToken )
      88                 :            : {
      89         [ #  # ]:          0 :     if( aSystemWorkWindowToken.hasValue() )
      90                 :            :     {
      91         [ #  # ]:          0 :         ::com::sun::star::uno::Sequence< sal_Int8 > aSeq;
      92         [ #  # ]:          0 :         aSystemWorkWindowToken >>= aSeq;
      93         [ #  # ]:          0 :         SystemParentData* pData = (SystemParentData*)aSeq.getArray();
      94                 :            :         DBG_ASSERT( aSeq.getLength() == sizeof( SystemParentData ) && pData->nSize == sizeof( SystemParentData ), "WorkWindow::WorkWindow( Window*, const Any&, WinBits ) called with invalid Any" );
      95                 :            :         // init with style 0 as does WorkWindow::WorkWindow( SystemParentData* );
      96 [ #  # ][ #  # ]:          0 :         ImplInit( pParent, 0, pData );
      97                 :            :     }
      98                 :            :     else
      99                 :          0 :         ImplInit( pParent, nStyle, NULL );
     100                 :          0 : }
     101                 :            : 
     102                 :            : // -----------------------------------------------------------------------
     103                 :            : 
     104                 :          0 : WorkWindow::WorkWindow( WindowType nType ) :
     105                 :          0 :     SystemWindow( nType )
     106                 :            : {
     107                 :          0 :     ImplInitWorkWindowData();
     108                 :          0 : }
     109                 :            : 
     110                 :            : #ifdef ANDROID
     111                 :            : 
     112                 :            : extern "C" void *
     113                 :            : createWindowFoo(void)
     114                 :            : {
     115                 :            :     return (void*) new WorkWindow((Window *)NULL);
     116                 :            : }
     117                 :            : 
     118                 :            : #endif
     119                 :            : 
     120                 :            : // -----------------------------------------------------------------------
     121                 :            : 
     122                 :       2130 : WorkWindow::WorkWindow( Window* pParent, WinBits nStyle ) :
     123                 :       2130 :     SystemWindow( WINDOW_WORKWINDOW )
     124                 :            : {
     125                 :       2130 :     ImplInitWorkWindowData();
     126         [ +  - ]:       2130 :     ImplInit( pParent, nStyle, NULL );
     127                 :       2130 : }
     128                 :            : 
     129                 :            : // -----------------------------------------------------------------------
     130                 :            : 
     131                 :          0 : WorkWindow::WorkWindow( Window* pParent, const ResId& rResId ) :
     132                 :          0 :     SystemWindow( WINDOW_WORKWINDOW )
     133                 :            : {
     134                 :          0 :     ImplInitWorkWindowData();
     135                 :          0 :     rResId.SetRT( RSC_WORKWIN );
     136         [ #  # ]:          0 :     WinBits nStyle = ImplInitRes( rResId );
     137         [ #  # ]:          0 :     ImplInit( pParent, nStyle );
     138         [ #  # ]:          0 :     ImplLoadRes( rResId );
     139                 :          0 : }
     140                 :            : 
     141                 :            : // -----------------------------------------------------------------------
     142                 :            : 
     143                 :          0 : WorkWindow::WorkWindow( Window* pParent, const ::com::sun::star::uno::Any& aSystemWorkWindowToken, WinBits nStyle ) :
     144                 :          0 :     SystemWindow( WINDOW_WORKWINDOW )
     145                 :            : {
     146                 :          0 :     ImplInitWorkWindowData();
     147                 :          0 :     mbSysChild = sal_True;
     148         [ #  # ]:          0 :     ImplInit( pParent, nStyle, aSystemWorkWindowToken );
     149                 :          0 : }
     150                 :            : 
     151                 :            : // -----------------------------------------------------------------------
     152                 :            : 
     153                 :          0 : WorkWindow::WorkWindow( SystemParentData* pParent ) :
     154                 :          0 :     SystemWindow( WINDOW_WORKWINDOW )
     155                 :            : {
     156                 :          0 :     ImplInitWorkWindowData();
     157                 :          0 :     mbSysChild = sal_True;
     158         [ #  # ]:          0 :     ImplInit( NULL, 0, pParent );
     159                 :          0 : }
     160                 :            : 
     161                 :            : // -----------------------------------------------------------------------
     162                 :            : 
     163                 :          0 : void WorkWindow::ImplLoadRes( const ResId& rResId )
     164                 :            : {
     165                 :          0 :     SystemWindow::ImplLoadRes( rResId );
     166                 :            : 
     167                 :          0 :     ReadLongRes();
     168 [ #  # ][ #  # ]:          0 :     if ( !(rResId.GetWinBits() & WB_HIDE) && (RSC_WORKWIN == rResId.GetRT()) )
                 [ #  # ]
     169                 :          0 :         Show();
     170                 :          0 : }
     171                 :            : 
     172                 :            : // -----------------------------------------------------------------------
     173                 :            : 
     174                 :       1948 : WorkWindow::~WorkWindow()
     175                 :            : {
     176         [ +  - ]:       1948 :     ImplSVData* pSVData = ImplGetSVData();
     177         [ -  + ]:       1948 :     if ( pSVData->maWinData.mpAppWin == this )
     178                 :            :     {
     179                 :          0 :         pSVData->maWinData.mpAppWin = NULL;
     180         [ #  # ]:          0 :         Application::Quit();
     181                 :            :     }
     182         [ -  + ]:       3894 : }
     183                 :            : 
     184                 :            : // -----------------------------------------------------------------------
     185                 :            : 
     186                 :          0 : void WorkWindow::ShowFullScreenMode( sal_Bool bFullScreenMode, sal_Int32 nDisplayScreen )
     187                 :            : {
     188         [ #  # ]:          0 :     if ( !mbFullScreenMode == !bFullScreenMode )
     189                 :          0 :         return;
     190                 :            : 
     191   [ #  #  #  # ]:          0 :     if( (nDisplayScreen < 0)
                 [ #  # ]
     192                 :          0 :     || (nDisplayScreen >= static_cast<sal_Int32>(Application::GetScreenCount()) ) )
     193                 :            :     {
     194                 :          0 :         nDisplayScreen = GetScreenNumber();
     195                 :            :     }
     196                 :            : 
     197                 :          0 :     mbFullScreenMode = bFullScreenMode != 0;
     198         [ #  # ]:          0 :     if ( !mbSysChild )
     199                 :            :     {
     200                 :            :         // Dispose of the canvas implementation, which might rely on
     201                 :            :         // screen-specific system data.
     202         [ #  # ]:          0 :         com::sun::star::uno::Reference< com::sun::star::rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas );
     203         [ #  # ]:          0 :         if( xCanvas.is() )
     204                 :            :         {
     205                 :            :             com::sun::star::uno::Reference< com::sun::star::lang::XComponent >
     206                 :            :                 xCanvasComponent( xCanvas,
     207         [ #  # ]:          0 :                                   com::sun::star::uno::UNO_QUERY );
     208         [ #  # ]:          0 :             if( xCanvasComponent.is() )
     209 [ #  # ][ #  # ]:          0 :                 xCanvasComponent->dispose();
     210                 :            :         }
     211                 :            : 
     212                 :          0 :         mpWindowImpl->mpFrameWindow->mpWindowImpl->mbWaitSystemResize = sal_True;
     213 [ #  # ][ #  # ]:          0 :         ImplGetFrame()->ShowFullScreen( bFullScreenMode, nDisplayScreen );
     214                 :            :     }
     215                 :            : }
     216                 :            : 
     217                 :            : // -----------------------------------------------------------------------
     218                 :            : 
     219                 :          0 : void WorkWindow::StartPresentationMode( sal_Bool bPresentation, sal_uInt16 nFlags, sal_Int32 nDisplayScreen )
     220                 :            : {
     221         [ #  # ]:          0 :     if ( !bPresentation == !mbPresentationMode )
     222                 :          0 :         return;
     223                 :            : 
     224         [ #  # ]:          0 :     if ( bPresentation )
     225                 :            :     {
     226                 :          0 :         mbPresentationMode      = sal_True;
     227                 :          0 :         mbPresentationVisible   = IsVisible();
     228                 :          0 :         mbPresentationFull      = mbFullScreenMode;
     229                 :          0 :         mnPresentationFlags     = nFlags;
     230                 :            : 
     231         [ #  # ]:          0 :         if ( !(mnPresentationFlags & PRESENTATION_NOFULLSCREEN) )
     232                 :          0 :             ShowFullScreenMode( sal_True, nDisplayScreen );
     233         [ #  # ]:          0 :         if ( !mbSysChild )
     234                 :            :         {
     235         [ #  # ]:          0 :             if ( mnPresentationFlags & PRESENTATION_HIDEALLAPPS )
     236                 :          0 :                 mpWindowImpl->mpFrame->SetAlwaysOnTop( sal_True );
     237         [ #  # ]:          0 :             if ( !(mnPresentationFlags & PRESENTATION_NOAUTOSHOW) )
     238                 :          0 :                 ToTop();
     239                 :          0 :             mpWindowImpl->mpFrame->StartPresentation( sal_True );
     240                 :            :         }
     241                 :            : 
     242         [ #  # ]:          0 :         if ( !(mnPresentationFlags & PRESENTATION_NOAUTOSHOW) )
     243                 :          0 :             Show();
     244                 :            :     }
     245                 :            :     else
     246                 :            :     {
     247                 :          0 :         Show( mbPresentationVisible );
     248         [ #  # ]:          0 :         if ( !mbSysChild )
     249                 :            :         {
     250                 :          0 :             mpWindowImpl->mpFrame->StartPresentation( sal_False );
     251         [ #  # ]:          0 :             if ( mnPresentationFlags & PRESENTATION_HIDEALLAPPS )
     252                 :          0 :                 mpWindowImpl->mpFrame->SetAlwaysOnTop( sal_False );
     253                 :            :         }
     254                 :          0 :         ShowFullScreenMode( mbPresentationFull, nDisplayScreen );
     255                 :            : 
     256                 :          0 :         mbPresentationMode      = sal_False;
     257                 :          0 :         mbPresentationVisible   = sal_False;
     258                 :          0 :         mbPresentationFull      = sal_False;
     259                 :          0 :         mnPresentationFlags     = 0;
     260                 :            :     }
     261                 :            : }
     262                 :            : 
     263                 :            : // -----------------------------------------------------------------------
     264                 :            : 
     265                 :       3393 : sal_Bool WorkWindow::IsMinimized() const
     266                 :            : {
     267                 :            :     //return mpWindowImpl->mpFrameData->mbMinimized;
     268                 :            :     SalFrameState aState;
     269         [ +  - ]:       3393 :     mpWindowImpl->mpFrame->GetWindowState(&aState);
     270                 :       3393 :     return (( aState.mnState & SAL_FRAMESTATE_MINIMIZED ) != 0);
     271                 :            : }
     272                 :            : 
     273                 :            : // -----------------------------------------------------------------------
     274                 :            : 
     275                 :          0 : sal_Bool WorkWindow::SetPluginParent( SystemParentData* pParent )
     276                 :            : {
     277                 :            :     DBG_ASSERT( ! mbPresentationMode && ! mbFullScreenMode, "SetPluginParent in fullscreen or presentation mode !" );
     278                 :            : 
     279                 :          0 :     bool bWasDnd = Window::ImplStopDnd();
     280                 :            : 
     281                 :          0 :     sal_Bool bShown = IsVisible();
     282                 :          0 :     Show( sal_False );
     283                 :          0 :     sal_Bool bRet = mpWindowImpl->mpFrame->SetPluginParent( pParent );
     284                 :          0 :     Show( bShown );
     285                 :            : 
     286         [ #  # ]:          0 :     if( bWasDnd )
     287                 :          0 :         Window::ImplStartDnd();
     288                 :            : 
     289                 :          0 :     return bRet;
     290                 :            : }
     291                 :            : 
     292                 :          0 : void WorkWindow::ImplSetFrameState( sal_uLong aFrameState )
     293                 :            : {
     294                 :            :     SalFrameState   aState;
     295                 :          0 :     aState.mnMask   = SAL_FRAMESTATE_MASK_STATE;
     296                 :          0 :     aState.mnState  = aFrameState;
     297         [ #  # ]:          0 :     mpWindowImpl->mpFrame->SetWindowState( &aState );
     298                 :          0 : }
     299                 :            : 
     300                 :            : 
     301                 :          0 : void WorkWindow::Minimize()
     302                 :            : {
     303                 :          0 :     ImplSetFrameState( SAL_FRAMESTATE_MINIMIZED );
     304                 :          0 : }
     305                 :            : 
     306                 :          0 : void WorkWindow::Restore()
     307                 :            : {
     308                 :          0 :     ImplSetFrameState( SAL_FRAMESTATE_NORMAL );
     309                 :          0 : }
     310                 :            : 
     311                 :          0 : sal_Bool WorkWindow::Close()
     312                 :            : {
     313                 :          0 :     sal_Bool bCanClose = SystemWindow::Close();
     314                 :            : 
     315                 :            :     // Ist es das Applikationsfenster, dann beende die Applikation
     316 [ #  # ][ #  # ]:          0 :     if ( bCanClose && ( ImplGetSVData()->maWinData.mpAppWin == this ) )
                 [ #  # ]
     317                 :          0 :         GetpApp()->Quit();
     318                 :            : 
     319                 :          0 :     return bCanClose;
     320                 :            : }
     321                 :            : 
     322                 :          0 : void WorkWindow::Maximize( sal_Bool bMaximize )
     323                 :            : {
     324         [ #  # ]:          0 :     ImplSetFrameState( bMaximize ? SAL_FRAMESTATE_MAXIMIZED : SAL_FRAMESTATE_NORMAL );
     325                 :          0 : }
     326                 :            : 
     327                 :          0 : sal_Bool WorkWindow::IsMaximized() const
     328                 :            : {
     329                 :          0 :     sal_Bool bRet = sal_False;
     330                 :            : 
     331                 :            :     SalFrameState aState;
     332 [ #  # ][ #  # ]:          0 :     if( mpWindowImpl->mpFrame->GetWindowState( &aState ) )
     333                 :            :     {
     334         [ #  # ]:          0 :         if( aState.mnState & (SAL_FRAMESTATE_MAXIMIZED          |
     335                 :            :                               SAL_FRAMESTATE_MAXIMIZED_HORZ     |
     336                 :            :                               SAL_FRAMESTATE_MAXIMIZED_VERT ) )
     337                 :          0 :             bRet = sal_True;
     338                 :            :     }
     339                 :          0 :     return bRet;
     340                 :            : }
     341                 :            : 
     342                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10