sw/source/core/txtnode/fntcap.cxx |   29 ++++++++++++++------------
 sw/source/core/txtnode/swfont.cxx |   42 +++++++++++++++++++-------------------
 2 files changed, 37 insertions(+), 34 deletions(-)

New commits:
commit 669b9c993dc771ada788d23296252f141462398d
Author: Michael Stahl <mst...@redhat.com>
Date:   Fri Dec 6 21:18:37 2013 +0100

    sw: fix more cases of SwDrawTextInfo::GetText()/SetText() not restoring
    
    Change-Id: I9625958e4139dd595f269ebac72b9a037118a9f5
    (cherry picked from commit cc3341847f857b1d340d0b9dd09c7bccfb146ab6)

diff --git a/sw/source/core/txtnode/swfont.cxx 
b/sw/source/core/txtnode/swfont.cxx
index d569db9..2269f24 100644
--- a/sw/source/core/txtnode/swfont.cxx
+++ b/sw/source/core/txtnode/swfont.cxx
@@ -1092,15 +1092,15 @@ Size SwSubFont::_GetTxtSize( SwDrawTextInfo& rInf )
     {
         SV_STAT( nGetTextSize );
         long nOldKern = rInf.GetKern();
-        const OUString &rOldTxt = rInf.GetText();
+        const OUString oldTxt = rInf.GetText();
         rInf.SetKern( CheckKerning() );
         if ( !IsCaseMap() )
             aTxtSize = pLastFont->GetTextSize( rInf );
         else
         {
             OUString aTmp = CalcCaseMap( rInf.GetText() );
-            const OUString &rOldStr = rInf.GetText();
-            bool bCaseMapLengthDiffers(aTmp.getLength() != 
rOldStr.getLength());
+            const OUString oldStr = rInf.GetText();
+            bool bCaseMapLengthDiffers(aTmp.getLength() != oldStr.getLength());
 
             if(bCaseMapLengthDiffers && rInf.GetLen())
             {
@@ -1110,7 +1110,7 @@ Size SwSubFont::_GetTxtSize( SwDrawTextInfo& rInf )
                 // a single snippet since its size may differ, too.
                 xub_StrLen nOldIdx(rInf.GetIdx());
                 xub_StrLen nOldLen(rInf.GetLen());
-                const OUString aSnippet(rOldStr.copy(nOldIdx, nOldLen));
+                const OUString aSnippet(oldStr.copy(nOldIdx, nOldLen));
                 OUString aNewText(CalcCaseMap(aSnippet));
 
                 rInf.SetText( aNewText );
@@ -1128,10 +1128,10 @@ Size SwSubFont::_GetTxtSize( SwDrawTextInfo& rInf )
                 aTxtSize = pLastFont->GetTextSize( rInf );
             }
 
-            rInf.SetText( rOldStr );
+            rInf.SetText(oldStr);
         }
         rInf.SetKern( nOldKern );
-        rInf.SetText( rOldTxt );
+        rInf.SetText(oldTxt);
         // 15142: Ein Wort laenger als eine Zeile, beim Zeilenumbruch
         //        hochgestellt, muss seine effektive Hoehe melden.
         if( GetEscapement() )
@@ -1213,9 +1213,9 @@ void SwSubFont::_DrawText( SwDrawTextInfo &rInf, const 
sal_Bool bGrey )
             pLastFont->DrawText( rInf );
         else
         {
-            const OUString &rOldStr = rInf.GetText();
-            OUString aString( CalcCaseMap( rOldStr ) );
-            bool bCaseMapLengthDiffers(aString.getLength() != 
rOldStr.getLength());
+            const OUString oldStr = rInf.GetText();
+            OUString aString( CalcCaseMap(oldStr) );
+            bool bCaseMapLengthDiffers(aString.getLength() != 
oldStr.getLength());
 
             if(bCaseMapLengthDiffers && rInf.GetLen())
             {
@@ -1225,7 +1225,7 @@ void SwSubFont::_DrawText( SwDrawTextInfo &rInf, const 
sal_Bool bGrey )
                 // a single snippet since its size may differ, too.
                 xub_StrLen nOldIdx(rInf.GetIdx());
                 xub_StrLen nOldLen(rInf.GetLen());
-                const OUString aSnippet(rOldStr.copy(nOldIdx, nOldLen));
+                const OUString aSnippet(oldStr.copy(nOldIdx, nOldLen));
                 OUString aNewText = CalcCaseMap(aSnippet);
 
                 rInf.SetText( aNewText );
@@ -1243,14 +1243,14 @@ void SwSubFont::_DrawText( SwDrawTextInfo &rInf, const 
sal_Bool bGrey )
                 pLastFont->DrawText( rInf );
             }
 
-            rInf.SetText( rOldStr );
+            rInf.SetText(oldStr);
         }
     }
 
     if( pUnderFnt && nOldUnder != UNDERLINE_NONE )
     {
         Size aFontSize = _GetTxtSize( rInf );
-        const OUString &rOldStr = rInf.GetText();
+        const OUString oldStr = rInf.GetText();
         OUString aStr("  ");
 
         xub_StrLen nOldIdx = rInf.GetIdx();
@@ -1259,8 +1259,8 @@ void SwSubFont::_DrawText( SwDrawTextInfo &rInf, const 
sal_Bool bGrey )
         if( rInf.GetSpace() )
         {
             xub_StrLen nTmpEnd = nOldIdx + nOldLen;
-            if( nTmpEnd > rOldStr.getLength() )
-                nTmpEnd = rOldStr.getLength();
+            if (nTmpEnd > oldStr.getLength())
+                nTmpEnd = oldStr.getLength();
 
             const SwScriptInfo* pSI = rInf.GetScriptInfo();
 
@@ -1268,8 +1268,8 @@ void SwSubFont::_DrawText( SwDrawTextInfo &rInf, const 
sal_Bool bGrey )
                 ( rInf.GetFont() && SW_CJK == rInf.GetFont()->GetActual() );
             for( sal_Int32 nTmp = nOldIdx; nTmp < nTmpEnd; ++nTmp )
             {
-                if( CH_BLANK == rOldStr[nTmp] || bAsianFont ||
-                    ( nTmp + 1 < rOldStr.getLength() && pSI &&
+                if (CH_BLANK == oldStr[nTmp] || bAsianFont ||
+                    ( nTmp + 1 < oldStr.getLength() && pSI &&
                       i18n::ScriptType::ASIAN == pSI->ScriptType( nTmp + 1 ) ) 
)
                     ++nSpace;
             }
@@ -1295,7 +1295,7 @@ void SwSubFont::_DrawText( SwDrawTextInfo &rInf, const 
sal_Bool bGrey )
         pUnderFnt->GetFont()._DrawStretchText( rInf );
 
         rInf.SetUnderFnt( pUnderFnt );
-        rInf.SetText( rOldStr );
+        rInf.SetText(oldStr);
         rInf.SetIdx( nOldIdx );
         rInf.SetLen( nOldLen );
     }
@@ -1361,7 +1361,7 @@ void SwSubFont::_DrawStretchText( SwDrawTextInfo &rInf )
 
     if( pUnderFnt && nOldUnder != UNDERLINE_NONE )
     {
-        const OUString &rOldStr = rInf.GetText();
+        const OUString oldStr = rInf.GetText();
         OUString aStr("  ");
         xub_StrLen nOldIdx = rInf.GetIdx();
         xub_StrLen nOldLen = rInf.GetLen();
@@ -1377,7 +1377,7 @@ void SwSubFont::_DrawStretchText( SwDrawTextInfo &rInf )
         pUnderFnt->GetFont()._DrawStretchText( rInf );
 
         rInf.SetUnderFnt( pUnderFnt );
-        rInf.SetText( rOldStr );
+        rInf.SetText(oldStr);
         rInf.SetIdx( nOldIdx );
         rInf.SetLen( nOldLen );
     }
@@ -1400,7 +1400,7 @@ xub_StrLen SwSubFont::_GetCrsrOfst( SwDrawTextInfo& rInf )
         nCrsr = GetCapitalCrsrOfst( rInf );
     else
     {
-        const OUString &rOldTxt = rInf.GetText();
+        const OUString oldTxt = rInf.GetText();
         long nOldKern = rInf.GetKern();
         rInf.SetKern( CheckKerning() );
         SV_STAT( nGetTextSize );
@@ -1413,7 +1413,7 @@ xub_StrLen SwSubFont::_GetCrsrOfst( SwDrawTextInfo& rInf )
             nCrsr = pLastFont->GetCrsrOfst( rInf );
         }
         rInf.SetKern( nOldKern );
-        rInf.SetText( rOldTxt );
+        rInf.SetText(oldTxt);
     }
     return nCrsr;
 }
commit 29b5612ac135512bfa3762fbbdbc54339200b9ec
Author: Michael Stahl <mst...@redhat.com>
Date:   Fri Dec 6 19:47:37 2013 +0100

    fdo#71714: sw: fix small capitals rendering
    
    So f22006dc6ac34a35a060e15466cf6b2d2058617d changed the SwDrawTextInfo
    to contain not a pointer but an actual OUString, and then
    d908422f5763ed8ea79af81336ca564f46435baf changes
    SwSubFont::DoOnCapitals() thus:
    
    -    const XubString& rOldText = rDo.GetInf().GetText();
    +    const OUString& rOldText = rDo.GetInf().GetText();
         rDo.GetInf().SetText( aTxt );
    
    That used to _copy_ the string, but now it just references the
    member, and so the SetText(aTxt) below overwrites rOldText.
    
    Change-Id: I06d7ee7084c15d88b3e748ef18877b62e79bdd0e
    (cherry picked from commit 1050dfbf7daac2f2a4a8580c622447b55b147d57)

diff --git a/sw/source/core/txtnode/fntcap.cxx 
b/sw/source/core/txtnode/fntcap.cxx
index 2ae345b..0c31695 100644
--- a/sw/source/core/txtnode/fntcap.cxx
+++ b/sw/source/core/txtnode/fntcap.cxx
@@ -548,7 +548,7 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo )
                              rDo.GetInf().GetLen() );
     rDo.GetInf().SetLen( nMaxPos );
 
-    const OUString& rOldText = rDo.GetInf().GetText();
+    const OUString oldText = rDo.GetInf().GetText();
     rDo.GetInf().SetText( aTxt );
     xub_StrLen nPos = rDo.GetInf().GetIdx();
     xub_StrLen nOldPos = nPos;
@@ -558,8 +558,8 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo )
     // Look if the length of the original text and the ToUpper-converted
     // text is different. If yes, do special handling.
     OUString aNewText;
-    SwCapitalInfo aCapInf( rOldText );
-    sal_Bool bCaseMapLengthDiffers( aTxt.getLength() != rOldText.getLength() );
+    SwCapitalInfo aCapInf(oldText);
+    sal_Bool bCaseMapLengthDiffers(aTxt.getLength() != oldText.getLength());
     if ( bCaseMapLengthDiffers )
         rDo.SetCapInf( aCapInf );
 
@@ -630,7 +630,8 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo )
 
     if( nPos < nMaxPos )
     {
-        nPos = (xub_StrLen)g_pBreakIt->GetBreakIter()->endOfCharBlock( 
rOldText, nPos,
+        nPos = (xub_StrLen)g_pBreakIt->GetBreakIter()->endOfCharBlock(
+                        oldText, nPos,
             g_pBreakIt->GetLocale( eLng ), CharType::LOWERCASE_LETTER);
         if( nPos == STRING_LEN )
             nPos = nOldPos;
@@ -654,7 +655,7 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo )
                 // Build an own 'changed' string for the given part of the
                 // source string and use it. That new string may differ in 
length
                 // from the source string.
-                const OUString aSnippet(rOldText.copy(nOldPos, nPos - 
nOldPos));
+                const OUString aSnippet(oldText.copy(nOldPos, nPos - nOldPos));
                 aNewText = CalcCaseMap( aSnippet );
                 aCapInf.nIdx = nOldPos;
                 aCapInf.nLen = nPos - nOldPos;
@@ -679,7 +680,8 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo )
             rDo.Do();
             nOldPos = nPos;
         }
-        nPos = (xub_StrLen)g_pBreakIt->GetBreakIter()->nextCharBlock( 
rOldText, nPos,
+        nPos = (xub_StrLen)g_pBreakIt->GetBreakIter()->nextCharBlock(
+                            oldText, nPos,
                g_pBreakIt->GetLocale( eLng ), CharType::LOWERCASE_LETTER);
         if( nPos == STRING_LEN || nPos > nMaxPos )
             nPos = nMaxPos;
@@ -702,7 +704,7 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo )
                 if( bWordWise )
                 {
                     nTmp = nOldPos;
-                    while( nTmp < nPos && CH_BLANK == rOldText[nTmp] )
+                    while (nTmp < nPos && CH_BLANK == oldText[nTmp])
                         ++nTmp;
                     if( nOldPos < nTmp )
                     {
@@ -720,7 +722,7 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo )
                             // Build an own 'changed' string for the given 
part of the
                             // source string and use it. That new string may 
differ in length
                             // from the source string.
-                            const OUString aSnippet(rOldText.copy(nOldPos, 
nTmp - nOldPos));
+                            const OUString aSnippet(oldText.copy(nOldPos, nTmp 
- nOldPos));
                             aNewText = CalcCaseMap( aSnippet );
                             aCapInf.nIdx = nOldPos;
                             aCapInf.nLen = nTmp - nOldPos;
@@ -748,7 +750,7 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo )
                         nOldPos = nTmp;
                     }
 
-                    while( nTmp < nPos && CH_BLANK != rOldText[nTmp] )
+                    while (nTmp < nPos && CH_BLANK != oldText[nTmp])
                         ++nTmp;
                 }
                 else
@@ -761,7 +763,7 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo )
                         // Build an own 'changed' string for the given part of 
the
                         // source string and use it. That new string may 
differ in length
                         // from the source string.
-                        const OUString aSnippet(rOldText.copy(nOldPos, nTmp - 
nOldPos));
+                        const OUString aSnippet(oldText.copy(nOldPos, nTmp - 
nOldPos));
                         aNewText = CalcCaseMap( aSnippet );
                         aCapInf.nIdx = nOldPos;
                         aCapInf.nLen = nTmp - nOldPos;
@@ -783,7 +785,7 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo )
                     {
                         for( sal_Int32 nI = nOldPos; nI < nPos; ++nI )
                         {
-                            if( CH_BLANK == rOldText[nI] )
+                            if (CH_BLANK == oldText[nI])
                                 aPartSize.Width() += nSpaceAdd;
                         }
                     }
@@ -795,7 +797,8 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo )
                 }
             } while( nOldPos != nPos );
         }
-        nPos = (xub_StrLen)g_pBreakIt->GetBreakIter()->endOfCharBlock( 
rOldText, nPos,
+        nPos = (xub_StrLen)g_pBreakIt->GetBreakIter()->endOfCharBlock(
+                            oldText, nPos,
                g_pBreakIt->GetLocale( eLng ), CharType::LOWERCASE_LETTER);
         if( nPos == STRING_LEN || nPos > nMaxPos )
             nPos = nMaxPos;
@@ -825,7 +828,7 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo )
     pLastFont->SetDevFont( rDo.GetInf().GetShell(), rDo.GetOut() );
 
     delete pSmallFontAccess;
-    rDo.GetInf().SetText( rOldText );
+    rDo.GetInf().SetText(oldText);
     rDo.GetInf().SetKanaDiff( nKana );
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to