We're working on a huge porting from 100+ MA applications from V8i to Connect Edition.
One of the problems we're encountering regards the old mdlText_extract API.
In order to determine the size of an existing text element, we so far use the following code:
MSElement* pElement = ...;
char text[256];
TextSize tileSize;
TextSize textSize;
mdlText_extract(NULL, NULL, NULL, NULL, text, NULL, NULL, NULL, &tileSize, &textSize, pElement);
printf("Text '%s' has tileSize (%.1lf, %.1lf) and textSize (%.1lf, %.1lf)\n",
text, tileSize.width, tileSize.height, textSize.width, textSize.height);
It has the following output:
Text 'TTF3' has tileSize (525.0, 1200.0) and textSize (1901.5, 1200.0)
Text 'ODF10' has tileSize (420.0, 1200.0) and textSize (1785.7, 1200.0)
I tried the code as suggested by the link:
ElementHandle eh(pElement, ACTIVEMODEL);
TextBlockPtr textBlock = TextHandlerBase::GetFirstTextPartValue(eh);
DPoint2d fontSize = textBlock->GetRunPropertiesForAdd().GetFontSize();
DRange3d range = textBlock->GetNominalRange();
printf("FontSize of %ls: (%.1lf, %.1lf)\n", textBlock->ToString().GetWCharCP(), fontSize.x, fontSize.y);
printf("low/high: (%.1lf, %.1lf) / (%.1lf, %.1lf)\n", range.low.x, range.low.y, range.high.x, range.high.y);
printf("doc.width: %.1lf\n", textBlock->GetProperties().GetDocumentWidth());
But this gives me the output:
FontSize of TTF3: (0.0, 12.0)
low/high: (0.0, -12.0) / (0.0, 0.0)
doc.width: 0.0
FontSize of ODF10: (0.0, 12.0)
low/high: (0.0, -12.0) / (0.0, 0.0)
doc.width: 0.0
In other words, I get the height of the text (expressed as the fontsize) but not the width.
Any idea how to get the actual width and height of an existing text element?
I didn't find anything useful within the TextBlock class.
Thanks,
Robert Kock