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 : :
21 : : #include <sot/stg.hxx>
22 : : #include <sot/storinfo.hxx>
23 : : #include <sot/exchange.hxx>
24 : :
25 : :
26 : : /************** class SvStorageInfo **************************************
27 : : *************************************************************************/
28 : 81 : sal_uLong ReadClipboardFormat( SvStream & rStm )
29 : : {
30 : 81 : sal_uInt32 nFormat = 0;
31 : 81 : sal_Int32 nLen = 0;
32 [ + - ]: 81 : rStm >> nLen;
33 [ - + ]: 81 : if( rStm.IsEof() )
34 [ # # ]: 0 : rStm.SetError( SVSTREAM_GENERALERROR );
35 [ + - ]: 81 : if( nLen > 0 )
36 : : {
37 : : // get a string name
38 : 81 : sal_Char * p = new( ::std::nothrow ) sal_Char[ nLen ];
39 [ + - ][ + - ]: 81 : if( p && rStm.Read( p, nLen ) == (sal_uLong) nLen )
[ + - ][ + - ]
40 : : {
41 [ + - ][ + - ]: 81 : nFormat = SotExchange::RegisterFormatName(rtl::OUString(p, nLen-1, RTL_TEXTENCODING_ASCII_US));
[ + - ][ + - ]
42 : : }
43 : : else
44 [ # # ]: 0 : rStm.SetError( SVSTREAM_GENERALERROR );
45 [ + - ]: 81 : delete [] p;
46 : : }
47 [ # # ]: 0 : else if( nLen == -1L )
48 : : // Windows clipboard format
49 : : // SV und Win stimmen ueberein (bis einschl. FORMAT_GDIMETAFILE)
50 [ # # ]: 0 : rStm >> nFormat;
51 [ # # ]: 0 : else if( nLen == -2L )
52 : : {
53 [ # # ]: 0 : rStm >> nFormat;
54 : : // Mac clipboard format
55 : : // ??? not implemented
56 [ # # ]: 0 : rStm.SetError( SVSTREAM_GENERALERROR );
57 : : }
58 [ # # ]: 0 : else if( nLen != 0 )
59 : : {
60 : : // unknown identifier
61 [ # # ]: 0 : rStm.SetError( SVSTREAM_GENERALERROR );
62 : : }
63 : 81 : return nFormat;
64 : : }
65 : :
66 : 12 : void WriteClipboardFormat( SvStream & rStm, sal_uLong nFormat )
67 : : {
68 : : // determine the clipboard format string
69 [ + - ]: 12 : String aCbFmt;
70 [ + + ]: 12 : if( nFormat > FORMAT_GDIMETAFILE )
71 [ + - ][ + - ]: 3 : aCbFmt = SotExchange::GetFormatName( nFormat );
[ + - ]
72 [ + + ]: 12 : if( aCbFmt.Len() )
73 : : {
74 : : rtl::OString aAsciiCbFmt(rtl::OUStringToOString(aCbFmt,
75 [ + - ][ + - ]: 3 : RTL_TEXTENCODING_ASCII_US));
76 [ + - ]: 3 : rStm << (sal_Int32) (aAsciiCbFmt.getLength() + 1);
77 [ + - ]: 3 : rStm << (const char *)aAsciiCbFmt.getStr();
78 [ + - ]: 3 : rStm << (sal_uInt8) 0;
79 : : }
80 [ - + ]: 9 : else if( nFormat )
81 [ # # ]: 0 : rStm << (sal_Int32) -1 // for Windows
82 [ # # ]: 0 : << (sal_Int32) nFormat;
83 : : else
84 [ + - ][ + - ]: 12 : rStm << (sal_Int32) 0; // no clipboard format
85 : 12 : }
86 : :
87 : :
88 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|