LCOV - code coverage report
Current view: top level - tools/source/rc - rc.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 24 55 43.6 %
Date: 2014-11-03 Functions: 3 5 60.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 <string.h>
      21             : #include <rtl/ustrbuf.hxx>
      22             : #include <tools/date.hxx>
      23             : #include <tools/time.hxx>
      24             : #include <tools/rc.hxx>
      25             : #include <tools/rcid.h>
      26             : 
      27       39182 : Resource::Resource( const ResId& rResId )
      28       39182 :     : m_pResMgr(NULL)
      29             : {
      30       39182 :     GetRes( rResId.SetRT( RSC_RESOURCE ) );
      31       39182 : }
      32             : 
      33       73665 : void Resource::GetRes( const ResId& rResId )
      34             : {
      35       73665 :     if( rResId.GetResMgr() )
      36       73665 :         m_pResMgr = rResId.GetResMgr();
      37             :     assert(m_pResMgr);
      38       73665 :     m_pResMgr->GetResource( rResId, this );
      39       73665 :     IncrementRes( sizeof( RSHEADER_TYPE ) );
      40       73665 : }
      41             : 
      42             : namespace tools {
      43             : 
      44           0 : Time::Time( const ResId& rResId )
      45             : {
      46           0 :     nTime = 0;
      47           0 :     rResId.SetRT( RSC_TIME );
      48           0 :     ResMgr* pResMgr = NULL;
      49             : 
      50           0 :     ResMgr::GetResourceSkipHeader( rResId, &pResMgr );
      51             : 
      52           0 :     sal_uIntPtr nObjMask = (sal_uInt16)pResMgr->ReadLong();
      53             : 
      54           0 :     if ( 0x01 & nObjMask )
      55           0 :         SetHour( (sal_uInt16)pResMgr->ReadShort() );
      56           0 :     if ( 0x02 & nObjMask )
      57           0 :         SetMin( (sal_uInt16)pResMgr->ReadShort() );
      58           0 :     if ( 0x04 & nObjMask )
      59           0 :         SetSec( (sal_uInt16)pResMgr->ReadShort() );
      60           0 :     if ( 0x08 & nObjMask )
      61             :         // TODO: when we change the place that writes this binary resource format to match:
      62             :         // SetNanoSec( pResMgr->ReadLong() );
      63             :         // In the meantime:
      64           0 :         SetNanoSec( pResMgr->ReadShort() * ::tools::Time::nanoPerCenti );
      65           0 : }
      66             : 
      67             : } /* namespace tools */
      68             : 
      69           0 : Date::Date( const ResId& rResId ) : nDate(0)
      70             : {
      71           0 :     rResId.SetRT( RSC_DATE );
      72           0 :     ResMgr* pResMgr = NULL;
      73             : 
      74           0 :     ResMgr::GetResourceSkipHeader( rResId, &pResMgr );
      75             : 
      76           0 :     sal_uIntPtr nObjMask = (sal_uInt16)pResMgr->ReadLong();
      77             : 
      78           0 :     if ( 0x01 & nObjMask )
      79           0 :         SetYear( (sal_uInt16)pResMgr->ReadShort() );
      80           0 :     if ( 0x02 & nObjMask )
      81           0 :         SetMonth( (sal_uInt16)pResMgr->ReadShort() );
      82           0 :     if ( 0x04 & nObjMask )
      83           0 :         SetDay( (sal_uInt16)pResMgr->ReadShort() );
      84           0 : }
      85             : 
      86     1691857 : OUString ResId::toString() const
      87             : {
      88     1691857 :     SetRT( RSC_STRING );
      89     1691857 :     ResMgr* pResMgr = GetResMgr();
      90             : 
      91     1691857 :     if ( !pResMgr || !pResMgr->GetResource( *this ) )
      92             :     {
      93           0 :         OUString sRet;
      94             : 
      95             : #if OSL_DEBUG_LEVEL > 0
      96             :         sRet = OUStringBuffer().
      97             :             append("<resource id ").
      98             :             append(static_cast<sal_Int32>(GetId())).
      99             :             append(" not found>").
     100             :             makeStringAndClear();
     101             : #endif
     102             : 
     103           0 :         if( pResMgr )
     104           0 :             pResMgr->PopContext();
     105             : 
     106           0 :         return sRet;
     107             :     }
     108             : 
     109             :     // String loading
     110     1691857 :     RSHEADER_TYPE * pResHdr = (RSHEADER_TYPE*)pResMgr->GetClass();
     111             : 
     112     1691857 :     sal_Int32 nStringLen = rtl_str_getLength( (char*)(pResHdr+1) );
     113     1691857 :     OUString sRet((const char*)(pResHdr+1), nStringLen, RTL_TEXTENCODING_UTF8);
     114             : 
     115             :     sal_uInt32 nSize = sizeof( RSHEADER_TYPE )
     116     1691857 :         + sal::static_int_cast< sal_uInt32 >(nStringLen) + 1;
     117     1691857 :     nSize += nSize % 2;
     118     1691857 :     pResMgr->Increment( nSize );
     119             : 
     120     1691857 :     ResHookProc pImplResHookProc = ResMgr::GetReadStringHook();
     121     1691857 :     if ( pImplResHookProc )
     122      891991 :         sRet = pImplResHookProc(sRet);
     123     1691857 :     return sRet;
     124             : }
     125             : 
     126             : 
     127             : 
     128             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10