[squeak-dev] The Trunk: System-mt.1408.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Mar 31 13:46:28 UTC 2023


Marcel Taeumel uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-mt.1408.mcz

==================== Summary ====================

Name: System-mt.1408
Author: mt
Time: 31 March 2023, 3:46:27.004258 pm
UUID: 7f2615f1-de4b-e94c-afc2-c6db47d95633
Ancestors: System-mt.1407

Make ExtendedClipboardWinInterface compatible with latest platform code:
https://github.com/OpenSmalltalk/opensmalltalk-vm/commit/ed1f7431a09f044488a85f9d275994d6def7b670

Avoid in-image use of CF_UNICODE and let CF_UTF8TEXT handle that consistently.

Try reading the PNG data from the Windows Snipping Tool or copy a shape from PowerPoint and read CF_BITMAP. See #readFormClipboardData. More work needed. :-)

=============== Diff against System-mt.1407 ===============

Item was added:
+ ----- Method: Clipboard class>>extended (in category 'accessing') -----
+ extended
+ 	
+ 	^ ExtendedClipboardInterface current!

Item was added:
+ ----- Method: Clipboard>>extended (in category 'accessing') -----
+ extended
+ 	"Answer an object representing the extended clipboard interface."
+ 	
+ 	^ self class extended!

Item was changed:
  ----- Method: ExtendedClipboardInterface>>initialize (in category 'initialize-release') -----
  initialize
  
- 	super initialize.
- 
  	clipboard := [self primCreateClipboard]
  		on: Error
  		do: [:ex | clipboard := 0].!

Item was changed:
  ExtendedClipboardInterface subclass: #ExtendedClipboardWinInterface
  	instanceVariableNames: ''
+ 	classVariableNames: 'CF_BITMAP CF_DIB CF_DIBV5 CF_HDROP CF_HTMLTEXT CF_LOCALE CF_OEMTEXT CF_PALETTE CF_PENDATA CF_PRIVATELAST CF_RIFF CF_TEXT CF_TIFF CF_UTF8TEXT CF_WAVE SQCF_GIF SQCF_HTML SQCF_MIME_BMP SQCF_MIME_GIF SQCF_MIME_HTML SQCF_MIME_JPEG SQCF_MIME_MPEG SQCF_MIME_PDF SQCF_MIME_PNG SQCF_MIME_RAW SQCF_MIME_RICHTEXT SQCF_MIME_RTF SQCF_MIME_SVG SQCF_MIME_TEXT SQCF_MIME_TEXTUTF8 SQCF_MIME_TIFF SQCF_MIME_WAV SQCF_MIME_XHTML SQCF_MIME_XML SQCF_PNG SQCF_RTF'
- 	classVariableNames: 'CF_BITMAP CF_DIB CF_DIBV5 CF_HDROP CF_HTMLTEXT CF_LOCALE CF_OEMTEXT CF_PALETTE CF_PENDATA CF_PRIVATELAST CF_RIFF CF_TEXT CF_TIFF CF_UNICODETEXT CF_UTF8TEXT CF_WAVE'
  	poolDictionaries: ''
  	category: 'System-Clipboard'!

Item was changed:
  ----- Method: ExtendedClipboardWinInterface class>>initializeClipboardFormatMap (in category 'class initialization') -----
  initializeClipboardFormatMap
- 	"ExtendedClipboardWinInterface initializeClipboardFormatMap"
- 	CF_TEXT := 1.
- 	CF_BITMAP := 2.
- 	"CF_METAFILEPICT := 3.
- 	CF_SYLK := 4.
- 	CF_DIF := 5."
- 	CF_TIFF := 6.
- 	CF_OEMTEXT := 7.
- 	CF_DIB := 8.
- 	CF_PALETTE := 9.
- 	CF_PENDATA := 10.
- 	CF_RIFF := 11.
- 	CF_WAVE := 12.
- 	CF_UNICODETEXT := 13.
- 	"CF_ENHMETAFILE := 14."
- 	CF_HDROP := 15.
- 	CF_LOCALE := 16.
- 	CF_DIBV5 := 17.
  
- 	"CF_OWNERDISPLAY := 16r0080.
- 	CF_DSPTEXT := 16r0081.
- 	CF_DSPBITMAP := 16r0082.
- 	CF_DSPMETAFILEPICT := 16r0083.
- 	CF_DSPENHMETAFILE  := 16r008E.
- 	CF_PRIVATEFIRST := 16r0200."
- 	CF_PRIVATELAST := 16r02FF.
- 	CF_UTF8TEXT := CF_PRIVATELAST. "extension to the Windows ClipboardExtendedPlugin..."
- 	"CF_GDIOBJFIRST := 16r0300.
- 	CF_GDIOBJLAST := 16r03FF."
- 	CF_HTMLTEXT := 49358. "a.k.a. 16rC0CE this is used by both Chrome and Edge when one selects HTML there-in."
- 
  	clipboardFormatMap := Dictionary new.
- 	"at: 6 put: 'image/tiff' asMIMEType; CF_TIFF"
  
+ 	self initializeClipboardStandardFormatMap.
+ 	self initializeClipboardRegisteredFormatMap.	!
- 	clipboardFormatMap
- 		at: 49510 put: 'text/rtf' asMIMEType; 
- 		at: 1 put: 'text/plain' asMIMEType; "CF_TEXT"
- 		at: 2 put: 'image/bmp' asMIMEType; "CF_BITMAP"
- 		at: 12 put: 'audio/wave'; "CF_WAVE"
- 		at: 13 put: 'text/unicode' asMIMEType; "CF_UNICODETEXT"
- 		at: 16 put: 'CF_LOCALE'; "CF_LOCALE"
- 		yourself.
- 
- 
- !

Item was added:
+ ----- Method: ExtendedClipboardWinInterface class>>initializeClipboardRegisteredFormatMap (in category 'class initialization') -----
+ initializeClipboardRegisteredFormatMap
+ 	"https://learn.microsoft.com/en-us/windows/win32/dataxchg/clipboard-formats#registered-clipboard-formats
+ 	
+ 	ExtendedClipboardWinInterface initializeClipboardRegisteredFormatMap
+ 	"
+ 	
+ 	SQCF_HTML := 16r10001.
+ 	SQCF_RTF := 16r10002.
+ 	SQCF_PNG := 16r10003.
+ 	SQCF_GIF := 16r10004.
+ 
+ 	clipboardFormatMap
+ "		at: SQCF_HTML put: 'text/html' asMIMEType;"
+ 		at: SQCF_HTML put: 'HTML Format';
+ "		at: SQCF_RTF put: 'text/rtf' asMIMEType;
+ 		at: SQCF_RTF put: 'text/richtext' asMIMEType;"
+ 		at: SQCF_RTF put: 'Rich Text Format';				
+ "		at: SQCF_PNG put: 'image/png' asMIMEType;"
+ 		at: SQCF_PNG put: 'PNG';
+ "		at: SQCF_GIF put: 'image/gif' asMIMEType;"
+ 		at: SQCF_GIF put: 'GIF';		
+ 		yourself.
+ 
+ 	SQCF_MIME_TEXT := 16r20001.
+ 	SQCF_MIME_TEXTUTF8 := 16r20002.
+ 	SQCF_MIME_RICHTEXT := 16r20003.
+ 	SQCF_MIME_RTF := 16r20004.
+ 	SQCF_MIME_WAV := 16r20005.
+ 	SQCF_MIME_GIF := 16r20006.
+ 	SQCF_MIME_JPEG := 16r20007.
+ 	SQCF_MIME_TIFF := 16r20008.
+ 	SQCF_MIME_PNG := 16r20009.
+ 	SQCF_MIME_SVG := 16r2000A.
+ 	SQCF_MIME_BMP := 16r2000B.
+ 	SQCF_MIME_MPEG := 16r2000C.
+ 	SQCF_MIME_RAW := 16r2000D.
+ 	SQCF_MIME_PDF := 16r2000E.
+ 	SQCF_MIME_XHTML := 16r2000F.
+ 	SQCF_MIME_HTML := 16r20010.
+ 	SQCF_MIME_XML := 16r20011.
+ 	
+ 	clipboardFormatMap
+ 		at: SQCF_MIME_TEXT put: 'text/plain' asMIMEType;
+ 		at: SQCF_MIME_TEXTUTF8 put: 'text/plain;charset=utf-8' asMIMEType;
+ 		at: SQCF_MIME_RICHTEXT put: 'text/richtext' asMIMEType;
+ 		at: SQCF_MIME_RTF put: 'application/richtext' asMIMEType;
+ 		at: SQCF_MIME_WAV put: 'audio/wav' asMIMEType;
+ 		at: SQCF_MIME_GIF put: 'image/gif' asMIMEType;
+ 		at: SQCF_MIME_JPEG put: 'image/jpeg' asMIMEType;
+ 		at: SQCF_MIME_TIFF put: 'image/tiff' asMIMEType;
+ 		at: SQCF_MIME_PNG put: 'image/png' asMIMEType;
+ 		at: SQCF_MIME_SVG put: 'image/svg+xml' asMIMEType;
+ 		at: SQCF_MIME_BMP put: 'image/bmp' asMIMEType;
+ 		at: SQCF_MIME_MPEG put: 'video/mpeg' asMIMEType;
+ 		at: SQCF_MIME_RAW put: 'application/octet-stream' asMIMEType;
+ 		at: SQCF_MIME_PDF put: 'application/pdf' asMIMEType;
+ 		at: SQCF_MIME_XHTML put: 'application/xhtml+xml' asMIMEType;
+ 		at: SQCF_MIME_HTML put: 'text/html' asMIMEType;
+ 		at: SQCF_MIME_XML put: 'text/xml' asMIMEType;
+ 		yourself.!

Item was added:
+ ----- Method: ExtendedClipboardWinInterface class>>initializeClipboardStandardFormatMap (in category 'class initialization') -----
+ initializeClipboardStandardFormatMap
+ 	"https://learn.microsoft.com/en-us/windows/win32/dataxchg/standard-clipboard-formats
+ 	
+ 	ExtendedClipboardWinInterface initializeClipboardFormatMap
+ 	"
+ 	
+ 	CF_TEXT := 1.
+ 	CF_BITMAP := 2.
+ 	"CF_METAFILEPICT := 3.
+ 	CF_SYLK := 4.
+ 	CF_DIF := 5."
+ 	CF_TIFF := 6.
+ 	CF_OEMTEXT := 7.
+ 	CF_DIB := 8.
+ 	CF_PALETTE := 9.
+ 	CF_PENDATA := 10.
+ 	CF_RIFF := 11.
+ 	CF_WAVE := 12.
+ 	"CF_UNICODETEXT := 13. -- unused in image, see CF_UTF8TEXT"
+ 	"CF_ENHMETAFILE := 14."
+ 	CF_HDROP := 15.
+ 	CF_LOCALE := 16.
+ 	CF_DIBV5 := 17.
+ 
+ 	"CF_OWNERDISPLAY := 16r0080.
+ 	CF_DSPTEXT := 16r0081.
+ 	CF_DSPBITMAP := 16r0082.
+ 	CF_DSPMETAFILEPICT := 16r0083.
+ 	CF_DSPENHMETAFILE  := 16r008E.
+ 	CF_PRIVATEFIRST := 16r0200."
+ 	CF_PRIVATELAST := 16r02FF.
+ 	CF_UTF8TEXT := CF_PRIVATELAST. "extension to the Windows ClipboardExtendedPlugin..."
+ 	"CF_GDIOBJFIRST := 16r0300.
+ 	CF_GDIOBJLAST := 16r03FF."
+ 
+ 	clipboardFormatMap
+ 		at: CF_UTF8TEXT put: 'text/unicode' asMIMEType;
+ 		at: CF_TEXT put: 'text/plain' asMIMEType;
+ 		at: CF_OEMTEXT put: 'OEM Text';
+ 		at: CF_BITMAP put: 'image/bmp' asMIMEType;
+ "		at: CF_DIB put: 'image/bmp' asMIMEType;
+ 		at: CF_DIBV5 put: 'image/bmp' asMIMEType;		
+ "		at: CF_WAVE put: 'audio/wav' asMIMEType;
+ 		at: CF_LOCALE put: 'Locale Identifier';
+ 		at: CF_TIFF put: 'image/tiff' asMIMEType;
+ 		yourself.
+ 
+ 
+ !

Item was changed:
  ----- Method: ExtendedClipboardWinInterface class>>initializeMimeTypeMap (in category 'class initialization') -----
  initializeMimeTypeMap
  	"ExtendedClipboardWinInterface initializeMimeTypeMap"
  
+ 	self flag: #todo.
  	mimeTypeMap := Dictionary new.
  	mimeTypeMap
  		at: 'text/rtf' asMIMEType put: 49510; 
  		at: 'text/plain' asMIMEType put: 1; "CF_TEXT"
  		at: 'image/*' asMIMEType put: 2; "CF_BITMAP"
  		at: 'metafile' put: 3; "CF_METAFILEPICT"
  		at: 'CF_SYLK' put: 4; "CF_SYLK"
  		at: 'CF_DIF' put: 5; "CF_DIF"
  		at: 'image/tiff' asMIMEType put: 6; "CF_TIFF"
  		at: 'oemtext' put: 7; "CF_OEMTEXT"
  		at: 'CF_DIB' put: 8; "CF_DIB"
  		at: 'CF_PALETTE' put: 9; "CF_PALETTE"
  		at: 'CF_PENDATA' put: 10; "CF_PENDATA"
  		at: 'CF_RIFF' put: 11; "CF_RIFF"
  		at: 'wave' put: 12; "CF_WAVE"
  		at: 'text/unicode' asMIMEType put: 13; "CF_UNICODETEXT"
  		at: 'CF_ENHMETAFILE' put: 14; "CF_ENHMETAFILE"
  		at: 'CF_HDROP' put: 15; "CF_HDROP"
  		at: 'CF_LOCALE' put: 16; "CF_LOCALE"
  		at: 'CF_DIBV5' put: 17; "CF_DIBV5"
  		yourself
  !

Item was changed:
+ ----- Method: ExtendedClipboardWinInterface>>clipboardText: (in category 'accessing') -----
- ----- Method: ExtendedClipboardWinInterface>>clipboardText: (in category 'private') -----
  clipboardText: aText
  	"Attempt to paste aText to the system clipboard in as many formats as makes sense on the platform.
  	 Answer if the attempt succeeded.  On Windows we paste HTML and UTF8. But we can only paste more
  	 than one thing at a time with the VMMaker.oscog-eem.3276 version of the plugin, or later.  Note that
  	 the funky HTML format (see packageAsHTML:) has been derived by observing Chrome and Edge."
  	| htmlPayload |
  	(aText isPlainText
  	 or: [clipboard = 0
  	 or: [self class pluginVersion < 3276]]) ifTrue:
  		[^false].
  	htmlPayload := self packageAsHTML: aText printHtmlString.
  	self clearClipboard.
  	"We don't understand why yet, but sometimes the plugin fails to copy HTML text."
+ 	^(self tryAddClipboardData: htmlPayload dataFormat: SQCF_HTML)
- 	^(self tryAddClipboardData: htmlPayload dataFormat: CF_HTMLTEXT)
  	 and: [self tryAddClipboardData: (UTF8TextConverter new encodeString: aText asString) dataFormat: CF_UTF8TEXT]!

Item was added:
+ ----- Method: ExtendedClipboardWinInterface>>convertPNGBytesToForm: (in category 'private') -----
+ convertPNGBytesToForm: aByteArray
+ 
+ 	^ PNGReadWriter formFromStream: aByteArray readStream!

Item was removed:
- ----- Method: ExtendedClipboardWinInterface>>readAvailableFormats (in category 'general-api-read') -----
- readAvailableFormats
- 	
- 	| lastFormat availableFormats |
- 	availableFormats := OrderedCollection new: 10.
- 	lastFormat := 0.
- 	[(lastFormat := self getClipboardFormat: lastFormat) notNil]
- 		whileTrue: [
- 			(self class clipboardFormatMap at: lastFormat ifAbsent: [nil])
- 				ifNotNil: [:mimeType | availableFormats add: mimeType]].
- 	^ availableFormats!

Item was changed:
  ----- Method: ExtendedClipboardWinInterface>>readFormClipboardData (in category 'general-api-read') -----
  readFormClipboardData
  	self readAvailableRawFormats sorted reverseDo:
  		[:format|
  		format
  			caseOf: {
  				[CF_DIBV5]		-> [^self convertDIBV5BytesToForm: (self readClipboardData: format)].
  				[CF_DIB]		-> [^self convertDIBBytesToForm: (self readClipboardData: format)].
+ 				[CF_BITMAP]	-> [^self convertBitmapBytesToForm: (self readClipboardData: format)].
+ 				[SQCF_PNG]	-> [^ self convertPNGBytesToForm: (self readClipboardData: format)].
- 				[CF_BITMAP]	-> [^self convertBitmapBytesToForm: (self readClipboardData: format)]
  			}
  			otherwise: []].
  	^nil!

Item was changed:
  ----- Method: ExtendedClipboardWinInterface>>readWideStringClipboardData (in category 'general-api-read') -----
  readWideStringClipboardData
  
+ 	^ (self hasClipboardData: CF_UTF8TEXT)
- 	^ (self hasClipboardData: CF_UNICODETEXT)
  		ifTrue: [((self readClipboardData: CF_UTF8TEXT) changeClassTo: ByteString) utf8ToSqueak]!



More information about the Squeak-dev mailing list