LCOV - code coverage report
Current view: top level - vcl/source/window - resource.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 69 79 87.3 %
Date: 2014-11-03 Functions: 6 6 100.0 %
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/rc.h>
      21             : 
      22             : #include <vcl/window.hxx>
      23             : #include <vcl/svapp.hxx>
      24             : 
      25             : #include "window.h"
      26             : 
      27       10002 : static OString ImplAutoHelpID( ResMgr* pResMgr )
      28             : {
      29       10002 :     OString aRet;
      30             : 
      31       10002 :     if( pResMgr && Application::IsAutoHelpIdEnabled() )
      32       10002 :         aRet = pResMgr->GetAutoHelpId();
      33             : 
      34       10002 :     return aRet;
      35             : }
      36             : 
      37             : namespace vcl {
      38             : 
      39       10002 : WinBits Window::ImplInitRes( const ResId& rResId )
      40             : {
      41       10002 :     GetRes( rResId );
      42             : 
      43       10002 :     char* pRes = (char*)GetClassRes();
      44       10002 :     pRes += 8;
      45       10002 :     sal_uInt32 nStyle = (sal_uInt32)GetLongRes( (void*)pRes );
      46       10002 :     rResId.SetWinBits( nStyle );
      47       10002 :     return nStyle;
      48             : }
      49             : 
      50       10002 : WindowResHeader Window::ImplLoadResHeader( const ResId& rResId )
      51             : {
      52       10002 :     WindowResHeader aHeader;
      53             : 
      54       10002 :     aHeader.nObjMask = ReadLongRes();
      55             : 
      56             :     // we need to calculate auto helpids before the resource gets closed
      57             :     // if the resource  only contains flags, it will be closed before we try to read a help id
      58             :     // so we always create an auto help id that might be overwritten later
      59             :     // HelpId
      60       10002 :     aHeader.aHelpId = ImplAutoHelpID( rResId.GetResMgr() );
      61             : 
      62             :     // ResourceStyle
      63       10002 :     aHeader.nRSStyle = ReadLongRes();
      64             :     // WinBits
      65       10002 :     ReadLongRes();
      66             : 
      67       10002 :     if( aHeader.nObjMask & WINDOW_HELPID )
      68        2058 :         aHeader.aHelpId = ReadByteStringRes();
      69             : 
      70       10002 :     return aHeader;
      71             : }
      72             : 
      73       10002 : void Window::ImplLoadRes( const ResId& rResId )
      74             : {
      75       10002 :     WindowResHeader aHeader = ImplLoadResHeader( rResId );
      76             : 
      77       10002 :     SetHelpId( aHeader.aHelpId );
      78             : 
      79       10002 :     sal_uLong nObjMask = aHeader.nObjMask;
      80             : 
      81       10002 :     bool  bPos  = false;
      82       10002 :     bool  bSize = false;
      83       10002 :     Point aPos;
      84       10002 :     Size  aSize;
      85             : 
      86       10002 :     if ( nObjMask & (WINDOW_XYMAPMODE | WINDOW_X | WINDOW_Y) )
      87             :     {
      88             :         // use size as per resource
      89        4716 :         MapUnit ePosMap = MAP_PIXEL;
      90             : 
      91        4716 :         bPos = true;
      92             : 
      93        4716 :         if ( nObjMask & WINDOW_XYMAPMODE )
      94        4716 :             ePosMap = (MapUnit)ReadLongRes();
      95        4716 :         if ( nObjMask & WINDOW_X )
      96        4716 :             aPos.X() = ImplLogicUnitToPixelX( ReadLongRes(), ePosMap );
      97        4716 :         if ( nObjMask & WINDOW_Y )
      98        4716 :             aPos.Y() = ImplLogicUnitToPixelY( ReadLongRes(), ePosMap );
      99             :     }
     100             : 
     101       10002 :     if ( nObjMask & (WINDOW_WHMAPMODE | WINDOW_WIDTH | WINDOW_HEIGHT) )
     102             :     {
     103             :         // use size as per resource
     104        6256 :         MapUnit eSizeMap = MAP_PIXEL;
     105             : 
     106        6256 :         bSize = true;
     107             : 
     108        6256 :         if ( nObjMask & WINDOW_WHMAPMODE )
     109        6256 :             eSizeMap = (MapUnit)ReadLongRes();
     110        6256 :         if ( nObjMask & WINDOW_WIDTH )
     111        6256 :             aSize.Width() = ImplLogicUnitToPixelX( ReadLongRes(), eSizeMap );
     112        6256 :         if ( nObjMask & WINDOW_HEIGHT )
     113        6256 :             aSize.Height() = ImplLogicUnitToPixelY( ReadLongRes(), eSizeMap );
     114             :     }
     115             : 
     116       10002 :     sal_uLong nRSStyle = aHeader.nRSStyle;
     117             : 
     118             :     // looks bad due to optimization
     119       10002 :     if ( nRSStyle & RSWND_CLIENTSIZE )
     120             :     {
     121         196 :         if ( bPos )
     122           0 :             SetPosPixel( aPos );
     123         196 :         if ( bSize )
     124         196 :             SetOutputSizePixel( aSize );
     125             :     }
     126        9806 :     else if ( bPos && bSize )
     127        4716 :         SetPosSizePixel( aPos, aSize );
     128        5090 :     else if ( bPos )
     129           0 :         SetPosPixel( aPos );
     130        5090 :     else if ( bSize )
     131        1344 :         SetSizePixel( aSize );
     132             : 
     133       10002 :     if ( nRSStyle & RSWND_DISABLED )
     134           0 :         Enable( false );
     135             : 
     136       10002 :     if ( nObjMask & WINDOW_TEXT )
     137        4006 :         SetText( ReadStringRes() );
     138       10002 :     if ( nObjMask & WINDOW_HELPTEXT )
     139             :     {
     140           0 :         SetHelpText( ReadStringRes() );
     141           0 :         mpWindowImpl->mbHelpTextDynamic = true;
     142             :     }
     143       10002 :     if ( nObjMask & WINDOW_QUICKTEXT )
     144           2 :         SetQuickHelpText( ReadStringRes() );
     145       10002 :     if ( nObjMask & WINDOW_EXTRALONG )
     146             :     {
     147           0 :         sal_uIntPtr nRes = ReadLongRes();
     148           0 :         SetData( reinterpret_cast<void*>(nRes) );
     149             :     }
     150       10002 :     if ( nObjMask & WINDOW_UNIQUEID )
     151           0 :         SetUniqueId( ReadByteStringRes() );
     152             : 
     153       10002 :     if ( nObjMask & WINDOW_BORDER_STYLE )
     154             :     {
     155           0 :         sal_uInt16 nBorderStyle = (sal_uInt16)ReadLongRes();
     156           0 :         SetBorderStyle( static_cast<WindowBorderStyle>(nBorderStyle) );
     157       10002 :     }
     158       10002 : }
     159             : 
     160        1233 : } /* namespace vcl */
     161             : 

Generated by: LCOV version 1.10