Skip to content

Commit

Permalink
tdf#147143 Word selection error in Arabic text
Browse files Browse the repository at this point in the history
this reverts
    commit 563af8f
    Author: Noel Grandin <noelgrandin@gmail.com>
    Date:   Fri Jan 7 22:50:29 2022 +0200
    tdf#144890 Invalid selection area when text in LTR run
and
    commit ec50b9e
    Author: Noel Grandin <noel.grandin@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.grandin@collabora.co.uk>
  • Loading branch information
Noel Grandin committed Mar 14, 2022
1 parent 6ba9daa commit 22be166
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions sw/inc/crstate.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <tools/gen.hxx>
#include "swrect.hxx"

#include <optional>
#include <memory>

enum class SwFillMode
{
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions sw/source/core/layout/trvlfrm.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions sw/source/core/text/frmcrsr.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}

Expand All @@ -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 );
}
}

Expand Down
30 changes: 15 additions & 15 deletions sw/source/core/text/itrcrsr.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -681,26 +681,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 )
Expand All @@ -710,9 +710,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
Expand Down Expand Up @@ -1220,12 +1220,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();
Expand Down

0 comments on commit 22be166

Please sign in to comment.