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