You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Henning Femmer <fe...@in.tum.de> on 2015/06/19 18:12:45 UTC

Re: Accepting all Changes / Reading only accepted changes

Dear poi developers,

just fyi:
The problem lays in the fact that the paragraph.getText() method refers to the toString() without checking whether there is a deletion associated with it.
I now wrote a workaround to fix this issue for myself, feel free to adapt and include it in the code, if you like:

	public static String getBasicTextFromParagraphWithoutDeletions(
			XWPFParagraph par) {
		StringBuffer out = new StringBuffer();
		for (IRunElement run : par.getIRuns()) {
			if (run instanceof XWPFRun) {
				XWPFRun xRun = (XWPFRun) run;
				if (xRun.getCTR().getRsidDel() == null) {
					out.append(xRun.toString());
				}
			} else if (run instanceof XWPFSDT) {
				out.append(((XWPFSDT) run).getContent().getText());
			} else {
				out.append(run.toString());
			}
		}
		return out.toString();
	}

Best,
Henning
-------------------------------------------------------------------------------------------------

Technische Universität München

Henning Femmer . Phone +49 (89) 289-17080
Faculty of Informatics . Software & Systems Engineering
Room 00.11.064 . femmer@in.tum.de <ma...@in.tum.de> . http://www4.in.tum.de/~femmer <http://www4.in.tum.de/~femmer>
-------------------------------------------------------------------------------------------------


> On 08 Apr 2015, at 16:35, Henning Femmer <fe...@in.tum.de> wrote:
> 
> Dear all,
> 
> I’m looking for a simple solution to parse only the newest version of an XWPF file (as if all changes are accepted or so). As far as I could google and browse through the javadoc there is no such functionality in apache poi, is that correct?
> If I wanted to access this information, how would I have to approach the problem?
> I would be willing to contribute a patch, if that is necessary.
> 
> Best,
> Henning
> -------------------------------------------------------------------------------------------------
> 
> Technische Universität München
> 
> Henning Femmer . Phone +49 (89) 289-17080
> Faculty of Informatics . Software & Systems Engineering
> Room 00.11.064 . femmer@in.tum.de <ma...@in.tum.de> . http://www4.in.tum.de/~femmer <http://www4.in.tum.de/~femmer>
> -------------------------------------------------------------------------------------------------
> 
> 


Re: Accepting all Changes / Reading only accepted changes

Posted by Nick Burch <ap...@gagravarr.org>.
On Fri, 19 Jun 2015, Henning Femmer wrote:
> I now wrote a workaround to fix this issue for myself, feel free to 
> adapt and include it in the code, if you like:

Would you be able to raise a new bug in bugzilla, and post your code 
there? Bonus marks if you could also upload a very small word file that 
can be used to trigger the problem, and a junit test that shows it up?

http://poi.apache.org/guidelines.html#SubmittingPatches should talk you 
through the process of doing a full-blown patch, smaller code snippets can 
work too though!

Thanks
Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org