Browse Source

Pull request #14864: REPORT-134777 超链名称支持公式计算-全局查找匹配不到控件里的公式

Merge in DESIGN/design from ~ZACK/design:feature/x to feature/x

* commit '93ac7196f7c36357f4e5fe622bb129cdad656f23':
  REPORT-134777 超链名称支持公式计算-全局查找匹配不到控件里的公式
feature/x
zack-申凯鹏 2 months ago
parent
commit
8d161cd761
  1. 41
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java
  2. 13
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java
  3. 15
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaAction.java
  4. 27
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/AbstractSearchWidgetFormulaAction.java
  5. 4
      designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java

41
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java

@ -4,27 +4,24 @@ import com.fr.base.BaseFormula;
import com.fr.base.Formula; import com.fr.base.Formula;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.StoreProcedureParameter; import com.fr.base.StoreProcedureParameter;
import com.fr.base.core.KV;
import com.fr.base.iofile.attr.WatermarkAttr; import com.fr.base.iofile.attr.WatermarkAttr;
import com.fr.base.present.FormulaPresent; import com.fr.base.present.FormulaPresent;
import com.fr.base.present.Present;
import com.fr.data.condition.FormulaCondition; import com.fr.data.condition.FormulaCondition;
import com.fr.data.core.Compare; import com.fr.data.core.Compare;
import com.fr.design.actions.replace.info.DealWithInfoValue; import com.fr.design.actions.replace.info.DealWithInfoValue;
import com.fr.design.actions.replace.info.Info; import com.fr.design.actions.replace.info.Info;
import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.design.actions.replace.utils.ShowValueUtils;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.form.main.Form;
import com.fr.function.IF;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.js.NameJavaScript;
import com.fr.js.SingleJavaScript; import com.fr.js.SingleJavaScript;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.report.cell.cellattr.CellInsertPolicyAttr; import com.fr.report.cell.cellattr.CellInsertPolicyAttr;
import com.fr.report.cell.cellattr.core.RichChar;
import com.fr.report.cell.cellattr.core.group.DSColumn; import com.fr.report.cell.cellattr.core.group.DSColumn;
import com.fr.report.core.sort.sortexpression.FormulaSortExpression; import com.fr.report.core.sort.sortexpression.FormulaSortExpression;
import com.fr.stable.FormulaProvider; import com.fr.stable.FormulaProvider;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.collections.combination.Pair; import com.fr.stable.collections.combination.Pair;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -545,6 +542,40 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
} }
return false; return false;
} }
},
/**
* 超链名字
*/
NAMEJAVASCRIPT("NameJavaScript") {
@Override
public Map<String, String> getValue(Object... o) {
HashMap<String, String> map = new HashMap<>();
if (StringUtils.isNotEmpty(((NameJavaScript) o[0]).getName())) {
map.put("content", ((NameJavaScript) o[0]).getName());
}
return map;
}
@Override
public void setValue(Info info, String findStr, String replaceStr, List<Pair<Integer, Integer>> operatorArray) {
Object replaceObject = info.getContent().getReplaceObject();
info.updateOldStr(((NameJavaScript)replaceObject).getName(), findStr);
String str = ((NameJavaScript)replaceObject).getName();
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
((NameJavaScript)replaceObject).setName(ShowValueUtils.replaceAll(str, findStr, replaceStr));
}
@Override
public boolean check(Info info) {
if (info.getContent().getReplaceObject() instanceof NameJavaScript) {
NameJavaScript nameJavaScript = (NameJavaScript) info.getContent().getReplaceObject();
if (StableUtils.canBeFormula(nameJavaScript.getName())) {
return StringUtils.equals(nameJavaScript.getName(), info.getContent().getOldShowStr());
}
}
return false;
}
}; };

13
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java

@ -1,12 +1,12 @@
package com.fr.design.actions.replace.action.content.formula; package com.fr.design.actions.replace.action.content.formula;
import com.fr.chart.chartdata.MeterReportDefinition;
import com.fr.data.VerifyItem; import com.fr.data.VerifyItem;
import com.fr.data.impl.FormulaDictionary; import com.fr.data.impl.FormulaDictionary;
import com.fr.design.actions.replace.info.DealWithInfoValue; import com.fr.design.actions.replace.info.DealWithInfoValue;
import com.fr.design.actions.replace.info.Info; import com.fr.design.actions.replace.info.Info;
import com.fr.design.actions.replace.info.base.SearchTag; import com.fr.design.actions.replace.info.base.SearchTag;
import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.design.actions.replace.utils.ShowValueUtils;
import com.fr.form.ui.Widget;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.plugin.chart.map.data.VanMapReportDefinition; import com.fr.plugin.chart.map.data.VanMapReportDefinition;
@ -173,6 +173,17 @@ public enum FormulaTag implements DealWithInfoValue {
dictionary.setProduceFormula(ShowValueUtils.replaceAll(str, findStr, replaceStr)); dictionary.setProduceFormula(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
} }
},
WIDGET_LABEL(SearchTag.WIDGET_LABEL) {
@Override
public void setValue(Info info, String findStr, String replaceStr, List<Pair<Integer, Integer>> operatorArray) {
if (info.getContent().getHoldObject() instanceof Widget) {
Widget widget = (Widget) info.getContent().getHoldObject();
String str = widget.getLabelName();
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
widget.setLabelName(ShowValueUtils.replaceAll(str, findStr, replaceStr));
}
}
}; };
int index; int index;

15
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaAction.java

@ -6,13 +6,13 @@ import com.fr.base.present.FormulaPresent;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.actions.replace.action.content.cell.SearchCellAction; import com.fr.design.actions.replace.action.content.cell.SearchCellAction;
import com.fr.design.actions.replace.action.content.formula.chart.SearchChartCollectionFormulaAction; import com.fr.design.actions.replace.action.content.formula.chart.SearchChartCollectionFormulaAction;
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.SearchHighlightFormulaAction;
import com.fr.design.actions.replace.action.content.formula.highlight.condition.SearchConditionFormula;
import com.fr.design.actions.replace.action.content.formula.highlight.condition.SearchConditionManager;
import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchJSHighlightAction; import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchJSHighlightAction;
import com.fr.design.actions.replace.action.content.formula.widget.DictionaryType; import com.fr.design.actions.replace.action.content.formula.widget.DictionaryType;
import com.fr.design.actions.replace.info.CellInfo; import com.fr.design.actions.replace.info.CellInfo;
import com.fr.design.actions.replace.info.FormulaInfo; import com.fr.design.actions.replace.info.FormulaInfo;
import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.actions.replace.info.base.SearchTag; import com.fr.design.actions.replace.info.base.SearchTag;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
@ -29,7 +29,7 @@ import com.fr.report.core.sort.common.CellSortAttr;
import com.fr.report.core.sort.sortexpression.FormulaSortExpression; import com.fr.report.core.sort.sortexpression.FormulaSortExpression;
import com.fr.report.core.sort.sortexpression.SortExpression; import com.fr.report.core.sort.sortexpression.SortExpression;
import com.fr.stable.CommonUtils; import com.fr.stable.CommonUtils;
import com.fr.stable.StableUtils;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -119,7 +119,14 @@ public class SearchCellFormulaAction implements SearchCellFormula {
for (int i = 0; i < nameJavaScriptGroup.size(); i++) { for (int i = 0; i < nameJavaScriptGroup.size(); i++) {
SearchJSHighlightAction action = SearchJSHighlightAction.getInstance(); SearchJSHighlightAction action = SearchJSHighlightAction.getInstance();
ITContent content = ITContent.copy(cellInfo.getContent()); ITContent content = ITContent.copy(cellInfo.getContent());
content.addOtherPos(nameJavaScriptGroup.getNameHyperlink(i).getName()); String name = nameJavaScriptGroup.getNameHyperlink(i).getName();
if(StableUtils.canBeFormula(name)){
ITContent newContent = ITContent.copy(content);
newContent.setReplaceObject(nameJavaScriptGroup.getNameHyperlink(i));
newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Hyperlink"));
formulaInfos.add(new FormulaInfo(newContent));
}
content.addOtherPos(name);
action.searchJSFormulaFromOther(formulaInfos, content, nameJavaScriptGroup.getNameHyperlink(i).getJavaScript()); action.searchJSFormulaFromOther(formulaInfos, content, nameJavaScriptGroup.getNameHyperlink(i).getJavaScript());
} }
} }

27
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/AbstractSearchWidgetFormulaAction.java

@ -4,12 +4,14 @@ import com.fr.base.Formula;
import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchJSHighlightAction; import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchJSHighlightAction;
import com.fr.design.actions.replace.info.FormulaInfo; import com.fr.design.actions.replace.info.FormulaInfo;
import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.actions.replace.info.base.SearchTag;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.form.event.Listener; import com.fr.form.event.Listener;
import com.fr.form.ui.DataControl; import com.fr.form.ui.DataControl;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WScaleLayout; import com.fr.form.ui.container.WScaleLayout;
import com.fr.form.ui.widget.CRBoundsWidget; import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.stable.StableUtils;
import java.util.List; import java.util.List;
@ -33,12 +35,13 @@ public abstract class AbstractSearchWidgetFormulaAction implements SearchWidgetF
Widget widget = (Widget) content.getReplaceObject(); Widget widget = (Widget) content.getReplaceObject();
//控件值中的公式 //控件值中的公式
searchFormulaFromWidgetValue(content, formulaInfos); searchFormulaFromWidgetValue(content, formulaInfos);
searchFormulaFromWidgetLabel(content, formulaInfos);
for (int i = 0; i < widget.getListenerSize(); i++) { for (int i = 0; i < widget.getListenerSize(); i++) {
Listener listener = widget.getListener(i); Listener listener = widget.getListener(i);
ITContent newContent = ITContent.copy(content); ITContent newContent = ITContent.copy(content);
//控件的事件可以使用的JS有五种,这边统一交给Highlight那边判断超级链接并进行处理 //控件的事件可以使用的JS有五种,这边统一交给Highlight那边判断超级链接并进行处理
SearchJSHighlightAction jsHighlightAction = SearchJSHighlightAction.getInstance(); SearchJSHighlightAction jsHighlightAction = SearchJSHighlightAction.getInstance();
newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Event"),listener.getName()); newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Event"), listener.getName());
jsHighlightAction.searchJSFormulaFromOther(formulaInfos, newContent, listener.getAction()); jsHighlightAction.searchJSFormulaFromOther(formulaInfos, newContent, listener.getAction());
} }
@ -53,8 +56,8 @@ public abstract class AbstractSearchWidgetFormulaAction implements SearchWidgetF
@Override @Override
public void searchFormulaFromWidgetValue(ITContent content, List<FormulaInfo> formulaInfos) { public void searchFormulaFromWidgetValue(ITContent content, List<FormulaInfo> formulaInfos) {
Widget widget = (Widget) content.getReplaceObject(); Widget widget = (Widget) content.getReplaceObject();
if (widget instanceof WScaleLayout){ if (widget instanceof WScaleLayout) {
widget = ((CRBoundsWidget)((WScaleLayout)widget).getWidget(0)).getWidget(); widget = ((CRBoundsWidget) ((WScaleLayout) widget).getWidget(0)).getWidget();
} }
if (widget instanceof DataControl) { if (widget instanceof DataControl) {
if (isWidgetValueValid(((DataControl) widget))) { if (isWidgetValueValid(((DataControl) widget))) {
@ -66,7 +69,23 @@ public abstract class AbstractSearchWidgetFormulaAction implements SearchWidgetF
} }
} }
private boolean isWidgetValueValid(DataControl control){ public void searchFormulaFromWidgetLabel(ITContent content, List<FormulaInfo> formulaInfos) {
Widget widget = (Widget) content.getReplaceObject();
if (widget instanceof WScaleLayout) {
widget = ((CRBoundsWidget) ((WScaleLayout) widget).getWidget(0)).getWidget();
}
if (StableUtils.canBeFormula(widget.getLabelName())) {
ITContent newContent = ITContent.copy(content);
newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Form_Label_Name"));
newContent.setHoldObject(widget);
newContent.setReplaceObject(widget.getLabelName());
newContent.setTag(SearchTag.WIDGET_LABEL);
formulaInfos.add(new FormulaInfo(newContent));
}
}
private boolean isWidgetValueValid(DataControl control) {
return control.getWidgetValue() != null return control.getWidgetValue() != null
&& control.getWidgetValue().getValue() instanceof Formula; && control.getWidgetValue().getValue() instanceof Formula;
} }

4
designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java

@ -56,6 +56,10 @@ public class SearchTag {
* 引用JS * 引用JS
*/ */
public static final int IMPORT_JS = 11; public static final int IMPORT_JS = 11;
/**
* 控件-标签名称
*/
public static final int WIDGET_LABEL = 12;

Loading…
Cancel
Save