Пример #1
0
  public void copy(int column1, int row1, int column2, int row2, boolean skipGeoCopy, boolean nat) {
    sourceColumn1 = column1;
    sourceRow1 = row1;

    // copy tab-delimited geo values into the external buffer
    if (cellBufferStr == null) {
      cellBufferStr = new StringBuilder();
    } else {
      cellBufferStr.setLength(0);
    }
    for (int row = row1; row <= row2; ++row) {
      for (int column = column1; column <= column2; ++column) {
        GeoElement value = RelativeCopy.getValue(app, column, row);
        if (value != null) {
          cellBufferStr.append(value.toValueString(StringTemplate.maxPrecision));
        }
        if (column != column2) {
          cellBufferStr.append('\t');
        }
      }
      if (row != row2) {
        cellBufferStr.append('\n');
      }
    }

    // store the tab-delimited values in the clipboard
    /*Toolkit toolkit = Toolkit.getDefaultToolkit();
    Clipboard clipboard = toolkit.getSystemClipboard();
    StringSelection stringSelection = new StringSelection(cellBufferStr);
    clipboard.setContents(stringSelection, null);*/

    // a clipboard inside this application is better than nothing
    // staticClipboardString = new String(cellBufferStr);
    if (nat) {
      // if called from native event, setting clipboard contents
      // is not crucial, and redundant/harmful in IE...
      setInternalClipboardContents(new String(cellBufferStr));
    } else {
      setClipboardContents(new String(cellBufferStr), getFocusCallback());
    }

    // store copies of the actual geos in the internal buffer
    if (skipGeoCopy) {
      cellBufferGeo = null;
    } else {
      cellBufferGeo = RelativeCopy.getValues(app, column1, row1, column2, row2);
    }
  }