LCOV - code coverage report
Current view: top level - sw/source/filter/ww8 - WW8Sttbf.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 29 30 96.7 %
Date: 2014-04-11 Functions: 8 8 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             :  * 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             : #include <iostream>
      21             : #include <dbgoutsw.hxx>
      22             : #include "WW8Sttbf.hxx"
      23             : #include "ww8scan.hxx"
      24             : #include <cstdio>
      25             : #include <osl/endian.h>
      26             : #include <rtl/ustrbuf.hxx>
      27             : 
      28             : #if OSL_DEBUG_LEVEL > 1
      29             : #include <stdio.h>
      30             : #endif
      31             : 
      32             : namespace ww8
      33             : {
      34          73 :     WW8Struct::WW8Struct(SvStream& rSt, sal_uInt32 nPos, sal_uInt32 nSize)
      35          73 :         : mn_offset(0), mn_size(0)
      36             :     {
      37          73 :         if (checkSeek(rSt, nPos))
      38             :         {
      39          73 :             mp_data.reset(new sal_uInt8[nSize]);
      40          73 :             mn_size = rSt.Read(mp_data.get(), nSize);
      41             :         }
      42             :         OSL_ENSURE(mn_size == nSize, "short read in WW8Struct::WW8Struct");
      43          73 :     }
      44             : 
      45       24929 :     WW8Struct::WW8Struct(WW8Struct * pStruct, sal_uInt32 nPos, sal_uInt32 nSize)
      46       24929 :         : mp_data(pStruct->mp_data), mn_offset(pStruct->mn_offset + nPos)
      47       49858 :         , mn_size(nSize)
      48             :     {
      49       24929 :     }
      50             : 
      51       49931 :     WW8Struct::~WW8Struct()
      52             :     {
      53       49931 :     }
      54             : 
      55       27419 :     sal_uInt8 WW8Struct::getU8(sal_uInt32 nOffset)
      56             :     {
      57       27419 :         sal_uInt8 nResult = 0;
      58             : 
      59       27419 :         if (nOffset < mn_size)
      60             :         {
      61        2413 :             nResult = mp_data[mn_offset + nOffset];
      62             :         }
      63             : 
      64       27419 :         return nResult;
      65             :     }
      66             : 
      67       25955 :     OUString WW8Struct::getUString(sal_uInt32 nOffset,
      68             :                                           sal_uInt32 nCount)
      69             :     {
      70       25955 :         OUString aResult;
      71             : 
      72       25955 :         if (nCount > 0)
      73             :         {
      74             :             //clip to available
      75         128 :             sal_uInt32 nStartOff = mn_offset + nOffset;
      76         128 :             if (nStartOff >= mn_size)
      77           0 :                 return aResult;
      78         128 :             sal_uInt32 nAvailable = (mn_size - nStartOff)/sizeof(sal_Unicode);
      79         128 :             if (nCount > nAvailable)
      80           1 :                 nCount = nAvailable;
      81             : #if defined OSL_LITENDIAN
      82         384 :             aResult = OUString(reinterpret_cast<const sal_Unicode *>(
      83         256 :                 mp_data.get() + nStartOff), nCount);
      84             : #else
      85             :             OUStringBuffer aBuf;
      86             :             for (sal_uInt32 i = 0; i < nCount; ++i)
      87             :                 aBuf.append(static_cast<sal_Unicode>(getU16(nStartOff+i*2)));
      88             :             aResult = aBuf.makeStringAndClear();
      89             : #endif
      90             :         }
      91             : 
      92             :         SAL_INFO( "sw.ww8.level2", "<WW8Struct-getUString" << " offset=\"" << nOffset
      93             :             << "\" count=\"" << nCount << "\"" << ">" << aResult << "</WW8Struct-getUString>" );
      94             : 
      95       25955 :         return aResult;
      96             : 
      97             :     }
      98          33 : }
      99             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10