|
|
@ -1,6 +1,8 @@ |
|
|
|
package com.fr.design.actions.replace.utils; |
|
|
|
package com.fr.design.actions.replace.utils; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.Formula; |
|
|
|
import com.fr.base.Formula; |
|
|
|
|
|
|
|
import com.fr.base.present.DictPresent; |
|
|
|
|
|
|
|
import com.fr.base.present.Present; |
|
|
|
import com.fr.chart.chartattr.ChartCollection; |
|
|
|
import com.fr.chart.chartattr.ChartCollection; |
|
|
|
import com.fr.chart.web.ChartHyperPoplink; |
|
|
|
import com.fr.chart.web.ChartHyperPoplink; |
|
|
|
import com.fr.data.SimpleDSColumn; |
|
|
|
import com.fr.data.SimpleDSColumn; |
|
|
@ -121,8 +123,18 @@ public class ReplaceUtils { |
|
|
|
* @return 报表块使用的数据集 |
|
|
|
* @return 报表块使用的数据集 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static Set<String> getElementCaseDependenceTables(ElementCaseEditor elementCaseEditor) { |
|
|
|
public static Set<String> getElementCaseDependenceTables(ElementCaseEditor elementCaseEditor) { |
|
|
|
FormElementCaseProvider elementCase = elementCaseEditor.getElementCase(); |
|
|
|
Set<String> ans = new HashSet<>(); |
|
|
|
return elementCase.getCellTableDataSet(); |
|
|
|
FormElementCaseProvider provider = elementCaseEditor.getElementCase(); |
|
|
|
|
|
|
|
if (provider instanceof ElementCase) { |
|
|
|
|
|
|
|
// 非公式部分
|
|
|
|
|
|
|
|
ans.addAll(searchTableDataWithOutFormula((ElementCase)provider)); |
|
|
|
|
|
|
|
// 公式部分——理论上就只有单元格和控件(超链那些都包含)
|
|
|
|
|
|
|
|
List<FormulaInfo> formulaInfos = getElementCaseFormulas((ElementCase) provider); |
|
|
|
|
|
|
|
ans.addAll(searchFormulaInfos(formulaInfos)); |
|
|
|
|
|
|
|
// 超链部分
|
|
|
|
|
|
|
|
ans.addAll(searchElementCasJs((ElementCase)provider)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ans; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -635,5 +647,206 @@ public class ReplaceUtils { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* ------------------------private search----------------------------------- |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Set<String> searchElementCasJs(ElementCase elementCase) { |
|
|
|
|
|
|
|
Set<String> ans = new HashSet<>(); |
|
|
|
|
|
|
|
List<JavaScript> javaScripts = new ArrayList<>(); |
|
|
|
|
|
|
|
// 替换通用元素
|
|
|
|
|
|
|
|
Iterator cellIterator = elementCase.cellIterator(); |
|
|
|
|
|
|
|
while (cellIterator.hasNext()) { |
|
|
|
|
|
|
|
CellElement cell = (CellElement) cellIterator.next(); |
|
|
|
|
|
|
|
javaScripts.addAll(SearchJSUtils.getJSDependenceTables(cell)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ans.addAll(searchJs(javaScripts)); |
|
|
|
|
|
|
|
return ans; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Set<String> searchJs(List<JavaScript> javaScripts) { |
|
|
|
|
|
|
|
Set<String> ans = new HashSet<>(); |
|
|
|
|
|
|
|
for (JavaScript javaScript : javaScripts) { |
|
|
|
|
|
|
|
if (javaScript instanceof ChartHyperPoplink) { |
|
|
|
|
|
|
|
ChartHyperPoplink chartHyperPoplink = (ChartHyperPoplink) javaScript; |
|
|
|
|
|
|
|
if (chartHyperPoplink.getChartCollection() instanceof ChartCollection) { |
|
|
|
|
|
|
|
ans.addAll((chartHyperPoplink.getChartCollection().getDataSetNames())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ans; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Set<String> searchFormulaInfos(List<FormulaInfo> formulaInfos) { |
|
|
|
|
|
|
|
Set<String> ans = new HashSet<>(); |
|
|
|
|
|
|
|
for (FormulaInfo formulaInfo : formulaInfos) { |
|
|
|
|
|
|
|
ans.addAll(TableDataFormulaUtils.search4TableData(formulaInfo.getPureValue())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ans; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Set<String> searchTableDataWithOutFormula(ElementCase elementCase) { |
|
|
|
|
|
|
|
Set<String> ans = new HashSet<>(); |
|
|
|
|
|
|
|
Iterator cellIterator = elementCase.cellIterator(); |
|
|
|
|
|
|
|
while (cellIterator.hasNext()) { |
|
|
|
|
|
|
|
CellElement cell = (CellElement) cellIterator.next(); |
|
|
|
|
|
|
|
// 处理【形态、控件、数据字典】
|
|
|
|
|
|
|
|
ans.addAll(searchPresentAndDictionary(cell)); |
|
|
|
|
|
|
|
// 处理【单元格值】
|
|
|
|
|
|
|
|
ans.addAll(searchCellValue(cell)); |
|
|
|
|
|
|
|
// 处理【条件属性】
|
|
|
|
|
|
|
|
ans.addAll(searchCellHighlight(cell)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ans; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Set<String> searchCellHighlight(CellElement cell) { |
|
|
|
|
|
|
|
Set<String> ans = new HashSet<>(); |
|
|
|
|
|
|
|
if (cell instanceof TemplateCellElement) { |
|
|
|
|
|
|
|
HighlightGroup group = ((TemplateCellElement) cell).getHighlightGroup(); |
|
|
|
|
|
|
|
if (group != null) { |
|
|
|
|
|
|
|
for (int i = 0 ; i < group.size(); i++) { |
|
|
|
|
|
|
|
Highlight highlight = group.getHighlight(i); |
|
|
|
|
|
|
|
ans.addAll(searchHighlight(highlight)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ans; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Set<String> searchHighlight(Highlight highlight) { |
|
|
|
|
|
|
|
Set<String> ans = new HashSet<>(); |
|
|
|
|
|
|
|
if (highlight instanceof DefaultHighlight) { |
|
|
|
|
|
|
|
DefaultHighlight defaultHighlight = (DefaultHighlight) highlight; |
|
|
|
|
|
|
|
for (int i = 0 ; i < defaultHighlight.actionCount() ; i++) { |
|
|
|
|
|
|
|
if (defaultHighlight.getHighlightAction(i) instanceof PresentHighlightAction) { |
|
|
|
|
|
|
|
PresentHighlightAction action = (PresentHighlightAction) defaultHighlight.getHighlightAction(i); |
|
|
|
|
|
|
|
ans.addAll(searchPresent(action.getPresent())); |
|
|
|
|
|
|
|
} else if (defaultHighlight.getHighlightAction(i) instanceof WidgetHighlightAction) { |
|
|
|
|
|
|
|
WidgetHighlightAction action = (WidgetHighlightAction) defaultHighlight.getHighlightAction(i); |
|
|
|
|
|
|
|
ans.addAll(searchWidget(action.getWidget())); |
|
|
|
|
|
|
|
} else if (defaultHighlight.getHighlightAction(i) instanceof HyperlinkHighlightAction) { |
|
|
|
|
|
|
|
HyperlinkHighlightAction action = (HyperlinkHighlightAction) defaultHighlight.getHighlightAction(i); |
|
|
|
|
|
|
|
NameJavaScriptGroup group = action.getHperlink(); |
|
|
|
|
|
|
|
ans.addAll(searchNameJavaScriptGroup(group)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ans; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Set<String> searchNameJavaScriptGroup(NameJavaScriptGroup group) { |
|
|
|
|
|
|
|
Set<String> ans = new HashSet<>(); |
|
|
|
|
|
|
|
if (group != null) { |
|
|
|
|
|
|
|
for (int i = 0 ; i < group.size(); i++) { |
|
|
|
|
|
|
|
NameJavaScript javaScript = group.getNameHyperlink(i); |
|
|
|
|
|
|
|
if (javaScript.getJavaScript() instanceof ChartHyperPoplink) { |
|
|
|
|
|
|
|
if (((ChartHyperPoplink) javaScript.getJavaScript()).getChartCollection() instanceof ChartCollection) { |
|
|
|
|
|
|
|
ans.addAll((((ChartHyperPoplink) javaScript.getJavaScript()).getChartCollection().getDataSetNames())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ans; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Set<String> searchCellValue(CellElement cell) { |
|
|
|
|
|
|
|
Set<String> ans = new HashSet<>(); |
|
|
|
|
|
|
|
Object value = cell.getValue(); |
|
|
|
|
|
|
|
if (value instanceof DSColumn) { |
|
|
|
|
|
|
|
// 查找【数据列】
|
|
|
|
|
|
|
|
ans.add(((DSColumn) value).getDSName()); |
|
|
|
|
|
|
|
// 查找【条件属性】
|
|
|
|
|
|
|
|
ans.addAll(searchCondition(((DSColumn) value).getCondition())); |
|
|
|
|
|
|
|
} else if (value instanceof ChartCollection) { |
|
|
|
|
|
|
|
ans.addAll(((ChartCollection) value).getDataSetNames()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ans; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Set<String> searchCondition(Condition condition) { |
|
|
|
|
|
|
|
Set<String> ans = new HashSet<>(); |
|
|
|
|
|
|
|
if (condition != null) { |
|
|
|
|
|
|
|
//普通条件
|
|
|
|
|
|
|
|
//1条条件
|
|
|
|
|
|
|
|
if (condition instanceof CommonCondition) { |
|
|
|
|
|
|
|
ans.addAll(searchCondition0((CommonCondition) condition)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//N条条件
|
|
|
|
|
|
|
|
if (condition instanceof ListCondition) { |
|
|
|
|
|
|
|
for (int k = 0; k < ((ListCondition) condition).getJoinConditionCount(); k++) { |
|
|
|
|
|
|
|
JoinCondition joinCondition = ((ListCondition) condition).getJoinCondition(k); |
|
|
|
|
|
|
|
Condition obCondition = joinCondition.getCondition(); |
|
|
|
|
|
|
|
if (obCondition instanceof CommonCondition) { |
|
|
|
|
|
|
|
ans.addAll(searchCondition0((CommonCondition) obCondition)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ans; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Set<String> searchCondition0(CommonCondition condition) { |
|
|
|
|
|
|
|
Set<String> ans = new HashSet<>(); |
|
|
|
|
|
|
|
Compare compare = condition.getCompare(); |
|
|
|
|
|
|
|
Object ob = compare.getValue(); |
|
|
|
|
|
|
|
if (ob instanceof SimpleDSColumn) { |
|
|
|
|
|
|
|
ans.add(((SimpleDSColumn) ob).getDsName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ans; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Set<String> searchPresentAndDictionary(CellElement cell) { |
|
|
|
|
|
|
|
Set<String> ans = new HashSet<>(); |
|
|
|
|
|
|
|
TemplateCellElement cellElement = (TemplateCellElement) cell; |
|
|
|
|
|
|
|
// 处理单元格的控件
|
|
|
|
|
|
|
|
ans.addAll(searchWidget(cellElement.getWidget())); |
|
|
|
|
|
|
|
// 处理形态
|
|
|
|
|
|
|
|
ans.addAll(searchPresent(cellElement.getPresent())); |
|
|
|
|
|
|
|
return ans; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Set<String> searchPresent(Present p) { |
|
|
|
|
|
|
|
Set<String> ans = new HashSet<>(); |
|
|
|
|
|
|
|
if (!(p instanceof DictPresent)) { |
|
|
|
|
|
|
|
return ans; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
DictPresent dp = (DictPresent) p; |
|
|
|
|
|
|
|
if (!(dp.getDictionary() instanceof TableDataDictionary)) { |
|
|
|
|
|
|
|
return ans; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
TableDataDictionary td = (TableDataDictionary) dp.getDictionary(); |
|
|
|
|
|
|
|
if (!(td.getTableData() instanceof NameTableData)) { |
|
|
|
|
|
|
|
return ans; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
NameTableData nd = (NameTableData) td.getTableData(); |
|
|
|
|
|
|
|
ans.add(nd.getName()); |
|
|
|
|
|
|
|
return ans; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Set<String> searchWidget(Widget widget) { |
|
|
|
|
|
|
|
Set<String> ans = new HashSet<>(); |
|
|
|
|
|
|
|
if (widget instanceof DictionaryContainer) { |
|
|
|
|
|
|
|
DictionaryContainer db = (DictionaryContainer) widget; |
|
|
|
|
|
|
|
if (db.getDictionary() instanceof TableDataDictionary) { |
|
|
|
|
|
|
|
TableDataDictionary tdd = (TableDataDictionary) db.getDictionary(); |
|
|
|
|
|
|
|
NameTableData ndd = (NameTableData) tdd.getTableData(); |
|
|
|
|
|
|
|
if (ndd != null) { |
|
|
|
|
|
|
|
ans.add(ndd.getName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (widget instanceof DataControl) { |
|
|
|
|
|
|
|
ValueInitializer value = ((DataControl) widget).getWidgetValue(); |
|
|
|
|
|
|
|
if (value != null && value.getValue() instanceof DataBinding) { |
|
|
|
|
|
|
|
DataBinding binding = (DataBinding) value.getValue(); |
|
|
|
|
|
|
|
ans.add(binding.getDataSourceName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ans; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|