diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-11 12:31:36 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-05-17 22:14:30 +0200 |
commit | bdc0b3e3d7f1f5a07f4863913aef0824dedf9a69 (patch) | |
tree | 1a8c0dc73f0d91a3f00080c5a87f85140d534bd7 /xmloff | |
parent | 30cee1ae3e36c5b3bdae71550298abac5abc8788 (diff) |
crashtesting: assert on fdo62508-1.odt
document, with meta:generator of "opxml2odf - Version KO 0.1" has
a styles.xml xmlns of...
xmlns:ofo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
instead of the usual xmlns:fo=...
use the importer namespace map to get the importers namespace prefix
for the fastparser namespace uri for the token
Change-Id: Ib633009f6c2b7dae5a3ceb1c921adfff84e21150
Reviewed-on: https://gerrit.libreoffice.org/52720
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/core/xmlictxt.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/core/xmlimp.cxx | 10 |
2 files changed, 12 insertions, 4 deletions
diff --git a/xmloff/source/core/xmlictxt.cxx b/xmloff/source/core/xmlictxt.cxx index 7d2cc23d9372..18e1446e190a 100644 --- a/xmloff/source/core/xmlictxt.cxx +++ b/xmloff/source/core/xmlictxt.cxx @@ -70,7 +70,7 @@ void SvXMLImportContext::Characters( const OUString& ) void SAL_CALL SvXMLImportContext::startFastElement(sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList > & Attribs) { mrImport.isFastContext = false; - const OUString& rPrefix = SvXMLImport::getNamespacePrefixFromToken( nElement ); + const OUString& rPrefix = SvXMLImport::getNamespacePrefixFromToken(nElement, &GetImport().GetNamespaceMap()); const OUString& rLocalName = SvXMLImport::getNameFromToken( nElement ); startUnknownElement( SvXMLImport::aDefaultNamespace, (rPrefix.isEmpty())? rLocalName : rPrefix + SvXMLImport::aNamespaceSeparator + rLocalName, Attribs ); } @@ -93,7 +93,7 @@ void SAL_CALL SvXMLImportContext::startUnknownElement(const OUString & /*rNamesp for( auto &it : *pAttribList ) { sal_Int32 nToken = it.getToken(); - const OUString& rAttrNamespacePrefix = SvXMLImport::getNamespacePrefixFromToken( nToken ); + const OUString& rAttrNamespacePrefix = SvXMLImport::getNamespacePrefixFromToken(nToken, &GetImport().GetNamespaceMap()); OUString sAttrName = SvXMLImport::getNameFromToken( nToken ); if ( !rAttrNamespacePrefix.isEmpty() ) sAttrName = rAttrNamespacePrefix + SvXMLImport::aNamespaceSeparator + sAttrName; @@ -117,7 +117,7 @@ void SAL_CALL SvXMLImportContext::startUnknownElement(const OUString & /*rNamesp void SAL_CALL SvXMLImportContext::endFastElement(sal_Int32 nElement) { mrImport.isFastContext = false; - const OUString& rPrefix = SvXMLImport::getNamespacePrefixFromToken( nElement ); + const OUString& rPrefix = SvXMLImport::getNamespacePrefixFromToken(nElement, &GetImport().GetNamespaceMap()); const OUString& rLocalName = SvXMLImport::getNameFromToken( nElement ); endUnknownElement( SvXMLImport::aDefaultNamespace, (rPrefix.isEmpty())? rLocalName : rPrefix + SvXMLImport::aNamespaceSeparator + rLocalName ); } diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 9b2b51060341..fdf943d775a3 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -2042,12 +2042,20 @@ const OUString SvXMLImport::getNameFromToken( sal_Int32 nToken ) aSeq.getConstArray() ), aSeq.getLength(), RTL_TEXTENCODING_UTF8 ); } -const OUString SvXMLImport::getNamespacePrefixFromToken( sal_Int32 nToken ) +const OUString SvXMLImport::getNamespacePrefixFromToken(sal_Int32 nToken, const SvXMLNamespaceMap* pMap) { sal_Int32 nNamespaceToken = ( nToken & NMSP_MASK ) >> NMSP_SHIFT; auto aIter( aNamespaceMap.find( nNamespaceToken ) ); if( aIter != aNamespaceMap.end() ) + { + if (pMap) + { + OUString sRet = pMap->GetPrefixByKey(pMap->GetKeyByName((*aIter).second.second)); + if (!sRet.isEmpty()) + return sRet; + } return (*aIter).second.first; + } else return OUString(); } |