From 7f835f9f8f64067203ff4ed8bd54326c72a3c04b Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 26 Sep 2022 14:48:43 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-75998=20=E5=88=A0=E9=99=A4=E5=AF=8C?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E9=80=BB=E8=BE=91=E3=80=81=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E9=80=9A=E9=85=8D=E7=AC=A6=E3=80=81=E5=A2=9E=E5=8A=A0=E6=82=AC?= =?UTF-8?q?=E6=B5=AE=E5=85=83=E7=B4=A0=E5=9B=BE=E7=89=87=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../replace/action/SearchManagerCenter.java | 2 +- .../action/ShowSearchResultAction.java | 31 ++++++++++------- .../action/content/cell/SearchCellAction.java | 1 + .../floatelement/SearchFloatAction.java | 5 ++- .../content/formula/FormulaReplaceObject.java | 34 ------------------- .../cell/SearchCellFormulaManager.java | 2 -- .../design/actions/replace/info/CellInfo.java | 28 --------------- .../actions/replace/utils/ShowValueUtils.java | 9 ++--- 8 files changed, 30 insertions(+), 82 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/SearchManagerCenter.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/SearchManagerCenter.java index 211ab41d6..0608bde48 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/SearchManagerCenter.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/SearchManagerCenter.java @@ -61,7 +61,7 @@ public class SearchManagerCenter { */ public enum ManagerType implements SearchManager { /** - * 注册单元格不同值类型中自己特有的公式(数据列、子报表、公式、富文本,可自己添加) + * 注册单元格不同值类型中自己特有的公式(数据列、子报表、公式,可自己添加) */ CELL_FORMULA(0) { @Override diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java index f555de968..846263c5a 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java @@ -24,6 +24,7 @@ import com.fr.design.mainframe.JTemplate; import com.fr.general.GeneralUtils; import com.fr.report.cell.CellElement; import com.fr.report.cell.FloatElement; +import com.fr.report.cell.cellattr.core.RichText; import com.fr.stable.StringUtils; import com.fr.stable.collections.combination.Pair; import org.jetbrains.annotations.Nullable; @@ -75,7 +76,7 @@ public enum ShowSearchResultAction implements ShowValue { } else { Map stringHashMap = info.getValue(); String content = stringHashMap.getOrDefault(objectContentKey, StringUtils.EMPTY); - if (ShowValueUtils.contains(content,str) && StringUtils.isNotEmpty(content)) { + if (isValueValid(content, str, info)) { info.getContent().setShowStr(ShowValueUtils.getCommonString(content, str)); info.getContent().setOldShowStr(content); info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); @@ -94,6 +95,11 @@ public enum ShowSearchResultAction implements ShowValue { cellInfo.getContent().setSelected(true); } + private boolean isValueValid(String content, String str, Info info) { + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + return ShowValueUtils.contains(content, str) && StringUtils.isNotEmpty(content) && !(cellElement.getValue() instanceof RichText); + + } }, /** * 搜索JS事件 @@ -139,7 +145,7 @@ public enum ShowSearchResultAction implements ShowValue { private void searchMap4JS(Map map, List jsInfos, JSInfo info, String str) { if (map.containsKey(objectNameKey) && StringUtils.isNotEmpty(map.get(objectNameKey))) { String name = map.get(objectNameKey); - if (name.contains(str)) { + if (ShowValueUtils.contains(name,str)) { JSInfo nameJSInfo = info.copy(); nameJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(name, str)); nameJSInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(name, str)); @@ -151,7 +157,7 @@ public enum ShowSearchResultAction implements ShowValue { } if (map.containsKey(objectContentKey) && StringUtils.isNotEmpty(map.get(objectContentKey))) { String content = map.get(objectContentKey); - if (content.contains(str)) { + if (ShowValueUtils.contains(content,str)) { JSInfo contentJSInfo = info.copy(); contentJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(content, str)); contentJSInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); @@ -195,7 +201,7 @@ public enum ShowSearchResultAction implements ShowValue { private void searchMap4SQLContent(Map map, List sqlInfos, SQLInfo info, String str) { if (map.containsKey(objectContentKey) && StringUtils.isNotEmpty(map.get(objectContentKey))) { String content = map.get(objectContentKey); - if (content.contains(str)) { + if (ShowValueUtils.contains(content,str)) { SQLInfo contentJSInfo = info.copy(); contentJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(content, str)); contentJSInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); @@ -231,7 +237,7 @@ public enum ShowSearchResultAction implements ShowValue { if (((FloatInfo) info).isChartExist()) { ChartCollection chartCollection = (ChartCollection) floatElement.getValue(); for (int i = 0; i < chartCollection.getChartCount(); i++) { - if (isTitleNameValid(chartCollection.getChart(i).getTitle(),str)) { + if (isTitleNameValid(chartCollection.getChart(i).getTitle(), str)) { String titleName = GeneralUtils.objectToString(chartCollection.getChart(i).getTitle().getTextObject()); FloatInfo floatInfo = ((FloatInfo) info).copy(); floatInfo.setFloatChartIndex(i); @@ -244,7 +250,7 @@ public enum ShowSearchResultAction implements ShowValue { } } } else { - if (GeneralUtils.objectToString(floatElement.getValue()).contains(str)) { + if (ShowValueUtils.contains(GeneralUtils.objectToString(floatElement.getValue()), str)) { FloatInfo floatInfo = ((FloatInfo) info).copy(); setShowInfo(floatInfo, GeneralUtils.objectToString(floatElement.getValue()), str); floatInfos.add(floatInfo); @@ -285,7 +291,7 @@ public enum ShowSearchResultAction implements ShowValue { private void searchMap4Component(Map stringHashMap, ArrayList componentInfos, ComponentInfo info, String str) { if (stringHashMap.containsKey(objectContentKey)) { String content = stringHashMap.get(objectContentKey); - if (content.contains(str)) { + if (ShowValueUtils.contains(content,str)) { info.getContent().setShowStr(ShowValueUtils.getCommonString(content, str)); info.getContent().setOldShowStr(stringHashMap.get(objectContentKey)); info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); @@ -319,7 +325,7 @@ public enum ShowSearchResultAction implements ShowValue { private void searchMap4Widget(Map map, List widgetInfos, WidgetInfo info, String str) { if (map.containsKey(objectNameKey)) { String name = map.get(objectNameKey); - if (StringUtils.isNotEmpty(name) && name.contains(str)) { + if (StringUtils.isNotEmpty(name) && ShowValueUtils.contains(name,str)) { WidgetInfo nameInfo = info.copy(info); nameInfo.getContent().setShowStr(ShowValueUtils.getCommonString(name, str)); nameInfo.getContent().setOldShowStr(map.get(objectNameKey)); @@ -331,7 +337,7 @@ public enum ShowSearchResultAction implements ShowValue { } if (map.containsKey(objectWaterMarkKey)) { String waterMark = map.get(objectWaterMarkKey); - if (StringUtils.isNotEmpty(waterMark) && waterMark.contains(str)) { + if (StringUtils.isNotEmpty(waterMark) && ShowValueUtils.contains(waterMark,str)) { WidgetInfo widgetInfo = info.copy(info); widgetInfo.getContent().setShowStr(ShowValueUtils.getCommonString(waterMark, str)); widgetInfo.getContent().setOldShowStr(map.get(objectWaterMarkKey)); @@ -368,7 +374,7 @@ public enum ShowSearchResultAction implements ShowValue { private void searchMap4Formula(Map stringHashMap, List formulaInfos, FormulaInfo info, String str) { if (stringHashMap.containsKey(objectContentKey)) { String name = stringHashMap.get(objectContentKey); - if (name.contains(str)) { + if (ShowValueUtils.contains(name,str)) { info.getContent().setShowStr(ShowValueUtils.getCommonString(name, str)); info.getContent().setOldShowStr(stringHashMap.get(objectContentKey)); info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(name, str)); @@ -411,11 +417,12 @@ public enum ShowSearchResultAction implements ShowValue { /** * 标题是否可用 + * * @param title * @param str * @return */ - public boolean isTitleNameValid(Title title, String str){ - return title != null && ShowValueUtils.contains(GeneralUtils.objectToString(title.getTextObject()),str) && StringUtils.isNotEmpty(GeneralUtils.objectToString(title.getTextObject())); + public boolean isTitleNameValid(Title title, String str) { + return title != null && ShowValueUtils.contains(GeneralUtils.objectToString(title.getTextObject()), str) && StringUtils.isNotEmpty(GeneralUtils.objectToString(title.getTextObject())); } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/cell/SearchCellAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/cell/SearchCellAction.java index 826b247e0..0f2f6d181 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/cell/SearchCellAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/cell/SearchCellAction.java @@ -17,6 +17,7 @@ import com.fr.form.ui.widget.CRBoundsWidget; import com.fr.general.GeneralUtils; import com.fr.main.impl.WorkBook; import com.fr.report.cell.CellElement; +import com.fr.report.cell.cellattr.core.RichText; import com.fr.report.elementcase.ElementCase; import com.fr.report.poly.PolyECBlock; import com.fr.report.report.Report; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/floatelement/SearchFloatAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/floatelement/SearchFloatAction.java index 6f0a338b9..4a478b596 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/floatelement/SearchFloatAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/floatelement/SearchFloatAction.java @@ -7,6 +7,7 @@ import com.fr.design.actions.replace.info.FloatInfo; import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.JTemplate; +import com.fr.general.ImageWithSuffix; import com.fr.main.impl.WorkBook; import com.fr.report.cell.FloatElement; import com.fr.report.elementcase.ElementCase; @@ -84,7 +85,9 @@ public class SearchFloatAction implements SearchAction { if (floatElement.getValue() instanceof ChartCollection) { floatInfo.setChartExist(true); } - result.add(floatInfo); + if (!(floatElement.getValue() instanceof ImageWithSuffix)){ + result.add(floatInfo); + } } } 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 index 720dbab1e..e00283265 100644 --- 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 @@ -133,40 +133,6 @@ public enum FormulaReplaceObject implements DealWithInfoValue { return false; } }, - /** - * 富文本 - */ - RICH_CHAR("RichChar") { - @Override - public Map getValue(Object... o) { - HashMap map = new HashMap<>(); - if (o[0] instanceof RichChar) { - if (StringUtils.isNotEmpty(((RichChar) o[0]).getText())) { - map.put("content", (((RichChar) o[0]).getText())); - } - } - return map; - } - - @Override - public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { - Object replaceObject = info.getContent().getReplaceObject(); - if (replaceObject instanceof RichChar) { - RichChar richChar = (RichChar) replaceObject; - info.updateOldStr(richChar.getText(), findStr); - richChar.setText(ShowValueUtils.replaceAll(richChar.getText(), findStr, replaceStr)); - } - } - - @Override - public boolean check(Info info) { - if (info.getContent().getReplaceObject() instanceof RichChar){ - RichChar richChar = (RichChar) info.getContent().getReplaceObject(); - return StringUtils.equals(richChar.getText(), info.getContent().getOldShowStr()); - } - return false; - } - }, /** * KV */ diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaManager.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaManager.java index eee99bf20..59982245e 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaManager.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaManager.java @@ -25,8 +25,6 @@ public class SearchCellFormulaManager implements SearchManager { register(DS_COLUMN, SearchDSColumnFormulaAction.getInstance()); //公式 register(FORMULA, SearchCellFormulaTypeAction.getInstance()); - //富文本 - register(RICH_TEXT, SearchRichFormulaAction.getInstance()); //子报表 register(SUB_REPORT, SearchSubReportFormulaAction.getInstance()); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/CellInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/CellInfo.java index 94a8f73ce..e5a6ce4fa 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/CellInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/CellInfo.java @@ -219,34 +219,6 @@ public class CellInfo implements Info { return ((DSColumn) o.getValue()).getDSName(); } }, - - /** - * 富文本形式 - * 为了不破坏富文本的格式,暂时不对样式不同的文本进行连接替换,每个样式不同的文本都是一个独立的个体 - */ - RICH_TEXT("RichText") { - @Override - public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) { - cellInfo.updateOldStr(GeneralUtils.objectToString(((RichText) o).getContent()), findStr); - Iterator it = ((RichText) o).charIterator(); - while (it.hasNext()) { - RichChar richChar = it.next(); - richChar.setText(ShowValueUtils.replaceAll(richChar.getText(), findStr, replaceStr)); - } - } - - @Override - public void addValue2Map(Object o, HashMap map) { - map.put("content", ((RichText) o).getContent()); - } - - @Override - public String getCheckValue(Info info) { - CellElement o = (CellElement) info.getContent().getReplaceObject(); - return ((RichText) o.getValue()).getContent(); - } - }, - /** * 公式类型 */ diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java index b7da5fc23..c0d95e707 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java @@ -31,7 +31,7 @@ public class ShowValueUtils { public static final String ENGLISH_REGEX = "[a-zA-Z]"; private static List specialCharList = new ArrayList<>(); static { - //正则特殊字符:? * () [] {} ^ $ + //正则特殊字符:? * () [] {} ^ $ . //如果是? 并采用通配符 ,会自动转成“.” 所以 ? 不用处理 //$同理 specialCharList.add("*"); @@ -42,6 +42,7 @@ public class ShowValueUtils { specialCharList.add("{"); specialCharList.add("}"); specialCharList.add("^"); + specialCharList.add("."); } /** @@ -82,13 +83,13 @@ public class ShowValueUtils { * @return */ public static String changeRegex(String regex) { - regex = regex.replace(NUMBER, NUMBER_REGEX); - regex = regex.replace(ENGLISH, ENGLISH_REGEX); - regex = regex.replace(ANY_THING, ANY_THING_REGEX); String change = "\\"; for (int i = 0 ; i < specialCharList.size() ; i ++){ regex = regex.replace(specialCharList.get(i),change + specialCharList.get(i)); } + regex = regex.replace(NUMBER, NUMBER_REGEX); + regex = regex.replace(ENGLISH, ENGLISH_REGEX); + regex = regex.replace(ANY_THING, ANY_THING_REGEX); return regex; }