|
|
|
@ -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())) { |
|
|
|
|