[PATCH] Use OUString and sal_Int32 in ImplPrepareLayoutArgs() and Ge...

Christina Roßmanith (via_Code_Review) gerrit at gerrit.libreoffice.org
Sun Mar 24 02:15:55 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2959

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/59/2959/1

Use OUString and sal_Int32 in ImplPrepareLayoutArgs() and GetTextIsRTL()

Change-Id: Ib1b659aa56a38efdfc2dddb5e362ac1eb54972f1
---
M vcl/inc/vcl/outdev.hxx
M vcl/source/gdi/outdev3.cxx
2 files changed, 29 insertions(+), 25 deletions(-)



diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx
index e51ec2b..5f00757 100644
--- a/vcl/inc/vcl/outdev.hxx
+++ b/vcl/inc/vcl/outdev.hxx
@@ -382,10 +382,8 @@
                                             xub_StrLen nLen, const Point& rLogicPos = Point(0,0),
                                             long nLogicWidth=0, const sal_Int32* pLogicDXArray=NULL,
                                             bool bFilter = false ) const;
-    SAL_DLLPRIVATE ImplLayoutArgs ImplPrepareLayoutArgs( String&,
-                                            xub_StrLen nIndex, xub_StrLen nLen,
-                                            long nPixelWidth,
-                                            const sal_Int32* pPixelDXArray ) const;
+    SAL_DLLPRIVATE ImplLayoutArgs ImplPrepareLayoutArgs( OUString&, const sal_Int32 nIndex, const sal_Int32 nLen,
+                                            long nPixelWidth, const sal_Int32* pPixelDXArray ) const;
     SAL_DLLPRIVATE SalLayout*   ImplGlyphFallbackLayout( SalLayout*, ImplLayoutArgs& ) const;
 
     static
@@ -1060,8 +1058,7 @@
 
     sal_uInt16              GetBitCount() const;
 
-    sal_Bool                GetTextIsRTL( const String&, xub_StrLen nIndex,
-                            xub_StrLen nLen ) const;
+    sal_Bool                GetTextIsRTL( const OUString&, sal_Int32 nIndex, sal_Int32 nLen ) const;
 
     /** Query the existence and depth of the alpha channel
 
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index a2e2e1b..1fedcbd 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -5665,13 +5665,13 @@
         mpAlphaVDev->DrawStretchText( rStartPt, nWidth, rStr, nIndex, nLen );
 }
 
-ImplLayoutArgs OutputDevice::ImplPrepareLayoutArgs( String& rStr,
-                                       xub_StrLen nMinIndex, xub_StrLen nLen,
+ImplLayoutArgs OutputDevice::ImplPrepareLayoutArgs( OUString& rStr,
+                                       const sal_Int32 nMinIndex, const sal_Int32 nLen,
                                        long nPixelWidth, const sal_Int32* pDXArray ) const
 {
     // get string length for calculating extents
-    xub_StrLen nEndIndex = rStr.Len();
-    if( (sal_uLong)nMinIndex + nLen < nEndIndex )
+    sal_Int32 nEndIndex = rStr.getLength();
+    if( nMinIndex + nLen < nEndIndex )
         nEndIndex = nMinIndex + nLen;
 
     // don't bother if there is nothing to do
@@ -5686,8 +5686,8 @@
     else if( 0 == (mnTextLayoutMode & TEXT_LAYOUT_BIDI_RTL) )
     {
         // disable Bidi if no RTL hint and no RTL codes used
-        const sal_Unicode* pStr = rStr.GetBuffer() + nMinIndex;
-        const sal_Unicode* pEnd = rStr.GetBuffer() + nEndIndex;
+        const sal_Unicode* pStr = rStr.getStr() + nMinIndex;
+        const sal_Unicode* pEnd = rStr.getStr() + nEndIndex;
         for( ; pStr < pEnd; ++pStr )
             if( ((*pStr >= 0x0580) && (*pStr < 0x0800))   // middle eastern scripts
             ||  ((*pStr >= 0xFB18) && (*pStr < 0xFE00))   // hebrew + arabic A presentation forms
@@ -5711,8 +5711,8 @@
     else
     {
         // disable CTL for non-CTL text
-        const sal_Unicode* pStr = rStr.GetBuffer() + nMinIndex;
-        const sal_Unicode* pEnd = rStr.GetBuffer() + nEndIndex;
+        const sal_Unicode* pStr = rStr.getStr() + nMinIndex;
+        const sal_Unicode* pEnd = rStr.getStr() + nEndIndex;
         for( ; pStr < pEnd; ++pStr )
             if( ((*pStr >= 0x0300) && (*pStr < 0x0370))   // diacritical marks
             ||  ((*pStr >= 0x0590) && (*pStr < 0x10A0))   // many CTL scripts
@@ -5731,9 +5731,10 @@
     if( meTextLanguage ) //TODO: (mnTextLayoutMode & TEXT_LAYOUT_SUBSTITUTE_DIGITS)
     {
         // disable character localization when no digits used
-        const sal_Unicode* pBase = rStr.GetBuffer();
+        const sal_Unicode* pBase = rStr.getStr();
         const sal_Unicode* pStr = pBase + nMinIndex;
         const sal_Unicode* pEnd = pBase + nEndIndex;
+        OUStringBuffer sTmpStr(rStr);
         for( ; pStr < pEnd; ++pStr )
         {
             // TODO: are there non-digit localizations?
@@ -5743,10 +5744,10 @@
                 sal_UCS4 cChar = GetLocalizedChar( *pStr, meTextLanguage );
                 if( cChar != *pStr )
                     // TODO: are the localized digit surrogates?
-                    rStr.SetChar( static_cast<sal_uInt16>(pStr - pBase),
-                                 static_cast<sal_Unicode>(cChar) );
+                    sTmpStr[pStr - pBase] = cChar;
             }
         }
+        rStr = sTmpStr.makeStringAndClear();
     }
 
     // right align for RTL text, DRAWPOS_REVERSED, RTL window style
@@ -5764,7 +5765,7 @@
         nLayoutFlags |= SAL_LAYOUT_RIGHT_ALIGN;
 
     // set layout options
-    ImplLayoutArgs aLayoutArgs( rStr.GetBuffer(), rStr.Len(), nMinIndex, nEndIndex, nLayoutFlags, maFont.GetLanguage() );
+    ImplLayoutArgs aLayoutArgs( rStr.getStr(), rStr.getLength(), nMinIndex, nEndIndex, nLayoutFlags, maFont.GetLanguage() );
 
     int nOrientation = mpFontEntry ? mpFontEntry->mnOrientation : 0;
     aLayoutArgs.SetOrientation( nOrientation );
@@ -5862,7 +5863,13 @@
         pDXArray = pTempDXAry;
     }
 
-    ImplLayoutArgs aLayoutArgs = ImplPrepareLayoutArgs( aStr, nMinIndex, nLen, nPixelWidth, pDXArray );
+    OUString aTmpStr(aStr); // only needed until aStr is OUString as well
+    sal_Int32 nMinIndex2=nMinIndex; // ditto
+    sal_Int32 nLen2=nLen;           // ditto
+    ImplLayoutArgs aLayoutArgs = ImplPrepareLayoutArgs( aTmpStr, nMinIndex, nLen, nPixelWidth, pDXArray );
+    aStr = String(aTmpStr);     // ditto
+    nLen = nLen2;           // ditto
+    nMinIndex = nMinIndex2; // ditto
 
     // get matching layout object for base font
     SalLayout* pSalLayout = NULL;
@@ -6077,11 +6084,9 @@
     return pSalLayout;
 }
 
-sal_Bool OutputDevice::GetTextIsRTL(
-            const String& rString,
-            xub_StrLen nIndex, xub_StrLen nLen ) const
+sal_Bool OutputDevice::GetTextIsRTL( const OUString& rString, sal_Int32 nIndex, sal_Int32 nLen ) const
 {
-    String aStr( rString );
+    OUString aStr( rString );
     ImplLayoutArgs aArgs = ImplPrepareLayoutArgs( aStr, nIndex, nLen, 0, NULL );
     bool bRTL = false;
     int nCharPos = -1;
@@ -7620,8 +7625,10 @@
 
     bRet = true;
     bool bRTL = false;
-    String aStr( rStr ); // prepare for e.g. localized digits
-    ImplLayoutArgs aLayoutArgs = ImplPrepareLayoutArgs( aStr, nIndex, nLen, 0, NULL );
+    OUString aStr( rStr ); // prepare for e.g. localized digits
+    sal_Int32 nIndex2 = nIndex;  // only needed until nIndex is sal_Int32
+    sal_Int32 nLen2 = nLen;  // only needed until nLen is sal_Int32
+    ImplLayoutArgs aLayoutArgs = ImplPrepareLayoutArgs( aStr, nIndex2, nLen2, 0, NULL );
     for( int nCharPos = -1; aLayoutArgs.GetNextPos( &nCharPos, &bRTL);)
     {
         bool bSuccess = false;

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

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



More information about the LibreOffice mailing list