diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-09-12 20:29:26 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-09-13 08:43:40 +0200 |
commit | b9fcf43a38773f81ef1833897c4e36d8db16c0b1 (patch) | |
tree | a35eca5058fc6a923e0eb557de6b861a777088a3 /writerfilter/qa | |
parent | 8b5a989dcdcf4edd50c9fdb092d4180432ce4b6a (diff) |
tdf#140302 RTF import: fix unexpected repeated image
The bugdoc has 2 images, but the resulting doc model had 3 images since
commit 7e863504854ae8ab286b32510aba8b363a8e314b (tdf#81943 sw RTF
import: fix missing wrap in background for in-table shape, 2018-07-16).
The trouble was that shape replay wants to access the current shape at
m_aStates.top().aShape, but we only set it, forgot to unset it after
replay was done, which can result in duplicated insertions.
Fix this by saving the old current shape on the stack, set the current
shape to the wanted value and then undo it after replay.
This only affects documents that have a \picprop group, since the
unwanted insertion happened when popping that group.
Change-Id: I088054de2332deb4b45f7e269672fa799dd49c2f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139818
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'writerfilter/qa')
-rw-r--r-- | writerfilter/qa/cppunittests/rtftok/data/duplicated-image.rtf | 41 | ||||
-rw-r--r-- | writerfilter/qa/cppunittests/rtftok/rtfdocumentimpl.cxx | 18 |
2 files changed, 59 insertions, 0 deletions
diff --git a/writerfilter/qa/cppunittests/rtftok/data/duplicated-image.rtf b/writerfilter/qa/cppunittests/rtftok/data/duplicated-image.rtf new file mode 100644 index 000000000000..f225ff1f248f --- /dev/null +++ b/writerfilter/qa/cppunittests/rtftok/data/duplicated-image.rtf @@ -0,0 +1,41 @@ +{\rtf1 +before table\par +\trowd\cellx4819\cellx9638\pard\plain\intbl +A1 +\cell\pard\plain +{\shp +{\*\shpinst\shpwr1\shpbypara\shpbyignore\shptop113\shpbottom1352\shpbxcolumn\shpbxignore\shpleft-22\shpright4733 +{\sp +{\sn shapeType} +{\sv 75} +} +{\sp +{\sn pib} +{\sv +{\pict\picscalex92\picscaley92\piccropl0\piccropr0\piccropt0\piccropb0\picw341\pich89\picwgoal5115\pichgoal1335\pngblip +89504e470d0a1a0a0000000d4948445200000010000000100403000000eddde25200000030504c54450000008000000080008080000000808000800080808080 +80c0c0c0ff000000ff00ffff000000ffff00ff00ffffffffff7b1fb1c40000005b49444154789c458db10ac03008445d33e5b71d04d764caef3808f99d0604ab +b5a5b778dc933bf057f01bdd650ca98cf8d885ce240d0c3ecf40a41dc9097011f4d67a2ad18ac8f239af44f33255e19c1044ce42e39a60f9469fc06fa01a6b07 +bcd70bc70000000049454e44ae426082 +} +} +} +} +} +\cell\row +\pard\plain after table\par +\pard\plain +{\*\shppict +{\pict +{\*\picprop +} +\picscalex100\picscaley100\piccropl0\piccropr0\piccropt0\piccropb0\picw16\pich16\picwgoal240\pichgoal240\pngblip +89504e470d0a1a0a0000000d4948445200000010000000100403000000eddde25200000030504c54450000008000000080008080000000808000800080808080 +80c0c0c0ff000000ff00ffff000000ffff00ff00ffffffffff7b1fb1c40000005b49444154789c458db10ac03008445d33e5b71d04d764caef3808f99d0604ab +b5a5b778dc933bf057f01bdd650ca98cf8d885ce240d0c3ecf40a41dc9097011f4d67a2ad18ac8f239af44f33255e19c1044ce42e39a60f9469fc06fa01a6b07 +bcd70bc70000000049454e44ae426082 +} +} +end +\par +} diff --git a/writerfilter/qa/cppunittests/rtftok/rtfdocumentimpl.cxx b/writerfilter/qa/cppunittests/rtftok/rtfdocumentimpl.cxx index 1898e0057695..6020453ba783 100644 --- a/writerfilter/qa/cppunittests/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/qa/cppunittests/rtftok/rtfdocumentimpl.cxx @@ -101,6 +101,24 @@ CPPUNIT_TEST_FIXTURE(Test, testCharHiddenInTable) // hidden. CPPUNIT_ASSERT(bCharHidden); } + +CPPUNIT_TEST_FIXTURE(Test, testDuplicatedImage) +{ + // Given a document with 2 images: + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "duplicated-image.rtf"; + + // When importing that document: + getComponent() = loadFromDesktop(aURL); + + // Then make sure no duplicated images are created: + uno::Reference<drawing::XDrawPageSupplier> xTextDocument(getComponent(), uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xTextDocument->getDrawPage(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 2 + // - Actual : 3 + // i.e. there was a 3rd, duplicated image. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xDrawPage->getCount()); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |