aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2020-12-12 23:15:20 +0000
committerAndreas Beeker <kiwiwings@apache.org>2020-12-12 23:15:20 +0000
commitc5f6dfa68e04c5a42b64b3f862756b9c990665dc (patch)
treeabeaa3d26edfb046c64ef744451648999b0d3a53 /src/java
parent1f072afe18b3022f90a7f2dae52b9606b459e045 (diff)
downloadpoi-c5f6dfa68e04c5a42b64b3f862756b9c990665dc.tar.gz
poi-c5f6dfa68e04c5a42b64b3f862756b9c990665dc.zip
Bug 56205 - Upgrade OOXML schema to 3rd edition (transitional)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1884368 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/poi/util/Units.java38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/java/org/apache/poi/util/Units.java b/src/java/org/apache/poi/util/Units.java
index 599e443f63..1aad77db8b 100644
--- a/src/java/org/apache/poi/util/Units.java
+++ b/src/java/org/apache/poi/util/Units.java
@@ -29,11 +29,17 @@ public class Units {
public static final int EMU_PER_POINT = 12700;
public static final int EMU_PER_CENTIMETER = 360000;
+ /** 72 points per inch (dpi) */
+ public static final int EMU_PER_INCH = 12700*72;
+
+ /** EMU_PER_POINT/20 */
+ public static final int EMU_PER_DXA = 635;
+
/**
* Master DPI (576 pixels per inch).
* Used by the reference coordinate system in PowerPoint (HSLF)
*/
- public static final int MASTER_DPI = 576;
+ public static final int MASTER_DPI = 576;
/**
* Pixels DPI (96 pixels per inch)
@@ -43,7 +49,7 @@ public class Units {
/**
* Points DPI (72 pixels per inch)
*/
- public static final int POINT_DPI = 72;
+ public static final int POINT_DPI = 72;
/**
@@ -59,7 +65,7 @@ public class Units {
/**
* Column widths are in fractional characters, this is the EMU equivalent.
- * One character is defined as the widest value for the integers 0-9 in the
+ * One character is defined as the widest value for the integers 0-9 in the
* default font.
*/
public static final int EMU_PER_CHARACTER = (int) (EMU_PER_PIXEL * DEFAULT_CHARACTER_WIDTH);
@@ -72,7 +78,7 @@ public class Units {
public static int toEMU(double points){
return (int)Math.rint(EMU_PER_POINT*points);
}
-
+
/**
* Converts pixels to EMUs
* @param pixels pixels
@@ -88,15 +94,15 @@ public class Units {
* @return points
*/
public static double toPoints(long emu){
- return (double)emu/EMU_PER_POINT;
+ return (emu == -1) ? -1.d : (double)emu/EMU_PER_POINT;
}
-
+
/**
* Converts a value of type FixedPoint to a floating point
*
* @param fixedPoint value in fixed point notation
* @return floating point (double)
- *
+ *
* @see <a href="http://msdn.microsoft.com/en-us/library/dd910765(v=office.12).aspx">[MS-OSHARED] - 2.2.1.6 FixedPoint</a>
*/
public static double fixedPointToDouble(int fixedPoint) {
@@ -104,13 +110,13 @@ public class Units {
int f = fixedPoint & 0xFFFF;
return (i + f/65536d);
}
-
+
/**
* Converts a value of type floating point to a FixedPoint
*
* @param floatPoint value in floating point notation
* @return fixedPoint value in fixed points notation
- *
+ *
* @see <a href="http://msdn.microsoft.com/en-us/library/dd910765(v=office.12).aspx">[MS-OSHARED] - 2.2.1.6 FixedPoint</a>
*/
public static int doubleToFixedPoint(double floatPoint) {
@@ -133,7 +139,7 @@ public class Units {
points /= POINT_DPI;
return (int)Math.rint(points);
}
-
+
public static int pointsToPixel(double points) {
points *= PIXEL_DPI;
points /= POINT_DPI;
@@ -178,7 +184,7 @@ public class Units {
public static int charactersToEMU(double characters) {
return (int) characters * EMU_PER_CHARACTER;
}
-
+
/**
* @param columnWidth specified in 256ths of a standard character
* @return equivalent EMUs
@@ -186,12 +192,8 @@ public class Units {
public static int columnWidthToEMU(int columnWidth) {
return charactersToEMU(columnWidth / 256d);
}
-
- /**
- * @param twips (1/20th of a point) typically used for row heights
- * @return equivalent EMUs
- */
- public static int TwipsToEMU(short twips) {
- return (int) (twips / 20d * EMU_PER_POINT);
+
+ public static double toDXA(long emu) {
+ return (emu == -1) ? -1.d : (double)emu/EMU_PER_DXA;
}
}