Browse Source

Merge pull request #553 in BA/design from ~KERRY/design:dev to dev

* commit '6a99e92200bfe44b17ed5a9c95abb574ca8bc11c':
  REPORT-747 之前没考虑不同模板之间复制
master
superman 8 years ago
parent
commit
9b6a9e7eb5
  1. 27
      designer/src/com/fr/design/cell/clipboard/CellElementsClip.java
  2. 2
      designer/src/com/fr/grid/GridUtils.java
  3. 12
      designer/src/com/fr/grid/selection/CellSelection.java

27
designer/src/com/fr/design/cell/clipboard/CellElementsClip.java

@ -12,24 +12,29 @@ import com.fr.report.cell.CellElement;
import com.fr.report.cell.CellElementComparator; import com.fr.report.cell.CellElementComparator;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.unit.FU;
/** /**
* The clip of CellElement. * The clip of CellElement.
*/ */
public class CellElementsClip implements Cloneable, java.io.Serializable { public class CellElementsClip implements Cloneable, java.io.Serializable {
private int column;
private int row;
private int columnSpan = 0; private int columnSpan = 0;
private int rowSpan = 0; private int rowSpan = 0;
private FU[] columnWidth;
private FU[] rowHeight;
private TemplateCellElement[] clips; private TemplateCellElement[] clips;
public CellElementsClip(int column, int row, int columnSpan, int rowSpan, TemplateCellElement[] clips) { public CellElementsClip(int columnSpan, int rowSpan, FU[] columnWidth , FU[] rowHeight, TemplateCellElement[] clips) {
this.column = column;
this.row = row;
this.columnSpan = columnSpan; this.columnSpan = columnSpan;
this.rowSpan = rowSpan; this.rowSpan = rowSpan;
this.columnWidth = columnWidth ;
this.rowHeight = rowHeight;
this.clips = clips;
}
public CellElementsClip(int columnSpan, int rowSpan, TemplateCellElement[] clips) {
this.columnSpan = columnSpan;
this.rowSpan = rowSpan;
this.clips = clips; this.clips = clips;
} }
@ -86,16 +91,18 @@ public class CellElementsClip implements Cloneable, java.io.Serializable {
), false); ), false);
} }
//设置单元格的宽高 //设置单元格的宽高
if(this.columnWidth != null && this.rowHeight != null){
pasteWidthAndHeight(ec, column, row, columnSpan, rowSpan); pasteWidthAndHeight(ec, column, row, columnSpan, rowSpan);
}
return new CellSelection(column, row, columnSpan, rowSpan); return new CellSelection(column, row, columnSpan, rowSpan);
} }
public void pasteWidthAndHeight(TemplateElementCase ec, int column, int row, int columnSpan, int rowSpan){ public void pasteWidthAndHeight(TemplateElementCase ec, int column, int row, int columnSpan, int rowSpan){
for(int i = 0; i<columnSpan; i++){ for(int i = 0; i < columnSpan; i++){
for(int j = 0; j<rowSpan; j++){ ec.setColumnWidth(column + i, columnWidth[i]);
ec.setColumnWidth(column + i, ec.getColumnWidth(this.column + i));
ec.setRowHeight(row + j, ec.getRowHeight(this.row + j));
} }
for(int j = 0; j < rowSpan; j++){
ec.setRowHeight(row + j, rowHeight[j]);
} }
} }

2
designer/src/com/fr/grid/GridUtils.java

@ -288,7 +288,7 @@ public class GridUtils {
} }
} }
elementsTransferable.addObject(new CellElementsClip(cs.getColumn(), cs.getRow(), elementsTransferable.addObject(new CellElementsClip(
cs.getColumnSpan(), cs.getRowSpan(), elList.toArray(new TemplateCellElement[elList.size()]) cs.getColumnSpan(), cs.getRowSpan(), elList.toArray(new TemplateCellElement[elList.size()])
)); ));
} }

12
designer/src/com/fr/grid/selection/CellSelection.java

@ -33,6 +33,7 @@ import com.fr.report.cell.cellattr.CellGUIAttr;
import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.ColumnRow; import com.fr.stable.ColumnRow;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.unit.FU;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -236,8 +237,15 @@ public class CellSelection extends Selection {
TemplateCellElement cellElement = (TemplateCellElement) cells.next(); TemplateCellElement cellElement = (TemplateCellElement) cells.next();
list.add((TemplateCellElement) cellElement.deriveCellElement(cellElement.getColumn() - column, cellElement.getRow() - row)); list.add((TemplateCellElement) cellElement.deriveCellElement(cellElement.getColumn() - column, cellElement.getRow() - row));
} }
FU [] columnWidth = new FU[columnSpan];
transferable.addObject(new CellElementsClip(this.column, this.row, this.columnSpan, this.rowSpan, list.toArray(new TemplateCellElement[list.size()]))); FU [] rowHeight = new FU[rowSpan];
for(int i = 0; i < columnSpan; i++){
columnWidth[i] = ec.getColumnWidth(this.column + i);
}
for(int j = 0; j < rowSpan; j++){
rowHeight[j] = ec.getRowHeight(this.row + j);
}
transferable.addObject(new CellElementsClip(this.columnSpan, this.rowSpan, columnWidth, rowHeight, list.toArray(new TemplateCellElement[list.size()])));
} }
/** /**

Loading…
Cancel
Save