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

Generated by: LCOV version 1.10