How can I deal with RTF better in my NSTextView?
How can I deal with RTF better in my NSTextView?
- Subject: How can I deal with RTF better in my NSTextView?
- From: Evan Gross <email@hidden>
- Date: Tue, 31 Dec 2002 20:13:05 -0500
Hi,
I've been running into some real nasty issues (that my customers are
definitely going to notice) related to copying and pasting RTF between my
app and (pretty much any, but primarily Word) Microsoft app. My app is
(primarily) a spelling checker, one of the ways it works is via the
pasteboard - telling the "host" app to copy its selection, the user makes
changes/corrections in my app, viewed in a NSTextView, then when finished
the NSTextView's contents are copied to the pasteboard and pasted back in
over the original app's selection.
This is turning out to be a real problem with apps (primarily MS Word) that
generate RTF that can't be dealt with by the OS's (AppKit's?) RTF
translators. It's even a problem with any app that uses MLTE (which can be
configured to place RTF on the pasteboard). In fact, if an MLTE selection
contains graphics, NSAttributedString totally barfs (logs an exception) when
it tries to convert the RTF into an attributed string - easy to see if you
try copying from the MLTE sample from the CarbonLib SDK and pasting into
(say) TextEdit. But I digress...
So the big question is, just what do I have to do (and how
involved/possible/impossible would it be) to somehow parse the RTF myself,
and instead of tossing any RTF control codes that I can't directly deal
with, just preserve them somehow so that copying from my NSTextView does
what I want? I've looked at filter services, replacing the backing store by
subclassing NSTextStorage, using AppleScript and a few other things, but the
best way isn't really clear to me at this point. Nothing I've looked at
seems terribly easy, that's for sure.
It's not just that tables go away, but all graphics, all kinds of breaks
(section, page) and many other kinds of formatting just get totally lost in
the translation. This might not be so terrible if RTF with embedded graphics
could be translated to/from RTFD, but it just doesn't happen (actually, I9d
like to be able to deal with this myself somehow, translating the images in
RTF to attachments somehow).
Ideas?
Evan Gross
Rainmaker Research Inc.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.