Trying to figure out how to modify text parameters (e.g. Bold/Italics/etc) for existing text. I get a SUCCESS return from ReplaceTextPart(), but there is no change in the "italics" setting...
ITextEditP editor = eeh.GetITextEdit(); if (editor && editor->IsTextElement(eeh)) { TextBlockPtr textBlock = TextHandlerBase::GetFirstTextPartValue(eeh); if (textBlock.IsValid()) { RunPropertiesR runProps = textBlock->GetRunPropertiesForAddR(); runProps.SetIsItalic(true); textBlock->SetRunPropertiesForAdd(runProps); textBlock->PerformLayout(); } T_ITextPartIdPtrVector partIDs; editor->GetTextPartIds(eeh,*ITextQueryOptions::CreateDefault(), partIDs); ITextEdit::ReplaceStatus rStatus = editor->ReplaceTextPart(eeh, *partIDs[0], *textBlock); wprintf(L"rStatus=%d\n", rStatus); }
Calling ITextEdit::ReplaceTextPart isn't enough to replace the text. Suffixing a call of eeh.ReplaceInModel can make your code worked.
Jon Summers said:Replace that Run in the TextBlock
I guess that is the real question/issue. How is this done? Does replacing the Run in the TextBlock mean we have to "create" a whole NEW TextBlock (with our desired TextBlock, Paragraph and Run properties) then insert our text items (TextBlock::InsertText() calls)?
Help tells us this about SetRunPropertiesForAdd(runProps): Gets the run properties that will be used when any future run DOM nodes are created
SetRunPropertiesForAdd(runProps)
I don't see any method that sets the Run properties for editing in an existing block. I suppose we have to …
Regards, Jon Summers LA Solutions