poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r1203969 - in /poi/trunk/src: documentation/content/xdocs/ ooxml/java/org/apache/poi/xslf/usermodel/
Date Sat, 19 Nov 2011 12:28:33 GMT
Author: yegor
Date: Sat Nov 19 12:28:33 2011
New Revision: 1203969

URL: http://svn.apache.org/viewvc?rev=1203969&view=rev
Log:
Bugzilla 52209: fixed inserting multiple pictures to a group or slide in XSLF

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1203969&r1=1203968&r2=1203969&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Sat Nov 19 12:28:33 2011
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta5" date="2011-??-??">
+           <action dev="poi-developers" type="fix">52209 - fixed inserting multiple
pictures in XSLF </action>
            <action dev="poi-developers" type="fix">51803 - fixed HSLF TextExtractor
to extract content from master slide </action>
            <action dev="poi-developers" type="fix">52190 - null check on XWPF setFontFamily</action>
            <action dev="poi-developers" type="fix">52062 - ensure that temporary files
in SXSSF are deleted</action>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java?rev=1203969&r1=1203968&r2=1203969&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java Sat Nov 19 12:28:33
2011
@@ -338,7 +338,7 @@ public class XMLSlideShow  extends POIXM
     public int addPicture(byte[] pictureData, int format) {
         getAllPictures();
         
-        int imageNumber = getPackage().getPartsByName(Pattern.compile("/ppt/media/.*?")).size()
+ 1;
+        int imageNumber = _pictures.size() + 1;
         XSLFPictureData img = (XSLFPictureData) createRelationship(
                 XSLFPictureData.RELATIONS[format], XSLFFactory.getInstance(), imageNumber,
true);
         _pictures.add(img);

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java?rev=1203969&r1=1203968&r2=1203969&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java Sat Nov 19
12:28:33 2011
@@ -227,9 +227,13 @@ public class XSLFGroupShape extends XSLF
     public XSLFPictureShape createPicture(int pictureIndex){
 
         List<PackagePart>  pics = _sheet.getPackagePart().getPackage()
-                .getPartsByName(Pattern.compile("/ppt/media/.*?"));
+                .getPartsByName(Pattern.compile("/ppt/media/image" + (pictureIndex + 1) +
".*?"));
 
-        PackagePart pic = pics.get(pictureIndex);
+        if(pics.size() == 0) {
+            throw new IllegalArgumentException("Picture with index=" + pictureIndex + " was
not found");
+        }
+
+        PackagePart pic = pics.get(0);
 
         PackageRelationship rel = _sheet.getPackagePart().addRelationship(
                 pic.getPartName(), TargetMode.INTERNAL, XSLFRelation.IMAGES.getRelation());

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java?rev=1203969&r1=1203968&r2=1203969&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java Sat Nov 19 12:28:33
2011
@@ -172,9 +172,13 @@ public abstract class XSLFSheet extends 
 
     public XSLFPictureShape createPicture(int pictureIndex){
         List<PackagePart>  pics = getPackagePart().getPackage()
-                .getPartsByName(Pattern.compile("/ppt/media/.*?"));
+                .getPartsByName(Pattern.compile("/ppt/media/image" + (pictureIndex + 1) +
".*?"));
 
-        PackagePart pic = pics.get(pictureIndex);
+        if(pics.size() == 0) {
+            throw new IllegalArgumentException("Picture with index=" + pictureIndex + " was
not found");
+        }
+
+        PackagePart pic = pics.get(0);
 
         PackageRelationship rel = getPackagePart().addRelationship(
                 pic.getPartName(), TargetMode.INTERNAL, XSLFRelation.IMAGES.getRelation());

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java?rev=1203969&r1=1203968&r2=1203969&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java Sat Nov
19 12:28:33 2011
@@ -841,18 +841,22 @@ public class XSLFTextParagraph implement
                  layout = measurer.nextLayout((float)wrappingWidth, nextBreak, false);
             }
 
-            int endIndex = measurer.getPosition();
-
-            TextAlign hAlign = getTextAlign();
-            if(hAlign == TextAlign.JUSTIFY || hAlign == TextAlign.JUSTIFY_LOW) {
-                layout = layout.getJustifiedLayout((float)wrappingWidth);
+            if(layout == null) {
+                // exit if can't break any more
+                break;
             }
 
+            int endIndex = measurer.getPosition();
             // skip over new line breaks (we paint 'clear' text runs not starting or ending
with \n)
             if(endIndex < it.getEndIndex() && text.charAt(endIndex) == '\n'){
                 measurer.setPosition(endIndex + 1);
             }
 
+            TextAlign hAlign = getTextAlign();
+            if(hAlign == TextAlign.JUSTIFY || hAlign == TextAlign.JUSTIFY_LOW) {
+                layout = layout.getJustifiedLayout((float)wrappingWidth);
+            }
+
             AttributedString str = new AttributedString(it, startIndex, endIndex);
             TextFragment line = new TextFragment(
                     layout, // we will not paint empty paragraphs



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


Mime
View raw message