diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-10-18 16:01:15 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-10-18 16:27:43 +0100 |
commit | f1a8aefec91f51a15c951f53f283a38a2edcd141 (patch) | |
tree | b47778798747e7f10b5377d72abcea781684dde7 /editeng | |
parent | b57ffef61afd61b57087150b1a9245e21079e15b (diff) |
Resolves: rhbz#1020712 return all the selected scripts
What we want here is *all* the scripts in the range, that's the whole point of
using SCRIPTTYPE. We use this to determine the font to show in the fontbox. If
it's an exclusive script then we can show the font that that script, and if
there are multiple scripts we know to set it empty.
With the other intermediate bugs out of the way, this now appears to work
correctly.
Change-Id: I58426123602d70c151bd878e96fa5cbab7d3fd3e
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index e7dbdc65b546..a9b69a7caef0 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -1803,28 +1803,31 @@ sal_uInt16 ImpEditEngine::GetScriptType( const EditSelection& rSel ) const const ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos; - // find the first(!) script type position that holds the - // complete selection. Thus it will work for selections as - // well as with just moving the cursor from char to char. + // find all the scripts of this range sal_uInt16 nS = ( nPara == nStartPara ) ? aSel.Min().GetIndex() : 0; sal_uInt16 nE = ( nPara == nEndPara ) ? aSel.Max().GetIndex() : pParaPortion->GetNode()->Len(); - for ( size_t n = 0; n < rTypes.size(); n++ ) + + //no selection, just bare cursor + if (nStartPara == nEndPara && nS == nE) + { + //If we are not at the start of the paragraph we want the properties of the + //preceding character. Otherwise get the properties of the next (or what the + //next would have if it existed) + if (nS != 0) + --nS; + else + ++nE; + } + + for (size_t n = 0; n < rTypes.size(); ++n) { - if (rTypes[n].nStartPos <= nS && nE <= rTypes[n].nEndPos) + bool bStartInRange = rTypes[n].nStartPos <= nS && nS < rTypes[n].nEndPos; + bool bEndInRange = rTypes[n].nStartPos < nE && nE <= rTypes[n].nEndPos; + + if (bStartInRange || bEndInRange) { if ( rTypes[n].nScriptType != i18n::ScriptType::WEAK ) - { nScriptType |= GetItemScriptType ( rTypes[n].nScriptType ); - } - else - { - if ( !nScriptType && n ) - { - // #93548# When starting with WEAK, use prev ScriptType... - nScriptType = rTypes[n-1].nScriptType; - } - } - break; } } } |