sw/qa/extras/ooxmlexport/data/tdf166201_simplePos.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport22.cxx | 13 +++++++++++++ sw/source/writerfilter/dmapper/GraphicImport.cxx | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-)
New commits: commit 38862895bb76acf8855c87316f55cc7824fbc89e Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Tue Apr 15 18:30:12 2025 -0400 Commit: Justin Luth <jl...@mail.com> CommitDate: Wed Apr 16 02:31:32 2025 +0200 tdf#166201 docx import: simplePos is defined in EMUs, not TWIPs The normal values of simplePos are usually larger than ConversionHelper::convertTwipToMm100_Limited allows, so it typically returned 0, so usually the anchor was positioned at the top left of the page. There were no existing unit tests with non-zero simplePos. Although LN_CT_Point2D_x sounds very generic, commit history suggests that it has only been used for simplePos. (handle wp:simplePos properly) I also checked model.xml, and didn't notice anything else actually being imported that could share it. Based on the documentation, they all would also be defined in EMUs or "Universal Measurement". make CppunitTest_sw_ooxmlexport22 \ CPPUNIT_TEST_NAME=testTdf166201_simplePos Change-Id: I65f49408262c8f68107fa1614f70ff2f8365e5c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184244 Reviewed-by: Justin Luth <jl...@mail.com> Tested-by: Jenkins Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184246 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/sw/qa/extras/ooxmlexport/data/tdf166201_simplePos.docx b/sw/qa/extras/ooxmlexport/data/tdf166201_simplePos.docx new file mode 100644 index 000000000000..76f243a97189 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf166201_simplePos.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx index b9ccffd3a37d..189f8a69e97e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx @@ -55,6 +55,19 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf165933_noDelTextOnMove) assertXPath(pXmlDoc, "//w:moveFrom/w:r/w:delText", 0); } +CPPUNIT_TEST_FIXTURE(Test, testTdf166201_simplePos) +{ + // Given a document with an image at the bottom-right placed there by simplePos + + loadAndSave("tdf166201_simplePos.docx"); + + CPPUNIT_ASSERT_EQUAL(css::text::RelOrientation::PAGE_FRAME, + getProperty<sal_Int16>(getShape(1), u"HoriOrientRelation"_ustr)); + // Without the fix, this was 0 - at the top left, instead of 10.5cm - at the bottom right + CPPUNIT_ASSERT_EQUAL(sal_Int32(10478), + getProperty<sal_Int32>(getShape(1), u"HoriOrientPosition"_ustr)); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf165492_exactWithBottomSpacing) { // Given a document with "exact row height" of 2cm diff --git a/sw/source/writerfilter/dmapper/GraphicImport.cxx b/sw/source/writerfilter/dmapper/GraphicImport.cxx index 23330a742f26..d1df5176c917 100644 --- a/sw/source/writerfilter/dmapper/GraphicImport.cxx +++ b/sw/source/writerfilter/dmapper/GraphicImport.cxx @@ -795,12 +795,12 @@ void GraphicImport::lcl_attribute(Id nName, const Value& rValue) } break; case NS_ooxml::LN_CT_Point2D_x: - m_pImpl->m_nLeftPosition = ConversionHelper::convertTwipToMm100_Limited(nIntValue); + m_pImpl->m_nLeftPosition = oox::drawingml::convertEmuToHmm(nIntValue); m_pImpl->m_nHoriRelation = text::RelOrientation::PAGE_FRAME; m_pImpl->m_nHoriOrient = text::HoriOrientation::NONE; break; case NS_ooxml::LN_CT_Point2D_y: - m_pImpl->m_nTopPosition = ConversionHelper::convertTwipToMm100_Limited(nIntValue); + m_pImpl->m_nTopPosition = oox::drawingml::convertEmuToHmm(nIntValue); m_pImpl->m_nVertRelation = text::RelOrientation::PAGE_FRAME; m_pImpl->m_nVertOrient = text::VertOrientation::NONE; break;