Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * OpenOffice.org - a multi-platform office productivity suite
5 : : *
6 : : * Author:
7 : : * Fridrich Strba <fridrich.strba@bluewin.ch>
8 : : * Thorsten Behrens <tbehrens@novell.com>
9 : : *
10 : : * Copyright (C) 2008, Novell Inc.
11 : : * Parts copyright 2005 by Sun Microsystems, Inc.
12 : : *
13 : : * The Contents of this file are made available subject to
14 : : * the terms of GNU Lesser General Public License Version 3.
15 : : *
16 : : ************************************************************************/
17 : :
18 : :
19 : : #include "tokenmap.hxx"
20 : : #include <string.h>
21 : :
22 : : namespace svgi
23 : : {
24 : :
25 : : #include "tokens.cxx"
26 : :
27 : 0 : sal_Int32 getTokenId( const char* sIdent, sal_Int32 nLen )
28 : : {
29 : 0 : const struct xmltoken* t = Perfect_Hash::in_word_set( sIdent, nLen );
30 [ # # ]: 0 : if( t )
31 : 0 : return t->nToken;
32 : : else
33 : 0 : return XML_TOKEN_INVALID;
34 : : }
35 : :
36 : 0 : sal_Int32 getTokenId( const rtl::OUString& sIdent )
37 : : {
38 : : rtl::OString aUTF8( sIdent.getStr(),
39 : : sIdent.getLength(),
40 [ # # ]: 0 : RTL_TEXTENCODING_UTF8 );
41 : 0 : return getTokenId( aUTF8.getStr(), aUTF8.getLength() );
42 : : }
43 : :
44 : 0 : const char* getTokenName( sal_Int32 nTokenId )
45 : : {
46 [ # # ]: 0 : if( nTokenId >= XML_TOKEN_COUNT )
47 : 0 : return NULL;
48 : :
49 : 0 : const xmltoken* pCurr=wordlist;
50 : 0 : const xmltoken* pEnd=wordlist+sizeof(wordlist)/sizeof(*wordlist);
51 [ # # ]: 0 : while( pCurr != pEnd )
52 : : {
53 [ # # ]: 0 : if(pCurr->nToken == nTokenId)
54 : 0 : return pCurr->name;
55 : 0 : ++pCurr;
56 : : }
57 : :
58 : 0 : return NULL;
59 : : }
60 : :
61 : : } // namespace svgi
62 : :
63 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|