Author: fanningpj
Date: Wed Jul 20 23:04:02 2022
New Revision: 1902898
URL: http://svn.apache.org/viewvc?rev=1902898&view=rev
Log:
add getPictureTypeEnum
Added:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/PictureType.java
(with props)
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java
Added:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/PictureType.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/PictureType.java?rev=1902898&view=auto
==============================================================================
---
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/PictureType.java
(added)
+++
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/PictureType.java
Wed Jul 20 23:04:02 2022
@@ -0,0 +1,102 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.xwpf.usermodel;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @since POI 5.2.3
+ */
+public enum PictureType {
+ /**
+ * Extended windows meta file
+ */
+ EMF(Document.PICTURE_TYPE_EMF),
+ /**
+ * Windows Meta File
+ */
+ WMF(Document.PICTURE_TYPE_WMF),
+ /**
+ * Mac PICT format
+ */
+ PICT(Document.PICTURE_TYPE_PICT),
+ /**
+ * JPEG format
+ */
+ JPEG(Document.PICTURE_TYPE_JPEG),
+ /**
+ * JPEG format
+ */
+ PNG(Document.PICTURE_TYPE_PNG),
+ /**
+ * Device independent bitmap
+ */
+ DIB(Document.PICTURE_TYPE_DIB),
+ /**
+ * GIF image format
+ */
+ GIF(Document.PICTURE_TYPE_GIF),
+ /**
+ * Tag Image File (.tiff)
+ */
+ TIFF(Document.PICTURE_TYPE_TIFF),
+ /**
+ * Encapsulated Postscript (.eps)
+ */
+ EPS(Document.PICTURE_TYPE_EPS),
+ /**
+ * Windows Bitmap (.bmp)
+ */
+ BMP(Document.PICTURE_TYPE_BMP),
+ /**
+ * WordPerfect graphics (.wpg)
+ */
+ WPG(Document.PICTURE_TYPE_WPG);
+
+ /**
+ * Map relating the old API constant values to their corresponding
+ * enumeration value
+ */
+ private static final Map<Integer, PictureType> PICTURE_TYPE_BY_ID;
+
+ static {
+ PICTURE_TYPE_BY_ID = new HashMap<>();
+
+ for (PictureType pictureType : values()) {
+ PICTURE_TYPE_BY_ID.put(pictureType.id, pictureType);
+ }
+ }
+
+ private int id;
+
+ PictureType(int id) {
+ this.id = id;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id for PictureType
+ * @return PictureType, null if id does not match any PictureTypes
+ */
+ public static PictureType findById(int id) {
+ return PICTURE_TYPE_BY_ID.get(id);
+ }
+}
Propchange:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/PictureType.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java?rev=1902898&r1=1902897&r2=1902898&view=diff
==============================================================================
---
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java
(original)
+++
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java
Wed Jul 20 23:04:02 2022
@@ -145,7 +145,9 @@ public class XWPFPictureData extends POI
* @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_PICT
* @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_JPEG
* @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_PNG
+ * @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_GIF
* @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_DIB
+ * @see {@link #getPictureTypeEnum()}
*/
public int getPictureType() {
String contentType = getPackagePart().getContentType();
@@ -161,6 +163,16 @@ public class XWPFPictureData extends POI
return 0;
}
+ /**
+ * Return a {@link PictureType} that specifies type of this picture
+ *
+ * @return a {@link PictureType}, returns null if an unknown type
+ * @since POI 5.2.3
+ */
+ public PictureType getPictureTypeEnum() {
+ return PictureType.findById(getPictureType());
+ }
+
public Long getChecksum() {
if (this.checksum == null) {
try (InputStream is = getPackagePart().getInputStream()) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]