merge the formfield patch from ooo-build
[ooovba.git] / xmloff / source / core / xmltkmap.cxx
blob9463dea06c4c7841b0fc3280c63821ecf046de4a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmltkmap.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include <tools/debug.hxx>
34 #include <rtl/ustring.hxx>
35 #include <svtools/svarray.hxx>
36 #include <xmloff/xmltkmap.hxx>
37 #include <xmloff/xmltoken.hxx>
39 using namespace rtl;
40 using namespace ::xmloff::token;
42 class SvXMLTokenMapEntry_Impl
44 sal_uInt16 nPrefixKey;
45 OUString sLocalName;
46 sal_uInt16 nToken;
48 public:
50 sal_uInt16 GetToken() const { return nToken; }
52 SvXMLTokenMapEntry_Impl( sal_uInt16 nPrefix, const OUString& rLName,
53 sal_uInt16 nTok=XML_TOK_UNKNOWN ) :
54 nPrefixKey( nPrefix ),
55 sLocalName( rLName ),
56 nToken( nTok )
59 SvXMLTokenMapEntry_Impl( const SvXMLTokenMapEntry& rEntry ) :
60 nPrefixKey( rEntry.nPrefixKey ),
61 sLocalName( GetXMLToken( rEntry.eLocalName ) ),
62 nToken( rEntry.nToken )
65 BOOL operator==( const SvXMLTokenMapEntry_Impl& r ) const
67 return nPrefixKey == r.nPrefixKey &&
68 sLocalName == r.sLocalName;
71 BOOL operator<( const SvXMLTokenMapEntry_Impl& r ) const
73 return nPrefixKey < r.nPrefixKey ||
74 ( nPrefixKey == r.nPrefixKey &&
75 sLocalName < r.sLocalName);
79 typedef SvXMLTokenMapEntry_Impl *SvXMLTokenMapEntry_ImplPtr;
80 SV_DECL_PTRARR_SORT_DEL( SvXMLTokenMap_Impl, SvXMLTokenMapEntry_ImplPtr, 5, 5 )
81 SV_IMPL_OP_PTRARR_SORT( SvXMLTokenMap_Impl, SvXMLTokenMapEntry_ImplPtr )
83 // ---------------------------------------------------------------------
85 SvXMLTokenMapEntry_Impl *SvXMLTokenMap::_Find( sal_uInt16 nKeyPrefix,
86 const OUString& rLName ) const
88 SvXMLTokenMapEntry_Impl *pRet = 0;
89 SvXMLTokenMapEntry_Impl aTst( nKeyPrefix, rLName );
91 sal_uInt16 nPos;
92 if( pImpl->Seek_Entry( &aTst, &nPos ) )
94 pRet = (*pImpl)[nPos];
97 return pRet;
100 SvXMLTokenMap::SvXMLTokenMap( const SvXMLTokenMapEntry *pMap ) :
101 pImpl( new SvXMLTokenMap_Impl )
103 while( pMap->eLocalName != XML_TOKEN_INVALID )
105 pImpl->Insert( new SvXMLTokenMapEntry_Impl( *pMap ) );
106 pMap++;
110 SvXMLTokenMap::~SvXMLTokenMap()
112 delete pImpl;
115 sal_uInt16 SvXMLTokenMap::Get( sal_uInt16 nKeyPrefix,
116 const OUString& rLName ) const
118 SvXMLTokenMapEntry_Impl *pEntry = _Find( nKeyPrefix, rLName );
119 if( pEntry )
120 return pEntry->GetToken();
121 else
122 return XML_TOK_UNKNOWN;