sw/qa/extras/ooxmlexport/data/tdf166201_simplePos.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport22.cxx | 13 +++++++++++++ writerfilter/source/dmapper/GraphicImport.cxx | 8 ++++---- 3 files changed, 17 insertions(+), 4 deletions(-)
New commits: commit 28917562f641654c47dd5b621e1e12aaa98dd5d7 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Tue Apr 15 18:30:12 2025 -0400 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Apr 16 08:30:20 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/+/184247 Reviewed-by: Miklos Vajna <vmik...@collabora.com> 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 463f7f7db7c5..374231f339fb 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx @@ -43,6 +43,19 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf165642_glossaryFootnote) parseExport(u"word/glossary/footnotes.xml"_ustr); } +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, testTdf165933_noDelTextOnMove) { loadAndSave("tdf165933.docx"); diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 9b0f161d2f94..9b1541377264 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -769,13 +769,13 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) m_pImpl->m_sAnchorId = aString.makeStringAndClear().toAsciiUpperCase(); } break; - case NS_ooxml::LN_CT_Point2D_x: // 90405; - m_pImpl->m_nLeftPosition = ConversionHelper::convertTwipToMM100(nIntValue); + case NS_ooxml::LN_CT_Point2D_x: + 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: // 90406; - m_pImpl->m_nTopPosition = ConversionHelper::convertTwipToMM100(nIntValue); + case NS_ooxml::LN_CT_Point2D_y: + m_pImpl->m_nTopPosition = oox::drawingml::convertEmuToHmm(nIntValue); m_pImpl->m_nVertRelation = text::RelOrientation::PAGE_FRAME; m_pImpl->m_nVertOrient = text::VertOrientation::NONE; break;