This patch removes the last use of SvBytes from SwScriptInfo. And should
be the last usage in sw.

Nigel
>From 3d1e455ca3ede76235e769b65342f0f31d9f44ee Mon Sep 17 00:00:00 2001
From: Nigel Hawkins <n.hawk...@gmx.com>
Date: Tue, 8 Feb 2011 16:12:13 +0000
Subject: [PATCH 5/5] Remove compression svArray usage from SwScriptInfo

---
 sw/source/core/inc/scriptinfo.hxx |   26 ++++++++++++++++----------
 sw/source/core/text/porlay.cxx    |   15 +++------------
 2 files changed, 19 insertions(+), 22 deletions(-)

diff --git a/sw/source/core/inc/scriptinfo.hxx b/sw/source/core/inc/scriptinfo.hxx
index f8cf486..4a70226 100644
--- a/sw/source/core/inc/scriptinfo.hxx
+++ b/sw/source/core/inc/scriptinfo.hxx
@@ -121,10 +121,16 @@ private:
     SvXub_StrLens aKashidaInvalid;
     SvXub_StrLens aNoKashidaLine;
     SvXub_StrLens aNoKashidaLineEnd;
-    SvXub_StrLens aCompChg;
-    SvXub_StrLens aCompLen;
     SvXub_StrLens aHiddenChg;
-    SvBytes aCompType;
+    //! Records a single change in compression.
+    struct CompressionChangeInfo
+    {
+        xub_StrLen position; //!< Character position where the change occurs.
+        xub_StrLen length;   //!< Length of the segment.
+        BYTE       type;     //!< Type of compression that we change to.
+        inline CompressionChangeInfo(xub_StrLen pos, xub_StrLen len, BYTE typ) : position(pos), length(len), type(typ) {};
+    };
+    std::vector<CompressionChangeInfo> aCompressionChanges;
     xub_StrLen nInvalidityPos;
     BYTE nDefaultDir;
 
@@ -403,22 +409,22 @@ inline xub_StrLen SwScriptInfo::GetKashida( const USHORT nCnt ) const
     return aKashida[ nCnt ];
 }
 
-inline USHORT SwScriptInfo::CountCompChg() const { return aCompChg.Count(); };
+inline USHORT SwScriptInfo::CountCompChg() const { return aCompressionChanges.size(); };
 inline xub_StrLen SwScriptInfo::GetCompStart( const USHORT nCnt ) const
 {
-    OSL_ENSURE( nCnt < aCompChg.Count(),"No CompressionStart today!");
-    return aCompChg[ nCnt ];
+    OSL_ENSURE( nCnt < aCompressionChanges.size(),"No CompressionStart today!");
+    return aCompressionChanges[ nCnt ].position;
 }
 inline xub_StrLen SwScriptInfo::GetCompLen( const USHORT nCnt ) const
 {
-    OSL_ENSURE( nCnt < aCompChg.Count(),"No CompressionLen today!");
-    return aCompLen[ nCnt ];
+    OSL_ENSURE( nCnt < aCompressionChanges.size(),"No CompressionLen today!");
+    return aCompressionChanges[ nCnt ].length;
 }
 
 inline BYTE SwScriptInfo::GetCompType( const USHORT nCnt ) const
 {
-    OSL_ENSURE( nCnt < aCompChg.Count(),"No CompressionType today!");
-    return aCompType[ nCnt ];
+    OSL_ENSURE( nCnt < aCompressionChanges.size(),"No CompressionType today!");
+    return aCompressionChanges[ nCnt ].type;
 }
 
 inline USHORT SwScriptInfo::CountHiddenChg() const { return aHiddenChg.Count(); };
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index b7db718..8ca3535 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -931,10 +931,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL )
     }
 
     // remove invalid entries from compression information arrays
-    const USHORT nCompRemove = aCompChg.Count() - nCntComp;
-    aCompChg.Remove( nCntComp, nCompRemove );
-    aCompLen.Remove( nCntComp, nCompRemove );
-    aCompType.Remove( nCntComp, nCompRemove );
+    aCompressionChanges.erase(aCompressionChanges.begin() + nCntComp, aCompressionChanges.end() );
 
     // get the start of the last kashida group
     USHORT nLastKashida = nChg;
@@ -1085,10 +1082,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL )
                         if ( CHARCOMPRESS_PUNCTUATION_KANA == aCompEnum ||
                              ePrevState != KANA )
                         {
-                            aCompChg.Insert( nPrevChg, nCntComp );
-                            BYTE nTmpType = ePrevState;
-                            aCompType.Insert( nTmpType, nCntComp );
-                            aCompLen.Insert( nLastCompression - nPrevChg, nCntComp++ );
+                            aCompressionChanges.push_back( CompressionChangeInfo(nPrevChg, nLastCompression - nPrevChg, ePrevState) );
                         }
                     }
 
@@ -1106,10 +1100,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL )
                 if ( CHARCOMPRESS_PUNCTUATION_KANA == aCompEnum ||
                      ePrevState != KANA )
                 {
-                    aCompChg.Insert( nPrevChg, nCntComp );
-                    BYTE nTmpType = ePrevState;
-                    aCompType.Insert( nTmpType, nCntComp );
-                    aCompLen.Insert( nLastCompression - nPrevChg, nCntComp++ );
+                    aCompressionChanges.push_back( CompressionChangeInfo(nPrevChg, nLastCompression - nPrevChg, ePrevState) );
                 }
             }
         }
-- 
1.7.0.4

_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to