POSSIBLE BUG: Class: Richtextitem; Method: AppendTable; Parameter: opt. rtpstylearray

CLASS: notesrichtextitem METHOD: AppendTable

PARAMETER: optional rtpstylearray

PROBLEM:

When appending the Table to the rich text item, I have found that the array of RT Paragraph Styles only formats to the lowest demension of the array (rtpstyle(0)) correctly, other demension are not successfully applied. I have the same number of demensions as the number of columns on the table.

Example:

Dim ws As New NotesUIWorkspace

Dim s As New NotesSession

Dim rtpstyle() As NotesRichTextItemParagraphStyle

Dim rtitem As NotesRichTextItem

Dim db As NotesDatabase

Dim doc As NotesDocument

Set db = ws.CurrentDatabase.Database

Set doc = db.CreateDocument

doc.form = “Memo”

Set rtitem = doc.CreateRichTextItem(“Body”)

row% = 15

col% = 2

ReDim rtpstyle(1 to col) As NotesRichTextItemParagraphStyle

Set rtpstyle(1) = s.CreateRichTextItemParagraphStyle

'Settings for Column (1)

With rtpstyle(1)

.Alignment = ALIGN_LEFT

.Firstlineleftmargin = 0

.Leftmargin = 1.5 * RULER_ONE_CENTIMETER

.Rightmargin = 5.0 * RULER_ONE_CENTIMETER

End With

Set rtpstyle(2) = s.CreateRichTextItemParagraphStyle

'Setting for COLUMN 2

With rtpstyle(2)

.Alignment = ALIGN_CENTER

.Firstlineleftmargin = 0

.Leftmargin = 1.5 * RULER_ONE_CENTIMETER

.Rightmargin = 10.5 * RULER_ONE_CENTIMETER

End With

Call rtitem.AppendTable(row%, col%, RULER_ONE_CENTIMETER * 1.5, rtpstyles)

The first cell (r1,c1) is applied ok. There after, there are no uniform styles that are applied.

This makes this whole feature unusable.

Is there a solution to this problem?

Subject: POSSIBLE BUG: Class: Richtextitem; Method: AppendTable; Parameter: opt. rtpstylearray

You are (apparently) trying to set the position of the left side of both columns to the same location. The overall left margin for the table is set in the table declaration, and each column style in the array should only have a right “margin” (the width of the cell), which is relative to the left “margin” (the rightmost edge of the preceeding cell). Part of adapting an existing class (NotesRichTextParagraphStyle) to a new class.

Subject: RE: POSSIBLE BUG: Class: Richtextitem; Method: AppendTable; Parameter: opt. rtpstylearray

Maybe my example was not very clear.

If we look at the notes help file (below or in Notes R6 Designer Help).

You will see a description of what Lotus says about the method AppendTable.

My understanding is that rtpsStyleArray is the settings for each column’s paragraph.

That means from my example rightmargin for column 1 is 5cm and rightmargin for column 2 is 10.5

Yet, what has been applied is

cell 1(r1,c2) = rtpstyle(1),

cell 2(r1,c2) = rtpstyle(2), but rightmargin of rtpstyle(1)

cell 3(r2,c1) = a mixer of rtpstyle(1) and rtpstyle(2)

cell 4(r2,c2) = a mixer of rtpstyle(1) and rtpstyle(2), anyone’s guest.

Lotus’s Description states:

“The array must contain one element for each column in the table in sequence”

To me this means: each demension of array = column’s paragraph style.

i.e

(Sorry best I can do with variable font.)

|____________________|

|rtpstyle(1)|rtpstyle(2) |

|____________________|

|rtpstyle(1)|rtpstyle(2) |

|____________________|

cell 1(r1,c2) = rtpstyle(1)

cell 2(r1,c2) = rtpstyle(2)

cell 3(r2,c1) = rtpstyle(1)

cell 4(r2,c2) = rtpstyle(2)

This is what happening.

In my example I had set the Columns margin to

column1 = 5cm and column2 = 10.5

Lets ignore the leftmargins are they are all the same…

Table Leftmargin = 1.5cm

Every Cell Leftmargin = 1.5cm

My concern is that rtpstyle(2) is suppose to have a rightmargin of 10.5 and yes it spans the column to 10.5 but every column 2 has a rightmargin of column 1 cell (5cm).

i.e

|5cm|10cm____|

|^LM_______________RM^|_^LM_____ ^RM(@5cm)____|

|____________|__(takes on r1,c1 right margin)|

||____________|

On top of that you also get the alignment all out of wack.

|LEFT____|CENTER|

|CENTER|CENTER|

what should apply according to the Designer Help and Example is:

i.e demension 1 is applied to column one

demension 2 is applied to column two.

so on...........

|5cm|10cm___|

|^LM_______________RM^|_^LM_____________________________RM^|

|Left________________|CENTER|

||______________|

|^LM_______________RM^|_^LM_____________________________RM^|

|Left________________|CENTER|

||______________|

Has anyone had this functioning correctly?

If so, could you please provide a quick example?

I like to test it against my understanding of how its applied.


Extract from the Notes Help file.

Call notesRichTextItem.AppendTable( rows%, columns% [, labels] [, leftMargin&] [, rtpsStyleArray] )

Parameters

• rows%

Integer. Number of rows in the table.

• columns%

Integer. Number of columns in the table.

• labels

Array of type String. Optional. Text of labels for a tabbed table. The number of array elements must equal the number of rows. Omitting this parameter appends a basic table. Including this parameter appends a tabbed table.

• leftMargin&

Long. Optional. Left margin of the table in twips. Defaults to 1440. The following constants are available:

RULER_ONE_CENTIMETER (567)

RULER_ONE_INCH (1440)

• rtpsStyleArray

Array of type NotesRichTextParagraphStyle. Optional. Creates a table with fixed-width columns and style attributes as specified. Omitting this parameter creates an auto-width table. The array must contain one element for each column in the table in sequence. Explicitly set the first line left margin and left margin, which control the start of text relative to the start of the column, and the right margin, which controls column width.

Example 4

________-

This view action creates a basic table of 4 rows and 3 columns, and populates it. The width of each column is fixed at 1.5 inches. The left margin of the table is 1.5 inches.

Sub Click(Source As Button)

Dim session As New NotesSession

Dim db As NotesDatabase

Set db = session.CurrentDatabase

REM Create document with Body rich text item

Dim doc As New NotesDocument(db)

Call doc.ReplaceItemValue(“Form”, “Main topic”)

Call doc.ReplaceItemValue(“Subject”, “Table 4 x 3”)

Dim body As New NotesRichTextItem(doc, “Body”)

REM Create table in Body item

rowCount% = 4

columnCount% = 3

Dim styles(1 To 3) As NotesRichTextParagraphStyle

For i% = 1 To 3 Step 1

Set styles(i%) = session.CreateRichTextParagraphStyle

styles(i%).LeftMargin = 0

styles(i%).FirstLineLeftMargin = 0

styles(i%).RightMargin = RULER_ONE_INCH * 1.5

Next

Call body.AppendTable _

(rowCount%, columnCount%, RULER_ONE_INCH * 1.5, styles)

Subject: Workaround: POSSIBLE BUG: Class: Richtextitem; Method: AppendTable; Parameter: opt. rtpstylearray

I’ve been able to find a workaround. By looking through the forum, I found that it appears that prior paragraph styles can have an influence on the columns of the table created with .AppendTable. So I did the following:

  1. Create a temporary RichTextItem (I called it nrtTemp)

  2. Build my table (ONLY) using nrtTemp (separate from my main body)

  3. Where I want it, just do an .AppendRTItem of the new nrtTemp

Works fine - I don’t have the paragraph right margin issue in the columns.

Subject: RE: POSSIBLE BUG: Class: Richtextitem; Method: AppendTable; Parameter: opt. rtpstylearray

I am experiencing the exact same problem. I’ve narrowed it down to whatever the second column in my table has set as it’s right margin (width), the remaining columns take as a right margin! It doesn’t matter what the remaining columns have set for their column width (.RightMargin property) - they get the right column width, but as soon as I start putting text in the cell, it sets a right margin inside those remaining columns equal to the width of the second column. When I adjust JUST the second column’s .RightMargin property, the right margin of the remaining columns changes to match!.

Here’s the important parts of my code:

Dim ncoRowColor1 As NotesColorObject

Dim ncoRowColor2 As NotesColorObject

Dim rtRange As NotesRichTextRange

Dim rtNav As NotesRichTextNavigator

Dim a_rtpsColumns(1 To 4) As NotesRichTextParagraphStyle

Dim rttNew As NotesRichTextTable



For I = 1 To 4

	Set a_rtpsColumns(I) = nsCurrent.CreateRichTextParagraphStyle()

	a_rtpsColumns(I).FirstLineLeftMargin = 0.05

	a_rtpsColumns(I).LeftMargin = 0.05

	a_rtpsColumns(I).Alignment = ALIGN_LEFT

Next I

a_rtpsColumns(1).RightMargin = RULER_ONE_INCH * 0.5

a_rtpsColumns(2).RightMargin = RULER_ONE_INCH * 2.0

a_rtpsColumns(3).RightMargin = RULER_ONE_INCH * 3.0

a_rtpsColumns(4).RightMargin = RULER_ONE_INCH * 3.0

'Create the table

		Call nrtMailBody.AppendParagraphStyle(rtpsHeader)

		Call nrtMailBody.AppendStyle(rtsHeader)

		Call nrtMailBody.AppendText("New Product Announcements:")

		Call nrtMailBody.AppendTable(1, 4, , RULER_ONE_INCH * 1.0, a_rtpsColumns)

		

		Call rtNav.FindFirstElement(RTELEM_TYPE_TEXTPARAGRAPH)

		Do

			Call rtRange.SetBegin(rtNav)

			Call rtNav.FindNextElement(RTELEM_TYPE_TEXTRUN)

		Loop Until (Instr(rtRange.TextRun, "New Product Announcements:") <> 0)

		

		Call rtNav.FindNextElement(RTELEM_TYPE_TABLE)

		Set rttNew = rtNav.GetElement()

		Call rttNew.SetColor(ncoRowColor1)

		Call rttNew.SetAlternateColor(ncoRowColor2)

		rttNew.Style = TABLESTYLE_ALTERNATINGROWS

		

		

		Call rtNav.FindNextElement(RTELEM_TYPE_TABLECELL)

		Call nrtMailBody.BeginInsert(rtNav)

		Call nrtMailBody.AppendStyle(rtsHeader)

		Call nrtMailBody.AppendText("Cat")

		Call nrtMailBody.EndInsert()

		Call rtNav.FindNextElement(RTELEM_TYPE_TABLECELL)

		Call nrtMailBody.BeginInsert(rtNav)

		Call nrtMailBody.AppendStyle(rtsHeader)

		Call nrtMailBody.AppendText("Type-Mod")

		Call nrtMailBody.EndInsert()

		Call rtNav.FindNextElement(RTELEM_TYPE_TABLECELL)

		Call nrtMailBody.BeginInsert(rtNav)

		Call nrtMailBody.AppendStyle(rtsHeader)

		Call nrtMailBody.AppendText("Description (Max Discount)")

		Call nrtMailBody.EndInsert()

		Call rtNav.FindNextElement(RTELEM_TYPE_TABLECELL)

		Call nrtMailBody.BeginInsert(rtNav)

		Call nrtMailBody.AppendStyle(rtsHeader)

		Call nrtMailBody.AppendText("Region Detail Links (Max Disc., if different)")

		Call nrtMailBody.EndInsert()

Driving me nuts! Any suggestions?

Todd