LCOV - code coverage report
Current view: top level - sw/source/filter/ww8 - WW8Sttbf.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 23 28 82.1 %
Date: 2012-08-25 Functions: 6 8 75.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 16 30 53.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <iostream>
      30                 :            : #include <dbgoutsw.hxx>
      31                 :            : #include "WW8Sttbf.hxx"
      32                 :            : #include "ww8scan.hxx"
      33                 :            : #include <cstdio>
      34                 :            : #include <osl/endian.h>
      35                 :            : #include <rtl/ustrbuf.hxx>
      36                 :            : 
      37                 :            : #if OSL_DEBUG_LEVEL > 1
      38                 :            : #include <stdio.h>
      39                 :            : #endif
      40                 :            : 
      41                 :            : namespace ww8
      42                 :            : {
      43                 :        102 :     WW8Struct::WW8Struct(SvStream& rSt, sal_uInt32 nPos, sal_uInt32 nSize)
      44         [ +  - ]:        102 :         : mn_offset(0), mn_size(0)
      45                 :            :     {
      46 [ +  - ][ +  - ]:        102 :         if (checkSeek(rSt, nPos))
      47                 :            :         {
      48 [ +  - ][ +  - ]:        102 :             mp_data.reset(new sal_uInt8[nSize]);
      49         [ +  - ]:        102 :             mn_size = rSt.Read(mp_data.get(), nSize);
      50                 :            :         }
      51                 :            :         OSL_ENSURE(mn_size == nSize, "short read in WW8Struct::WW8Struct");
      52                 :        102 :     }
      53                 :            : 
      54                 :          0 :     WW8Struct::WW8Struct(WW8Struct * pStruct, sal_uInt32 nPos, sal_uInt32 nSize)
      55                 :            :         : mp_data(pStruct->mp_data), mn_offset(pStruct->mn_offset + nPos)
      56         [ #  # ]:          0 :         , mn_size(nSize)
      57                 :            :     {
      58                 :          0 :     }
      59                 :            : 
      60         [ +  - ]:         99 :     WW8Struct::~WW8Struct()
      61                 :            :     {
      62         [ -  + ]:         99 :     }
      63                 :            : 
      64                 :       3528 :     sal_uInt8 WW8Struct::getU8(sal_uInt32 nOffset)
      65                 :            :     {
      66                 :       3528 :         sal_uInt8 nResult = 0;
      67                 :            : 
      68         [ +  + ]:       3528 :         if (nOffset < mn_size)
      69                 :            :         {
      70                 :       3438 :             nResult = mp_data[mn_offset + nOffset];
      71                 :            :         }
      72                 :            : 
      73                 :       3528 :         return nResult;
      74                 :            :     }
      75                 :            : 
      76                 :       1458 :     ::rtl::OUString WW8Struct::getUString(sal_uInt32 nOffset,
      77                 :            :                                           sal_uInt32 nCount)
      78                 :            :     {
      79                 :       1458 :         ::rtl::OUString aResult;
      80                 :            : 
      81         [ +  + ]:       1458 :         if (nCount > 0)
      82                 :            :         {
      83                 :            :             //clip to available
      84                 :        198 :             sal_uInt32 nStartOff = mn_offset + nOffset;
      85         [ -  + ]:        198 :             if (nStartOff >= mn_size)
      86                 :          0 :                 return aResult;
      87                 :        198 :             sal_uInt32 nAvailable = (mn_size - nStartOff)/sizeof(sal_Unicode);
      88         [ -  + ]:        198 :             if (nCount > nAvailable)
      89                 :          0 :                 nCount = nAvailable;
      90                 :            : #if defined OSL_LITENDIAN
      91                 :            :             aResult = rtl::OUString(reinterpret_cast<const sal_Unicode *>(
      92                 :        198 :                 mp_data.get() + nStartOff), nCount);
      93                 :            : #else
      94                 :            :             rtl::OUStringBuffer aBuf;
      95                 :            :             for (sal_uInt32 i = 0; i < nCount; ++i)
      96                 :            :                 aBuf.append(static_cast<sal_Unicode>(getU16(nStartOff+i*2)));
      97                 :            :             aResult = aBuf.makeStringAndClear();
      98                 :            : #endif
      99                 :            :         }
     100                 :            : 
     101                 :            : #if OSL_DEBUG_LEVEL > 1
     102                 :            :         char sBuffer[256];
     103                 :            :         snprintf(sBuffer, sizeof(sBuffer), "offset=\"%" SAL_PRIuUINT32 "\" count=\"%" SAL_PRIuUINT32 "\"",
     104                 :            :                  nOffset, nCount);
     105                 :            :         ::std::clog << "<WW8Struct-getUString" << sBuffer << ">"
     106                 :            :                     << rtl::OUStringToOString( aResult, RTL_TEXTENCODING_UTF8 ).getStr() << "</WW8Struct-getUString>"
     107                 :            :                     << ::std::endl;
     108                 :            : #endif
     109                 :            : 
     110                 :       1458 :         return aResult;
     111                 :            : 
     112                 :            :     }
     113 [ +  - ][ +  - ]:         54 : }
     114                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10