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

RE: [CONNECT C++] Of Carets and TextBlocks

$
0
0

I have not verified what you said, but I'm certain it's most likely correct.

 

However, in my example, I am using sample code from the documentation. and (apparently) that example is not correct. Maybe the documentation should be updated:

 

// Ensure that the element can expose text.
// If you only want to process free-standing text elements, you can check textQueryHandler->IsTextElement (), which implies a single piece of text.
ITextQueryCP textQueryHandler = eh.GetITextQuery ();
if (NULL == textQueryHandler)
return;
// Some elements expose multiple pieces of text (e.g. dimensions); in general, you must be prepared to accept multiple pieces of text, unless textQueryHandler->IsTextElement ().
// Some element handlers (or associated APIs) will provide pieces of text via TextBlock through their own more specific getter methods, bestowing specific meanings to each piece of text.
textQueryHandler->GetTextPartIds (eh, *ITextQueryOptions::CreateDefault (), textPartIds);
for eachITextPartIdPtr textPartId in textPartIds)
{
// Ask the handler for the specific piece of text.
// The TextBlock is in no way directly tied to the underlying textual data, and you must use ITextEdit::ReplaceText to actually modify the element.
TextBlockPtr textBlock = textQueryHandler->GetTextPart (eh, *textPartId);
// Each paragraph has unique properties, so to consume all properties, you must iterate paragraphs.
// You could also simply iterate runs and continually check to see if the paragraph or paragraph properties has changed.
for (CaretPtr paragraphCaret = textBlock->CreateStartCaret (); !paragraphCaret->IsAtEnd (); paragraphCaret->MoveToNextParagraph ())
{
// Perform logic to deal with the new paragraph; get the current paragraph using paragraphCaret->GetCurrentParagraphCP ().
CaretPtr runCaret = paragraphCaret->Clone ();
do
{
// Perform logic to deal with the new run; get the current run using runCaret->GetCurrentRunCP ().
// You will likely want to find a way to switch on run type in order to gather specific information about each (e.g. CharStream, Fraction, ParagraphBreak, LineBreak, and Tab).
}
while (SUCCESS == runCaret->MoveToNextRunInParagraph ());
}
}

 


Viewing all articles
Browse latest Browse all 7260

Trending Articles



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