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