An Excel sheet fragment has been copied to the clipboard. Is it possible to find out the name of the data format in the clipboard?
An Excel sheet fragment has been copied to the clipboard. Is it possible to find out the name of the data format in the clipboard?
The short answer is: partially. You can obtain the numeric format ID, but not the name string of the format directly through FWH's existing API.
FWH provides the
The underlying C implementation in
The codebase itself already acknowledges the problem in a comment inside
"Clipboard from Excel, Word, etc are format no. 49161. This is object. WE should know how to handle this." 0-cite-2
This means when Excel copies a sheet fragment, it places data in a registered (custom) format with a dynamically assigned numeric ID (e.g.,
To translate a numeric format ID like
The only mention of
The only registered (named) custom formats in FWH are
File: source/classes/clipbrd.prg (L197-199)
// Notes: Clipboard from Excel,Word,etc are format no. 49161
// This is object. WE should know how to handle this
// We can get text part of it as CF_UNICODETEXTFile: source/classes/clipbrd.prg (L201-209)
if ::Open()
cText = GetClpData( CF_UNICODETEXT )
if IsText8Bit( cText )
cText = GetClpData( CF_TEXT )
else
cText = UTF16TOUTF8( cText )
endif
::Close()
endifFile: source/classes/clipbrd.prg (L248-265)
function GetClipContentFormat(...)
local aParams := HB_AParams()
if Len( aParams ) == 1 .and. ValType( aParams[ 1 ] ) == 'A'
aParams := aParams[ 1 ]
endif
if Empty( aParams ) .or. Empty( aParams[ 1 ] )
aParams := nil
else
if AScan( aParams, 1 ) > 0 .and. ;
AScan( aParams, 13 ) == 0
AAdd( aParams, 13 )
endif
endif
return GETPRIORITYCLIPBOARDFORMAT( aParams )File: source/winapi/clpbrd.c (L146-147)
// if( ( wType == CF_TEXT ) && ( EnumClipboardFormats( 0 ) == CF_UNICODETEXT ) )
// wType = CF_UNICODETEXT;File: source/winapi/clpbrd.c (L198-217)
HB_FUNC (GETPRIORITYCLIPBOARDFORMAT)
{
int uFormat;
UINT auPriorityList[] = { CF_UNICODETEXT, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15 };
int iFormats = 15;
int i;
if ( HB_ISARRAY( 1 ) )
{
iFormats = ( int ) hb_parinfa( 1, 0 );
for ( i = 0; i < iFormats; i++ )
{
auPriorityList[ i ] = hb_parvni( 1, i + 1 );
}
}
uFormat = GetPriorityClipboardFormat( auPriorityList, iFormats );
// if ( uFormat == NULL ) { uFormat = 0; }
hb_retni( uFormat );
}File: source/function/fgetclip.c (L11-12)
static far char GTF[] = "Get Text Format";
static far char RTF[] = "Rich Text Format";Thanks !!!