Branch data 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 : : /****************** I N C L U D E S **************************************/
21 : :
22 : : // C and C++ Includes.
23 : :
24 : : // Solar Definitionen
25 : : #include <tools/solar.h>
26 : :
27 : : // Programmabhaengige Includes.
28 : : #include <rscclobj.hxx>
29 : : #include <rsctop.hxx>
30 : :
31 : : /****************** C O D E **********************************************/
32 : :
33 : : /****************** R e f N o d e ****************************************/
34 : : /*************************************************************************
35 : : |*
36 : : |* RefNode::RefNode()
37 : : |*
38 : : *************************************************************************/
39 : 387360 : RefNode::RefNode( Atom nTyp ){
40 : 387360 : pObjBiTree = 0;
41 : 387360 : nTypNameId = nTyp;
42 : 387360 : }
43 : :
44 : : /*************************************************************************
45 : : |*
46 : : |* RefNode::GetId()
47 : : |*
48 : : *************************************************************************/
49 : 2972414 : sal_uInt32 RefNode::GetId() const
50 : : {
51 : 2972414 : return( nTypNameId );
52 : : }
53 : :
54 : : /*************************************************************************
55 : : |*
56 : : |* RefNode::PutObjNode()
57 : : |*
58 : : *************************************************************************/
59 : 36744 : sal_Bool RefNode::PutObjNode( ObjNode * pPutObject ){
60 : : // insert a node in the b-tree pObjBiTree
61 : : // if the node with the same name is in pObjBiTree,
62 : : // return sal_False and no insert,
63 : :
64 [ + + ]: 36744 : if( pObjBiTree )
65 : 33858 : return( pObjBiTree->Insert( pPutObject ) );
66 : :
67 : 2886 : pObjBiTree = pPutObject;
68 : 36744 : return( sal_True );
69 : : }
70 : :
71 : : /****************** O b j N o d e ****************************************/
72 : : /*************************************************************************
73 : : |*
74 : : |* RefNode::GetObjNode()
75 : : |*
76 : : *************************************************************************/
77 : 60 : ObjNode * RefNode :: GetObjNode( const RscId & rRscId ){
78 : : // insert a node in the b-tree pObjBiTree
79 : : // if the node with the same name is in pObjBiTree,
80 : : // return NULL and no insert,
81 : : // if not return the pointer to the Object
82 : :
83 [ + + ]: 60 : if( pObjBiTree )
84 : 44 : return( pObjBiTree->Search( rRscId ) );
85 : 60 : return( NULL );
86 : : }
87 : :
88 : : /*************************************************************************
89 : : |*
90 : : |* ObjNode::ObjNode()
91 : : |*
92 : : *************************************************************************/
93 : 36744 : ObjNode::ObjNode( const RscId & rId, CLASS_DATA pData, sal_uLong lKey ){
94 : 36744 : pRscObj = pData;
95 [ + - ]: 36744 : aRscId = rId;
96 : 36744 : lFileKey = lKey;
97 : 36744 : }
98 : :
99 : : /*************************************************************************
100 : : |*
101 : : |* ObjNode::DelObjNode()
102 : : |*
103 : : *************************************************************************/
104 : 0 : ObjNode * ObjNode::DelObjNode( RscTop * pClass, sal_uLong nFileKey ){
105 : 0 : ObjNode * pRetNode = this;
106 : :
107 [ # # ]: 0 : if( Right() )
108 : 0 : pRight = ((ObjNode *)Right())->DelObjNode( pClass, nFileKey );
109 [ # # ]: 0 : if( Left() )
110 : 0 : pLeft = ((ObjNode *)Left())->DelObjNode( pClass, nFileKey );
111 : :
112 [ # # ]: 0 : if( GetFileKey() == nFileKey ){
113 [ # # ]: 0 : if( GetRscObj() ){
114 [ # # ]: 0 : pClass->Destroy( RSCINST( pClass, GetRscObj() ) );
115 : 0 : rtl_freeMemory( GetRscObj() );
116 : : }
117 : 0 : pRetNode = (ObjNode *)Right();
118 [ # # ]: 0 : if( pRetNode ){
119 [ # # ]: 0 : if( Left() )
120 : 0 : pRetNode->Insert( (ObjNode *)Left() );
121 : : }
122 : : else
123 : 0 : pRetNode = (ObjNode *)Left();
124 [ # # ]: 0 : delete this;
125 : : }
126 : 0 : return pRetNode;
127 : : }
128 : :
129 : : /*************************************************************************
130 : : |*
131 : : |* ObjNode::GetId()
132 : : |*
133 : : *************************************************************************/
134 : 875866 : sal_uInt32 ObjNode::GetId() const
135 : : {
136 : 875866 : return( (sal_uInt32)(long)aRscId );
137 : : }
138 : :
139 : : /*************************************************************************
140 : : |*
141 : : |* ObjNode::IsConsistent()
142 : : |*
143 : : *************************************************************************/
144 : 0 : sal_Bool ObjNode::IsConsistent()
145 : : {
146 : 0 : sal_Bool bRet = sal_True;
147 : :
148 [ # # ][ # # ]: 0 : if( (long)aRscId > 0x7FFF || (long)aRscId < 1 )
[ # # ]
149 : : {
150 : 0 : bRet = sal_False;
151 : : }
152 : : else
153 : : {
154 [ # # ]: 0 : if( Left() )
155 : : {
156 [ # # ]: 0 : if( !((ObjNode *)Left())->IsConsistent() )
157 : 0 : bRet = sal_False;
158 [ # # ]: 0 : if( ((ObjNode *)Left())->aRscId >= aRscId )
159 : : {
160 : 0 : bRet = sal_False;
161 : : }
162 : : };
163 [ # # ]: 0 : if( Right() )
164 : : {
165 [ # # ]: 0 : if( ((ObjNode *)Right())->aRscId <= aRscId )
166 : : {
167 : 0 : bRet = sal_False;
168 : : }
169 [ # # ]: 0 : if( !((ObjNode *)Right())->IsConsistent() )
170 : 0 : bRet = sal_False;
171 : : };
172 : : };
173 : :
174 : 0 : return( bRet );
175 : : }
176 : :
177 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|