Skip to content

Commit

Permalink
Fix RTF clipboard tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bpieber committed Sep 17, 2023
1 parent f7d3764 commit b5d5ed7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
22 changes: 11 additions & 11 deletions RTFExporting.pck.st
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
'From Cuis 6.0 [latest update: #6025] on 14 September 2023 at 9:00:56 am'!
'From Cuis 6.0 [latest update: #6032] on 17 September 2023 at 7:56:05 pm'!
'Description Please enter a description for this package.'!
!provides: 'RTFExporting' 1 4!
!provides: 'RTFExporting' 1 5!
!requires: 'Graphics-Files-Additional' 1 nil nil!



!String methodsFor: '*rtfExporting' stamp: 'jmv 9/5/2016 20:27:00'!
iso8859s15ToRTFEncoding
"Convert the given string to RTF escaped Unicode from the internal encoding: ISO Latin 9 (ISO 8859-15)"
!CharacterSequence methodsFor: '*rtfExporting' stamp: 'bp 9/17/2023 19:54:03'!
asUnicodeRTF
"Convert the given character sequence to Unicode RTF"
"
self assert: ('A¢€' iso8859s15ToRTFEncoding) hex = ' 'A\u162?\u8364?''
self assert: 'A¢€' rtfString = 'A\u162?\u8364?'
"
| c cp |
^String streamContents: [ :strm | | characters |
characters _ self readStream.
characters := self readStream.
[ characters atEnd ] whileFalse: [
c _ characters next.
cp _ c codePoint.
c := characters next.
cp := c codePoint.
cp < 128
ifTrue: [ strm nextPut: c ]
ifFalse: [
Expand All @@ -26,7 +26,7 @@ iso8859s15ToRTFEncoding
cp printOn: strm.
strm nextPut: $? ]]]! !

!Text methodsFor: '*rtfExporting' stamp: 'bp 9/13/2023 19:29:46'!
!Text methodsFor: '*rtfExporting' stamp: 'bp 9/17/2023 19:54:47'!
rtfString
"
| text |
Expand Down Expand Up @@ -68,7 +68,7 @@ rtfString
"Add string now"
s := string copyFrom: actualStart to: stop.
s := s withLineEndings: '\par '.
s := s iso8859s15ToRTFEncoding.
s := s asUnicodeRTF.
strm nextPutAll: s.
prevAttributes := currentAttributes ].
strm nextPut: $} ]
Expand Down
62 changes: 31 additions & 31 deletions StyledText.pck.st
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'From Cuis 6.0 [latest update: #6032] on 17 September 2023 at 6:06:09 pm'!
'From Cuis 6.0 [latest update: #6032] on 17 September 2023 at 8:00:49 pm'!
'Description Please enter a description for this package.'!
!provides: 'StyledText' 1 62!
!requires: 'Cuis-Base' 60 5718 nil!
Expand Down Expand Up @@ -3301,140 +3301,140 @@ testOldInstanceDeserialization
self shouldnt: [ newInstance undoRedoCommands ] raise: Exception.
! !

!StyledTextTest methodsFor: 'tests' stamp: 'jmv 3/14/2012 09:49'!
!StyledTextTest methodsFor: 'tests' stamp: 'bp 9/17/2023 20:00:37'!
testSample1ToAndFromRTFClipboardStyle
"
StyledTextTest new testSample1ToAndFromRTFClipboardStyle
"
| text text2 |
text _ RTFConversionTest textSample1.
text := RTFConversionTest textSample1.

"This will use a refStreamed object"
Clipboard default storeObject: text.
text2 _ Clipboard default retrieveObject.
text2 := Clipboard default retrieveObject.
self assert: text2 = text.
self assert: text2 runs = text runs.

"This will also test storing and retrieving RTF data from platform Clipboard, and RTF conversion"
ExtendedClipboardInterface current
clearClipboard;
addClipboardData: text rtfString dataFormat: 'public.rtf'.
text2 _ Clipboard default retrieveObject.
addClipboardData: text rtfString asUtf8Bytes dataFormat: 'public.rtf'.
text2 := Clipboard default retrieveObject.
self assert: text2 = text.
self assert: text2 asNonStyledText runs = text runs.! !

!StyledTextTest methodsFor: 'tests' stamp: 'jmv 4/2/2016 14:48'!
!StyledTextTest methodsFor: 'tests' stamp: 'bp 9/17/2023 20:00:30'!
testSample2ToAndFromRTFClipboardStyle
"
StyledTextTest new testSample2ToAndFromRTFClipboardStyle
"
| text text2 |
self assert: Clipboard default extendedClipboardInterface canStore description: 'Extended Clipboard cant store'.
text _ RTFConversionTest textSample2.
text := RTFConversionTest textSample2.

"This will use a refStreamed object"
Clipboard default storeObject: text.
text2 _ Clipboard default retrieveObject.
text2 := Clipboard default retrieveObject.
self assert: text2 = text.
self assert: text2 runs = text runs.

"This will also test storing and retrieving RTF data from platform Clipboard, and RTF conversion"
ExtendedClipboardInterface current
clearClipboard;
addClipboardData: text rtfString dataFormat: 'public.rtf'.
text2 _ Clipboard default retrieveObject.
addClipboardData: text rtfString asUtf8Bytes dataFormat: 'public.rtf'.
text2 := Clipboard default retrieveObject.
self assert: text2 = text.
self assert: text2 asNonStyledText runs = text runs.! !

!StyledTextTest methodsFor: 'tests' stamp: 'jmv 3/14/2012 09:50'!
!StyledTextTest methodsFor: 'tests' stamp: 'bp 9/17/2023 20:00:20'!
testSample3ToAndFromRTFClipboardStyle
"
StyledTextTest new testSample3ToAndFromRTFClipboardStyle
"
| text text2 |
text _ RTFConversionTest textSample3.
text := RTFConversionTest textSample3.

"This will use a refStreamed object"
Clipboard default storeObject: text.
text2 _ Clipboard default retrieveObject.
text2 := Clipboard default retrieveObject.
self assert: text2 = text.
self assert: text2 runs = text runs.

"This will also test storing and retrieving RTF data from platform Clipboard, and RTF conversion"
ExtendedClipboardInterface current
clearClipboard;
addClipboardData: text rtfString dataFormat: 'public.rtf'.
text2 _ Clipboard default retrieveObject.
addClipboardData: text rtfString asUtf8Bytes dataFormat: 'public.rtf'.
text2 := Clipboard default retrieveObject.
self assert: text2 = text.
self assert: text2 asNonStyledText runs = text runs.! !

!StyledTextTest methodsFor: 'tests' stamp: 'jmv 3/14/2012 09:50'!
!StyledTextTest methodsFor: 'tests' stamp: 'bp 9/17/2023 20:00:13'!
testSample4ToAndFromRTFClipboardStyle
"
StyledTextTest new testSample4ToAndFromRTFClipboardStyle
"
| text text2 |
text _ RTFConversionTest textSample4.
text := RTFConversionTest textSample4.

"This will use a refStreamed object"
Clipboard default storeObject: text.
text2 _ Clipboard default retrieveObject.
text2 := Clipboard default retrieveObject.
self assert: text2 = text.
self assert: text2 runs = text runs.

"This will also test storing and retrieving RTF data from platform Clipboard, and RTF conversion"
ExtendedClipboardInterface current
clearClipboard;
addClipboardData: text rtfString dataFormat: 'public.rtf'.
text2 _ Clipboard default retrieveObject.
addClipboardData: text rtfString asUtf8Bytes dataFormat: 'public.rtf'.
text2 := Clipboard default retrieveObject.
self assert: text2 = text.
"kern and struckThrough not supported in rtf yet..."
" self assert: text2 asNonStyledText runs = text runs."
" self assert: text2 usesOnlyStyles description: 'If not using the RTFStyledTextBuilder, next assert makes no sense.'."
"kern and struckThrough not supported in rtf yet..."
" self assert: text2 runs = text asStyledText runs"! !

!StyledTextTest methodsFor: 'tests' stamp: 'jmv 3/14/2012 09:50'!
!StyledTextTest methodsFor: 'tests' stamp: 'bp 9/17/2023 20:00:06'!
testSample5ToAndFromRTFClipboardStyle
"
StyledTextTest new testSample5ToAndFromRTFClipboardStyle
"
| text text2 |
text _ RTFConversionTest textSample5.
text := RTFConversionTest textSample5.

"This will use a refStreamed object"
Clipboard default storeObject: text.
text2 _ Clipboard default retrieveObject.
text2 := Clipboard default retrieveObject.
self assert: text2 = text.
self assert: text2 runs = text runs.

"This will also test storing and retrieving RTF data from platform Clipboard, and RTF conversion"
ExtendedClipboardInterface current
clearClipboard;
addClipboardData: text rtfString dataFormat: 'public.rtf'.
text2 _ Clipboard default retrieveObject.
addClipboardData: text rtfString asUtf8Bytes dataFormat: 'public.rtf'.
text2 := Clipboard default retrieveObject.
self assert: text2 = text.
self assert: text2 asNonStyledText runs = text runs.! !

!StyledTextTest methodsFor: 'tests' stamp: 'jmv 3/14/2012 09:50'!
!StyledTextTest methodsFor: 'tests' stamp: 'bp 9/17/2023 19:29:35'!
testSample6ToAndFromRTFClipboardStyle
"
StyledTextTest new testSample6ToAndFromRTFClipboardStyle
"
| text text2 |
text _ RTFConversionTest textSample6.
text := RTFConversionTest textSample6.

"This will use a refStreamed object"
Clipboard default storeObject: text.
text2 _ Clipboard default retrieveObject.
text2 := Clipboard default retrieveObject.
self assert: text2 = text.
self assert: text2 runs = text runs.

"This will also test storing and retrieving RTF data from platform Clipboard, and RTF conversion"
ExtendedClipboardInterface current
clearClipboard;
addClipboardData: text rtfString dataFormat: 'public.rtf'.
text2 _ Clipboard default retrieveObject.
addClipboardData: text rtfString asUtf8Bytes dataFormat: 'public.rtf'.
text2 := Clipboard default retrieveObject.
self assert: text2 = text.
self assert: text2 asNonStyledText runs = text runs.! !

Expand Down

0 comments on commit b5d5ed7

Please sign in to comment.