diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java index 6d7aa5d9ff..896cbe37c5 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java @@ -780,6 +780,17 @@ public class XWFitLayout extends XLayoutContainer { tabLayout.updateBoundsWidget(); } } + } + layout.setContainerHeight(containerHeight); + layout.setContainerWidth(containerWidth); + addCompInterval(getAcualInterval()); + + // REPORT-54410: 决策报表,模板中其他组件的宽高修改会影响绝对画布块中组件的宽高和位置 + // 绝对布局内的组件尺寸调整需要在绝对布局的bound排除GAP后进行,否则计算出的 + // 组件尺寸缩放比例会有问题 + for (int index = 0, n = this.getComponentCount(); index < n; index++) { + XCreator creator = (XCreator) this.getComponent(index); + BoundsWidget wgt = (BoundsWidget) layout.getBoundsWidget(creator.toData()); //如果子组件是绝对布局,则内部的widget也要更新 if (creator.acceptType(XWAbsoluteLayout.class)){ //更新的时候一定要带上backupBound @@ -790,9 +801,6 @@ public class XWFitLayout extends XLayoutContainer { creator.setBackupBound(creator.getBounds()); } } - layout.setContainerHeight(containerHeight); - layout.setContainerWidth(containerWidth); - addCompInterval(getAcualInterval()); } private Rectangle recalculateWidgetBounds(Rectangle rec, int[] hors, int[] veris) { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index 0f1ced3797..d43926e6a5 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -1019,6 +1019,9 @@ public class JWorkBook extends JTemplate { // EastRegionContainerPane.getInstance().replaceDownPane(new JPanel()); QuickEditorRegion.getInstance().populate(QuickEditor.DEFAULT_EDITOR); } else { + if (polyDesigner.getSelectionType() == PolyDesigner.SelectionType.INNER) { + EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT); + } EastRegionContainerPane.getInstance().replaceDownPane(CellElementPropertyPane.getInstance()); } EastRegionContainerPane.getInstance().replaceUpPane(QuickEditorRegion.getInstance()); diff --git a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java index b6dc8bc4ad..0ae21bf4d5 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java +++ b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java @@ -501,54 +501,59 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous private void doWithCellElementDragged(int evtX, int evtY, CellSelection cs) { ElementCasePane reportPane = grid.getElementCasePane(); - java.awt.Rectangle cellRectangle = cs.toRectangle(); + java.awt.Rectangle startRec = cs.toRectangle(); - ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(reportPane, evtX, evtY, resolution); - if (cellRectangle.contains(selectedCellPoint.getColumn(), selectedCellPoint.getRow())) { - grid.getDragRectangle().setBounds(cellRectangle); + ColumnRow currentMouseCell = GridUtils.getAdjustEventColumnRow_withresolution(reportPane, evtX, evtY, resolution); + if (isOutECBlockPane(evtX, evtY)) { + return; + } + int xDistance = evtX - this.oldEvtX; + int yDistance = evtY - this.oldEvtY; + boolean isHorizontal = isHorizontal(xDistance, yDistance); + Rectangle endRec = calculateEndRec(currentMouseCell, startRec, isHorizontal); + grid.getDragRectangle().setBounds(calculateDragRectangle(startRec, endRec)); + + reportPane.ensureColumnRowVisible(currentMouseCell.getColumn() + 1, currentMouseCell.getRow() + 1); + } + + private boolean isHorizontal(int xDistance, int yDistance) { + return Math.abs(yDistance) <= Math.abs(xDistance); + } + + /** + * 计算拖拽的结尾矩形 + * @param currentMouseCell 当前鼠标所在的格子 + * @param startRec 起始格子 + * @param isHorizontal 拖拽方向 水平or垂直 + * @return 计算拖拽的结尾矩形 + */ + private Rectangle calculateEndRec(ColumnRow currentMouseCell, Rectangle startRec, boolean isHorizontal) { + if (isHorizontal) { + return new Rectangle(currentMouseCell.column, startRec.y, 1, 1); } else { - int xDistance = evtX - this.oldEvtX; - int yDistance = evtY - this.oldEvtY; - if (Math.abs(yDistance) > Math.abs(xDistance)) { - grid.getDragRectangle().x = cellRectangle.x; - grid.getDragRectangle().width = cellRectangle.width; - if (yDistance >= 0) { - // 聚合报表要求拖拽的时候要在本块的内部进行 不能无限往下拖 - if (reportPane instanceof ECBlockPane && evtY > reportPane.getBounds().height - ECBlockGap) { - return; - } - grid.getDragRectangle().y = cellRectangle.y; - grid.getDragRectangle().height = selectedCellPoint.getRow() - cellRectangle.y + 1; - } else { - if (selectedCellPoint.getRow() >= cellRectangle.y && selectedCellPoint.getRow() < cellRectangle.y + cellRectangle.height) { - grid.getDragRectangle().y = cellRectangle.y; - grid.getDragRectangle().height = cellRectangle.height; - } else { - grid.getDragRectangle().y = cellRectangle.y; - grid.getDragRectangle().height = cellRectangle.y - selectedCellPoint.getRow() + cellRectangle.height; - } - } - } else { - grid.getDragRectangle().y = cellRectangle.y; - grid.getDragRectangle().height = cellRectangle.height; - if (xDistance >= 0) { - if (reportPane instanceof ECBlockPane && evtX > reportPane.getBounds().width - ECBlockGap) { - return; - } - grid.getDragRectangle().x = cellRectangle.x; - grid.getDragRectangle().width = selectedCellPoint.getColumn() - cellRectangle.x + 1; - } else { - if (selectedCellPoint.getColumn() >= cellRectangle.x && selectedCellPoint.getColumn() < cellRectangle.x + cellRectangle.width) { - grid.getDragRectangle().x = cellRectangle.x; - grid.getDragRectangle().width = cellRectangle.width; - } else { - grid.getDragRectangle().x = selectedCellPoint.getColumn(); - grid.getDragRectangle().width = cellRectangle.x - selectedCellPoint.getColumn() + cellRectangle.width; - } - } - } + return new Rectangle(startRec.x, currentMouseCell.row, 1, 1); } - reportPane.ensureColumnRowVisible(selectedCellPoint.getColumn() + 1, selectedCellPoint.getRow() + 1); + } + + /** + * 计算拖拽的边框,传俩矩形确认出一个大矩形,就是所要的结果 + * @param startRec 起始格子矩形 + * @param endRec 结尾格子矩形 + * @return 拖拽的边框 + */ + private Rectangle calculateDragRectangle(Rectangle startRec, Rectangle endRec) { + Rectangle rectangle = new Rectangle(); + int x = Math.min(startRec.x, endRec.x); + int y = Math.min(startRec.y, endRec.y); + int rightBottomX = Math.max(startRec.x + startRec.width, endRec.x + endRec.width); + int rightBottomY = Math.max(startRec.y + startRec.height, endRec.y + endRec.height); + rectangle.setBounds(x, y, rightBottomX - x, rightBottomY - y); + return rectangle; + } + + private boolean isOutECBlockPane(int evtX, int evtY) { + ElementCasePane reportPane = grid.getElementCasePane(); + return reportPane instanceof ECBlockPane && ((evtY > reportPane.getBounds().height - ECBlockGap) || (evtX > reportPane.getBounds().width - ECBlockGap)); } private void doShiftSelectCell(double evtX, double evtY) { diff --git a/designer-realize/src/main/java/com/fr/grid/IntelliElements.java b/designer-realize/src/main/java/com/fr/grid/IntelliElements.java index ca1ed55d8a..e53e8b9522 100644 --- a/designer-realize/src/main/java/com/fr/grid/IntelliElements.java +++ b/designer-realize/src/main/java/com/fr/grid/IntelliElements.java @@ -183,42 +183,40 @@ public class IntelliElements { } - public void doIntelliAction() { - for (int colIndex = getStartColumnIndex(), colEnd = getEndColumnIndex(); colIndex < colEnd; colIndex++) { - for (int rowIndex = getStartRowIndex(), rowEnd = getEndRowIndex(); rowIndex < rowEnd; rowIndex++) { - TemplateCellElement sourceCellElement = getSourceCellElementByColumnRow(colIndex, rowIndex); + public abstract void doIntelliAction(); - if (sourceCellElement == null) { - sourceCellElement = new DefaultTemplateCellElement(); - } - TemplateCellElement newCellElement = new DefaultTemplateCellElement(colIndex, rowIndex); - applyStyle(newCellElement, sourceCellElement);//style - if (sourceCellElement.getValue() instanceof DSColumn) { - try{ - DSColumn dsColumn = (DSColumn)((DSColumn) sourceCellElement.getValue()).clone(); - newCellElement.setValue(dsColumn); - }catch (CloneNotSupportedException e){ - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - newCellElement.setCellExpandAttr(sourceCellElement.getCellExpandAttr()); - } else if (sourceCellElement.getValue() instanceof Number) { - newCellElement.setValue(processNumber((Number) sourceCellElement.getValue())); - } else if (sourceCellElement.getValue() instanceof BaseFormula) { - BaseFormula formula = (BaseFormula) sourceCellElement.getValue(); - formula = this.generateSimpleFormula(formula, 1); - newCellElement.setValue(formula); - } else { - try { - //richer:不改变原单元格 - newCellElement.setValue(BaseUtils.cloneObject(sourceCellElement.getValue())); - } catch (CloneNotSupportedException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } + public void expandCellValue(int colIndex, int rowIndex) { + TemplateCellElement sourceCellElement = getSourceCellElementByColumnRow(colIndex, rowIndex); - report.addCellElement(newCellElement); + if (sourceCellElement == null) { + sourceCellElement = new DefaultTemplateCellElement(); + } + TemplateCellElement newCellElement = new DefaultTemplateCellElement(colIndex, rowIndex); + applyStyle(newCellElement, sourceCellElement);//style + if (sourceCellElement.getValue() instanceof DSColumn) { + try{ + DSColumn dsColumn = (DSColumn)((DSColumn) sourceCellElement.getValue()).clone(); + newCellElement.setValue(dsColumn); + }catch (CloneNotSupportedException e){ + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + newCellElement.setCellExpandAttr(sourceCellElement.getCellExpandAttr()); + } else if (sourceCellElement.getValue() instanceof Number) { + newCellElement.setValue(processNumber((Number) sourceCellElement.getValue())); + } else if (sourceCellElement.getValue() instanceof BaseFormula) { + BaseFormula formula = (BaseFormula) sourceCellElement.getValue(); + formula = this.generateSimpleFormula(formula, 1); + newCellElement.setValue(formula); + } else { + try { + //richer:不改变原单元格 + newCellElement.setValue(BaseUtils.cloneObject(sourceCellElement.getValue())); + } catch (CloneNotSupportedException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } + + report.addCellElement(newCellElement); } protected abstract int getStartColumnIndex(); @@ -328,6 +326,15 @@ public class IntelliElements { }; } + @Override + public void doIntelliAction() { + for (int colIndex = getStartColumnIndex(), colEnd = getEndColumnIndex(); colIndex < colEnd; colIndex ++) { + for (int rowIndex = getStartRowIndex(), rowEnd = getEndRowIndex(); rowIndex < rowEnd; rowIndex ++) { + expandCellValue(colIndex, rowIndex); + } + } + } + @Override public boolean havetoModify() { return IntelliElements.this.dragCellRectangle.width > IntelliElements.this.oldCellRectangle.width; @@ -397,39 +404,48 @@ public class IntelliElements { }; } + @Override + public void doIntelliAction() { + for (int colIndex = getStartColumnIndex(), colEnd = getEndColumnIndex(); colIndex > colEnd; colIndex --) { + for (int rowIndex = getStartRowIndex(), rowEnd = getEndRowIndex(); rowIndex < rowEnd; rowIndex ++) { + expandCellValue(colIndex, rowIndex); + } + } + } + @Override public boolean havetoModify() { return true; } @Override - public int getStartRowIndex() { + public int getStartRowIndex() { return IntelliElements.this.oldCellRectangle.y; } @Override - public int getEndRowIndex() { + public int getEndRowIndex() { return IntelliElements.this.oldCellRectangle.y + IntelliElements.this.oldCellRectangle.height; } @Override - public int getStartColumnIndex() { - return IntelliElements.this.dragCellRectangle.x; + public int getStartColumnIndex() { + return IntelliElements.this.oldCellRectangle.x - 1; } @Override - public int getEndColumnIndex() { - return IntelliElements.this.oldCellRectangle.x; + public int getEndColumnIndex() { + return IntelliElements.this.dragCellRectangle.x - 1; } @Override public TemplateCellElement getSourceCellElementByColumnRow(int columnIndex, int rowIndex) { - return report.getTemplateCellElement(IntelliElements.this.oldCellRectangle.x + (columnIndex - IntelliElements.this.dragCellRectangle.x) % (IntelliElements.this.oldCellRectangle.width), rowIndex); + return report.getTemplateCellElement(columnIndex + IntelliElements.this.oldCellRectangle.width, rowIndex); } @Override protected Number processNumber(Number i) { - return i; + return FunctionHelper.asNumber(i.doubleValue() - 1); } @Override @@ -465,6 +481,15 @@ public class IntelliElements { }; } + @Override + public void doIntelliAction() { + for (int colIndex = getStartColumnIndex(), colEnd = getEndColumnIndex(); colIndex < colEnd; colIndex ++) { + for (int rowIndex = getStartRowIndex(), rowEnd = getEndRowIndex(); rowIndex < rowEnd; rowIndex ++) { + expandCellValue(colIndex, rowIndex); + } + } + } + @Override public boolean havetoModify() { return IntelliElements.this.dragCellRectangle.height > IntelliElements.this.oldCellRectangle.height; @@ -534,38 +559,47 @@ public class IntelliElements { } @Override - public boolean havetoModify() { + public void doIntelliAction() { + for (int colIndex = getStartColumnIndex(), colEnd = getEndColumnIndex(); colIndex < colEnd; colIndex++) { + for (int rowIndex = getStartRowIndex(), rowEnd = getEndRowIndex(); rowIndex > rowEnd; rowIndex--) { + expandCellValue(colIndex, rowIndex); + } + } + } + + @Override + public boolean havetoModify() { return true; } @Override - public int getStartRowIndex() { - return IntelliElements.this.dragCellRectangle.y; + public int getStartRowIndex() { + return IntelliElements.this.oldCellRectangle.y - 1; } @Override - public int getEndRowIndex() { - return IntelliElements.this.oldCellRectangle.y; + public int getEndRowIndex() { + return IntelliElements.this.dragCellRectangle.y - 1; } @Override - public int getStartColumnIndex() { + public int getStartColumnIndex() { return IntelliElements.this.oldCellRectangle.x; } @Override - public int getEndColumnIndex() { + public int getEndColumnIndex() { return IntelliElements.this.oldCellRectangle.x + IntelliElements.this.oldCellRectangle.width; } @Override public TemplateCellElement getSourceCellElementByColumnRow(int columnIndex, int rowIndex) { - return report.getTemplateCellElement(columnIndex, IntelliElements.this.oldCellRectangle.y + (rowIndex - IntelliElements.this.dragCellRectangle.y) % (IntelliElements.this.oldCellRectangle.height)); + return report.getTemplateCellElement(columnIndex, rowIndex + IntelliElements.this.oldCellRectangle.height); } @Override protected Number processNumber(Number i) { - return i; + return FunctionHelper.asNumber(i.doubleValue() - 1); } @Override