update dev300-m58
[ooovba.git] / sot / source / sdstor / storinfo.cxx
blob0e6e577ae3871dd59a867b985ef5508b2c6dd43f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: storinfo.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sot.hxx"
34 #include <stg.hxx>
35 #include <storinfo.hxx>
36 #include <sot/exchange.hxx>
39 /************** class SvStorageInfoList **********************************
40 *************************************************************************/
41 PRV_SV_IMPL_OWNER_LIST(SvStorageInfoList,SvStorageInfo)
43 const SvStorageInfo * SvStorageInfoList::Get( const String & rEleName )
45 for( ULONG i = 0; i < Count(); i++ )
47 const SvStorageInfo & rType = GetObject( i );
48 if( rType.GetName() == rEleName )
49 return &rType;
51 return NULL;
54 /************** class SvStorageInfo **************************************
55 *************************************************************************/
56 ULONG ReadClipboardFormat( SvStream & rStm )
58 sal_uInt32 nFormat = 0;
59 INT32 nLen = 0;
60 rStm >> nLen;
61 if( rStm.IsEof() )
62 rStm.SetError( SVSTREAM_GENERALERROR );
63 if( nLen > 0 )
65 // get a string name
66 sal_Char * p = new sal_Char[ nLen ];
67 if( rStm.Read( p, nLen ) == (ULONG) nLen )
69 nFormat = SotExchange::RegisterFormatName( String::CreateFromAscii( p, short(nLen-1) ) );
71 else
72 rStm.SetError( SVSTREAM_GENERALERROR );
73 delete [] p;
75 else if( nLen == -1L )
76 // Windows clipboard format
77 // SV und Win stimmen ueberein (bis einschl. FORMAT_GDIMETAFILE)
78 rStm >> nFormat;
79 else if( nLen == -2L )
81 rStm >> nFormat;
82 // Mac clipboard format
83 // ??? not implemented
84 rStm.SetError( SVSTREAM_GENERALERROR );
86 else if( nLen != 0 )
88 // unknown identifier
89 rStm.SetError( SVSTREAM_GENERALERROR );
91 return nFormat;
94 void WriteClipboardFormat( SvStream & rStm, ULONG nFormat )
96 // determine the clipboard format string
97 String aCbFmt;
98 if( nFormat > FORMAT_GDIMETAFILE )
99 aCbFmt = SotExchange::GetFormatName( nFormat );
100 if( aCbFmt.Len() )
102 ByteString aAsciiCbFmt( aCbFmt, RTL_TEXTENCODING_ASCII_US );
103 rStm << (INT32) (aAsciiCbFmt.Len() + 1);
104 rStm << (const char *)aAsciiCbFmt.GetBuffer();
105 rStm << (UINT8) 0;
107 else if( nFormat )
108 rStm << (INT32) -1 // for Windows
109 << (INT32) nFormat;
110 else
111 rStm << (INT32) 0; // no clipboard format