LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwpobjid.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 60 62 96.8 %
Date: 2014-11-03 Functions: 9 9 100.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             :  *
       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       24480 : LwpObjectID::LwpObjectID(sal_uInt32 low, sal_uInt16 high)
      71       24480 :     :m_nLow(low), m_nHigh(high), m_nIndex(0), m_bIsCompressed(false)
      72             : {
      73       24480 : }
      74             : /**
      75             :  * @descr       Read object id with format: low(4bytes)+high(2bytes) from stream
      76             :  *          for LWP7 record
      77             : */
      78          24 : sal_uInt32 LwpObjectID::Read(LwpSvStream *pStrm)
      79             : {
      80          24 :     *pStrm >> m_nLow;
      81          24 :     *pStrm >> m_nHigh;
      82          24 :     return DiskSize();
      83             : }
      84             : /**
      85             :  * @descr       Read object id with format: low(4bytes)+high(2bytes) from object stream
      86             : */
      87         230 : sal_uInt32 LwpObjectID::Read(LwpObjectStream *pObj)
      88             : {
      89         230 :     m_nLow = pObj->QuickReaduInt32();
      90         230 :     m_nHigh = pObj->QuickReaduInt16();
      91         230 :     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        1864 : 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        1864 :     m_bIsCompressed = false;
     102        1864 :     if( LwpFileHeader::m_nFileRevision < 0x000B)
     103             :     {
     104           0 :         return Read(pStrm);
     105             :     }
     106             : 
     107        1864 :     *pStrm >> m_nIndex;
     108             : 
     109        1864 :     if (m_nIndex)
     110             :     {
     111        1828 :         m_bIsCompressed = true;
     112             :         //m_nLow = index;       //note the m_nLow stores the index instead of the actual time id
     113        1828 :         LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
     114        1828 :         LwpObjectFactory* pFactory = pGlobal->GetLwpObjFactory();
     115        1828 :         LwpIndexManager& rIdxMgr = pFactory->GetIndexManager();
     116        1828 :         m_nLow = rIdxMgr.GetObjTime( (sal_uInt16)m_nIndex);
     117             :     }
     118             :     else
     119             :     {
     120          36 :         *pStrm >> m_nLow;
     121             :     }
     122        1864 :     *pStrm >> m_nHigh;
     123        1864 :     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       14104 : sal_uInt32 LwpObjectID::ReadIndexed(LwpObjectStream *pStrm)
     132             : {
     133       14104 :     m_bIsCompressed = false;
     134       14104 :     if(LwpFileHeader::m_nFileRevision < 0x000B)
     135             :     {
     136           0 :         return Read(pStrm);
     137             :     }
     138             : 
     139       14104 :     m_nIndex = pStrm->QuickReaduInt8();
     140       14104 :     if (m_nIndex)
     141             :     {
     142        9474 :         m_bIsCompressed = true;
     143             :         //m_nLow = index;       //note the m_nLow stores the index instead of the actual time id
     144        9474 :         LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
     145        9474 :         LwpObjectFactory* pFactory = pGlobal->GetLwpObjFactory();
     146        9474 :         LwpIndexManager& rIdxMgr = pFactory->GetIndexManager();
     147        9474 :         m_nLow = rIdxMgr.GetObjTime( (sal_uInt16)m_nIndex);
     148             :     }
     149             :     else
     150        4630 :         m_nLow = pStrm->QuickReaduInt32();
     151       14100 :     m_nHigh = pStrm->QuickReaduInt16();
     152       14100 :     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        4422 : sal_uInt32 LwpObjectID::ReadCompressed( LwpObjectStream* pObj, LwpObjectID &prev )
     161             : {
     162        4422 :     sal_uInt8 diff = pObj->QuickReaduInt8();
     163        4422 :     sal_uInt32 len=1;
     164             : 
     165        4422 :     if (diff == 255)
     166             :     {
     167         176 :         len += Read(pObj);
     168             :     }
     169             :     else
     170             :     {
     171        4246 :         m_nLow = prev.GetLow();
     172        4246 :         m_nHigh = prev.GetHigh() + diff +1;
     173             :     }
     174        4422 :     return len;
     175             : }
     176             : /**
     177             :  * @descr       return the size of indexed object id
     178             : */
     179       17828 : sal_uInt32 LwpObjectID::DiskSizeIndexed() const
     180             : {
     181             :     return sizeof(sal_uInt8)
     182       17828 :         + ((m_nIndex != 0) ? 0 : sizeof(m_nLow))
     183       35656 :         + sizeof(m_nHigh);
     184             : }
     185             : /**
     186             :  * @descr       return the size of object id with format: low(4bytes)+high(2bytes)
     187             : */
     188         266 : sal_uInt32 LwpObjectID::DiskSize() const
     189             : {
     190         266 :     return sizeof(m_nLow) + sizeof(m_nHigh);
     191             : }
     192             : /**
     193             :  * @descr       get object from object factory per the object id
     194             : */
     195       27230 : rtl::Reference<LwpObject> LwpObjectID::obj(VO_TYPE tag) const
     196             : {
     197       27230 :     LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
     198       27230 :     LwpObjectFactory* pObjMgr = pGlobal->GetLwpObjFactory();
     199       27230 :     if(IsNull())
     200             :     {
     201        2894 :         return NULL;
     202             :     }
     203       24336 :     rtl::Reference<LwpObject> pObj = pObjMgr->QueryObject(*this);
     204       24330 :     if( tag!=VO_INVALID &&  (pObj.is()) )
     205             :     {
     206        3806 :         if(static_cast<sal_uInt32>(tag) != pObj->GetTag())
     207             :         {
     208          18 :             pObj.clear();
     209             :         }
     210             :     }
     211       24330 :     return(pObj);
     212             : }
     213             : 
     214             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10