]> source.dussan.org Git - poi.git/commitdiff
Fixed XSLFPowerPointExtractor to properly process line breaks, see bugzilla 46568
authorYegor Kozlov <yegor@apache.org>
Mon, 20 Apr 2009 18:04:37 +0000 (18:04 +0000)
committerYegor Kozlov <yegor@apache.org>
Mon, 20 Apr 2009 18:04:37 +0000 (18:04 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@766775 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/changes.xml
src/documentation/content/xdocs/status.xml
src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java

index 380f9c78c9d083429839ce85370825b7b5108472..6619952eedeccda93ab7e90b947d83779eaaa976 100644 (file)
@@ -37,6 +37,7 @@
 
                <!-- Don't forget to update status.xml too! -->
         <release version="3.5-beta6" date="2009-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">46568 - Fixed XSLFPowerPointExtractor to properly process line breaks</action>
            <action dev="POI-DEVELOPERS" type="fix">39056 - Fixed POIFSFileSystem to set CLSID of root when constructing instances from InputStream</action>
            <action dev="POI-DEVELOPERS" type="fix">47054 - Fixed cloneStyleFrom to avoid exception when cloning styles of the same family</action>
            <action dev="POI-DEVELOPERS" type="fix">46186 - Fixed Sheet to read GutsRecord in the Sheet(RecordStream rs)</action>
index ccf0741d9f6fc43f207f88b37331779a62d89d24..7da766676d56e34a8d45fbac7c06a12381da6aa8 100644 (file)
@@ -34,6 +34,7 @@
        <!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.5-beta6" date="2009-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">46568 - Fixed XSLFPowerPointExtractor to properly process line breaks</action>
            <action dev="POI-DEVELOPERS" type="fix">39056 - Fixed POIFSFileSystem to set CLSID of root when constructing instances from InputStream</action>
            <action dev="POI-DEVELOPERS" type="fix">47054 - Fixed cloneStyleFrom to avoid exception when cloning styles of the same family</action>
            <action dev="POI-DEVELOPERS" type="fix">46186 - Fixed Sheet to read GutsRecord in the Sheet(RecordStream rs)</action>
index bb3e9143d1cefdd0742178b6f955ddd6a527140e..9728dcfe658f8db11f6ec3e4f64995e563015afd 100644 (file)
@@ -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");
                                }
index bfcdd6065b606758be0571a85e83a736a3b5df49..17f267b7cbc84f43cde9c26ee67eb4fbe338cd02 100644 (file)
@@ -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");
         }