Kaydet (Commit) c49faa14 authored tarafından Matteo Casalin's avatar Matteo Casalin

Use enumeration directly

Change-Id: I5b537bb863eafa9e508c7298c611b0d1c0145d77
üst a048b088
...@@ -35,6 +35,9 @@ typedef std::list< sal_Int32 > PositionList; ...@@ -35,6 +35,9 @@ typedef std::list< sal_Int32 > PositionList;
// encapsultes information about script changes // encapsultes information about script changes
class SwScriptInfo class SwScriptInfo
{ {
public:
enum CompType { KANA, SPECIAL_LEFT, SPECIAL_RIGHT, NONE };
private: private:
//! Records a single change in script type. //! Records a single change in script type.
struct ScriptChangeInfo struct ScriptChangeInfo
...@@ -64,10 +67,14 @@ private: ...@@ -64,10 +67,14 @@ private:
{ {
sal_Int32 position; //!< Character position where the change occurs. sal_Int32 position; //!< Character position where the change occurs.
sal_Int32 length; //!< Length of the segment. sal_Int32 length; //!< Length of the segment.
sal_uInt8 type; //!< Type of compression that we change to. CompType type; //!< Type of compression that we change to.
inline CompressionChangeInfo(sal_Int32 pos, sal_Int32 len, sal_uInt8 typ) : position(pos), length(len), type(typ) {}; inline CompressionChangeInfo(sal_Int32 pos, sal_Int32 len, CompType typ) : position(pos), length(len), type(typ) {};
}; };
std::vector<CompressionChangeInfo> aCompressionChanges; std::vector<CompressionChangeInfo> aCompressionChanges;
#ifdef DBG_UTIL
CompType DbgCompType( const sal_Int32 nPos ) const;
#endif
sal_Int32 nInvalidityPos; sal_Int32 nInvalidityPos;
sal_uInt8 nDefaultDir; sal_uInt8 nDefaultDir;
...@@ -83,7 +90,6 @@ private: ...@@ -83,7 +90,6 @@ private:
size_t HasKana( sal_Int32 nStart, const sal_Int32 nEnd ) const; size_t HasKana( sal_Int32 nStart, const sal_Int32 nEnd ) const;
public: public:
enum CompType { KANA, SPECIAL_LEFT, SPECIAL_RIGHT, NONE };
SwScriptInfo(); SwScriptInfo();
~SwScriptInfo(); ~SwScriptInfo();
...@@ -153,7 +159,7 @@ public: ...@@ -153,7 +159,7 @@ public:
OSL_ENSURE( nCnt < aCompressionChanges.size(),"No CompressionLen today!"); OSL_ENSURE( nCnt < aCompressionChanges.size(),"No CompressionLen today!");
return aCompressionChanges[ nCnt ].length; return aCompressionChanges[ nCnt ].length;
} }
sal_uInt8 GetCompType( const size_t nCnt ) const CompType GetCompType( const size_t nCnt ) const
{ {
OSL_ENSURE( nCnt < aCompressionChanges.size(),"No CompressionType today!"); OSL_ENSURE( nCnt < aCompressionChanges.size(),"No CompressionType today!");
return aCompressionChanges[ nCnt ].type; return aCompressionChanges[ nCnt ].type;
...@@ -181,10 +187,6 @@ public: ...@@ -181,10 +187,6 @@ public:
const sal_uInt8* pLevel = 0 ) const; const sal_uInt8* pLevel = 0 ) const;
sal_uInt8 DirType( const sal_Int32 nPos ) const; sal_uInt8 DirType( const sal_Int32 nPos ) const;
#ifdef DBG_UTIL
sal_uInt8 CompType( const sal_Int32 nPos ) const;
#endif
// HIDDEN TEXT STUFF START // HIDDEN TEXT STUFF START
/** Hidden text range information - static and non-version /** Hidden text range information - static and non-version
......
...@@ -856,8 +856,8 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, bool bRTL ) ...@@ -856,8 +856,8 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, bool bRTL )
if ( CHARCOMPRESS_NONE != aCompEnum && if ( CHARCOMPRESS_NONE != aCompEnum &&
i18n::ScriptType::ASIAN == nScript ) i18n::ScriptType::ASIAN == nScript )
{ {
sal_uInt8 ePrevState = NONE; CompType ePrevState = NONE;
sal_uInt8 eState; CompType eState = NONE;
sal_Int32 nPrevChg = nLastCompression; sal_Int32 nPrevChg = nLastCompression;
while ( nLastCompression < nChg ) while ( nLastCompression < nChg )
...@@ -881,7 +881,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, bool bRTL ) ...@@ -881,7 +881,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, bool bRTL )
eState = SPECIAL_RIGHT; eState = SPECIAL_RIGHT;
break; break;
default: default:
eState = static_cast<sal_uInt8>( ( 0x3040 <= cChar && 0x3100 > cChar ) ? KANA : NONE ); eState = ( 0x3040 <= cChar && 0x3100 > cChar ) ? KANA : NONE;
} }
// insert range of compressable characters // insert range of compressable characters
...@@ -1468,7 +1468,7 @@ bool SwScriptInfo::IsInHiddenRange( const SwTxtNode& rNode, sal_Int32 nPos ) ...@@ -1468,7 +1468,7 @@ bool SwScriptInfo::IsInHiddenRange( const SwTxtNode& rNode, sal_Int32 nPos )
#ifdef DBG_UTIL #ifdef DBG_UTIL
// returns the type of the compressed character // returns the type of the compressed character
sal_uInt8 SwScriptInfo::CompType( const sal_Int32 nPos ) const SwScriptInfo::CompType SwScriptInfo::DbgCompType( const sal_Int32 nPos ) const
{ {
const size_t nEnd = CountCompChg(); const size_t nEnd = CountCompChg();
for( size_t nX = 0; nX < nEnd; ++nX ) for( size_t nX = 0; nX < nEnd; ++nX )
...@@ -1545,9 +1545,9 @@ long SwScriptInfo::Compress( long* pKernArray, sal_Int32 nIdx, sal_Int32 nLen, ...@@ -1545,9 +1545,9 @@ long SwScriptInfo::Compress( long* pKernArray, sal_Int32 nIdx, sal_Int32 nLen,
long nLast = nI ? pKernArray[ nI - 1 ] : 0; long nLast = nI ? pKernArray[ nI - 1 ] : 0;
do do
{ {
const sal_uInt8 nType = GetCompType( nCompIdx ); const CompType nType = GetCompType( nCompIdx );
#ifdef DBG_UTIL #ifdef DBG_UTIL
SAL_WARN_IF( nType != CompType( nIdx ), "sw.core", "Gimme the right type!" ); SAL_WARN_IF( nType != DbgCompType( nIdx ), "sw.core", "Gimme the right type!" );
#endif #endif
nCompLen += nIdx; nCompLen += nIdx;
if( nCompLen > nLen ) if( nCompLen > nLen )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment