You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2020/10/21 17:40:14 UTC
[Bug 64838] New: Loading and saving a file, adds an unwanted
tag
https://bz.apache.org/bugzilla/show_bug.cgi?id=64838
Bug ID: 64838
Summary: Loading and saving a file, adds an unwanted <w:p/> tag
Product: POI
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P2
Component: XWPF
Assignee: dev@poi.apache.org
Reporter: nadavbenedek@gmail.com
Target Milestone: ---
Created attachment 37517
--> https://bz.apache.org/bugzilla/attachment.cgi?id=37517&action=edit
Example file to regenerate the bug
Loading and saving a file, adds an unwanted <w:p/> tag in the output file.
Here's the code to regenerate the problem:
FileInputStream inputFis = new FileInputStream("test6.docx");
XWPFDocument doc = new XWPFDocument(inputFis);
doc.write(new FileOutputStream(new File("test6_out.docx")));
doc.close();
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 64838] Loading and saving a file adds an unwanted tag
resulting in additional newlines in the document
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64838
--- Comment #5 from Dominik Stadler <do...@gmx.at> ---
The following change would remove this check and adding of the paragraph, but
it seems to have been added for a reason a long time ago, probably for a
similar reason to what Sayi explained, so I fear reverting this in general
might have side-effects on other documents.
Index: src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java
(revision d427ca10e24dfc4b43985a0dd87ad750ca1e18ba)
+++ src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java
(revision 3304c1bdfa571730386f147116586917ac40762f)
@@ -80,9 +80,7 @@
this.ctTc = cell;
this.part = part;
this.tableRow = tableRow;
- // NB: If a table cell does not include at least one block-level
element, then this document shall be considered corrupt.
- if (cell.sizeOfPArray() < 1)
- cell.addNewP();
+
bodyElements = new ArrayList<>();
paragraphs = new ArrayList<>();
tables = new ArrayList<>();
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 64838] Loading and saving a file, adds an unwanted tag
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64838
--- Comment #3 from Sayi <sa...@163.com> ---
I think there will be an error when opening your document in some versions of
word processing software: table cell should include at least one block-level
element.
For example, if you add a paragraph to the cell, the new paragraph will not be
added automatically.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 64838] Loading and saving a file, adds an unwanted tag
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64838
--- Comment #4 from NadavB <na...@gmail.com> ---
Is there a way to simulate with POI an opening of a file with LibreOffice and
saving it, to fix these kinds of issues?
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 64838] Loading and saving a file adds an unwanted tag
resulting in additional newlines in the document
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64838
--- Comment #7 from Sayi <sa...@163.com> ---
see bug #65292
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 64838] Loading and saving a file, adds an unwanted tag
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64838
--- Comment #2 from NadavB <na...@gmail.com> ---
Yes, there is a problem - a new line is added. I view it with LibreOffice
Writer.
Do you see that a new tag <w:p/> is added? That's a new paragraph.
Why loading a document xml and saving it should change the structure by Apache
POI?
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 64838] Loading and saving a file adds an unwanted tag
resulting in additional newlines in the document
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64838
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #6 from Dominik Stadler <do...@gmx.at> ---
I thought some more about this and decided to try to remove this behavior as it
seems unwanted and is likely a very old remnant of the early implementation
here.
We'll see if there are cases that need this behavior and can then re-add it
under some better conditions that do not change files in such an unexpected
way.
This is done via r1884958.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 64838] Loading and saving a file adds an unwanted tag
resulting in additional newlines in the document
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64838
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEEDINFO |NEW
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 64838] Loading and saving a file adds an unwanted tag
resulting in additional newlines in the document
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64838
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Loading and saving a file, |Loading and saving a file
|adds an unwanted <w:p/> tag |adds an unwanted <w:p/> tag
| |resulting in additional
| |newlines in the document
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 64838] Loading and saving a file, adds an unwanted tag
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64838
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |NEEDINFO
--- Comment #1 from Dominik Stadler <do...@gmx.at> ---
Does it actually cause a problem or is just some of your custom parsing strict
about the elements?
I don't see a visual difference caused by this tag and if I load/save the file
with LibreOffice, the structure is stored completely differently anyway.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org