From eeb25e7dfafa2cebd93397c63c0b732e074a5ee9 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 14 Sep 2022 14:59:21 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-75998=20=E6=90=9C=E7=B4=A2=E5=85=AC?= =?UTF-8?q?=E5=BC=8F=E2=80=94=E2=80=94=E5=8D=95=E5=85=83=E6=A0=BC=E3=80=81?= =?UTF-8?q?=E5=9B=BE=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../formula/AbstractSearchFormulaAction.java | 25 ++ .../content/formula/FormulaReplaceObject.java | 396 ++++++++++++++++++ .../content/formula/SearchFormulaAction.java | 46 ++ .../cell/AbstractSearchCellFormulaAction.java | 37 ++ .../formula/cell/SearchCellFormulaAction.java | 198 +++++++++ .../cell/SearchCellFormulaTypeAction.java | 27 ++ .../cell/SearchDSColumnFormulaAction.java | 117 ++++++ .../formula/cell/SearchRichFormulaAction.java | 34 ++ .../cell/SearchSubReportFormulaAction.java | 36 ++ .../SearchChartCollectionFormulaAction.java | 213 ++++++++++ 10 files changed, 1129 insertions(+) create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/AbstractSearchFormulaAction.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/SearchFormulaAction.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/AbstractSearchCellFormulaAction.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaAction.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaTypeAction.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchDSColumnFormulaAction.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchRichFormulaAction.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchSubReportFormulaAction.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/AbstractSearchFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/AbstractSearchFormulaAction.java new file mode 100644 index 0000000000..9746cc169a --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/AbstractSearchFormulaAction.java @@ -0,0 +1,25 @@ +package com.fr.design.actions.replace.action.content.formula; + +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.mainframe.JTemplate; + +import java.util.ArrayList; + +/** + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-19 + */ +public abstract class AbstractSearchFormulaAction implements SearchFormula{ + @Override + public void searchFormula(ArrayList formulaInfos, ITContent content) { + + } + + @Override + public ArrayList search4Infos(JTemplate jTemplate) { + return null; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java new file mode 100644 index 0000000000..2971945689 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java @@ -0,0 +1,396 @@ +package com.fr.design.actions.replace.action.content.formula; + +import com.fr.base.BaseFormula; +import com.fr.base.Formula; +import com.fr.base.Parameter; +import com.fr.base.StoreProcedureParameter; +import com.fr.base.iofile.attr.WatermarkAttr; +import com.fr.base.present.FormulaPresent; +import com.fr.data.condition.FormulaCondition; +import com.fr.data.core.Compare; +import com.fr.design.actions.replace.action.ShowValue; +import com.fr.design.actions.replace.info.DealWithInfoValue; +import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.utils.ShowValueUtils; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.js.SingleJavaScript; +import com.fr.main.impl.WorkBook; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.cellattr.CellInsertPolicyAttr; +import com.fr.report.cell.cellattr.core.RichText; +import com.fr.report.cell.cellattr.core.group.DSColumn; +import com.fr.stable.FormulaProvider; +import com.fr.stable.ParameterProvider; +import com.fr.stable.StringUtils; +import javafx.util.Pair; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.HashMap; + +/** + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-25 + */ +public enum FormulaReplaceObject implements DealWithInfoValue { + /** + * Formula类型(最基础也是最常见) + */ + FORMULA("Formula") { + @Override + public HashMap getValue(Object... o) { + HashMap map = new HashMap<>(); + if (!StringUtils.isEmpty(((Formula) o[0]).getContent())) { + map.put("content", ((Formula) o[0]).getContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, ArrayList> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((Formula) replaceObject).getContent(), findStr); + ((Formula) replaceObject).setContent(ShowValueUtils.replaceAll(((Formula) replaceObject).getContent(), findStr, replaceStr)); + } + }, + /** + * FormulaCondition + */ + FORMULA_CONDITION("FormulaCondition") { + @Override + public HashMap getValue(Object... o) { + HashMap map = new HashMap<>(); + if (!StringUtils.isEmpty(((FormulaCondition) o[0]).getFormula())) { + map.put("content", ((FormulaCondition) o[0]).getFormula()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, ArrayList> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + //更新上一次操作的信息 + info.updateOldStr(((FormulaCondition) replaceObject).getFormula(), findStr); + + ((FormulaCondition) replaceObject).setFormula(ShowValueUtils.replaceAll(((FormulaCondition) replaceObject).getFormula(), findStr, replaceStr)); + } + + }, + /** + * Compare + */ + COMPARE("Compare") { + @Override + public HashMap getValue(Object... o) { + HashMap map = new HashMap<>(); + if (!StringUtils.isEmpty(((Formula) ((Compare) o[0]).getValue()).getContent())) { + map.put("content", ((Formula) ((Compare) o[0]).getValue()).getContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, ArrayList> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + if (((Compare) replaceObject).getValue() instanceof Formula) { + Formula formula = (Formula) ((Compare) replaceObject).getValue(); + info.updateOldStr(formula.getContent(), findStr); + + formula.setContent(ShowValueUtils.replaceAll(formula.getContent(), findStr, replaceStr)); + } + } + + }, + /** + * 富文本 + */ + RICH_TEXT("RichText") { + @Override + public HashMap getValue(Object... o) { + HashMap map = new HashMap<>(); + if (!StringUtils.isEmpty(((RichText) ((CellElement) o[0]).getValue()).getContent())) { + map.put("content", ((RichText) ((CellElement) o[0]).getValue()).getContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, ArrayList> operatorArray) { + //todo 富文本公式处理 + } + + }, + /** + * KV + */ + KV("KV") { + @Override + public HashMap getValue(Object... o) { + HashMap map = new HashMap<>(); + if (!StringUtils.isEmpty(((Formula) ((com.fr.base.core.KV) o[0]).getValue()).getContent())) { + map.put("content", ((Formula) ((com.fr.base.core.KV) o[0]).getValue()).getContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, ArrayList> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((Formula) ((com.fr.base.core.KV) replaceObject).getValue()).getContent(), findStr); + + ((Formula) ((com.fr.base.core.KV) replaceObject).getValue()).setContent(ShowValueUtils.replaceAll(((Formula) ((com.fr.base.core.KV) replaceObject).getValue()).getContent(), findStr, replaceStr)); + } + + }, + /** + * 插入策略 + */ + CELL_INSERT_POLICY_ATTR("CellInsertPolicyAttr") { + @Override + public HashMap getValue(Object... o) { + HashMap map = new HashMap<>(); + if (!StringUtils.isEmpty(((Formula) (((CellInsertPolicyAttr) o[0]).getDefaultInsertValue())).getContent())) { + map.put("content", ((Formula) (((CellInsertPolicyAttr) o[0]).getDefaultInsertValue())).getContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, ArrayList> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((Formula) (((CellInsertPolicyAttr) replaceObject).getDefaultInsertValue())).getContent(), findStr); + ((Formula) (((CellInsertPolicyAttr) replaceObject).getDefaultInsertValue())).setContent(ShowValueUtils.replaceAll(((Formula) (((CellInsertPolicyAttr) replaceObject).getDefaultInsertValue())).getContent(), findStr, replaceStr)); + } + + }, + /** + * present + */ + PRESENT("Present") { + @Override + public HashMap getValue(Object... o) { + HashMap map = new HashMap<>(); + if (!StringUtils.isEmpty(((FormulaPresent) o[0]).getFormulaContent())) { + map.put("content", ((FormulaPresent) o[0]).getFormulaContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, ArrayList> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((FormulaPresent) replaceObject).getFormulaContent(), findStr); + + ((FormulaPresent) replaceObject).setFormulaContent(ShowValueUtils.replaceAll(((FormulaPresent) replaceObject).getFormulaContent(), findStr, replaceStr)); + } + + }, + /** + * SingleJavaScript + */ + SINGLE_JAVA_SCRIPT("SingleJavaScript") { + @Override + public HashMap getValue(Object... o) { + HashMap map = new HashMap<>(); + if (!StringUtils.isEmpty(((SingleJavaScript) o[0]).getFileName())) { + map.put("content", ((SingleJavaScript) o[0]).getFileName()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, ArrayList> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((SingleJavaScript) replaceObject).getFileName(), findStr); + + ((SingleJavaScript) replaceObject).setFileName(ShowValueUtils.replaceAll(((SingleJavaScript) replaceObject).getFileName(), findStr, replaceStr)); + } + + }, + /** + * 参数 + */ + PARAMETER_PROVIDER("ParameterProvider") { + @Override + public HashMap getValue(Object... o) { + HashMap map = new HashMap<>(); + if (!StringUtils.isEmpty(((Formula) (((ParameterProvider) o[0]).getValue())).getContent())) { + map.put("content", ((Formula) (((ParameterProvider) o[0]).getValue())).getContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, ArrayList> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((Formula) (((ParameterProvider) replaceObject).getValue())).getContent(), findStr); + + ((Formula) (((ParameterProvider) replaceObject).getValue())).setContent(ShowValueUtils.replaceAll(((Formula) (((ParameterProvider) replaceObject).getValue())).getContent(), findStr, replaceStr)); + } + + }, + /** + * FormulaProvider + */ + FORMULA_PROVIDER("FormulaProvider") { + @Override + public HashMap getValue(Object... o) { + HashMap map = new HashMap<>(); + if (!StringUtils.isEmpty(((FormulaProvider) o[0]).getContent())) { + map.put("content", ((FormulaProvider) o[0]).getContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, ArrayList> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((FormulaProvider) replaceObject).getContent(), findStr); + + ((FormulaProvider) replaceObject).setContent(ShowValueUtils.replaceAll(((FormulaProvider) replaceObject).getContent(), findStr, replaceStr)); + } + + }, + /** + * 参数 + */ + PARAMETER("Parameter") { + @Override + public HashMap getValue(Object... o) { + HashMap map = new HashMap<>(); + if (!StringUtils.isEmpty(((Formula) (((Parameter) o[0]).getValue())).getContent())) { + map.put("content", ((Formula) (((Parameter) o[0]).getValue())).getContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, ArrayList> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((Formula) (((Parameter) replaceObject).getValue())).getContent(), findStr); + + ((Formula) (((Parameter) replaceObject).getValue())).setContent(ShowValueUtils.replaceAll(((Formula) (((Parameter) replaceObject).getValue())).getContent(), findStr, replaceStr)); + } + + }, + /** + * 数据列 + */ + DS_COLUMN("DSColumn") { + @Override + public HashMap getValue(Object... o) { + HashMap map = new HashMap<>(); + if (!StringUtils.isEmpty(((DSColumn) o[0]).getResult())) { + map.put("content", ((DSColumn) o[0]).getResult()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, ArrayList> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((DSColumn) replaceObject).getResult(), findStr); + + ((DSColumn) replaceObject).setResult(ShowValueUtils.replaceAll(((DSColumn) replaceObject).getResult(), findStr, replaceStr)); + } + + }, + /** + * 公式类型 + */ + BASE_FORMULA("BaseFormula") { + @Override + public HashMap getValue(Object... o) { + HashMap map = new HashMap<>(); + if (!StringUtils.isEmpty(((BaseFormula) o[0]).getContent())) { + map.put("content", ((BaseFormula) o[0]).getContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, ArrayList> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((BaseFormula) replaceObject).getContent(), findStr); + + ((BaseFormula) replaceObject).setContent(ShowValueUtils.replaceAll(((BaseFormula) replaceObject).getContent(), findStr, replaceStr)); + } + + }, + /** + * 存储过程的参数 + */ + STORE_PROCEDURE_PARAMETER("StoreProcedureParameter") { + @Override + public HashMap getValue(Object... o) { + HashMap map = new HashMap<>(); + if (!StringUtils.isEmpty(((Formula) ((StoreProcedureParameter) o[0]).getValue()).getContent())) { + map.put("content", ((Formula) ((StoreProcedureParameter) o[0]).getValue()).getContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, ArrayList> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((Formula) ((StoreProcedureParameter) replaceObject).getValue()).getContent(), findStr); + + ((Formula) ((StoreProcedureParameter) replaceObject).getValue()).setContent(ShowValueUtils.replaceAll(((Formula) ((StoreProcedureParameter) replaceObject).getValue()).getContent(), findStr, replaceStr)); + } + + }, + /** + * WatermarkAttr水印 + */ + WATER_MARK_ATTR("WatermarkAttr") { + @Override + public HashMap getValue(Object... o) { + HashMap map = new HashMap<>(); + if (!StringUtils.isEmpty(((WatermarkAttr) o[0]).getText())) { + map.put("content", ((WatermarkAttr) o[0]).getText()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, ArrayList> operatorArray) { + WorkBook workBook = (WorkBook) HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget(); + WatermarkAttr watermarkAttr = (WatermarkAttr) info.getContent().getReplaceObject(); + info.updateOldStr(watermarkAttr.getText(), findStr); + watermarkAttr.setText(ShowValueUtils.replaceAll(watermarkAttr.getText(), findStr, replaceStr)); + workBook.addAttrMark(watermarkAttr); + } + }; + + + String name; + + FormulaReplaceObject(String name) { + this.name = name; + } + + /** + * 匹配 + * + * @param name + * @return + */ + @Nullable + public static FormulaReplaceObject match(String name) { + FormulaReplaceObject[] values = FormulaReplaceObject.values(); + for (FormulaReplaceObject value : values) { + if (value.name.equals(name)) { + return value; + } + } + return null; + } + + + @Override + public String getInfoShowStr(Info info) { + return info.getContent().getOldShowStr(); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/SearchFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/SearchFormulaAction.java new file mode 100644 index 0000000000..2f5e03137b --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/SearchFormulaAction.java @@ -0,0 +1,46 @@ +package com.fr.design.actions.replace.action.content.formula; + +import com.fr.design.actions.replace.action.SearchAction; +import com.fr.design.actions.replace.action.content.formula.cell.SearchCellFormulaAction; +import com.fr.design.actions.replace.action.content.formula.data.SearchDataFormulaAction; +import com.fr.design.actions.replace.action.content.formula.floatelement.SearchFloatFormulaAction; +import com.fr.design.actions.replace.action.content.formula.template.SearchTemplateFormulaAction; +import com.fr.design.actions.replace.action.content.formula.widget.SearchWidgetFormulaAction; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.mainframe.JTemplate; +import com.fr.form.main.Form; +import com.fr.main.impl.WorkBook; + +import java.util.ArrayList; + +/** + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-17 + */ +public class SearchFormulaAction implements SearchAction { + private ArrayList formulaInfos; + + public SearchFormulaAction(JTemplate jTemplate) { + setFormulaInfos(search4Infos(jTemplate)); + } + + @Override + public ArrayList search4Infos(JTemplate jTemplate) { + ArrayList formulaInfos = new ArrayList<>(); + new SearchCellFormulaAction(jTemplate, formulaInfos); + new SearchWidgetFormulaAction(jTemplate, formulaInfos); + new SearchDataFormulaAction(jTemplate, formulaInfos); + new SearchTemplateFormulaAction(jTemplate, formulaInfos); + new SearchFloatFormulaAction(jTemplate, formulaInfos); + return formulaInfos; + } + + public ArrayList getFormulaInfos() { + return formulaInfos; + } + + public void setFormulaInfos(ArrayList formulaInfos) { + this.formulaInfos = formulaInfos; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/AbstractSearchCellFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/AbstractSearchCellFormulaAction.java new file mode 100644 index 0000000000..3156878f3f --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/AbstractSearchCellFormulaAction.java @@ -0,0 +1,37 @@ +package com.fr.design.actions.replace.action.content.formula.cell; + +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.mainframe.JTemplate; + +import java.util.ArrayList; + +/** + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-30 + */ +public abstract class AbstractSearchCellFormulaAction implements SearchCellFormula{ + + + @Override + public void searchFormulaFromCell(JTemplate jTemplate, ArrayList formulaInfos) { + + } + + @Override + public void searchFormulaFromCellType(ArrayList formulaInfos, ITContent content) { + + } + + @Override + public void searchFormula(ArrayList formulaInfos, ITContent content) { + + } + + @Override + public ArrayList search4Infos(JTemplate jTemplate) { + return new ArrayList<>(); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaAction.java new file mode 100644 index 0000000000..cc27b002ea --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaAction.java @@ -0,0 +1,198 @@ +package com.fr.design.actions.replace.action.content.formula.cell; + +import com.fr.base.Formula; +import com.fr.base.present.FormulaPresent; +import com.fr.design.actions.replace.action.content.cell.SearchCellAction; +import com.fr.design.actions.replace.action.content.formula.AbstractSearchFormulaAction; +import com.fr.design.actions.replace.action.content.formula.SearchFormula; +import com.fr.design.actions.replace.action.content.formula.highlight.condition.*; +import com.fr.design.actions.replace.action.content.formula.highlight.SearchHighlightFormulaAction; +import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchJSHighlightAction; +import com.fr.design.actions.replace.info.CellInfo; +import com.fr.design.actions.replace.info.FormulaInfo; + +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.js.NameJavaScriptGroup; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.cell.cellattr.highlight.DefaultHighlight; +import com.fr.report.cell.cellattr.highlight.HighlightAction; +import com.fr.report.cell.cellattr.highlight.HighlightGroup; +import com.fr.report.core.sort.common.CellSortAttr; +import com.fr.report.core.sort.sortexpression.FormulaSortExpression; +import com.fr.report.core.sort.sortexpression.SortExpression; + +import java.util.ArrayList; +import java.util.HashMap; + +/** + * 搜索单元格中的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-17 + */ +public class SearchCellFormulaAction extends AbstractSearchCellFormulaAction { + + + public static HashMap cellType = new HashMap<>(); + + static { + cellType.put("DSColumn", new SearchDSColumnFormulaAction()); + cellType.put("Formula", new SearchCellFormulaTypeAction()); + cellType.put("RichText", new SearchRichFormulaAction()); + cellType.put("SubReport", new SearchSubReportFormulaAction()); + } + + public static HashMap conditionHashMap = new HashMap<>(); + + static { + conditionHashMap.put("FormulaCondition", new SearchFormulaConditionAction()); + conditionHashMap.put("ObjectCondition", new SearchObjectConditionAction()); + conditionHashMap.put("ListCondition", new SearchListConditionAction()); + } + + public SearchCellFormulaAction(JTemplate jTemplate, ArrayList fomulaInfos) { + searchFormulaFromCell(jTemplate, fomulaInfos); + } + + /** + * 从单元格中寻找公式 + * + * @param jTemplate 指定搜索模板 + * @param formulaInfos 指定添加信息的数组 + */ + @Override + public void searchFormulaFromCell(JTemplate jTemplate, ArrayList formulaInfos) { + SearchCellAction searchCellAction = new SearchCellAction(jTemplate); + if (searchCellAction.isCellInfosExist()) { + for (CellInfo cellInfo : searchCellAction.getCellInfos()) { + //根据单元格类型的不同来进行不同的操作 + searchFormulaFromCellInfo(cellInfo, formulaInfos); + + if (cellInfo.getContent().getReplaceObject() instanceof TemplateCellElement) { + //单元格属性-排序 + searchCellSortAttr4Formula(cellInfo, formulaInfos); + //单元格属性-形态 + searchCellPresent4Formula(cellInfo, formulaInfos); + //单元格属性-其他-插入策略 + searchCellInsertPolicy4Formula(cellInfo, formulaInfos); + //单元格条件属性-参数-公式 + searchCellConditionPara4Formula(cellInfo, formulaInfos); + //单元格条件属性-属性-参数 + searchCellHighlightPara4Formula(cellInfo, formulaInfos); + //单元格超链 + searchCellHyperLink4Formula(cellInfo, formulaInfos); + } + + } + } + + } + + private void searchCellHyperLink4Formula(CellInfo cellInfo, ArrayList formulaInfos) { + NameJavaScriptGroup nameJavaScriptGroup = ((CellElement) cellInfo.getContent().getReplaceObject()).getNameHyperlinkGroup(); + if (nameJavaScriptGroup != null) { + for (int i = 0; i < nameJavaScriptGroup.size(); i++) { + SearchJSHighlightAction action = new SearchJSHighlightAction(); + action.searchJSFormulaFromOther(formulaInfos, cellInfo.getContent(), nameJavaScriptGroup.getNameHyperlink(i).getJavaScript()); + } + } + + } + + private void searchCellHighlightPara4Formula(CellInfo cellInfo, ArrayList formulaInfos) { + if (((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getHighlightGroup() != null) { + HighlightGroup highlightGroup = ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getHighlightGroup(); + for (int i = 0; i < highlightGroup.size(); i++) { + for (int j = 0; j < ((DefaultHighlight) highlightGroup.getHighlight(i)).actionCount(); j++) { + HighlightAction highlightAction = ((DefaultHighlight) highlightGroup.getHighlight(i)).getHighlightAction(j); + //处理HighlightAction + SearchHighlightFormulaAction searchHighlightAction = new SearchHighlightFormulaAction(); + ITContent newContent = cellInfo.getContent().copy(); + searchHighlightAction.dealWithHighlightAction(newContent, formulaInfos, highlightAction); + } + } + } + } + + private void searchCellConditionPara4Formula(CellInfo cellInfo, ArrayList formulaInfos) { + if (((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getHighlightGroup() != null) { + HighlightGroup highlightGroup = ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getHighlightGroup(); + for (int i = 0; i < highlightGroup.size(); i++) { + if (conditionHashMap.containsKey(((DefaultHighlight) highlightGroup.getHighlight(i)).getCondition().getClass().getSimpleName())) { + SearchConditionFormula searchCondition = conditionHashMap.get(((DefaultHighlight) highlightGroup.getHighlight(i)).getCondition().getClass().getSimpleName()); + ITContent newContent = cellInfo.getContent().copy(); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Condition_Attributes"), + Toolkit.i18nText("Fine-Design_Basic_Formula")); + searchCondition.searchFormulaFromCondition(formulaInfos, newContent, ((DefaultHighlight) highlightGroup.getHighlight(i)).getCondition()); + } + } + } + } + + private void searchCellPresent4Formula(CellInfo cellInfo, ArrayList formulaInfos) { + if (((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getPresent() != null + && ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getPresent() instanceof FormulaPresent) { + ITContent newContent = cellInfo.getContent().copy(); + newContent.setReplaceObject((((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getPresent())); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Cell_Attributes"), + Toolkit.i18nText("Fine-Design_Report_Present")); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + + private void searchCellInsertPolicy4Formula(CellInfo cellInfo, ArrayList formulaInfos) { + if (((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getCellInsertPolicyAttr() != null + && ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getCellInsertPolicyAttr().getDefaultInsertValue() instanceof Formula) { + ITContent newContent = cellInfo.getContent().copy(); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Cell_Attributes"), + Toolkit.i18nText("Fine-Design_Report_Other"), + Toolkit.i18nText("Fine-Design_Basic_CellWrite_InsertRow_Policy")); + newContent.setReplaceObject(((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getCellInsertPolicyAttr()); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + + + private void searchCellSortAttr4Formula(CellInfo cellInfo, ArrayList formulaInfos) { + if (((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getCellExpandAttr() != null) { + CellSortAttr sortAttr = ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getCellExpandAttr().getCellSortAttr(); + if (isSortAttrExist(sortAttr)) { + for (SortExpression sortExpression : sortAttr.getSortExpressions()) { + if (sortExpression instanceof FormulaSortExpression) { + ITContent newContent = cellInfo.getContent().copy(); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Cell_Attributes"), + Toolkit.i18nText("Fine-Design_Report_Expand"), + Toolkit.i18nText("Fine-Design_Basic_Action_Sort") + ); + newContent.setReplaceObject(sortExpression); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + + } + } + } + + private boolean isSortAttrExist(CellSortAttr sortAttr) { + return sortAttr != null && sortAttr.getSortExpressions() != null; + } + + private void searchFormulaFromCellInfo(CellInfo cellInfo, ArrayList formulaInfos) { + if (((CellElement) (cellInfo.getContent().getReplaceObject())).getValue() != null + && cellType.containsKey(((CellElement) (cellInfo.getContent().getReplaceObject())).getValue().getClass().getSimpleName())) { + SearchCellFormula searchCellFormula = cellType.get(((CellElement) (cellInfo.getContent().getReplaceObject())).getValue().getClass().getSimpleName()); + searchCellFormula.searchFormulaFromCellType(formulaInfos, cellInfo.getContent()); + + } + } + + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaTypeAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaTypeAction.java new file mode 100644 index 0000000000..75e2083cf2 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaTypeAction.java @@ -0,0 +1,27 @@ +package com.fr.design.actions.replace.action.content.formula.cell; + +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.report.cell.CellElement; + +import java.util.ArrayList; + +/** + * 查找公式时单元格格式如果是公式类型则操作此类 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-18 + */ +public class SearchCellFormulaTypeAction extends AbstractSearchCellFormulaAction { + + + @Override + public void searchFormulaFromCellType(ArrayList formulaInfos, ITContent content) { + ITContent newContent = content.copy(); + newContent.setReplaceObject(((CellElement)(content.getReplaceObject())).getValue()); + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Formula")); + formulaInfos.add(new FormulaInfo(newContent)); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchDSColumnFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchDSColumnFormulaAction.java new file mode 100644 index 0000000000..baa2e1ec61 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchDSColumnFormulaAction.java @@ -0,0 +1,117 @@ +package com.fr.design.actions.replace.action.content.formula.cell; + +import com.fr.base.Formula; +import com.fr.base.Parameter; +import com.fr.design.actions.replace.action.content.formula.AbstractSearchFormulaAction; +import com.fr.design.actions.replace.action.content.formula.highlight.condition.SearchCommonConditionAction; +import com.fr.design.actions.replace.action.content.formula.highlight.condition.SearchConditionFormula; +import com.fr.design.actions.replace.action.content.formula.highlight.condition.SearchFormulaConditionAction; +import com.fr.design.actions.replace.action.content.formula.highlight.condition.SearchListConditionAction; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.general.data.Condition; +import com.fr.report.cell.cellattr.core.group.DSColumn; +import com.fr.report.core.sort.sortexpression.FormulaSortExpression; +import com.fr.report.core.sort.sortexpression.SortExpression; + +import java.util.ArrayList; +import java.util.HashMap; + +/** + * 查找公式时单元格格式如果是数据列型则操作此类 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-18 + */ +public class SearchDSColumnFormulaAction extends AbstractSearchCellFormulaAction { + public static HashMap conditionHashMap = new HashMap<>(); + static { + conditionHashMap.put("FormulaCondition",new SearchFormulaConditionAction()); + conditionHashMap.put("CommonCondition",new SearchCommonConditionAction()); + conditionHashMap.put("ListCondition",new SearchListConditionAction()); + } + + + @Override + public void searchFormulaFromCellType(ArrayList formulaInfos, ITContent itContent) { + if (itContent.getContentObject().getCell().getValue() instanceof DSColumn){ + if (((DSColumn) itContent.getContentObject().getCell().getValue()).getCondition() != null){ + ITContent content = itContent.copy(); + //数据列 + content.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_DS_Column")); + DSColumn dsColumn = ((DSColumn) itContent.getContentObject().getCell().getValue()); + //过滤条件中的公式 + addFormulaInfos2ArrayFromCondition(content,dsColumn.getCondition(), formulaInfos); + //动态参数中的公式 + addFormulaInfos2ArrayFromPara(content,dsColumn,formulaInfos); + //高级-排序中的公式 + addFormulaInfos2ArrayFromSortExpression(content,dsColumn,formulaInfos); + //高级-显示值中的公式 + addFormulaInfos2ArrayFromResult(content,dsColumn,formulaInfos); + + } + + } + } + private void addFormulaInfos2ArrayFromResult(ITContent content, DSColumn dsColumn, ArrayList formulaInfos) { + if (dsColumn.getResult().length() > 0 && dsColumn.getResult().charAt(0) == '='){ + ITContent newContent =content.copy(); + newContent.setReplaceObject(dsColumn); + //高级-显示值 + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Advanced"), + Toolkit.i18nText("Fine-Design_Basic_Display_Value") + ); + formulaInfos.add(new FormulaInfo(newContent)); + } + + } + + private void addFormulaInfos2ArrayFromSortExpression(ITContent content, DSColumn dsColumn, ArrayList formulaInfos) { + if (dsColumn.getCellSortAttr() != null && dsColumn.getCellSortAttr().getSortExpressions() != null){ + for (SortExpression sortExpression : dsColumn.getCellSortAttr().getSortExpressions()){ + if (sortExpression instanceof FormulaSortExpression){ + ITContent newContent =content.copy(); + //高级-排序 + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Advanced"), + Toolkit.i18nText("Fine-Design_Basic_Action_Sort") + ); + newContent.getContentObject().setSortExpression((FormulaSortExpression) sortExpression); + newContent.setReplaceObject(sortExpression); + formulaInfos.add(new FormulaInfo(newContent)); + + } + } + + } + } + + private void addFormulaInfos2ArrayFromPara(ITContent content, DSColumn dsColumn, ArrayList formulaInfos) { + for (Parameter parameter : dsColumn.getParameters()){ + if (parameter.getValue() instanceof Formula){ + ITContent newContent = content.copy(); + //动态参数注入 + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_TableData_Dynamic_Parameter_Setting")); + newContent.getContentObject().setFormula((Formula) parameter.getValue()); + newContent.setReplaceObject(parameter.getValue()); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + } + + /** + * 数据列过滤条件中的公式 + */ + private void addFormulaInfos2ArrayFromCondition(ITContent content, Condition condition, ArrayList formulaInfos){ + //这边condition有三种情况:FormulaCondition、CommonCondition、ListCondition,分别处理 + SearchConditionFormula searchCondition = conditionHashMap.get(condition.getClass().getSimpleName()); + ITContent newContent = content.copy(); + //过滤条件 + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Filter_Conditions")); + searchCondition.searchFormulaFromCondition(formulaInfos, newContent,condition); + + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchRichFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchRichFormulaAction.java new file mode 100644 index 0000000000..db1c97923a --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchRichFormulaAction.java @@ -0,0 +1,34 @@ +package com.fr.design.actions.replace.action.content.formula.cell; + +import com.fr.design.actions.replace.action.content.formula.AbstractSearchFormulaAction; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.cellattr.core.RichText; + +import java.util.ArrayList; + +/** + * 搜索单元格富文本类型的公式 + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-18 + */ +public class SearchRichFormulaAction extends AbstractSearchCellFormulaAction { + @Override + public void searchFormulaFromCellType(ArrayList formulaInfos, ITContent content) { + //todo 富文本这边直接遍历RichChar来拿公式 + if (((RichText)((CellElement)(content.getReplaceObject())).getValue()).getContent().contains("${")){ + ITContent newContent =content.copy(); + newContent.setReplaceObject(((CellElement)(content.getReplaceObject())).getValue()); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Rich_Text"), + Toolkit.i18nText("Fine-Design_Basic_Formula") + ); + formulaInfos.add(new FormulaInfo(newContent)); + } + + + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchSubReportFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchSubReportFormulaAction.java new file mode 100644 index 0000000000..66e9802a0f --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchSubReportFormulaAction.java @@ -0,0 +1,36 @@ +package com.fr.design.actions.replace.action.content.formula.cell; + +import com.fr.base.Formula; +import com.fr.base.core.KV; +import com.fr.design.actions.replace.action.content.formula.AbstractSearchFormulaAction; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.cellattr.core.SubReport; + +import java.util.ArrayList; + +/** + * 搜索单元格子报表类型的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-18 + */ +public class SearchSubReportFormulaAction extends AbstractSearchCellFormulaAction { + @Override + public void searchFormulaFromCellType(ArrayList formulaInfos, ITContent content) { + KV[] kvs = ((SubReport) (((CellElement) content.getReplaceObject()).getValue())).getParameterKVS(); + for (KV kv : kvs) { + if (kv.getValue() instanceof Formula) { + ITContent newContent = content.copy(); + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Sub_Report_Parameter")); + newContent.setReplaceObject(kv); + formulaInfos.add(new FormulaInfo(newContent)); + } + + } + + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java new file mode 100644 index 0000000000..0a30bc39c2 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java @@ -0,0 +1,213 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.Formula; +import com.fr.chart.chartattr.Axis; +import com.fr.chart.chartattr.Chart; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.chartattr.Title; +import com.fr.chart.chartdata.NormalChartData; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.attr.axis.VanChartAlertValue; +import com.fr.plugin.chart.attr.axis.VanChartAxis; +import com.fr.plugin.chart.attr.axis.VanChartValueAxis; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * 图表类型获取公式汇总 + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-12 + */ +public class SearchChartCollectionFormulaAction { + + public SearchChartCollectionFormulaAction(ArrayList formulaInfos, ITContent content, ChartCollection chartCollection) { + for (int i = 0 ; i < chartCollection.getChartCount() ;i ++){ + ITContent chartContent =content.copy(); + SearchChartPatternFormula(formulaInfos,chartContent,chartCollection.getChart(i)); + //数据-单元格数据-分类名&系列名&值 + SearchChartDataFormula(formulaInfos,content,chartCollection.getChart(i)); + } + + } + + private void SearchChartDataFormula(ArrayList formulaInfos, ITContent content, Chart chart) { + if (chart.defaultChartData() instanceof NormalChartData){ + NormalChartData chartData = (NormalChartData) chart.defaultChartData(); + //todo + } + } + + + private void SearchChartPatternFormula(ArrayList formulaInfos, ITContent chartContent, Chart chart){ + //样式-标题 + SearchChartPatternFormulaFromTitle(formulaInfos, chartContent, chart); + + //样式-坐标轴-值定义&样式-坐标轴-轴标题 + SearchChartPatternFormulaFromAxisValue(formulaInfos, chartContent, chart); + + //样式-背景-警戒线 + SearchChartPatternFormulaFromAlertLine(formulaInfos,chartContent,chart); + } + + private void SearchChartPatternFormulaFromAlertLine(ArrayList formulaInfos, ITContent chartContent, Chart chart) { + Axis xAxis = chart.getPlot().getxAxis(); + Axis yAxis = chart.getPlot().getyAxis(); + ITContent content = chartContent.copy(); + content.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Pattern"), + Toolkit.i18nText("Fine-Design_Chart_Background"), + Toolkit.i18nText("Fine-Design_Chart_Plot_Region"), + Toolkit.i18nText("Fine-Design_Chart_Alert_Line") + ); + if (xAxis instanceof VanChartAxis){ + List list = ((VanChartAxis) xAxis).getAlertValues(); + for (VanChartAlertValue alertValue : list){ + //警戒线设置 + dealAlertValue(formulaInfos,content,alertValue); + //提示文字 + dealAlertContent(formulaInfos,content,alertValue); + } + } + if (yAxis instanceof VanChartAxis){ + List list = ((VanChartAxis) yAxis).getAlertValues(); + for (VanChartAlertValue alertValue : list){ + //警戒线设置 + dealAlertValue(formulaInfos,content,alertValue); + //提示文字 + dealAlertContent(formulaInfos,content,alertValue); + } + } + + } + + private void dealAlertContent(ArrayList formulaInfos, ITContent content, VanChartAlertValue alertValue) { + if (alertValue.getAlertContentFormula() != null){ + ITContent alertContent = content.copy(); + alertContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Alert_Text")); + alertContent.setReplaceObject(alertValue.getAlertContentFormula()); + formulaInfos.add(new FormulaInfo(alertContent)); + } + } + + private void dealAlertValue(ArrayList formulaInfos, ITContent content, VanChartAlertValue alertValue) { + if (alertValue.getAlertValueFormula() != null){ + ITContent valueContent = content.copy(); + valueContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Alert_Set")); + valueContent.setReplaceObject(alertValue.getAlertValueFormula()); + formulaInfos.add(new FormulaInfo(valueContent)); + } + } + + private void SearchChartPatternFormulaFromAxisValue(ArrayList formulaInfos, ITContent chartContent, Chart chart) { + Axis xAxis = chart.getPlot().getxAxis(); + Axis yAxis = chart.getPlot().getyAxis(); + //样式-坐标轴-x轴 + if (xAxis!= null){ + //轴标题 + ITContent xAxisContent = chartContent.copy(); + xAxisContent.addOtherPos( + chart.getChartName(), + Toolkit.i18nText("Fine-Design_Chart_Pattern"), + Toolkit.i18nText("Fine-Design_Chart_Axis"), + Toolkit.i18nText("Fine-Design_Chart_X_Axis") + ); + dealTitle(formulaInfos, xAxisContent,xAxis.getTitle()); + dealChartValueDefine(formulaInfos, xAxisContent,xAxis); + } + + //样式-坐标轴-y轴-轴标题 + if (yAxis !=null){ + ITContent yAxisContent = chartContent.copy(); + yAxisContent.addOtherPos( + chart.getChartName(), + Toolkit.i18nText("Fine-Design_Chart_Pattern"), + Toolkit.i18nText("Fine-Design_Chart_Axis"), + Toolkit.i18nText("Fine-Design_Chart_Y_Axis") + + ); + dealTitle(formulaInfos,yAxisContent,yAxis.getTitle()); + dealChartValueDefine(formulaInfos,yAxisContent,yAxis); + } + + + + } + + private void dealChartValueDefine(ArrayList formulaInfos, ITContent axisContent, Axis axis) { + ITContent content = axisContent.copy(); + content.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Value_Define")); + //自定义最大值最小值 + dealChartMaxAndMinValue(formulaInfos,content,axis); + //自定义主次刻度 + dealChartMainAndSecUnit(formulaInfos,content,axis); + //自定义对数底数 + dealChartLogBase(formulaInfos,content,axis); + + } + + private void dealChartLogBase(ArrayList formulaInfos, ITContent content, Axis axis) { + if (axis instanceof VanChartValueAxis){ + if (axis.isLog() && ((VanChartValueAxis) axis).getLogBase() != null){ + ITContent logContent =content.copy(); + logContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Custom_LogBase_Value")); + logContent.setReplaceObject(((VanChartValueAxis) axis).getLogBase()); + formulaInfos.add(new FormulaInfo(logContent)); + } + } + } + + private void dealChartMainAndSecUnit(ArrayList formulaInfos, ITContent content, Axis axis) { + if (axis.isCustomMainUnit() && axis.getMainUnit() != null){ + ITContent mainContent = content.copy(); + mainContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Custom_Main_Type")); + mainContent.setReplaceObject(axis.getMainUnit()); + formulaInfos.add(new FormulaInfo(mainContent)); + } + if (axis.isCustomSecUnit() && axis.getSecUnit() != null){ + ITContent secContent = content.copy(); + secContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Custom_Second_Type")); + secContent.setReplaceObject(axis.getSecUnit()); + formulaInfos.add(new FormulaInfo(secContent)); + } + } + + private void dealChartMaxAndMinValue(ArrayList formulaInfos, ITContent axisContent, Axis axis) { + if (axis.isCustomMaxValue() && axis.getMaxValue() != null){ + ITContent maxContent = axisContent.copy(); + maxContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Custom_Max_Value")); + maxContent.setReplaceObject(axis.getMaxValue()); + formulaInfos.add(new FormulaInfo(maxContent)); + } + if (axis.isCustomMinValue() && axis.getMinValue() != null){ + ITContent minContent = axisContent.copy(); + minContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Custom_Min_Value")); + minContent.setReplaceObject(axis.getMinValue()); + formulaInfos.add(new FormulaInfo(minContent)); + } + } + + private void SearchChartPatternFormulaFromTitle(ArrayList formulaInfos, ITContent chartContent, Chart chart){ + //样式-标题 + ITContent titleContent = chartContent.copy(); + titleContent.addOtherPos( + chart.getChartName(), + Toolkit.i18nText("Fine-Design_Chart_Pattern") + + ); + dealTitle(formulaInfos,titleContent,chart.getTitle()); + } + + private void dealTitle(ArrayList formulaInfos, ITContent chartContent, Title title) { + if (title !=null && title.getTextObject() instanceof Formula){ + ITContent content = chartContent.copy(); + content.addOtherPos(Toolkit.i18nText("Fine-Design_Form_Title")); + content.setReplaceObject(title.getTextObject()); + formulaInfos.add(new FormulaInfo(content)); + } + } +}