C++SDK About IWaxStrand::GetTextIndexToWaxLineData
IWaxStrand::GetTextIndexToWaxLineData is being used to obtain coordinates.
It seems to work fine, but when tables with two or more rows exist, it doesn't seem to work properly. Is this a bug?
do
{
// -------------------------------------------------------------
// Query Index
// iScript : InsertionPointObjectScriptElement
ScriptObject scriptObject = iScript->GetScriptObject(iScriptRequestData->GetRequestContext());
ScriptData scriptData = scriptObject.specifierData;
int32 int32_TargetIndex;
scriptData.GetInt32(&int32_TargetIndex);
// -------------------------------------------------------------
// Query IWaxStrand
InterfacePtr<ITextModel> iTextModel((ITextModel*)iScript->QueryParent(
IID_ITEXTMODEL,
iScriptRequestData->GetRequestContext()
));
if (!iTextModel) break;
InterfacePtr<IWaxStrand> iWaxStrand(((IWaxStrand*)iTextModel->QueryStrand(kFrameListBoss, IID_IWAXSTRAND)));
if (!iWaxStrand) break;
// -------------------------------------------------------------
// Recompose
InterfacePtr<IFrameList> iFrameList(iWaxStrand, ::UseDefaultIID());
if (!iFrameList) break;
const int32 kNoDamage = -1;
if (iFrameList->GetFirstDamagedFrameIndex() != kNoDamage) {
// Recompose.
InterfacePtr<IFrameListComposer> iFrameListComposer(iFrameList, UseDefaultIID());
if (!iFrameListComposer) break;
iFrameListComposer->RecomposeThruLastFrame();
}
// -------------------------------------------------------------
// GetTextIndexToWaxLineData
int32 int32_OffsetWithinLine;
int32 int32_TextSpan;
ParcelKey parcelKey;
UID uID_Frame;
PMReal pMReal_LineHeight;
PMLineSeg pMLineSeg_Selection;
PMPoint pMPoint_WaxPt;
PMMatrix pMMatrix_WaxToFrameMatrix;
PMMatrix pMMatrix_WaxToGlyphMatrix;
bool16 result = iWaxStrand->GetTextIndexToWaxLineData(
int32_TargetIndex,
kFalse,
&int32_OffsetWithinLine,
&int32_TextSpan,
&parcelKey,
&uID_Frame,
&pMReal_LineHeight,
&pMLineSeg_Selection,
&pMPoint_WaxPt,
&pMMatrix_WaxToFrameMatrix,
&pMMatrix_WaxToGlyphMatrix
);
// -------------------------------------------------------------
// PointsToUnits
InterfacePtr<IMeasurementSystem> iMeasurementSystem(::GetExecutionContextSession(), ::UseDefaultIID());
InterfacePtr<IUnitOfMeasure> iUnitOfMeasure(iMeasurementSystem->QueryUnitOfMeasure(
iMeasurementSystem->Location(kMillimetersBoss))
);
if (!iUnitOfMeasure) break;
PMReal pMReal_mmValue = iUnitOfMeasure->PointsToUnits(pMPoint_WaxPt.X());
PMString xCoordinate;
xCoordinate.AsNumber(pMReal_mmValue);
CAlert::InformationAlert(xCoordinate);
} while (false);
Modern AI is quite smart. When I asked it how to get character coordinates, it suggested the IWaxStrand::GetTextIndexToWaxLineData method. If it gives an incorrect answer, uploading the interface header seems to make it return much more accurate results.
