From: Yegor Kozlov Date: Mon, 20 Apr 2009 18:04:37 +0000 (+0000) Subject: Fixed XSLFPowerPointExtractor to properly process line breaks, see bugzilla 46568 X-Git-Tag: REL_3_5_BETA6~50 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=67ba7a20983ea00fbcfd7e06037ea67ca9c881e6;p=poi.git Fixed XSLFPowerPointExtractor to properly process line breaks, see bugzilla 46568 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@766775 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index 380f9c78c9..6619952eed 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -37,6 +37,7 @@ + 46568 - Fixed XSLFPowerPointExtractor to properly process line breaks 39056 - Fixed POIFSFileSystem to set CLSID of root when constructing instances from InputStream 47054 - Fixed cloneStyleFrom to avoid exception when cloning styles of the same family 46186 - Fixed Sheet to read GutsRecord in the Sheet(RecordStream rs) diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index ccf0741d9f..7da766676d 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 46568 - Fixed XSLFPowerPointExtractor to properly process line breaks 39056 - Fixed POIFSFileSystem to set CLSID of root when constructing instances from InputStream 47054 - Fixed cloneStyleFrom to avoid exception when cloning styles of the same family 46186 - Fixed Sheet to read GutsRecord in the Sheet(RecordStream rs) diff --git a/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java b/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java index bb3e9143d1..9728dcfe65 100644 --- a/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java +++ b/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java @@ -25,9 +25,12 @@ import org.apache.poi.xslf.XSLFSlideShow; import org.apache.poi.xslf.usermodel.XMLSlideShow; import org.apache.poi.xslf.usermodel.XSLFSlide; import org.apache.xmlbeans.XmlException; +import org.apache.xmlbeans.XmlObject; +import org.apache.xmlbeans.XmlCursor; import org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun; import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody; import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph; +import org.openxmlformats.schemas.drawingml.x2006.main.CTTextLineBreak; import org.openxmlformats.schemas.presentationml.x2006.main.CTComment; import org.openxmlformats.schemas.presentationml.x2006.main.CTCommentList; import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape; @@ -140,11 +143,18 @@ public class XSLFPowerPointExtractor extends POIXMLTextExtractor { CTTextParagraph[] paras = textBody.getPArray(); for (int j = 0; j < paras.length; j++) { - CTRegularTextRun[] textRuns = - paras[j].getRArray(); - for (int k = 0; k < textRuns.length; k++) { - text.append( textRuns[k].getT() ); - } + XmlCursor c = paras[j].newCursor(); + c.selectPath("./*"); + while (c.toNextSelection()) { + XmlObject o = c.getObject(); + if(o instanceof CTRegularTextRun){ + CTRegularTextRun txrun = (CTRegularTextRun)o; + text.append( txrun.getT() ); + } else if (o instanceof CTTextLineBreak){ + text.append('\n'); + } + } + // End each paragraph with a new line text.append("\n"); } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java index bfcdd6065b..17f267b7cb 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java @@ -111,7 +111,9 @@ public class XSSFCellStyle implements CellStyle { */ public void cloneStyleFrom(CellStyle source) { if(source instanceof XSSFCellStyle) { - this.cloneStyleFrom(source); + XSSFCellStyle src = (XSSFCellStyle)source; + cellXf.set(src.getCoreXf()); + cellStyleXf.set(src.getStyleXf()); } else { throw new IllegalArgumentException("Can only clone from one XSSFCellStyle to another, not between HSSFCellStyle and XSSFCellStyle"); }