LCOV - code coverage report
Current view: top level - writerfilter/source/doctok - WW8StreamImpl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 72 1.4 %
Date: 2012-08-25 Functions: 2 12 16.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 144 1.4 %

           Branch data     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 <WW8StreamImpl.hxx>
      21                 :            : 
      22                 :            : #include <com/sun/star/uno/Reference.h>
      23                 :            : #include <com/sun/star/io/XSeekable.hpp>
      24                 :            : #include <com/sun/star/io/XStream.hpp>
      25                 :            : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
      26                 :            : 
      27                 :            : #include <doctokLoggers.hxx>
      28                 :            : 
      29                 :            : namespace writerfilter {
      30                 :            : namespace doctok
      31                 :            : {
      32                 :            : using namespace ::com::sun::star;
      33                 :            : 
      34                 :            : #if OSL_DEBUG_LEVEL > 1
      35                 :            : TagLogger::Pointer_t debug_logger(TagLogger::getInstance("DEBUG"));
      36                 :            : #endif
      37                 :            : 
      38                 :          0 : WW8Stream::~WW8Stream()
      39                 :            : {
      40         [ #  # ]:          0 : }
      41                 :            : 
      42                 :          0 : WW8StreamImpl::WW8StreamImpl(uno::Reference<uno::XComponentContext> rContext,
      43                 :            :               uno::Reference<io::XInputStream> rStream)
      44                 :          0 : : mrComponentContext(rContext), mrStream(rStream)
      45                 :            : {
      46                 :            :     xFactory = uno::Reference<lang::XMultiComponentFactory>
      47 [ #  # ][ #  # ]:          0 :         (mrComponentContext->getServiceManager());
                 [ #  # ]
      48                 :            : 
      49         [ #  # ]:          0 :     uno::Sequence<uno::Any> aArgs( 1 );
      50 [ #  # ][ #  # ]:          0 :     aArgs[0] <<= mrStream;
      51                 :            : 
      52                 :            :     xOLESimpleStorage = uno::Reference<container::XNameContainer>
      53         [ #  # ]:          0 :         (xFactory->createInstanceWithArgumentsAndContext
      54                 :            :          ("com.sun.star.embed.OLESimpleStorage",
      55                 :          0 :           aArgs, mrComponentContext ),
      56 [ #  # ][ #  # ]:          0 :          uno::UNO_QUERY );
         [ #  # ][ #  # ]
      57                 :            : 
      58                 :          0 : }
      59                 :            : 
      60                 :          0 : WW8StreamImpl::~WW8StreamImpl()
      61                 :            : {
      62         [ #  # ]:          0 : }
      63                 :            : 
      64                 :          0 : WW8Stream::Sequence WW8StreamImpl::get(sal_uInt32 nOffset,
      65                 :            :                                        sal_uInt32 nCount) const
      66                 :            : {
      67         [ #  # ]:          0 :     uno::Sequence<sal_Int8> aSequence;
      68                 :            : 
      69         [ #  # ]:          0 :     if (nCount > 0)
      70                 :            :     {
      71         [ #  # ]:          0 :         uno::Reference< io::XSeekable > xSeek( mrStream, uno::UNO_QUERY_THROW );
      72                 :            : 
      73 [ #  # ][ #  # ]:          0 :         xSeek->seek(nOffset);
      74                 :            : 
      75 [ #  # ][ #  # ]:          0 :         sal_Int32 nRead = mrStream->readBytes(aSequence, nCount);
      76                 :            : 
      77                 :            :         Sequence aReturnSequence(const_cast<const sal_uInt8 *>
      78                 :            :                                  (reinterpret_cast<sal_uInt8 *>
      79 [ #  # ][ #  # ]:          0 :                                   (&(aSequence[0]))), nRead);
      80                 :            : 
      81 [ #  # ][ #  # ]:          0 :         return aReturnSequence;
      82                 :            :     }
      83                 :            : 
      84 [ #  # ][ #  # ]:          0 :     return WW8Stream::Sequence();
      85                 :            : }
      86                 :            : 
      87                 :          0 : WW8Stream::Pointer_t WW8StreamImpl::getSubStream(const OUString & sId)
      88                 :            : {
      89                 :          0 :     WW8Stream::Pointer_t pResult;
      90                 :            : 
      91                 :            :     try
      92                 :            :     {
      93         [ #  # ]:          0 :         if (xOLESimpleStorage.is())
      94                 :            :         {
      95 [ #  # ][ #  # ]:          0 :             if (xOLESimpleStorage->hasByName(sId))
                 [ #  # ]
      96                 :            :             {
      97                 :          0 :                 uno::Reference<io::XStream> xNewStream;
      98                 :            :                 {
      99 [ #  # ][ #  # ]:          0 :                     uno::Any aValue = xOLESimpleStorage->getByName(sId);
     100         [ #  # ]:          0 :                     aValue >>= xNewStream;
     101                 :            :                 }
     102                 :            : 
     103         [ #  # ]:          0 :                 if (xNewStream.is())
     104                 :            :                 {
     105                 :            :                     WW8Stream::Pointer_t
     106                 :            :                         pNew(new WW8StreamImpl(mrComponentContext,
     107 [ #  # ][ #  # ]:          0 :                                                xNewStream->getInputStream()));
         [ #  # ][ #  # ]
                 [ #  # ]
     108                 :            : 
     109 [ #  # ][ #  # ]:          0 :                     pResult = pNew;
     110                 :          0 :                 }
     111                 :            :             }
     112                 :            :         }
     113                 :            :     }
     114         [ #  # ]:          0 :     catch (...)
     115                 :            :     {
     116                 :            :     }
     117                 :            : 
     118         [ #  # ]:          0 :     if (pResult.get() == NULL)
     119 [ #  # ][ #  # ]:          0 :         throw ExceptionNotFound("Stream not found");
     120                 :            : 
     121                 :          0 :     return pResult;
     122                 :            : }
     123                 :            : 
     124                 :          0 : string WW8StreamImpl::getSubStreamNames() const
     125                 :            : {
     126                 :          0 :     string sResult;
     127                 :            : 
     128         [ #  # ]:          0 :     if (xOLESimpleStorage.is())
     129                 :            :     {
     130 [ #  # ][ #  # ]:          0 :         uno::Sequence<OUString> aSeq = xOLESimpleStorage->getElementNames();
     131                 :            : 
     132         [ #  # ]:          0 :         for (sal_uInt32 n = 0;
     133                 :          0 :              n < sal::static_int_cast<sal_uInt32>(aSeq.getLength()); ++n)
     134                 :            :         {
     135         [ #  # ]:          0 :             OUString aOUStr = aSeq[n];
     136                 :            : 
     137         [ #  # ]:          0 :             if (n > 0)
     138         [ #  # ]:          0 :                 sResult += ", ";
     139                 :            : 
     140                 :            :             char sBuffer[256];
     141         [ #  # ]:          0 :             for (sal_uInt32 j = 0;
     142                 :          0 :                  j < sal::static_int_cast<sal_uInt32>(aOUStr.getLength()); ++j)
     143                 :            :             {
     144         [ #  # ]:          0 :                 if (isprint(aOUStr[j]))
     145                 :            :                 {
     146                 :          0 :                     sal_Unicode nC = aOUStr[j];
     147                 :            : 
     148         [ #  # ]:          0 :                     if (nC < 255)
     149         [ #  # ]:          0 :                         sResult += sal::static_int_cast<char>(nC);
     150                 :            :                     else
     151         [ #  # ]:          0 :                         sResult += ".";
     152                 :            :                 }
     153                 :            :                 else
     154                 :            :                 {
     155                 :          0 :                     snprintf(sBuffer, sizeof(sBuffer), "\\u%x", aOUStr[j]);
     156         [ #  # ]:          0 :                     sResult += sBuffer;
     157                 :            :                 }
     158                 :            :             }
     159         [ #  # ]:          0 :         }
     160                 :            :     }
     161                 :            : 
     162                 :          0 :     return sResult;
     163                 :            : }
     164                 :            : 
     165                 :          0 : uno::Sequence<OUString> WW8StreamImpl::getSubStreamUNames() const
     166                 :            : {
     167                 :          0 :     return xOLESimpleStorage->getElementNames();
     168                 :            : }
     169                 :            : 
     170                 :          0 : void WW8StreamImpl::dump(OutputWithDepth<string> & o) const
     171                 :            : {
     172 [ #  # ][ #  # ]:          0 :     o.addItem("<stream>");
     173                 :            : 
     174         [ #  # ]:          0 :     Sequence aSeq;
     175                 :          0 :     sal_uInt32 nOffset = 0;
     176                 :          0 :     sal_uInt32 nStep = 16;
     177                 :            : 
     178         [ #  # ]:          0 :     do
     179                 :            :     {
     180 [ #  # ][ #  # ]:          0 :         aSeq = get(nOffset, nStep);
                 [ #  # ]
     181         [ #  # ]:          0 :         dumpLine(o, aSeq, nOffset, nStep);
     182                 :            : 
     183                 :          0 :         nOffset += nStep;
     184                 :            :     }
     185                 :          0 :     while (aSeq.getCount() == nStep);
     186                 :            : 
     187 [ #  # ][ #  # ]:          0 :     o.addItem("</stream>");
                 [ #  # ]
     188                 :          0 : }
     189                 :            : 
     190 [ +  - ][ +  - ]:         60 : }}
     191                 :            : 
     192                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10