Browse Source

REPORT-64075 【主题边框】框选设置主题样式,关闭模板,删除模板主题,重新打开模板边框丢失

【问题原因】
如果将格子四边框的来源标记保存到单元格中,那么会导致实际边框样式
不同单元格使用同一个NameStyle,从而在主题丢失,读取模版XML恢复
自定义样式时,使用相同的NameStyle作为最终样式,从而丢弃各自格子
原本不同的边框样式。

只有将四边框的来源标记保存到NameStyle中,才能避免这个问题,
使用不同标记的NameStyle才持久化时会分别存储.

【改动思路】
1. 删除之前在CellElement中添加的borderSourceFlags相关的接口
2. 将borderSourceFlags转移到NameStyle中
feature/x
Starryi 3 years ago
parent
commit
ba4b28c641
  1. 18
      designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java
  2. 2
      designer-realize/src/main/java/com/fr/design/actions/cell/BorderAction.java
  3. 15
      designer-realize/src/main/java/com/fr/design/style/BorderUtils.java

18
designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java

@ -1,6 +1,6 @@
package com.fr.design.cell; package com.fr.design.cell;
import com.fr.report.cell.CellElementBorderSourceFlag; import com.fr.base.CellBorderSourceFlag;
import com.fr.base.CellBorderStyle; import com.fr.base.CellBorderStyle;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase;
@ -20,6 +20,7 @@ public class CellRectangleStylePreviewPane extends JPanel {
private static final int COLUMN_COUNT = 2; private static final int COLUMN_COUNT = 2;
private final TemplateCellElement[][] cellElementGrid = new TemplateCellElement[ROW_COUNT][COLUMN_COUNT]; private final TemplateCellElement[][] cellElementGrid = new TemplateCellElement[ROW_COUNT][COLUMN_COUNT];
private final int[][] borderSourceFlags = new int[ROW_COUNT][COLUMN_COUNT];
private final CellStylePreviewPane[][] cellStylePreviewPaneGrid = new CellStylePreviewPane[ROW_COUNT][COLUMN_COUNT]; private final CellStylePreviewPane[][] cellStylePreviewPaneGrid = new CellStylePreviewPane[ROW_COUNT][COLUMN_COUNT];
public CellRectangleStylePreviewPane() { public CellRectangleStylePreviewPane() {
@ -29,25 +30,25 @@ public class CellRectangleStylePreviewPane extends JPanel {
for (int c = 0; c < COLUMN_COUNT; c++) { for (int c = 0; c < COLUMN_COUNT; c++) {
CellStylePreviewPane pane = new CellStylePreviewPane(); CellStylePreviewPane pane = new CellStylePreviewPane();
TemplateCellElement cellElement = DefaultThemedTemplateCellElementCase.createInstance(c, r); TemplateCellElement cellElement = DefaultThemedTemplateCellElementCase.createInstance(c, r);
int flags = CellElementBorderSourceFlag.ALL_BORDER_SOURCE_OUTER; int flags = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (r != 0) { if (r != 0) {
flags |= CellElementBorderSourceFlag.TOP_BORDER_SOURCE_INNER; flags |= CellBorderSourceFlag.TOP_BORDER_SOURCE_INNER;
} }
if (r != ROW_COUNT - 1) { if (r != ROW_COUNT - 1) {
flags |= CellElementBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER; flags |= CellBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER;
} }
if (c != 0) { if (c != 0) {
flags |= CellElementBorderSourceFlag.LEFT_BORDER_SOURCE_INNER; flags |= CellBorderSourceFlag.LEFT_BORDER_SOURCE_INNER;
} }
if (c != COLUMN_COUNT - 1) { if (c != COLUMN_COUNT - 1) {
flags |= CellElementBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER; flags |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER;
} }
cellElement.setBorderSourceFlags(flags);
pane.setStyle(cellElement.getStyle()); pane.setStyle(cellElement.getStyle());
add(pane); add(pane);
cellElementGrid[r][c] = cellElement; cellElementGrid[r][c] = cellElement;
borderSourceFlags[r][c] = flags;
cellStylePreviewPaneGrid[r][c] = pane; cellStylePreviewPaneGrid[r][c] = pane;
} }
} }
@ -64,7 +65,8 @@ public class CellRectangleStylePreviewPane extends JPanel {
for (int j = 0; j < COLUMN_COUNT; j++) { for (int j = 0; j < COLUMN_COUNT; j++) {
CellStylePreviewPane pane = cellStylePreviewPaneGrid[i][j]; CellStylePreviewPane pane = cellStylePreviewPaneGrid[i][j];
TemplateCellElement cellElement = cellElementGrid[i][j]; TemplateCellElement cellElement = cellElementGrid[i][j];
cellElement.setStyle(style, borderStyle); int flag = borderSourceFlags[i][j];
cellElement.setStyle(CellBorderSourceFlag.deriveBorderedStyle(style, borderStyle, flag));
pane.setStyle(cellElement.getStyle()); pane.setStyle(cellElement.getStyle());
} }

2
designer-realize/src/main/java/com/fr/design/actions/cell/BorderAction.java

@ -14,7 +14,6 @@ import com.fr.design.style.BorderUtils;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.FloatSelection;
import com.fr.grid.selection.Selection; import com.fr.grid.selection.Selection;
import com.fr.report.cell.CellElementBorderSourceFlag;
import com.fr.report.cell.FloatElement; import com.fr.report.cell.FloatElement;
import com.fr.report.cell.StyleProvider; import com.fr.report.cell.StyleProvider;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
@ -102,7 +101,6 @@ public class BorderAction extends ElementCaseAction implements ChangeListener {
TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row);
if (cellElement != null) { if (cellElement != null) {
resetElementStyleToCustom(cellElement); resetElementStyleToCustom(cellElement);
cellElement.setBorderSourceFlags(CellElementBorderSourceFlag.INVALID_BORDER_SOURCE);
}; };
} }
} }

15
designer-realize/src/main/java/com/fr/design/style/BorderUtils.java

@ -6,7 +6,7 @@ import java.util.ArrayList;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.List; import java.util.List;
import com.fr.report.cell.CellElementBorderSourceFlag; import com.fr.base.CellBorderSourceFlag;
import com.fr.base.CellBorderStyle; import com.fr.base.CellBorderStyle;
import com.fr.base.NameStyle; import com.fr.base.NameStyle;
import com.fr.base.Style; import com.fr.base.Style;
@ -527,15 +527,20 @@ public abstract class BorderUtils {
int cellColumnSpan = tmpCellElement.getColumnSpan(); int cellColumnSpan = tmpCellElement.getColumnSpan();
int cellRow = tmpCellElement.getRow(); int cellRow = tmpCellElement.getRow();
int cellRowSpan = tmpCellElement.getRowSpan(); int cellRowSpan = tmpCellElement.getRowSpan();
int borderSourceFlags = CellElementBorderSourceFlag.inspectBorderSourceFlag( int borderSourceFlags = CellBorderSourceFlag.inspectBorderSourceFlag(
column, row, column + columnSpan, row + rowSpan, column, row, column + columnSpan, row + rowSpan,
cellColumn, cellRow, cellColumn + cellColumnSpan, cellRow + cellRowSpan cellColumn, cellRow, cellColumn + cellColumnSpan, cellRow + cellRowSpan
); );
tmpCellElement.setBorderSourceFlags(borderSourceFlags);
if (style instanceof NameStyle && !ThemedFeatureController.isCellStyleSupportInnerBorder()) { if (style instanceof NameStyle && !ThemedFeatureController.isCellStyleSupportInnerBorder()) {
tmpCellElement.setBorderSourceFlags(CellElementBorderSourceFlag.INVALID_BORDER_SOURCE); borderSourceFlags = CellBorderSourceFlag.INVALID_BORDER_SOURCE;
} }
tmpCellElement.setStyle(style, newCellBorderStyle); if (style instanceof NameStyle) {
((NameStyle) style).refreshPassiveBorderStyle(newCellBorderStyle, borderSourceFlags);
} else {
style = CellBorderSourceFlag.deriveBorderedStyle(style, newCellBorderStyle, borderSourceFlags);
}
tmpCellElement.setStyle(style);
} }
} }
} }

Loading…
Cancel
Save