1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <rtl/ustring.hxx>
21 #include <xmloff/xmltkmap.hxx>
22 #include <xmloff/xmltoken.hxx>
23 #include <boost/ptr_container/ptr_set.hpp>
25 using namespace ::xmloff::token
;
27 class SvXMLTokenMapEntry_Impl
29 sal_uInt16 nPrefixKey
;
35 sal_uInt16
GetToken() const { return nToken
; }
37 SvXMLTokenMapEntry_Impl( sal_uInt16 nPrefix
, const OUString
& rLName
,
38 sal_uInt16 nTok
=XML_TOK_UNKNOWN
) :
39 nPrefixKey( nPrefix
),
44 SvXMLTokenMapEntry_Impl( const SvXMLTokenMapEntry
& rEntry
) :
45 nPrefixKey( rEntry
.nPrefixKey
),
46 sLocalName( GetXMLToken( rEntry
.eLocalName
) ),
47 nToken( rEntry
.nToken
)
50 bool operator<( const SvXMLTokenMapEntry_Impl
& r
) const
52 return nPrefixKey
< r
.nPrefixKey
||
53 ( nPrefixKey
== r
.nPrefixKey
&&
54 sLocalName
< r
.sLocalName
);
58 class SvXMLTokenMap_Impl
: public boost::ptr_set
<SvXMLTokenMapEntry_Impl
> {};
60 SvXMLTokenMapEntry_Impl
*SvXMLTokenMap::_Find( sal_uInt16 nKeyPrefix
,
61 const OUString
& rLName
) const
63 SvXMLTokenMapEntry_Impl
*pRet
= 0;
64 SvXMLTokenMapEntry_Impl
aTst( nKeyPrefix
, rLName
);
66 SvXMLTokenMap_Impl::iterator it
= pImpl
->find( aTst
);
67 if( it
!= pImpl
->end() )
75 SvXMLTokenMap::SvXMLTokenMap( const SvXMLTokenMapEntry
*pMap
) :
76 pImpl( new SvXMLTokenMap_Impl
)
78 while( pMap
->eLocalName
!= XML_TOKEN_INVALID
)
80 pImpl
->insert( new SvXMLTokenMapEntry_Impl( *pMap
) );
85 SvXMLTokenMap::~SvXMLTokenMap()
90 sal_uInt16
SvXMLTokenMap::Get( sal_uInt16 nKeyPrefix
,
91 const OUString
& rLName
) const
93 SvXMLTokenMapEntry_Impl
*pEntry
= _Find( nKeyPrefix
, rLName
);
95 return pEntry
->GetToken();
97 return XML_TOK_UNKNOWN
;
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */