Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

[CONNECT C++] Of Carets and TextBlocks

$
0
0

In attempting to iterate over the contents of a TextNode, I'm using the following for each TextBlock in the TextPartIdPtrVector:

T_ITextPartIdPtrVector			textPartIds;
textQueryHandler->GetTextPartIds(eehText, *ITextQueryOptions::CreateDefault(), textPartIds);
for each (ITextPartIdPtr textPartId in textPartIds)
{	// --- Handle TEXTBLOCKS here ---
    TextBlockPtr textBlock = textQueryHandler->GetTextPart(eehText, *textPartId);
    for (CaretPtr paragraphCaret = textBlock->CreateStartCaret(); !paragraphCaret->IsAtEnd(); paragraphCaret->MoveToNextParagraph())
    {	// --- Handle PARAGRAPHS here ---
        ...
    }
}

 

however, the for() loop never "ends". I've add some code to try and see what's going on:

CaretPtr paragraphCaret = textBlock->CreateStartCaret();
printf("1. paragraphCaret->IsAtEnd() %s\n",paragraphCaret->IsAtEnd()?"true":"false");
printf("MoveToNextParagraph() %d\n", paragraphCaret->MoveToNextParagraph());
printf("2. paragraphCaret->IsAtEnd() %s\n",paragraphCaret->IsAtEnd()?"true":"false");
printf("MoveToNextParagraph() %d\n", paragraphCaret->MoveToNextParagraph());
printf("3. paragraphCaret->IsAtEnd() %s\n", paragraphCaret->IsAtEnd() ? "true" : "false");

 

right before the for() statement. My TextNode has two lines of text, all the same formatting. This is the output I see:


 

So it appears that the call to paragraphCaret->MoveToNextParagraph() is FAILING (status code != 0 ), yet paragraphCaret->IsAtEnd() still evaluates to "false", so the loop continues. So is using a for() loop in this manner ever going to work? Should it be changed to a "do...while()" construct?

 

Bruce


Viewing all articles
Browse latest Browse all 7260

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>