From 55decd367588c2546c59cd3e5a297d42388a1f49 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Thu, 2 Apr 2026 10:33:24 -0400 Subject: [PATCH] tdf#157637 wrtw8esh: identify bMSOLayout better This is a follow-up from tdf#170767 bMSOLayout is a distraction (of my own creation I see), and was not entirely accurate. While all MSO formats turn CONSIDER_WRAP_ON_OBJECT_POSITION on (and ODT does not), it IS a user-customizable setting in Writer - Compatibility. So pure ODT files can have it as well. Remove this anti-pattern from the code base: ==> re-use non-user-customizable flags instead Change-Id: I69f42019d2819cad54f7521ac54a1bb3275f3137 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203178 Tested-by: Jenkins Reviewed-by: Justin Luth --- sw/source/filter/ww8/wrtw8esh.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 6bca53156b8f..9b8a465b73b5 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -2698,6 +2698,7 @@ void WinwordAnchoring::SetAnchoring(const SwFrameFormat& rFormat) break; } + const IDocumentSettingAccess& rIDSA = rFormat.getIDocumentSettingAccess(); mnGroupShapeBooleanProperties = 0; // LayoutInCell is hugely problematic if the value is false, // so much so that Microsoft, since DOCX compat15, ignores it and always does a layoutInCell. @@ -2714,9 +2715,10 @@ void WinwordAnchoring::SetAnchoring(const SwFrameFormat& rFormat) if (!bLayoutInCell) bLayoutInCell = mnYRelTo == 3 || mnXRelTo == 3; + // Re-using existing compat flags to determine if this comes from an MSO-formatted document. // If this is already MSO format, then we need to round-trip a false FollowingTextFlow value - const bool bIsMSOLayout = rFormat.getIDocumentSettingAccess().get( - DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION); + const bool bIsMSOLayout = rIDSA.get(DocumentSettingId::TAB_OVER_MARGIN) // <= MSO 2010 + || rIDSA.get(DocumentSettingId::TAB_OVER_SPACING); // <= MSO 2013+ // For native LO: if !FollowingTextFlow and the fly is oriented to the pageMargin(0) or page(1), // we must write layoutInCell(false), but paragraph-oriented flies match layoutInCell placement.