#62393 - Inconsistent slide import behavior depending on Mac OS X Version
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1831974 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
04bbc80292
commit
e268b16754
@ -458,7 +458,7 @@ public abstract class PackagePart implements RelationshipSource, Comparable<Pack
|
||||
* @see org.apache.poi.openxml4j.opc.RelationshipSource#isRelationshipExists(org.apache.poi.openxml4j.opc.PackageRelationship)
|
||||
*/
|
||||
public boolean isRelationshipExists(PackageRelationship rel) {
|
||||
return _relationships.getRelationshipByID(rel.getId()) != null;
|
||||
return rel != null && _relationships.getRelationshipByID(rel.getId()) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -193,6 +193,9 @@ public final class PackageRelationshipCollection implements
|
||||
* The relationship to add.
|
||||
*/
|
||||
public void addRelationship(PackageRelationship relPart) {
|
||||
if (relPart == null || relPart.getId() == null || relPart.getId().isEmpty()) {
|
||||
throw new IllegalArgumentException("invalid relationship part/id");
|
||||
}
|
||||
relationshipsByID.put(relPart.getId(), relPart);
|
||||
relationshipsByType.put(relPart.getRelationshipType(), relPart);
|
||||
}
|
||||
@ -227,8 +230,7 @@ public final class PackageRelationshipCollection implements
|
||||
|
||||
PackageRelationship rel = new PackageRelationship(container,
|
||||
sourcePart, targetUri, targetMode, relationshipType, id);
|
||||
relationshipsByID.put(rel.getId(), rel);
|
||||
relationshipsByType.put(rel.getRelationshipType(), rel);
|
||||
addRelationship(rel);
|
||||
if (targetMode == TargetMode.INTERNAL){
|
||||
internalRelationshipsByTargetName.put(targetUri.toASCIIString(), rel);
|
||||
}
|
||||
|
@ -50,14 +50,18 @@ public class XSLFHyperlink implements Hyperlink<XSLFShape,XSLFTextParagraph> {
|
||||
|
||||
@Override
|
||||
public String getAddress() {
|
||||
String id = _link.getId();
|
||||
final String id = _link.getId();
|
||||
if (id == null || id.isEmpty()) {
|
||||
return _link.getAction();
|
||||
}
|
||||
|
||||
URI targetURI = _sheet.getPackagePart().getRelationship(id).getTargetURI();
|
||||
|
||||
return targetURI.toASCIIString();
|
||||
final PackageRelationship rel = _sheet.getPackagePart().getRelationship(id);
|
||||
if (rel == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final URI targetURI = rel.getTargetURI();
|
||||
return (targetURI == null) ? null : targetURI.toASCIIString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,6 +30,8 @@ import org.apache.poi.openxml4j.opc.PackageRelationship;
|
||||
import org.apache.poi.sl.usermodel.PictureShape;
|
||||
import org.apache.poi.sl.usermodel.Placeholder;
|
||||
import org.apache.poi.util.Beta;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
import org.apache.xmlbeans.XmlCursor;
|
||||
import org.apache.xmlbeans.XmlException;
|
||||
import org.apache.xmlbeans.XmlObject;
|
||||
@ -52,6 +54,8 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTPictureNonVisual;
|
||||
@Beta
|
||||
public class XSLFPictureShape extends XSLFSimpleShape
|
||||
implements PictureShape<XSLFShape,XSLFTextParagraph> {
|
||||
private static final POILogger LOG = POILogFactory.getLogger(XSLFPictureShape.class);
|
||||
|
||||
private XSLFPictureData _data;
|
||||
|
||||
/*package*/ XSLFPictureShape(CTPicture shape, XSLFSheet sheet) {
|
||||
@ -201,6 +205,11 @@ public class XSLFPictureShape extends XSLFSimpleShape
|
||||
|
||||
XSLFPictureShape p = (XSLFPictureShape)sh;
|
||||
String blipId = p.getBlipId();
|
||||
if (blipId == null) {
|
||||
LOG.log(POILogger.WARN, "unable to copy invalid picture shape");
|
||||
return;
|
||||
}
|
||||
|
||||
String relId = getSheet().importBlip(blipId, p.getSheet().getPackagePart());
|
||||
|
||||
CTPicture ct = (CTPicture)getXmlObject();
|
||||
|
@ -658,7 +658,7 @@ implements XSLFShapeContainer, Sheet<XSLFShape,XSLFTextParagraph> {
|
||||
PackagePart blipPart;
|
||||
try {
|
||||
blipPart = packagePart.getRelatedPart(blipRel);
|
||||
} catch (InvalidFormatException e){
|
||||
} catch (Exception e){
|
||||
throw new POIXMLException(e);
|
||||
}
|
||||
XSLFPictureData data = new XSLFPictureData(blipPart);
|
||||
|
@ -30,6 +30,8 @@ import org.apache.poi.sl.usermodel.PaintStyle;
|
||||
import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
|
||||
import org.apache.poi.sl.usermodel.TextRun;
|
||||
import org.apache.poi.util.Beta;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
import org.apache.poi.xslf.model.CharacterPropertyFetcher;
|
||||
import org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties;
|
||||
import org.apache.xmlbeans.XmlObject;
|
||||
@ -40,6 +42,7 @@ import org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeStyle;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextField;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont;
|
||||
@ -54,6 +57,8 @@ import org.openxmlformats.schemas.drawingml.x2006.main.STTextUnderlineType;
|
||||
*/
|
||||
@Beta
|
||||
public class XSLFTextRun implements TextRun {
|
||||
private static final POILogger LOG = POILogFactory.getLogger(XSLFTextRun.class);
|
||||
|
||||
private final XmlObject _r;
|
||||
private final XSLFTextParagraph _p;
|
||||
|
||||
@ -107,7 +112,8 @@ public class XSLFTextRun implements TextRun {
|
||||
@Override
|
||||
public void setFontColor(PaintStyle color) {
|
||||
if (!(color instanceof SolidPaint)) {
|
||||
throw new IllegalArgumentException("Currently only SolidPaint is supported!");
|
||||
LOG.log(POILogger.WARN, "Currently only SolidPaint is supported!");
|
||||
return;
|
||||
}
|
||||
SolidPaint sp = (SolidPaint)color;
|
||||
Color c = DrawPaint.applyColorTransform(sp.getSolidColor());
|
||||
@ -173,12 +179,18 @@ public class XSLFTextRun implements TextRun {
|
||||
@Override
|
||||
public Double getFontSize(){
|
||||
double scale = 1;
|
||||
CTTextNormalAutofit afit = getParentParagraph().getParentShape().getTextBodyPr().getNormAutofit();
|
||||
if(afit != null) {
|
||||
scale = (double)afit.getFontScale() / 100000;
|
||||
final XSLFTextShape ps = getParentParagraph().getParentShape();
|
||||
if (ps != null) {
|
||||
final CTTextBodyProperties tbp = ps.getTextBodyPr();
|
||||
if (tbp != null) {
|
||||
CTTextNormalAutofit afit = tbp.getNormAutofit();
|
||||
if (afit != null && afit.isSetFontScale()) {
|
||||
scale = afit.getFontScale() / 100000.;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CharacterPropertyFetcher<Double> fetcher = new CharacterPropertyFetcher<Double>(_p.getIndentLevel()){
|
||||
final CharacterPropertyFetcher<Double> fetcher = new CharacterPropertyFetcher<Double>(_p.getIndentLevel()){
|
||||
@Override
|
||||
public boolean fetch(CTTextCharacterProperties props){
|
||||
if (props != null && props.isSetSz()) {
|
||||
|
Loading…
Reference in New Issue
Block a user