Back to index

wims  3.65+svn20090927
Public Member Functions | Private Attributes
SharpTools.SharpClipboard Class Reference
Collaboration diagram for SharpTools.SharpClipboard:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SharpClipboard (SharpTableModel model, CellRange range, boolean isCut)
 Creates new SharpClipboard.
CellRange getRange (SharpTableModel model, CellPoint corner)
 This gets the actual range of a paste from a corner point.
void paste (SharpTableModel table, CellPoint corner)
 This pastes the current contents of the spreadsheet object on to the region defined by the coordinates of the upper right hand corner.
void paste (SharpTableModel table, CellRange range)
 This is similar to the other paste, but take range as a parameter.
CellRange getSource ()
 This method returns the range the clipboard originally came from.
void setSource (CellRange x)
 Set the source of the clipboard.
String toString ()
 Return the string representation of contents of the clipboard.

Private Attributes

String text
 holds the objects that are cut or copied
CellRange source
 the range of Cells from which the clipboard was created

Detailed Description

Definition at line 19 of file SharpClipboard.java.


Constructor & Destructor Documentation

Creates new SharpClipboard.

If it is a cut, then it clears the range it was created from.

Parameters:
modelthe SharpTableModel you are operating on
rangean array of CellPoint objects where the first is the upper left hand corner and the second entry is the lower right hand corner coordinates
isCuttrue only if this is a cut

Definition at line 36 of file SharpClipboard.java.

                                      {
       text = model.toString(range, false);

        source = range;
        
        //if it is a cut, set the old cells to null
        if (isCut) {
            model.clearRange(range);
        }
    }

Here is the call graph for this function:


Member Function Documentation

This gets the actual range of a paste from a corner point.

This is actually a helper method for paste

Parameters:
cornerthe upper left corner coordinate
Returns:
the actual cell range; null if it's beyond the table range
Parameters:
modelthe SharpTableModel you are using

Definition at line 54 of file SharpClipboard.java.

                                                                       {
        //limit to paste region
        int rowLimit = model.getRowCount() - 1;
        int colLimit = model.getColumnCount() - 1;
        
        //calculate dimensions of clipboard
        int rowMax = corner.getRow() + source.getHeight() - 1;
        int colMax = corner.getCol() + source.getWidth() - 1;
        
        //cannot paste to nonexistent cells
        if ((corner.getRow() < SharpTools.baseRow) ||
           (corner.getCol() < SharpTools.baseCol)) {
           return null;
        }else {
            //paste as much as you can
           return new CellRange(corner,
                             new CellPoint(Math.min(rowMax, rowLimit),
                                          Math.min(colMax, colLimit)));
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

This method returns the range the clipboard originally came from.

Returns:
the range the clipboard originally can from

Definition at line 106 of file SharpClipboard.java.

                                 {
        return source;
    }

Here is the caller graph for this function:

void SharpTools.SharpClipboard.paste ( SharpTableModel  table,
CellPoint  corner 
) [inline]

This pastes the current contents of the spreadsheet object on to the region defined by the coordinates of the upper right hand corner.

If the contents cannot be entirely pasted on this region, it pastes as much as it can

Parameters:
tableSharpTable model you are pasting to
cornercoordinate of upper left hand corner

Definition at line 82 of file SharpClipboard.java.

                                                               {
        //if region to paste to is out of bounds
       CellRange range = getRange(table, corner);
       paste(table, range);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void SharpTools.SharpClipboard.paste ( SharpTableModel  table,
CellRange  range 
) [inline]

This is similar to the other paste, but take range as a parameter.

This is used together with getRange.

Parameters:
tableSharpTableModel you are pasting to
rangerange you are pasting to

Definition at line 93 of file SharpClipboard.java.

                                                              {

        //if region to paste to is out of bounds
       if (range != null) {
           int rowOff = range.getStartRow()-source.getStartRow();
           int colOff = range.getStartCol()-source.getStartCol();
           table.fromString(text, rowOff, colOff, range);
       }
    }            

Here is the call graph for this function:

Set the source of the clipboard.

Parameters:
xCellRange to set as the source of the clipboard

Definition at line 113 of file SharpClipboard.java.

                                       {
        source = x;
    }

Return the string representation of contents of the clipboard.

Returns:
the string representation of contents of the clipboard

Definition at line 120 of file SharpClipboard.java.

{ return text; }

Member Data Documentation

the range of Cells from which the clipboard was created

Definition at line 26 of file SharpClipboard.java.

holds the objects that are cut or copied

Definition at line 23 of file SharpClipboard.java.


The documentation for this class was generated from the following file: