LCOV - code coverage report
Current view: top level - sot/source/sdstor - storinfo.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 23 34 67.6 %
Date: 2014-11-03 Functions: 2 2 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             : 
      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          48 : sal_uLong ReadClipboardFormat( SvStream & rStm )
      29             : {
      30          48 :     sal_uInt32 nFormat = 0;
      31          48 :     sal_Int32 nLen = 0;
      32          48 :     rStm.ReadInt32( nLen );
      33          48 :     if( rStm.IsEof() )
      34           0 :         rStm.SetError( SVSTREAM_GENERALERROR );
      35          48 :     if( nLen > 0 )
      36             :     {
      37             :         // get a string name
      38          48 :         boost::scoped_array<sal_Char> p(new( ::std::nothrow ) sal_Char[ nLen ]);
      39          48 :         if( p && rStm.Read( p.get(), nLen ) == (sal_uLong) nLen )
      40             :         {
      41          48 :             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             :         // Windows clipboard format
      48             :         // SV und Win stimmen ueberein (bis einschl. FORMAT_GDIMETAFILE)
      49           0 :         rStm.ReadUInt32( nFormat );
      50           0 :     else if( nLen == -2L )
      51             :     {
      52           0 :         rStm.ReadUInt32( nFormat );
      53             :         // Mac clipboard format
      54             :         // ??? not implemented
      55           0 :         rStm.SetError( SVSTREAM_GENERALERROR );
      56             :     }
      57           0 :     else if( nLen != 0 )
      58             :     {
      59             :         // unknown identifier
      60           0 :         rStm.SetError( SVSTREAM_GENERALERROR );
      61             :     }
      62          48 :     return nFormat;
      63             : }
      64             : 
      65          62 : void WriteClipboardFormat( SvStream & rStm, sal_uLong nFormat )
      66             : {
      67             :     // determine the clipboard format string
      68          62 :     OUString aCbFmt;
      69          62 :     if( nFormat > FORMAT_GDIMETAFILE )
      70          28 :         aCbFmt = SotExchange::GetFormatName( nFormat );
      71          62 :     if( !aCbFmt.isEmpty() )
      72             :     {
      73             :         OString aAsciiCbFmt(OUStringToOString(aCbFmt,
      74          28 :                                               RTL_TEXTENCODING_ASCII_US));
      75          28 :         rStm.WriteInt32( (aAsciiCbFmt.getLength() + 1) );
      76          28 :         rStm.WriteCharPtr( (const char *)aAsciiCbFmt.getStr() );
      77          28 :         rStm.WriteUChar( 0 );
      78             :     }
      79          34 :     else if( nFormat )
      80             :     {
      81           0 :         rStm.WriteInt32( -1 )         // for Windows
      82           0 :             .WriteInt32( nFormat );
      83             :     }
      84             :     else
      85             :     {
      86          34 :         rStm.WriteInt32( 0 );         // no clipboard format
      87          62 :     }
      88          62 : }
      89             : 
      90             : 
      91             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10