1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sot.hxx" 26 27 #include <sot/stg.hxx> 28 #include <sot/storinfo.hxx> 29 #include <sot/exchange.hxx> 30 31 32 /************** class SvStorageInfoList ********************************** 33 *************************************************************************/ 34 PRV_SV_IMPL_OWNER_LIST(SvStorageInfoList,SvStorageInfo) 35 36 const SvStorageInfo * SvStorageInfoList::Get( const String & rEleName ) 37 { 38 for( sal_uLong i = 0; i < Count(); i++ ) 39 { 40 const SvStorageInfo & rType = GetObject( i ); 41 if( rType.GetName() == rEleName ) 42 return &rType; 43 } 44 return NULL; 45 } 46 47 /************** class SvStorageInfo ************************************** 48 *************************************************************************/ 49 sal_uLong ReadClipboardFormat( SvStream & rStm ) 50 { 51 sal_uInt32 nFormat = 0; 52 sal_Int32 nLen = 0; 53 rStm >> nLen; 54 if( rStm.IsEof() ) 55 rStm.SetError( SVSTREAM_GENERALERROR ); 56 if( nLen > 0 ) 57 { 58 // get a string name 59 sal_Char * p = new( ::std::nothrow ) sal_Char[ nLen ]; 60 if( p && rStm.Read( p, nLen ) == (sal_uLong) nLen ) 61 { 62 // take so much from the buffer, as the string supports 63 nFormat = SotExchange::RegisterFormatName( String::CreateFromAscii( p, xub_StrLen( ( nLen - 1 ) & STRING_MAXLEN ) ) ); 64 } 65 else 66 rStm.SetError( SVSTREAM_GENERALERROR ); 67 delete [] p; 68 } 69 else if( nLen == -1L ) 70 // Windows clipboard format 71 // SV und Win stimmen ueberein (bis einschl. FORMAT_GDIMETAFILE) 72 rStm >> nFormat; 73 else if( nLen == -2L ) 74 { 75 rStm >> nFormat; 76 // Mac clipboard format 77 // ??? not implemented 78 rStm.SetError( SVSTREAM_GENERALERROR ); 79 } 80 else if( nLen != 0 ) 81 { 82 // unknown identifier 83 rStm.SetError( SVSTREAM_GENERALERROR ); 84 } 85 return nFormat; 86 } 87 88 void WriteClipboardFormat( SvStream & rStm, sal_uLong nFormat ) 89 { 90 // determine the clipboard format string 91 String aCbFmt; 92 if( nFormat > FORMAT_GDIMETAFILE ) 93 aCbFmt = SotExchange::GetFormatName( nFormat ); 94 if( aCbFmt.Len() ) 95 { 96 ByteString aAsciiCbFmt( aCbFmt, RTL_TEXTENCODING_ASCII_US ); 97 rStm << (sal_Int32) (aAsciiCbFmt.Len() + 1); 98 rStm << (const char *)aAsciiCbFmt.GetBuffer(); 99 rStm << (sal_uInt8) 0; 100 } 101 else if( nFormat ) 102 rStm << (sal_Int32) -1 // for Windows 103 << (sal_Int32) nFormat; 104 else 105 rStm << (sal_Int32) 0; // no clipboard format 106 } 107 108 109