BF 2941565 - Multilingual document support for Jasper Reports.
https://sourceforge.net/tracker/?func=detail&aid=2941565&group_id=176962&atid=879332 Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2941565
This commit is contained in:
parent
092e89d664
commit
47022f6791
|
@ -37,6 +37,7 @@ import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.PropertyResourceBundle;
|
import java.util.PropertyResourceBundle;
|
||||||
|
@ -60,6 +61,7 @@ import org.compiere.db.CConnection;
|
||||||
import org.compiere.interfaces.MD5;
|
import org.compiere.interfaces.MD5;
|
||||||
import org.compiere.model.MAttachment;
|
import org.compiere.model.MAttachment;
|
||||||
import org.compiere.model.MAttachmentEntry;
|
import org.compiere.model.MAttachmentEntry;
|
||||||
|
import org.compiere.model.MBPartner;
|
||||||
import org.compiere.model.MProcess;
|
import org.compiere.model.MProcess;
|
||||||
import org.compiere.model.X_AD_PInstance_Para;
|
import org.compiere.model.X_AD_PInstance_Para;
|
||||||
import org.compiere.process.ClientProcess;
|
import org.compiere.process.ClientProcess;
|
||||||
|
@ -368,6 +370,7 @@ public class ReportStarter implements ProcessCall, ClientProcess
|
||||||
String Name=pi.getTitle();
|
String Name=pi.getTitle();
|
||||||
int AD_PInstance_ID=pi.getAD_PInstance_ID();
|
int AD_PInstance_ID=pi.getAD_PInstance_ID();
|
||||||
int Record_ID=pi.getRecord_ID();
|
int Record_ID=pi.getRecord_ID();
|
||||||
|
|
||||||
log.info( "Name="+Name+" AD_PInstance_ID="+AD_PInstance_ID+" Record_ID="+Record_ID);
|
log.info( "Name="+Name+" AD_PInstance_ID="+AD_PInstance_ID+" Record_ID="+Record_ID);
|
||||||
String trxName = null;
|
String trxName = null;
|
||||||
if (trx != null) {
|
if (trx != null) {
|
||||||
|
@ -424,6 +427,15 @@ public class ReportStarter implements ProcessCall, ClientProcess
|
||||||
String name = jasperReport.getName();
|
String name = jasperReport.getName();
|
||||||
File reportDir = data.getReportDir();
|
File reportDir = data.getReportDir();
|
||||||
|
|
||||||
|
// Add reportDir to class path
|
||||||
|
ClassLoader scl = ClassLoader.getSystemClassLoader();
|
||||||
|
try {
|
||||||
|
java.net.URLClassLoader ucl = new java.net.URLClassLoader(new java.net.URL[]{reportDir.toURI().toURL()}, scl);
|
||||||
|
net.sf.jasperreports.engine.util.JRResourcesUtil.setThreadClassLoader(ucl);
|
||||||
|
} catch (MalformedURLException me) {
|
||||||
|
log.warning("Could not add report directory to classpath: "+ me.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
if (jasperReport != null) {
|
if (jasperReport != null) {
|
||||||
File[] subreports;
|
File[] subreports;
|
||||||
|
|
||||||
|
@ -463,8 +475,19 @@ public class ReportStarter implements ProcessCall, ClientProcess
|
||||||
params.put("AD_PINSTANCE_ID", new Integer( AD_PInstance_ID));
|
params.put("AD_PINSTANCE_ID", new Integer( AD_PInstance_ID));
|
||||||
|
|
||||||
Language currLang = Env.getLanguage(Env.getCtx());
|
Language currLang = Env.getLanguage(Env.getCtx());
|
||||||
|
ProcessInfoParameter[] pip = pi.getParameter();
|
||||||
|
// Check for language parameter
|
||||||
|
if (pip!=null) {
|
||||||
|
for (int i=0; i<pip.length; i++) {
|
||||||
|
if ("CURRENT_LANG".equalsIgnoreCase(pip[i].getParameterName())) {
|
||||||
|
currLang = (Language)pip[i].getParameter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
params.put("CURRENT_LANG", currLang.getAD_Language());
|
params.put("CURRENT_LANG", currLang.getAD_Language());
|
||||||
params.put(JRParameter.REPORT_LOCALE, currLang.getLocale());
|
params.put(JRParameter.REPORT_LOCALE, currLang.getLocale());
|
||||||
|
|
||||||
// Resources
|
// Resources
|
||||||
File resFile = null;
|
File resFile = null;
|
||||||
if (reportPath.startsWith("attachment:") && attachment != null) {
|
if (reportPath.startsWith("attachment:") && attachment != null) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.compiere.model.MQuery;
|
||||||
import org.compiere.model.MTable;
|
import org.compiere.model.MTable;
|
||||||
import org.compiere.model.PrintInfo;
|
import org.compiere.model.PrintInfo;
|
||||||
import org.compiere.process.ProcessInfo;
|
import org.compiere.process.ProcessInfo;
|
||||||
|
import org.compiere.process.ProcessInfoParameter;
|
||||||
import org.compiere.util.ASyncProcess;
|
import org.compiere.util.ASyncProcess;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
|
@ -280,11 +281,18 @@ public class ReportCtl
|
||||||
|
|
||||||
if(re.getPrintFormat() != null)
|
if(re.getPrintFormat() != null)
|
||||||
{
|
{
|
||||||
if(re.getPrintFormat().getJasperProcess_ID() > 0)
|
MPrintFormat format = re.getPrintFormat();
|
||||||
|
if(format.getJasperProcess_ID() > 0)
|
||||||
{
|
{
|
||||||
ProcessInfo pi = new ProcessInfo ("", re.getPrintFormat().getJasperProcess_ID());
|
PrintInfo info = re.getPrintInfo();
|
||||||
|
ProcessInfo pi = new ProcessInfo ("", format.getJasperProcess_ID());
|
||||||
pi.setPrintPreview( !IsDirectPrint );
|
pi.setPrintPreview( !IsDirectPrint );
|
||||||
pi.setRecord_ID ( Record_ID );
|
pi.setRecord_ID ( Record_ID );
|
||||||
|
if (info.isDocument()) {
|
||||||
|
ProcessInfoParameter pip = new ProcessInfoParameter("CURRENT_LANG", format.getLanguage(), null, null, null);
|
||||||
|
pi.setParameter(new ProcessInfoParameter[]{pip});
|
||||||
|
}
|
||||||
|
|
||||||
// Execute Process
|
// Execute Process
|
||||||
if (Ini.isClient())
|
if (Ini.isClient())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue