Browse Source

REPORT-138249 cpt支持数据集替换 调整抽象层级

release/11.0
Destiny.Lin 2 weeks ago
parent
commit
518f5a78b1
  1. 3
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java
  2. 39
      designer-realize/src/main/java/com/fr/design/actions/replace/utils/ReplaceUtils.java

3
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java

@ -130,8 +130,7 @@ public class ITReplaceMainDialog extends UIDialog {
northPane.fitScreen(0, 0, width);
//ReplaceUtils.replaceCpt(jTemplate, new TableReplacementEntity().setOldName("test-测试").setNewName("test-测试的副本").setFields(new HashMap<>()));
}
}
/**

39
designer-realize/src/main/java/com/fr/design/actions/replace/utils/ReplaceUtils.java

@ -1,7 +1,11 @@
package com.fr.design.actions.replace.utils;
import com.fr.base.Formula;
import com.fr.base.chart.chartdata.TopDefinitionProvider;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartdata.TableDataDefinition;
import com.fr.chartx.attr.ChartProvider;
import com.fr.data.TableReplacementEntity;
import com.fr.design.actions.replace.action.content.cell.SearchCellAction;
import com.fr.design.actions.replace.action.content.formula.SearchFormulaManager;
@ -16,11 +20,15 @@ import com.fr.design.actions.replace.info.FormulaInfo;
import com.fr.design.actions.replace.info.WidgetInfo;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.mainframe.JTemplate;
import com.fr.extended.chart.ChartTableDataDefinitionReplacer;
import com.fr.form.FormElementCaseProvider;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.main.impl.WorkBook;
import com.fr.report.elementcase.ElementCase;
import com.fr.report.report.Report;
import com.fr.report.utils.ElementCaseHelper;
import com.fr.stable.StringUtils;
import java.util.ArrayList;
import java.util.HashSet;
@ -206,7 +214,7 @@ public class ReplaceUtils {
WorkBook workBook = (WorkBook) template.getTarget();
// 非公式部分替换
workBook.replaceTableData(entity);
replaceWorkBook(workBook, entity);
// 公式部分
SearchFormulaManager.getInstance().search4Infos(template);
List<FormulaInfo> formulaInfos = SearchFormulaManager.getInstance().getFormulaInfos();
@ -214,6 +222,35 @@ public class ReplaceUtils {
}
}
private static void replaceWorkBook(WorkBook workBook, List<TableReplacementEntity> entity) {
if (acceptTableReplacement(entity)) {
for (int i = 0; i < workBook.getReportCount(); i++) {
Report report = workBook.getReport(i);
if (report != null) {
Iterator it = report.iteratorOfElementCase();
while (it.hasNext()) {
ElementCase elementCase = (ElementCase) it.next();
ElementCaseHelper.replaceTableDataWithOutFormula(elementCase, entity);
}
}
}
}
}
private static boolean acceptTableReplacement(List<TableReplacementEntity> entities) {
for (TableReplacementEntity entity : entities) {
if (entity == null) {
return false;
}
String newName = entity.getNewName();
String oldName = entity.getOldName();
if (StringUtils.isEmpty(newName) || StringUtils.isEmpty(oldName)) {
return false;
}
}
return true;
}
private static void replaceFormulaInfos(List<FormulaInfo> formulaInfos, List<TableReplacementEntity> entity) {
for (FormulaInfo formulaInfo : formulaInfos) {
if (TableDataFormulaType.needReplace(formulaInfo.getPureValue())) {

Loading…
Cancel
Save