Bug 92789

Summary: FILEOPEN embedded graphic of format "pct" is not displayed.
Product: LibreOffice Reporter: Regina Henschel <rb.henschel>
Component: filters and storageAssignee: osnola <alonso>
Status: VERIFIED FIXED    
Severity: normal CC: alonso, caolan.mcnamara, dtardon, ilmari.lauhakangas, momonasmon, serval2412
Priority: medium Keywords: regression
Version: 4.4.0.0.beta1   
Hardware: Other   
OS: All   
Whiteboard:
Crash report or crash signature: Regression By:
Attachments: example with embedded PICT image
a proposition to correct the reading of some bitmaps

Description Regina Henschel 2015-07-16 18:35:35 UTC
Created attachment 117286 [details]
example with embedded PICT image

The attached document has embedded pictures of format type ".bmp", ".wmf", ".eps" and ".pct".

In Version: 4.2.5.2 Build ID: 6ff819b65674ae6c83f3cbab9e4a4c2b292a7a94 all of them are shown.

In Version: 5.1.0.0.alpha1+
Build ID: dad6be8af0e670a56d3d399a1b0a35859bd7b093
TinderBox: Win-x86@62-merge-TDF, Branch:MASTER, Time: 2015-07-11_01:26:15
Locale: de-DE (de_DE)
the ".pct" picture is missing.
Comment 1 Julien Nabet 2015-07-16 19:06:29 UTC
On pc Debian x86-64 with master sources updated yesterday, I could reproduce this.

Then, I unzipped the odt file and found the pct picture.
I tried to insert it (just a mere "menu Insert/image") in a brand new odt file but had a popup indicating "Unknown Image format".

I can't open an pct file too, I've got a popup indicated "Incorrect format. Incorrect file format"


With LO Debian package 4.4.4, I could open the attached file and could see the picture.
Comment 2 Julien Nabet 2015-07-16 19:31:25 UTC
Some gdb session:
(gdb) 
1925	        if (nOpcode==0x00ff)
(gdb) 
1928	        nSize=ReadData(nOpcode);
(gdb) 
1930	        if ( IsVersion2 )
(gdb) 
1932	            if ( nSize & 1 )
(gdb) 
1935	            nPos+=2+nSize;
(gdb) 
1940	        pPict->Seek(nPos);
(gdb) 
1952	    if (pPict->GetError()) pPict->Seek(nOrigPos);
(gdb) p *pPict
$21 = {_vptr.SvStream = 0x2aaab0e9cf50 <vtable for SvStream+16>, xLockBytes = {pObj = 0x36e9b80}, m_nActPos = 566, pRWBuf = 0x37c9110 "", pBufPos = 0x37c9110 "", 
  nBufSize = 4096, nBufActualLen = 0, nBufActualPos = 0, nBufFree = 3464, bIoRead = false, bIoWrite = false, bIsDirty = false, bIsConsistent = true, bSwap = true, 
  bIsEof = false, nError = 3861, nEndian = BIG, nCompressMode = NONE, eLineDelimiter = LINEEND_LF, eStreamCharSet = 76, m_aCryptMaskKey = "", nCryptMask = 0 '\000', 
  nVersion = 0, m_nBufFilePos = 566, eStreamMode = NONE, bIsWritable = true}
(gdb) n

bt part:
#0  0x00002aaace590514 in PictReader::ReadPict(SvStream&, GDIMetaFile&) (this=0x7fffffff2bc0, rStreamPict=..., rGDIMetaFile=...)
    at /home/julien/compile-libreoffice/libreoffice/filter/source/graphicfilter/ipict/ipict.cxx:1945
#1  0x00002aaace5906d7 in pict::ReadPictFile(SvStream&, GDIMetaFile&) (rStreamPict=..., rGDIMetaFile=...)
    at /home/julien/compile-libreoffice/libreoffice/filter/source/graphicfilter/ipict/ipict.cxx:1960
#2  0x00002aaace590782 in GraphicImport(SvStream&, Graphic&, FilterConfigItem*) (rIStm=..., rGraphic=...)
    at /home/julien/compile-libreoffice/libreoffice/filter/source/graphicfilter/ipict/ipict.cxx:1980
#3  0x00002aaab1fbc7ee in GraphicFilter::ImportGraphic(Graphic&, rtl::OUString const&, SvStream&, unsigned short, unsigned short*, GraphicFilterImportFlags, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>*, WMF_EXTERNALHEADER*) (this=0x2aaab2977fa0 <rtl::Static<(anonymous namespace)::StandardGraphicFilter, (anonymous namespace)::theGraphicFilter>::get()::instance>, rGraphic=..., rPath="file:///home/julien/compile-libreoffice/bugs/92789_pict/test/Pictures/20000005000000BD000000BD6EAA04F7.pct", rIStream=..., nFormat=9, pDeterminedFormat=0x0, nImportFlags=NONE, pFilterData=0x0, pExtHeader=0x0)
    at /home/julien/compile-libreoffice/libreoffice/vcl/source/filter/graphicfilter.cxx:1732
#4  0x00002aaab1fbb00d in GraphicFilter::ImportGraphic(Graphic&, rtl::OUString const&, SvStream&, unsigned short, unsigned short*, GraphicFilterImportFlags, WMF_EXTERNALHEADER*) (this=0x2aaab2977fa0 <rtl::Static<(anonymous namespace)::StandardGraphicFilter, (anonymous namespace)::theGraphicFilter>::get()::instance>, rGraphic=..., rPath="file:///home/julien/compile-libreoffice/bugs/92789_pict/test/Pictures/20000005000000BD000000BD6EAA04F7.pct", rIStream=..., nFormat=65535, pDeterminedFormat=0x0, nImportFlags=NONE, pExtHeader=0x0) at /home/julien/compile-libreoffice/libreoffice/vcl/source/filter/graphicfilter.cxx:1328
#5  0x00002aaab1fbaf4f in GraphicFilter::ImportGraphic(Graphic&, INetURLObject const&, unsigned short, unsigned short*, GraphicFilterImportFlags) (this=0x2aaab2977fa0 <rtl::Static<(anonymous namespace)::StandardGraphicFilter, (anonymous namespace)::theGraphicFilter>::get()::instance>, rGraphic=..., rPath=..., nFormat=65535, pDeterminedFormat=0x0, nImportFlags=NONE) at /home/julien/compile-libreoffice/libreoffice/vcl/source/filter/graphicfilter.cxx:1320
#6  0x00002aaab1fbf2ae in GraphicFilter::LoadGraphic(rtl::OUString const&, rtl::OUString const&, Graphic&, GraphicFilter*, unsigned short*) (rPath="file:///home/julien/compile-libreoffice/bugs/92789_pict/test/Pictures/20000005000000BD000000BD6EAA04F7.pct", rFilterName="", rGraphic=..., pFilter=0x2aaab2977fa0 <rtl::Static<(anonymous namespace)::StandardGraphicFilter, (anonymous namespace)::theGraphicFilter>::get()::instance>, pDeterminedFormat=0x0)
    at /home/julien/compile-libreoffice/libreoffice/vcl/source/filter/graphicfilter.cxx:2276
#7  0x00002aaad43dfbac in SwView::InsertGraphic(rtl::OUString const&, rtl::OUString const&, bool, GraphicFilter*, Graphic*, bool) (this=0x2eb6ae0, rPath="file:///home/julien/compile-libreoffice/bugs/92789_pict/test/Pictures/20000005000000BD000000BD6EAA04F7.pct", rFilter="", bLink=false, pFilter=0x2aaab2977fa0 <rtl::Static<(anonymous namespace)::StandardGraphicFilter, (anonymous namespace)::theGraphicFilter>::get()::instance>, pPreviewGrf=0x0, bRule=false)
    at /home/julien/compile-libreoffice/libreoffice/sw/source/uibase/uiview/view2.cxx:232
#8  0x00002aaad43e11cb in SwView::InsertGraphicDlg(SfxRequest&) (this=0x2eb6ae0, rReq=...)
    at /home/julien/compile-libreoffice/libreoffice/sw/source/uibase/uiview/view2.cxx:464
Comment 4 Maxim Monastirsky 2015-07-16 22:39:42 UTC
@Caolán: You might be interested in this one. This regressed in your coverity#1209824 commit (and started to show the error message in one of the coverity#1242658 commits).
Comment 5 osnola 2015-07-17 08:49:41 UTC
Hello,
I just take a quick look, I do not not understand the two lines of ipict.cxx (and the following lines):
>        const size_t nMinRowWidth = nWidth * nMinRecordSize;
for me there only make sense if the bitmap is not "packed", i.e. :
- line 912: only when (nRowBytes < 8 || nPackType == 1)
- line 1072: never
Comment 6 osnola 2015-07-18 08:52:05 UTC
Created attachment 117311 [details]
a proposition to correct the reading of some bitmaps

Hello,
a proposition to correct some problems, i.e. to correct
- some checks that the bitmap data can be read in the file
- some bad conversions between uint_16t and int_16t

Note:
- I still does not have set a gerrit account, so....
Comment 7 vihsa 2017-06-02 03:43:06 UTC
.eps, .pct shows read error on
Version: 5.5.0.0.alpha0+
Build ID: 066665644b398a882e6cded98af5bb060af41d76
TinderBox: Android-ARM@24-Bytemark-Hosting, Branch: Master, Time: 2017-06-01 00:30:43
Comment 8 Buovjaga 2017-06-13 06:54:37 UTC
For completeness, this is the fixing commit: https://cgit.freedesktop.org/libreoffice/core/commit/?id=5fa73031aa42b62ccd167f193376565df2e635fc