DXL for bulletted list

I have a DXL Layout attribute that lists items linked from another module. I'm trying to make the list look like a list, i.e. with bullet and indentation, but no luck. My latest code is like this: 

               desc = probeRichAttr_(othero,"Object Text", false)
                disp = disp  " " desc
                //disp = applyTextFormattingToParagraph(disp, true, 1, 0)
                displayRich("\\pard \\bullet " disp)

 

which produces a list that looks like this: 

 

* item 1 spans multiple lines and next line is indented so obvious it is 

part of same bullet

* item 2 spans multiple lines and next line is indented so obvious it is 

part of same bullet

 

instead of 

 

*    item 1 spans multiple lines and next line is indented so obvious it is 

     part of same bullet

*    item 2 spans multiple lines and next line is indented so obvious it is 

     part of same bullet

 

I'm not very familiar with RTF so I tried a few things involve pntext and such by look at the RTF of existing DOORS text attributes that have the formatting I want, but no luck. I also tried applyTextFormattingToParagraph() but that did not help. 

 

If possible when you post solution, list the resource you used (a reference section in DOORS docs, etc). 

 


Schollii - Tue Dec 20 17:48:46 EST 2016

Re: DXL for bulletted list
MrNiceGuy - Tue Dec 20 18:00:31 EST 2016

So I had this same issue before when I was trying to get bullet points to list items in an infoBox before the script would run

I came across a lot of really convoluted ways to go about doing it but nothing seemed to work.

What I did was the simplest thing, I just copy and pasted an bullet point from WORD into DOORs and tada!

infoBox "Object Type = Requirements that are missing values in
        • Value 1
        • Value 2
        • Value 3"

Now is there a better way to do this? most likely yes but this is what I did.

Re: DXL for bulletted list
Schollii - Tue Dec 20 19:51:07 EST 2016

MrNiceGuy - Tue Dec 20 18:00:31 EST 2016

So I had this same issue before when I was trying to get bullet points to list items in an infoBox before the script would run

I came across a lot of really convoluted ways to go about doing it but nothing seemed to work.

What I did was the simplest thing, I just copy and pasted an bullet point from WORD into DOORs and tada!

infoBox "Object Type = Requirements that are missing values in
        • Value 1
        • Value 2
        • Value 3"

Now is there a better way to do this? most likely yes but this is what I did.

Thanks for the useful tip. Unfortunately, this will not work here because I *have* to generate the list items programmatically: the attribute is Layout DXL.

I'll keep your trick in mind for rich text attributes, although so far the ctrl+shift+L has done the job of "listifying" a selection of paragraphs (this little-known keyboard shortcut cycles among the many list numbering styles supported by DOORS. 

Re: DXL for bulletted list
MrNiceGuy - Tue Dec 20 19:53:21 EST 2016

Schollii - Tue Dec 20 19:51:07 EST 2016

Thanks for the useful tip. Unfortunately, this will not work here because I *have* to generate the list items programmatically: the attribute is Layout DXL.

I'll keep your trick in mind for rich text attributes, although so far the ctrl+shift+L has done the job of "listifying" a selection of paragraphs (this little-known keyboard shortcut cycles among the many list numbering styles supported by DOORS. 

Well could you set a string variable to the bullet point and then just insert that string prior to the listed items?

Re: DXL for bulletted list
Mathias Mamsch - Wed Dec 21 04:52:17 EST 2016

What you want to achieve is actually not so easy. You can control paragraph indenting inside the RTF using the \\li  (line indent) and \\fi  (first line indent) tags, allowing you to produce the look you are after. BUT: If your object text contains multiple paragraphs, then inside the paragraphs you will have a lot of "\\pard" statements, which will reset paragraph formatting. That means by just preceeding something to the object text, you will not be able to produce the bulleting you want. 

Instead you could try and go with RTF tables. Put the bullet in the first cell, and the object text in the second. You will get problems though if your object text contains RTF tables itself. 

Conclusion: You will need to go into the RTF to have this code work ALWAYS. The question is, if you want to spend this effort for some layout DXL or if you find a visually more appealing way to achieve that. One way I used in the past was to put a horizontal line between the text of the objects: 

string sLine = "{\\pict\\wmetafile8\\picw26\\pich26\\picwgoal20000\\pichgoal15 
0100090000035000000000002700000000000400000003010800050000000b0200000000050000
000c0202000200030000001e000400000007010400040000000701040027000000410b2000cc00
010001000000000001000100000000002800000001000000010000000100010000000000000000
000000000000000000000000000000000000000000ffffff00000000ff040000002701ffff0300
00000000
}"

Buffer buf = create(); 
buf = "{\\rtf1"
for o in sk do {
   buf += "{"
   buf += richTextFragment richText o."Object Text"
   buf += "}"
   buf += sLine
}

buf += "}"

displayRich tempStringOf buf

kind of hacky, but it works. Maybe that helps, Regards, Mathias

Re: DXL for bulletted list
Schollii - Fri Dec 23 13:20:09 EST 2016

MrNiceGuy - Tue Dec 20 19:53:21 EST 2016

Well could you set a string variable to the bullet point and then just insert that string prior to the listed items?

I extracted the RTF from columns that do have the bullet list formatting I want, and I'm unable to find just the portion I need, I get close but there's so far always something wrong/missing. So unless I'm misunderstanding what you mean, putting the RTF in a var would not help; once I know the RTF, the problem is solved. I will just use hyphens; when I export DOORS module to HTML, I run a script on it that cleans up the HTML (I'll replace hyphens according to regular expression), and I insert the HTML into the deliverable Word doc. Cumbersome but the error-prone part is handled by the script so it'll have to do for now. 

Re: DXL for bulletted list
Schollii - Fri Dec 23 13:23:37 EST 2016

Mathias Mamsch - Wed Dec 21 04:52:17 EST 2016

What you want to achieve is actually not so easy. You can control paragraph indenting inside the RTF using the \\li  (line indent) and \\fi  (first line indent) tags, allowing you to produce the look you are after. BUT: If your object text contains multiple paragraphs, then inside the paragraphs you will have a lot of "\\pard" statements, which will reset paragraph formatting. That means by just preceeding something to the object text, you will not be able to produce the bulleting you want. 

Instead you could try and go with RTF tables. Put the bullet in the first cell, and the object text in the second. You will get problems though if your object text contains RTF tables itself. 

Conclusion: You will need to go into the RTF to have this code work ALWAYS. The question is, if you want to spend this effort for some layout DXL or if you find a visually more appealing way to achieve that. One way I used in the past was to put a horizontal line between the text of the objects: 

string sLine = "{\\pict\\wmetafile8\\picw26\\pich26\\picwgoal20000\\pichgoal15 
0100090000035000000000002700000000000400000003010800050000000b0200000000050000
000c0202000200030000001e000400000007010400040000000701040027000000410b2000cc00
010001000000000001000100000000002800000001000000010000000100010000000000000000
000000000000000000000000000000000000000000ffffff00000000ff040000002701ffff0300
00000000
}"

Buffer buf = create(); 
buf = "{\\rtf1"
for o in sk do {
   buf += "{"
   buf += richTextFragment richText o."Object Text"
   buf += "}"
   buf += sLine
}

buf += "}"

displayRich tempStringOf buf

kind of hacky, but it works. Maybe that helps, Regards, Mathias

Thanks for posting this. However this is too onerous, having to do this processing for every item in the list (every object will have a dozen items, some have 40!). I will just use hyphens and an HTML post-processing script (written in Python) that I can apply to the DOORS HTML export of my module. Cumbersome but the error-prone part is handled by the script so it'll have to do for now. 

Re: DXL for bulletted list
Jan_Lautenbach - Fri Jun 09 07:06:48 EDT 2017

Mathias Mamsch - Wed Dec 21 04:52:17 EST 2016

What you want to achieve is actually not so easy. You can control paragraph indenting inside the RTF using the \\li  (line indent) and \\fi  (first line indent) tags, allowing you to produce the look you are after. BUT: If your object text contains multiple paragraphs, then inside the paragraphs you will have a lot of "\\pard" statements, which will reset paragraph formatting. That means by just preceeding something to the object text, you will not be able to produce the bulleting you want. 

Instead you could try and go with RTF tables. Put the bullet in the first cell, and the object text in the second. You will get problems though if your object text contains RTF tables itself. 

Conclusion: You will need to go into the RTF to have this code work ALWAYS. The question is, if you want to spend this effort for some layout DXL or if you find a visually more appealing way to achieve that. One way I used in the past was to put a horizontal line between the text of the objects: 

string sLine = "{\\pict\\wmetafile8\\picw26\\pich26\\picwgoal20000\\pichgoal15 
0100090000035000000000002700000000000400000003010800050000000b0200000000050000
000c0202000200030000001e000400000007010400040000000701040027000000410b2000cc00
010001000000000001000100000000002800000001000000010000000100010000000000000000
000000000000000000000000000000000000000000ffffff00000000ff040000002701ffff0300
00000000
}"

Buffer buf = create(); 
buf = "{\\rtf1"
for o in sk do {
   buf += "{"
   buf += richTextFragment richText o."Object Text"
   buf += "}"
   buf += sLine
}

buf += "}"

displayRich tempStringOf buf

kind of hacky, but it works. Maybe that helps, Regards, Mathias

Hi there,

why is it not possible to use the applyTextFormattingToParagraph function?

 

 

applyTextFormattingToParagraph

Declaration

string applyTextFormattingToParagraph(string s, bool addBullets, int indentLevel, int paraNumber, [int firstIndent])

Operation

Applies bullet and/or indent style to the given text, overwriting any existing bulleting/indenting.

•If  addBullets is true, adds bullet style. 

•If indentLevel is nonzero, adds indenting to the value of indentLevel. The units for indentLevel are twips = twentieths of a point.

•If paraNumber is zero, the formatting is applied to all the text. Otherwise it is only applied to the specified paragraph number.

•If the optional parameter firstIndent is specified, then this sets the first line indent. If the value is negative then this sets a hanging indent. The units are in points.

The input string s must be rich text. For example, from string s = richText o."Object Text".

Returns a rich text string which describes the text with the formatting applied.

Example

Object o = current

string s = o."Object text"

o."Object text" = richText (applyTextFormattingToParagraph(richText s,true,0,0))

Adds bullet style to all of the current object's text.

Regards,

Jan

Re: DXL for bulletted list
Mathias Mamsch - Fri Jun 09 09:57:54 EDT 2017

Jan_Lautenbach - Fri Jun 09 07:06:48 EDT 2017

Hi there,

why is it not possible to use the applyTextFormattingToParagraph function?

 

 

applyTextFormattingToParagraph

Declaration

string applyTextFormattingToParagraph(string s, bool addBullets, int indentLevel, int paraNumber, [int firstIndent])

Operation

Applies bullet and/or indent style to the given text, overwriting any existing bulleting/indenting.

•If  addBullets is true, adds bullet style. 

•If indentLevel is nonzero, adds indenting to the value of indentLevel. The units for indentLevel are twips = twentieths of a point.

•If paraNumber is zero, the formatting is applied to all the text. Otherwise it is only applied to the specified paragraph number.

•If the optional parameter firstIndent is specified, then this sets the first line indent. If the value is negative then this sets a hanging indent. The units are in points.

The input string s must be rich text. For example, from string s = richText o."Object Text".

Returns a rich text string which describes the text with the formatting applied.

Example

Object o = current

string s = o."Object text"

o."Object text" = richText (applyTextFormattingToParagraph(richText s,true,0,0))

Adds bullet style to all of the current object's text.

Regards,

Jan

Because it will - as far as I remember - only apply the formatting to one paragraph. You may get more lucky if you iterate over the richtext paragraphs and run this function on each one, but my tests indicated that it does not always produce correct results. You can try for yourself though - use multiple paragraphs, maybe some OLE objects inside, etc. If you find it working feel free to post it here. 

Regards, Mathias