cui/source/inc/swpossizetabpage.hxx      |    1 +
 cui/source/tabpages/swpossizetabpage.cxx |   27 +++++++++++++++++++++------
 sw/source/uibase/shells/drwbassh.cxx     |   10 ++++++++++
 3 files changed, 32 insertions(+), 6 deletions(-)

New commits:
commit 0f410680461d7ba5f70dd65b2a8263dec15ac357
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Fri May 3 08:08:29 2024 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri May 3 13:51:08 2024 +0200

    tdf#160833 sw DoNotMirrorRtlDrawObjs: add UI in cui/
    
    The UI code at lcl_ChangeResIdToVerticalOrRTL() was aware that
    SwAnchoredObjectPosition::CalcRelPosX() mirrors the position when the
    anchor paragraph is RTL, so swapped the "from left" label to a "from
    right" label.
    
    Don't do this when the compat option is enabled, so not only we render
    correctly but the UI now correctly explains why we came up with the
    correct position.
    
    Change-Id: I479ed1f085b249d10be47b66d7a656dc1bd4f936
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167031
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/cui/source/inc/swpossizetabpage.hxx 
b/cui/source/inc/swpossizetabpage.hxx
index 2e5a15fbebbb..037cede29326 100644
--- a/cui/source/inc/swpossizetabpage.hxx
+++ b/cui/source/inc/swpossizetabpage.hxx
@@ -53,6 +53,7 @@ class SvxSwPosSizeTabPage : public SfxTabPage
     bool    m_bPositioningDisabled;
     bool    m_bIsMultiSelection;
     bool    m_bIsInRightToLeft;
+    bool m_bDoNotMirrorRtlDrawObjs = false;
     TriState    m_nProtectSizeState;
 
     SwFrameExample m_aExampleWN;
diff --git a/cui/source/tabpages/swpossizetabpage.cxx 
b/cui/source/tabpages/swpossizetabpage.cxx
index 1a0d14759eac..752af91a1a62 100644
--- a/cui/source/tabpages/swpossizetabpage.cxx
+++ b/cui/source/tabpages/swpossizetabpage.cxx
@@ -37,6 +37,7 @@
 #include <svx/svxids.hrc>
 #include <svtools/unitconv.hxx>
 #include <osl/diagnose.h>
+#include <svl/grabbagitem.hxx>
 
 #include <bitmaps.hlst>
 
@@ -433,14 +434,16 @@ static std::size_t lcl_GetFrmMapCount(const FrmMap* pMap)
 }
 
 static SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL(
-            SvxSwFramePosString::StringId eStringId, bool bVertical, bool bRTL)
+            SvxSwFramePosString::StringId eStringId, bool bVertical, bool 
bRTL, bool bDontMirrorRTL)
 {
     //special handling of STR_FROMLEFT
     if(SvxSwFramePosString::FROMLEFT == eStringId)
     {
+        bool bMirrorRtlDrawObjs = !bDontMirrorRTL;
+        bool bSwapLR = bRTL && bMirrorRtlDrawObjs;
         eStringId = bVertical ?
             bRTL ? SvxSwFramePosString::FROMBOTTOM : 
SvxSwFramePosString::FROMTOP :
-            bRTL ? SvxSwFramePosString::FROMRIGHT : 
SvxSwFramePosString::FROMLEFT;
+            bSwapLR ? SvxSwFramePosString::FROMRIGHT : 
SvxSwFramePosString::FROMLEFT;
         return eStringId;
     }
     if(bVertical)
@@ -749,7 +752,8 @@ WhichRangesContainer SvxSwPosSizeTabPage::GetRanges()
         SID_ATTR_TRANSFORM_AUTOWIDTH, SID_ATTR_TRANSFORM_VERT_ORIENT,
         SID_HTML_MODE, SID_HTML_MODE,
         SID_SW_FOLLOW_TEXT_FLOW, SID_SW_FOLLOW_TEXT_FLOW,
-        SID_ATTR_TRANSFORM_HORI_POSITION, SID_ATTR_TRANSFORM_VERT_POSITION
+        SID_ATTR_TRANSFORM_HORI_POSITION, SID_ATTR_TRANSFORM_VERT_POSITION,
+        SID_ATTR_CHAR_GRABBAG, SID_ATTR_CHAR_GRABBAG
     >);
     return ranges;
 }
@@ -988,6 +992,17 @@ void SvxSwPosSizeTabPage::Reset( const SfxItemSet* rSet)
     }
     m_xFollowCB->save_state();
 
+    const SfxGrabBagItem* pGrabBag = GetItem(*rSet, SID_ATTR_CHAR_GRABBAG);
+    if (pGrabBag)
+    {
+        const std::map<OUString, css::uno::Any>& rMap = pGrabBag->GetGrabBag();
+        auto it = rMap.find("DoNotMirrorRtlDrawObjs");
+        if (it != rMap.end())
+        {
+            it->second >>= m_bDoNotMirrorRtlDrawObjs;
+        }
+    }
+
     if(m_bHtmlMode)
     {
         m_xHoriMirrorCB->hide();
@@ -1677,7 +1692,7 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, 
sal_uInt16 nMapPos, sal_
                         {
                             SvxSwFramePosString::StringId sStrId1 = 
aAsCharRelationMap[nRelPos].eStrId;
 
-                            sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, 
m_bIsVerticalFrame, m_bIsInRightToLeft);
+                            sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, 
m_bIsVerticalFrame, m_bIsInRightToLeft, m_bDoNotMirrorRtlDrawObjs);
                             OUString sEntry = 
SvxSwFramePosString::GetString(sStrId1);
                             
rLB.append(weld::toId(&aAsCharRelationMap[nRelPos]), sEntry);
                             if (pMap[_nMapPos].nAlign == nAlign)
@@ -1732,7 +1747,7 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, 
sal_uInt16 nMapPos, sal_
                         if (aRelationMap[nRelPos].nLBRelation == 
static_cast<LB>(nBit))
                         {
                             SvxSwFramePosString::StringId sStrId1 = 
m_xHoriMirrorCB->get_active() ? aRelationMap[nRelPos].eMirrorStrId : 
aRelationMap[nRelPos].eStrId;
-                            sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, 
m_bIsVerticalFrame, m_bIsInRightToLeft);
+                            sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, 
m_bIsVerticalFrame, m_bIsInRightToLeft, m_bDoNotMirrorRtlDrawObjs);
                             OUString sEntry = 
SvxSwFramePosString::GetString(sStrId1);
                             rLB.append(weld::toId(&aRelationMap[nRelPos]), 
sEntry);
                             if (sSelEntry.isEmpty() && 
aRelationMap[nRelPos].nRelation == nRel)
@@ -1809,7 +1824,7 @@ sal_uInt16 SvxSwPosSizeTabPage::FillPosLB(FrmMap const 
*_pMap,
     for (std::size_t i = 0; _pMap && i < nCount; ++i)
     {
         SvxSwFramePosString::StringId eStrId = m_xHoriMirrorCB->get_active() ? 
_pMap[i].eMirrorStrId : _pMap[i].eStrId;
-        eStrId = lcl_ChangeResIdToVerticalOrRTL(eStrId, m_bIsVerticalFrame, 
m_bIsInRightToLeft);
+        eStrId = lcl_ChangeResIdToVerticalOrRTL(eStrId, m_bIsVerticalFrame, 
m_bIsInRightToLeft, m_bDoNotMirrorRtlDrawObjs);
         OUString sEntry(SvxSwFramePosString::GetString(eStrId));
         if (_rLB.find_text(sEntry) == -1)
         {
diff --git a/sw/source/uibase/shells/drwbassh.cxx 
b/sw/source/uibase/shells/drwbassh.cxx
index 39d5882c9666..44e838b96ca7 100644
--- a/sw/source/uibase/shells/drwbassh.cxx
+++ b/sw/source/uibase/shells/drwbassh.cxx
@@ -60,6 +60,8 @@
 #include <fmtfollowtextflow.hxx>
 #include <textboxhelper.hxx>
 #include <svx/diagram/IDiagramHelper.hxx>
+#include <svl/grabbagitem.hxx>
+#include <IDocumentSettingAccess.hxx>
 
 using namespace ::com::sun::star;
 using namespace css::beans;
@@ -243,6 +245,14 @@ void SwDrawBaseShell::Execute(SfxRequest& rReq)
                         aSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_HORI_MIRROR, 
aHOrient.IsPosToggle()));
                         
aSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_HORI_POSITION, aHOrient.GetPos()));
 
+                        const IDocumentSettingAccess& rIDSA = 
pFrameFormat->getIDocumentSettingAccess();
+                        if 
(rIDSA.get(DocumentSettingId::DO_NOT_MIRROR_RTL_DRAW_OBJS))
+                        {
+                            SfxGrabBagItem aItem(RES_CHRATR_GRABBAG);
+                            aItem.GetGrabBag()["DoNotMirrorRtlDrawObjs"] <<= 
true;
+                            aSet.Put(aItem);
+                        }
+
                         aSet.Put(SfxUInt16Item(SID_HTML_MODE, nHtmlMode));
 
                         pDlg->SetInputSet( &aSet );

Reply via email to