Identifying Formatted Items in Object Text

In DXL is there an easy way to identify whether object text contains any formatting, e.g words bolded, subscripted, italic, etc
I have tried several richText() functions, but have had no success.
Thanks
philcher - Tue Oct 26 20:32:09 EDT 2010

Re: Identifying Formatted Items in Object Text
llandale - Wed Oct 27 14:01:02 EDT 2010

There's no doubt a better way, but you may need to find each richtext chunk and query it for each and every formatting option. Didn't try this, but it may get you started.

bool    HasRichTextFormatting(string Text)
{     // Does the text contain rich text chunks?
 
        if (null Text     or
            !isRichText(Text))          return(false) // bad input
 
        RichTextParagraph rtp
        RichText    rt
 
        for rtp in Text do
        {  for rt in rtp do
           {  if (rt.bold)            return(true)
              if (rt.italic)            return(true)
              if (rt.newline)           return(true)
              if (rt.strikethru)        return(true)
              if (rt.subscript)         return(true)
              if (rt.superscript)       return(true)
              if (rt.underline)         return(true)
           }  // end for rt
        }     // end for rtp
 
        return(false)           // No formatting found
}     // end HasRichTextFormatting(Text)
 
bool    HasRichTextFormatting(Object obj, string NameAttr)
{     // does the obj-attr have rich text formatting?
 
        if (null obj or null NameAttr) return(false)  // bad input
        string  Text = probeRichAttr_(obj, NameAttr)
        return(HasRichTextFormatting(Text))
}     // end HasRichTextFormatting(Obj, Attr)
 
Object oCurr = current
print (identifier(oCurr)) "\thas rich text? " (HasRichTextFormatting(oCurr, "Object Text")) "\n"

 


Maybe replace "probeRichAttr_" with
noError()
Text = richTextNoOle(obj, NameAttr)
string ErrMess = lastError
if (!null ErrMess) return(false) // ignore the error I guess

 

 

 

  • Louie