xref: /aoo4110/main/tools/source/rc/rc.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_tools.hxx"
26 
27 #define _TOOLS_RC_CXX
28 
29 #include <string.h>
30 #include <tools/date.hxx>
31 #include <tools/time.hxx>
32 #include <tools/rc.hxx>
33 #include <tools/rcid.h>
34 
35 // =======================================================================
36 
Resource(const ResId & rResId)37 Resource::Resource( const ResId& rResId )
38 {
39     GetRes( rResId.SetRT( RSC_RESOURCE ) );
40 }
41 
42 // -----------------------------------------------------------------------
43 
GetRes(const ResId & rResId)44 void Resource::GetRes( const ResId& rResId )
45 {
46     if( rResId.GetResMgr() )
47         m_pResMgr = rResId.GetResMgr();
48     m_pResMgr->GetResource( rResId, this );
49     IncrementRes( sizeof( RSHEADER_TYPE ) );
50 }
51 
52 // -----------------------------------------------------------------------
53 
54 // =======================================================================
55 
Time(const ResId & rResId)56 Time::Time( const ResId& rResId )
57 {
58     nTime = 0;
59     rResId.SetRT( RSC_TIME );
60     ResMgr* pResMgr = NULL;
61 
62     ResMgr::GetResourceSkipHeader( rResId, &pResMgr );
63 
64     sal_uIntPtr nObjMask = (sal_uInt16)pResMgr->ReadLong();
65 
66     if ( 0x01 & nObjMask )
67         SetHour( (sal_uInt16)pResMgr->ReadShort() );
68     if ( 0x02 & nObjMask )
69         SetMin( (sal_uInt16)pResMgr->ReadShort() );
70     if ( 0x04 & nObjMask )
71         SetSec( (sal_uInt16)pResMgr->ReadShort() );
72     if ( 0x08 & nObjMask )
73         Set100Sec( (sal_uInt16)pResMgr->ReadShort() );
74 }
75 
76 // =======================================================================
77 
Date(const ResId & rResId)78 Date::Date( const ResId& rResId ) : nDate(0)
79 {
80     rResId.SetRT( RSC_DATE );
81     ResMgr* pResMgr = NULL;
82 
83     ResMgr::GetResourceSkipHeader( rResId, &pResMgr );
84 
85     sal_uIntPtr nObjMask = (sal_uInt16)pResMgr->ReadLong();
86 
87     if ( 0x01 & nObjMask )
88         SetYear( (sal_uInt16)pResMgr->ReadShort() );
89     if ( 0x02 & nObjMask )
90         SetMonth( (sal_uInt16)pResMgr->ReadShort() );
91     if ( 0x04 & nObjMask )
92         SetDay( (sal_uInt16)pResMgr->ReadShort() );
93 }
94