summaryrefslogtreecommitdiff
path: root/xmloff/source/text
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2020-01-19 12:08:09 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-01-19 18:36:34 +0100
commit55f224ff57cf16057e0493ee4f9b8a14132d7ec1 (patch)
tree75c42a6fe5f4c09967768b5bd5c0c8e42b129260 /xmloff/source/text
parent51cb4c23563307417818106446152e5adc311ab7 (diff)
tdf#129883 Section links are lost on save and reload
Revert "convert XMLSectionSourceImportContext to FastParser APIs" This reverts commit ccdcc25a085299bda45bc5ea4b3594e856f2d315. THis was one of my earliest fastparser attempts before I properly understood the weirde workings of the SvImportXML stuff. Change-Id: I729467cb513740d36c0483eb6f8c84ffa4cab578 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87038 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff/source/text')
-rw-r--r--xmloff/source/text/XMLSectionSourceImportContext.cxx52
-rw-r--r--xmloff/source/text/XMLSectionSourceImportContext.hxx6
2 files changed, 40 insertions, 18 deletions
diff --git a/xmloff/source/text/XMLSectionSourceImportContext.cxx b/xmloff/source/text/XMLSectionSourceImportContext.cxx
index 82e01979ab0c..2ae4e671f7c0 100644
--- a/xmloff/source/text/XMLSectionSourceImportContext.cxx
+++ b/xmloff/source/text/XMLSectionSourceImportContext.cxx
@@ -32,7 +32,6 @@
using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::xml::sax::XAttributeList;
-using ::com::sun::star::xml::sax::XFastAttributeList;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::text;
@@ -53,31 +52,54 @@ XMLSectionSourceImportContext::~XMLSectionSourceImportContext()
{
}
+namespace {
+enum XMLSectionSourceToken
+{
+ XML_TOK_SECTION_XLINK_HREF,
+ XML_TOK_SECTION_TEXT_FILTER_NAME,
+ XML_TOK_SECTION_TEXT_SECTION_NAME
+};
+
+}
+
+static const SvXMLTokenMapEntry aSectionSourceTokenMap[] =
+{
+ { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_SECTION_XLINK_HREF },
+ { XML_NAMESPACE_TEXT, XML_FILTER_NAME, XML_TOK_SECTION_TEXT_FILTER_NAME },
+ { XML_NAMESPACE_TEXT, XML_SECTION_NAME,
+ XML_TOK_SECTION_TEXT_SECTION_NAME },
+ XML_TOKEN_MAP_END
+};
+
-void XMLSectionSourceImportContext::startFastElement(sal_Int32 /*nElement*/,
- const Reference<XFastAttributeList> & xAttrList)
+void XMLSectionSourceImportContext::StartElement(
+ const Reference<XAttributeList> & xAttrList)
{
+ static const SvXMLTokenMap aTokenMap(aSectionSourceTokenMap);
OUString sURL;
OUString sFilterName;
OUString sSectionName;
- sax_fastparser::FastAttributeList *pAttribList =
- sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList );
-
- for (auto &aIter : *pAttribList)
+ sal_Int16 nLength = xAttrList->getLength();
+ for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
{
- switch (aIter.getToken())
+ OUString sLocalName;
+ sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
+ GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
+ &sLocalName );
+
+ switch (aTokenMap.Get(nPrefix, sLocalName))
{
- case XML_ELEMENT(XLINK, XML_HREF):
- sURL = aIter.toString();
+ case XML_TOK_SECTION_XLINK_HREF:
+ sURL = xAttrList->getValueByIndex(nAttr);
break;
- case XML_ELEMENT(TEXT, XML_FILTER_NAME):
- sFilterName = aIter.toString();
+ case XML_TOK_SECTION_TEXT_FILTER_NAME:
+ sFilterName = xAttrList->getValueByIndex(nAttr);
break;
- case XML_ELEMENT(TEXT, XML_SECTION_NAME):
- sSectionName = aIter.toString();
+ case XML_TOK_SECTION_TEXT_SECTION_NAME:
+ sSectionName = xAttrList->getValueByIndex(nAttr);
break;
default:
@@ -105,7 +127,7 @@ void XMLSectionSourceImportContext::startFastElement(sal_Int32 /*nElement*/,
}
}
-void XMLSectionSourceImportContext::endFastElement(sal_Int32 /*nElement*/)
+void XMLSectionSourceImportContext::EndElement()
{
// this space intentionally left blank.
}
diff --git a/xmloff/source/text/XMLSectionSourceImportContext.hxx b/xmloff/source/text/XMLSectionSourceImportContext.hxx
index 838375ff7e78..865e9753ff6f 100644
--- a/xmloff/source/text/XMLSectionSourceImportContext.hxx
+++ b/xmloff/source/text/XMLSectionSourceImportContext.hxx
@@ -45,10 +45,10 @@ public:
protected:
- virtual void SAL_CALL startFastElement(sal_Int32 nElement,
- const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList) override;
+ virtual void StartElement(
+ const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList) override;
- virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
+ virtual void EndElement() override;
};
#endif