From b9bb9c71c535398f2feff3367e85b53f8cbb46fe Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Tue, 12 Dec 2017 17:53:04 +0100 Subject: [PATCH] Fix "map" issue that was broken --- .../plantuml/servlet/DiagramResponse.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java b/src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java index 8cf05ad..e9337b7 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java @@ -35,11 +35,12 @@ import javax.servlet.http.HttpServletRequest; import net.sourceforge.plantuml.BlockUml; import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormatOption; +import net.sourceforge.plantuml.NullOutputStream; import net.sourceforge.plantuml.SourceStringReader; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.Diagram; -import net.sourceforge.plantuml.servlet.utility.NullOutputStream; +import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.version.Version; import net.sourceforge.plantuml.PSystemError; import net.sourceforge.plantuml.ErrorUml; @@ -108,12 +109,13 @@ class DiagramResponse { if (StringUtils.isDiagramCacheable(uml)) { addHeaderForCache(blockUml); } - String map = reader.outputImage(new NullOutputStream(), - new FileFormatOption(FileFormat.PNG, false)).getDescription(); - String[] mapLines = map.split("[\\r\\n]"); - PrintWriter httpOut = response.getWriter(); - for (int i = 2; (i + 1) < mapLines.length; i++) { - httpOut.print(mapLines[i]); + final Diagram diagram = blockUml.getDiagram(); + ImageData map = diagram.exportDiagram(new NullOutputStream(), 0, + new FileFormatOption(FileFormat.PNG, false)); + if (map.containsCMapData()) { + PrintWriter httpOut = response.getWriter(); + final String cmap = map.getCMapData("plantuml"); + httpOut.print(cmap); } }