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/2967

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/67/2967/1

Use OUString and sal_Int32 in GetTextArray() and ImplLayout()

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



diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx
index 5f00757..44a5979 100644
--- a/vcl/inc/vcl/outdev.hxx
+++ b/vcl/inc/vcl/outdev.hxx
@@ -378,10 +378,9 @@
     SAL_DLLPRIVATE bool         ImplSelectClipRegion( const Region&, SalGraphics* pGraphics = NULL 
);
     SAL_DLLPRIVATE void         ImplSetClipRegion( const Region* pRegion );
 
-    SAL_DLLPRIVATE SalLayout*   ImplLayout( const String&, xub_StrLen nIndex,
-                                            xub_StrLen nLen, const Point& rLogicPos = Point(0,0),
-                                            long nLogicWidth=0, const sal_Int32* 
pLogicDXArray=NULL,
-                                            bool bFilter = false ) const;
+    SAL_DLLPRIVATE SalLayout*   ImplLayout( const OUString&, sal_Int32 nIndex, sal_Int32 nLen,
+                                            const Point& rLogicPos = Point(0,0), long 
nLogicWidth=0,
+                                            const sal_Int32* pLogicDXArray=NULL, bool bFilter = 
false ) 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;
@@ -583,9 +582,8 @@
                                        const sal_Int32* pDXAry = NULL,
                                        xub_StrLen nIndex = 0,
                                        xub_StrLen nLen = STRING_LEN );
-    long                GetTextArray( const XubString& rStr, sal_Int32* pDXAry = NULL,
-                                      xub_StrLen nIndex = 0,
-                                      xub_StrLen nLen = STRING_LEN ) const;
+    long                GetTextArray( const OUString& rStr, sal_Int32* pDXAry = NULL,
+                                      sal_Int32 nIndex = 0, sal_Int32 nLen = -1 ) const;
     bool                GetCaretPositions( const XubString&, sal_Int32* pCaretXArray,
                                       xub_StrLen nIndex, xub_StrLen nLen,
                                       sal_Int32* pDXAry = NULL, long nWidth = 0,
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index 1fedcbd..56d1d4a 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -5475,7 +5475,11 @@
 {
     DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
 
-    long nWidth = GetTextArray( rStr, NULL, nIndex, nLen );
+    sal_Int32 nLen2 = (nLen == STRING_LEN) ? -1 : nLen; // only needed until nLen is sal_Int32
+    sal_Int32 nIndex2 = nIndex;                            // ditto
+    OUString aTmpStr(rStr);
+    long nWidth = GetTextArray( aTmpStr, NULL, nIndex2, nLen2 );
+
     return nWidth;
 }
 
@@ -5532,15 +5536,17 @@
         mpAlphaVDev->DrawTextArray( rStartPt, rStr, pDXAry, nIndex, nLen );
 }
 
-long OutputDevice::GetTextArray( const String& rStr, sal_Int32* pDXAry,
-                                 xub_StrLen nIndex, xub_StrLen nLen ) const
+long OutputDevice::GetTextArray( const OUString& rStr, sal_Int32* pDXAry,
+                                 sal_Int32 nIndex, sal_Int32 nLen ) const
 {
+    // MEM: default nLen = STRING_LENGTH
     DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
 
-    if( nIndex >= rStr.Len() )
+    if( nIndex >= rStr.getLength() )
         return 0;
-    if( (sal_uLong)nIndex+nLen >= rStr.Len() )
-        nLen = rStr.Len() - nIndex;
+
+    if( nLen < 0 || nIndex+nLen >= rStr.getLength() )
+        nLen = rStr.getLength() - nIndex;
 
     // do layout
     SalLayout* pSalLayout = ImplLayout( rStr, nIndex, nLen );
@@ -5776,12 +5782,8 @@
     return aLayoutArgs;
 }
 
-SalLayout* OutputDevice::ImplLayout( const String& rOrigStr,
-                                     xub_StrLen nMinIndex,
-                                     xub_StrLen nLen,
-                                     const Point& rLogicalPos,
-                                     long nLogicalWidth,
-                                     const sal_Int32* pDXArray,
+SalLayout* OutputDevice::ImplLayout( const OUString& rOrigStr, sal_Int32 nMinIndex, sal_Int32 nLen,
+                                     const Point& rLogicalPos, long nLogicalWidth, const 
sal_Int32* pDXArray,
                                      bool bFilter ) const
 {
     // we need a graphics
@@ -5797,28 +5799,21 @@
         ImplInitFont();
 
     // check string index and length
-    if( (unsigned)nMinIndex + nLen > rOrigStr.Len() )
+    if( nMinIndex + nLen > rOrigStr.getLength() )
     {
-        const int nNewLen = (int)rOrigStr.Len() - nMinIndex;
+        const sal_Int32 nNewLen = rOrigStr.getLength() - nMinIndex;
         if( nNewLen <= 0 )
             return NULL;
-        nLen = static_cast<xub_StrLen>(nNewLen);
+        nLen = nNewLen;
     }
 
-    String aStr = rOrigStr;
+    OUString aStr = rOrigStr;
 
     // filter out special markers
     if( bFilter )
     {
         sal_Int32 nCutStart, nCutStop, nOrgLen = nLen;
-        OUString aTmpStr(aStr);
-        OUString aTmpOrigStr(rOrigStr); // only needed until rOrigStr is OUString
-        sal_Int32 nMinIndex2=nMinIndex; // ditto
-        sal_Int32 nLen2=nLen;           // ditto
-        bool bFiltered = mpGraphics->filterText( aTmpOrigStr, aTmpStr, nMinIndex2, nLen2, 
nCutStart, nCutStop );
-        nLen = nLen2;           // ditto
-        nMinIndex = nMinIndex2; // ditto
-        aStr = aTmpStr;
+        bool bFiltered = mpGraphics->filterText( rOrigStr, aStr, nMinIndex, nLen, nCutStart, 
nCutStop );
         if( !nLen )
             return NULL;
 
@@ -5843,9 +5838,7 @@
     // convert from logical units to physical units
     // recode string if needed
     if( mpFontEntry->mpConversion ) {
-        OUString aTmpStr(aStr); // only needed until aStr is OUString as well
-        mpFontEntry->mpConversion->RecodeString( aTmpStr, 0, aTmpStr.getLength() );
-        aStr = String(aTmpStr);
+        mpFontEntry->mpConversion->RecodeString( aStr, 0, aStr.getLength() );
     }
 
     long nPixelWidth = nLogicalWidth;
@@ -5863,13 +5856,7 @@
         pDXArray = pTempDXAry;
     }
 
-    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
+    ImplLayoutArgs aLayoutArgs = ImplPrepareLayoutArgs( aStr, nMinIndex, nLen, nPixelWidth, 
pDXArray );
 
     // get matching layout object for base font
     SalLayout* pSalLayout = NULL;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2c1e5b7d53c0d78f2ccf9ac317a7ff40298cd68d
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.