Discussion:
MLTE to RTF trouble...
(too old to reply)
j***@yahoo.com
2006-03-16 16:23:05 UTC
Permalink
Hi,

I'm using an MLTEPane derived class (CMLTEView) to display formatted
text with bold, italic... and colours.
I'm trying to export it to RTF but with some trouble: (running OS X.3.5
with CW 9.5)
the colours are not exported: i.e. the whole text is black on white in
the resulting RTF.

I get:
{\colortbl;\red255\green255\blue255;\red0\green0\blue0;}
instead of:
{\colortbl;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;
\red127\green0\blue0;
\red0\green127\blue127;} for instance...

If I copy and paste the same text in another MLTEPane or in TextEdit
the colours are OK in that new window but not in the data gotten from
the RTF export (in the pRTF pointer below).

What is more the exported RTF is in MacRoman (ansicp10000). I would
like to export it for my Windows colleagues using CP1252 but how can I
ask TXNFlattenObjectToCFDataRef to do so?

Here is the code:

bool CMLTEView::StreamOutRTF()
{
CFDataRef rDataRef;
OSStatus status = ::TXNFlattenObjectToCFDataRef(mTXNObject,
kTXNRichTextFormatData, &rDataRef);
if(noErr!=status)
return false;

CFStringRef rString =
::CFStringCreateFromExternalRepresentation(kCFAllocatorDefault,
rDataRef, kCFStringEncodingMacRoman); // Here data in rDataRef are
already in MacRoman...
::CFRelease(rDataRef);
if(!rString)
return false;

CFIndex nFCIndex = ::CFStringGetLength(rString);
if(!nFCIndex)
return false;

++nFCIndex;
char* pRTF = new char[nFCIndex];
if(!::CFStringGetCString(rString, pRTF, nFCIndex,
kCFStringEncodingMacRoman))
{
::CFRelease(rString);
return false;
}

// Do my things with pRTF...

delete [] pRTF;
::CFRelease(rString);
return true;
}

Thanks in advance for your help.

Regards, MacPorter.
James W. Walker
2006-03-16 17:29:34 UTC
Permalink
Post by j***@yahoo.com
I'm using an MLTEPane derived class (CMLTEView) to display formatted
text with bold, italic... and colours.
I'm trying to export it to RTF but with some trouble: (running OS X.3.5
with CW 9.5)
the colours are not exported: i.e. the whole text is black on white in
the resulting RTF.
I don't know the answers to your questions, but I think they have
little to do with PowerPlant. You might be better off asking on the
carbon-dev mailing list.
j***@yahoo.com
2006-03-16 19:26:58 UTC
Permalink
Post by James W. Walker
Post by j***@yahoo.com
I'm using an MLTEPane derived class (CMLTEView) to display formatted
text with bold, italic... and colours.
I'm trying to export it to RTF but with some trouble: (running OS X.3.5
with CW 9.5)
the colours are not exported: i.e. the whole text is black on white in
the resulting RTF.
I don't know the answers to your questions, but I think they have
little to do with PowerPlant.
My trouble might be Carbon-specific but since LMLTEPane is a PowerPlant
class they could come from it that's why I posted here...
Sorry for bugging you...
Post by James W. Walker
You might be better off asking on the
carbon-dev mailing list.
I guess you mean http://lists.apple.com/mailman/listinfo/carbon-dev...

Thanks

Loading...