Forum > FPvectorial

[SOLVED] Adding columns to a Word document table (FPVectorial)

<< < (4/4)

Mike.Cornflake:
G'day,

Heh.  I've only been offshore twice this year, and both times bugs in my code have been found.

Apologies @JD, when I got back onshore I completely forgot to follow up and get the trunk code fixed.  And I see CellSpacing has now failed



--- Quote ---As i tested, every single char such as 'A', 'B', or '1', '2'... will be empty in saved docx or odt file

--- End quote ---

@qindj
Right - I've confirmed that indeed there is a bug.  I'll get to it, but in the meantime you're going to need to keep appending those spaces. 

I'm away from IDE at the moment (Yes, offshore again working 12 hours shifts).

The following are my quick notes to assist with chasing this when I have time.   I'm planned to be back on shore Nov 4, so I should reply sometime in the weekend following that.  If you haven't heard, ping me (pm or here) and remind me.

The issue is likely in docxvectorialwriter.pas,

Line 703.  For some reason AddTextRun doesn't look like it's being run (in the xml of the resulting word document, not only is the there no text, but there's no w:r tag written either, and that's done in AddtextRun).  Oh, or AddTextRun  is being passed an empty string.  Ah, that's makes more sense.  If it's being passed with an empty string, then the following code needs to be tightened to ONLY strip CR or LF. 

Line 696:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---        // Strip out the trailing line break        // added by TStringList.Text        If DefaultTextLineBreakStyle = tlbsCRLF Then          sTemp := Copy(sTemp, 1, Length(sTemp) - 2)        Else          sTemp := Copy(sTemp, 1, Length(sTemp) - 1);  
If my suspicion is right about that code being overzealous and stripping two chars when there is only one to be stripped, then I'd expect missing characters all over the place.  Replacement code for the above should be TrimChars(<string>, [CR, LF]).  There will be one floating around somewhere.  Not sure, but have to resume work now :-(

Cheers

Mike

UPDATE:   OK, I've broken out an IDE.  No, it wasn't the above code.

Issue is actually in AddTextRun.  I'm parsing over the passed string - looking for internal LF, CR, TAB, so I can turn large collections of text in to actual word paragraphs.

Except, I start my looking at the wrong index :-(

Quick fix:
Line 554 of docxvectorialwriter.pas needs to be changed to:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---          If i >= iStart Then     (it was previously i > iStart, so worked for strings with length > 1)

Better fix:
Mike remembers this time and supplies an actual patch, fixing both this and @JD's issue.


Dean Qin:
@Mike

Thank you for your time & explaination, I use the fix you suggested and It works now (Single char without space)

Navigation

[0] Message Index

[*] Previous page

Go to full version