[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - include/xmloff xmloff/source
Caolán McNamara
caolanm at redhat.com
Sun May 20 21:45:39 UTC 2018
include/xmloff/xmlimp.hxx | 2 +-
xmloff/source/core/xmlictxt.cxx | 6 +++---
xmloff/source/core/xmlimp.cxx | 10 +++++++++-
3 files changed, 13 insertions(+), 5 deletions(-)
New commits:
commit 3e50044ba41410b9f6a6879f71cdb8314a6d56c3
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Apr 11 12:31:36 2018 +0100
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 at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
Reviewed-on: https://gerrit.libreoffice.org/54548
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx
index b6552a297843..642c5b2e652b 100644
--- a/include/xmloff/xmlimp.hxx
+++ b/include/xmloff/xmlimp.hxx
@@ -376,7 +376,7 @@ public:
XMLEventImportHelper& GetEventImport();
static const OUString getNameFromToken( sal_Int32 nToken );
- static const OUString getNamespacePrefixFromToken( sal_Int32 nToken );
+ static const OUString getNamespacePrefixFromToken(sal_Int32 nToken, const SvXMLNamespaceMap* pMap);
SvXMLNamespaceMap& GetNamespaceMap() { return *mpNamespaceMap; }
const SvXMLNamespaceMap& GetNamespaceMap() const { return *mpNamespaceMap; }
diff --git a/xmloff/source/core/xmlictxt.cxx b/xmloff/source/core/xmlictxt.cxx
index cc5f46ce0c48..832cd5a2c7bf 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;
- startUnknownElement( SvXMLImport::getNamespacePrefixFromToken( nElement ),
+ startUnknownElement( SvXMLImport::getNamespacePrefixFromToken(nElement, &GetImport().GetNamespaceMap()),
SvXMLImport::getNameFromToken( nElement ), Attribs );
}
@@ -99,7 +99,7 @@ void SAL_CALL SvXMLImportContext::startUnknownElement(const OUString & rPrefix,
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 + ":" + sAttrName;
@@ -129,7 +129,7 @@ void SAL_CALL SvXMLImportContext::startUnknownElement(const OUString & rPrefix,
void SAL_CALL SvXMLImportContext::endFastElement(sal_Int32 nElement)
{
mrImport.isFastContext = false;
- endUnknownElement( SvXMLImport::getNamespacePrefixFromToken( nElement ),
+ endUnknownElement( SvXMLImport::getNamespacePrefixFromToken(nElement, &GetImport().GetNamespaceMap()),
SvXMLImport::getNameFromToken( nElement ) );
}
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index af7a0788bf02..310fae5fc9bb 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -2038,12 +2038,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();
}
More information about the Libreoffice-commits
mailing list