summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorNoel <noelgrandin@gmail.com>2020-12-04 11:35:32 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-12-04 11:58:33 +0100
commit15c5da78ec773b7b59a092f84dca02de5931e634 (patch)
tree9226248afc3fe2e48075cca002e5fd5c59e3bd2a /xmloff
parent44a3a3a53db57398efa2ec4db026e4ebda086dde (diff)
fastparser in CreateGroupChildContext
Change-Id: I3e3e6785fdedb27353e4d97a9a2bea71c6f2b24a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107189 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/chart/SchXMLChartContext.cxx44
-rw-r--r--xmloff/source/chart/SchXMLChartContext.hxx4
-rw-r--r--xmloff/source/draw/shapeimport.cxx44
-rw-r--r--xmloff/source/draw/ximpgrp.cxx33
-rw-r--r--xmloff/source/draw/ximpgrp.hxx2
-rw-r--r--xmloff/source/draw/ximplink.cxx9
-rw-r--r--xmloff/source/draw/ximplink.hxx5
-rw-r--r--xmloff/source/draw/ximppage.cxx17
-rw-r--r--xmloff/source/draw/ximppage.hxx3
9 files changed, 94 insertions, 67 deletions
diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx
index 5221ffd67140..d6ab1baf5c09 100644
--- a/xmloff/source/chart/SchXMLChartContext.cxx
+++ b/xmloff/source/chart/SchXMLChartContext.cxx
@@ -1020,7 +1020,7 @@ void SchXMLChartContext::MergeSeriesForStockChart()
css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLChartContext::createFastChildContext(
sal_Int32 nElement,
- const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
{
SvXMLImportContext* pContext = nullptr;
uno::Reference< chart::XChartDocument > xDoc = mrImportHelper.GetChartDocument();
@@ -1039,7 +1039,6 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLChartContext::cr
maChartTypeServiceName,
maLSequencesPerIndex, maChartSize );
break;
-
case XML_ELEMENT(CHART, XML_TITLE):
if( xDoc.is())
{
@@ -1052,7 +1051,6 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLChartContext::cr
maMainTitle, xTitleShape );
}
break;
-
case XML_ELEMENT(CHART, XML_SUBTITLE):
if( xDoc.is())
{
@@ -1065,12 +1063,10 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLChartContext::cr
maSubTitle, xTitleShape );
}
break;
-
case XML_ELEMENT(CHART, XML_LEGEND):
pContext = new SchXMLLegendContext( mrImportHelper, GetImport() );
break;
-
- case XML_ELEMENT(TABLE, XML_TABLE):
+ case XML_ELEMENT(TABLE, XML_TABLE):
{
SchXMLTableContext * pTableContext =
new SchXMLTableContext( GetImport(), maTable );
@@ -1103,40 +1099,6 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLChartContext::cr
break;
default:
- break;
- }
-
- return pContext;
-}
-
-SvXMLImportContextRef SchXMLChartContext::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList >& xAttrList )
-{
- SvXMLImportContext* pContext = nullptr;
- const SvXMLTokenMap& rTokenMap = mrImportHelper.GetChartElemTokenMap();
- uno::Reference< chart::XChartDocument > xDoc = mrImportHelper.GetChartDocument();
- uno::Reference< beans::XPropertySet > xProp( xDoc, uno::UNO_QUERY );
-
- switch( rTokenMap.Get( nPrefix, rLocalName ))
- {
- case XML_TOK_CHART_PLOT_AREA:
- break;
-
- case XML_TOK_CHART_TITLE:
- break;
-
- case XML_TOK_CHART_SUBTITLE:
- break;
-
- case XML_TOK_CHART_LEGEND:
- break;
-
- case XML_TOK_CHART_TABLE:
- break;
-
- default:
// try importing as an additional shape
if( ! mxDrawPage.is())
{
@@ -1148,7 +1110,7 @@ SvXMLImportContextRef SchXMLChartContext::CreateChildContext(
}
if( mxDrawPage.is())
pContext = GetImport().GetShapeImport()->CreateGroupChildContext(
- GetImport(), nPrefix, rLocalName, xAttrList, mxDrawPage );
+ GetImport(), nElement, xAttrList, mxDrawPage );
break;
}
diff --git a/xmloff/source/chart/SchXMLChartContext.hxx b/xmloff/source/chart/SchXMLChartContext.hxx
index 251431912d75..a40465394df0 100644
--- a/xmloff/source/chart/SchXMLChartContext.hxx
+++ b/xmloff/source/chart/SchXMLChartContext.hxx
@@ -85,10 +85,6 @@ public:
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
- virtual SvXMLImportContextRef CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
private:
SchXMLTable maTable;
diff --git a/xmloff/source/draw/shapeimport.cxx b/xmloff/source/draw/shapeimport.cxx
index 2a2d5e137eb4..9a26ea3576be 100644
--- a/xmloff/source/draw/shapeimport.cxx
+++ b/xmloff/source/draw/shapeimport.cxx
@@ -20,6 +20,7 @@
#include <tools/debug.hxx>
#include <tools/diagnose_ex.h>
#include <sal/log.hxx>
+#include <comphelper/attributelist.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/text/PositionLayoutDir.hpp>
@@ -419,6 +420,49 @@ void XMLShapeImportHelper::SetAutoStylesContext(SvXMLStylesContext* pNew)
SvXMLShapeContext* XMLShapeImportHelper::CreateGroupChildContext(
SvXMLImport& rImport,
+ sal_Int32 Element,
+ const uno::Reference< xml::sax::XFastAttributeList>& Attribs,
+ uno::Reference< drawing::XShapes > const & rShapes,
+ bool bTemporaryShape)
+{
+ // fall back to slow-parser path
+ const OUString& rPrefix = SvXMLImport::getNamespacePrefixFromToken(Element, &rImport.GetNamespaceMap());
+ const OUString& rLocalName = SvXMLImport::getNameFromToken( Element );
+ OUString aName = rPrefix.isEmpty() ? rLocalName : rPrefix + SvXMLImport::aNamespaceSeparator + rLocalName;
+ OUString aLocalName;
+ sal_uInt16 nPrefix =
+ rImport.GetNamespaceMap().GetKeyByAttrName( aName, &aLocalName );
+
+ rtl::Reference < comphelper::AttributeList > maAttrList = new comphelper::AttributeList();
+
+ if ( Attribs.is() )
+ {
+ for( auto &it : sax_fastparser::castToFastAttributeList( Attribs ) )
+ {
+ sal_Int32 nToken = it.getToken();
+ const OUString& rAttrNamespacePrefix = SvXMLImport::getNamespacePrefixFromToken(nToken, &rImport.GetNamespaceMap());
+ OUString sAttrName = SvXMLImport::getNameFromToken( nToken );
+ if ( !rAttrNamespacePrefix.isEmpty() )
+ sAttrName = rAttrNamespacePrefix + SvXMLImport::aNamespaceSeparator + sAttrName;
+
+ maAttrList->AddAttribute( sAttrName, "CDATA", it.toString() );
+ }
+
+ const uno::Sequence< xml::Attribute > unknownAttribs = Attribs->getUnknownAttributes();
+ for ( const auto& rUnknownAttrib : unknownAttribs )
+ {
+ const OUString& rAttrValue = rUnknownAttrib.Value;
+ const OUString& rAttrName = rUnknownAttrib.Name;
+ // note: rAttrName is expected to be namespace-prefixed here
+ maAttrList->AddAttribute( rAttrName, "CDATA", rAttrValue );
+ }
+ }
+
+ return CreateGroupChildContext(rImport, nPrefix, aLocalName, maAttrList.get(), rShapes, bTemporaryShape );
+}
+
+SvXMLShapeContext* XMLShapeImportHelper::CreateGroupChildContext(
+ SvXMLImport& rImport,
sal_uInt16 p_nPrefix,
const OUString& rLocalName,
const uno::Reference< xml::sax::XAttributeList>& xAttrList,
diff --git a/xmloff/source/draw/ximpgrp.cxx b/xmloff/source/draw/ximpgrp.cxx
index 6627cfacb692..716e0d5f506b 100644
--- a/xmloff/source/draw/ximpgrp.cxx
+++ b/xmloff/source/draw/ximpgrp.cxx
@@ -41,6 +41,35 @@ SdXMLGroupShapeContext::~SdXMLGroupShapeContext()
{
}
+css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLGroupShapeContext::createFastChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
+{
+ // #i68101#
+ if( nElement == XML_ELEMENT(SVG, XML_TITLE) ||
+ nElement == XML_ELEMENT(SVG, XML_DESC ) ||
+ nElement == XML_ELEMENT(SVG_COMPAT, XML_TITLE) ||
+ nElement == XML_ELEMENT(SVG_COMPAT, XML_DESC ) )
+ {
+ // handled in CreateChildContext
+ }
+ else if( nElement == XML_ELEMENT(OFFICE, XML_EVENT_LISTENERS) )
+ {
+ // handled in CreateChildContext
+ }
+ else if( nElement == XML_ELEMENT(DRAW, XML_GLUE_POINT) )
+ {
+ // handled in CreateChildContext
+ }
+ else
+ {
+ // call GroupChildContext function at common ShapeImport
+ return GetImport().GetShapeImport()->CreateGroupChildContext(
+ GetImport(), nElement, xAttrList, mxChildren);
+ }
+ return nullptr;
+}
+
SvXMLImportContextRef SdXMLGroupShapeContext::CreateChildContext( sal_uInt16 nPrefix,
const OUString& rLocalName,
const uno::Reference< xml::sax::XAttributeList>& xAttrList )
@@ -63,9 +92,7 @@ SvXMLImportContextRef SdXMLGroupShapeContext::CreateChildContext( sal_uInt16 nPr
}
else
{
- // call GroupChildContext function at common ShapeImport
- xContext = GetImport().GetShapeImport()->CreateGroupChildContext(
- GetImport(), nPrefix, rLocalName, xAttrList, mxChildren);
+ // handled in createFastChildContext
}
return xContext;
diff --git a/xmloff/source/draw/ximpgrp.hxx b/xmloff/source/draw/ximpgrp.hxx
index e0c6802b9f08..c775e2e35bfc 100644
--- a/xmloff/source/draw/ximpgrp.hxx
+++ b/xmloff/source/draw/ximpgrp.hxx
@@ -46,6 +46,8 @@ public:
sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
+ virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
+ sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
};
#endif // INCLUDED_XMLOFF_SOURCE_DRAW_XIMPGRP_HXX
diff --git a/xmloff/source/draw/ximplink.cxx b/xmloff/source/draw/ximplink.cxx
index 08049faac123..cebd3086c7f4 100644
--- a/xmloff/source/draw/ximplink.cxx
+++ b/xmloff/source/draw/ximplink.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/log.hxx>
#include <xmloff/xmlimp.hxx>
#include <xmloff/xmlnamespace.hxx>
#include "ximplink.hxx"
@@ -50,11 +51,11 @@ SdXMLShapeLinkContext::~SdXMLShapeLinkContext()
{
}
-SvXMLImportContextRef SdXMLShapeLinkContext::CreateChildContext( sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList>& xAttrList )
+css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLShapeLinkContext::createFastChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
{
- SvXMLShapeContext* pContext = GetImport().GetShapeImport()->CreateGroupChildContext( GetImport(), nPrefix, rLocalName, xAttrList, mxParent);
+ SvXMLShapeContext* pContext = GetImport().GetShapeImport()->CreateGroupChildContext( GetImport(), nElement, xAttrList, mxParent);
if( pContext )
{
diff --git a/xmloff/source/draw/ximplink.hxx b/xmloff/source/draw/ximplink.hxx
index d5d075a2f993..3055d85204af 100644
--- a/xmloff/source/draw/ximplink.hxx
+++ b/xmloff/source/draw/ximplink.hxx
@@ -41,9 +41,8 @@ public:
css::uno::Reference< css::drawing::XShapes > const & rShapes);
virtual ~SdXMLShapeLinkContext() override;
- virtual SvXMLImportContextRef CreateChildContext(
- sal_uInt16 nPrefix, const OUString& rLocalName,
- const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) override;
+ virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
+ sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
};
#endif // INCLUDED_XMLOFF_SOURCE_DRAW_XIMPLINK_HXX
diff --git a/xmloff/source/draw/ximppage.cxx b/xmloff/source/draw/ximppage.cxx
index 486c0e05f4d9..8b8342bd0edc 100644
--- a/xmloff/source/draw/ximppage.cxx
+++ b/xmloff/source/draw/ximppage.cxx
@@ -261,18 +261,17 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLGenericPageContex
if( mxAnnotationAccess.is() )
return new DrawAnnotationContext( GetImport(), xAttrList, mxAnnotationAccess );
}
+ else
+ {
+ // call GroupChildContext function at common ShapeImport
+ auto p = GetImport().GetShapeImport()->CreateGroupChildContext(GetImport(), nElement, xAttrList, mxShapes);
+ if (p)
+ return p;
+ }
+ XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
return nullptr;
}
-SvXMLImportContextRef SdXMLGenericPageContext::CreateChildContext( sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const Reference< xml::sax::XAttributeList>& xAttrList )
-{
- // call GroupChildContext function at common ShapeImport
- return GetImport().GetShapeImport()->CreateGroupChildContext(
- GetImport(), nPrefix, rLocalName, xAttrList, mxShapes);
-}
-
void SdXMLGenericPageContext::endFastElement(sal_Int32 )
{
GetImport().GetShapeImport()->popGroupAndPostProcess();
diff --git a/xmloff/source/draw/ximppage.hxx b/xmloff/source/draw/ximppage.hxx
index daa47f9ec48a..2bde07d12a18 100644
--- a/xmloff/source/draw/ximppage.hxx
+++ b/xmloff/source/draw/ximppage.hxx
@@ -65,9 +65,6 @@ public:
virtual ~SdXMLGenericPageContext() override;
virtual void SAL_CALL startFastElement( sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
- virtual SvXMLImportContextRef CreateChildContext(
- sal_uInt16 nPrefix, const OUString& rLocalName,
- const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) override;
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;