Browse Source

REPORT-747 之前没考虑不同模板之间复制

master
kerry 8 years ago
parent
commit
5c9c82c4f6
  1. 47
      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

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

@ -12,27 +12,32 @@ import com.fr.report.cell.CellElement;
import com.fr.report.cell.CellElementComparator;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.unit.FU;
/**
* The clip of CellElement.
*/
public class CellElementsClip implements Cloneable, java.io.Serializable {
private int column;
private int row;
private int columnSpan = 0;
private int rowSpan = 0;
private FU[] columnWidth;
private FU[] rowHeight;
private TemplateCellElement[] clips;
public CellElementsClip(int column, int row, int columnSpan, int rowSpan, TemplateCellElement[] clips) {
this.column = column;
this.row = row;
public CellElementsClip(int columnSpan, int rowSpan, FU[] columnWidth , FU[] rowHeight, TemplateCellElement[] clips) {
this.columnSpan = columnSpan;
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;
}
public String compateExcelPaste() {
Arrays.sort(this.clips, CellElementComparator.getRowFirstComparator());
@ -63,9 +68,9 @@ public class CellElementsClip implements Cloneable, java.io.Serializable {
return sbuf.toString();
}
public CellSelection pasteAt(TemplateElementCase ec, int column, int row) {
Iterator cells = ec.intersect(column, row, columnSpan, rowSpan);
while (cells.hasNext()) {
TemplateCellElement cellElement = (TemplateCellElement)cells.next();
@ -79,28 +84,30 @@ public class CellElementsClip implements Cloneable, java.io.Serializable {
FRContext.getLogger().error(e.getMessage(), e);
return null;
}
// peter:因为前面已经将这个位置的元素删除了,所以不需要override了.
ec.addCellElement((TemplateCellElement) cellElement.deriveCellElement(
column + cellElement.getColumn(), row + cellElement.getRow()
column + cellElement.getColumn(), row + cellElement.getRow()
), false);
}
//设置单元格的宽高
pasteWidthAndHeight(ec, column, row, columnSpan, rowSpan);
if(this.columnWidth != null && this.rowHeight != null){
pasteWidthAndHeight(ec, column, row, columnSpan, rowSpan);
}
return new CellSelection(column, row, columnSpan, rowSpan);
}
public void pasteWidthAndHeight(TemplateElementCase ec, int column, int row, int columnSpan, int rowSpan){
for(int i = 0; i<columnSpan; i++){
for(int j = 0; j<rowSpan; j++){
ec.setColumnWidth(column + i, ec.getColumnWidth(this.column + i));
ec.setRowHeight(row + j, ec.getRowHeight(this.row + j));
}
for(int i = 0; i < columnSpan; i++){
ec.setColumnWidth(column + i, columnWidth[i]);
}
for(int j = 0; j < rowSpan; j++){
ec.setRowHeight(row + j, rowHeight[j]);
}
}
public void pasteAtRegion(TemplateElementCase ec,
int startColumn, int startRow,
public void pasteAtRegion(TemplateElementCase ec,
int startColumn, int startRow,
int column, int row,
int columnSpan, int rowSpan) {
for (int i = 0; i < clips.length; i++) {

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()])
));
}

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.stable.ColumnRow;
import com.fr.stable.StableUtils;
import com.fr.stable.unit.FU;
import javax.swing.*;
import java.awt.*;
@ -236,8 +237,15 @@ public class CellSelection extends Selection {
TemplateCellElement cellElement = (TemplateCellElement) cells.next();
list.add((TemplateCellElement) cellElement.deriveCellElement(cellElement.getColumn() - column, cellElement.getRow() - row));
}
transferable.addObject(new CellElementsClip(this.column, this.row, this.columnSpan, this.rowSpan, list.toArray(new TemplateCellElement[list.size()])));
FU [] columnWidth = new FU[columnSpan];
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