editeng/source/editeng/editeng.cxx | 4 +-- editeng/source/editeng/impedit.hxx | 8 +++--- editeng/source/editeng/impedit2.cxx | 45 +++++++++++++++++++----------------- editeng/source/editeng/impedit3.cxx | 14 +++++------ editeng/source/editeng/impedit4.cxx | 14 +++++------ include/tools/string.hxx | 2 - tools/source/string/tustring.cxx | 26 -------------------- 7 files changed, 44 insertions(+), 69 deletions(-)
New commits: commit 9567fbdff6141a605f54df77ddcae173467d5cba Author: Caolán McNamara <caol...@redhat.com> Date: Fri Oct 18 16:21:33 2013 +0100 disambiguate GetScriptType that return different value types Change-Id: I694d81d17fac5fbd964937dc654ebd764af90842 diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 6b7538d..dfc9713 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -511,7 +511,7 @@ sal_uInt16 EditEngine::GetScriptType( const ESelection& rSelection ) const { DBG_CHKTHIS( EditEngine, 0 ); EditSelection aSel( pImpEditEngine->CreateSel( rSelection ) ); - return pImpEditEngine->GetScriptType( aSel ); + return pImpEditEngine->GetItemScriptType( aSel ); } LanguageType EditEngine::GetLanguage(const EditPaM& rPaM) const @@ -739,7 +739,7 @@ const ParaPortion* EditEngine::GetPrevVisPortion(const ParaPortion* pCurPortion) sal_uInt16 EditEngine::GetScriptType(const EditSelection& rSel) const { - return pImpEditEngine->GetScriptType(rSel); + return pImpEditEngine->GetItemScriptType(rSel); } void EditEngine::RemoveParaPortion(sal_Int32 nNode) diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 2ded5c5..1cd40de 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -592,10 +592,10 @@ private: void InitScriptTypes( sal_Int32 nPara ); - sal_uInt16 GetScriptType( const EditPaM& rPaM, sal_uInt16* pEndPos = NULL ) const; - sal_uInt16 GetScriptType( const EditSelection& rSel ) const; - sal_Bool IsScriptChange( const EditPaM& rPaM ) const; - sal_Bool HasScriptType( sal_Int32 nPara, sal_uInt16 nType ) const; + sal_uInt16 GetI18NScriptType( const EditPaM& rPaM, sal_uInt16* pEndPos = NULL ) const; + sal_uInt16 GetItemScriptType( const EditSelection& rSel ) const; + sal_Bool IsScriptChange( const EditPaM& rPaM ) const; + sal_Bool HasScriptType( sal_Int32 nPara, sal_uInt16 nType ) const; sal_Bool ImplCalcAsianCompression( ContentNode* pNode, TextPortion* pTextPortion, sal_uInt16 nStartPos, sal_Int32* pDXArray, sal_uInt16 n100thPercentFromMax, sal_Bool bManipulateDXArray ); void ImplExpandCompressedPortions( EditLine* pLine, ParaPortion* pParaPortion, long nRemainingWidth ); diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index a9b69a7..e8cf38d4 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -1757,7 +1757,7 @@ private: } -sal_uInt16 ImpEditEngine::GetScriptType( const EditPaM& rPaM, sal_uInt16* pEndPos ) const +sal_uInt16 ImpEditEngine::GetI18NScriptType( const EditPaM& rPaM, sal_uInt16* pEndPos ) const { sal_uInt16 nScriptType = 0; @@ -1785,7 +1785,7 @@ sal_uInt16 ImpEditEngine::GetScriptType( const EditPaM& rPaM, sal_uInt16* pEndPo return nScriptType ? nScriptType : GetI18NScriptTypeOfLanguage( GetDefaultLanguage() ); } -sal_uInt16 ImpEditEngine::GetScriptType( const EditSelection& rSel ) const +sal_uInt16 ImpEditEngine::GetItemScriptType( const EditSelection& rSel ) const { EditSelection aSel( rSel ); aSel.Adjust( aEditDoc ); @@ -1827,7 +1827,7 @@ sal_uInt16 ImpEditEngine::GetScriptType( const EditSelection& rSel ) const if (bStartInRange || bEndInRange) { if ( rTypes[n].nScriptType != i18n::ScriptType::WEAK ) - nScriptType |= GetItemScriptType ( rTypes[n].nScriptType ); + nScriptType |= ::GetItemScriptType( rTypes[n].nScriptType ); } } } @@ -3775,7 +3775,7 @@ sal_uInt16 ImpEditEngine::GetChar( if ( nChar && ( nChar < pParaPortion->GetNode()->Len() ) ) { EditPaM aPaM( pParaPortion->GetNode(), nChar+1 ); - sal_uInt16 nScriptType = GetScriptType( aPaM ); + sal_uInt16 nScriptType = GetI18NScriptType( aPaM ); if ( nScriptType == i18n::ScriptType::COMPLEX ) { uno::Reference < i18n::XBreakIterator > _xBI( ImplGetBreakIterator() ); diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index 8e66ec1..d100109 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -1095,8 +1095,8 @@ sal_Bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) if( bScriptSpace && ( _nPortionEnd < pNode->Len() ) && ( nTmpWidth < nXWidth ) && IsScriptChange( EditPaM( pNode, _nPortionEnd ) ) ) { sal_Bool bAllow = sal_False; - sal_uInt16 nScriptTypeLeft = GetScriptType( EditPaM( pNode, _nPortionEnd ) ); - sal_uInt16 nScriptTypeRight = GetScriptType( EditPaM( pNode, _nPortionEnd+1 ) ); + sal_uInt16 nScriptTypeLeft = GetI18NScriptType( EditPaM( pNode, _nPortionEnd ) ); + sal_uInt16 nScriptTypeRight = GetI18NScriptType( EditPaM( pNode, _nPortionEnd+1 ) ); if ( ( nScriptTypeLeft == i18n::ScriptType::ASIAN ) || ( nScriptTypeRight == i18n::ScriptType::ASIAN ) ) bAllow = sal_True; @@ -2002,7 +2002,7 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine, { EditPaM aPaM( pNode, nChar+1 ); LanguageType eLang = GetLanguage(aPaM); - sal_uInt16 nScript = GetScriptType(aPaM); + sal_uInt16 nScript = GetI18NScriptType(aPaM); if ( MsLangId::getPrimaryLanguage( eLang) == LANGUAGE_ARABIC_PRIMARY_ONLY ) // Arabic script is handled later. continue; @@ -2556,7 +2556,7 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_uInt16 nPos, SvxFont& rF rFont = pNode->GetCharAttribs().GetDefFont(); - short nScriptType = GetScriptType( EditPaM( pNode, nPos ) ); + short nScriptType = GetI18NScriptType( EditPaM( pNode, nPos ) ); if ( ( nScriptType == i18n::ScriptType::ASIAN ) || ( nScriptType == i18n::ScriptType::COMPLEX ) ) { const SvxFontItem& rFontItem = (const SvxFontItem&)pNode->GetContentAttribs().GetItem( GetScriptItemId( EE_CHAR_FONTINFO, nScriptType ) ); @@ -3012,7 +3012,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt aTmpFont.SetFillColor( COL_LIGHTGRAY ); aTmpFont.SetTransparent( sal_False ); } - else if ( GetScriptType( EditPaM( pPortion->GetNode(), nIndex+1 ) ) == i18n::ScriptType::COMPLEX ) + else if ( GetI18NScriptType( EditPaM( pPortion->GetNode(), nIndex+1 ) ) == i18n::ScriptType::COMPLEX ) { aTmpFont.SetFillColor( COL_LIGHTCYAN ); aTmpFont.SetTransparent( sal_False ); @@ -4303,7 +4303,7 @@ void ImpEditEngine::ImplInitLayoutMode( OutputDevice* pOutDev, sal_Int32 nPara, else { ContentNode* pNode = GetEditDoc().GetObject( nPara ); - short nScriptType = GetScriptType( EditPaM( pNode, nIndex+1 ) ); + short nScriptType = GetI18NScriptType( EditPaM( pNode, nIndex+1 ) ); bCTL = nScriptType == i18n::ScriptType::COMPLEX; // this change was discussed in issue 37190 bR2L = GetRightToLeft( nPara, nIndex + 1) % 2 ? sal_True : sal_False; @@ -4385,7 +4385,7 @@ sal_Bool ImpEditEngine::ImplCalcAsianCompression( ContentNode* pNode, TextPortio sal_Bool bCompressed = sal_False; - if ( GetScriptType( EditPaM( pNode, nStartPos+1 ) ) == i18n::ScriptType::ASIAN ) + if ( GetI18NScriptType( EditPaM( pNode, nStartPos+1 ) ) == i18n::ScriptType::ASIAN ) { long nNewPortionWidth = pTextPortion->GetSize().Width(); sal_uInt16 nPortionLen = pTextPortion->GetLen(); diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index d04545d..3ec19db 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -598,7 +598,7 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) if ( nStartPos != 0 ) { aAttribItems.Clear(); - lcl_FindValidAttribs( aAttribItems, pNode, nStartPos, GetScriptType( EditPaM( pNode, 0 ) ) ); + lcl_FindValidAttribs( aAttribItems, pNode, nStartPos, GetI18NScriptType( EditPaM( pNode, 0 ) ) ); if ( aAttribItems.Count() ) { // These attributes may not apply to the entire paragraph: @@ -634,7 +634,7 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) else { aAttribItems.Clear(); - sal_uInt16 nScriptType = GetScriptType( EditPaM( pNode, nIndex+1 ) ); + sal_uInt16 nScriptType = GetI18NScriptType( EditPaM( pNode, nIndex+1 ) ); if ( !n || IsScriptChange( EditPaM( pNode, nIndex ) ) ) { SfxItemSet aAttribs = GetAttribs( nNode, nIndex+1, nIndex+1 ); @@ -1029,7 +1029,7 @@ EditTextObject* ImpEditEngine::CreateTextObject( EditSelection aSel, SfxItemPool // Templates are not saved! // (Only the name and family, template itself must be in App!) - pTxtObj->mpImpl->SetScriptType(GetScriptType(aSel)); + pTxtObj->mpImpl->SetScriptType(GetItemScriptType(aSel)); // iterate over the paragraphs ... sal_Int32 nNode; @@ -1414,7 +1414,7 @@ void ImpEditEngine::SetAllMisspellRanges( const std::vector<editeng::MisspellRan LanguageType ImpEditEngine::GetLanguage( const EditPaM& rPaM, sal_uInt16* pEndPos ) const { - short nScriptType = GetScriptType( rPaM, pEndPos ); // pEndPos will be valid now, pointing to ScriptChange or NodeLen + short nScriptType = GetI18NScriptType( rPaM, pEndPos ); // pEndPos will be valid now, pointing to ScriptChange or NodeLen sal_uInt16 nLangId = GetScriptItemId( EE_CHAR_LANGUAGE, nScriptType ); const SvxLanguageItem* pLangItem = &(const SvxLanguageItem&)rPaM.GetNode()->GetContentAttribs().GetItem( nLangId ); const EditCharAttrib* pAttr = rPaM.GetNode()->GetCharAttribs().FindAttrib( nLangId, rPaM.GetIndex() ); @@ -1750,7 +1750,7 @@ void ImpEditEngine::ImpConvert( OUString &rConvTxt, LanguageType &rConvTxtLang, // check script type to the right of the start of the current portion EditPaM aPaM( CreateEditPaM( EPaM(aCurStart.nPara, nLangIdx) ) ); - sal_Bool bIsAsianScript = (i18n::ScriptType::ASIAN == GetScriptType( aPaM )); + sal_Bool bIsAsianScript = (i18n::ScriptType::ASIAN == GetI18NScriptType( aPaM )); // not yet processed text part with for conversion // not suitable language found that needs to be changed? if (bAllowImplicitChangesForNotConvertibleText && commit fdf85819c33abe5a81d19a94b3bac0800b6cda30 Author: Caolán McNamara <caol...@redhat.com> Date: Fri Oct 18 16:04:40 2013 +0100 Related: fdo#38838 remove String::Match Change-Id: I9db663dbcb432cbfe380e1272d6daaed3e6f4221 diff --git a/include/tools/string.hxx b/include/tools/string.hxx index 16f28db..2e9e1cb 100644 --- a/include/tools/string.hxx +++ b/include/tools/string.hxx @@ -229,8 +229,6 @@ public: sal_Bool Equals( const UniString& rStr, xub_StrLen nIndex, xub_StrLen nLen ) const; - xub_StrLen Match( const UniString& rStr ) const; - xub_StrLen Search( sal_Unicode c, xub_StrLen nIndex = 0 ) const; xub_StrLen Search( const UniString& rStr, xub_StrLen nIndex = 0 ) const; diff --git a/tools/source/string/tustring.cxx b/tools/source/string/tustring.cxx index 40c99cf..59b80d7 100644 --- a/tools/source/string/tustring.cxx +++ b/tools/source/string/tustring.cxx @@ -186,32 +186,6 @@ sal_Bool STRING::Equals( const STRING& rStr, xub_StrLen nIndex, xub_StrLen nLen return (ImplStringCompareWithoutZero( mpData->maStr+nIndex, rStr.mpData->maStr, nLen ) == 0); } -xub_StrLen STRING::Match( const STRING& rStr ) const -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING ); - - // return if string is empty - if ( !mpData->mnLen ) - return STRING_MATCH; - - // Search the string for unmatching chars - const STRCODE* pStr1 = mpData->maStr; - const STRCODE* pStr2 = rStr.mpData->maStr; - xub_StrLen i = 0; - while ( i < mpData->mnLen ) - { - // Abort on the first unmatching char - if ( *pStr1 != *pStr2 ) - return i; - ++pStr1, - ++pStr2, - ++i; - } - - return STRING_MATCH; -} - STRING& STRING::Append( STRCODE c ) { DBG_CHKTHIS( STRING, DBGCHECKSTRING ); commit f1a8aefec91f51a15c951f53f283a38a2edcd141 Author: Caolán McNamara <caol...@redhat.com> Date: Fri Oct 18 16:01:15 2013 +0100 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 diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index e7dbdc6..a9b69a7 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; } } } commit b57ffef61afd61b57087150b1a9245e21079e15b Author: Caolán McNamara <caol...@redhat.com> Date: Fri Oct 18 15:52:43 2013 +0100 Related: rhbz#1020712 more i18n::ScriptType being compared against SCRIPTTYPE Change-Id: I5da9114a3fd8330df2b63dc9187323765d305791 diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index fb61b94..d04545d 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -2144,7 +2144,7 @@ void ImpEditEngine::ApplyChangedSentence(EditView& rEditView, rEditView.pImpEditView->SetEditSelection( aCurrentOldPosition->Max() ); } - sal_uInt16 nScriptType = GetI18NScriptTypeOfLanguage( aCurrentNewPortion->eLanguage ); + sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( aCurrentNewPortion->eLanguage ); sal_uInt16 nLangWhichId = EE_CHAR_LANGUAGE; switch(nScriptType) { @@ -2191,7 +2191,7 @@ void ImpEditEngine::ApplyChangedSentence(EditView& rEditView, LanguageType eCurLanguage = GetLanguage( aCurrentPaM ); if(eCurLanguage != aCurrentNewPortion->eLanguage) { - sal_uInt16 nScriptType = GetI18NScriptTypeOfLanguage( aCurrentNewPortion->eLanguage ); + sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( aCurrentNewPortion->eLanguage ); sal_uInt16 nLangWhichId = EE_CHAR_LANGUAGE; switch(nScriptType) { commit e63a0d5657c7b9c7431525ba669b3edab0e56af3 Author: Caolán McNamara <caol...@redhat.com> Date: Fri Oct 18 15:36:28 2013 +0100 Related: rhbz#1020712 wrong default font shown in editengine Only in editengine could we have this fiasco. There are two ImpEditEngine::GetScriptType's a) sal_uInt16 ImpEditEngine::GetScriptType(const EditPaM& rPaM, sal_uInt16* pEndPos) const this one returns i18n::ScriptType b) sal_uInt16 ImpEditEngine::GetScriptType(const EditSelection& rSel) const this one returns SCRIPTTYPE Could there be a better way to ensure that mistakes will be made. Anyway, within variant b, with an empty edit engine ImpEditEngine::GetScriptType calls GetI18NScriptTypeOfLanguage but *that* returns i18n::ScriptType's not SCRIPTTYPEs but when there is content then a SCRIPTTYPE is truly returned. Change-Id: I3a4a7c8746728e0fdfb25d961004c8339a24c93d diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 515842e..e7dbdc6 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -1828,7 +1828,7 @@ sal_uInt16 ImpEditEngine::GetScriptType( const EditSelection& rSel ) const } } } - return nScriptType ? nScriptType : GetI18NScriptTypeOfLanguage( GetDefaultLanguage() ); + return nScriptType ? nScriptType : SvtLanguageOptions::GetScriptTypeOfLanguage( GetDefaultLanguage() ); } sal_Bool ImpEditEngine::IsScriptChange( const EditPaM& rPaM ) const
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits