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


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.hawkins@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


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.