Bugzilla 52209: fixed inserting multiple pictures to a group or slide in XSLF

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1203969 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yegor Kozlov 2011-11-19 12:28:33 +00:00
parent 1d81b3e8bc
commit f07f08293c
5 changed files with 23 additions and 10 deletions

View File

@ -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>

View File

@ -338,7 +338,7 @@ public class XMLSlideShow extends POIXMLDocument {
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);

View File

@ -227,9 +227,13 @@ public class XSLFGroupShape extends XSLFShape {
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());

View File

@ -172,9 +172,13 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements Iterable<X
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());

View File

@ -841,18 +841,22 @@ public class XSLFTextParagraph implements Iterable<XSLFTextRun>{
layout = measurer.nextLayout((float)wrappingWidth, nextBreak, false);
}
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);
}
// 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);
}
AttributedString str = new AttributedString(it, startIndex, endIndex);
TextFragment line = new TextFragment(
layout, // we will not paint empty paragraphs