diff --git a/org.adempiere.base/src/org/compiere/print/IHTMLExtension.java b/org.adempiere.base/src/org/compiere/print/IHTMLExtension.java index bb244f783d..c83f12b892 100644 --- a/org.adempiere.base/src/org/compiere/print/IHTMLExtension.java +++ b/org.adempiere.base/src/org/compiere/print/IHTMLExtension.java @@ -35,4 +35,6 @@ public interface IHTMLExtension { public void extendIDColumn(int row, ConcreteElement columnElement, a href, PrintDataElement dataElement); public void setWebAttribute (body reportBody); + + public String getFullPathStyle (); } diff --git a/org.adempiere.base/src/org/compiere/print/ReportEngine.java b/org.adempiere.base/src/org/compiere/print/ReportEngine.java index fd50a313cf..53104d2fc7 100644 --- a/org.adempiere.base/src/org/compiere/print/ReportEngine.java +++ b/org.adempiere.base/src/org/compiere/print/ReportEngine.java @@ -23,12 +23,16 @@ import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.io.FileReader; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -764,8 +768,16 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) doc.appendBody(table); if (extension != null && extension.getStyleURL() != null) { - link l = new link(extension.getStyleURL(), "stylesheet", "text/css"); - doc.appendHead(l); + // maybe cache style content with key is path + String pathStyleFile = extension.getFullPathStyle(); + Path path = Paths.get(pathStyleFile); + List styleLines = Files.readAllLines(path, Ini.getCharset()); + StringBuilder styleBuild = new StringBuilder(); + for (String styleLine : styleLines){ + styleBuild.append(styleLine); + } + + appendInlineCss (doc, styleBuild); } if (extension != null && extension.getScriptURL() != null) { @@ -1816,6 +1828,10 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) buildCssInline.append("\n"); } + appendInlineCss (doc, buildCssInline); + } + + public void appendInlineCss (XhtmlDocument doc, StringBuilder buildCssInline){ if (buildCssInline.length() > 0){ buildCssInline.insert(0, ""); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DashboardController.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DashboardController.java index 37175c593c..832e6b3941 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DashboardController.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DashboardController.java @@ -798,7 +798,8 @@ public class DashboardController implements EventListener { Iframe iframe = new Iframe(); iframe.setSclass("dashboard-report-iframe"); File file = File.createTempFile(re.getName(), ".html"); - re.createHTML(file, false, AEnv.getLanguage(Env.getCtx()), new HTMLExtension(Executions.getCurrent().getContextPath(), "rp", + re.createHTML(file, false, AEnv.getLanguage(Env.getCtx()), new HTMLExtension(Executions.getCurrent().getDesktop().getWebApp().getRealPath("/"), + Executions.getCurrent().getContextPath(), "rp", SessionManager.getAppDesktop().getComponent().getUuid())); AMedia media = new AMedia(re.getName(), "html", "text/html", file, false); iframe.setContent(media); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/report/HTMLExtension.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/report/HTMLExtension.java index 3353403225..52b16af718 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/report/HTMLExtension.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/report/HTMLExtension.java @@ -36,8 +36,9 @@ public class HTMLExtension implements IHTMLExtension { private String componentId; private String scriptURL; private String styleURL; + private String contextFullPath; - public HTMLExtension(String contextPath, String classPrefix, String componentId) { + public HTMLExtension(String contextFullPath, String contextPath, String classPrefix, String componentId) { String theme = MSysConfig.getValue(MSysConfig.HTML_REPORT_THEME, "/", Env.getAD_Client_ID(Env.getCtx())); @@ -50,6 +51,7 @@ public class HTMLExtension implements IHTMLExtension { this.componentId = componentId; this.scriptURL = contextPath + theme + "js/report.js"; this.styleURL = contextPath + theme + "css/report.css"; + this.contextFullPath = contextFullPath; } public void extendIDColumn(int row, ConcreteElement columnElement, a href, @@ -91,4 +93,16 @@ public class HTMLExtension implements IHTMLExtension { reportBody.addAttribute ("windowLabel", Msg.getMsg(AEnv.getLanguage(Env.getCtx()), "Window")); } + + public String getFullPathStyle (){ + String theme = MSysConfig.getValue(MSysConfig.HTML_REPORT_THEME, "/", Env.getAD_Client_ID(Env.getCtx())); + + if (! theme.startsWith("/")) + theme = "/" + theme; + if (! theme.endsWith("/")) + theme = theme + "/"; + + return contextFullPath + theme + "css/report.css"; + + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java index fdb896c6b8..37ceaba843 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java @@ -1422,11 +1422,13 @@ public class ZkReportViewer extends Window implements EventListener, ITab private ZkReportViewer viewer; private String contextPath; + private String contextFullPath; public HTMLRendererRunnable(ZkReportViewer viewer) { super(); this.viewer = viewer; contextPath = Executions.getCurrent().getContextPath(); + contextFullPath = Executions.getCurrent().getDesktop().getWebApp().getRealPath("/"); } @Override @@ -1441,7 +1443,7 @@ public class ZkReportViewer extends Window implements EventListener, ITab log.log(Level.FINE, "Path="+path + " Prefix="+prefix); } File file = File.createTempFile(prefix, ".html", new File(path)); - viewer.m_reportEngine.createHTML(file, false, viewer.m_reportEngine.getPrintFormat().getLanguage(), new HTMLExtension(contextPath, "rp", viewer.getUuid())); + viewer.m_reportEngine.createHTML(file, false, viewer.m_reportEngine.getPrintFormat().getLanguage(), new HTMLExtension(contextFullPath, contextPath, "rp", viewer.getUuid())); viewer.media = new AMedia(file.getName(), "html", "text/html", file, false); } catch (Exception e) { if (e instanceof RuntimeException)