1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <tools/date.hxx>
23 #include <tools/time.hxx>
24 #include <tools/rc.hxx>
25 #include <tools/rcid.h>
27 Resource::Resource( const ResId
& rResId
)
29 GetRes( rResId
.SetRT( RSC_RESOURCE
) );
32 void Resource::GetRes( const ResId
& rResId
)
34 if( rResId
.GetResMgr() )
35 m_pResMgr
= rResId
.GetResMgr();
36 m_pResMgr
->GetResource( rResId
, this );
37 IncrementRes( sizeof( RSHEADER_TYPE
) );
40 Time::Time( const ResId
& rResId
)
43 rResId
.SetRT( RSC_TIME
);
44 ResMgr
* pResMgr
= NULL
;
46 ResMgr::GetResourceSkipHeader( rResId
, &pResMgr
);
48 sal_uIntPtr nObjMask
= (sal_uInt16
)pResMgr
->ReadLong();
50 if ( 0x01 & nObjMask
)
51 SetHour( (sal_uInt16
)pResMgr
->ReadShort() );
52 if ( 0x02 & nObjMask
)
53 SetMin( (sal_uInt16
)pResMgr
->ReadShort() );
54 if ( 0x04 & nObjMask
)
55 SetSec( (sal_uInt16
)pResMgr
->ReadShort() );
56 if ( 0x08 & nObjMask
)
57 // TODO: when we change the place that writes this binary resource format to match:
58 // SetNanoSec( pResMgr->ReadLong() );
60 SetNanoSec( pResMgr
->ReadShort() * ::Time::nanoPerCenti
);
63 Date::Date( const ResId
& rResId
) : nDate(0)
65 rResId
.SetRT( RSC_DATE
);
66 ResMgr
* pResMgr
= NULL
;
68 ResMgr::GetResourceSkipHeader( rResId
, &pResMgr
);
70 sal_uIntPtr nObjMask
= (sal_uInt16
)pResMgr
->ReadLong();
72 if ( 0x01 & nObjMask
)
73 SetYear( (sal_uInt16
)pResMgr
->ReadShort() );
74 if ( 0x02 & nObjMask
)
75 SetMonth( (sal_uInt16
)pResMgr
->ReadShort() );
76 if ( 0x04 & nObjMask
)
77 SetDay( (sal_uInt16
)pResMgr
->ReadShort() );
80 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */