Alberto1202 / zkspreadsheet

Automatically exported from code.google.com/p/zkspreadsheet
0 stars 0 forks source link

Shall not allow Copy and Paste operation in a protected spreadsheet #351

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi.

How can I prevent a user from running ctrl + c ctrl + v in a spreadsheet? I 
tried to intercept the keys (ctrl+c, ctrl+v,shift+inx,ctrl+ins) and "do 
nothing" but not worked.

Another thing, when the sheet is locked you can still do ctrl + c/x ctrl + v 
between cells. Is this normal?

I lock the spreadsheet using this code:

Spreadsheet s;

Ranges.range(s.getSelectedSheet()).protectSheet("testing123");

int topRow = 0;
int bottomRow = 6;
int leftCol = 0;
int rightCol = 7;

void toggleLockCells() {
final Worksheet sheet = s.getSelectedSheet();
for (int r = topRow; r <= bottomRow; r++) {
for (int c = leftCol; c <= rightCol; c++) {
org.zkoss.poi.ss.usermodel.Cell cell = 
(org.zkoss.poi.ss.usermodel.Cell)Utils.getOrCreateCell(sheet, r, c);
org.zkoss.poi.ss.usermodel.CellStyle cellStyle = 
(org.zkoss.poi.ss.usermodel.CellStyle)cell.getCellStyle();
if (cellStyle.getLocked() != lock) {
org.zkoss.poi.ss.usermodel.CellStyle newCellStyle = 
sheet.getBook().createCellStyle();
newCellStyle.setLocked(true);
Ranges.range(sheet, r, c).setStyle(newCellStyle);
System.out.println("row : " + r + " - c : " + c);
}
}
}
}

I'm using version 2.1.0.

Thanks

Original issue reported on code.google.com by chenhe...@gmail.com on 10 Jun 2011 at 1:21

GoogleCodeExporter commented 9 years ago
This issue is reported by Andreas Boos.

Original comment by chenhe...@gmail.com on 10 Jun 2011 at 1:22

GoogleCodeExporter commented 9 years ago
http://tracker.zkoss.org/browse/ZSS-22

    ---------
The ZK Spreadsheet team has moved the issue tracker from here to our own new 
system at http://tracker.zkoss.org/secure/IssueNavigator.jspa. Please remember 
to adopt to the new system.

Users are able to log into the new system using their ZK forum account. If you 
do not already have one, please register at http://www.zkoss.org/forum/

Our new system on Jira introduces a new and very powerful voting system 
enabling users to vote up for a desired new feature or a bug that other users 
also have problem encountering.

Original comment by chenhe...@gmail.com on 15 Jul 2011 at 7:48