Bug 79087 - After inserting a Sheet, getCellByPosition returns Cell on wrong sheet
Summary: After inserting a Sheet, getCellByPosition returns Cell on wrong sheet
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
4.2.4.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium major
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-22 20:16 UTC by greentntminer
Modified: 2014-05-25 10:53 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description greentntminer 2014-05-22 20:16:33 UTC
The following writes the text to "Sheet1" instead of the usual "TestSheet" from Calc. It worked fine from 3.x up to 4.0.6.2.


Sub Main
    Doc = ThisComponent
    TestSheet = Doc.createInstance("com.sun.star.sheet.Spreadsheet")
    Doc.Sheets.insertByName("TestSheet",TestSheet)
    Cell = TestSheet.getCellByPosition(1,6)
    Cell.String = "Hello World - Should be on TestSheet but appears on Sheet1"
End Sub
Comment 1 reporter_of_bugs 2014-05-23 10:01:02 UTC
Macro Code inserts text as intended in :

Ubuntu 14.04 64bit
Version: 4.3.0.0.beta1
Build ID: 2e39c7e59c8fc8b16a54c3d981dceef27fb0c07f
Comment 2 reporter_of_bugs 2014-05-23 21:24:23 UTC
Macro Code incorrectly inserts text in Sheet 1 as indicated by greentntminer@gmail.com when I run it in

Ubuntu 14.04 64bit
Version: 4.2.4.2
Build ID: 63150712c6d317d27ce2db16eb94c2f3d7b699f8
Comment 3 pierre-yves samyn 2014-05-25 10:53:37 UTC
Hi

I reproduce on windows 7/64 & Version: 4.2.4.2
Build ID: 63150712c6d317d27ce2db16eb94c2f3d7b699f8

I do *not* reproduce with Version: 4.3.0.0.beta1
Build ID: 2e39c7e59c8fc8b16a54c3d981dceef27fb0c07f

The bug seems solved so I close the Issue. Thank you for reporting.

In the meantime you can use the following workaround:

Sub InsertSheet
   Doc = ThisComponent
   Doc.Sheets.insertNewByName("TestSheet", Doc.Sheets.count)
   TestSheet = Doc.Sheets.getByName("TestSheet")
   Cell = TestSheet.getCellByPosition(1,6)
   Cell.String = "Hello World - on TestSheet"
End Sub

Regards
Pierre-Yves