LCOV - code coverage report
Current view: top level - sw/source/filter/ww8 - WW8Sttbf.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 29 30 96.7 %
Date: 2015-06-13 12:38:46 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             : namespace ww8
      29             : {
      30         125 :     WW8Struct::WW8Struct(SvStream& rSt, sal_uInt32 nPos, sal_uInt32 nSize)
      31         125 :         : mn_offset(0), mn_size(0)
      32             :     {
      33         125 :         if (checkSeek(rSt, nPos))
      34             :         {
      35         125 :             mp_data.reset(new sal_uInt8[nSize]);
      36         125 :             mn_size = rSt.Read(mp_data.get(), nSize);
      37             :         }
      38             :         OSL_ENSURE(mn_size == nSize, "short read in WW8Struct::WW8Struct");
      39         125 :     }
      40             : 
      41       24929 :     WW8Struct::WW8Struct(WW8Struct * pStruct, sal_uInt32 nPos, sal_uInt32 nSize)
      42       24929 :         : mp_data(pStruct->mp_data), mn_offset(pStruct->mn_offset + nPos)
      43       49858 :         , mn_size(nSize)
      44             :     {
      45       24929 :     }
      46             : 
      47       49983 :     WW8Struct::~WW8Struct()
      48             :     {
      49       49983 :     }
      50             : 
      51       29135 :     sal_uInt8 WW8Struct::getU8(sal_uInt32 nOffset)
      52             :     {
      53       29135 :         sal_uInt8 nResult = 0;
      54             : 
      55       29135 :         if (nOffset < mn_size)
      56             :         {
      57        3811 :             nResult = mp_data[mn_offset + nOffset];
      58             :         }
      59             : 
      60       29135 :         return nResult;
      61             :     }
      62             : 
      63       26765 :     OUString WW8Struct::getUString(sal_uInt32 nOffset,
      64             :                                           sal_uInt32 nCount)
      65             :     {
      66       26765 :         OUString aResult;
      67             : 
      68       26765 :         if (nCount > 0)
      69             :         {
      70             :             //clip to available
      71         195 :             sal_uInt32 nStartOff = mn_offset + nOffset;
      72         195 :             if (nStartOff >= mn_size)
      73           0 :                 return aResult;
      74         195 :             sal_uInt32 nAvailable = (mn_size - nStartOff)/sizeof(sal_Unicode);
      75         195 :             if (nCount > nAvailable)
      76           3 :                 nCount = nAvailable;
      77             : #if defined OSL_LITENDIAN
      78         585 :             aResult = OUString(reinterpret_cast<const sal_Unicode *>(
      79         390 :                 mp_data.get() + nStartOff), nCount);
      80             : #else
      81             :             OUStringBuffer aBuf;
      82             :             for (sal_uInt32 i = 0; i < nCount; ++i)
      83             :                 aBuf.append(static_cast<sal_Unicode>(getU16(nStartOff+i*2)));
      84             :             aResult = aBuf.makeStringAndClear();
      85             : #endif
      86             :         }
      87             : 
      88             :         SAL_INFO( "sw.ww8.level2", "<WW8Struct-getUString offset=\"" << nOffset
      89             :             << "\" count=\"" << nCount << "\">" << aResult << "</WW8Struct-getUString>" );
      90             : 
      91       26765 :         return aResult;
      92             : 
      93             :     }
      94          60 : }
      95             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11