xref: /aoo4110/main/oox/inc/oox/token/tokenmap.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef OOX_TOKEN_TOKENMAP_HXX
25 #define OOX_TOKEN_TOKENMAP_HXX
26 
27 #include <vector>
28 #include <rtl/instance.hxx>
29 #include <rtl/ustring.hxx>
30 #include <com/sun/star/uno/Sequence.hxx>
31 
32 namespace oox {
33 
34 // ============================================================================
35 
36 class TokenMap
37 {
38 public:
39     explicit            TokenMap();
40                         ~TokenMap();
41 
42     /** Returns the Unicode name of the passed token identifier. */
43     ::rtl::OUString     getUnicodeTokenName( sal_Int32 nToken ) const;
44 
45     /** Returns the token identifier for the passed Unicode token name. */
46     sal_Int32           getTokenFromUnicode( const ::rtl::OUString& rUnicodeName ) const;
47 
48     /** Returns the UTF8 name of the passed token identifier as byte sequence. */
49     ::com::sun::star::uno::Sequence< sal_Int8 >
50                         getUtf8TokenName( sal_Int32 nToken ) const;
51 
52     /** Returns the token identifier for the passed UTF8 token name. */
53     sal_Int32           getTokenFromUtf8(
54                             const ::com::sun::star::uno::Sequence< sal_Int8 >& rUtf8Name ) const;
55 
56 private:
57     struct TokenName
58     {
59         ::rtl::OUString maUniName;
60         ::com::sun::star::uno::Sequence< sal_Int8 > maUtf8Name;
61     };
62     typedef ::std::vector< TokenName > TokenNameVector;
63 
64     TokenNameVector     maTokenNames;
65 };
66 
67 // ============================================================================
68 
69 struct StaticTokenMap : public ::rtl::Static< TokenMap, StaticTokenMap > {};
70 
71 // ============================================================================
72 
73 } // namespace oox
74 
75 #endif
76 
77