Make SvXMLTokenMap compatible with FastTokens:

Added new methods for the fasttokens and
a lot of entries must be updated in later commits.

Change-Id: I37de9c8d4bdeb75f678902a422a5961670480562
Reviewed-on: https://gerrit.libreoffice.org/28355
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
Daniel Sikeler
2016-08-25 02:19:48 +05:30
committed by Noel Grandin
parent 674e0f0b43
commit e3b3c3fe41
2 changed files with 37 additions and 10 deletions

View File

@@ -28,20 +28,32 @@
class SvXMLTokenMap_Impl;
class SvXMLTokenMapEntry_Impl;
#define XML_TOK_UNKNOWN 0xffffU
#define XML_TOKEN_MAP_END { 0xffffU, ::xmloff::token::XML_TOKEN_INVALID, 0U }
#define XML_TOKEN_MAP_END { 0xffffU, xmloff::token::XML_TOKEN_INVALID, 0U, 0 }
struct SvXMLTokenMapEntry
{
sal_uInt16 nPrefixKey;
enum ::xmloff::token::XMLTokenEnum eLocalName;
enum xmloff::token::XMLTokenEnum eLocalName;
sal_uInt16 nToken;
sal_Int32 nFastToken;
SvXMLTokenMapEntry( sal_uInt16 nPrefix, xmloff::token::XMLTokenEnum eName,
sal_uInt16 nTok = XML_TOK_UNKNOWN, sal_Int32 nFastTok = 0 ) :
nPrefixKey( nPrefix ),
eLocalName( eName ),
nToken( nTok ),
nFastToken( nFastTok )
{}
};
class XMLOFF_DLLPUBLIC SvXMLTokenMap
{
private:
std::unique_ptr<SvXMLTokenMap_Impl> m_pImpl;
sal_uInt16 Get( const SvXMLTokenMapEntry_Impl& rEntry ) const;
public:
@@ -49,6 +61,7 @@ public:
~SvXMLTokenMap();
sal_uInt16 Get( sal_uInt16 nPrefix, const OUString& rLName ) const;
sal_uInt16 Get( sal_Int32 nFastTok ) const;
};
#endif // INCLUDED_XMLOFF_XMLTKMAP_HXX

View File

@@ -30,22 +30,25 @@ class SvXMLTokenMapEntry_Impl
sal_uInt16 nPrefixKey;
OUString sLocalName;
sal_uInt16 nToken;
sal_Int32 nFastToken;
public:
sal_uInt16 GetToken() const { return nToken; }
SvXMLTokenMapEntry_Impl( sal_uInt16 nPrefix, const OUString& rLName,
sal_uInt16 nTok=XML_TOK_UNKNOWN ) :
sal_uInt16 nTok = XML_TOK_UNKNOWN, sal_Int32 nFastTok = 0 ) :
nPrefixKey( nPrefix ),
sLocalName( rLName ),
nToken( nTok )
nToken( nTok ),
nFastToken( nFastTok )
{}
explicit SvXMLTokenMapEntry_Impl( const SvXMLTokenMapEntry& rEntry ) :
nPrefixKey( rEntry.nPrefixKey ),
sLocalName( GetXMLToken( rEntry.eLocalName ) ),
nToken( rEntry.nToken )
nToken( rEntry.nToken ),
nFastToken( rEntry.nFastToken )
{}
bool operator<( const SvXMLTokenMapEntry_Impl& r ) const
@@ -72,13 +75,10 @@ SvXMLTokenMap::~SvXMLTokenMap()
{
}
sal_uInt16 SvXMLTokenMap::Get( sal_uInt16 nKeyPrefix,
const OUString& rLName ) const
sal_uInt16 SvXMLTokenMap::Get( const SvXMLTokenMapEntry_Impl& rEntry ) const
{
SvXMLTokenMapEntry_Impl const* pEntry = nullptr;
SvXMLTokenMapEntry_Impl aTst( nKeyPrefix, rLName );
SvXMLTokenMap_Impl::iterator it = m_pImpl->find( aTst );
SvXMLTokenMap_Impl::iterator it = m_pImpl->find( rEntry );
if (it != m_pImpl->end())
{
pEntry = &*it;
@@ -90,4 +90,18 @@ sal_uInt16 SvXMLTokenMap::Get( sal_uInt16 nKeyPrefix,
return XML_TOK_UNKNOWN;
}
sal_uInt16 SvXMLTokenMap::Get( sal_uInt16 nKeyPrefix,
const OUString& rLName ) const
{
SvXMLTokenMapEntry_Impl aTst( nKeyPrefix, rLName );
return( Get( aTst ) );
}
sal_uInt16 SvXMLTokenMap::Get( sal_Int32 nFastTok ) const
{
static const OUString sEmptyString("");
SvXMLTokenMapEntry_Impl aTst( 0, sEmptyString, XML_TOK_UNKNOWN, nFastTok );
return( Get( aTst ) );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */