Bug 39850 - Copying sheet corrupts what is copied
Summary: Copying sheet corrupts what is copied
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
3.4.2 release
Hardware: Other macOS (All)
: medium critical
Assignee: Markus Mohrhard
URL:
Whiteboard: target:3.5
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-05 00:41 UTC by James
Modified: 2011-08-25 05:39 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
Source to copy data from (93.96 KB, application/vnd.oasis.opendocument.spreadsheet)
2011-08-05 00:42 UTC, James
Details
Target to paste data to (98.76 KB, application/vnd.oasis.opendocument.spreadsheet)
2011-08-05 00:45 UTC, James
Details

Note You need to log in before you can comment on or make changes to this bug.
Description James 2011-08-05 00:41:42 UTC
I have two spreadsheets, Source and Target. Both have identical sets of named ranges (all global) and formulas. The only difference is Source has some data in the relevant sheet to drive the formulas. Target is basically an empty version of Source. To the bug:

Open both. Go to sheet "Character" in both.
In Source, copy the entire sheet with Ctrl-A/Ctrl-C.
In Target, paste (on cell R1C1) with Ctrl-V.
Watch the fireworks. What you see copied to Target is a corrupt version of what's in Source. Named ranges in formulas are mysteriously replaced with other named ranges, with predictably bizarre and bad results.

Specifically:
R2C1:R19C1 - NameStats is replaced by PD
R21C1:R32C1 - NameMove is replaced by NamePrivate
R13C6 - PERSkill is replaced by PRESkill
R2C7 - PD is replaced by PERBonus
Column 11 - TableSkills is replaced by TotalMove
Column 13 - TableSkills is replaced by TotalMove, RollStats is replaced by RollSkills
Column 18 - PowerAdders is replaced by PowerAdvantages, TableAdders is replaced by TableAdvantages
Column 20 - PowerAdvantages is replaced by PowerLimitations, TableAdvantages is replaced by TableEncumbrance
Column 21 - PowerLimitations is replaced by RollSkills, TableLimitations is replaced by TablePowers
Column 24 - TablePowers is replaced by TableSkills, TableAdvantages is replaced by TableEncumbrance
Column 27 - TablePowers is replaced by TableSkills, PowerLimitations is replaced by PowerAdvantages

Were you to take these formulas and enter them in the formula entry box they would be accepted without error, so somehow pasting a formula is different than manually entering it.

Sometimes manual entry is the only way to get a formula copied when this bug appears. Sometimes this bug also corrupts Data Validation formulas; I've seen the named range that was supposed to appear in the Validity popup get replaced with something else, though this particular test case doesn't cause that.

I wonder if this bug may in some way be related to bug #39820, even though this test case has no sheet-local named ranges.
Comment 1 James 2011-08-05 00:42:42 UTC
Created attachment 49942 [details]
Source to copy data from
Comment 2 James 2011-08-05 00:45:49 UTC
Created attachment 49943 [details]
Target to paste data to
Comment 3 m_a_riosv 2011-08-05 17:06:23 UTC
Win7 Libeoffice 3.4.2

If you first show all columns and rows in Source then copy well.

The problem is you have the column "W" hide in the Source, then this column is not copied, and the ranges change properly.
Comment 4 James 2011-08-05 23:04:54 UTC
Are you saying this is all about hidden columns? Because if so, there's still a bug, at least in the Mac version. I unhid all the columns and rows and it still bombs out.

It couldn't be a hidden column problem because hidden columns are copied by LO. If you copy a row across a hidden column, and then paste it atop some virgin cells, you will see that your copied range includes the hidden column. If you copy a row of cells, and then paste them across a hidden column, the paste alters the hidden cells, not just the visible ones. Deleting cell contents across hidden cells deletes the contents of the hidden cells as well. This is arguably bad behavior, but it's probably what Excel does so we're stuck with it.
Comment 5 Markus Mohrhard 2011-08-07 18:37:09 UTC
These two bugs are related. The problem is our handling of named ranges in formulas. We don't use the name to identify the named range in the formula but an index that may diver between both documents.

At the moment I have no idea how to adjust our copy/paste code so that it will handle named ranges in new documents correctly. I don't think this is something for the 3-4 release cycle since this will need some rework in the copy/paste formula handling.
Comment 6 Markus Mohrhard 2011-08-15 23:26:13 UTC
might have a patch that is acceptable for 3-4, have send it to the ML for review
Comment 7 Markus Mohrhard 2011-08-25 05:38:18 UTC
fixed in master + a unit test

I don't ask for 3-4 now, the changes were too complex

will be in 3-5