Bug 60311 - EDITING: Copy cells with CONDITIONAL FORMATTING formula with wrong references after paste
Summary: EDITING: Copy cells with CONDITIONAL FORMATTING formula with wrong references...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.0.0.1 rc
Hardware: Other Windows (All)
: medium major
Assignee: Not Assigned
URL:
Whiteboard: target:4.1.0 target:4.0.2
Keywords: regression
: 60521 (view as bug list)
Depends on:
Blocks: Conditional-Formatting mab4.0
  Show dependency treegraph
 
Reported: 2013-02-05 08:56 UTC by Rainer Bielefeld Retired
Modified: 2017-07-17 09:25 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
Screenshot shows wrong row calculation (97.90 KB, image/png)
2013-02-05 08:56 UTC, Rainer Bielefeld Retired
Details
Paste special corrupts cell refferences in Conditional Formatting (9.36 KB, application/vnd.oasis.opendocument.spreadsheet)
2013-02-09 22:27 UTC, Robert Popa
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rainer Bielefeld Retired 2013-02-05 08:56:42 UTC
Created attachment 74224 [details]
Screenshot shows wrong row calculation

During my research for "Bug 60306 - EDITING: CONDITIONAL FORMATTING destroyed after copy-paste cell" with [Version 4.1.0.0.alpha0+ (Build ID: 2823789bec0c029d9714aff0ed65923e23177ef) TinderBox: Win-x86@6, Branch:master, Time: 2013-01-24_22:52:49] I found something strange with formula in CF cell when I copy / paste to target:

Steps how to reproduce: 

0. Open both documents from Attachment 74218 [details] for Bug 60306
1. In source.ods select row 65 by click on row heading
2. <control+c> for copy all row
3. In target document click A65
5. <control+v> for paste
   > Row contents will become pasted
6. As in step 5 also paste to rows 64 ... 54 and 66 ... 70 
   Expected: Comparison always to Cell in Column T of SAME row
             (as T65 in row 65)
   Actual: Reference to cell in different line of Column T, see list below and
           Screenshot
	
Souce:  $Tabelle1.$T65>$Tabelle1.$C$10   (Row 65)
Target: $Tabelle1.$T65>$Tabelle1.$C$10   (Row 65)    
        $Tabelle1.$T64>$Tabelle1.$C$10   (Row 63) !!
        $Tabelle1.$T63>$Tabelle1.$C$10   (Row 61) !!

Row reference is calculated wrongly for row different from Source row.
Comment 1 Rainer Bielefeld Retired 2013-02-05 08:57:17 UTC
I can't tell whether this problem is related to root of Bug 60306
Comment 2 Rainer Bielefeld Retired 2013-02-05 09:13:22 UTC
Already [Reproducible] with server  installation of  "LOdev  4.0.0.0.beta2+   -  ENGLISH UI / German Locale  [Build ID:6738ae52bd075dc6478dedfeddc60d1c25cffcb)]"  {tinderbox: Win-x86@6, pull time 2013-01-04 23:41:48} on German WIN7 Home Premium (64bit) with own separate User Profile 

Was still ok  with unzipped  installation of  "LOdev  4.0.0.0.alpha1+   -  ENGLISH UI / German Locale  [Build ID:af60316514f3ae3d4c475819bf86f2af837171e)]"  {tinderbox: Win-x86@6, pull time 2012-11-23 22:10:31} on German WIN7 Home Premium (64bit) with own separate User Profile 

Reproduced in independent builds, so NEW

This one appeared later than Bug 60306, so I now doubt that there is a direct relation.

@Markus:
can you please have a look?
Comment 3 Markus Mohrhard 2013-02-06 02:15:33 UTC
I suspect you are checking the conditional format with the Manage conditional formats dialog?
Comment 4 Markus Mohrhard 2013-02-06 02:45:31 UTC
And after playing around with it for some time I can no longer reproduce it again. This code is so screwed up but for the first time in a long time it is not my change that is responsible :/

Despite my rejection a patch has been integrated that might be responsible for this problem. Can you please test if selecting a cell in the range and then using not the "Manage Conditional Format" but the Format->Conditional Formatting->Condition dialog with a cell in the range selected shows the right formula?
Comment 5 Rainer Bielefeld Retired 2013-02-06 05:45:16 UTC
(In reply to comment #3)
I check with Menu 'Format - CF -> Condition', sometimes via 'Format - CF -> Manage'

(In reply to comment #4)
> And after playing around ...
It meets with my experience: always when I thought to have understood what happens I see something totally unexpected ...
I checked again with Server Installation of "LibO  4.0.0.3 rc   -  ENGLISH UI / German Locale  [Build ID: 7545bee9c2a0782548772a21bc84a9dcc583b89)]"  {tinderbox: @6, pull time 2013-01-31 11:30(?)} on German WIN7 Home Premium (64bit) with separate new User Profile.
In source.ods Formula for I65 (Via 'Format -> CF -> Manage':
* Condition1: $Tabelle1.$T65>$Tabelle1.$C$10 - Apply Style: EK_Aktuell
* Condition1: $Tabelle1.$T65<=$Tabelle1.$C$10 - Apply Style: EK_Veraltet

That's what I expect

After copying complete row to SampleTarget.ods Row 65:
* Condition1: $Tabelle1.$T65>$Tabelle1.$C$10 - Apply Style: EK_Aktuell
* Condition1: $Tabelle1.$T65<=$Tabelle1.$C$10 - Apply Style: EK_Veraltet
What seems to be exactly the same.
But I see I65 with blue border of Style "Berechnet"

And it seems the information in CF dialog is not correct. When I copy / Paste I65 to I66 I would expect to see a very similar CF formula for Row 66, but In the copied Cell I66 I see no formula, but:
* Condition1: Cell Value Is: not equal to: leer - Apply Style: Berechnet
* Condition1: nothing
Comment 6 Robert Popa 2013-02-09 22:26:05 UTC
Problem description: 
Paste special for conditional formatting not working as expected! Wrong incrementing for second cell refference.



Steps to reproduce:
1. Blank ods
2. Create a conditional formatting formula (for example: IF(isblank($A2),0,IF(AK2=AK$40,0,1)) then apply style NEW_STYLE
3. copy cell
4. paste special,  only format, in cell ak3
5. You get the formula: IF(ISBLANK($A2),0,IF(B2=B$40,0,1))


Current behavior:
You get the formula: IF(ISBLANK($A3),0,IF(B4=B$40,0,1))


Expected behavior:
You should get IF(ISBLANK($A3),0,IF(B3=B$40,0,1))

NOTE:
This only happens for paste special (CTRL+SHIFT+V) and the brush button from the toolbar.
If you make the cell B2 and the FILL DOWN, and after that you complete the data, then it works as expected.

Clearly a bug, quite unpleasant!
Comment 7 Robert Popa 2013-02-09 22:27:47 UTC
Created attachment 74514 [details]
Paste special corrupts cell refferences in Conditional Formatting
Comment 8 Robert Popa 2013-02-09 22:29:52 UTC
The comment above was for LO 4.0.0.3 release, on Windows 7 PRO 64bit EN.
For any additional info please email me for further tests!
Comment 9 john.pratt 2013-02-09 22:56:30 UTC
@Robert Popa
I cannot follow your steps - which cell did you originally enter the conditional format into before copying?  Should the relative reference in the original formula certainly be to AK2?
Comment 10 Robert Popa 2013-02-10 06:22:50 UTC
Sorry, I discovered the issue in one of our files and I created another example file afterwards. So, at point 2 I should have written:

2. Create a conditional formatting formula (for example: IF(isblank($A2),0,IF(B2=B$40,0,1)) then apply style NEW_STYLE

Just take a look at the file I attached. I hope it is much clear there.
Comment 11 Rainer Bielefeld Retired 2013-02-20 05:34:33 UTC
*** Bug 60521 has been marked as a duplicate of this bug. ***
Comment 12 Michael Meeks 2013-02-26 11:25:54 UTC
Judging by the fix: 
http://cgit.freedesktop.org/libreoffice/core/commit/?id=a9ce4176d274587de755147cf52bbec91b53fa2b&h=libreoffice-4-0

This is a duplicate of 60306.

Thanks for reporting and helping to chase this down - we're trying to get the fix reviewed for 4.0.1 currently.

*** This bug has been marked as a duplicate of bug 60306 ***
Comment 13 Rainer Bielefeld Retired 2013-02-27 09:12:26 UTC
Not a real DUP due to latest research, function was already ok while Bug 60306 still unfixed.

This bug has been fixed,
Markus Mohrhard committed a patch related to this issue:
<https://bugs.freedesktop.org/show_bug.cgi?id=60306#c10>
<https://bugs.freedesktop.org/show_bug.cgi?id=60306#c11>

I will check whether fixes for "Bug 60306 - EDITING: CONDITIONAL FORMATTING destroyed after copy-paste cell" will contain a backport of those fixes to 4.0.1 for this one, too