LCOV - code coverage report
Current view: top level - rsc/source/res - rscclobj.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 21 54 38.9 %
Date: 2014-11-03 Functions: 6 8 75.0 %
Legend: Lines: hit not hit

          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             : 
      21             : #include <rscclobj.hxx>
      22             : #include <rsctop.hxx>
      23             : 
      24             : 
      25       83800 : RefNode::RefNode( Atom nTyp )
      26             : {
      27       83800 :     pObjBiTree = 0;
      28       83800 :     nTypNameId = nTyp;
      29       83800 : }
      30             : 
      31      444610 : sal_uInt32 RefNode::GetId() const
      32             : {
      33      444610 :     return nTypNameId;
      34             : }
      35             : 
      36             : // insert a node in the b-tree pObjBiTree
      37             : // if the node with the same name is in pObjBiTree,
      38             : // return sal_False and no insert,
      39             : 
      40       19066 : bool RefNode::PutObjNode( ObjNode * pPutObject )
      41             : {
      42       19066 :     if( pObjBiTree )
      43       18338 :         return pObjBiTree->Insert( pPutObject );
      44             : 
      45         728 :     pObjBiTree = pPutObject;
      46         728 :     return true;
      47             : }
      48             : 
      49             : // insert a node in the b-tree pObjBiTree
      50             : // if the node with the same name is in pObjBiTree,
      51             : // return NULL and no insert,
      52             : // if not return the pointer to the Object
      53           7 : ObjNode * RefNode :: GetObjNode( const RscId & rRscId )
      54             : {
      55           7 :     if( pObjBiTree )
      56           7 :         return pObjBiTree->Search( rRscId );
      57           0 :     return NULL;
      58             : }
      59             : 
      60       19066 : ObjNode::ObjNode( const RscId & rId, CLASS_DATA pData, sal_uLong lKey )
      61             : {
      62       19066 :     pRscObj  = pData;
      63       19066 :     aRscId   = rId;
      64       19066 :     lFileKey = lKey;
      65       19066 : }
      66             : 
      67           0 : ObjNode * ObjNode::DelObjNode( RscTop * pClass, sal_uLong nFileKey )
      68             : {
      69           0 :     ObjNode * pRetNode = this;
      70             : 
      71           0 :     if( Right() )
      72           0 :         pRight = static_cast<ObjNode *>(Right())->DelObjNode( pClass, nFileKey );
      73           0 :     if( Left() )
      74           0 :         pLeft = static_cast<ObjNode *>(Left())->DelObjNode( pClass, nFileKey );
      75             : 
      76           0 :     if( GetFileKey() == nFileKey )
      77             :     {
      78           0 :         if( GetRscObj() )
      79             :         {
      80           0 :             pClass->Destroy( RSCINST( pClass, GetRscObj() ) );
      81           0 :             rtl_freeMemory( GetRscObj() );
      82             :         }
      83           0 :         pRetNode = static_cast<ObjNode *>(Right());
      84           0 :         if( pRetNode )
      85             :         {
      86           0 :             if( Left() )
      87           0 :                 pRetNode->Insert( static_cast<ObjNode *>(Left()) );
      88             :         }
      89             :         else
      90           0 :             pRetNode = static_cast<ObjNode *>(Left());
      91             : 
      92           0 :         delete this;
      93             :     }
      94           0 :     return pRetNode;
      95             : }
      96             : 
      97      500434 : sal_uInt32 ObjNode::GetId() const
      98             : {
      99      500434 :     return (sal_uInt32)(long)aRscId;
     100             : }
     101             : 
     102           0 : bool ObjNode::IsConsistent()
     103             : {
     104           0 :     bool bRet = true;
     105             : 
     106           0 :     if( (long)aRscId > 0x7FFF || (long)aRscId < 1 )
     107             :     {
     108           0 :         bRet = false;
     109             :     }
     110             :     else
     111             :     {
     112           0 :         if( Left() )
     113             :         {
     114           0 :             if( !static_cast<ObjNode *>(Left())->IsConsistent() )
     115             :             {
     116           0 :                 bRet = false;
     117             :             }
     118           0 :             if( static_cast<ObjNode *>(Left())->aRscId >= aRscId )
     119             :             {
     120           0 :                 bRet = false;
     121             :             }
     122             :         }
     123           0 :         if( Right() )
     124             :         {
     125           0 :             if( static_cast<ObjNode *>(Right())->aRscId <= aRscId )
     126             :             {
     127           0 :                 bRet = false;
     128             :             }
     129           0 :             if( !static_cast<ObjNode *>(Right())->IsConsistent() )
     130             :             {
     131           0 :                 bRet = false;
     132             :             }
     133             :         }
     134             :     }
     135             : 
     136           0 :     return bRet;
     137             : }
     138             : 
     139             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10