summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-02-05 15:00:13 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-02-06 17:30:10 +0100
commitd0ec225bf654bb998fd1e62a1b832aa20464fb90 (patch)
tree6a9dd64f1ad60d8c0caa6a70b4e55bb76e9911ba /sw
parentf842037f72d0b29411aa1e10bec89c297e887fcf (diff)
tdf#129881 missing sections in link section
actually this is a regression from commit 2b77d9dba51e1c3841428f3343e9186ca9c446ae Date: Wed Nov 6 11:19:12 2019 +0200 convert SwXMLSectionList to FastParser the commit mentioned in the bug report was fixed by caolan, and then I broke it again with the above commit Change-Id: If6d3dad7baadcdfcc73d87d1e9d6a91c9f65a6e5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88019 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/swg/SwXMLSectionList.cxx47
-rw-r--r--sw/source/filter/xml/swxml.cxx3
2 files changed, 29 insertions, 21 deletions
diff --git a/sw/source/core/swg/SwXMLSectionList.cxx b/sw/source/core/swg/SwXMLSectionList.cxx
index 2dfcb49e8457..d0df14d7e90d 100644
--- a/sw/source/core/swg/SwXMLSectionList.cxx
+++ b/sw/source/core/swg/SwXMLSectionList.cxx
@@ -36,6 +36,9 @@ private:
public:
SvXMLSectionListContext(SwXMLSectionList& rImport);
+ virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {}
+
virtual css::uno::Reference<css::xml::sax::XFastContextHandler> SAL_CALL createFastChildContext(
sal_Int32 Element,
const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) override;
@@ -52,26 +55,33 @@ public:
{
}
+ virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {}
+
virtual css::uno::Reference<XFastContextHandler> SAL_CALL createFastChildContext(
sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & /*xAttrList*/ ) override
{
if (Element == XML_ELEMENT(OFFICE, XML_BODY) ||
- Element == XML_ELEMENT(TEXT, XML_P) ||
- Element == XML_ELEMENT(TEXT, XML_H) ||
- Element == XML_ELEMENT(TEXT, XML_A) ||
- Element == XML_ELEMENT(TEXT, XML_SPAN) ||
- Element == XML_ELEMENT(TEXT, XML_SECTION) ||
- Element == XML_ELEMENT(TEXT, XML_INDEX_BODY) ||
- Element == XML_ELEMENT(TEXT, XML_INDEX_TITLE) ||
- Element == XML_ELEMENT(TEXT, XML_INSERTION) ||
- Element == XML_ELEMENT(TEXT, XML_DELETION))
+ Element == XML_ELEMENT(OFFICE_OOO, XML_BODY))
{
return new SvXMLSectionListContext(GetImport());
}
- else
+ if ((Element & NMSP_MASK) == NAMESPACE_TOKEN(XML_NAMESPACE_TEXT) ||
+ (Element & NMSP_MASK) == NAMESPACE_TOKEN(XML_NAMESPACE_TEXT_OOO))
{
- return new SwXMLParentContext(GetImport());
+ auto nToken = Element & TOKEN_MASK;
+ if (nToken == XML_P ||
+ nToken == XML_H ||
+ nToken == XML_A ||
+ nToken == XML_SPAN ||
+ nToken == XML_SECTION ||
+ nToken == XML_INDEX_BODY ||
+ nToken == XML_INDEX_TITLE ||
+ nToken == XML_INSERTION ||
+ nToken == XML_DELETION)
+ return new SvXMLSectionListContext(GetImport());
}
+ return new SwXMLParentContext(GetImport());
}
};
@@ -81,14 +91,6 @@ SwXMLSectionList::SwXMLSectionList(const css::uno::Reference< css::uno::XCompone
: SvXMLImport(rContext, "")
, m_rSectionList(rNewSectionList)
{
- // TODO: verify if these should match the same-name constants
- // in xmloff/source/core/xmlimp.cxx ("_office" and "_office")
- GetNamespaceMap().Add( "_ooffice",
- GetXMLToken(XML_N_OFFICE_OOO),
- XML_NAMESPACE_OFFICE );
- GetNamespaceMap().Add( "_otext",
- GetXMLToken(XML_N_TEXT_OOO),
- XML_NAMESPACE_TEXT );
}
SwXMLSectionList::~SwXMLSectionList()
@@ -115,14 +117,17 @@ css::uno::Reference<css::xml::sax::XFastContextHandler> SvXMLSectionListContext:
SvXMLImportContext *pContext = nullptr;
if (Element == XML_ELEMENT(TEXT, XML_SECTION ) ||
- Element == XML_ELEMENT(TEXT, XML_BOOKMARK) )
+ Element == XML_ELEMENT(TEXT, XML_BOOKMARK) ||
+ Element == XML_ELEMENT(TEXT_OOO, XML_SECTION ) ||
+ Element == XML_ELEMENT(TEXT_OOO, XML_BOOKMARK) )
{
sax_fastparser::FastAttributeList *pAttribList =
sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList );
OUString sName;
for (auto &aIter : *pAttribList)
- if (aIter.getToken() == (XML_NAMESPACE_TEXT | XML_NAME))
+ if (aIter.getToken() == XML_ELEMENT(TEXT, XML_NAME) ||
+ aIter.getToken() == XML_ELEMENT(TEXT_OOO, XML_NAME))
sName = aIter.toString();
if ( !sName.isEmpty() )
GetImport().m_rSectionList.push_back(sName);
diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx
index 780479c1e992..d3b84dccf456 100644
--- a/sw/source/filter/xml/swxml.cxx
+++ b/sw/source/filter/xml/swxml.cxx
@@ -1001,14 +1001,17 @@ size_t XMLReader::GetSectionList( SfxMedium& rMedium,
}
catch( xml::sax::SAXParseException& )
{
+ TOOLS_WARN_EXCEPTION("sw", "");
// re throw ?
}
catch( xml::sax::SAXException& )
{
+ TOOLS_WARN_EXCEPTION("sw", "");
// re throw ?
}
catch( io::IOException& )
{
+ TOOLS_WARN_EXCEPTION("sw", "");
// re throw ?
}
catch( packages::WrongPasswordException& )