Bug 145558 - reproducible Crash: VBA insert graphic, save, crash
Summary: reproducible Crash: VBA insert graphic, save, crash
Status: RESOLVED INSUFFICIENTDATA
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.2.1.2 release
Hardware: All Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-05 16:09 UTC by daniel.heiserer
Modified: 2023-03-29 03:26 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
.ods file with macros to reproduce the crash and to avoid it. (27.42 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-11-21 11:11 UTC, daniel.heiserer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description daniel.heiserer 2021-11-05 16:09:59 UTC
Description:
I tried to insert grafiks into calc using a macro.
A reproducable crash occurs when I insert a grafik into a sheet which ist "not active", scale the grafik and then try to save the document.

Crash can be avoided (see the VBA script) when "focus/activesheet" is switched. 

Steps to Reproduce:
REM  *****  BASIC  *****
sub LoadLogo
    odoc = Thiscomponent
	
	grafikname="Logo"
	path=replace(Thiscomponent.Location,Thiscomponent.Title,"")
	urlgrafik=path+"Logo.png"
    oSheet = oDoc.Sheets(0)
   
	ocell = oSheet.getcellbyposition(0,0)
	call Insertgrafik(oSheet,ocell,urlgrafik,odoc,grafikname)
	call SaveAndExport()


end sub

Sub Insertgrafik(oSheet,ocell,urlgrafik,odoc,grafikname)
    Dim Size 		As New com.sun.star.awt.Size
    Dim Size_max 	As New com.sun.star.awt.Size
    ' WORKAROUND ---------------------------------------------------
	' This ins necessary. Else it will crash when we save afterwards.
	oView = Thiscomponent.CurrentController
	aSheet= Thiscomponent.getCurrentController().getActiveSheet()
	oView.setActiveSheet(oSheet)
    '---------------------------------------------------------------
    
    oGrafik = oDoc.createInstance("com.sun.star.drawing.GraphicObjectShape")
    oGrafik.GraphicURL = urlgrafik
    oGrafik.name = grafikname
    'Ankerposition festlegen 
    
    oPage = oSheet.drawpage  
    opage.add(oGrafik)
    oGrafik.Anchor = oCell
    new_Original_Size = oGrafik.Graphic.SizePixel
    
    'Msgbox("widht:"+new_Original_Size.width+" Height:"+new_Original_Size.Height)
    
    ' Height is im mikrometers
    Target_Height=3000
    factor=Target_Height/new_Original_Size.Height

    size.width = new_Original_Size.width*factor
    size.Height = new_Original_Size.Height*factor
    oGrafik.setSize(size)
    ' undo WORKAROUND --------------------------------
	oView.setActiveSheet(aSheet)
	' ------------------------------------------------    
End Sub


Sub DeleteAllPics()
    Dim oDoc As Object
    Dim oDrawPage As Object
    Dim oShape As Object
    Dim iShape As Integer
    Dim iSheet As Integer
    oDoc = ThisComponent
    'Achtung löscht Knöpfe!!!
    
    
    For iSheet = 0 To oDoc.getSheets().getCount() - 1
        'oDrawPage = oDoc.getSheets().getByIndex(iSheet).getDrawPage()
        oDrawPage = oDoc.Sheets(iSheet).getDrawPage()
        'do until iShape = oDrawPage.getCount() > 0
        oRange = oDoc.Sheets(iSheet).getCellRangeByName("C2:H9999")
        oRange.clearContents(4+1)
		For iShape = oDrawPage.getCount() - 1 To 0 Step -1
		'For iShape = 0 to oDrawPage.getCount() -1 
            oShape = oDrawPage.getByIndex(iShape)
            'msgbox("iShape: "+iShape+" Name: '"+oShape.Name+"'")
            'print "Name: "+oShape.Name
            'msgbox("Title:"+oShape.Title)
            ' name ist unschön. Typ "nicht button wäre besser"
            oDoc.Sheets(1).getcellbyposition(2,iShape+1).value=iShape
            oDoc.Sheets(1).getcellbyposition(3,iShape+1).setString(oShape.Name)
            oDoc.Sheets(1).getcellbyposition(4,iShape+1).setString(oDoc.Sheets(iSheet).getName())
            if left(oShape.Name,4) = "Logo" then
            	oDrawPage.remove(oShape)
            endif
        Next iShape
        'Loop
    Next iSheet
End Sub

sub SaveAndExport
	' funktioniert gut. Kein uno nötig.
	ThisComponent.store()
end sub


Actual Results:
See
See https://crashreport.libreoffice.org/stats/crash_details/713a7969-10df-4c8e-89ab-f3a927677e53

Expected Results:
No Crash ;-)


Reproducible: Always


User Profile Reset: No



Additional Info:
No other information necessary.
Comment 1 raal 2021-11-20 23:17:27 UTC
Hello,

Thank you for filing the bug. Please send us a sample document, as this makes it easier for us to verify the bug, and steps to reproduce the bug. When I copy, paste your code into new file, then it runs with errors.
I have set the bug's status to 'NEEDINFO', so please do change it back to 'UNCONFIRMED' once you have attached a document.
(Please note that the attachment will be public, remove any sensitive information before attaching it.)
How can I eliminate confidential data from a sample document?
https://wiki.documentfoundation.org/QA/FAQ#How_can_I_eliminate_confidential_data_from_a_sample_document.3F
Thank you
Comment 2 daniel.heiserer 2021-11-21 11:06:57 UTC
The crash is ugly because it goes deep. You cannot simply restart LibreOffice you have to reboot the computer. 
I have Windows10 running. Did not test it on linux.

I will attach and .ods exammple containing 4 buttons with macros associated:
1) remove picutres.
2a) insert picture without crash (workaround)
2b) insert picture with crash.
3) just save..
Comment 3 daniel.heiserer 2021-11-21 11:11:06 UTC
Created attachment 176394 [details]
.ods file with macros to reproduce the crash and to avoid it.

got to tab2.
Four buttons associacted with macros:
1) clear .ods from pics
2a) insert pic with workaround from crash.
2b) insert pic with the crash
3) just save.
Comment 4 QA Administrators 2021-11-22 04:02:12 UTC Comment hidden (obsolete)
Comment 5 Stéphane Guillou (stragu) 2022-08-29 16:28:41 UTC
I couldn't reproduce in:

Version: 7.1.8.1 / LibreOffice Community
Build ID: e1f30c802c3269a1d052614453f260e49458c82c
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

or:

Version: 7.2.7.2 / LibreOffice Community
Build ID: 8d71d29d553c0f7dcbfa38fbfda25ee34cce99a2
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

or:

Version: 7.3.5.2 / LibreOffice Community
Build ID: 184fe81b8c8c30d8b5082578aee2fed2ea847c01
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Clicking the LoadLogo and LoadLogoCrash buttons results in an error, e.g.:

BASIC runtime error.
An exception occurred
Type: com.sun.star.lang.IllegalArgumentException
Message: /home/buildslave/source/libo-core/svx/source/unodraw/-unoshap2.cxx:1399.

Could you please try again with an updated version of LibreOffice?
Could you also please try it in safe mode? (Help > Restart in safe mode)
Comment 6 QA Administrators 2023-02-26 03:21:34 UTC Comment hidden (obsolete)
Comment 7 QA Administrators 2023-03-29 03:26:05 UTC
Dear daniel.heiserer,

Please read this message in its entirety before proceeding.

Your bug report is being closed as INSUFFICIENTDATA due to inactivity and
a lack of information which is needed in order to accurately
reproduce and confirm the problem. We encourage you to retest
your bug against the latest release. If the issue is still
present in the latest stable release, we need the following
information (please ignore any that you've already provided):

a) Provide details of your system including your operating
   system and the latest version of LibreOffice that you have
   confirmed the bug to be present

b) Provide easy to reproduce steps – the simpler the better

c) Provide any test case(s) which will help us confirm the problem

d) Provide screenshots of the problem if you think it might help

e) Read all comments and provide any requested information

Once all of this is done, please set the bug back to UNCONFIRMED
and we will attempt to reproduce the issue. Please do not:

a) respond via email 

b) update the version field in the bug or any of the other details
   on the top section of our bug tracker

Warm Regards,
QA Team

MassPing-NeedInfo-FollowUp