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