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


The attached patch removes some more SvBytes and SvXub_StrLens usage
from SwScriptInfo.

Changes under LGPLv3+/MPL

Nigel.
From bdbe75e3715a5e553c26edcefb09abff7ebf936b Mon Sep 17 00:00:00 2001
From: Nigel Hawkins <n.hawkins@gmx.com>
Date: Tue, 8 Feb 2011 15:05:14 +0000
Subject: [PATCH 4/4] Remove direction svArray usage in SwScriptInfo

---
 sw/source/core/inc/scriptinfo.hxx |   20 +++++++++++++-------
 sw/source/core/text/porlay.cxx    |   17 ++++-------------
 2 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/sw/source/core/inc/scriptinfo.hxx b/sw/source/core/inc/scriptinfo.hxx
index ef3a365..f8cf486 100644
--- a/sw/source/core/inc/scriptinfo.hxx
+++ b/sw/source/core/inc/scriptinfo.hxx
@@ -109,8 +109,14 @@ private:
     //TODO - This is sorted, so should probably be a std::set rather than vector.
     //       But we also use random access (probably unnecessarily).
     std::vector<ScriptChangeInfo> aScriptChanges;
-    SvXub_StrLens aDirChg;
-    SvBytes aDirType;
+    //! Records a single change in direction.
+    struct DirectionChangeInfo
+    {
+        xub_StrLen position; //!< Character position at which we change direction.
+        BYTE       type;     //!< Direction that we change to.
+        inline DirectionChangeInfo(xub_StrLen pos, BYTE typ) : position(pos), type(typ) {};
+    };
+    std::vector<DirectionChangeInfo> aDirectionChanges;
     SvXub_StrLens aKashida;
     SvXub_StrLens aKashidaInvalid;
     SvXub_StrLens aNoKashidaLine;
@@ -378,16 +384,16 @@ inline BYTE SwScriptInfo::GetScriptType( const xub_StrLen nCnt ) const
     return aScriptChanges[nCnt].type;
 }
 
-inline USHORT SwScriptInfo::CountDirChg() const { return aDirChg.Count(); }
+inline USHORT SwScriptInfo::CountDirChg() const { return aDirectionChanges.size(); }
 inline xub_StrLen SwScriptInfo::GetDirChg( const USHORT nCnt ) const
 {
-    OSL_ENSURE( nCnt < aDirChg.Count(),"No DirChange today!");
-    return aDirChg[ nCnt ];
+    OSL_ENSURE( nCnt < aDirectionChanges.size(),"No DirChange today!");
+    return aDirectionChanges[ nCnt ].position;
 }
 inline BYTE SwScriptInfo::GetDirType( const xub_StrLen nCnt ) const
 {
-    OSL_ENSURE( nCnt < aDirChg.Count(),"No DirType today!");
-    return aDirType[ nCnt ];
+    OSL_ENSURE( nCnt < aDirectionChanges.size(),"No DirType today!");
+    return aDirectionChanges[ nCnt ].type;
 }
 
 inline USHORT SwScriptInfo::CountKashida() const { return aKashida.Count(); }
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 51d6c55..b7db718 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -1304,9 +1304,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL )
 #endif
 
     // remove invalid entries from direction information arrays
-    const USHORT nDirRemove = aDirChg.Count();
-    aDirChg.Remove( 0, nDirRemove );
-    aDirType.Remove( 0, nDirRemove );
+    aDirectionChanges.clear();
 
     // Perform Unicode Bidi Algorithm for text direction information
     bool bPerformUBA = UBIDI_LTR != nDefaultDir;
@@ -1326,7 +1324,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL )
         // 1. All text in RTL runs will use the CTL font
         // #i89825# change the script type also to CTL (hennerdrewes)
         // 2. Text in embedded LTR runs that does not have any strong LTR characters (numbers!)
-        for ( USHORT nDirIdx = 0; nDirIdx < aDirChg.Count(); ++nDirIdx )
+        for ( USHORT nDirIdx = 0; nDirIdx < aDirectionChanges.size(); ++nDirIdx )
         {
             const BYTE nCurrDirType = GetDirType( nDirIdx );
                 // nStart ist start of RTL run:
@@ -1395,10 +1393,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL )
 void SwScriptInfo::UpdateBidiInfo( const String& rTxt )
 {
     // remove invalid entries from direction information arrays
-    const USHORT nDirRemove = aDirChg.Count();
-    aDirChg.Remove( 0, nDirRemove );
-    aDirType.Remove( 0, nDirRemove );
-
+    aDirectionChanges.clear();
     //
     // Bidi functions from icu 2.0
     //
@@ -1413,14 +1408,10 @@ void SwScriptInfo::UpdateBidiInfo( const String& rTxt )
     int32_t nStart = 0;
     int32_t nEnd;
     UBiDiLevel nCurrDir;
-    // counter for direction information arrays
-    USHORT nCntDir = 0;
-
     for ( USHORT nIdx = 0; nIdx < nCount; ++nIdx )
     {
         ubidi_getLogicalRun( pBidi, nStart, &nEnd, &nCurrDir );
-        aDirChg.Insert( (USHORT)nEnd, nCntDir );
-        aDirType.Insert( (BYTE)nCurrDir, nCntDir++ );
+        aDirectionChanges.push_back( DirectionChangeInfo(nEnd, nCurrDir) );
         nStart = nEnd;
     }
 
-- 
1.7.0.4


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.