sw/inc/crstate.hxx                |    4 ++--
 sw/source/core/layout/trvlfrm.cxx |    6 +++---
 sw/source/core/text/frmcrsr.cxx   |   12 ++++++------
 sw/source/core/text/itrcrsr.cxx   |   30 +++++++++++++++---------------
 4 files changed, 26 insertions(+), 26 deletions(-)

New commits:
commit 1b94a54826d4f8a4ae0c670868c317d68e246e3e
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Mar 14 14:03:56 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Mar 14 17:02:41 2022 +0100

    tdf#147143 Word selection error in Arabic text
    
    this reverts
        commit 563af8fd15aa37e75af8882cccbdf8914ebe8e61
        Author: Noel Grandin <noelgran...@gmail.com>
        Date:   Fri Jan 7 22:50:29 2022 +0200
        tdf#144890 Invalid selection area when text in LTR run
    and
        commit ec50b9e5eaec7c94df35617676077ef0d65cecc7
        Author: Noel Grandin <noel.gran...@collabora.co.uk>
        Date:   Thu May 27 11:16:11 2021 +0200
        no need to allocate Sw2LinesPos separately on heap
    
    No idea why the commits caused trouble, clearing there is some
    "interesting" interaction going on.
    
    Change-Id: I606768403db777b61554f378d3f69f9b4d33d493
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131533
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    (cherry picked from commit 22be1665dc6eb28ea1d52c7c5e4347628fc5a76b)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131477
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/inc/crstate.hxx b/sw/inc/crstate.hxx
index f3430c714787..9b223319fd93 100644
--- a/sw/inc/crstate.hxx
+++ b/sw/inc/crstate.hxx
@@ -23,7 +23,7 @@
 #include <tools/gen.hxx>
 #include "swrect.hxx"
 
-#include <optional>
+#include <memory>
 
 enum class SwFillMode
 {
@@ -132,7 +132,7 @@ enum class CursorMoveState
 struct SwCursorMoveState
 {
     SwFillCursorPos   *m_pFill;     ///< for automatic filling with tabs etc
-    std::optional<Sw2LinesPos> m_x2Lines;   ///< for selections inside/around 
2line portions
+    std::unique_ptr<Sw2LinesPos> m_p2Lines;   ///< for selections 
inside/around 2line portions
     SwSpecialPos*   m_pSpecialPos; ///< for positions inside fields
     Point m_aRealHeight;          ///< contains then the position/height of 
the cursor
     CursorMoveState m_eState;
diff --git a/sw/source/core/layout/trvlfrm.cxx 
b/sw/source/core/layout/trvlfrm.cxx
index 0e99d2b3bd0a..6942dab6a2ba 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -2124,11 +2124,11 @@ void SwRootFrame::CalcFrameRects(SwShellCursor &rCursor)
     //ContentRects to Start- and EndFrames.
     SwRect aStRect, aEndRect;
     pStartFrame->GetCharRect( aStRect, *pStartPos, &aTmpState );
-    std::optional<Sw2LinesPos> pSt2Pos = std::move(aTmpState.m_x2Lines);
+    std::unique_ptr<Sw2LinesPos> pSt2Pos = std::move(aTmpState.m_p2Lines);
     aTmpState.m_nCursorBidiLevel = pEndFrame->IsRightToLeft() ? 1 : 0;
 
     pEndFrame->GetCharRect( aEndRect, *pEndPos, &aTmpState );
-    std::optional<Sw2LinesPos> pEnd2Pos = std::move(aTmpState.m_x2Lines);
+    std::unique_ptr<Sw2LinesPos> pEnd2Pos = std::move(aTmpState.m_p2Lines);
 
     SwRect aStFrame ( pStartFrame->UnionFrame( true ) );
     aStFrame.Intersection( pStartFrame->GetPaintArea() );
@@ -2145,7 +2145,7 @@ void SwRootFrame::CalcFrameRects(SwShellCursor &rCursor)
     // If there's no doubleline portion involved or start and end are both
     // in the same doubleline portion, all works fine, but otherwise
     // we need the following...
-    if( (!pSt2Pos && !pEnd2Pos) && ( !pSt2Pos || !pEnd2Pos ||
+    if( pSt2Pos != pEnd2Pos && ( !pSt2Pos || !pEnd2Pos ||
         pSt2Pos->aPortion != pEnd2Pos->aPortion ) )
     {
         // If we have a start(end) position inside a doubleline portion
diff --git a/sw/source/core/text/frmcrsr.cxx b/sw/source/core/text/frmcrsr.cxx
index 0eb130848f3d..58792ecf80d6 100644
--- a/sw/source/core/text/frmcrsr.cxx
+++ b/sw/source/core/text/frmcrsr.cxx
@@ -307,10 +307,10 @@ bool SwTextFrame::GetCharRect( SwRect& rOrig, const 
SwPosition &rPos,
         {
             if ( pFrame->IsRightToLeft() )
             {
-                if( pCMS->m_b2Lines && pCMS->m_x2Lines)
+                if( pCMS->m_b2Lines && pCMS->m_p2Lines)
                 {
-                    pFrame->SwitchLTRtoRTL( pCMS->m_x2Lines->aLine );
-                    pFrame->SwitchLTRtoRTL( pCMS->m_x2Lines->aPortion );
+                    pFrame->SwitchLTRtoRTL( pCMS->m_p2Lines->aLine );
+                    pFrame->SwitchLTRtoRTL( pCMS->m_p2Lines->aPortion );
                 }
             }
 
@@ -327,10 +327,10 @@ bool SwTextFrame::GetCharRect( SwRect& rOrig, const 
SwPosition &rPos,
                                                    pCMS->m_aRealHeight.Y() );
                     }
                 }
-                if( pCMS->m_b2Lines && pCMS->m_x2Lines)
+                if( pCMS->m_b2Lines && pCMS->m_p2Lines)
                 {
-                    pFrame->SwitchHorizontalToVertical( pCMS->m_x2Lines->aLine 
);
-                    pFrame->SwitchHorizontalToVertical( 
pCMS->m_x2Lines->aPortion );
+                    pFrame->SwitchHorizontalToVertical( pCMS->m_p2Lines->aLine 
);
+                    pFrame->SwitchHorizontalToVertical( 
pCMS->m_p2Lines->aPortion );
                 }
             }
 
diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx
index 7d60210fba7b..d9d87aaa713c 100644
--- a/sw/source/core/text/itrcrsr.cxx
+++ b/sw/source/core/text/itrcrsr.cxx
@@ -676,26 +676,26 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, 
TextFrameIndex const nOfst,
 
                         if( pCMS && pCMS->m_b2Lines )
                         {
-                            const bool bRecursion (pCMS->m_x2Lines);
+                            const bool bRecursion (pCMS->m_p2Lines);
                             if ( !bRecursion )
                             {
-                                pCMS->m_x2Lines = Sw2LinesPos();
-                                pCMS->m_x2Lines->aLine = SwRect(aCharPos, 
aCharSize);
+                                pCMS->m_p2Lines.reset(new Sw2LinesPos);
+                                pCMS->m_p2Lines->aLine = SwRect(aCharPos, 
aCharSize);
                             }
 
                             if( 
static_cast<SwMultiPortion*>(pPor)->HasRotation() )
                             {
                                 if( 
static_cast<SwMultiPortion*>(pPor)->IsRevers() )
-                                    pCMS->m_x2Lines->nMultiType = 
MultiPortionType::ROT_270;
+                                    pCMS->m_p2Lines->nMultiType = 
MultiPortionType::ROT_270;
                                 else
-                                    pCMS->m_x2Lines->nMultiType = 
MultiPortionType::ROT_90;
+                                    pCMS->m_p2Lines->nMultiType = 
MultiPortionType::ROT_90;
                             }
                             else if( 
static_cast<SwMultiPortion*>(pPor)->IsDouble() )
-                                pCMS->m_x2Lines->nMultiType = 
MultiPortionType::TWOLINE;
+                                pCMS->m_p2Lines->nMultiType = 
MultiPortionType::TWOLINE;
                             else if( 
static_cast<SwMultiPortion*>(pPor)->IsBidi() )
-                                pCMS->m_x2Lines->nMultiType = 
MultiPortionType::BIDI;
+                                pCMS->m_p2Lines->nMultiType = 
MultiPortionType::BIDI;
                             else
-                                pCMS->m_x2Lines->nMultiType = 
MultiPortionType::RUBY;
+                                pCMS->m_p2Lines->nMultiType = 
MultiPortionType::RUBY;
 
                             SwTwips nTmpWidth = pPor->Width();
                             if( nSpaceAdd )
@@ -705,9 +705,9 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, 
TextFrameIndex const nOfst,
                                           Size( nTmpWidth, pPor->Height() ) );
 
                             if ( ! bRecursion )
-                                pCMS->m_x2Lines->aPortion = aRect;
+                                pCMS->m_p2Lines->aPortion = aRect;
                             else
-                                pCMS->m_x2Lines->aPortion2 = aRect;
+                                pCMS->m_p2Lines->aPortion2 = aRect;
                         }
 
                         // In a multi-portion we use GetCharRect()-function
@@ -1215,12 +1215,12 @@ void SwTextCursor::GetCharRect( SwRect* pOrig, 
TextFrameIndex const nOfst,
     pOrig->Pos().AdjustX(aCharPos.X() );
     pOrig->Pos().AdjustY(aCharPos.Y() );
 
-    if( pCMS && pCMS->m_b2Lines && pCMS->m_x2Lines )
+    if( pCMS && pCMS->m_b2Lines && pCMS->m_p2Lines )
     {
-        pCMS->m_x2Lines->aLine.Pos().AdjustX(aCharPos.X() );
-        pCMS->m_x2Lines->aLine.Pos().AdjustY(aCharPos.Y() );
-        pCMS->m_x2Lines->aPortion.Pos().AdjustX(aCharPos.X() );
-        pCMS->m_x2Lines->aPortion.Pos().AdjustY(aCharPos.Y() );
+        pCMS->m_p2Lines->aLine.Pos().AdjustX(aCharPos.X() );
+        pCMS->m_p2Lines->aLine.Pos().AdjustY(aCharPos.Y() );
+        pCMS->m_p2Lines->aPortion.Pos().AdjustX(aCharPos.X() );
+        pCMS->m_p2Lines->aPortion.Pos().AdjustY(aCharPos.Y() );
     }
 
     const IDocumentSettingAccess& rIDSA = 
GetTextFrame()->GetDoc().getIDocumentSettingAccess();

Reply via email to