xref: /aoo42x/main/sw/source/filter/xml/xmlitmpr.cxx (revision efeef26f)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 #include <rtl/ustring.hxx>
27 #include "xmlitmap.hxx"
28 
29 using rtl::OUString;
30 using ::xmloff::token::IsXMLToken;
31 using ::xmloff::token::XML_TOKEN_INVALID;
32 
33 // TODO: optimize this!
34 
35 class SvXMLItemMapEntries_impl
36 {
37 public:
38 	SvXMLItemMapEntry* mpEntries;
39 	sal_uInt16 mnCount;
40 };
41 
SvXMLItemMapEntries(SvXMLItemMapEntry * pEntries)42 SvXMLItemMapEntries::SvXMLItemMapEntries( SvXMLItemMapEntry* pEntries )
43 {
44 	mpImpl = new SvXMLItemMapEntries_impl;
45 	mpImpl->mpEntries = pEntries;
46 
47 	mpImpl->mnCount = 0;
48 	while( pEntries->eLocalName != XML_TOKEN_INVALID )
49 	{
50 		pEntries++;
51 		mpImpl->mnCount++;
52 	}
53 }
54 
~SvXMLItemMapEntries()55 SvXMLItemMapEntries::~SvXMLItemMapEntries()
56 {
57 	delete mpImpl;
58 }
59 
getByName(sal_uInt16 nNameSpace,const OUString & rString,SvXMLItemMapEntry * pStartAt) const60 SvXMLItemMapEntry* SvXMLItemMapEntries::getByName(	sal_uInt16 nNameSpace,
61 													const OUString& rString,
62 													SvXMLItemMapEntry* pStartAt /* = NULL */  ) const
63 {
64 	SvXMLItemMapEntry* pMap =
65         (pStartAt && (pStartAt->eLocalName!=XML_TOKEN_INVALID)) ?
66                                            &(pStartAt[1]) : mpImpl->mpEntries;
67 	while( pMap && (pMap->eLocalName != XML_TOKEN_INVALID) )
68 	{
69 		if( pMap->nNameSpace == nNameSpace &&
70             IsXMLToken( rString, pMap->eLocalName ) )
71 			break;
72 		pMap++;
73 	}
74 
75 	return (pMap->eLocalName != XML_TOKEN_INVALID) ? pMap : NULL;
76 }
77 
getByIndex(sal_uInt16 nIndex) const78 SvXMLItemMapEntry* SvXMLItemMapEntries::getByIndex( sal_uInt16 nIndex ) const
79 {
80 	return &mpImpl->mpEntries[nIndex];
81 }
82 
getCount() const83 sal_uInt16 SvXMLItemMapEntries::getCount() const
84 {
85 	return mpImpl->mnCount;
86 }
87 
88