poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 51483] XSSF locking of specific features not working
Date Sun, 05 Jan 2014 21:48:10 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=51483

--- Comment #2 from Da_Groovy@gmx.de ---
I compared 2 files at xml level. It seems the "lock state" is activated by
default for all possible settings:

* sheet.lockDeleteColumns();
* sheet.lockDeleteRows();
* sheet.lockFormatCells();
* sheet.lockFormatColumns();
* sheet.lockFormatRows();
* sheet.lockInsertColumns();
* sheet.lockInsertHyperlinks();
* sheet.lockInsertRows();
* sheet.lockObjects();
* sheet.lockPivotTables();
* sheet.lockScenarios();
* sheet.lockSelectLockedCells();
* sheet.lockSelectUnlockedCells();
* sheet.lockSort();

That means calling "enableLocking()" automatically enables nearly all locks.
Setting one of the locks above is quite useless because it already is locked by
default. What we need here is an "unlock" option. In the following example
nearly everything is locked. The only options allowed are selecting unlocked
fields and inserting new rows.

POI export file:

  <sheetProtection
     sheet="true"
     objects="true"
     scenarios="true"
     deleteColumns="true"
     deleteRows="true"
     formatColumns="true"
     formatRows="true"
     insertColumns="true"
     insertHyperlinks="true"
     pivotTables="true"
     selectLockedCells="true"
     sort="true"
     password=""
  />


Excel export file with same settings:

  <sheetProtection
     sheet="1"
     objects="1"
     scenarios="1"
     insertRows="0"
     selectLockedCells="1"
     password=""
  />

Using "true"/"false" instead of "1"/"0" doesn't matter here, means the same and
seems to be interpreted both.
In POI export "insertRows" lock has not been set and was therefore assumed to
be unlocked but it wasn't, inserting rows wasn't possible.
Manually changing the file by adding  insertRows="false"  makes the clue. It
worked as assumed.

Maybe there are 3 possibilities:

1. developer can set "lock" only (same as current)
  --> internally all other settings must be set to "unlock" (false or 0)
2. replace sheet methods "lock..." with "unlock..." because all locks are
activated by default, the opposite must be defined
3. developer can set "unlock" for each setting as well as "lock"
  --> would be a more intuitive handling as it would lead to something like
this in code:

  sheet.lockDeleteColumns();
  sheet.lockDeleteRows();
  sheet.lockFormatCells();
  sheet.lockFormatColumns();
  sheet.lockFormatRows();
  sheet.lockInsertColumns();
  sheet.lockInsertHyperlinks();
  sheet.unlockInsertRows();
  sheet.lockObjects();
  sheet.lockPivotTables();
  sheet.lockScenarios();
  sheet.lockSelectLockedCells();
  sheet.unlockSelectUnlockedCells();
  sheet.lockSort();

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Mime
View raw message