|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.fr.nx.app.designer.utils; |
|
|
|
package com.fr.nx.app.designer.utils; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.extension.FileExtension; |
|
|
|
import com.fr.design.mainframe.JTemplate; |
|
|
|
import com.fr.design.mainframe.JTemplate; |
|
|
|
import com.fr.file.FILE; |
|
|
|
import com.fr.file.FILE; |
|
|
|
import com.fr.file.FileNodeFILE; |
|
|
|
import com.fr.file.FileNodeFILE; |
|
|
@ -39,8 +40,12 @@ public class CptCompileUtil { |
|
|
|
FILE file = jtemplate.getEditingFILE(); |
|
|
|
FILE file = jtemplate.getEditingFILE(); |
|
|
|
String path = file.getPath(); |
|
|
|
String path = file.getPath(); |
|
|
|
WorkBook workbook = (WorkBook) jtemplate.getTarget(); |
|
|
|
WorkBook workbook = (WorkBook) jtemplate.getTarget(); |
|
|
|
//如果是cpt并且引擎设置正确,执行预编译。cptx文件不执行预编译
|
|
|
|
/* |
|
|
|
if (!(path.endsWith(".cpt") && isNewEngine(workbook))){ |
|
|
|
* 如果是cpt并且引擎设置正确,执行预编译,如果是cptx文件也执行预编译。在JStreamWork中,保存和另存为流程都进行了重新编译。 |
|
|
|
|
|
|
|
* 但是由于之前的DefaultTemplateResource.saveTemplate的原因导致JStreamWork::saveFile()不能执行--cptx的保存不能进行预编译, |
|
|
|
|
|
|
|
* 应该是流程的误改动,这里改回来,保存时仍然执行预编译。 |
|
|
|
|
|
|
|
* */ |
|
|
|
|
|
|
|
if (!isNewEngine(workbook, path)){ |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
TransformResultInfo resultInfo = compile0(workbook, file); |
|
|
|
TransformResultInfo resultInfo = compile0(workbook, file); |
|
|
@ -48,7 +53,7 @@ public class CptCompileUtil { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static TransformResultInfo compile0(WorkBook workbook, FILE file) { |
|
|
|
private static TransformResultInfo compile0(WorkBook workbook, FILE file) { |
|
|
|
if (!(file instanceof FileNodeFILE)) { |
|
|
|
if (!(file instanceof FileNodeFILE)) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
OutputStream outputStream = file.asOutputStream(); |
|
|
|
OutputStream outputStream = file.asOutputStream(); |
|
|
@ -138,14 +143,28 @@ public class CptCompileUtil { |
|
|
|
/* |
|
|
|
/* |
|
|
|
* 该另存为流程会改变文件内容,现在作为兼容的流程,以后可以随时删除该流程 |
|
|
|
* 该另存为流程会改变文件内容,现在作为兼容的流程,以后可以随时删除该流程 |
|
|
|
* */ |
|
|
|
* */ |
|
|
|
public static boolean changeFrEngineAttr(String oldName, JTemplate jTemplate){ |
|
|
|
public static boolean haveChanged(String oldName, JTemplate jTemplate){ |
|
|
|
FILE editingFILE = jTemplate.getEditingFILE(); |
|
|
|
FILE editingFILE = jTemplate.getEditingFILE(); |
|
|
|
String path = editingFILE.getPath(); |
|
|
|
String path = editingFILE.getPath(); |
|
|
|
//只有在旧文件是cptx文件并且新文件是cpt文件时才会改变报表引擎属性
|
|
|
|
//只有在旧文件是cptx文件并且新文件是cpt文件时才会改变报表引擎属性
|
|
|
|
boolean isChange = oldName.endsWith(".cptx") && path.endsWith(".cpt"); |
|
|
|
boolean isChange = oldName.endsWith(".cptx") && path.endsWith(".cpt"); |
|
|
|
if (isChange){ |
|
|
|
if (isChange && !changeFrEngineAttr(jTemplate)){ |
|
|
|
WorkBook target = (WorkBook)jTemplate.getTarget(); |
|
|
|
isChange = false; |
|
|
|
WorkSheet workSheet = (WorkSheet)target.getReport(0); |
|
|
|
} |
|
|
|
|
|
|
|
//合并JStreamWork中另存为流程,cptx的另存为也需要重新预编译
|
|
|
|
|
|
|
|
return (isChange || isSaveAs(jTemplate, oldName, path)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//cptx和设置了新引擎的cpt的另存也需要进行预编译
|
|
|
|
|
|
|
|
private static boolean isSaveAs(JTemplate jTemplate, String oldName, String newName){ |
|
|
|
|
|
|
|
return isNewEngine(jTemplate.getTarget(), newName) && ((FileExtension.CPTX.matchExtension(oldName) && FileExtension.CPTX.matchExtension(newName)) || (FileExtension.CPT.matchExtension(oldName) && FileExtension.CPT.matchExtension(newName))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static boolean changeFrEngineAttr(JTemplate jTemplate){ |
|
|
|
|
|
|
|
WorkSheet workSheet = gainWorkSheet(jTemplate); |
|
|
|
|
|
|
|
if (workSheet == null){ |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
}else { |
|
|
|
LayerReportAttr layerReportAttr = workSheet.getLayerReportAttr(); |
|
|
|
LayerReportAttr layerReportAttr = workSheet.getLayerReportAttr(); |
|
|
|
if (layerReportAttr == null){ |
|
|
|
if (layerReportAttr == null){ |
|
|
|
layerReportAttr = new LayerReportAttr(); |
|
|
|
layerReportAttr = new LayerReportAttr(); |
|
|
@ -153,26 +172,36 @@ public class CptCompileUtil { |
|
|
|
} |
|
|
|
} |
|
|
|
layerReportAttr.setClientPaging(true); |
|
|
|
layerReportAttr.setClientPaging(true); |
|
|
|
layerReportAttr.setNewEngine(true); |
|
|
|
layerReportAttr.setNewEngine(true); |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
return isChange; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static boolean isNewEngine(Object workBook){ |
|
|
|
|
|
|
|
if (workBook == null || !(workBook instanceof TemplateWorkBook)){ |
|
|
|
public static boolean isNewEngine(Object workBook, String fileName){ |
|
|
|
return false; |
|
|
|
WorkSheet workSheet = gainWorkSheet(workBook); |
|
|
|
|
|
|
|
LayerReportAttr layerReportAttr = gainLayerReportAttr(workSheet); |
|
|
|
|
|
|
|
return isNewEngine(layerReportAttr, fileName); |
|
|
|
} |
|
|
|
} |
|
|
|
Report report = ((TemplateWorkBook) workBook).getReport(0); |
|
|
|
|
|
|
|
if (report instanceof WorkSheet){ |
|
|
|
private static LayerReportAttr gainLayerReportAttr(WorkSheet workSheet){ |
|
|
|
WorkSheet workSheet = (WorkSheet) report; |
|
|
|
if (workSheet != null){ |
|
|
|
LayerReportAttr layerReportAttr = workSheet.getLayerReportAttr(); |
|
|
|
LayerReportAttr layerReportAttr = workSheet.getLayerReportAttr(); |
|
|
|
if (layerReportAttr!= null && layerReportAttr.isClientPaging() && layerReportAttr.isNewEngine()){ |
|
|
|
return layerReportAttr; |
|
|
|
return true; |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return false; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static WorkSheet gainWorkSheet(Object workBook){ |
|
|
|
|
|
|
|
if (workBook == null || !(workBook instanceof TemplateWorkBook)){ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Report report = ((TemplateWorkBook) workBook).getReport(0); |
|
|
|
|
|
|
|
return report instanceof WorkSheet ? (WorkSheet)report : null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static boolean isNewEngine(LayerReportAttr layerReportAttr, String fileName){ |
|
|
|
|
|
|
|
return (layerReportAttr!= null && layerReportAttr.isClientPaging() && layerReportAttr.isNewEngine()) || FileExtension.CPTX.matchExtension(fileName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void unSupportLog(TransformResultInfo transformResultInfo){ |
|
|
|
private static void unSupportLog(TransformResultInfo transformResultInfo){ |
|
|
|