summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhaled Hosny <khaled@aliftype.com>2022-08-11 18:52:17 +0200
committerCaolán McNamara <caolanm@redhat.com>2022-08-14 21:11:15 +0200
commit72e56537d4bb9411229346da977d1d669ccfca9a (patch)
tree2d278306c50f35bac6963229f47b25504f462e02
parenttdf#137528: Sync Kashida algorithm in editeng with sw (diff)
downloadcore-72e56537d4bb9411229346da977d1d669ccfca9a.tar.gz
core-72e56537d4bb9411229346da977d1d669ccfca9a.zip
tdf#139627: Don’t set Kashida insertion position after combining marks
We were skipping the marks when checking for previous char, but not when setting the index to previous char. Fixes also the second part of tdf#106653. Change-Id: I73436ba9df6ccf104ea6d4dfbd76a59c86040a44 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138154 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--editeng/source/editeng/impedit3.cxx18
-rw-r--r--sw/source/core/text/porlay.cxx18
2 files changed, 20 insertions, 16 deletions
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index d7129999dfa5..6195b0e8e606 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -2339,10 +2339,9 @@ void ImpEditEngine::ImpFindKashidas( ContentNode* pNode, sal_Int32 nStart, sal_I
// restore selection for proper iteration at the end of the function
aWordSel.Max().SetIndex( nSavPos );
- sal_Int32 nIdx = 0;
+ sal_Int32 nIdx = 0, nPrevIdx = 0;
sal_Int32 nKashidaPos = -1;
- sal_Unicode cCh;
- sal_Unicode cPrevCh = 0;
+ sal_Unicode cCh, cPrevCh = 0;
int nPriorityLevel = 7; // 0..6 = level found
// 7 not found
@@ -2390,7 +2389,7 @@ void ImpEditEngine::ImpFindKashidas( ContentNode* pNode, sal_Int32 nStart, sal_I
// check if character is connectable to previous character,
if ( lcl_ConnectToPrev( cCh, cPrevCh ) )
{
- nKashidaPos = aWordSel.Min().GetIndex() + nIdx - 1;
+ nKashidaPos = aWordSel.Min().GetIndex() + nPrevIdx;
nPriorityLevel = 2;
}
}
@@ -2411,7 +2410,7 @@ void ImpEditEngine::ImpFindKashidas( ContentNode* pNode, sal_Int32 nStart, sal_I
// check if character is connectable to previous character,
if ( lcl_ConnectToPrev( cCh, cPrevCh ) )
{
- nKashidaPos = aWordSel.Min().GetIndex() + nIdx - 1;
+ nKashidaPos = aWordSel.Min().GetIndex() + nPrevIdx;
nPriorityLevel = 3;
}
}
@@ -2431,7 +2430,7 @@ void ImpEditEngine::ImpFindKashidas( ContentNode* pNode, sal_Int32 nStart, sal_I
// check if character is connectable to previous character,
if ( lcl_ConnectToPrev( cCh, cPrevCh ) )
{
- nKashidaPos = aWordSel.Min().GetIndex() + nIdx - 1;
+ nKashidaPos = aWordSel.Min().GetIndex() + nPrevIdx;
nPriorityLevel = 4;
}
}
@@ -2453,7 +2452,7 @@ void ImpEditEngine::ImpFindKashidas( ContentNode* pNode, sal_Int32 nStart, sal_I
// check if character is connectable to previous character,
if ( lcl_ConnectToPrev( cCh, cPrevCh ) )
{
- nKashidaPos = aWordSel.Min().GetIndex() + nIdx - 1;
+ nKashidaPos = aWordSel.Min().GetIndex() + nPrevIdx;
nPriorityLevel = 5;
}
}
@@ -2469,7 +2468,7 @@ void ImpEditEngine::ImpFindKashidas( ContentNode* pNode, sal_Int32 nStart, sal_I
// check if character is connectable to previous character,
if ( lcl_ConnectToPrev( cCh, cPrevCh ) )
{
- nKashidaPos = aWordSel.Min().GetIndex() + nIdx - 1;
+ nKashidaPos = aWordSel.Min().GetIndex() + nPrevIdx;
nPriorityLevel = 6;
}
}
@@ -2478,7 +2477,10 @@ void ImpEditEngine::ImpFindKashidas( ContentNode* pNode, sal_Int32 nStart, sal_I
// Do not consider vowel marks when checking if a character
// can be connected to previous character.
if ( !isTransparentChar ( cCh) )
+ {
cPrevCh = cCh;
+ nPrevIdx = nIdx;
+ }
++nIdx;
} // end of current word
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 3db6a07600e9..d1e4b967f235 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -1509,10 +1509,9 @@ void SwScriptInfo::InitScriptInfo(const SwTextNode& rNode,
{
const OUString& rWord = aScanner.GetWord();
- sal_Int32 nIdx = 0;
+ sal_Int32 nIdx = 0, nPrevIdx = 0;
sal_Int32 nKashidaPos = -1;
- sal_Unicode cCh;
- sal_Unicode cPrevCh = 0;
+ sal_Unicode cCh, cPrevCh = 0;
int nPriorityLevel = 7; // 0..6 = level found
// 7 not found
@@ -1560,7 +1559,7 @@ void SwScriptInfo::InitScriptInfo(const SwTextNode& rNode,
// check if character is connectable to previous character,
if ( lcl_ConnectToPrev( cCh, cPrevCh ) )
{
- nKashidaPos = aScanner.GetBegin() + nIdx - 1;
+ nKashidaPos = aScanner.GetBegin() + nPrevIdx;
nPriorityLevel = 2;
}
}
@@ -1581,7 +1580,7 @@ void SwScriptInfo::InitScriptInfo(const SwTextNode& rNode,
// check if character is connectable to previous character,
if ( lcl_ConnectToPrev( cCh, cPrevCh ) )
{
- nKashidaPos = aScanner.GetBegin() + nIdx - 1;
+ nKashidaPos = aScanner.GetBegin() + nPrevIdx;
nPriorityLevel = 3;
}
}
@@ -1601,7 +1600,7 @@ void SwScriptInfo::InitScriptInfo(const SwTextNode& rNode,
// check if character is connectable to previous character,
if ( lcl_ConnectToPrev( cCh, cPrevCh ) )
{
- nKashidaPos = aScanner.GetBegin() + nIdx - 1;
+ nKashidaPos = aScanner.GetBegin() + nPrevIdx;
nPriorityLevel = 4;
}
}
@@ -1623,7 +1622,7 @@ void SwScriptInfo::InitScriptInfo(const SwTextNode& rNode,
// check if character is connectable to previous character,
if ( lcl_ConnectToPrev( cCh, cPrevCh ) )
{
- nKashidaPos = aScanner.GetBegin() + nIdx - 1;
+ nKashidaPos = aScanner.GetBegin() + nPrevIdx;
nPriorityLevel = 5;
}
}
@@ -1639,7 +1638,7 @@ void SwScriptInfo::InitScriptInfo(const SwTextNode& rNode,
// check if character is connectable to previous character,
if ( lcl_ConnectToPrev( cCh, cPrevCh ) )
{
- nKashidaPos = aScanner.GetBegin() + nIdx - 1;
+ nKashidaPos = aScanner.GetBegin() + nPrevIdx;
nPriorityLevel = 6;
}
}
@@ -1648,7 +1647,10 @@ void SwScriptInfo::InitScriptInfo(const SwTextNode& rNode,
// Do not consider vowel marks when checking if a character
// can be connected to previous character.
if ( !isTransparentChar ( cCh) )
+ {
cPrevCh = cCh;
+ nPrevIdx = nIdx;
+ }
++nIdx;
} // end of current word