Partially fix 5.0 SF1 In bug 122807 and hand it to clu per brade request.

This commit is contained in:
ftang 1998-07-15 16:33:40 +00:00
parent 49042cfd9b
commit 1339a4b50d
2 changed files with 77 additions and 38 deletions

View File

@ -21,6 +21,9 @@
#include "edt.h" #include "edt.h"
#include "uintl.h" #include "uintl.h"
#include "intl_csi.h" #include "intl_csi.h"
#include "xp_trace.h"
HoldUpdatesProxy::HoldUpdatesProxy(CEditView &inTextView) : HoldUpdatesProxy::HoldUpdatesProxy(CEditView &inTextView) :
@ -85,7 +88,7 @@ void HoldUpdatesProxy::DocumentChanged( int32 iStartY, int32 iHeight )
AEEventHandlerUPP HTMLInlineTSMProxy::sAEHandler = NewAEEventHandlerProc( AEHandlerTSM ); AEEventHandlerUPP HTMLInlineTSMProxy::sAEHandler = NewAEEventHandlerProc( AEHandlerTSM );
HTMLInlineTSMProxy *HTMLInlineTSMProxy::sCurrentProxy = NULL; // HTMLInlineTSMProxy *HTMLInlineTSMProxy::sCurrentProxy = NULL;
#if _HAVE_FIXES_FOR_REPLACING_AEGIZMOS_ #if _HAVE_FIXES_FOR_REPLACING_AEGIZMOS_
@ -211,7 +214,7 @@ HTMLInlineTSMProxy::Activate( void )
InstallTSMHandlers(); InstallTSMHandlers();
sCurrentProxy = this; // sCurrentProxy = this;
#ifdef Debug_Signal #ifdef Debug_Signal
// check to see if a bug in TSM will be encountered // check to see if a bug in TSM will be encountered
@ -246,7 +249,7 @@ HTMLInlineTSMProxy::Deactivate( void )
RemoveTSMHandlers(); RemoveTSMHandlers();
sCurrentProxy = NULL; // sCurrentProxy = NULL;
err = ::DeactivateTSMDocument( mTSMDocID ); err = ::DeactivateTSMDocument( mTSMDocID );
@ -315,7 +318,7 @@ HTMLInlineTSMProxy::RemoveTSMHandlers( void )
pascal OSErr pascal OSErr
HTMLInlineTSMProxy::AEHandlerTSM( const AppleEvent *inAppleEvent, AppleEvent *outReply, Int32 inRefCon ) HTMLInlineTSMProxy::AEHandlerTSM( const AppleEvent *inAppleEvent, AppleEvent *outReply, Int32 inRefCon )
{ {
// XP_Trace("begin HTMLInlineTSMProxy::AEHandlerTSM\n");
OSErr err = noErr; OSErr err = noErr;
THz oldZone = ::LMGetTheZone(), // Apple bug #115424? THz oldZone = ::LMGetTheZone(), // Apple bug #115424?
@ -332,44 +335,58 @@ HTMLInlineTSMProxy::AEHandlerTSM( const AppleEvent *inAppleEvent, AppleEvent *ou
AESubDesc appleEvent; AESubDesc appleEvent;
AEDescToSubDesc(inAppleEvent, &appleEvent); AEDescToSubDesc(inAppleEvent, &appleEvent);
// ThrowIf_(((Int32)(void *)sCurrentProxy) != appleEvent.KeyedItem(keyAETSMDocumentRefcon).ToInt32());
AESubDesc keySubDesc; AESubDesc keySubDesc;
AEGetKeySubDesc( &appleEvent, keyAETSMDocumentRefcon, &keySubDesc ); AEGetKeySubDesc( &appleEvent, keyAETSMDocumentRefcon, &keySubDesc );
long len; long len;
void *tsmdocrefcon = AEGetSubDescData( &keySubDesc, &len ); Int32 *tsmdocrefcon = (Int32*)AEGetSubDescData( &keySubDesc, &len );
ThrowIf_(NULL == tsmdocrefcon);
ThrowIf_(((Int32)(void *)sCurrentProxy) != ((Int32)tsmdocrefcon));
// XP_Trace("try to get keyAETSMDocumentRefcon\n");
HTMLInlineTSMProxy *proxy = (HTMLInlineTSMProxy *)(*tsmdocrefcon);
AEStream replyStream; AEStream replyStream;
err = AEStream_OpenRecord( &replyStream, 'xxxx' ); err = AEStream_Open( &replyStream);
if ( sCurrentProxy != NULL ) err = AEStream_OpenRecord( &replyStream, typeAERecord );
if ( proxy != NULL )
{ {
switch( inRefCon ) switch( inRefCon )
{ {
case kUpdateActiveInputArea: case kUpdateActiveInputArea:
sCurrentProxy->AEUpdate(appleEvent); // XP_Trace("kUpdateActiveInputArea\n");
proxy->AEUpdate(appleEvent);
break; break;
case kPos2Offset: case kPos2Offset:
XP_Trace("kPos2Offset\n");
sCurrentProxy->AEPos2Offset(appleEvent, replyStream); proxy->AEPos2Offset(appleEvent, replyStream);
break; break;
case kOffset2Pos: case kOffset2Pos:
XP_Trace("kOffset2Pos\n");
sCurrentProxy->AEOffset2Pos(appleEvent, replyStream); proxy->AEOffset2Pos(appleEvent, replyStream);
break; break;
default:
XP_Trace("AppleEvent %c%c%c%c \n", (char)(inRefCon >> 24), (char)((inRefCon >> 16) & 0xff), (char)((inRefCon >> 8) & 0xff), (char)(inRefCon & 0xff) );
Assert_(0);
break;
} }
} }
// XP_Trace("AEStream_CloseRecord\n");
err = AEStream_CloseRecord( &replyStream ); err = AEStream_CloseRecord( &replyStream );
@ -379,6 +396,8 @@ HTMLInlineTSMProxy::AEHandlerTSM( const AppleEvent *inAppleEvent, AppleEvent *ou
// replyStream.Close(outReply); // replyStream.Close(outReply);
// //
StAEDescriptor reply; StAEDescriptor reply;
// XP_Trace("AEStream_Close\n");
err = AEStream_Close( &replyStream, reply ); err = AEStream_Close( &replyStream, reply );
AESubDesc replySD; AESubDesc replySD;
AEDescToSubDesc(reply, &replySD); AEDescToSubDesc(reply, &replySD);
@ -413,6 +432,7 @@ HTMLInlineTSMProxy::AEHandlerTSM( const AppleEvent *inAppleEvent, AppleEvent *ou
#endif _HAVE_FIXES_FOR_REPLACING_AEGIZMOS_ #endif _HAVE_FIXES_FOR_REPLACING_AEGIZMOS_
::LMSetTheZone(oldZone); // Apple bug #115424? ::LMSetTheZone(oldZone); // Apple bug #115424?
// XP_Trace ("end HTMLInlineTSMProxy::AEHandlerTSM\n");
return err; return err;
@ -435,25 +455,42 @@ void HTMLInlineTSMProxy::AEUpdate(
mInputHoleLen = 0; mInputHoleLen = 0;
} }
// get the text in the input hole
AESubDesc keySubDesc;
AEGetKeySubDesc( &inAppleEvent, keyAETheData, &keySubDesc );
int32 textlen; AESubDesc keySubDesc;
Ptr thedata = (char *)AEGetSubDescData( &keySubDesc, &textlen ); long textlen;
ThrowIf_(((Int32)(void *)sCurrentProxy) != ((Int32)(void*)thedata)); long dummylen;
// AESubDesc textSD(inAppleEvent.KeyedItem(keyAETheData), typeChar);
// Get keyAETheData
// fixLength is the number of characters which can be fixed into the buffer. AEGetKeySubDesc( &inAppleEvent, keyAETheData, &keySubDesc );
AESubDesc fixedLengthDesc; Ptr thedata = (char *) AEGetSubDescData( &keySubDesc, &textlen );
AEGetKeySubDesc( &inAppleEvent, keyAEFixLength, &fixedLengthDesc );
// Get keyAEFixLength
Int32 fixLength, lengthlen; AEGetKeySubDesc( &inAppleEvent, keyAEFixLength, &keySubDesc );
fixLength = *(Int32 *)AEGetSubDescData( &fixedLengthDesc, &lengthlen ); Int32 fixLength = *(Int32 *) AEGetSubDescData( &keySubDesc, &dummylen );
// Int32 fixLength = inAppleEvent.KeyedItem(keyAEFixLength).ToInt32();
if (fixLength < 0) // special signal to fix it all!! if (fixLength < 0) // special signal to fix it all!!
fixLength = textlen; fixLength = textlen;
// Get keyAEScriptTag
// Currently do not depend on it.
// Get [optional] keyAEUpdateRange
// Currently do not depend on it.
// Get [optional] keyAEPinRange
// Currently do not depend on it.
// Get [optional] keyAEClauseOffsets
// Currently do not depend on it.
mTextView.EraseCaret(); mTextView.EraseCaret();
mTextView.HideCaret(true); mTextView.HideCaret(true);
@ -489,15 +526,15 @@ void HTMLInlineTSMProxy::AEUpdate(
mInputHoleStart = EDT_GetInsertPointOffset(mContext); // a new starting point for our input hole mInputHoleStart = EDT_GetInsertPointOffset(mContext); // a new starting point for our input hole
} }
AESubDesc hiliteRangeSubDesc; // Get [optional] keyAEHiliteRange
err = AEGetKeySubDesc( &inAppleEvent, keyAEHiliteRange, &hiliteRangeSubDesc ); err = AEGetKeySubDesc( &inAppleEvent, keyAEHiliteRange, &keySubDesc );
XP_ASSERT( hiliteRangeSubDesc != NULL && err == noErr ); XP_ASSERT( keySubDesc != NULL && err == noErr );
if ( err == noErr) { if ( err == noErr) {
// if (inAppleEvent.KeyExists(keyAEHiliteRange)) { // if (inAppleEvent.KeyExists(keyAEHiliteRange)) {
// AESubDesc hiliteSD( hiliteRangeSubDesc, typeTextRangeArray ); // AESubDesc hiliteSD( hiliteRangeSubDesc, typeTextRangeArray );
// TextRangeArrayPtr p = (TextRangeArrayPtr)hiliteSD.GetDataPtr(); // TextRangeArrayPtr p = (TextRangeArrayPtr)hiliteSD.GetDataPtr();
TextRangeArrayPtr p = (TextRangeArrayPtr)AEGetSubDescData( &hiliteRangeSubDesc, &textlen ); TextRangeArrayPtr p = (TextRangeArrayPtr)AEGetSubDescData( &keySubDesc, &dummylen );
for (Int32 i = 0; i < p->fNumOfRanges; i++) { for (Int32 i = 0; i < p->fNumOfRanges; i++) {
TextRange record; TextRange record;
@ -526,6 +563,7 @@ void HTMLInlineTSMProxy::AEPos2Offset(
AEStream &inStream) const AEStream &inStream) const
{ {
// input // input
Point* pWhere;
Point where; Point where;
Boolean dragging; Boolean dragging;
long len; long len;
@ -533,7 +571,9 @@ void HTMLInlineTSMProxy::AEPos2Offset(
AESubDesc subdesc; AESubDesc subdesc;
err = AEGetKeySubDesc( &inAppleEvent, keyAECurrentPoint, &subdesc ); err = AEGetKeySubDesc( &inAppleEvent, keyAECurrentPoint, &subdesc );
where = *(Point *)AEGetSubDescData( &subdesc, &len ); pWhere = (Point *)AEGetSubDescData( &subdesc, &len );
where.h = pWhere->h;
where.v = pWhere->v;
// inAppleEvent.KeyedItem(keyAECurrentPoint).ToPtr(typeQDPoint, &where, sizeof(where)); // inAppleEvent.KeyedItem(keyAECurrentPoint).ToPtr(typeQDPoint, &where, sizeof(where));
@ -636,7 +676,6 @@ void HTMLInlineTSMProxy::AEOffset2Pos(
err = AEGetKeySubDesc( &inAppleEvent, keyAEOffset, &subdesc ); err = AEGetKeySubDesc( &inAppleEvent, keyAEOffset, &subdesc );
long len; long len;
Int32 offset = *(Int32 *)AEGetSubDescData( &subdesc, &len ); Int32 offset = *(Int32 *)AEGetSubDescData( &subdesc, &len );
// Int32 offset = inAppleEvent.KeyedItem(keyAEOffset).ToInt32();
offset += mInputHoleStart; offset += mInputHoleStart;
LO_Element * element; LO_Element * element;

View File

@ -85,7 +85,7 @@ class HTMLInlineTSMProxy //: public VTSMProxy
Boolean mDocActive; Boolean mDocActive;
static AEEventHandlerUPP sAEHandler; static AEEventHandlerUPP sAEHandler;
static HTMLInlineTSMProxy *sCurrentProxy; // static HTMLInlineTSMProxy *sCurrentProxy;
}; };