diff --git a/src/main/java/org/olat/core/util/openxml/OpenXMLDocument.java b/src/main/java/org/olat/core/util/openxml/OpenXMLDocument.java index 319c22c0c9738a2acad5d300e25ee367ede5c40c..d4cf066313d15c238ad557e2475dd3ec2527dc8d 100644 --- a/src/main/java/org/olat/core/util/openxml/OpenXMLDocument.java +++ b/src/main/java/org/olat/core/util/openxml/OpenXMLDocument.java @@ -1368,7 +1368,7 @@ public class OpenXMLDocument { appendPicture(grpSpEl, backgroundImageRef); for(OpenXMLGraphic element:elements) { - appendGraphicElementEl(grpSpEl, backgroundImageRef.getEmuSize(), element); + appendGraphicElementEl(grpSpEl, emuSize, element); } return drawingEl; @@ -1417,7 +1417,7 @@ public class OpenXMLDocument { <wps:bodyPr /> </wps:wsp> */ - private void appendGraphicElementEl(Element parentEl, OpenXMLSize size, OpenXMLGraphic element) { + private void appendGraphicElementEl(Element parentEl, OpenXMLSize backgroundSize, OpenXMLGraphic element) { Element wspEl = (Element)parentEl.appendChild(document.createElement("wps:wsp")); String formId = generateSimpleId(); @@ -1430,9 +1430,9 @@ public class OpenXMLDocument { Element spPrEl = (Element)wspEl.appendChild(document.createElement("wps:spPr")); if(element.type() == OpenXMLGraphic.Type.rectangle) { - appendGraphicRectangle(spPrEl, size, element); + appendGraphicRectangle(spPrEl, backgroundSize, element); } else if(element.type() == OpenXMLGraphic.Type.circle) { - appendGraphicEllipse(spPrEl, size, element); + appendGraphicEllipse(spPrEl, backgroundSize, element); } appendGraphicSolidFill_transparent(spPrEl, element.getStyle()); @@ -1468,7 +1468,7 @@ public class OpenXMLDocument { alphaEl.setAttribute("val", "50000"); } - private void appendGraphicRectangle(Element spPrEl, OpenXMLSize size, OpenXMLGraphic element) { + private void appendGraphicRectangle(Element spPrEl, OpenXMLSize backgroundSize, OpenXMLGraphic element) { /* <a:xfrm> <a:off x="2028190" y="581660" /> @@ -1480,8 +1480,8 @@ public class OpenXMLDocument { List<Integer> coords = element.getCoords(); int leftx = coords.get(0); int topy = coords.get(1); - int leftxEmu = OpenXMLUtils.convertPixelToEMUs(leftx, DPI, size.getResizeRatio()); - int topyEmu = OpenXMLUtils.convertPixelToEMUs(topy, DPI, size.getResizeRatio()); + int leftxEmu = OpenXMLUtils.convertPixelToEMUs(leftx, DPI, backgroundSize.getResizeRatio()); + int topyEmu = OpenXMLUtils.convertPixelToEMUs(topy, DPI, backgroundSize.getResizeRatio()); aOffEl.setAttribute("x", Integer.toString(leftxEmu)); aOffEl.setAttribute("y", Integer.toString(topyEmu)); @@ -1489,9 +1489,9 @@ public class OpenXMLDocument { int rightx = coords.get(2); int bottomy = coords.get(3); int width = rightx -leftx; - int cx = OpenXMLUtils.convertPixelToEMUs(width, DPI, size.getResizeRatio()); + int cx = OpenXMLUtils.convertPixelToEMUs(width, DPI, backgroundSize.getResizeRatio()); int height = bottomy - topy; - int cy = OpenXMLUtils.convertPixelToEMUs(height, DPI, size.getResizeRatio()); + int cy = OpenXMLUtils.convertPixelToEMUs(height, DPI, backgroundSize.getResizeRatio()); aExtEl.setAttribute("cx", Integer.toString(cx)); aExtEl.setAttribute("cy", Integer.toString(cy)); /* @@ -1504,7 +1504,7 @@ public class OpenXMLDocument { prstGeomEl.appendChild(document.createElement("a:avLst")); } - private void appendGraphicEllipse(Element spPrEl, OpenXMLSize size, OpenXMLGraphic element) { + private void appendGraphicEllipse(Element spPrEl, OpenXMLSize backgroundSize, OpenXMLGraphic element) { /* <a:xfrm> <a:off x="2028190" y="581660" /> @@ -1520,8 +1520,8 @@ public class OpenXMLDocument { int topx = centerx - radius; int lefty = centery - radius; - int topxEmu = OpenXMLUtils.convertPixelToEMUs(topx, DPI, size.getResizeRatio()); - int leftyEmu = OpenXMLUtils.convertPixelToEMUs(lefty, DPI, size.getResizeRatio()); + int topxEmu = OpenXMLUtils.convertPixelToEMUs(topx, DPI, backgroundSize.getResizeRatio()); + int leftyEmu = OpenXMLUtils.convertPixelToEMUs(lefty, DPI, backgroundSize.getResizeRatio()); aOffEl.setAttribute("x", Integer.toString(topxEmu)); aOffEl.setAttribute("y", Integer.toString(leftyEmu)); @@ -1529,7 +1529,7 @@ public class OpenXMLDocument { Element aExtEl = (Element)aXfrmEl.appendChild(document.createElement("a:ext")); int width = (radius * 2); - int widthEmu = OpenXMLUtils.convertPixelToEMUs(width, DPI, size.getResizeRatio()); + int widthEmu = OpenXMLUtils.convertPixelToEMUs(width, DPI, backgroundSize.getResizeRatio()); aExtEl.setAttribute("cx", Integer.toString(widthEmu)); aExtEl.setAttribute("cy", Integer.toString(widthEmu)); /* diff --git a/src/main/java/org/olat/core/util/openxml/OpenXMLUtils.java b/src/main/java/org/olat/core/util/openxml/OpenXMLUtils.java index 307ece7f899431913d18b8d9e5599057db2d7404..915200463c974699f7d7e66d5bc34977cdf2ae3d 100644 --- a/src/main/java/org/olat/core/util/openxml/OpenXMLUtils.java +++ b/src/main/java/org/olat/core/util/openxml/OpenXMLUtils.java @@ -69,7 +69,7 @@ public class OpenXMLUtils { public static final int convertPixelToEMUs(int pixel, int dpi, double resizeRatio) { double rezDpi = dpi * 1.0d; - return (int)(((pixel / rezDpi) * emusPerInch) / resizeRatio); + return (int)(((pixel / rezDpi) * emusPerInch) * resizeRatio); } public static final OpenXMLSize convertPixelToEMUs2(Size img, int dpi) {