This project has moved. For the latest updates, please go here.
2
Vote

Found 3 bugs, for 2 I have bugfix.

description

Hello

while using DocX for processing files I found these issues, and I think that for two of them I have also bugfix. But as I don't see deeply into the code I don't know if the bugfix is correct and if it does not break something else.

Please if possible fix these bugs in the sources. I made fix on the latest sources (docx-79962.zip). Modified Paragraph.cs is in the attachment, there is also sample project and test files to test the issues.

Bug1:
Input file contains one line. On the line there are about 10 characters.
First character is colored red, rest is black. So these characters are split
into two 'runs.'
RemoveText(0, 3); causes removal of 1 in the first run, and then 3 characters
in second run, although only 2 should be removed in second run.
Fix of the problem:
Paragraph.cs line 3241
from:
int min = Math.Min(index + processed + (count - processed), run.EndIndex);
to:
int min = Math.Min(index + (count - processed), run.EndIndex);

Bug2:
Issue shows that document does not contain 'r' xml element on the line
which starts with 'tab'. This causes exception in processing.
The line is enclosed in the 'pPr' element though.
Fix of the problem:
Paragraph.cs line 1620
from:
while (Xml.Name.LocalName != "r")
to:
while ((Xml.Name.LocalName != "r") && (Xml.Name.LocalName != "pPr"))

Bug3:
This issue shows that docx document with tracked changes can't be used
File contains only single line and part of the line is marked as deleted.
Call to RemoveText() throws exception because
XElement temp = SplitEdit(splitEditBefore[1], index + min, EditType.del)[0];
returns null.
Fix: not known, I'm not familiar with the topic.

file attachments

comments

bwegiel wrote Oct 1, 2013 at 10:56 PM

Bug1 confirmed.

Thanks for the fix MiroJanosik!
I owe you a beer.

wrote Oct 1, 2013 at 10:56 PM

bwegiel wrote Nov 18, 2013 at 10:23 PM

I would love to see it fixed in next releases. Can you please push it to the trunk? As for now I have to fix it manually in every release I download.

MadBoy wrote Nov 20, 2013 at 9:41 AM

I'll apply it although would be better if you supplied it in the form of Patches. It's easier to find differences.

wrote Nov 22, 2013 at 4:35 PM

bwegiel wrote Nov 22, 2013 at 4:35 PM

Hi,

Not sure about other bugs but I can provide details on Bug1.
Attached is patch containing change in source code as well as new unit test to cover new implementation.

Regards,
Bartosz Węgielewski

MadBoy wrote Nov 26, 2013 at 2:55 PM

Ok it's added. Hope it's useful to you.

BoucherS wrote Apr 24 at 8:24 PM

Hi,

Xceed has this in the commercial version 1.2 (coming out soon, here: https://xceed.com/xceed-words-for-net). Since CodePlex is shutting down, this bug fix will eventually make its way to GitHub in DocX community edition. It will be one at least a version behind the commercial version, though. We are working on the move in May.