You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2012/02/26 07:22:09 UTC
svn commit: r1293748 - in /poi/trunk/src: documentation/content/xdocs/
ooxml/java/org/apache/poi/xslf/usermodel/
ooxml/java/org/apache/poi/xssf/usermodel/
ooxml/java/org/apache/poi/xwpf/usermodel/
ooxml/testcases/org/apache/poi/xwpf/usermodel/
Author: yegor
Date: Sun Feb 26 06:22:09 2012
New Revision: 1293748
URL: http://svn.apache.org/viewvc?rev=1293748&view=rev
Log:
Bugzilla 52255 - support adding TIFF,EPS and WPG pictures in OOXML documents
Modified:
poi/trunk/src/documentation/content/xdocs/status.xml
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFRelation.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPictureData.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRelation.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/Document.java
poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java
poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.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=1293748&r1=1293747&r2=1293748&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Sun Feb 26 06:22:09 2012
@@ -34,6 +34,7 @@
<changes>
<release version="3.8-beta6" date="2012-??-??">
+ <action dev="poi-developers" type="fix">52255 - support adding TIFF,EPS and WPG pictures in OOXML documents </action>
<action dev="poi-developers" type="fix">52078 - avoid OutOfMemoryError when rendering groupped pictures in HSLF </action>
<action dev="poi-developers" type="fix">52745 - fixed XSSFRichtextString.append to preserve leading / trailing spaces </action>
<action dev="poi-developers" type="fix">52716 - tolerate hyperlinks that have neither location nor relation </action>
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java?rev=1293748&r1=1293747&r2=1293748&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java Sun Feb 26 06:22:09 2012
@@ -72,12 +72,33 @@ public final class XSLFPictureData exten
public static final int PICTURE_TYPE_GIF = 8;
/**
+ * Tag Image File (.tiff)
+ */
+ public static final int PICTURE_TYPE_TIFF = 9;
+
+ /**
+ * Encapsulated Postscript (.eps)
+ */
+ public static final int PICTURE_TYPE_EPS = 10;
+
+
+ /**
+ * Windows Bitmap (.bmp)
+ */
+ public static final int PICTURE_TYPE_BMP = 11;
+
+ /**
+ * WordPerfect graphics (.wpg)
+ */
+ public static final int PICTURE_TYPE_WPG = 12;
+
+ /**
* Relationships for each known picture type
*/
protected static final POIXMLRelation[] RELATIONS;
static {
- RELATIONS = new POIXMLRelation[9];
+ RELATIONS = new POIXMLRelation[13];
RELATIONS[PICTURE_TYPE_EMF] = XSLFRelation.IMAGE_EMF;
RELATIONS[PICTURE_TYPE_WMF] = XSLFRelation.IMAGE_WMF;
RELATIONS[PICTURE_TYPE_PICT] = XSLFRelation.IMAGE_PICT;
@@ -85,6 +106,10 @@ public final class XSLFPictureData exten
RELATIONS[PICTURE_TYPE_PNG] = XSLFRelation.IMAGE_PNG;
RELATIONS[PICTURE_TYPE_DIB] = XSLFRelation.IMAGE_DIB;
RELATIONS[PICTURE_TYPE_GIF] = XSLFRelation.IMAGE_GIF;
+ RELATIONS[PICTURE_TYPE_TIFF] = XSLFRelation.IMAGE_TIFF;
+ RELATIONS[PICTURE_TYPE_EPS] = XSLFRelation.IMAGE_EPS;
+ RELATIONS[PICTURE_TYPE_BMP] = XSLFRelation.IMAGE_BMP;
+ RELATIONS[PICTURE_TYPE_WPG] = XSLFRelation.IMAGE_WPG;
}
private Long checksum = null;
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFRelation.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFRelation.java?rev=1293748&r1=1293747&r2=1293748&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFRelation.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFRelation.java Sun Feb 26 06:22:09 2012
@@ -182,6 +182,30 @@ public class XSLFRelation extends POIXML
"/ppt/media/image#.gif",
XSLFPictureData.class
);
+ public static final XSLFRelation IMAGE_TIFF = new XSLFRelation(
+ "image/tiff",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/ppt/media/image#.tiff",
+ XSLFPictureData.class
+ );
+ public static final XSLFRelation IMAGE_EPS = new XSLFRelation(
+ "image/x-eps",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/ppt/media/image#.eps",
+ XSLFPictureData.class
+ );
+ public static final XSLFRelation IMAGE_BMP = new XSLFRelation(
+ "image/x-ms-bmp",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/ppt/media/image#.bmp",
+ XSLFPictureData.class
+ );
+ public static final XSLFRelation IMAGE_WPG = new XSLFRelation(
+ "image/x-wpg",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/ppt/media/image#.wpg",
+ XSLFPictureData.class
+ );
public static final XSLFRelation IMAGES = new XSLFRelation(
null,
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPictureData.java?rev=1293748&r1=1293747&r2=1293748&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPictureData.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPictureData.java Sun Feb 26 06:22:09 2012
@@ -39,13 +39,18 @@ public class XSSFPictureData extends POI
*/
protected static final POIXMLRelation[] RELATIONS;
static {
- RELATIONS = new POIXMLRelation[8];
+ RELATIONS = new POIXMLRelation[13];
RELATIONS[Workbook.PICTURE_TYPE_EMF] = XSSFRelation.IMAGE_EMF;
RELATIONS[Workbook.PICTURE_TYPE_WMF] = XSSFRelation.IMAGE_WMF;
RELATIONS[Workbook.PICTURE_TYPE_PICT] = XSSFRelation.IMAGE_PICT;
RELATIONS[Workbook.PICTURE_TYPE_JPEG] = XSSFRelation.IMAGE_JPEG;
RELATIONS[Workbook.PICTURE_TYPE_PNG] = XSSFRelation.IMAGE_PNG;
RELATIONS[Workbook.PICTURE_TYPE_DIB] = XSSFRelation.IMAGE_DIB;
+ RELATIONS[XSSFWorkbook.PICTURE_TYPE_GIF] = XSSFRelation.IMAGE_GIF;
+ RELATIONS[XSSFWorkbook.PICTURE_TYPE_TIFF] = XSSFRelation.IMAGE_TIFF;
+ RELATIONS[XSSFWorkbook.PICTURE_TYPE_EPS] = XSSFRelation.IMAGE_EPS;
+ RELATIONS[XSSFWorkbook.PICTURE_TYPE_BMP] = XSSFRelation.IMAGE_BMP;
+ RELATIONS[XSSFWorkbook.PICTURE_TYPE_WPG] = XSSFRelation.IMAGE_WPG;
}
/**
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRelation.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRelation.java?rev=1293748&r1=1293747&r2=1293748&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRelation.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRelation.java Sun Feb 26 06:22:09 2012
@@ -191,6 +191,38 @@ public final class XSSFRelation extends
XSSFPictureData.class
);
+ public static final XSSFRelation IMAGE_GIF = new XSSFRelation(
+ "image/gif",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/xl/media/image#.gif",
+ XSSFPictureData.class
+ );
+
+ public static final XSSFRelation IMAGE_TIFF = new XSSFRelation(
+ "image/tiff",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/xl/media/image#.tiff",
+ XSSFPictureData.class
+ );
+ public static final XSSFRelation IMAGE_EPS = new XSSFRelation(
+ "image/x-eps",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/xl/media/image#.eps",
+ XSSFPictureData.class
+ );
+ public static final XSSFRelation IMAGE_BMP = new XSSFRelation(
+ "image/x-ms-bmp",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/xl/media/image#.bmp",
+ XSSFPictureData.class
+ );
+ public static final XSSFRelation IMAGE_WPG = new XSSFRelation(
+ "image/x-wpg",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/xl/media/image#.wpg",
+ XSSFPictureData.class
+ );
+
public static final XSSFRelation SHEET_COMMENTS = new XSSFRelation(
"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=1293748&r1=1293747&r2=1293748&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java Sun Feb 26 06:22:09 2012
@@ -82,6 +82,15 @@ public class XSSFWorkbook extends POIXML
private static final int MAX_SENSITIVE_SHEET_NAME_LEN = 31;
/**
+ * Images formats supported by XSSF but not by HSSF
+ */
+ public static final int PICTURE_TYPE_GIF = 8;
+ public static final int PICTURE_TYPE_TIFF = 9;
+ public static final int PICTURE_TYPE_EPS = 10;
+ public static final int PICTURE_TYPE_BMP = 11;
+ public static final int PICTURE_TYPE_WPG = 12;
+
+ /**
* The underlying XML bean
*/
private CTWorkbook workbook;
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/Document.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/Document.java?rev=1293748&r1=1293747&r2=1293748&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/Document.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/Document.java Sun Feb 26 06:22:09 2012
@@ -37,5 +37,25 @@ public interface Document {
/** GIF image format */
public static final int PICTURE_TYPE_GIF = 8;
-
+
+ /**
+ * Tag Image File (.tiff)
+ */
+ public static final int PICTURE_TYPE_TIFF = 9;
+
+ /**
+ * Encapsulated Postscript (.eps)
+ */
+ public static final int PICTURE_TYPE_EPS = 10;
+
+
+ /**
+ * Windows Bitmap (.bmp)
+ */
+ public static final int PICTURE_TYPE_BMP = 11;
+
+ /**
+ * WordPerfect graphics (.wpg)
+ */
+ public static final int PICTURE_TYPE_WPG = 12;
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java?rev=1293748&r1=1293747&r2=1293748&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java Sun Feb 26 06:22:09 2012
@@ -44,7 +44,7 @@ public class XWPFPictureData extends POI
*/
protected static final POIXMLRelation[] RELATIONS;
static {
- RELATIONS = new POIXMLRelation[9];
+ RELATIONS = new POIXMLRelation[13];
RELATIONS[Document.PICTURE_TYPE_EMF] = XWPFRelation.IMAGE_EMF;
RELATIONS[Document.PICTURE_TYPE_WMF] = XWPFRelation.IMAGE_WMF;
RELATIONS[Document.PICTURE_TYPE_PICT] = XWPFRelation.IMAGE_PICT;
@@ -52,6 +52,10 @@ public class XWPFPictureData extends POI
RELATIONS[Document.PICTURE_TYPE_PNG] = XWPFRelation.IMAGE_PNG;
RELATIONS[Document.PICTURE_TYPE_DIB] = XWPFRelation.IMAGE_DIB;
RELATIONS[Document.PICTURE_TYPE_GIF] = XWPFRelation.IMAGE_GIF;
+ RELATIONS[Document.PICTURE_TYPE_TIFF] = XWPFRelation.IMAGE_TIFF;
+ RELATIONS[Document.PICTURE_TYPE_EPS] = XWPFRelation.IMAGE_EPS;
+ RELATIONS[Document.PICTURE_TYPE_BMP] = XWPFRelation.IMAGE_BMP;
+ RELATIONS[Document.PICTURE_TYPE_WPG] = XWPFRelation.IMAGE_WPG;
}
private Long checksum = null;
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java?rev=1293748&r1=1293747&r2=1293748&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java Sun Feb 26 06:22:09 2012
@@ -131,7 +131,10 @@ public final class XWPFRelation extends
null,
null
);
-
+
+ /**
+ * Supported image formats
+ */
public static final XWPFRelation IMAGE_EMF = new XWPFRelation(
"image/x-emf",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
@@ -174,6 +177,31 @@ public final class XWPFRelation extends
"/word/media/image#.gif",
XWPFPictureData.class
);
+ public static final XWPFRelation IMAGE_TIFF = new XWPFRelation(
+ "image/tiff",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/word/media/image#.tiff",
+ XWPFPictureData.class
+ );
+ public static final XWPFRelation IMAGE_EPS = new XWPFRelation(
+ "image/x-eps",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/word/media/image#.eps",
+ XWPFPictureData.class
+ );
+ public static final XWPFRelation IMAGE_BMP = new XWPFRelation(
+ "image/x-ms-bmp",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/word/media/image#.bmp",
+ XWPFPictureData.class
+ );
+ public static final XWPFRelation IMAGE_WPG = new XWPFRelation(
+ "image/x-wpg",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/word/media/image#.wpg",
+ XWPFPictureData.class
+ );
+
public static final XWPFRelation IMAGES = new XWPFRelation(
null,
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java?rev=1293748&r1=1293747&r2=1293748&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java Sun Feb 26 06:22:09 2012
@@ -139,6 +139,27 @@ public final class TestXWPFDocument exte
assertEquals(newJpeg[i],jpeg[i]);
}
}
+ public void testAllPictureFormats() throws IOException, InvalidFormatException {
+ XWPFDocument doc = new XWPFDocument();
+
+ doc.addPictureData(new byte[10], XWPFDocument.PICTURE_TYPE_EMF);
+ doc.addPictureData(new byte[11], XWPFDocument.PICTURE_TYPE_WMF);
+ doc.addPictureData(new byte[12], XWPFDocument.PICTURE_TYPE_PICT);
+ doc.addPictureData(new byte[13], XWPFDocument.PICTURE_TYPE_JPEG);
+ doc.addPictureData(new byte[14], XWPFDocument.PICTURE_TYPE_PNG);
+ doc.addPictureData(new byte[15], XWPFDocument.PICTURE_TYPE_DIB);
+ doc.addPictureData(new byte[16], XWPFDocument.PICTURE_TYPE_GIF);
+ doc.addPictureData(new byte[17], XWPFDocument.PICTURE_TYPE_TIFF);
+ doc.addPictureData(new byte[18], XWPFDocument.PICTURE_TYPE_EPS);
+ doc.addPictureData(new byte[19], XWPFDocument.PICTURE_TYPE_BMP);
+ doc.addPictureData(new byte[20], XWPFDocument.PICTURE_TYPE_WPG);
+
+ assertEquals(11, doc.getAllPictures().size());
+
+ doc = XWPFTestDataSamples.writeOutAndReadBack(doc);
+ assertEquals(11, doc.getAllPictures().size());
+
+ }
public void testRemoveBodyElement() throws IOException {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("sample.docx");
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org