22#include <rtl/ustring.hxx>
23#include <rtl/ustrbuf.hxx>
126 nKey =
Add_( rPrefix, rName, nKey );
144 NameSpaceHash::const_iterator aIter =
m_aNameHash.find( rPrefix );
145 if( aIter ==
m_aNameHash.end() || (*aIter).second.m_sName != rName )
146 nKey =
Add_( rPrefix, rName, nKey );
155 NameSpaceHash::const_iterator aIter =
m_aNameHash.find(rPrefix);
156 return (aIter !=
m_aNameHash.end()) ? (*aIter).second.m_nKey : USHRT_MAX;
163 [&rName](
const NameSpaceHash::value_type& rEntry) { return rEntry.second.m_sName == rName; });
166 nKey = (*aIter).second.m_nKey;
189 const OUString &
prefix( (*aIter).second.sPrefix );
197 const OUString& rLocalName,
206 SAL_WARN(
"xmloff.core",
"unknown namespace, probable missing xmlns: declaration");
215 if (!rLocalName.isEmpty())
227 QNameCache::const_iterator aQCacheIter;
233 return (*aQCacheIter).second;
240 const OUString &
prefix( (*aIter).second.sPrefix );
243 sQName =
prefix +
":" + rLocalName;
262 const OUString& rAttrValue,
263 OUString *pLocalName)
const
275 OUString *pLocalName,
276 OUString *pNamespace,
281 NameSpaceHash::const_iterator it;
297 *pNamespace = aMapIter !=
maKeyToNamespaceMap.end() ? (*aMapIter).second.sName : OUString();
302 OUString sEntryPrefix, sEntryName;
304 sal_Int32 nColonPos = rQName.indexOf(
':' );
305 if( -1 == nColonPos )
313 sEntryPrefix = rQName.copy( 0, nColonPos );
314 sEntryName = rQName.copy( nColonPos + 1 );
319 SAL_INFO(
"xmloff",
"invalid attribute name with multiple ':'");
325 *pPrefix = sEntryPrefix;
327 *pLocalName = sEntryName;
329 NameSpaceHash::const_iterator aIter =
m_aNameHash.find( sEntryPrefix );
333 nKey = (*aIter).second.m_nKey;
335 *pNamespace = (*aIter).second.m_sName;
337 else if ( sEntryPrefix ==
m_sXMLNS )
340 else if( nColonPos == -1 )
385 const OUString& rName, sal_uInt16 nKey )
393 Add_( rPrefix, rName, nKey );
416 NameSpaceHash::const_iterator aIter =
m_aNameHash.find(rPrefix);
417 return (aIter !=
m_aNameHash.end()) ? (*aIter).second.m_nKey : USHRT_MAX;
420 const OUString& rAttrName,
421 OUString *pLocalName)
const
428 OUString *pLocalName,
429 OUString *pNamespace )
const
451 bool bSuccess =
false;
452 const OUString& sURIPrefix =
GetXMLToken( XML_URI_W3_PREFIX );
453 if( rName.startsWith( sURIPrefix ) )
455 const OUString& sURISuffix =
GetXMLToken( XML_URI_XFORMS_SUFFIX );
456 sal_Int32 nCompareFrom = rName.getLength() - sURISuffix.getLength();
457 if( rName.subView( nCompareFrom ) == sURISuffix )
472 if(
IsXMLToken( rName, ::xmloff::token::XML_N_SVG ) )
474 rName =
GetXMLToken( ::xmloff::token::XML_N_SVG_COMPAT );
477 else if(
IsXMLToken( rName, ::xmloff::token::XML_N_FO ) )
479 rName =
GetXMLToken( ::xmloff::token::XML_N_FO_COMPAT );
482 else if(
IsXMLToken( rName, ::xmloff::token::XML_N_SMIL ) ||
483 IsXMLToken( rName, ::xmloff::token::XML_N_SMIL_OLD ) )
485 rName =
GetXMLToken( ::xmloff::token::XML_N_SMIL_COMPAT );
495 sal_Int32 nNameLen = rName.getLength();
497 const OUString& rOasisURN =
GetXMLToken( XML_URN_OASIS_NAMES_TC );
498 if( !rName.startsWith( rOasisURN ) )
502 sal_Int32
nPos = rOasisURN.getLength();
503 if(
nPos >= nNameLen || rName[
nPos] !=
':' )
507 sal_Int32 nTCIdStart =
nPos+1;
508 sal_Int32 nTCIdEnd = rName.indexOf(
':', nTCIdStart );
514 std::u16string_view sTmp( rName.subView(
nPos ) );
520 nPos += rXMLNS.getLength();
521 if(
nPos >= nNameLen || rName[
nPos] !=
':' )
525 nPos = rName.indexOf(
':',
nPos+1 );
530 sal_Int32 nVersionStart =
nPos+1;
531 if( nVersionStart+2 >= nNameLen ||
532 -1 != rName.indexOf(
':', nVersionStart ) )
536 if( rName[nVersionStart] !=
'1' || rName[nVersionStart+1] !=
'.' )
541 rName = rName.subView( 0, nTCIdStart ) +
543 rName.subView( nTCIdEnd, nVersionStart-nTCIdEnd ) +
OUString GetQNameByKey(sal_uInt16 nKey, const OUString &rLocalName, bool bCache=true) const
const OUString & GetNameByKey(sal_uInt16 nKey) const
sal_uInt16 GetFirstKey() const
void AddAtIndex(const OUString &rPrefix, const OUString &rName, sal_uInt16 nKey)
const OUString & GetPrefixByIndex(sal_uInt16 nIdx) const
SvXMLNamespaceMap & operator=(const SvXMLNamespaceMap &rCmp)
sal_uInt16 GetKeyByPrefix(const OUString &rPrefix) const
sal_uInt16 GetKeyByAttrName(const OUString &rAttrName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace) const
static bool NormalizeOasisURN(OUString &rName)
static bool NormalizeW3URI(OUString &rName)
OUString GetAttrNameByKey(sal_uInt16 nKey) const
KeyToNameSpaceMap maKeyToNamespaceMap
sal_uInt16 GetKeyByAttrValueQName(const OUString &rAttrName, OUString *pLocalName) const
sal_uInt16 AddIfKnown(const OUString &rPrefix, const OUString &rName)
NameSpaceHash m_aNameCache
sal_uInt16 GetNextKey(sal_uInt16 nOldKey) const
sal_uInt16 GetIndexByPrefix(const OUString &rPrefix) const
sal_uInt16 GetNextIndex(sal_uInt16 nOldIdx) const
bool operator==(const SvXMLNamespaceMap &rCmp) const
SAL_DLLPRIVATE sal_uInt16 Add_(const OUString &rPrefix, const OUString &rName, sal_uInt16 nKey)
sal_uInt16 GetFirstIndex() const
sal_uInt16 Add(const OUString &rPrefix, const OUString &rName, sal_uInt16 nKey=XML_NAMESPACE_UNKNOWN)
OUString GetAttrNameByIndex(sal_uInt16 nIdx) const
sal_uInt16 GetKeyByQName(const OUString &rQName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace, QNameMode eMode) const
const OUString & GetNameByIndex(sal_uInt16 nIdx) const
static bool NormalizeURI(OUString &rName)
static sal_uInt16 GetIndexByKey(sal_uInt16 nKey)
sal_uInt16 GetKeyByName(const OUString &rName) const
NameSpaceHash m_aNameHash
const OUString & GetPrefixByKey(sal_uInt16 nKey) const
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
constexpr OUStringLiteral first
const sal_uInt16 XML_NAMESPACE_UNKNOWN_FLAG
::std::pair< sal_uInt16, OUString > QNamePair
const sal_uInt16 XML_NAMESPACE_NONE
const sal_uInt16 XML_NAMESPACE_UNKNOWN
const sal_uInt16 XML_NAMESPACE_XMLNS
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
Handling of tokens in XML:
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
constexpr sal_uInt16 XML_NAMESPACE_XML