From e350093be6e4c3403b95f98afeb3f0e357cbaebb Mon Sep 17 00:00:00 2001 From: Maxim Valyanskiy Date: Wed, 17 Nov 2010 08:13:40 +0000 Subject: [PATCH] dispose xml cursor when iteration over it is done (more) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1035947 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/poi/xslf/usermodel/DrawingParagraph.java | 2 ++ .../org/apache/poi/xslf/usermodel/XSLFCommonSlideData.java | 2 ++ .../java/org/apache/poi/xwpf/usermodel/XWPFDocument.java | 1 + src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java | 2 ++ src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java | 2 ++ .../java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java | 2 ++ .../java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java | 4 ++++ src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java | 2 ++ .../java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java | 2 ++ 9 files changed, 19 insertions(+) diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/DrawingParagraph.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/DrawingParagraph.java index e2dcc6cf4..f1e84ce6c 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/DrawingParagraph.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/DrawingParagraph.java @@ -44,6 +44,8 @@ public class DrawingParagraph { text.append('\n'); } } + + c.dispose(); return text; } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommonSlideData.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommonSlideData.java index a926d8b3f..3716f7e93 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommonSlideData.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommonSlideData.java @@ -69,6 +69,8 @@ public class XSLFCommonSlideData { } } } + + c.dispose(); } return out; diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java index 3d1ee2a58..4188cbdac 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java @@ -1098,6 +1098,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody { CTRow row = (CTRow)o; cursor.toParent(); o = cursor.getObject(); + cursor.dispose(); if(! (o instanceof CTTbl)){ return null; } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java index 73834d767..feaf9f7dd 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java @@ -66,6 +66,7 @@ public class XWPFFooter extends XWPFHeaderFooter { bodyElements.add(t); } } + cursor.dispose(); getAllPictures(); } @@ -125,6 +126,7 @@ public class XWPFFooter extends XWPFHeaderFooter { bodyElements.add(t); } } + cursor.dispose(); getAllPictures(); } catch (IOException e) { // TODO Auto-generated catch block diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java index d49aa5d7e..07f59afff 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java @@ -67,6 +67,7 @@ public class XWPFHeader extends XWPFHeaderFooter { tables.add(t); } } + cursor.dispose(); getAllPictures(); } @@ -131,6 +132,7 @@ public class XWPFHeader extends XWPFHeaderFooter { bodyElements.add(t); } } + cursor.dispose(); getAllPictures(); } catch (IOException e) { // TODO Auto-generated catch block diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java index 5aedc15f9..96274be21 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java @@ -504,6 +504,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo bodyElements.add(t); } } + cursor.dispose(); getAllPictures(); } @@ -521,6 +522,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo CTRow row = (CTRow)o; cursor.toParent(); o = cursor.getObject(); + cursor.dispose(); if(! (o instanceof CTTbl)){ return null; } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java index 2e7e16f3e..2833695e9 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java @@ -107,6 +107,8 @@ public class XWPFParagraph implements IBodyElement{ } } } + + c.dispose(); // Look for bits associated with the runs for(XWPFRun run : runs) { @@ -1159,6 +1161,8 @@ public class XWPFParagraph implements IBodyElement{ else candCharPos=0; } + + c.dispose(); } return null; } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java index 067f2c088..0e8bbb20a 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java @@ -628,6 +628,8 @@ public class XWPFRun { } } } + + c.dispose(); // Any picture text? if(pictureText != null && pictureText.length() > 0) { diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java index 656bf307a..9ffb65a34 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java @@ -65,6 +65,7 @@ public class XWPFTableCell implements IBody { bodyElements.add(t); } } + cursor.dispose(); } @@ -336,6 +337,7 @@ public class XWPFTableCell implements IBody { CTRow row = (CTRow)o; cursor.toParent(); o = cursor.getObject(); + cursor.dispose(); if(! (o instanceof CTTbl)){ return null; }