diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-29 11:19:28 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-12-07 08:52:49 +0100 |
commit | 5080bb930de3ecfce8ab78bbd23a9d48c2f2bfa0 (patch) | |
tree | 9f92d184627177dbd83dedda40d4a4abb531381e /sc | |
parent | 121464be43830a6f6bfbc27a17c8e0bc7577f455 (diff) |
convert SvXMLImport to fastparser, drop slowparser paths
Change-Id: I0f880a7680373043fecf083cdf4de8b0bb7041a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103775
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/xml/XMLTableShapeImportHelper.cxx | 81 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLTableShapeImportHelper.hxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLTableShapesContext.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLTrackedChangesContext.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xml/importcontext.cxx | 5 | ||||
-rw-r--r-- | sc/source/filter/xml/importcontext.hxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlannoi.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcelli.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlconti.cxx | 9 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlconti.hxx | 3 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlstyli.cxx | 1 |
11 files changed, 42 insertions, 71 deletions
diff --git a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx index 32317e7ec86e..443f23d611d2 100644 --- a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx +++ b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx @@ -74,7 +74,7 @@ static uno::Reference< drawing::XShape > lcl_getTopLevelParent( const uno::Refer void XMLTableShapeImportHelper::finishShape( uno::Reference< drawing::XShape >& rShape, - const uno::Reference< xml::sax::XAttributeList >& xAttrList, + const uno::Reference< xml::sax::XFastAttributeList >& xAttrList, uno::Reference< drawing::XShapes >& rShapes ) { bool bNote = false; @@ -93,51 +93,48 @@ void XMLTableShapeImportHelper::finishShape( sal_Int32 nEndX(-1); sal_Int32 nEndY(-1); - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; std::optional<OUString> xRangeList; SdrLayerID nLayerID = SDRLAYER_NOTFOUND; - for( sal_Int16 i=0; i < nAttrCount; ++i ) + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { - const OUString& rAttrName(xAttrList->getNameByIndex( i )); - const OUString& rValue(xAttrList->getValueByIndex( i )); - - OUString aLocalName; - sal_uInt16 nPrefix( - static_cast<ScXMLImport&>(mrImporter).GetNamespaceMap().GetKeyByAttrName( rAttrName, - &aLocalName )); - if(nPrefix == XML_NAMESPACE_TABLE) + const OUString sValue = aIter.toString(); + + switch(aIter.getToken()) { - if (IsXMLToken(aLocalName, XML_END_CELL_ADDRESS)) + case XML_ELEMENT(TABLE, XML_END_CELL_ADDRESS): { sal_Int32 nOffset(0); ScDocument* pDoc = static_cast<ScXMLImport&>(mrImporter).GetDocument(); assert(pDoc); - ScRangeStringConverter::GetAddressFromString(aAnchor.maEnd, rValue, *pDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset); + ScRangeStringConverter::GetAddressFromString(aAnchor.maEnd, sValue, *pDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset); // When the cell end address is set, we let the shape resize with the cell aAnchor.mbResizeWithCell = true; + break; } - else if (IsXMLToken(aLocalName, XML_END_X)) + case XML_ELEMENT(TABLE, XML_END_X): { static_cast<ScXMLImport&>(mrImporter). GetMM100UnitConverter().convertMeasureToCore( - nEndX, rValue); + nEndX, sValue); aAnchor.maEndOffset.setX( nEndX ); + break; } - else if (IsXMLToken(aLocalName, XML_END_Y)) + case XML_ELEMENT(TABLE, XML_END_Y): { static_cast<ScXMLImport&>(mrImporter). GetMM100UnitConverter().convertMeasureToCore( - nEndY, rValue); + nEndY, sValue); aAnchor.maEndOffset.setY( nEndY ); + break; } - else if (IsXMLToken(aLocalName, XML_TABLE_BACKGROUND)) - if (IsXMLToken(rValue, XML_TRUE)) + case XML_ELEMENT(TABLE, XML_TABLE_BACKGROUND): + if (IsXMLToken(sValue, XML_TRUE)) nLayerID = SC_LAYER_BACK; - } - else if(nPrefix == XML_NAMESPACE_DRAW) - { - if (IsXMLToken(aLocalName, XML_NOTIFY_ON_UPDATE_OF_RANGES)) - xRangeList = rValue; + break; + case XML_ELEMENT(DRAW, XML_NOTIFY_ON_UPDATE_OF_RANGES): + xRangeList = sValue; + break; + default: ; } } SetLayer(rShape, nLayerID, rShape->getShapeType()); @@ -168,18 +165,18 @@ void XMLTableShapeImportHelper::finishShape( // get the style names for stream copying OUString aStyleName; OUString aTextStyle; - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for( sal_Int16 i=0; i < nAttrCount; ++i ) + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { - const OUString& rAttrName(xAttrList->getNameByIndex( i )); - OUString aLocalName; - sal_uInt16 nPrefix(static_cast<ScXMLImport&>(mrImporter).GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName )); - if(nPrefix == XML_NAMESPACE_DRAW) + const OUString sValue = aIter.toString(); + switch (aIter.getToken()) { - if (IsXMLToken(aLocalName, XML_STYLE_NAME)) - aStyleName = xAttrList->getValueByIndex( i ); - else if (IsXMLToken(aLocalName, XML_TEXT_STYLE_NAME)) - aTextStyle = xAttrList->getValueByIndex( i ); + case XML_ELEMENT(DRAW, XML_STYLE_NAME): + aStyleName = sValue; + break; + case XML_ELEMENT(DRAW, XML_TEXT_STYLE_NAME): + aTextStyle = sValue; + break; + default:; } } @@ -214,20 +211,14 @@ void XMLTableShapeImportHelper::finishShape( } } } - sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0); SdrLayerID nLayerID = SDRLAYER_NOTFOUND; - for( sal_Int16 i=0; i < nAttrCount; ++i ) + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { - const OUString& rAttrName(xAttrList->getNameByIndex( i )); - const OUString& rValue(xAttrList->getValueByIndex( i )); - - OUString aLocalName; - sal_uInt16 nPrefix(static_cast<ScXMLImport&>(mrImporter).GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName )); - if(nPrefix == XML_NAMESPACE_TABLE) + if (aIter.getToken() == XML_ELEMENT(TABLE, XML_TABLE_BACKGROUND)) { - if (IsXMLToken(aLocalName, XML_TABLE_BACKGROUND)) - if (IsXMLToken(rValue, XML_TRUE)) - nLayerID = SC_LAYER_BACK; + if (IsXMLToken(aIter.toString(), XML_TRUE)) + nLayerID = SC_LAYER_BACK; + break; } } SetLayer(rShape, nLayerID, rShape->getShapeType()); diff --git a/sc/source/filter/xml/XMLTableShapeImportHelper.hxx b/sc/source/filter/xml/XMLTableShapeImportHelper.hxx index 55d85f6ad919..188411a97ce0 100644 --- a/sc/source/filter/xml/XMLTableShapeImportHelper.hxx +++ b/sc/source/filter/xml/XMLTableShapeImportHelper.hxx @@ -40,7 +40,7 @@ public: static void SetLayer(const css::uno::Reference<css::drawing::XShape>& rShape, SdrLayerID nLayerID, std::u16string_view sType); virtual void finishShape(css::uno::Reference< css::drawing::XShape >& rShape, - const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList, css::uno::Reference< css::drawing::XShapes >& rShapes) override; void SetCell (const ScAddress& rAddress) { aStartCell = rAddress; } diff --git a/sc/source/filter/xml/XMLTableShapesContext.cxx b/sc/source/filter/xml/XMLTableShapesContext.cxx index 866d6107d591..676bc560faa5 100644 --- a/sc/source/filter/xml/XMLTableShapesContext.cxx +++ b/sc/source/filter/xml/XMLTableShapesContext.cxx @@ -43,7 +43,7 @@ uno::Reference< xml::sax::XFastContextHandler > ScXMLTableShapesContext::createF { XMLTableShapeImportHelper* pTableShapeImport(static_cast<XMLTableShapeImportHelper*>(rXMLImport.GetShapeImport().get())); pTableShapeImport->SetOnTable(true); - return GetImport().GetShapeImport()->CreateGroupChildContext( + return XMLShapeImportHelper::CreateGroupChildContext( rXMLImport, nElement, xAttrList, xShapes); } XMLOFF_WARN_UNKNOWN_ELEMENT("sc", nElement); diff --git a/sc/source/filter/xml/XMLTrackedChangesContext.cxx b/sc/source/filter/xml/XMLTrackedChangesContext.cxx index 74f0810831d8..2accb0987344 100644 --- a/sc/source/filter/xml/XMLTrackedChangesContext.cxx +++ b/sc/source/filter/xml/XMLTrackedChangesContext.cxx @@ -693,7 +693,7 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLChangeTextPContext { if (!bWasContext) pTextPContext->characters(sText.makeStringAndClear()); - xContext = pTextPContext->createFastChildContextFallback(nElement, xAttrList); + xContext = pTextPContext->createFastChildContext(nElement, xAttrList); } } diff --git a/sc/source/filter/xml/importcontext.cxx b/sc/source/filter/xml/importcontext.cxx index 611c704c75c8..ef493f23b432 100644 --- a/sc/source/filter/xml/importcontext.cxx +++ b/sc/source/filter/xml/importcontext.cxx @@ -10,11 +10,6 @@ #include "importcontext.hxx" #include "xmlimprt.hxx" -ScXMLImportContext::ScXMLImportContext(ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName) : - SvXMLImportContext(rImport, nPrefix, rLocalName) -{ -} - ScXMLImportContext::ScXMLImportContext(SvXMLImport& rImport ) : SvXMLImportContext( rImport ) { diff --git a/sc/source/filter/xml/importcontext.hxx b/sc/source/filter/xml/importcontext.hxx index 0ed1c4d7ed49..01f09dadb051 100644 --- a/sc/source/filter/xml/importcontext.hxx +++ b/sc/source/filter/xml/importcontext.hxx @@ -20,8 +20,6 @@ class ScXMLImport; class ScXMLImportContext : public SvXMLImportContext { public: - ScXMLImportContext(ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName); - ScXMLImportContext(SvXMLImport& rImport); protected: diff --git a/sc/source/filter/xml/xmlannoi.cxx b/sc/source/filter/xml/xmlannoi.cxx index d14fb587645c..143d60a414c1 100644 --- a/sc/source/filter/xml/xmlannoi.cxx +++ b/sc/source/filter/xml/xmlannoi.cxx @@ -52,7 +52,7 @@ ScXMLAnnotationContext::ScXMLAnnotationContext( ScXMLImport& rImport, { XMLTableShapeImportHelper* pTableShapeImport = static_cast<XMLTableShapeImportHelper*>(GetScImport().GetShapeImport().get()); pTableShapeImport->SetAnnotation(this); - pShapeContext.reset( GetImport().GetShapeImport()->CreateGroupChildContext( + pShapeContext.reset( XMLShapeImportHelper::CreateGroupChildContext( GetScImport(), nElement, xAttrList, xLocalShapes, true) ); } @@ -126,7 +126,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > ScXMLAnnotationContext if( pShapeContext ) { - auto p = pShapeContext->createFastChildContextFallback(nElement, xAttrList); + auto p = pShapeContext->createFastChildContext(nElement, xAttrList); if (p) return p; } diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index 3b1bab4f34ab..26d85c4768f4 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -697,7 +697,7 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLTableRowCellContex static_cast< XMLTableShapeImportHelper* >( rXMLImport.GetShapeImport().get() ); pTableShapeImport->SetOnTable(false); pTableShapeImport->SetCell(aCellPos); - pContext = GetImport().GetShapeImport()->CreateGroupChildContext( + pContext = XMLShapeImportHelper::CreateGroupChildContext( rXMLImport, nElement, xAttrList, xShapes); if (pContext) { diff --git a/sc/source/filter/xml/xmlconti.cxx b/sc/source/filter/xml/xmlconti.cxx index 871cabf888be..532354f28bf2 100644 --- a/sc/source/filter/xml/xmlconti.cxx +++ b/sc/source/filter/xml/xmlconti.cxx @@ -27,15 +27,6 @@ using namespace xmloff::token; ScXMLContentContext::ScXMLContentContext( ScXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - OUStringBuffer& sTempValue) : - ScXMLImportContext( rImport, nPrfx, rLName ), - sValue(sTempValue) -{ -} - -ScXMLContentContext::ScXMLContentContext( ScXMLImport& rImport, OUStringBuffer& sTempValue) : ScXMLImportContext( rImport ), sValue(sTempValue) diff --git a/sc/source/filter/xml/xmlconti.hxx b/sc/source/filter/xml/xmlconti.hxx index 2eb568a27e24..eb3cbf40dec1 100644 --- a/sc/source/filter/xml/xmlconti.hxx +++ b/sc/source/filter/xml/xmlconti.hxx @@ -28,9 +28,6 @@ class ScXMLContentContext : public ScXMLImportContext public: - ScXMLContentContext( ScXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLName, - OUStringBuffer& sValue); ScXMLContentContext( ScXMLImport& rImport, OUStringBuffer& sValue); diff --git a/sc/source/filter/xml/xmlstyli.cxx b/sc/source/filter/xml/xmlstyli.cxx index 20ea0dffaa75..3a0fd7ecf2ba 100644 --- a/sc/source/filter/xml/xmlstyli.cxx +++ b/sc/source/filter/xml/xmlstyli.cxx @@ -263,7 +263,6 @@ namespace { class XMLTableCellPropsContext : public SvXMLPropertySetContext { - using SvXMLPropertySetContext::CreateChildContext; public: XMLTableCellPropsContext( SvXMLImport& rImport, sal_Int32 nElement, |