xref: /aoo41x/main/rsc/source/misc/rscdbl.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_rsc.hxx"
30 
31 #include <stdio.h>
32 #include <rscdb.hxx>
33 #include <rscall.h>
34 #include <rschash.hxx>
35 #include <rsctree.hxx>
36 #include <rsctop.hxx>
37 #include "rsclst.hxx"
38 
39 /*************************************************************************
40 |*
41 |*	  RscTypCont::FillNameIdList()
42 |*
43 |*	  Beschreibung
44 |*	  Ersterstellung	MM 07.05.91
45 |*	  Letzte Aenderung	MM 30.05.91
46 |*
47 *************************************************************************/
48 REResourceList * InsertList( Atom nClassName, const RscId& rId,
49 							 REResourceList * pList ){
50 	REResourceList	*	pSubList;
51 	const char *				pStrClass;
52 	ByteString			aStrClass;
53 
54 	pStrClass = pHS->getString( nClassName ).getStr();
55 	if( pStrClass )
56 		aStrClass = pStrClass;
57 	else
58 		aStrClass = ByteString::CreateFromInt32( (long)nClassName );
59 
60 	pSubList = new REResourceList( pList, aStrClass, rId );
61 
62 	pList->Insert( pSubList, 0xFFFFFFFF );
63 	return( pSubList );
64 }
65 
66 void FillSubList( RSCINST & rInst, REResourceList * pList )
67 {
68 	sal_uInt32		nCount, i;
69 	SUBINFO_STRUCT	aInfo;
70 	REResourceList* pSubList;
71 	RSCINST 		aTmpI;
72 
73 	nCount = rInst.pClass->GetCount( rInst );
74 	for( i = 0; i < nCount; i++ ){
75 		aInfo = rInst.pClass->GetInfoEle( rInst, i );
76 		aTmpI = rInst.pClass->GetPosEle( rInst, i );
77 		pSubList = InsertList( aInfo.pClass->GetId(),
78 							   aInfo.aId, pList );
79 		FillSubList( aTmpI, pSubList );
80 	};
81 }
82 
83 void FillListObj( ObjNode * pObjNode, RscTop * pRscTop,
84 				  REResourceList * pList, sal_uLong lFileKey )
85 {
86 	if( pObjNode ){
87 		if( pObjNode->GetFileKey() == lFileKey ){
88 			RSCINST 		aTmpI;
89 			REResourceList* pSubList;
90 
91 			FillListObj( (ObjNode*)pObjNode->Left(), pRscTop,
92 						 pList, lFileKey );
93 
94 			pSubList = InsertList( pRscTop->GetId(),
95 								   pObjNode->GetRscId(), pList );
96 
97 			aTmpI.pClass = pRscTop;
98 			aTmpI.pData = pObjNode->GetRscObj();
99 			FillSubList( aTmpI, pSubList );
100 
101 			FillListObj( (ObjNode*)pObjNode->Right(), pRscTop,
102 						 pList, lFileKey );
103 		}
104 	};
105 }
106 
107 void FillList( RscTop * pRscTop, REResourceList * pList, sal_uLong lFileKey ){
108 	if( pRscTop ){
109 		FillList( (RscTop*)pRscTop->Left(), pList, lFileKey );
110 
111 		FillListObj( pRscTop->GetObjNode(), pRscTop, pList, lFileKey );
112 
113 		FillList( (RscTop*)pRscTop->Right(), pList, lFileKey );
114 	};
115 }
116 
117 void RscTypCont::FillNameIdList( REResourceList * pList, sal_uLong lFileKey ){
118 	FillList( pRoot, pList, lFileKey );
119 }
120