LCOV - code coverage report
Current view: top level - sot/source/sdstor - storinfo.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 13 36 36.1 %
Date: 2015-06-13 12:38:46 Functions: 1 2 50.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             : 
      21             : #include <sot/stg.hxx>
      22             : #include <sot/storinfo.hxx>
      23             : #include <sot/exchange.hxx>
      24             : #include <boost/scoped_array.hpp>
      25             : 
      26             : /************** class SvStorageInfo **************************************
      27             : *************************************************************************/
      28           0 : SotClipboardFormatId ReadClipboardFormat( SvStream & rStm )
      29             : {
      30           0 :     SotClipboardFormatId nFormat = SotClipboardFormatId::NONE;
      31           0 :     sal_Int32 nLen = 0;
      32           0 :     rStm.ReadInt32( nLen );
      33           0 :     if( rStm.IsEof() )
      34           0 :         rStm.SetError( SVSTREAM_GENERALERROR );
      35           0 :     if( nLen > 0 )
      36             :     {
      37             :         // get a string name
      38           0 :         boost::scoped_array<sal_Char> p(new( ::std::nothrow ) sal_Char[ nLen ]);
      39           0 :         if( p && rStm.Read( p.get(), nLen ) == (sal_uLong) nLen )
      40             :         {
      41           0 :             nFormat = SotExchange::RegisterFormatName(OUString(p.get(), nLen-1, RTL_TEXTENCODING_ASCII_US));
      42             :         }
      43             :         else
      44           0 :             rStm.SetError( SVSTREAM_GENERALERROR );
      45             :     }
      46           0 :     else if( nLen == -1L )
      47             :     {
      48             :         // Windows clipboard format
      49             :         // SV und Win stimmen ueberein (bis einschl. SotClipboardFormatId::GDIMETAFILE)
      50             :         sal_uInt32 nTmp;
      51           0 :         rStm.ReadUInt32( nTmp );
      52           0 :         nFormat = static_cast<SotClipboardFormatId>(nTmp);
      53             :     }
      54           0 :     else if( nLen == -2L )
      55             :     {
      56             :         sal_uInt32 nTmp;
      57           0 :         rStm.ReadUInt32( nTmp );
      58           0 :         nFormat = static_cast<SotClipboardFormatId>(nTmp);
      59             :         // Mac clipboard format
      60             :         // ??? not implemented
      61           0 :         rStm.SetError( SVSTREAM_GENERALERROR );
      62             :     }
      63           0 :     else if( nLen != 0 )
      64             :     {
      65             :         // unknown identifier
      66           0 :         rStm.SetError( SVSTREAM_GENERALERROR );
      67             :     }
      68           0 :     return nFormat;
      69             : }
      70             : 
      71          53 : void WriteClipboardFormat( SvStream & rStm, SotClipboardFormatId nFormat )
      72             : {
      73             :     // determine the clipboard format string
      74          53 :     OUString aCbFmt;
      75          53 :     if( nFormat > SotClipboardFormatId::GDIMETAFILE )
      76          18 :         aCbFmt = SotExchange::GetFormatName( nFormat );
      77          53 :     if( !aCbFmt.isEmpty() )
      78             :     {
      79             :         OString aAsciiCbFmt(OUStringToOString(aCbFmt,
      80          18 :                                               RTL_TEXTENCODING_ASCII_US));
      81          18 :         rStm.WriteInt32( aAsciiCbFmt.getLength() + 1 );
      82          18 :         rStm.WriteCharPtr( aAsciiCbFmt.getStr() );
      83          18 :         rStm.WriteUChar( 0 );
      84             :     }
      85          35 :     else if( nFormat != SotClipboardFormatId::NONE )
      86             :     {
      87           0 :         rStm.WriteInt32( -1 )         // for Windows
      88           0 :             .WriteInt32( static_cast<sal_Int32>(nFormat) );
      89             :     }
      90             :     else
      91             :     {
      92          35 :         rStm.WriteInt32( 0 );         // no clipboard format
      93          53 :     }
      94          53 : }
      95             : 
      96             : 
      97             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11