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 #include	<rtl/alloc.h>
25 
26 #include	"specialtypemanager.hxx"
27 
28 extern "C"
29 {
30 sal_Bool SAL_CALL initTypeMapper( const sal_Char* pRegName );
31 sal_uInt32 SAL_CALL getTypeBlop(const sal_Char* pTypeName, sal_uInt8** pBlop);
32 }
33 
34 using namespace rtl;
35 
SpecialTypeManager()36 SpecialTypeManager::SpecialTypeManager()
37 {
38 	m_pImpl = new SpecialTypeManagerImpl();
39 	acquire();
40 }
41 
~SpecialTypeManager()42 SpecialTypeManager::~SpecialTypeManager()
43 {
44 	release();
45 }
46 
acquire()47 void SpecialTypeManager::acquire()
48 {
49 	TypeManager::acquire();
50 }
51 
release()52 void SpecialTypeManager::release()
53 {
54 	if (0 == TypeManager::release())
55 	{
56 		delete m_pImpl;
57 	}
58 }
59 
init(const OString & registryName)60 sal_Bool SpecialTypeManager::init(const OString& registryName)
61 {
62 	return initTypeMapper( registryName.getStr() );
63 }
64 
getTypeReader(const OString & name)65 TypeReader SpecialTypeManager::getTypeReader(const OString& name)
66 {
67 	TypeReader reader;
68 
69 	sal_uInt8* pBlop = NULL;
70 	sal_uInt32 blopSize = 0;
71 
72 	if ( (blopSize = getTypeBlop( name.getStr(), &pBlop)) > 0 )
73 	{
74 		reader = TypeReader(pBlop, blopSize, sal_True);
75 	}
76 
77 	if ( pBlop )
78 	{
79 		rtl_freeMemory(pBlop);
80 	}
81 
82 	return reader;
83 }
84 
getTypeClass(const OString & name)85 RTTypeClass SpecialTypeManager::getTypeClass(const OString& name)
86 {
87 	if (m_pImpl->m_t2TypeClass.count(name) > 0)
88 	{
89 		return m_pImpl->m_t2TypeClass[name];
90 	} else
91 	{
92 	}
93 
94 	return RT_TYPE_INVALID;
95 }
96 
97 
98