diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2013-10-11 22:51:44 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@gmail.com> | 2013-10-17 21:38:34 +0200 |
commit | 7e77559b6f79dbf7e96073ac5a90f9b8ff0270c9 (patch) | |
tree | 2c5cf7ce134c11299e346f2944dc7b3c87ffbf77 | |
parent | 86501dd6e0249c4291787d7cbaa88e84370a6c3e (diff) |
oox: special-case single-character a-z token mapping.
Change-Id: I58a810cc6062d5b42558dd5c0f37426a8a210f40
-rw-r--r-- | include/oox/token/tokenmap.hxx | 1 | ||||
-rw-r--r-- | oox/source/token/tokenmap.cxx | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/include/oox/token/tokenmap.hxx b/include/oox/token/tokenmap.hxx index 84dc70d03fac..fb9ebc590a1a 100644 --- a/include/oox/token/tokenmap.hxx +++ b/include/oox/token/tokenmap.hxx @@ -58,6 +58,7 @@ private: typedef ::std::vector< TokenName > TokenNameVector; TokenNameVector maTokenNames; + sal_Int32 mnAlphaTokens[26]; }; // ============================================================================ diff --git a/oox/source/token/tokenmap.cxx b/oox/source/token/tokenmap.cxx index 5460b7c959eb..ea3e621e3792 100644 --- a/oox/source/token/tokenmap.cxx +++ b/oox/source/token/tokenmap.cxx @@ -79,6 +79,13 @@ TokenMap::TokenMap() : append( nToken ).append( ", '" ).append( aUtf8Name ).append( '\'' ).getStr() ); } #endif + + for (unsigned char c = 'a'; c <= 'z'; c++) + { + struct xmltoken* pToken = Perfect_Hash::in_word_set( + reinterpret_cast< const char* >( &c ), 1 ); + mnAlphaTokens[ c - 'a' ] = pToken ? pToken->nToken : XML_TOKEN_INVALID; + } } TokenMap::~TokenMap() @@ -108,6 +115,13 @@ Sequence< sal_Int8 > TokenMap::getUtf8TokenName( sal_Int32 nToken ) const sal_Int32 TokenMap::getTokenFromUtf8( const Sequence< sal_Int8 >& rUtf8Name ) const { + // 50% of OOXML tokens are primarily 1 lower-case character, a-z + if( rUtf8Name.getLength() == 1) + { + sal_Char c = rUtf8Name[0]; + if (c >= 'a' && c <= 'z') + return mnAlphaTokens[ c - 'a' ]; + } struct xmltoken* pToken = Perfect_Hash::in_word_set( reinterpret_cast< const char* >( rUtf8Name.getConstArray() ), rUtf8Name.getLength() ); return pToken ? pToken->nToken : XML_TOKEN_INVALID; |