Update ooo320-m1
[ooovba.git] / filter / source / svg / tokenmap.cxx
blobd9fb57a31bf1cfbcc6874d9b1ac07fcaedaa3727
1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * Author:
6 * Fridrich Strba <fridrich.strba@bluewin.ch>
7 * Thorsten Behrens <tbehrens@novell.com>
9 * Copyright (C) 2008, Novell Inc.
10 * Parts copyright 2005 by Sun Microsystems, Inc.
12 * The Contents of this file are made available subject to
13 * the terms of GNU Lesser General Public License Version 2.1.
15 ************************************************************************/
17 // MARKER(update_precomp.py): autogen include statement, do not remove
18 #include "precompiled_filter.hxx"
20 #include "tokenmap.hxx"
21 #include <string.h>
23 namespace svgi
26 #include "tokens.cxx"
28 sal_Int32 getTokenId( const char* sIdent, sal_Int32 nLen )
30 const struct xmltoken* t = Perfect_Hash::in_word_set( sIdent, nLen );
31 if( t )
32 return t->nToken;
33 else
34 return XML_TOKEN_INVALID;
37 sal_Int32 getTokenId( const rtl::OUString& sIdent )
39 rtl::OString aUTF8( sIdent.getStr(),
40 sIdent.getLength(),
41 RTL_TEXTENCODING_UTF8 );
42 return getTokenId( aUTF8.getStr(), aUTF8.getLength() );
45 const char* getTokenName( sal_Int32 nTokenId )
47 if( nTokenId >= XML_TOKEN_COUNT )
48 return NULL;
50 const xmltoken* pCurr=wordlist;
51 const xmltoken* pEnd=wordlist+sizeof(wordlist)/sizeof(*wordlist);
52 while( pCurr != pEnd )
54 if(pCurr->nToken == nTokenId)
55 return pCurr->name;
56 ++pCurr;
59 return NULL;
62 } // namespace svgi