From 100fcb9ca39e6de4cb9b2e86c2deac5069440cd0 Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Thu, 21 May 2026 11:46:58 +0200 Subject: [PATCH] tdf#172188: Crash when switching para direction in editeng Test bLeftToRight to know if we must use StaticWhichCast with SID_ATTR_PARA_LEFT_TO_RIGHT or SID_ATTR_PARA_RIGHT_TO_LEFT It requires to add "TypedWhichId" for SID_ATTR_PARA_RIGHT_TO_LEFT Regression from c0b0a18f5c82ff0ea6ceff1c2e3c1fcab9496681: Related tdf#140226: use StaticWhichCast in ww8graf+drwtxtex (sw) Change-Id: I59f98d7b3285c12154ad69e9e2727d66ea1dfd3e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205476 Reviewed-by: Julien Nabet Tested-by: Jenkins --- include/editeng/editids.hrc | 2 +- sw/source/uibase/shells/annotsh.cxx | 12 ++++++++++-- sw/source/uibase/shells/drwtxtex.cxx | 12 ++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/include/editeng/editids.hrc b/include/editeng/editids.hrc index bf8031a8ac4a..292f6f6c726e 100644 --- a/include/editeng/editids.hrc +++ b/include/editeng/editids.hrc @@ -165,7 +165,7 @@ class SvxOpticalSizingItem; #define SID_ATTR_PARA_AUTOFRAMEDIRECTION TypedWhichId( SID_SVX_START + 946 ) #define SID_ATTR_PARA_LRSPACE_VERTICAL ( SID_SVX_START + 947 ) #define SID_ATTR_PARA_LEFT_TO_RIGHT TypedWhichId( SID_SVX_START + 950 ) -#define SID_ATTR_PARA_RIGHT_TO_LEFT ( SID_SVX_START + 951 ) +#define SID_ATTR_PARA_RIGHT_TO_LEFT TypedWhichId( SID_SVX_START + 951 ) #define SID_ATTR_CHAR_HIDDEN TypedWhichId( SID_SVX_START + 989 ) #define SID_ATTR_CHAR_LATIN_FONT ( SID_SVX_START + 994 ) #define SID_ATTR_CHAR_LATIN_FONTHEIGHT TypedWhichId( SID_SVX_START + 995 ) diff --git a/sw/source/uibase/shells/annotsh.cxx b/sw/source/uibase/shells/annotsh.cxx index e90596105f0e..3df937b2ce02 100644 --- a/sw/source/uibase/shells/annotsh.cxx +++ b/sw/source/uibase/shells/annotsh.cxx @@ -602,8 +602,16 @@ void SwAnnotationShell::Exec( SfxRequest &rReq ) const SfxPoolItem* pPoolItem; if( pNewAttrs && SfxItemState::SET == pNewAttrs->GetItemState( nSlot, true, &pPoolItem ) ) { - if( !pPoolItem->StaticWhichCast(SID_ATTR_PARA_LEFT_TO_RIGHT).GetValue() ) - bLeftToRight = !bLeftToRight; + if (bLeftToRight) + { + if( !pPoolItem->StaticWhichCast(SID_ATTR_PARA_LEFT_TO_RIGHT).GetValue() ) + bLeftToRight = !bLeftToRight; + } + else + { + if( !pPoolItem->StaticWhichCast(SID_ATTR_PARA_RIGHT_TO_LEFT).GetValue() ) + bLeftToRight = !bLeftToRight; + } } SfxItemSet aAttr(SfxItemSet::makeFixedSfxItemSet< EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR, diff --git a/sw/source/uibase/shells/drwtxtex.cxx b/sw/source/uibase/shells/drwtxtex.cxx index 698cc1a3a2a4..e0bda8f5d7a7 100644 --- a/sw/source/uibase/shells/drwtxtex.cxx +++ b/sw/source/uibase/shells/drwtxtex.cxx @@ -617,8 +617,16 @@ void SwDrawTextShell::Execute( SfxRequest &rReq ) const SfxPoolItem* pPoolItem; if( pNewAttrs && SfxItemState::SET == pNewAttrs->GetItemState( nSlot, true, &pPoolItem ) ) { - if( !pPoolItem->StaticWhichCast(SID_ATTR_PARA_LEFT_TO_RIGHT).GetValue() ) - bLeftToRight = !bLeftToRight; + if (bLeftToRight) + { + if( !pPoolItem->StaticWhichCast(SID_ATTR_PARA_LEFT_TO_RIGHT).GetValue() ) + bLeftToRight = !bLeftToRight; + } + else + { + if( !pPoolItem->StaticWhichCast(SID_ATTR_PARA_RIGHT_TO_LEFT).GetValue() ) + bLeftToRight = !bLeftToRight; + } } SfxItemSet aAttr(SfxItemSet::makeFixedSfxItemSet< EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR,