LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwpobjid.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 59 61 96.7 %
Date: 2012-08-25 Functions: 9 9 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 17 20 85.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  *  The Contents of this file are made available subject to the terms of
       5                 :            :  *  either of the following licenses
       6                 :            :  *
       7                 :            :  *         - GNU Lesser General Public License Version 2.1
       8                 :            :  *         - Sun Industry Standards Source License Version 1.1
       9                 :            :  *
      10                 :            :  *  Sun Microsystems Inc., October, 2000
      11                 :            :  *
      12                 :            :  *  GNU Lesser General Public License Version 2.1
      13                 :            :  *  =============================================
      14                 :            :  *  Copyright 2000 by Sun Microsystems, Inc.
      15                 :            :  *  901 San Antonio Road, Palo Alto, CA 94303, USA
      16                 :            :  *
      17                 :            :  *  This library is free software; you can redistribute it and/or
      18                 :            :  *  modify it under the terms of the GNU Lesser General Public
      19                 :            :  *  License version 2.1, as published by the Free Software Foundation.
      20                 :            :  *
      21                 :            :  *  This library is distributed in the hope that it will be useful,
      22                 :            :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      23                 :            :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      24                 :            :  *  Lesser General Public License for more details.
      25                 :            :  *
      26                 :            :  *  You should have received a copy of the GNU Lesser General Public
      27                 :            :  *  License along with this library; if not, write to the Free Software
      28                 :            :  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      29                 :            :  *  MA  02111-1307  USA
      30                 :            :  *
      31                 :            :  *
      32                 :            :  *  Sun Industry Standards Source License Version 1.1
      33                 :            :  *  =================================================
      34                 :            :  *  The contents of this file are subject to the Sun Industry Standards
      35                 :            :  *  Source License Version 1.1 (the "License"); You may not use this file
      36                 :            :  *  except in compliance with the License. You may obtain a copy of the
      37                 :            :  *  License at http://www.openoffice.org/license.html.
      38                 :            :  *
      39                 :            :  *  Software provided under this License is provided on an "AS IS" basis,
      40                 :            :  *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
      41                 :            :  *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
      42                 :            :  *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
      43                 :            :  *  See the License for the specific provisions governing your rights and
      44                 :            :  *  obligations concerning the Software.
      45                 :            :  *
      46                 :            :  *  The Initial Developer of the Original Code is: IBM Corporation
      47                 :            :  *
      48                 :            :  *  Copyright: 2008 by IBM Corporation
      49                 :            :  *
      50                 :            :  *  All Rights Reserved.
      51                 :            :  *
      52                 :            :  *  Contributor(s): _______________________________________
      53                 :            :  *
      54                 :            :  *
      55                 :            :  ************************************************************************/
      56                 :            : /*************************************************************************
      57                 :            :  * @file
      58                 :            :  *  For LWP filter architecture prototype
      59                 :            :  ************************************************************************/
      60                 :            : /*************************************************************************
      61                 :            :  * Change History
      62                 :            :  Jan 2005           Created
      63                 :            :  ************************************************************************/
      64                 :            : 
      65                 :            : #include "lwpobjid.hxx"
      66                 :            : #include "lwpfilehdr.hxx"
      67                 :            : #include "lwpobjfactory.hxx"
      68                 :            : #include "lwpglobalmgr.hxx"
      69                 :            : 
      70                 :      36918 : LwpObjectID::LwpObjectID(sal_uInt32 low, sal_uInt16 high)
      71                 :      36918 :     :m_nLow(low), m_nHigh(high), m_nIndex(0), m_bIsCompressed(sal_False)
      72                 :            : {
      73                 :      36918 : }
      74                 :            : /**
      75                 :            :  * @descr       Read object id with format: low(4bytes)+high(2bytes) from stream
      76                 :            :  *          for LWP7 record
      77                 :            : */
      78                 :         36 : sal_uInt32 LwpObjectID::Read(LwpSvStream *pStrm)
      79                 :            : {
      80                 :         36 :     *pStrm >> m_nLow;
      81                 :         36 :     *pStrm >> m_nHigh;
      82                 :         36 :     return DiskSize();
      83                 :            : }
      84                 :            : /**
      85                 :            :  * @descr       Read object id with format: low(4bytes)+high(2bytes) from object stream
      86                 :            : */
      87                 :        345 : sal_uInt32 LwpObjectID::Read(LwpObjectStream *pObj)
      88                 :            : {
      89                 :        345 :     m_nLow = pObj->QuickReaduInt32();
      90                 :        345 :     m_nHigh = pObj->QuickReaduInt16();
      91                 :        345 :     return DiskSize();
      92                 :            : }
      93                 :            : /**
      94                 :            :  * @descr       Read object id with indexed format from stream
      95                 :            :  *          if index>0, lowid is get from time table per the index
      96                 :            : *           else    index+lowid+highid
      97                 :            : */
      98                 :       2814 : sal_uInt32 LwpObjectID::ReadIndexed(LwpSvStream *pStrm)
      99                 :            : {
     100                 :            : //note the m_nLow store the index instead of time from the timetable as in LWP
     101                 :       2814 :     m_bIsCompressed = sal_False;
     102         [ -  + ]:       2814 :     if( LwpFileHeader::m_nFileRevision < 0x000B)
     103                 :            :     {
     104                 :          0 :         return Read(pStrm);
     105                 :            :     }
     106                 :            : 
     107                 :       2814 :     *pStrm >> m_nIndex;
     108                 :            : 
     109         [ +  + ]:       2814 :     if (m_nIndex)
     110                 :            :     {
     111                 :       2760 :         m_bIsCompressed = sal_True;
     112                 :            :         //m_nLow = index;       //note the m_nLow stores the index instead of the actual time id
     113                 :       2760 :         LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
     114                 :       2760 :         LwpObjectFactory* pFactory = pGlobal->GetLwpObjFactory();
     115                 :       2760 :         LwpIndexManager* pIdxMgr = pFactory->GetIndexManager();
     116                 :       2760 :         m_nLow =  pIdxMgr->GetObjTime( (sal_uInt16)m_nIndex);
     117                 :            :     }
     118                 :            :     else
     119                 :            :     {
     120                 :         54 :         *pStrm >> m_nLow;
     121                 :            :     }
     122                 :       2814 :     *pStrm >> m_nHigh;
     123                 :       2814 :     return DiskSizeIndexed();
     124                 :            : }
     125                 :            : 
     126                 :            : /**
     127                 :            :  * @descr       Read object id with indexed format from object stream
     128                 :            :  *          if index>0, lowid is get from time table per the index
     129                 :            : *           else    index+lowid+highid
     130                 :            : */
     131                 :      21291 : sal_uInt32 LwpObjectID::ReadIndexed(LwpObjectStream *pStrm)
     132                 :            : {
     133                 :      21291 :     m_bIsCompressed = sal_False;
     134         [ -  + ]:      21291 :     if(LwpFileHeader::m_nFileRevision < 0x000B)
     135                 :            :     {
     136                 :          0 :         return Read(pStrm);
     137                 :            :     }
     138                 :            : 
     139                 :      21291 :     m_nIndex = pStrm->QuickReaduInt8();
     140         [ +  + ]:      21291 :     if (m_nIndex)
     141                 :            :     {
     142                 :      14301 :         m_bIsCompressed = sal_True;
     143                 :            :         //m_nLow = index;       //note the m_nLow stores the index instead of the actual time id
     144                 :      14301 :         LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
     145                 :      14301 :         LwpObjectFactory* pFactory = pGlobal->GetLwpObjFactory();
     146                 :      14301 :         LwpIndexManager* pIdxMgr = pFactory->GetIndexManager();
     147                 :      14301 :         m_nLow = pIdxMgr->GetObjTime( (sal_uInt16)m_nIndex);
     148                 :            :     }
     149                 :            :     else
     150                 :       6990 :         m_nLow = pStrm->QuickReaduInt32();
     151                 :      21285 :     m_nHigh = pStrm->QuickReaduInt16();
     152                 :      21285 :     return DiskSizeIndexed();
     153                 :            : }
     154                 :            : /**
     155                 :            :  * @descr       Read object id with compressed format from object stream
     156                 :            :  *          if diff == 255: 255+lowid+highid
     157                 :            :  *          else    lowid equals to the lowid of previous low id
     158                 :            :  *              and high id = the high id of previous id + diff +1
     159                 :            : */
     160                 :       6633 : sal_uInt32 LwpObjectID::ReadCompressed( LwpObjectStream* pObj, LwpObjectID &prev )
     161                 :            : {
     162                 :       6633 :     sal_uInt8 diff = pObj->QuickReaduInt8();
     163                 :       6633 :     sal_uInt32 len=1;
     164                 :            : 
     165         [ +  + ]:       6633 :     if (diff == 255)
     166                 :            :     {
     167                 :        264 :         len += Read(pObj);
     168                 :            :     }
     169                 :            :     else
     170                 :            :     {
     171                 :       6369 :         m_nLow = prev.GetLow();
     172                 :       6369 :         m_nHigh = prev.GetHigh() + diff +1;
     173                 :            :     }
     174                 :       6633 :     return len;
     175                 :            : }
     176                 :            : /**
     177                 :            :  * @descr       return the size of indexed object id
     178                 :            : */
     179                 :      26913 : sal_uInt32 LwpObjectID::DiskSizeIndexed() const
     180                 :            : {
     181                 :            :     return sizeof(sal_uInt8)
     182                 :            :         + ((m_nIndex != 0) ? 0 : sizeof(m_nLow))
     183         [ +  + ]:      26913 :         + sizeof(m_nHigh);
     184                 :            : }
     185                 :            : /**
     186                 :            :  * @descr       return the size of object id with format: low(4bytes)+high(2bytes)
     187                 :            : */
     188                 :        399 : sal_uInt32 LwpObjectID::DiskSize() const
     189                 :            : {
     190                 :        399 :     return sizeof(m_nLow) + sizeof(m_nHigh);
     191                 :            : }
     192                 :            : /**
     193                 :            :  * @descr       get object from object factory per the object id
     194                 :            : */
     195                 :      41712 : LwpObject* LwpObjectID::obj(VO_TYPE tag) const
     196                 :            : {
     197                 :      41712 :     LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
     198                 :      41712 :     LwpObjectFactory* pObjMgr = pGlobal->GetLwpObjFactory();
     199         [ +  + ]:      41712 :     if(IsNull())
     200                 :            :     {
     201                 :       4491 :         return NULL;
     202                 :            :     }
     203                 :      37221 :     LwpObject* pObj = pObjMgr->QueryObject(*this);
     204 [ +  - ][ +  + ]:      37212 :     if( tag!=VO_INVALID &&  (pObj) )
     205                 :            :     {
     206         [ +  + ]:       5745 :         if(static_cast<sal_uInt32>(tag) != pObj->GetTag())
     207                 :            :         {
     208                 :         27 :             pObj=NULL;
     209                 :            :         }
     210                 :            :     }
     211                 :      41703 :     return(pObj);
     212                 :            : }
     213                 :            : 
     214                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10