How to copy Object Text attribute WITH rich text (to another attribute or attr-DXL)?

 

I want another attribute that will show the same information as the Object Text attribute **INCLUDING the RICH TEXT FORMATTING** (including any OLE content).

Tried some basic stuff but all I get is the text only, no rich text.

Ideally, I'd like the new attribute to display exactly what "Object Heading and Object Text" built in column displays...is that easy to replicate/copy??

(Eventually, I want to use attr-DXL attribute to take this and tweak it a bit by adding extra info [e.g. append object ID, and so forth].)

 


strathglass - Tue Jan 14 09:24:42 EST 2014

Re: How to copy Object Text attribute WITH rich text (to another attribute or attr-DXL)?
llandale - Wed Jan 15 12:39:20 EST 2014

[1] The following is by far the 'best" way to copy attribute values; ignore the fact that the "set" is undocumented.  It makes exact copies without any wasted string table space and I've never seen a downside to it.  Never tried it when "NameAttr_To" is an attrDXL, but have no reason to suspect it will fail.

  • set(oTo.NameAttr_To, oFrom.NameAttr_From)

[2a] You retrieve full RichText from a "Text" attribute like this:

  • string Value = richTextWithOle(oFrom, NameAttr_From)

[2b] You set full Rich Text like this:

  • oTo.NameAttr_To = richText(Value)

Not sure what happens if the attributes are not type "Text"; probably works anyway.

[3] You can reasonably simulate the "Main" column like this:

  • Buffer bufResults = create
  • bufResults = "{"      // Start RichText
  • string Heading = o."Object Heading"   // RAW text
  • if (length(Heading) > 0) //
  • {  bufResults += number(o) "\t"     // Start with Object Paragraph Number
  •    bufResults += richText(o."Object Heading")   // Heading can have no OLE
  •    bufResults += \\par
  • }
  • bufResults += richTextWithOle(o."Object Text")
  • bufResults += \\pard\\par}       // not sure what the pard par is all about, but it works
  • o.NameAttr_To = richText(bufResults)
  • delete(bufResults)

-Louie

 

Re: How to copy Object Text attribute WITH rich text (to another attribute or attr-DXL)?
strathglass - Wed Jan 15 14:11:00 EST 2014

llandale - Wed Jan 15 12:39:20 EST 2014

[1] The following is by far the 'best" way to copy attribute values; ignore the fact that the "set" is undocumented.  It makes exact copies without any wasted string table space and I've never seen a downside to it.  Never tried it when "NameAttr_To" is an attrDXL, but have no reason to suspect it will fail.

  • set(oTo.NameAttr_To, oFrom.NameAttr_From)

[2a] You retrieve full RichText from a "Text" attribute like this:

  • string Value = richTextWithOle(oFrom, NameAttr_From)

[2b] You set full Rich Text like this:

  • oTo.NameAttr_To = richText(Value)

Not sure what happens if the attributes are not type "Text"; probably works anyway.

[3] You can reasonably simulate the "Main" column like this:

  • Buffer bufResults = create
  • bufResults = "{"      // Start RichText
  • string Heading = o."Object Heading"   // RAW text
  • if (length(Heading) > 0) //
  • {  bufResults += number(o) "\t"     // Start with Object Paragraph Number
  •    bufResults += richText(o."Object Heading")   // Heading can have no OLE
  •    bufResults += \\par
  • }
  • bufResults += richTextWithOle(o."Object Text")
  • bufResults += \\pard\\par}       // not sure what the pard par is all about, but it works
  • o.NameAttr_To = richText(bufResults)
  • delete(bufResults)

-Louie

 

Great answer as always Louie.

Thanks!

 

-Colin

Re: How to copy Object Text attribute WITH rich text (to another attribute or attr-DXL)?
strathglass - Wed Jan 15 15:12:30 EST 2014

llandale - Wed Jan 15 12:39:20 EST 2014

[1] The following is by far the 'best" way to copy attribute values; ignore the fact that the "set" is undocumented.  It makes exact copies without any wasted string table space and I've never seen a downside to it.  Never tried it when "NameAttr_To" is an attrDXL, but have no reason to suspect it will fail.

  • set(oTo.NameAttr_To, oFrom.NameAttr_From)

[2a] You retrieve full RichText from a "Text" attribute like this:

  • string Value = richTextWithOle(oFrom, NameAttr_From)

[2b] You set full Rich Text like this:

  • oTo.NameAttr_To = richText(Value)

Not sure what happens if the attributes are not type "Text"; probably works anyway.

[3] You can reasonably simulate the "Main" column like this:

  • Buffer bufResults = create
  • bufResults = "{"      // Start RichText
  • string Heading = o."Object Heading"   // RAW text
  • if (length(Heading) > 0) //
  • {  bufResults += number(o) "\t"     // Start with Object Paragraph Number
  •    bufResults += richText(o."Object Heading")   // Heading can have no OLE
  •    bufResults += \\par
  • }
  • bufResults += richTextWithOle(o."Object Text")
  • bufResults += \\pard\\par}       // not sure what the pard par is all about, but it works
  • o.NameAttr_To = richText(bufResults)
  • delete(bufResults)

-Louie

 

OK, I tried Louie's code and wanted to note a couple things:

You need to quote the \\par and \\pard\\par} entries - I'm assuming Louie did that and the forum lost those!

(FYI - These are RTF paragraph markers: \pard is paragraph start, \par is paragraph end, so normal RTF paragraph looks like "{\pard stuff... par}"

ISSUE: For some reason, the copy ends up with an extra blank paragraph (blank line) at the top of the target copied attribute. Haven't found a way to fix that yet. Hmmm ... any ideas?

-Colin

Re: How to copy Object Text attribute WITH rich text (to another attribute or attr-DXL)?
llandale - Fri Jan 17 09:51:57 EST 2014

strathglass - Wed Jan 15 15:12:30 EST 2014

OK, I tried Louie's code and wanted to note a couple things:

You need to quote the \\par and \\pard\\par} entries - I'm assuming Louie did that and the forum lost those!

(FYI - These are RTF paragraph markers: \pard is paragraph start, \par is paragraph end, so normal RTF paragraph looks like "{\pard stuff... par}"

ISSUE: For some reason, the copy ends up with an extra blank paragraph (blank line) at the top of the target copied attribute. Haven't found a way to fix that yet. Hmmm ... any ideas?

-Colin

I think "\\pard" means "ignore previous paragraph settings, go back to Default".  I don't think there is a "start paragraph" code; a paragraph "starts" right after the previous \\par.  Having said that, I think it indeed makes sense to use "\\pard" to start most paragraphs as it protects this section of the RTF from anything previous.

Fixed code.  The RTF "Start" needs to be "{\\rtf1 " not just "{".  Also, whether an object "SHOULD BE a "Heading" has too many strange rules to apply, so I wrote a function to determine whether doors DOES consider it a heading, by looking at it's "number".

Attached is reasonable Attr-DXL to simulate the "Main" column.

I notice that when I retrieve the "richText" of the Heading; I lose my bold command.  Thus this script retrieves the raw Heading, just so the attrDXL will display it in bold.  Comments on fixing that will be appreciated (e.g., allow Italics in headings to be displayed with italics).

-Louie


Attachments

dxl_MainColumn.dxl