Browse Source

REPORT-75998 删除富文本逻辑、完善通配符、增加悬浮元素图片判断

feature/x
Destiny.Lin 2 years ago
parent
commit
7f835f9f8f
  1. 2
      designer-realize/src/main/java/com/fr/design/actions/replace/action/SearchManagerCenter.java
  2. 31
      designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java
  3. 1
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/cell/SearchCellAction.java
  4. 5
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/floatelement/SearchFloatAction.java
  5. 34
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java
  6. 2
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaManager.java
  7. 28
      designer-realize/src/main/java/com/fr/design/actions/replace/info/CellInfo.java
  8. 9
      designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java

2
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 { public enum ManagerType implements SearchManager {
/** /**
* 注册单元格不同值类型中自己特有的公式数据列子报表公式富文本可自己添加 * 注册单元格不同值类型中自己特有的公式数据列子报表公式可自己添加
*/ */
CELL_FORMULA(0) { CELL_FORMULA(0) {
@Override @Override

31
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.general.GeneralUtils;
import com.fr.report.cell.CellElement; import com.fr.report.cell.CellElement;
import com.fr.report.cell.FloatElement; import com.fr.report.cell.FloatElement;
import com.fr.report.cell.cellattr.core.RichText;
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;
@ -75,7 +76,7 @@ public enum ShowSearchResultAction implements ShowValue {
} else { } else {
Map<String, String> stringHashMap = info.getValue(); Map<String, String> stringHashMap = info.getValue();
String content = stringHashMap.getOrDefault(objectContentKey, StringUtils.EMPTY); 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().setShowStr(ShowValueUtils.getCommonString(content, str));
info.getContent().setOldShowStr(content); info.getContent().setOldShowStr(content);
info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str));
@ -94,6 +95,11 @@ public enum ShowSearchResultAction implements ShowValue {
cellInfo.getContent().setSelected(true); 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事件 * 搜索JS事件
@ -139,7 +145,7 @@ public enum ShowSearchResultAction implements ShowValue {
private void searchMap4JS(Map<String, String> map, List<JSInfo> jsInfos, JSInfo info, String str) { private void searchMap4JS(Map<String, String> map, List<JSInfo> jsInfos, JSInfo info, String str) {
if (map.containsKey(objectNameKey) && StringUtils.isNotEmpty(map.get(objectNameKey))) { if (map.containsKey(objectNameKey) && StringUtils.isNotEmpty(map.get(objectNameKey))) {
String name = map.get(objectNameKey); String name = map.get(objectNameKey);
if (name.contains(str)) { if (ShowValueUtils.contains(name,str)) {
JSInfo nameJSInfo = info.copy(); JSInfo nameJSInfo = info.copy();
nameJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(name, str)); nameJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(name, str));
nameJSInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(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))) { if (map.containsKey(objectContentKey) && StringUtils.isNotEmpty(map.get(objectContentKey))) {
String content = map.get(objectContentKey); String content = map.get(objectContentKey);
if (content.contains(str)) { if (ShowValueUtils.contains(content,str)) {
JSInfo contentJSInfo = info.copy(); JSInfo contentJSInfo = info.copy();
contentJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(content, str)); contentJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(content, str));
contentJSInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); contentJSInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str));
@ -195,7 +201,7 @@ public enum ShowSearchResultAction implements ShowValue {
private void searchMap4SQLContent(Map<String, String> map, List<SQLInfo> sqlInfos, SQLInfo info, String str) { private void searchMap4SQLContent(Map<String, String> map, List<SQLInfo> sqlInfos, SQLInfo info, String str) {
if (map.containsKey(objectContentKey) && StringUtils.isNotEmpty(map.get(objectContentKey))) { if (map.containsKey(objectContentKey) && StringUtils.isNotEmpty(map.get(objectContentKey))) {
String content = map.get(objectContentKey); String content = map.get(objectContentKey);
if (content.contains(str)) { if (ShowValueUtils.contains(content,str)) {
SQLInfo contentJSInfo = info.copy(); SQLInfo contentJSInfo = info.copy();
contentJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(content, str)); contentJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(content, str));
contentJSInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); contentJSInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str));
@ -231,7 +237,7 @@ public enum ShowSearchResultAction implements ShowValue {
if (((FloatInfo) info).isChartExist()) { if (((FloatInfo) info).isChartExist()) {
ChartCollection chartCollection = (ChartCollection) floatElement.getValue(); ChartCollection chartCollection = (ChartCollection) floatElement.getValue();
for (int i = 0; i < chartCollection.getChartCount(); i++) { 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()); String titleName = GeneralUtils.objectToString(chartCollection.getChart(i).getTitle().getTextObject());
FloatInfo floatInfo = ((FloatInfo) info).copy(); FloatInfo floatInfo = ((FloatInfo) info).copy();
floatInfo.setFloatChartIndex(i); floatInfo.setFloatChartIndex(i);
@ -244,7 +250,7 @@ public enum ShowSearchResultAction implements ShowValue {
} }
} }
} else { } else {
if (GeneralUtils.objectToString(floatElement.getValue()).contains(str)) { if (ShowValueUtils.contains(GeneralUtils.objectToString(floatElement.getValue()), str)) {
FloatInfo floatInfo = ((FloatInfo) info).copy(); FloatInfo floatInfo = ((FloatInfo) info).copy();
setShowInfo(floatInfo, GeneralUtils.objectToString(floatElement.getValue()), str); setShowInfo(floatInfo, GeneralUtils.objectToString(floatElement.getValue()), str);
floatInfos.add(floatInfo); floatInfos.add(floatInfo);
@ -285,7 +291,7 @@ public enum ShowSearchResultAction implements ShowValue {
private void searchMap4Component(Map<String, String> stringHashMap, ArrayList<ComponentInfo> componentInfos, ComponentInfo info, String str) { private void searchMap4Component(Map<String, String> stringHashMap, ArrayList<ComponentInfo> componentInfos, ComponentInfo info, String str) {
if (stringHashMap.containsKey(objectContentKey)) { if (stringHashMap.containsKey(objectContentKey)) {
String content = stringHashMap.get(objectContentKey); String content = stringHashMap.get(objectContentKey);
if (content.contains(str)) { if (ShowValueUtils.contains(content,str)) {
info.getContent().setShowStr(ShowValueUtils.getCommonString(content, str)); info.getContent().setShowStr(ShowValueUtils.getCommonString(content, str));
info.getContent().setOldShowStr(stringHashMap.get(objectContentKey)); info.getContent().setOldShowStr(stringHashMap.get(objectContentKey));
info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str));
@ -319,7 +325,7 @@ public enum ShowSearchResultAction implements ShowValue {
private void searchMap4Widget(Map<String, String> map, List<WidgetInfo> widgetInfos, WidgetInfo info, String str) { private void searchMap4Widget(Map<String, String> map, List<WidgetInfo> widgetInfos, WidgetInfo info, String str) {
if (map.containsKey(objectNameKey)) { if (map.containsKey(objectNameKey)) {
String name = map.get(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); WidgetInfo nameInfo = info.copy(info);
nameInfo.getContent().setShowStr(ShowValueUtils.getCommonString(name, str)); nameInfo.getContent().setShowStr(ShowValueUtils.getCommonString(name, str));
nameInfo.getContent().setOldShowStr(map.get(objectNameKey)); nameInfo.getContent().setOldShowStr(map.get(objectNameKey));
@ -331,7 +337,7 @@ public enum ShowSearchResultAction implements ShowValue {
} }
if (map.containsKey(objectWaterMarkKey)) { if (map.containsKey(objectWaterMarkKey)) {
String waterMark = map.get(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 widgetInfo = info.copy(info);
widgetInfo.getContent().setShowStr(ShowValueUtils.getCommonString(waterMark, str)); widgetInfo.getContent().setShowStr(ShowValueUtils.getCommonString(waterMark, str));
widgetInfo.getContent().setOldShowStr(map.get(objectWaterMarkKey)); widgetInfo.getContent().setOldShowStr(map.get(objectWaterMarkKey));
@ -368,7 +374,7 @@ public enum ShowSearchResultAction implements ShowValue {
private void searchMap4Formula(Map<String, String> stringHashMap, List<FormulaInfo> formulaInfos, FormulaInfo info, String str) { private void searchMap4Formula(Map<String, String> stringHashMap, List<FormulaInfo> formulaInfos, FormulaInfo info, String str) {
if (stringHashMap.containsKey(objectContentKey)) { if (stringHashMap.containsKey(objectContentKey)) {
String name = stringHashMap.get(objectContentKey); String name = stringHashMap.get(objectContentKey);
if (name.contains(str)) { if (ShowValueUtils.contains(name,str)) {
info.getContent().setShowStr(ShowValueUtils.getCommonString(name, str)); info.getContent().setShowStr(ShowValueUtils.getCommonString(name, str));
info.getContent().setOldShowStr(stringHashMap.get(objectContentKey)); info.getContent().setOldShowStr(stringHashMap.get(objectContentKey));
info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(name, str)); info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(name, str));
@ -411,11 +417,12 @@ public enum ShowSearchResultAction implements ShowValue {
/** /**
* 标题是否可用 * 标题是否可用
*
* @param title * @param title
* @param str * @param str
* @return * @return
*/ */
public boolean isTitleNameValid(Title title, String str){ public boolean isTitleNameValid(Title title, String str) {
return title != null && ShowValueUtils.contains(GeneralUtils.objectToString(title.getTextObject()),str) && StringUtils.isNotEmpty(GeneralUtils.objectToString(title.getTextObject())); return title != null && ShowValueUtils.contains(GeneralUtils.objectToString(title.getTextObject()), str) && StringUtils.isNotEmpty(GeneralUtils.objectToString(title.getTextObject()));
} }
} }

1
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.general.GeneralUtils;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.report.cell.CellElement; import com.fr.report.cell.CellElement;
import com.fr.report.cell.cellattr.core.RichText;
import com.fr.report.elementcase.ElementCase; import com.fr.report.elementcase.ElementCase;
import com.fr.report.poly.PolyECBlock; import com.fr.report.poly.PolyECBlock;
import com.fr.report.report.Report; import com.fr.report.report.Report;

5
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.actions.replace.info.base.ITContent;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.general.ImageWithSuffix;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.report.cell.FloatElement; import com.fr.report.cell.FloatElement;
import com.fr.report.elementcase.ElementCase; import com.fr.report.elementcase.ElementCase;
@ -84,7 +85,9 @@ public class SearchFloatAction implements SearchAction {
if (floatElement.getValue() instanceof ChartCollection) { if (floatElement.getValue() instanceof ChartCollection) {
floatInfo.setChartExist(true); floatInfo.setChartExist(true);
} }
result.add(floatInfo); if (!(floatElement.getValue() instanceof ImageWithSuffix)){
result.add(floatInfo);
}
} }
} }

34
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; return false;
} }
}, },
/**
* 富文本
*/
RICH_CHAR("RichChar") {
@Override
public Map<String, String> getValue(Object... o) {
HashMap<String, String> 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<Pair<Integer, Integer>> 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 * KV
*/ */

2
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(DS_COLUMN, SearchDSColumnFormulaAction.getInstance());
//公式 //公式
register(FORMULA, SearchCellFormulaTypeAction.getInstance()); register(FORMULA, SearchCellFormulaTypeAction.getInstance());
//富文本
register(RICH_TEXT, SearchRichFormulaAction.getInstance());
//子报表 //子报表
register(SUB_REPORT, SearchSubReportFormulaAction.getInstance()); register(SUB_REPORT, SearchSubReportFormulaAction.getInstance());

28
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(); 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<RichChar> 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<String, String> map) {
map.put("content", ((RichText) o).getContent());
}
@Override
public String getCheckValue(Info info) {
CellElement o = (CellElement) info.getContent().getReplaceObject();
return ((RichText) o.getValue()).getContent();
}
},
/** /**
* 公式类型 * 公式类型
*/ */

9
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]"; public static final String ENGLISH_REGEX = "[a-zA-Z]";
private static List<String> specialCharList = new ArrayList<>(); private static List<String> specialCharList = new ArrayList<>();
static { static {
//正则特殊字符:? * () [] {} ^ $ //正则特殊字符:? * () [] {} ^ $ .
//如果是? 并采用通配符 ,会自动转成“.” 所以 ? 不用处理 //如果是? 并采用通配符 ,会自动转成“.” 所以 ? 不用处理
//$同理 //$同理
specialCharList.add("*"); specialCharList.add("*");
@ -42,6 +42,7 @@ public class ShowValueUtils {
specialCharList.add("{"); specialCharList.add("{");
specialCharList.add("}"); specialCharList.add("}");
specialCharList.add("^"); specialCharList.add("^");
specialCharList.add(".");
} }
/** /**
@ -82,13 +83,13 @@ public class ShowValueUtils {
* @return * @return
*/ */
public static String changeRegex(String regex) { 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 = "\\"; String change = "\\";
for (int i = 0 ; i < specialCharList.size() ; i ++){ for (int i = 0 ; i < specialCharList.size() ; i ++){
regex = regex.replace(specialCharList.get(i),change + specialCharList.get(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; return regex;
} }

Loading…
Cancel
Save