xref: /trunk/main/tools/source/rc/resary.cxx (revision 89b56da7)
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_RESARY_CXX
28 #include <tools/resary.hxx>
29 #include <tools/rcid.h>
30 
31 // =======================================================================
32 
ResStringArray(const ResId & rResId)33 ResStringArray::ResStringArray( const ResId& rResId )
34 {
35     rResId.SetRT( RSC_STRINGARRAY );
36     ResMgr* pMgr = rResId.GetResMgr();
37     if( pMgr && pMgr->GetResource( rResId ) )
38     {
39         pMgr->GetClass();
40         pMgr->Increment( sizeof( RSHEADER_TYPE ) );
41         const sal_uInt32 nItems = pMgr->ReadLong();
42         if ( nItems )
43         {
44             m_aStrings.reserve( nItems );
45             for ( sal_uInt32 i = 0; i < nItems; i++ )
46             {
47                 // load string
48                 m_aStrings.push_back( ImplResStringItem( pMgr->ReadString() ) );
49 
50                 // load value
51                 m_aStrings[i].m_nValue = pMgr->ReadLong();
52             }
53         }
54     }
55 }
56 
57 // -----------------------------------------------------------------------
58 
~ResStringArray()59 ResStringArray::~ResStringArray()
60 {
61 }
62 
63 // -----------------------------------------------------------------------
64 
FindIndex(long nValue) const65 sal_uInt32 ResStringArray::FindIndex( long nValue ) const
66 {
67     const sal_uInt32 nItems = m_aStrings.size();
68 	for ( sal_uInt32 i = 0; i < nItems; i++ )
69 	{
70 		if ( m_aStrings[i].m_nValue == nValue )
71 			return i;
72 	}
73 	return RESARRAY_INDEX_NOTFOUND;
74 }
75