Hi all,
The tests were done with REALbasic 2007r2 Pro on Mac OS X on a PowerBook G4 Alu
15", 1.5GHz with 512 MB of RAM and some software opens (notably Netscape 7.2).
First of all, I tested Sven Example and found / get the same result. But I do
not liked to stop there. So...
I pushed a bit further Sven example:
In a brand new project, I added two PushButtons (Read RTF / Write RTF) and one
EditField (EFrtf). I also added a File type (application/rtf), see the code
below.
Test #1:
Run in the IDE and load a test rtf file (the one I found).
Result:
Crash where Sven says.
Test #2:
Run in the IDE,
Copy a Styled Text from TextEdit (the rtf file I used in Test #1),
Paste the Styled Text in the Styled EditField,
Click in the Write RTF and save the RTF data,
Clears the EditField contents,
Click in the Read RTF and choose the just saved RTF data
Result:
No crash. BUT:
1. The text size are different,
2. One color are different (Blue 255 probably, is now Majenta)
3. The copyright character and the typographic apostophe (a greek word !) are
correct, but { and } are no more there while [ and ] are there!
The blue color that is changed to Majenta is Myrtille in the Crayons palette
(pen palette).
NOTA: this is not the only color change, there are others; I do not wanted to
waste my time since it is certainly faster to check the sources (IMHO).
My blue color definition (on disk, the file that crash) is:
\red0\green0\blue255;
Your "Majenta" color is (as saved to disk): \red236\green0\blue255;
Other differences are in the > 127 RTF encoded characters; in the original
file, d5 stands for ’ (the typographical apostrophe) but in the REALbasic
generated file, the character is: \u8247 (with an ending space).
The text size are all 13 pixels where the two first lines were 24 pixels (Arial
Black, 24 pixels, Blue and Green), the third line is Helvetica Regular 10
pixels, black; the fourth line is 14 pixels (Arial Black 14 pixels, black -
that line starts with a copyright character) and the rest of the text is 12
pixels, some are Courier, some are Times New Roman, Helvetica Regular 12 (red),…
The missing curly braces:
{Not Fade Away}
Courier Regular 12, Blue
NOTA: the missing { and } are present in the REALbasic generated rtf file. What
is misses is the escape character (\).
<REAL MY RANT MESSAGE, SENT AFTER THIS ONE>
No, I decided to not send the message at all.
The RTF implementation is so bad IMHO that I prefered to not talk anymore on it.
In case you want to see the rtf file, I can share it (it is a description of
The Rolling Stones first LP in the USA - London PS 375, May 375). [NOT NEEDED,
DO YOUR JOB AND IT WILL BE ENOUGH]
Now, please, answer the question:
I am not surprised by the color change, why ?
[My answer: I already saw that on a previous REALbasic release!]
Emile
In Read RTF Action:
-------------------
Sub Action()
dim my_rtfStr as String
dim f as FolderItem
my_rtfStr = ""
f = GetOpenFolderItem("application/rtf")
if f <> nil and f.Exists then
dim i as TextInputStream
i = f.OpenAsTextFile
if i <> nil then
my_rtfStr = i.ReadAll
i.close
EFrtf.StyledText.RTFData = my_rtfStr // <<-------------- NIL
end if ' nil
end if ' exist
End Sub
NOTA: I changed a bit Sven code as follows
a. I used GetOpenFolderItem instead of GetFolderItem
b. I modified his variable: my_rtfStr instead of rtfStr
c. I initialized the my_rtfStr string variable
In Write RTF Action:
-------------------
Sub Action()
Dim s as TextOutputStream
Dim f as FolderItem
f = GetSaveFolderItem("application/rtf","TestSaveRTF")
s = f.CreateTextFile
s.Write EFrtf.StyledText.RTFData
s.Close
End Sub
In application/rtf:
-------------------
Display Name: application/rtf
Object Name: ApplicationRtf Auto generated
MacType: RTFf
MacCreator: ttxt
Extensions: rtf
>Date: Tue, 3 Apr 2007 07:32:47 +0200
>From: Sven E Olsson <[EMAIL PROTECTED]>
>Subject: Re: RTF Import in 2007r2
>To: REALbasic NUG <[email protected]>
>
>On 2007-04-03, at 05:35, Brendan Murphy wrote:
>
>>> I would like warn those who are intending to use the new RTF
>>> import feature in the StyledText object to be careful. Their RTF
>>> parser is not robust and will crash and burn given the right input
>>> (see feedback report "xfqdvyyl"). If you intend to import RTF data
>>> from arbitrary sources such as other word processors, there is a
>>> significant probability that it may crash your application. If
>>> can't control the source of the input RTF, then you are rolling
>>> the dice. So buyer beware.
>
>
>
>On OS X 10.4.9 Intel...
>I can't get it to work at all, perhaps I do something wrong.. The
>test file is is just "hello" saved using TextEdit
>
> dim rtfStr as String
> dim f as FolderItem
>
> f = GetFolderItem("hello.rtf")
>
> if f <> nil and f.Exists then
>
> dim i as TextInputStream
> i = f.OpenAsTextFile
> if i <> nil then
> rtfStr = i.ReadAll
> i.close
> EditField1.StyledText.RTFData = rtfStr <<-------------- NIL
> end if ' nil
>
> end if ' exist
>
> ------------------------
>Sven E
--
Q: Do you know why the bug introduced in version 2 (a true error, this happens
sometimes) have to wait until version 2 to be squashed ?
A: My users have to update its purchase plan to get version 3 ?
Q: Hey, my current plan ends some days after the release of version 2. Why must
have I to renew my update plan to get a version without that bug ?
"No, I am not doing bad thinking Monique, I am just explaining the things."
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>