Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3098

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/98/3098/1

Use OUString and sal_Int32 in GetTextBreak()

Change-Id: I66b85365d1c59f802253b8abdb1e04e25950a09b
---
M sw/source/core/txtnode/fntcache.cxx
M sw/source/core/txtnode/fntcap.cxx
M vcl/inc/vcl/outdev.hxx
M vcl/source/gdi/outdev3.cxx
4 files changed, 44 insertions(+), 24 deletions(-)



diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx
index fb4f523..b41fa2c 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -2437,14 +2437,23 @@
             bTextReplaced = true;
         }
 
-           if( rInf.GetHyphPos() )
-            nTxtBreak = rInf.GetOut().GetTextBreak( *pTmpText, nTextWidth,
-                                                    '-', *rInf.GetHyphPos(),
-                                                     nTmpIdx, nTmpLen, nKern );
+        OUString sTmpText(*pTmpText); // only needed until *pTmpText is OUString
+        sal_Int32 nTmpIdx2 = nTmpIdx;  // ditto
+        sal_Int32 nTmpLen2 = nTmpLen;  // ditto
+        if( rInf.GetHyphPos() ) {
+            sal_Int32 nHyphPos = *rInf.GetHyphPos();
+            nTxtBreak = rInf.GetOut().GetTextBreak( sTmpText, nTextWidth,
+                             static_cast<sal_Unicode>('-'), nHyphPos,
+                             nTmpIdx2, nTmpLen2, nKern );
+            xub_StrLen nTmpHyphPos = static_cast<xub_StrLen>(nHyphPos);
+            rInf.SetHyphPos(&nTmpHyphPos);
+        }
         else
-            nTxtBreak = rInf.GetOut().GetTextBreak( *pTmpText, nTextWidth,
-                                                    nTmpIdx, nTmpLen, nKern );
+            nTxtBreak = rInf.GetOut().GetTextBreak( sTmpText, nTextWidth,
+                                                    nTmpIdx2, nTmpLen2, nKern );
 
+        nTmpIdx = nTmpIdx2;     // ditto
+        nTmpLen = nTmpLen2;     // ditto
         if ( bTextReplaced && STRING_LEN != nTxtBreak )
         {
             if ( nTmpLen != nLn )
diff --git a/sw/source/core/txtnode/fntcap.cxx b/sw/source/core/txtnode/fntcap.cxx
index ef40571..00ed43e 100644
--- a/sw/source/core/txtnode/fntcap.cxx
+++ b/sw/source/core/txtnode/fntcap.cxx
@@ -208,16 +208,27 @@
         else
         {
             xub_StrLen nEnd = rInf.GetEnd();
+            OUString sText(rInf.GetText()); // only needed until rInf.GetText() returns OUString
+            long nTxtWidth2 = nTxtWidth;    // only needed until variables are migrated to 
sal_Int32
+            sal_Int32 nIdx2 = rInf.GetIdx(); // ditto
+            sal_Int32 nLen2 = rInf.GetLen(); // ditto
             if( pExtraPos )
             {
-                nBreak = GetOut().GetTextBreak( rInf.GetText(), nTxtWidth, '-',
-                     *pExtraPos, rInf.GetIdx(), rInf.GetLen(), rInf.GetKern() );
-                if( *pExtraPos > nEnd )
-                    *pExtraPos = nEnd;
+                sal_Int32 nExtraPos = *pExtraPos; // ditto
+                nBreak = GetOut().GetTextBreak( sText, nTxtWidth2, static_cast<sal_Unicode>('-'),
+                     nExtraPos, nIdx2, nLen2, rInf.GetKern() );
+                if( nExtraPos > nEnd )
+                    nExtraPos = nEnd;
+                *pExtraPos = nExtraPos;
             }
             else
-                nBreak = GetOut().GetTextBreak( rInf.GetText(), nTxtWidth,
-                               rInf.GetIdx(), rInf.GetLen(), rInf.GetKern() );
+                nBreak = GetOut().GetTextBreak( sText, nTxtWidth2,
+                               nIdx2, nLen2, rInf.GetKern() );
+
+            rInf.SetText(sText); // ditto
+            rInf.SetIdx(nIdx2);  // ditto
+            rInf.SetLen(nLen2);  // ditto
+            nTxtWidth = nTxtWidth2; // ditto
 
             if( nBreak > nEnd )
                 nBreak = nEnd;
diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx
index 3f4fdbd..e0dbd6c 100644
--- a/vcl/inc/vcl/outdev.hxx
+++ b/vcl/inc/vcl/outdev.hxx
@@ -590,12 +590,12 @@
     void                DrawStretchText( const Point& rStartPt, sal_uLong nWidth,
                                          const XubString& rStr,
                                          xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN );
-    xub_StrLen          GetTextBreak( const XubString& rStr, long nTextWidth,
-                                      xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN,
+    xub_StrLen          GetTextBreak( const OUString& rStr, long nTextWidth,
+                                      sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
                                       long nCharExtra = 0, sal_Bool bCellBreaking = sal_True ) 
const;
-    xub_StrLen          GetTextBreak( const XubString& rStr, long nTextWidth,
-                                      sal_uInt16 nExtraChar, xub_StrLen& rExtraCharPos,
-                                      xub_StrLen nIndex, xub_StrLen nLen,
+    xub_StrLen          GetTextBreak( const OUString& rStr, long nTextWidth,
+                                      sal_Unicode nExtraChar, sal_Int32& rExtraCharPos,
+                                      sal_Int32 nIndex, sal_Int32 nLen,
                                       long nCharExtra = 0 ) const;
     /** Generate MetaTextActions for the text rect
 
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index b588b08..49e5b33 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -5795,7 +5795,7 @@
         ImplInitFont();
 
     // check string index and length
-    if( nMinIndex + nLen > rOrigStr.getLength() )
+    if( -1 == nLen || nMinIndex + nLen > rOrigStr.getLength() )
     {
         const sal_Int32 nNewLen = rOrigStr.getLength() - nMinIndex;
         if( nNewLen <= 0 )
@@ -6077,8 +6077,8 @@
     return (nCharPos != nIndex) ? sal_True : sal_False;
 }
 
-xub_StrLen OutputDevice::GetTextBreak( const String& rStr, long nTextWidth,
-                                       xub_StrLen nIndex, xub_StrLen nLen,
+xub_StrLen OutputDevice::GetTextBreak( const OUString& rStr, long nTextWidth,
+                                       sal_Int32 nIndex, sal_Int32 nLen,
                                        long nCharExtra, sal_Bool /*TODO: bCellBreaking*/ ) const
 {
     DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
@@ -6109,9 +6109,9 @@
     return nRetVal;
 }
 
-xub_StrLen OutputDevice::GetTextBreak( const String& rStr, long nTextWidth,
-                                       sal_Unicode nHyphenatorChar, xub_StrLen& rHyphenatorPos,
-                                       xub_StrLen nIndex, xub_StrLen nLen,
+xub_StrLen OutputDevice::GetTextBreak( const OUString& rStr, long nTextWidth,
+                                       sal_Unicode nHyphenatorChar, sal_Int32& rHyphenatorPos,
+                                       sal_Int32 nIndex, sal_Int32 nLen,
                                        long nCharExtra ) const
 {
     DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
@@ -6143,7 +6143,7 @@
 
     // calculate hyphenated break position
     rtl::OUString aHyphenatorStr(nHyphenatorChar);
-    xub_StrLen nTempLen = 1;
+    sal_Int32 nTempLen = 1;
     SalLayout* pHyphenatorLayout = ImplLayout( aHyphenatorStr, 0, nTempLen );
     if( pHyphenatorLayout )
     {

-- 
To view, visit https://gerrit.libreoffice.org/3098
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I66b85365d1c59f802253b8abdb1e04e25950a09b
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Christina Roßmanith <ChrRossmanith@web.de>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.