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 /xmloff | |
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 'xmloff')
62 files changed, 1596 insertions, 2950 deletions
diff --git a/xmloff/inc/XMLImageMapContext.hxx b/xmloff/inc/XMLImageMapContext.hxx index d026477a6c3a..5c9c173c1082 100644 --- a/xmloff/inc/XMLImageMapContext.hxx +++ b/xmloff/inc/XMLImageMapContext.hxx @@ -44,8 +44,6 @@ public: XMLImageMapContext( SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, css::uno::Reference< css::beans::XPropertySet> const & rPropertySet); virtual ~XMLImageMapContext() override; diff --git a/xmloff/inc/XMLReplacementImageContext.hxx b/xmloff/inc/XMLReplacementImageContext.hxx index 14a1e58355ee..4b089d6118ce 100644 --- a/xmloff/inc/XMLReplacementImageContext.hxx +++ b/xmloff/inc/XMLReplacementImageContext.hxx @@ -39,9 +39,8 @@ public: XMLReplacementImageContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList > & rAttrList, + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList > & rAttrList, const css::uno::Reference< css::beans::XPropertySet >& rPropSet ); virtual ~XMLReplacementImageContext() override; diff --git a/xmloff/inc/txtfldi.hxx b/xmloff/inc/txtfldi.hxx index b8560b17b3d6..2a694423b640 100644 --- a/xmloff/inc/txtfldi.hxx +++ b/xmloff/inc/txtfldi.hxx @@ -66,13 +66,7 @@ public: XMLTextFieldImportContext( SvXMLImport& rImport, /// XML Import XMLTextImportHelper& rHlp, /// Text import helper - const char* pService, /// name of SO API service - sal_uInt16 nPrfx, /// namespace prefix - const OUString& rLocalName); /// element name w/o prefix - XMLTextFieldImportContext( - SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - const char* pService); /// name of SO API service + const char* pService); /// name of SO API service /// process character data: will be collected in member sContentBuffer virtual void SAL_CALL characters( const OUString& sContent ) override; @@ -90,12 +84,6 @@ public: static XMLTextFieldImportContext* CreateTextFieldImportContext( SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrefix, - const OUString& rName, - sal_uInt16 nToken); - static XMLTextFieldImportContext* CreateTextFieldImportContext( - SvXMLImport& rImport, - XMLTextImportHelper& rHlp, sal_Int32 nElement); protected: @@ -141,9 +129,7 @@ public: XMLSenderFieldImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& sLocalName); /// element name w/o prefix + XMLTextImportHelper& rHlp); /// Text import helper protected: /// start element @@ -171,9 +157,7 @@ public: XMLAuthorFieldImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& sLocalName); /// element name w/o prefix + XMLTextImportHelper& rHlp); /// Text import helper private: /// start element @@ -202,9 +186,7 @@ public: XMLPlaceholderFieldImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& sLocalName); /// element name w/o prefix + XMLTextImportHelper& rHlp); /// Text import helper private: /// process attribute values @@ -240,9 +222,7 @@ public: XMLTimeFieldImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& sLocalName); /// element name w/o prefix + XMLTextImportHelper& rHlp); /// Text import helper /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, @@ -261,9 +241,7 @@ public: XMLDateFieldImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& sLocalName); /// element name w/o prefix + XMLTextImportHelper& rHlp); /// Text import helper /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, @@ -285,9 +263,7 @@ public: XMLPageContinuationImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& sLocalName); /// element name w/o prefix + XMLTextImportHelper& rHlp); /// Text import helper /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, @@ -316,9 +292,7 @@ public: XMLPageNumberImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& sLocalName); /// element name w/o prefix + XMLTextImportHelper& rHlp); /// Text import helper /// process attribute values @@ -354,8 +328,6 @@ protected: XMLDatabaseFieldImportContext(SvXMLImport& rImport, XMLTextImportHelper& rHlp, const char* pServiceName, - sal_uInt16 nPrfx, - const OUString& sLocalName, bool bUseDisplay ); public: @@ -380,9 +352,7 @@ class XMLDatabaseNameImportContext final : public XMLDatabaseFieldImportContext public: XMLDatabaseNameImportContext(SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLTextImportHelper& rHlp); /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, @@ -401,16 +371,12 @@ protected: // for use in child classes XMLDatabaseNextImportContext(SvXMLImport& rImport, XMLTextImportHelper& rHlp, - const char* pServiceName, - sal_uInt16 nPrfx, - const OUString& sLocalName); + const char* pServiceName); public: XMLDatabaseNextImportContext(SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLTextImportHelper& rHlp); /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, @@ -431,9 +397,7 @@ class XMLDatabaseSelectImportContext final : public XMLDatabaseNextImportContext public: XMLDatabaseSelectImportContext(SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLTextImportHelper& rHlp); /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, @@ -458,9 +422,7 @@ class XMLDatabaseNumberImportContext final : public XMLDatabaseFieldImportContex public: XMLDatabaseNumberImportContext(SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLTextImportHelper& rHlp); /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, @@ -488,9 +450,7 @@ public: XMLSimpleDocInfoImportContext(SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName, - sal_uInt16 nToken, + sal_Int32 nElementToken, bool bContent, bool bAuthor); @@ -503,7 +463,7 @@ protected: virtual void PrepareField( const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override; - static const char* MapTokenToServiceName(sal_uInt16 nToken); + static const char* MapTokenToServiceName(sal_Int32 nElementToken); }; /** import docinfo fields with date or time attributes and numberformats */ @@ -523,9 +483,7 @@ public: XMLDateTimeDocInfoImportContext(SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName, - sal_uInt16 nToken); + sal_Int32 nElement); private: /// process attribute values @@ -544,9 +502,7 @@ public: XMLRevisionDocInfoImportContext(SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName, - sal_uInt16 nToken); + sal_Int32 nElement); private: /// prepare XTextField for insertion into document @@ -569,9 +525,7 @@ public: XMLUserDocInfoImportContext(SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName, - sal_uInt16 nToken); + sal_Int32 nElement); private: /// process attribute values @@ -593,9 +547,7 @@ class XMLHiddenParagraphImportContext final : public XMLTextFieldImportContext public: XMLHiddenParagraphImportContext(SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLTextImportHelper& rHlp); private: /// process attribute values @@ -625,9 +577,7 @@ class XMLConditionalTextImportContext final : public XMLTextFieldImportContext public: XMLConditionalTextImportContext(SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLTextImportHelper& rHlp); private: /// process attribute values @@ -656,9 +606,7 @@ class XMLHiddenTextImportContext final : public XMLTextFieldImportContext public: XMLHiddenTextImportContext(SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLTextImportHelper& rHlp); private: /// process attribute values @@ -683,9 +631,7 @@ class XMLFileNameImportContext final : public XMLTextFieldImportContext public: XMLFileNameImportContext(SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLTextImportHelper& rHlp); private: /// process attribute values @@ -707,9 +653,7 @@ class XMLTemplateNameImportContext final : public XMLTextFieldImportContext public: XMLTemplateNameImportContext(SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLTextImportHelper& rHlp); private: /// process attribute values @@ -730,9 +674,7 @@ class XMLChapterImportContext final : public XMLTextFieldImportContext public: XMLChapterImportContext(SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLTextImportHelper& rHlp); private: /// process attribute values @@ -758,9 +700,7 @@ public: XMLCountFieldImportContext(SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName, - sal_uInt16 nToken); + sal_Int32 nElement); private: /// process attribute values @@ -771,7 +711,7 @@ private: virtual void PrepareField( const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; - static const char* MapTokenToServiceName(sal_uInt16 nToken); + static const char* MapTokenToServiceName(sal_Int32 nElement); }; /** import page variable fields (<text:get-page-variable>) */ @@ -785,9 +725,7 @@ class XMLPageVarGetFieldImportContext final : public XMLTextFieldImportContext public: XMLPageVarGetFieldImportContext(SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLTextImportHelper& rHlp); private: /// process attribute values @@ -808,9 +746,7 @@ class XMLPageVarSetFieldImportContext final : public XMLTextFieldImportContext public: XMLPageVarSetFieldImportContext(SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLTextImportHelper& rHlp); private: /// process attribute values @@ -835,9 +771,7 @@ class XMLMacroFieldImportContext final : public XMLTextFieldImportContext public: XMLMacroFieldImportContext(SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLTextImportHelper& rHlp); private: /// for <office:events> children @@ -859,7 +793,7 @@ class XMLReferenceFieldImportContext final : public XMLTextFieldImportContext { OUString sName; OUString sLanguage; - sal_uInt16 nElementToken; + sal_Int32 nElementToken; sal_Int16 nSource; sal_Int16 nType; @@ -870,9 +804,7 @@ public: XMLReferenceFieldImportContext(SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nToken, - sal_uInt16 nPrfx, - const OUString& sLocalName); + sal_Int32 nToken); private: /// start element @@ -894,9 +826,7 @@ class XMLDdeFieldDeclsImportContext final : public SvXMLImportContext { public: - XMLDdeFieldDeclsImportContext(SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLDdeFieldDeclsImportContext(SvXMLImport& rImport); virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 nElement, @@ -925,9 +855,7 @@ class XMLDdeFieldImportContext final : public XMLTextFieldImportContext public: XMLDdeFieldImportContext(SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLTextImportHelper& rHlp); private: /// process attribute values @@ -949,9 +877,7 @@ class XMLSheetNameImportContext final : public XMLTextFieldImportContext public: XMLSheetNameImportContext(SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLTextImportHelper& rHlp); private: /// no attributes -> empty method @@ -970,9 +896,7 @@ public: XMLPageNameFieldImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& sLocalName); /// element name w/o prefix + XMLTextImportHelper& rHlp); /// Text import helper /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, @@ -1013,17 +937,15 @@ class XMLBibliographyFieldImportContext final : public XMLTextFieldImportContext public: XMLBibliographyFieldImportContext(SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLTextImportHelper& rHlp); private: /// process attributes (fill aValues) virtual void SAL_CALL startFastElement( sal_Int32 nElement, - const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList) override; + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList) override; - /// empty method; all attributes are handled in startFastElement + /// empty method; all attributes are handled in StartElement virtual void ProcessAttribute( sal_Int32 nAttrToken, const OUString& sAttrValue ) override; @@ -1032,6 +954,7 @@ private: const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; static const char* MapBibliographyFieldName(const OUString& sName); + static const char* MapBibliographyFieldName(sal_Int32 nElement); }; /** Import an annotation field (<text:annotation>) */ @@ -1048,15 +971,13 @@ class XMLAnnotationImportContext final : public XMLTextFieldImportContext css::uno::Reference < css::text::XTextCursor > mxCursor; css::uno::Reference < css::text::XTextCursor > mxOldCursor; - sal_uInt16 m_nToken; + sal_Int32 mnElement; public: XMLAnnotationImportContext(SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nToken, - sal_uInt16 nPrfx, - const OUString& sLocalName); + sal_Int32 nElement); private: /// process attributes @@ -1084,9 +1005,7 @@ class XMLScriptImportContext final : public XMLTextFieldImportContext public: XMLScriptImportContext(SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLTextImportHelper& rHlp); private: /// process attributes @@ -1106,9 +1025,7 @@ class XMLMeasureFieldImportContext final : public XMLTextFieldImportContext public: XMLMeasureFieldImportContext(SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLTextImportHelper& rHlp); private: /// process attribute values @@ -1135,9 +1052,7 @@ class XMLDropDownFieldImportContext final : public XMLTextFieldImportContext public: XMLDropDownFieldImportContext(SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLTextImportHelper& rHlp); virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override; @@ -1159,9 +1074,7 @@ public: XMLHeaderFieldImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& sLocalName); /// element name w/o prefix + XMLTextImportHelper& rHlp); /// Text import helper /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, @@ -1179,9 +1092,7 @@ public: XMLFooterFieldImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& sLocalName); /// element name w/o prefix + XMLTextImportHelper& rHlp); /// Text import helper /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, @@ -1199,9 +1110,7 @@ public: XMLDateTimeFieldImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& sLocalName); /// element name w/o prefix + XMLTextImportHelper& rHlp); /// Text import helper /// process attribute values virtual void ProcessAttribute( sal_Int32 nAttrToken, diff --git a/xmloff/inc/txtvfldi.hxx b/xmloff/inc/txtvfldi.hxx index 5cfca16c312b..8d0fb73bdd51 100644 --- a/xmloff/inc/txtvfldi.hxx +++ b/xmloff/inc/txtvfldi.hxx @@ -138,8 +138,6 @@ public: SvXMLImport& rImport, /// XML Import XMLTextImportHelper& rHlp, /// text import helper const char* pServiceName, /// name of SO API service - sal_uInt16 nPrfx, /// namespace prefix - const OUString& rLocalName, /// element name w/o prefix // config variables for PrepareField behavior: bool bFormula, /// set Formula property bool bFormulaDefault, /// use content as default for formula @@ -177,9 +175,7 @@ public: XMLVariableGetFieldImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& rLocalName); /// element name w/o prefix + XMLTextImportHelper& rHlp); /// Text import helper private: @@ -197,9 +193,7 @@ public: XMLExpressionFieldImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& sLocalName); /// element name w/o prefix + XMLTextImportHelper& rHlp); /// Text import helper private: virtual void PrepareField( @@ -214,9 +208,7 @@ public: XMLTextInputFieldImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& sLocalName); /// element name w/o prefix + XMLTextImportHelper& rHlp); /// Text import helper private: virtual void PrepareField( @@ -241,8 +233,6 @@ public: SvXMLImport& rImport, /// see XMLTextFieldImportContext XMLTextImportHelper& rHlp, /// see XMLTextFieldImportContext const char* pServiceName, /// see XMLTextFieldImportContext - sal_uInt16 nPrfx, /// see XMLTextFieldImportContext - const OUString& rLocalName, /// see XMLTextFieldImportContext // for finding appropriate field master (see endFastElement()) VarType eVarType, /// variable type // config variables: @@ -278,10 +268,8 @@ public: XMLVariableSetFieldImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& rLocalName); /// element name w/o prefix - + XMLTextImportHelper& rHlp); /// Text import helper +\ private: /// prepare XTextField for insertion into document virtual void PrepareField( @@ -297,9 +285,7 @@ public: XMLVariableInputFieldImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& rLocalName); /// element name w/o prefix + XMLTextImportHelper& rHlp); /// Text import helper private: @@ -318,9 +304,7 @@ public: XMLUserFieldImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& rLocalName); /// element name w/o prefix + XMLTextImportHelper& rHlp); /// Text import helper }; /** user input fields (<text:user-field-input>) */ @@ -332,9 +316,7 @@ public: XMLUserFieldInputImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& rLocalName); /// element name w/o prefix + XMLTextImportHelper& rHlp); /// Text import helper virtual void PrepareField( const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override; @@ -355,9 +337,7 @@ public: XMLSequenceFieldImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& rLocalName); /// element name w/o prefix + XMLTextImportHelper& rHlp); /// Text import helper private: @@ -382,12 +362,9 @@ class XMLVariableDeclsImportContext final : public SvXMLImportContext public: - XMLVariableDeclsImportContext( SvXMLImport& rImport, /// XML Import XMLTextImportHelper& rHlp, /// text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& rLocalName, /// element name w/o prefix enum VarType eVarType); /// variable type virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( @@ -431,9 +408,7 @@ public: XMLTableFormulaImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& rLocalName); /// element name w/o prefix + XMLTextImportHelper& rHlp); /// text import helper private: @@ -463,9 +438,7 @@ public: XMLDatabaseDisplayImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& rLocalName); /// element name w/o prefix + XMLTextImportHelper& rHlp); /// text import helper private: diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx index d6ab1baf5c09..8b4f79582138 100644 --- a/xmloff/source/chart/SchXMLChartContext.cxx +++ b/xmloff/source/chart/SchXMLChartContext.cxx @@ -1109,7 +1109,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLChartContext::cr SAL_WARN_IF( !mxDrawPage.is(), "xmloff.chart", "Invalid Chart Page" ); } if( mxDrawPage.is()) - pContext = GetImport().GetShapeImport()->CreateGroupChildContext( + pContext = XMLShapeImportHelper::CreateGroupChildContext( GetImport(), nElement, xAttrList, mxDrawPage ); break; } diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx index d43e6e2fef91..985a4a633212 100644 --- a/xmloff/source/chart/SchXMLPlotAreaContext.cxx +++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx @@ -218,9 +218,13 @@ void SchXMLPlotAreaContext::startFastElement (sal_Int32 /*nElement*/, switch( aIter.getToken() ) { case XML_ELEMENT(SVG, XML_X): + case XML_ELEMENT(SVG_COMPAT, XML_X): case XML_ELEMENT(SVG, XML_Y): + case XML_ELEMENT(SVG_COMPAT, XML_Y): case XML_ELEMENT(SVG, XML_WIDTH): + case XML_ELEMENT(SVG_COMPAT, XML_WIDTH): case XML_ELEMENT(SVG, XML_HEIGHT): + case XML_ELEMENT(SVG_COMPAT, XML_HEIGHT): m_aOuterPositioning.readPositioningAttribute( aIter.getToken(), aValue ); break; case XML_ELEMENT(CHART, XML_STYLE_NAME): diff --git a/xmloff/source/core/XMLBase64ImportContext.cxx b/xmloff/source/core/XMLBase64ImportContext.cxx index 504460bff96a..301865a26c10 100644 --- a/xmloff/source/core/XMLBase64ImportContext.cxx +++ b/xmloff/source/core/XMLBase64ImportContext.cxx @@ -30,15 +30,6 @@ using namespace ::com::sun::star::io; XMLBase64ImportContext::XMLBase64ImportContext( - SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, - const Reference< XAttributeList >&, - const Reference< XOutputStream >& rOut ) : - SvXMLImportContext( rImport, nPrfx, rLName ), - xOut( rOut ) -{ -} - -XMLBase64ImportContext::XMLBase64ImportContext( SvXMLImport& rImport, const Reference< XOutputStream >& rOut ) : SvXMLImportContext( rImport ), diff --git a/xmloff/source/core/xmlictxt.cxx b/xmloff/source/core/xmlictxt.cxx index b41d847805f0..360763349c93 100644 --- a/xmloff/source/core/xmlictxt.cxx +++ b/xmloff/source/core/xmlictxt.cxx @@ -27,21 +27,9 @@ using namespace ::com::sun::star; -SvXMLImportContext::SvXMLImportContext( SvXMLImport& rImp, sal_uInt16 nPrfx, - const OUString& rLName ) - : mrImport(rImp) - , maLocalName(rLName) - , m_nRefCount(0) - , mnPrefix(nPrfx) - , mbPrefixAndLocalNameFilledIn(true) -{ -} - SvXMLImportContext::SvXMLImportContext( SvXMLImport& rImp ) : mrImport(rImp) , m_nRefCount(0) - , mnPrefix(0) - , mbPrefixAndLocalNameFilledIn(false) { } @@ -49,50 +37,13 @@ SvXMLImportContext::~SvXMLImportContext() { } -SvXMLImportContextRef SvXMLImportContext::CreateChildContext( sal_uInt16 /*nPrefix*/, - const OUString& /*rLocalName*/, - const uno::Reference<xml::sax::XAttributeList>& ) -{ - return nullptr; -} - -void SvXMLImportContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& ) -{ -} - void SvXMLImportContext::endFastElement(sal_Int32 ) { } // css::xml::sax::XFastContextHandler: -void SAL_CALL SvXMLImportContext::startFastElement(sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList > & Attribs) +void SAL_CALL SvXMLImportContext::startFastElement(sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList > & ) { - const OUString& rPrefix = SvXMLImport::getNamespacePrefixFromToken(nElement, &GetImport().GetNamespaceMap()); - const OUString& rLocalName = SvXMLImport::getNameFromToken( nElement ); - startUnknownElement( SvXMLImport::aDefaultNamespace, (rPrefix.isEmpty())? rLocalName : rPrefix + SvXMLImport::aNamespaceSeparator + rLocalName, Attribs ); - mrImport.maAttrList->Clear(); - mrImport.maNamespaceHandler->addNSDeclAttributes( mrImport.maAttrList ); - - for( auto &it : sax_fastparser::castToFastAttributeList( Attribs ) ) - { - sal_Int32 nToken = it.getToken(); - const OUString& rAttrNamespacePrefix = SvXMLImport::getNamespacePrefixFromToken(nToken, &GetImport().GetNamespaceMap()); - OUString sAttrName = SvXMLImport::getNameFromToken( nToken ); - if ( !rAttrNamespacePrefix.isEmpty() ) - sAttrName = rAttrNamespacePrefix + SvXMLImport::aNamespaceSeparator + sAttrName; - - mrImport.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 - mrImport.maAttrList->AddAttribute( rAttrName, "CDATA", rAttrValue ); - } - StartElement( mrImport.maAttrList.get() ); } void SAL_CALL SvXMLImportContext::startUnknownElement(const OUString & /*rNamespace*/, const OUString & /*rElementName*/, @@ -110,49 +61,6 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SvXMLImportContext::cre return nullptr; } -css::uno::Reference< css::xml::sax::XFastContextHandler > SvXMLImportContext::createFastChildContextFallback(sal_Int32 Element, const uno::Reference< xml::sax::XFastAttributeList > & Attribs) -{ - auto p = createFastChildContext(Element, Attribs); - if (p) - return p; - - // fall back to slow-parser path - const OUString& rPrefix = SvXMLImport::getNamespacePrefixFromToken(Element, &mrImport.GetNamespaceMap()); - const OUString& rLocalName = SvXMLImport::getNameFromToken( Element ); - OUString aName = rPrefix.isEmpty() ? rLocalName : rPrefix + SvXMLImport::aNamespaceSeparator + rLocalName; - OUString aLocalName; - sal_uInt16 nPrefix = - mrImport.mpNamespaceMap->GetKeyByAttrName( aName, &aLocalName ); - - mrImport.maAttrList->Clear(); - - if ( Attribs.is() ) - { - for( auto &it : sax_fastparser::castToFastAttributeList( Attribs ) ) - { - sal_Int32 nToken = it.getToken(); - const OUString& rAttrNamespacePrefix = SvXMLImport::getNamespacePrefixFromToken(nToken, &mrImport.GetNamespaceMap()); - OUString sAttrName = SvXMLImport::getNameFromToken( nToken ); - if ( !rAttrNamespacePrefix.isEmpty() ) - sAttrName = rAttrNamespacePrefix + SvXMLImport::aNamespaceSeparator + sAttrName; - - mrImport.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 - mrImport.maAttrList->AddAttribute( rAttrName, "CDATA", rAttrValue ); - } - } - - SAL_INFO("xmloff.core", "calling CreateChildContext on " << typeid(*this).name()); - return CreateChildContext(nPrefix, aLocalName, mrImport.maAttrList.get() ).get(); -} - uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SvXMLImportContext::createUnknownChildContext (const OUString & /*rNamespace*/, const OUString & /*rName*/, const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/) { diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 03e076c0cba3..d2c346fbe5f6 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -779,44 +779,6 @@ void SAL_CALL SvXMLImport::startFastElement (sal_Int32 Element, const SvXMLImportContextRef & pHandler = maContexts.top(); SAL_INFO("xmloff.core", "calling createFastChildContext on " << typeid(*pHandler.get()).name()); auto tmp = pHandler->createFastChildContext( Element, Attribs ); - if (!tmp) - { - // fall back to slow-parser path - const OUString& rPrefix = SvXMLImport::getNamespacePrefixFromToken(Element, &GetNamespaceMap()); - const OUString& rLocalName = SvXMLImport::getNameFromToken( Element ); - OUString aName = rPrefix.isEmpty() ? rLocalName : rPrefix + SvXMLImport::aNamespaceSeparator + rLocalName; - OUString aLocalName; - sal_uInt16 nPrefix = - mpNamespaceMap->GetKeyByAttrName( aName, &aLocalName ); - - maAttrList->Clear(); - - if ( Attribs.is() ) - { - for( auto &it : sax_fastparser::castToFastAttributeList( Attribs ) ) - { - sal_Int32 nToken = it.getToken(); - const OUString& rAttrNamespacePrefix = SvXMLImport::getNamespacePrefixFromToken(nToken, &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 ); - } - } - - SAL_INFO("xmloff.core", "calling CreateChildContext on " << typeid(*pHandler).name()); - tmp = pHandler->CreateChildContext(nPrefix, aLocalName, maAttrList.get() ).get(); - } xContext = dynamic_cast<SvXMLImportContext*>(tmp.get()); assert((tmp && xContext) || (!tmp && !xContext)); } @@ -851,41 +813,6 @@ void SAL_CALL SvXMLImport::startUnknownElement (const OUString & rNamespace, con const SvXMLImportContextRef & pHandler = maContexts.top(); SAL_INFO("xmloff.core", "calling createUnknownChildContext on " << typeid(*pHandler.get()).name()); auto tmp = pHandler->createUnknownChildContext( rNamespace, rName, Attribs ); - if (!tmp) - { - // fall back to slow-parser path - OUString aLocalName; - sal_uInt16 nPrefix = mpNamespaceMap->GetKeyByAttrName( rName, &aLocalName ); - - maAttrList->Clear(); - maNamespaceHandler->addNSDeclAttributes( maAttrList ); - - if ( Attribs.is() ) - { - for( auto &it : sax_fastparser::castToFastAttributeList( Attribs ) ) - { - sal_Int32 nToken = it.getToken(); - const OUString& rAttrNamespacePrefix = SvXMLImport::getNamespacePrefixFromToken(nToken, &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 ); - } - } - - SAL_INFO("xmloff.core", "calling CreateChildContext on " << typeid(*pHandler).name()); - tmp = pHandler->CreateChildContext(nPrefix, aLocalName, maAttrList.get() ).get(); - } xContext = dynamic_cast<SvXMLImportContext*>(tmp.get()); assert((tmp && xContext) || (!tmp && !xContext)); } @@ -1582,36 +1509,6 @@ XMLEventImportHelper& SvXMLImport::GetEventImport() return *mpEventImportHelper; } -css::uno::Reference< css::xml::sax::XAttributeList > SvXMLImport::convertToSlowAttrList(const uno::Reference< xml::sax::XFastAttributeList > & Attribs) -{ - maAttrList->Clear(); - - if ( Attribs.is() ) - { - for( auto &it : sax_fastparser::castToFastAttributeList( Attribs ) ) - { - sal_Int32 nToken = it.getToken(); - const OUString& rAttrNamespacePrefix = SvXMLImport::getNamespacePrefixFromToken(nToken, &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 maAttrList.get(); -} - void SvXMLImport::SetFontDecls( XMLFontStylesContext *pFontDecls ) { if (mxFontDecls.is()) diff --git a/xmloff/source/draw/QRCodeContext.cxx b/xmloff/source/draw/QRCodeContext.cxx index a23f5ca11fd5..978737b34131 100644 --- a/xmloff/source/draw/QRCodeContext.cxx +++ b/xmloff/source/draw/QRCodeContext.cxx @@ -35,53 +35,47 @@ using namespace css::io; using namespace css::graphic; using namespace xmloff::token; -QRCodeContext::QRCodeContext(SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, - const Reference<XAttributeList>& xAttrList, +QRCodeContext::QRCodeContext(SvXMLImport& rImport, sal_Int32 /*nElement*/, + const Reference<XFastAttributeList>& xAttrList, const Reference<XShape>& rxShape) - : SvXMLImportContext(rImport, nPrfx, rLocalName) + : SvXMLImportContext(rImport) { Reference<beans::XPropertySet> xPropSet(rxShape, UNO_QUERY_THROW); css::drawing::QRCode aQRCode; - const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for (sal_Int16 i = 0; i < nAttrCount; i++) + for (auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList)) { - OUString sAttrName = xAttrList->getNameByIndex(i); - OUString aLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(sAttrName, &aLocalName); - OUString sValue = xAttrList->getValueByIndex(i); - - switch (nPrefix) + switch (aIter.getToken()) { - case XML_NAMESPACE_LO_EXT: - if (IsXMLToken(aLocalName, XML_QRCODE_ERROR_CORRECTION)) - { - OUString aErrorCorrValue = sValue; - - if (aErrorCorrValue == "low") - aQRCode.ErrorCorrection = css::drawing::QRCodeErrorCorrection::LOW; - else if (aErrorCorrValue == "medium") - aQRCode.ErrorCorrection = css::drawing::QRCodeErrorCorrection::MEDIUM; - else if (aErrorCorrValue == "quartile") - aQRCode.ErrorCorrection = css::drawing::QRCodeErrorCorrection::QUARTILE; - else - aQRCode.ErrorCorrection = css::drawing::QRCodeErrorCorrection::HIGH; - } + case XML_ELEMENT(LO_EXT, XML_QRCODE_ERROR_CORRECTION): + { + OUString aErrorCorrValue = aIter.toString(); - if (IsXMLToken(aLocalName, XML_QRCODE_BORDER)) - { - sal_Int32 nAttrVal; - if (sax::Converter::convertNumber(nAttrVal, sValue, 0)) - aQRCode.Border = nAttrVal; - } + if (aErrorCorrValue == "low") + aQRCode.ErrorCorrection = css::drawing::QRCodeErrorCorrection::LOW; + else if (aErrorCorrValue == "medium") + aQRCode.ErrorCorrection = css::drawing::QRCodeErrorCorrection::MEDIUM; + else if (aErrorCorrValue == "quartile") + aQRCode.ErrorCorrection = css::drawing::QRCodeErrorCorrection::QUARTILE; + else + aQRCode.ErrorCorrection = css::drawing::QRCodeErrorCorrection::HIGH; break; - - case XML_NAMESPACE_OFFICE: - if (IsXMLToken(aLocalName, XML_STRING_VALUE)) - { - aQRCode.Payload = sValue; - } + } + case XML_ELEMENT(LO_EXT, XML_QRCODE_BORDER): + { + sal_Int32 nAttrVal; + if (sax::Converter::convertNumber(nAttrVal, aIter.toString(), 0)) + aQRCode.Border = nAttrVal; + break; + } + case XML_ELEMENT(OFFICE, XML_STRING_VALUE): + { + aQRCode.Payload = aIter.toString(); + break; + } + default: + XMLOFF_WARN_UNKNOWN("xmloff", aIter); } } xPropSet->setPropertyValue("QRCodeProperties", Any(aQRCode)); diff --git a/xmloff/source/draw/QRCodeContext.hxx b/xmloff/source/draw/QRCodeContext.hxx index 74709bab40f8..c35c6f9bd988 100644 --- a/xmloff/source/draw/QRCodeContext.hxx +++ b/xmloff/source/draw/QRCodeContext.hxx @@ -18,8 +18,8 @@ class QRCodeContext : public SvXMLImportContext { public: - QRCodeContext(SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, - const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList, + QRCodeContext(SvXMLImport& rImport, sal_Int32 nElement, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList, const css::uno::Reference<css::drawing::XShape>& rxShape); }; diff --git a/xmloff/source/draw/SignatureLineContext.cxx b/xmloff/source/draw/SignatureLineContext.cxx index aa51e54156f0..d85acded8226 100644 --- a/xmloff/source/draw/SignatureLineContext.cxx +++ b/xmloff/source/draw/SignatureLineContext.cxx @@ -23,6 +23,7 @@ #include <comphelper/storagehelper.hxx> #include <xmloff/xmltoken.hxx> #include <xmloff/xmlimp.hxx> +#include <xmloff/xmlnamespace.hxx> using namespace css; using namespace css::xml::sax; @@ -35,29 +36,34 @@ using namespace css::graphic; using namespace css::security; using namespace xmloff::token; -SignatureLineContext::SignatureLineContext(SvXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLocalName, - const Reference<XAttributeList>& xAttrList, +SignatureLineContext::SignatureLineContext(SvXMLImport& rImport, sal_Int32 /*nElement*/, + const Reference<XFastAttributeList>& xAttrList, const Reference<XShape>& rxShape) - : SvXMLImportContext(rImport, nPrfx, rLocalName) + : SvXMLImportContext(rImport) { Reference<beans::XPropertySet> xPropSet(rxShape, UNO_QUERY_THROW); xPropSet->setPropertyValue("IsSignatureLine", Any(true)); - xPropSet->setPropertyValue("SignatureLineId", Any(xAttrList->getValueByName("loext:id"))); - xPropSet->setPropertyValue("SignatureLineSuggestedSignerName", - Any(xAttrList->getValueByName("loext:suggested-signer-name"))); - xPropSet->setPropertyValue("SignatureLineSuggestedSignerTitle", - Any(xAttrList->getValueByName("loext:suggested-signer-title"))); - xPropSet->setPropertyValue("SignatureLineSuggestedSignerEmail", - Any(xAttrList->getValueByName("loext:suggested-signer-email"))); - xPropSet->setPropertyValue("SignatureLineSigningInstructions", - Any(xAttrList->getValueByName("loext:signing-instructions"))); - - bool bShowSignDate = xAttrList->getValueByName("loext:show-sign-date") == GetXMLToken(XML_TRUE); - bool bCanAddComment - = xAttrList->getValueByName("loext:can-add-comment") == GetXMLToken(XML_TRUE); + xPropSet->setPropertyValue("SignatureLineId", + Any(xAttrList->getOptionalValue(XML_ELEMENT(LO_EXT, XML_ID)))); + xPropSet->setPropertyValue( + "SignatureLineSuggestedSignerName", + Any(xAttrList->getOptionalValue(XML_ELEMENT(LO_EXT, XML_SUGGESTED_SIGNER_NAME)))); + xPropSet->setPropertyValue( + "SignatureLineSuggestedSignerTitle", + Any(xAttrList->getOptionalValue(XML_ELEMENT(LO_EXT, XML_SUGGESTED_SIGNER_TITLE)))); + xPropSet->setPropertyValue( + "SignatureLineSuggestedSignerEmail", + Any(xAttrList->getOptionalValue(XML_ELEMENT(LO_EXT, XML_SUGGESTED_SIGNER_EMAIL)))); + xPropSet->setPropertyValue( + "SignatureLineSigningInstructions", + Any(xAttrList->getOptionalValue(XML_ELEMENT(LO_EXT, XML_SIGNING_INSTRUCTIONS)))); + + bool bShowSignDate = xAttrList->getOptionalValue(XML_ELEMENT(LO_EXT, XML_SHOW_SIGN_DATE)) + == GetXMLToken(XML_TRUE); + bool bCanAddComment = xAttrList->getOptionalValue(XML_ELEMENT(LO_EXT, XML_CAN_ADD_COMMENT)) + == GetXMLToken(XML_TRUE); xPropSet->setPropertyValue("SignatureLineShowSignDate", Any(bShowSignDate)); xPropSet->setPropertyValue("SignatureLineCanAddComment", Any(bCanAddComment)); @@ -91,11 +97,12 @@ SignatureLineContext::SignatureLineContext(SvXMLImport& rImport, sal_uInt16 nPrf // Try to find matching signature line image - if none exists that is fine, // then the signature line is not digitally signed. - auto pSignatureInfo = std::find_if( - xSignatureInfo.begin(), xSignatureInfo.end(), - [&xAttrList](const DocumentSignatureInformation& rSignatureInfo) { - return rSignatureInfo.SignatureLineId == xAttrList->getValueByName("loext:id"); - }); + auto pSignatureInfo + = std::find_if(xSignatureInfo.begin(), xSignatureInfo.end(), + [&xAttrList](const DocumentSignatureInformation& rSignatureInfo) { + return rSignatureInfo.SignatureLineId + == xAttrList->getOptionalValue(XML_ELEMENT(LO_EXT, XML_ID)); + }); bool bIsSigned(false); if (pSignatureInfo != xSignatureInfo.end()) { diff --git a/xmloff/source/draw/SignatureLineContext.hxx b/xmloff/source/draw/SignatureLineContext.hxx index f64b81bda5f4..cabefaafd954 100644 --- a/xmloff/source/draw/SignatureLineContext.hxx +++ b/xmloff/source/draw/SignatureLineContext.hxx @@ -18,8 +18,8 @@ class SignatureLineContext : public SvXMLImportContext { public: - SignatureLineContext(SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, - const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList, + SignatureLineContext(SvXMLImport& rImport, sal_Int32 nElement, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList, const css::uno::Reference<css::drawing::XShape>& rxShape); }; diff --git a/xmloff/source/draw/XMLImageMapContext.cxx b/xmloff/source/draw/XMLImageMapContext.cxx index 446e3e60801a..6ec8a01d6b29 100644 --- a/xmloff/source/draw/XMLImageMapContext.cxx +++ b/xmloff/source/draw/XMLImageMapContext.cxx @@ -496,10 +496,8 @@ constexpr OUStringLiteral gsImageMap(u"ImageMap"); XMLImageMapContext::XMLImageMapContext( SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, Reference<XPropertySet> const & rPropertySet) : - SvXMLImportContext(rImport, nPrefix, rLocalName), + SvXMLImportContext(rImport), xPropertySet(rPropertySet) { try diff --git a/xmloff/source/draw/XMLNumberStyles.cxx b/xmloff/source/draw/XMLNumberStyles.cxx index 44c85b8e2bfd..db2f93e8b607 100644 --- a/xmloff/source/draw/XMLNumberStyles.cxx +++ b/xmloff/source/draw/XMLNumberStyles.cxx @@ -555,7 +555,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLNumberFormatMembe sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { - return mxSlaveContext->createFastChildContextFallback( nElement, xAttrList ); + return mxSlaveContext->createFastChildContext( nElement, xAttrList ); } void SdXMLNumberFormatMemberImportContext::startFastElement( diff --git a/xmloff/source/draw/XMLReplacementImageContext.cxx b/xmloff/source/draw/XMLReplacementImageContext.cxx index a096a4823d38..3d7ad0e62e93 100644 --- a/xmloff/source/draw/XMLReplacementImageContext.cxx +++ b/xmloff/source/draw/XMLReplacementImageContext.cxx @@ -37,34 +37,13 @@ using namespace ::xmloff::token; XMLReplacementImageContext::XMLReplacementImageContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, const OUString& rLName, - const Reference< XAttributeList > & rAttrList, + sal_Int32 /*nElement*/, + const Reference< XFastAttributeList > & rAttrList, const Reference< XPropertySet > & rPropSet ) : - SvXMLImportContext( rImport, nPrfx, rLName ), + SvXMLImportContext( rImport ), m_xPropSet( rPropSet ) { - rtl::Reference < XMLTextImportHelper > xTxtImport = - GetImport().GetTextImport(); - const SvXMLTokenMap& rTokenMap = - xTxtImport->GetTextFrameAttrTokenMap(); - - sal_Int16 nAttrCount = rAttrList.is() ? rAttrList->getLength() : 0; - for( sal_Int16 i=0; i < nAttrCount; i++ ) - { - const OUString& rAttrName = rAttrList->getNameByIndex( i ); - const OUString& rValue = rAttrList->getValueByIndex( i ); - - OUString aLocalName; - sal_uInt16 nPrefix = - GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, - &aLocalName ); - switch( rTokenMap.Get( nPrefix, aLocalName ) ) - { - case XML_TOK_TEXT_FRAME_HREF: - m_sHRef = rValue; - break; - } - } + m_sHRef = rAttrList->getOptionalValue(XML_ELEMENT(XLINK, XML_HREF)); } XMLReplacementImageContext::~XMLReplacementImageContext() diff --git a/xmloff/source/draw/descriptionimp.cxx b/xmloff/source/draw/descriptionimp.cxx index 0e41cd680331..738f47dd2bf0 100644 --- a/xmloff/source/draw/descriptionimp.cxx +++ b/xmloff/source/draw/descriptionimp.cxx @@ -35,9 +35,8 @@ using namespace ::com::sun::star::beans; using namespace ::xmloff::token; -SdXMLDescriptionContext::SdXMLDescriptionContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, - const Reference< XAttributeList>&, const Reference< XShape >& rxShape) -: SvXMLImportContext(rImport, nPrfx, rLocalName), mxShape( rxShape ) +SdXMLDescriptionContext::SdXMLDescriptionContext( SvXMLImport& rImport, sal_Int32 nElement, const Reference< XShape >& rxShape) +: SvXMLImportContext(rImport), mxShape( rxShape ), mnElement(nElement) { } @@ -53,7 +52,7 @@ void SdXMLDescriptionContext::endFastElement(sal_Int32 ) try { uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY_THROW); - if(IsXMLToken(GetLocalName(),XML_TITLE)) + if( (mnElement & TOKEN_MASK) == XML_TITLE) { xPropSet->setPropertyValue("Title", Any(msText)); } diff --git a/xmloff/source/draw/descriptionimp.hxx b/xmloff/source/draw/descriptionimp.hxx index 6dee51daf293..57a1fa2b7c81 100644 --- a/xmloff/source/draw/descriptionimp.hxx +++ b/xmloff/source/draw/descriptionimp.hxx @@ -25,17 +25,15 @@ // office:events inside a shape -class SdXMLDescriptionContext : public SvXMLImportContext +class SdXMLDescriptionContext final : public SvXMLImportContext { private: css::uno::Reference< css::drawing::XShape > mxShape; OUString msText; + sal_Int32 mnElement; public: - SdXMLDescriptionContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + SdXMLDescriptionContext( SvXMLImport& rImport, sal_Int32 mnElement, const css::uno::Reference< css::drawing::XShape >& rxShape ); virtual ~SdXMLDescriptionContext() override; diff --git a/xmloff/source/draw/eventimp.cxx b/xmloff/source/draw/eventimp.cxx index 226cacafc1d3..c71c71043cc2 100644 --- a/xmloff/source/draw/eventimp.cxx +++ b/xmloff/source/draw/eventimp.cxx @@ -436,9 +436,8 @@ void SdXMLEventContextData::ApplyProperties() } -SdXMLEventsContext::SdXMLEventsContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, - const Reference< XAttributeList>&, const Reference< XShape >& rxShape) -: SvXMLImportContext(rImport, nPrfx, rLocalName), mxShape( rxShape ) +SdXMLEventsContext::SdXMLEventsContext( SvXMLImport& rImport, const Reference< XShape >& rxShape) +: SvXMLImportContext(rImport), mxShape( rxShape ) { } diff --git a/xmloff/source/draw/eventimp.hxx b/xmloff/source/draw/eventimp.hxx index 029601388078..2f66b7865dcb 100644 --- a/xmloff/source/draw/eventimp.hxx +++ b/xmloff/source/draw/eventimp.hxx @@ -36,9 +36,6 @@ private: public: SdXMLEventsContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, const css::uno::Reference< css::drawing::XShape >& rxShape ); virtual ~SdXMLEventsContext() override; diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index 32cf74b8a799..8ff9105412ce 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -2497,7 +2497,9 @@ void XMLShapeExport::ImpExportControlShape( SAL_WARN_IF( !xControlModel.is(), "xmloff", "Control shape has not XControlModel" ); if( xControlModel.is() ) { - mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CONTROL, mrExport.GetFormExport()->getControlId( xControlModel ) ); + OUString sControlId = mrExport.GetFormExport()->getControlId( xControlModel ); + assert(!sControlId.isEmpty()); + mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CONTROL, sControlId ); } } diff --git a/xmloff/source/draw/shapeimport.cxx b/xmloff/source/draw/shapeimport.cxx index 9a26ea3576be..e3fcfd70fd56 100644 --- a/xmloff/source/draw/shapeimport.cxx +++ b/xmloff/source/draw/shapeimport.cxx @@ -345,48 +345,48 @@ const SvXMLTokenMap& XMLShapeImportHelper::Get3DLightAttrTokenMap() SvXMLShapeContext* XMLShapeImportHelper::Create3DSceneChildContext( SvXMLImport& rImport, - sal_uInt16 p_nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList>& xAttrList, + sal_Int32 nElement, + const uno::Reference< xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes) { SdXMLShapeContext *pContext = nullptr; if(rShapes.is()) { - const SvXMLTokenMap& rTokenMap = Get3DSceneShapeElemTokenMap(); - switch(rTokenMap.Get(p_nPrefix, rLocalName)) + switch(nElement) { - case XML_TOK_3DSCENE_3DSCENE: + case XML_ELEMENT(DR3D, XML_SCENE): { // dr3d:3dscene inside dr3d:3dscene context pContext = new SdXML3DSceneShapeContext( rImport, xAttrList, rShapes, false); break; } - case XML_TOK_3DSCENE_3DCUBE: + case XML_ELEMENT(DR3D, XML_CUBE): { // dr3d:3dcube inside dr3d:3dscene context pContext = new SdXML3DCubeObjectShapeContext( rImport, xAttrList, rShapes); break; } - case XML_TOK_3DSCENE_3DSPHERE: + case XML_ELEMENT(DR3D, XML_SPHERE): { // dr3d:3dsphere inside dr3d:3dscene context pContext = new SdXML3DSphereObjectShapeContext( rImport, xAttrList, rShapes); break; } - case XML_TOK_3DSCENE_3DLATHE: + case XML_ELEMENT(DR3D, XML_ROTATE): { // dr3d:3dlathe inside dr3d:3dscene context pContext = new SdXML3DLatheObjectShapeContext( rImport, xAttrList, rShapes); break; } - case XML_TOK_3DSCENE_3DEXTRUDE: + case XML_ELEMENT(DR3D, XML_EXTRUDE): { // dr3d:3dextrude inside dr3d:3dscene context pContext = new SdXML3DExtrudeObjectShapeContext( rImport, xAttrList, rShapes); break; } + default: + XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); } } @@ -394,15 +394,11 @@ SvXMLShapeContext* XMLShapeImportHelper::Create3DSceneChildContext( return nullptr; // now parse the attribute list and call the child context for each unknown attribute - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for(sal_Int16 a(0); a < nAttrCount; a++) + for(auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList)) { - const OUString& rAttrName = xAttrList->getNameByIndex(a); - OUString aLocalName; - sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName); - const OUString aValue( xAttrList->getValueByIndex(a) ); + if (!pContext->processAttribute( aIter.getToken(), aIter.toString() )) + XMLOFF_WARN_UNKNOWN("xmloff", aIter); - pContext->processAttribute( nPrefix, aLocalName, aValue ); } return pContext; @@ -420,279 +416,216 @@ 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, + sal_Int32 nElement, + const uno::Reference< xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes, bool bTemporaryShape) { SdXMLShapeContext *pContext = nullptr; - - const SvXMLTokenMap& rTokenMap = GetGroupShapeElemTokenMap(); - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - - switch(rTokenMap.Get(p_nPrefix, rLocalName)) + switch (nElement) { - case XML_TOK_GROUP_GROUP: - { + case XML_ELEMENT(DRAW, XML_G): // draw:g inside group context (RECURSIVE) pContext = new SdXMLGroupShapeContext( rImport, xAttrList, rShapes, bTemporaryShape); break; - } - case XML_TOK_GROUP_3DSCENE: + case XML_ELEMENT(DR3D, XML_SCENE): { // dr3d:3dscene inside group context pContext = new SdXML3DSceneShapeContext( rImport, xAttrList, rShapes, bTemporaryShape); break; } - case XML_TOK_GROUP_RECT: + case XML_ELEMENT(DRAW, XML_RECT): { // draw:rect inside group context pContext = new SdXMLRectShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ); break; } - case XML_TOK_GROUP_LINE: + case XML_ELEMENT(DRAW, XML_LINE): { // draw:line inside group context pContext = new SdXMLLineShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ); break; } - case XML_TOK_GROUP_CIRCLE: - case XML_TOK_GROUP_ELLIPSE: + case XML_ELEMENT(DRAW, XML_CIRCLE): + case XML_ELEMENT(DRAW, XML_ELLIPSE): { // draw:circle or draw:ellipse inside group context pContext = new SdXMLEllipseShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ); break; } - case XML_TOK_GROUP_POLYGON: - case XML_TOK_GROUP_POLYLINE: + case XML_ELEMENT(DRAW, XML_POLYGON): + case XML_ELEMENT(DRAW, XML_POLYLINE): { // draw:polygon or draw:polyline inside group context pContext = new SdXMLPolygonShapeContext( rImport, xAttrList, rShapes, - rTokenMap.Get(p_nPrefix, rLocalName) == XML_TOK_GROUP_POLYGON, bTemporaryShape ); + nElement == XML_ELEMENT(DRAW, XML_POLYGON), bTemporaryShape ); break; } - case XML_TOK_GROUP_PATH: + case XML_ELEMENT(DRAW, XML_PATH): { // draw:path inside group context pContext = new SdXMLPathShapeContext( rImport, xAttrList, rShapes, bTemporaryShape); break; } - case XML_TOK_GROUP_FRAME: + case XML_ELEMENT(DRAW, XML_FRAME): { // text:text-box inside group context pContext = new SdXMLFrameShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ); break; } - case XML_TOK_GROUP_CONTROL: + case XML_ELEMENT(DRAW, XML_CONTROL): { // draw:control inside group context pContext = new SdXMLControlShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ); break; } - case XML_TOK_GROUP_CONNECTOR: + case XML_ELEMENT(DRAW, XML_CONNECTOR): { // draw:connector inside group context pContext = new SdXMLConnectorShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ); break; } - case XML_TOK_GROUP_MEASURE: + case XML_ELEMENT(DRAW, XML_MEASURE): { // draw:measure inside group context pContext = new SdXMLMeasureShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ); break; } - case XML_TOK_GROUP_PAGE: + case XML_ELEMENT(DRAW, XML_PAGE_THUMBNAIL): { // draw:page inside group context pContext = new SdXMLPageShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ); break; } - case XML_TOK_GROUP_CAPTION: - case XML_TOK_GROUP_ANNOTATION: + case XML_ELEMENT(DRAW, XML_CAPTION): + case XML_ELEMENT(OFFICE, XML_ANNOTATION): { // draw:caption inside group context pContext = new SdXMLCaptionShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ); break; } - case XML_TOK_GROUP_CHART: + case XML_ELEMENT(CHART, XML_CHART): { // chart:chart inside group context pContext = new SdXMLChartShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ); break; } - case XML_TOK_GROUP_CUSTOM_SHAPE: + case XML_ELEMENT(DRAW, XML_CUSTOM_SHAPE): { // draw:customshape pContext = new SdXMLCustomShapeContext( rImport, xAttrList, rShapes ); break; } - case XML_TOK_GROUP_A: - { - return new SdXMLShapeLinkContext( rImport, xAttrList, rShapes ); - } + case XML_ELEMENT(DRAW, XML_A): + return new SdXMLShapeLinkContext( rImport, xAttrList, rShapes ); + break; // add other shapes here... default: + XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); return new SvXMLShapeContext( rImport, bTemporaryShape ); } // now parse the attribute list and call the child context for each unknown attribute - for(sal_Int16 a(0); a < nAttrCount; a++) + for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList )) { - const OUString& rAttrName = xAttrList->getNameByIndex(a); - OUString aLocalName; - sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName); - const OUString aValue( xAttrList->getValueByIndex(a) ); - - pContext->processAttribute( nPrefix, aLocalName, aValue ); + if (!pContext->processAttribute( aIter.getToken(), aIter.toString() )) + XMLOFF_WARN_UNKNOWN("xmloff", aIter); } - return pContext; } // This method is called from SdXMLFrameShapeContext to create children of draw:frame SvXMLShapeContext* XMLShapeImportHelper::CreateFrameChildContext( SvXMLImport& rImport, - sal_uInt16 p_nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList>& rAttrList, + sal_Int32 nElement, + const uno::Reference< xml::sax::XFastAttributeList>& rAttrList, uno::Reference< drawing::XShapes > const & rShapes, - const uno::Reference< xml::sax::XAttributeList>& rFrameAttrList) + const uno::Reference< xml::sax::XFastAttributeList>& rFrameAttrList) { SdXMLShapeContext *pContext = nullptr; - const SvXMLTokenMap& rTokenMap = GetFrameShapeElemTokenMap(); - - SvXMLAttributeList *pAttrList = new SvXMLAttributeList( rAttrList ); + rtl::Reference<sax_fastparser::FastAttributeList> xCombinedAttrList = new sax_fastparser::FastAttributeList(rAttrList); if( rFrameAttrList.is() ) - pAttrList->AppendAttributeList( rFrameAttrList ); - uno::Reference < xml::sax::XAttributeList > xAttrList = pAttrList; + xCombinedAttrList->add(rFrameAttrList); - switch(rTokenMap.Get(p_nPrefix, rLocalName)) + switch(nElement) { - case XML_TOK_FRAME_TEXT_BOX: + case XML_ELEMENT(DRAW, XML_TEXT_BOX): { // text:text-box inside group context - pContext = new SdXMLTextBoxShapeContext( rImport, xAttrList, rShapes ); + pContext = new SdXMLTextBoxShapeContext( rImport, xCombinedAttrList.get(), rShapes ); break; } - case XML_TOK_FRAME_IMAGE: + case XML_ELEMENT(DRAW, XML_IMAGE): { // office:image inside group context - pContext = new SdXMLGraphicObjectShapeContext( rImport, xAttrList, rShapes ); + pContext = new SdXMLGraphicObjectShapeContext( rImport, xCombinedAttrList.get(), rShapes ); break; } - case XML_TOK_FRAME_OBJECT: - case XML_TOK_FRAME_OBJECT_OLE: + case XML_ELEMENT(DRAW, XML_OBJECT): + case XML_ELEMENT(DRAW, XML_OBJECT_OLE): { // draw:object or draw:object_ole - pContext = new SdXMLObjectShapeContext( rImport, xAttrList, rShapes ); + pContext = new SdXMLObjectShapeContext( rImport, xCombinedAttrList.get(), rShapes ); break; } - case XML_TOK_FRAME_TABLE: + case XML_ELEMENT(TABLE, XML_TABLE): { // draw:object or draw:object_ole if( rImport.IsTableShapeSupported() ) - pContext = new SdXMLTableShapeContext( rImport, xAttrList, rShapes ); + pContext = new SdXMLTableShapeContext( rImport, xCombinedAttrList.get(), rShapes ); break; } - case XML_TOK_FRAME_PLUGIN: + case XML_ELEMENT(DRAW, XML_PLUGIN): { // draw:plugin - pContext = new SdXMLPluginShapeContext( rImport, xAttrList, rShapes ); + pContext = new SdXMLPluginShapeContext( rImport, xCombinedAttrList.get(), rShapes ); break; } - case XML_TOK_FRAME_FLOATING_FRAME: + case XML_ELEMENT(DRAW, XML_FLOATING_FRAME): { // draw:floating-frame - pContext = new SdXMLFloatingFrameShapeContext( rImport, xAttrList, rShapes ); + pContext = new SdXMLFloatingFrameShapeContext( rImport, xCombinedAttrList.get(), rShapes ); break; } - case XML_TOK_FRAME_APPLET: + case XML_ELEMENT(DRAW, XML_APPLET): { // draw:applet - pContext = new SdXMLAppletShapeContext( rImport, xAttrList, rShapes ); + pContext = new SdXMLAppletShapeContext( rImport, xCombinedAttrList.get(), rShapes ); break; } // add other shapes here... default: + XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); break; } if( pContext ) { // now parse the attribute list and call the child context for each unknown attribute - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for(sal_Int16 a(0); a < nAttrCount; a++) + for(auto& aIter : *xCombinedAttrList) { - const OUString& rAttrName = xAttrList->getNameByIndex(a); - OUString aLocalName; - sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName); - const OUString aValue( xAttrList->getValueByIndex(a) ); - - pContext->processAttribute( nPrefix, aLocalName, aValue ); + if (!pContext->processAttribute( aIter.getToken(), aIter.toString() )) + XMLOFF_WARN_UNKNOWN("xmloff", aIter); } } return pContext; } -SvXMLImportContextRef XMLShapeImportHelper::CreateFrameChildContext( +css::uno::Reference< css::xml::sax::XFastContextHandler > XMLShapeImportHelper::CreateFrameChildContext( SvXMLImportContext *pThisContext, - sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList>& xAttrList ) + sal_Int32 nElement, + const uno::Reference< xml::sax::XFastAttributeList>& xAttrList ) { - SvXMLImportContextRef xContext; - + css::uno::Reference< css::xml::sax::XFastContextHandler > xContext; SdXMLFrameShapeContext *pFrameContext = dynamic_cast<SdXMLFrameShapeContext*>( pThisContext ); if (pFrameContext) - xContext = pFrameContext->CreateChildContext( nPrefix, rLocalName, xAttrList ); + xContext = pFrameContext->createFastChildContext( nElement, xAttrList ); + if (!xContext) + XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); return xContext; } @@ -700,7 +633,7 @@ SvXMLImportContextRef XMLShapeImportHelper::CreateFrameChildContext( shape to the given XShapes. */ void XMLShapeImportHelper::addShape( uno::Reference< drawing::XShape >& rShape, - const uno::Reference< xml::sax::XAttributeList >&, + const uno::Reference< xml::sax::XFastAttributeList >&, uno::Reference< drawing::XShapes >& rShapes) { if( rShape.is() && rShapes.is() ) @@ -716,7 +649,7 @@ void XMLShapeImportHelper::addShape( uno::Reference< drawing::XShape >& rShape, */ void XMLShapeImportHelper::finishShape( css::uno::Reference< css::drawing::XShape >& rShape, - const css::uno::Reference< css::xml::sax::XAttributeList >&, + const css::uno::Reference< css::xml::sax::XFastAttributeList >&, css::uno::Reference< css::drawing::XShapes >&) { /* Set property <PositionLayoutDir> diff --git a/xmloff/source/draw/ximp3dobject.cxx b/xmloff/source/draw/ximp3dobject.cxx index b58e7c559578..abe34189c90d 100644 --- a/xmloff/source/draw/ximp3dobject.cxx +++ b/xmloff/source/draw/ximp3dobject.cxx @@ -19,49 +19,48 @@ #include "ximp3dobject.hxx" #include <xmloff/xmluconv.hxx> +#include <xmloff/xmlnamespace.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <xexptran.hxx> #include <com/sun/star/drawing/PolyPolygonShape3D.hpp> #include <com/sun/star/drawing/Direction3D.hpp> #include <com/sun/star/drawing/Position3D.hpp> +#include <sal/log.hxx> #include <osl/diagnose.h> #include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <basegfx/polygon/b3dpolypolygontools.hxx> using namespace ::com::sun::star; +using namespace ::xmloff::token; SdXML3DObjectContext::SdXML3DObjectContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes) : SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ ), mbSetTransform( false ) { - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for(sal_Int16 i=0; i < nAttrCount; i++) + for(auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList)) { - OUString sAttrName = xAttrList->getNameByIndex( i ); - OUString aLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - OUString sValue = xAttrList->getValueByIndex( i ); - const SvXMLTokenMap& rAttrTokenMap = GetImport().GetShapeImport()->Get3DObjectAttrTokenMap(); - - switch(rAttrTokenMap.Get(nPrefix, aLocalName)) + const OUString sValue = aIter.toString(); + switch(aIter.getToken()) { - case XML_TOK_3DOBJECT_DRAWSTYLE_NAME: + case XML_ELEMENT(DRAW, XML_STYLE_NAME): { maDrawStyleName = sValue; break; } - case XML_TOK_3DOBJECT_TRANSFORM: + case XML_ELEMENT(DR3D, XML_TRANSFORM): { SdXMLImExTransform3D aTransform(sValue, GetImport().GetMM100UnitConverter()); if(aTransform.NeedsAction()) mbSetTransform = aTransform.GetFullHomogenTransform(mxHomMat); break; } + default: + XMLOFF_WARN_UNKNOWN("xmloff", aIter); } } } @@ -90,24 +89,19 @@ void SdXML3DObjectContext::startFastElement( SdXML3DCubeObjectShapeContext::SdXML3DCubeObjectShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes) : SdXML3DObjectContext( rImport, xAttrList, rShapes ), maMinEdge(-2500.0, -2500.0, -2500.0), maMaxEdge(2500.0, 2500.0, 2500.0) { - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for(sal_Int16 i=0; i < nAttrCount; i++) + for(auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList)) { - OUString sAttrName = xAttrList->getNameByIndex( i ); - OUString aLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - OUString sValue = xAttrList->getValueByIndex( i ); - const SvXMLTokenMap& rAttrTokenMap = GetImport().GetShapeImport()->Get3DCubeObjectAttrTokenMap(); + OUString sValue = aIter.toString(); - switch(rAttrTokenMap.Get(nPrefix, aLocalName)) + switch(aIter.getToken()) { - case XML_TOK_3DCUBEOBJ_MINEDGE: + case XML_ELEMENT(DR3D, XML_MIN_EDGE): { ::basegfx::B3DVector aNewVec; SvXMLUnitConverter::convertB3DVector(aNewVec, sValue); @@ -116,7 +110,7 @@ SdXML3DCubeObjectShapeContext::SdXML3DCubeObjectShapeContext( maMinEdge = aNewVec; break; } - case XML_TOK_3DCUBEOBJ_MAXEDGE: + case XML_ELEMENT(DR3D, XML_MAX_EDGE): { ::basegfx::B3DVector aNewVec; SvXMLUnitConverter::convertB3DVector(aNewVec, sValue); @@ -125,6 +119,8 @@ SdXML3DCubeObjectShapeContext::SdXML3DCubeObjectShapeContext( maMaxEdge = aNewVec; break; } + default: + XMLOFF_WARN_UNKNOWN("xmloff", aIter); } } } @@ -172,24 +168,19 @@ void SdXML3DCubeObjectShapeContext::startFastElement( SdXML3DSphereObjectShapeContext::SdXML3DSphereObjectShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes) : SdXML3DObjectContext( rImport, xAttrList, rShapes ), maCenter(0.0, 0.0, 0.0), maSphereSize(5000.0, 5000.0, 5000.0) { - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for(sal_Int16 i=0; i < nAttrCount; i++) + for(auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList)) { - OUString sAttrName = xAttrList->getNameByIndex( i ); - OUString aLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - OUString sValue = xAttrList->getValueByIndex( i ); - const SvXMLTokenMap& rAttrTokenMap = GetImport().GetShapeImport()->Get3DSphereObjectAttrTokenMap(); + OUString sValue = aIter.toString(); - switch(rAttrTokenMap.Get(nPrefix, aLocalName)) + switch(aIter.getToken()) { - case XML_TOK_3DSPHEREOBJ_CENTER: + case XML_ELEMENT(DR3D, XML_CENTER): { ::basegfx::B3DVector aNewVec; SvXMLUnitConverter::convertB3DVector(aNewVec, sValue); @@ -198,7 +189,7 @@ SdXML3DSphereObjectShapeContext::SdXML3DSphereObjectShapeContext( maCenter = aNewVec; break; } - case XML_TOK_3DSPHEREOBJ_SIZE: + case XML_ELEMENT(DR3D, XML_SIZE): { ::basegfx::B3DVector aNewVec; SvXMLUnitConverter::convertB3DVector(aNewVec, sValue); @@ -207,6 +198,8 @@ SdXML3DSphereObjectShapeContext::SdXML3DSphereObjectShapeContext( maSphereSize = aNewVec; break; } + default: + XMLOFF_WARN_UNKNOWN("xmloff", aIter); } } } @@ -251,31 +244,30 @@ void SdXML3DSphereObjectShapeContext::startFastElement( SdXML3DPolygonBasedShapeContext::SdXML3DPolygonBasedShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes) : SdXML3DObjectContext( rImport, xAttrList, rShapes ) { - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for(sal_Int16 i=0; i < nAttrCount; i++) + for(auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList)) { - OUString sAttrName = xAttrList->getNameByIndex( i ); - OUString aLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - OUString sValue = xAttrList->getValueByIndex( i ); - const SvXMLTokenMap& rAttrTokenMap = GetImport().GetShapeImport()->Get3DPolygonBasedAttrTokenMap(); + OUString sValue = aIter.toString(); - switch(rAttrTokenMap.Get(nPrefix, aLocalName)) + switch(aIter.getToken()) { - case XML_TOK_3DPOLYGONBASED_VIEWBOX: + case XML_ELEMENT(SVG, XML_VIEWBOX): + case XML_ELEMENT(SVG_COMPAT, XML_VIEWBOX): { maViewBox = sValue; break; } - case XML_TOK_3DPOLYGONBASED_D: + case XML_ELEMENT(SVG, XML_D): + case XML_ELEMENT(SVG_COMPAT, XML_D): { maPoints = sValue; break; } + default: + XMLOFF_WARN_UNKNOWN("xmloff", aIter); } } } @@ -328,7 +320,7 @@ void SdXML3DPolygonBasedShapeContext::startFastElement( SdXML3DLatheObjectShapeContext::SdXML3DLatheObjectShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes) : SdXML3DPolygonBasedShapeContext( rImport, xAttrList, rShapes ) { @@ -354,7 +346,7 @@ void SdXML3DLatheObjectShapeContext::startFastElement( SdXML3DExtrudeObjectShapeContext::SdXML3DExtrudeObjectShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes) : SdXML3DPolygonBasedShapeContext( rImport, xAttrList, rShapes ) { diff --git a/xmloff/source/draw/ximp3dobject.hxx b/xmloff/source/draw/ximp3dobject.hxx index ac40bd88b6ac..7bbab86f7ea0 100644 --- a/xmloff/source/draw/ximp3dobject.hxx +++ b/xmloff/source/draw/ximp3dobject.hxx @@ -36,7 +36,7 @@ class SdXML3DObjectContext : public SdXMLShapeContext public: SdXML3DObjectContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes); virtual ~SdXML3DObjectContext() override; @@ -55,7 +55,7 @@ class SdXML3DCubeObjectShapeContext : public SdXML3DObjectContext public: SdXML3DCubeObjectShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes); virtual ~SdXML3DCubeObjectShapeContext() override; @@ -74,7 +74,7 @@ class SdXML3DSphereObjectShapeContext : public SdXML3DObjectContext public: SdXML3DSphereObjectShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes); virtual ~SdXML3DSphereObjectShapeContext() override; @@ -93,7 +93,7 @@ class SdXML3DPolygonBasedShapeContext : public SdXML3DObjectContext public: SdXML3DPolygonBasedShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes); virtual ~SdXML3DPolygonBasedShapeContext() override; @@ -109,7 +109,7 @@ class SdXML3DLatheObjectShapeContext : public SdXML3DPolygonBasedShapeContext public: SdXML3DLatheObjectShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes); virtual ~SdXML3DLatheObjectShapeContext() override; @@ -125,7 +125,7 @@ class SdXML3DExtrudeObjectShapeContext : public SdXML3DPolygonBasedShapeContext public: SdXML3DExtrudeObjectShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes); virtual ~SdXML3DExtrudeObjectShapeContext() override; diff --git a/xmloff/source/draw/ximp3dscene.cxx b/xmloff/source/draw/ximp3dscene.cxx index b062898256ff..9477481343e8 100644 --- a/xmloff/source/draw/ximp3dscene.cxx +++ b/xmloff/source/draw/ximp3dscene.cxx @@ -94,7 +94,7 @@ SdXML3DLightContext::~SdXML3DLightContext() SdXML3DSceneShapeContext::SdXML3DSceneShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes, bool bTemporaryShapes) : SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShapes ), SdXML3DSceneAttributesHelper( rImport ) @@ -168,45 +168,24 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SdXML3DSceneShapeConte case XML_ELEMENT(SVG_COMPAT, XML_TITLE): case XML_ELEMENT(SVG, XML_DESC): case XML_ELEMENT(SVG_COMPAT, XML_DESC): + xContext = new SdXMLDescriptionContext( GetImport(), nElement, mxShape ); break; case XML_ELEMENT(OFFICE, XML_EVENT_LISTENERS): + xContext = new SdXMLEventsContext( GetImport(), mxShape ); break; // look for local light context first case XML_ELEMENT(DR3D, XML_LIGHT): // dr3d:light inside dr3d:scene context xContext = create3DLightContext( xAttrList ); break; + default: + // call GroupChildContext function at common ShapeImport + return XMLShapeImportHelper::Create3DSceneChildContext( + GetImport(), nElement, xAttrList, mxChildren); } return xContext.get(); } -SvXMLImportContextRef SdXML3DSceneShapeContext::CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList>& xAttrList ) -{ - SvXMLImportContextRef xContext; - - // #i68101# - if( nPrefix == XML_NAMESPACE_SVG && - (IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) ) - { - xContext = new SdXMLDescriptionContext( GetImport(), nPrefix, rLocalName, xAttrList, mxShape ); - } - else if( nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) ) - { - xContext = new SdXMLEventsContext( GetImport(), nPrefix, rLocalName, xAttrList, mxShape ); - } - - // call GroupChildContext function at common ShapeImport - if (!xContext) - { - xContext = GetImport().GetShapeImport()->Create3DSceneChildContext( - GetImport(), nPrefix, rLocalName, xAttrList, mxChildren); - } - - return xContext; -} - SdXML3DSceneAttributesHelper::SdXML3DSceneAttributesHelper( SvXMLImport& rImporter ) : mrImport( rImporter ), mbSetTransform( false ), diff --git a/xmloff/source/draw/ximp3dscene.hxx b/xmloff/source/draw/ximp3dscene.hxx index 9d06f93990cf..42905689fffb 100644 --- a/xmloff/source/draw/ximp3dscene.hxx +++ b/xmloff/source/draw/ximp3dscene.hxx @@ -36,7 +36,7 @@ public: SdXML3DSceneShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes, bool bTemporaryShape); virtual ~SdXML3DSceneShapeContext() override; @@ -48,10 +48,6 @@ public: sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; - - virtual SvXMLImportContextRef CreateChildContext( - sal_uInt16 nPrefix, const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) override; }; #endif // INCLUDED_XMLOFF_SOURCE_DRAW_XIMP3DSCENE_HXX diff --git a/xmloff/source/draw/ximpcustomshape.cxx b/xmloff/source/draw/ximpcustomshape.cxx index e85143e0b1d4..8e23b0ee844f 100644 --- a/xmloff/source/draw/ximpcustomshape.cxx +++ b/xmloff/source/draw/ximpcustomshape.cxx @@ -55,9 +55,8 @@ using namespace ::xmloff::EnhancedCustomShapeToken; XMLEnhancedCustomShapeContext::XMLEnhancedCustomShapeContext( SvXMLImport& rImport, css::uno::Reference< css::drawing::XShape >& rxShape, - sal_uInt16 nPrefix, const OUString& rLocalName, std::vector< css::beans::PropertyValue >& rCustomShapeGeometry ) : - SvXMLImportContext( rImport, nPrefix, rLocalName ), + SvXMLImportContext( rImport ), mrUnitConverter( rImport.GetMM100UnitConverter() ), mrxShape( rxShape ), mrCustomShapeGeometry( rCustomShapeGeometry ) diff --git a/xmloff/source/draw/ximpcustomshape.hxx b/xmloff/source/draw/ximpcustomshape.hxx index 4700388bf110..f06d01c0cddb 100644 --- a/xmloff/source/draw/ximpcustomshape.hxx +++ b/xmloff/source/draw/ximpcustomshape.hxx @@ -51,8 +51,8 @@ class XMLEnhancedCustomShapeContext : public SvXMLImportContext public: - XMLEnhancedCustomShapeContext( SvXMLImport& rImport, css::uno::Reference< css::drawing::XShape > &, sal_uInt16 nPrefix, - const OUString& rLocalName, std::vector< css::beans::PropertyValue >& rCustomShapeGeometry ); + XMLEnhancedCustomShapeContext( SvXMLImport& rImport, css::uno::Reference< css::drawing::XShape > &, + std::vector< css::beans::PropertyValue >& rCustomShapeGeometry ); virtual void SAL_CALL startFastElement( sal_Int32 nElement, diff --git a/xmloff/source/draw/ximpgrp.cxx b/xmloff/source/draw/ximpgrp.cxx index 716e0d5f506b..c9cf7e218a35 100644 --- a/xmloff/source/draw/ximpgrp.cxx +++ b/xmloff/source/draw/ximpgrp.cxx @@ -30,7 +30,7 @@ using namespace ::xmloff::token; SdXMLGroupShapeContext::SdXMLGroupShapeContext( SvXMLImport& rImport, - const uno::Reference< xml::sax::XAttributeList>& xAttrList, + const uno::Reference< xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes, bool bTemporaryShape) : SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ) @@ -45,59 +45,31 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLGroupShapeContext sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { - // #i68101# + // #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 + return new SdXMLDescriptionContext( GetImport(), nElement, mxShape ); } else if( nElement == XML_ELEMENT(OFFICE, XML_EVENT_LISTENERS) ) { - // handled in CreateChildContext + return new SdXMLEventsContext( GetImport(), mxShape ); } else if( nElement == XML_ELEMENT(DRAW, XML_GLUE_POINT) ) { - // handled in CreateChildContext + addGluePoint( xAttrList ); } else { // call GroupChildContext function at common ShapeImport - return GetImport().GetShapeImport()->CreateGroupChildContext( + return XMLShapeImportHelper::CreateGroupChildContext( GetImport(), nElement, xAttrList, mxChildren); } return nullptr; } -SvXMLImportContextRef SdXMLGroupShapeContext::CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList>& xAttrList ) -{ - SvXMLImportContextRef xContext; - - // #i68101# - if( nPrefix == XML_NAMESPACE_SVG && - (IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) ) - { - xContext = new SdXMLDescriptionContext( GetImport(), nPrefix, rLocalName, xAttrList, mxShape ); - } - else if( nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) ) - { - xContext = new SdXMLEventsContext( GetImport(), nPrefix, rLocalName, xAttrList, mxShape ); - } - else if( nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_GLUE_POINT ) ) - { - addGluePoint( xAttrList ); - } - else - { - // handled in createFastChildContext - } - - return xContext; -} - void SdXMLGroupShapeContext::startFastElement (sal_Int32 /*nElement*/, const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/) { diff --git a/xmloff/source/draw/ximpgrp.hxx b/xmloff/source/draw/ximpgrp.hxx index c775e2e35bfc..3bab50490c0b 100644 --- a/xmloff/source/draw/ximpgrp.hxx +++ b/xmloff/source/draw/ximpgrp.hxx @@ -34,14 +34,11 @@ class SdXMLGroupShapeContext : public SdXMLShapeContext public: SdXMLGroupShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes, bool bTemporaryShape); virtual ~SdXMLGroupShapeContext() override; - virtual SvXMLImportContextRef CreateChildContext( - sal_uInt16 nPrefix, const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) override; virtual void SAL_CALL startFastElement( sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; diff --git a/xmloff/source/draw/ximplink.cxx b/xmloff/source/draw/ximplink.cxx index cebd3086c7f4..41b236cc8a9c 100644 --- a/xmloff/source/draw/ximplink.cxx +++ b/xmloff/source/draw/ximplink.cxx @@ -27,23 +27,19 @@ using namespace ::com::sun::star; using namespace ::xmloff::token; -SdXMLShapeLinkContext::SdXMLShapeLinkContext( SvXMLImport& rImport, const uno::Reference< xml::sax::XAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes) +SdXMLShapeLinkContext::SdXMLShapeLinkContext( SvXMLImport& rImport, const uno::Reference< xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes) : SvXMLShapeContext( rImport, false ) , mxParent( rShapes ) { - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - - for(sal_Int16 i=0; i < nAttrCount; i++) + for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList )) { - OUString sAttrName = xAttrList->getNameByIndex( i ); - OUString aLocalName; - sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - if( (nPrefix == XML_NAMESPACE_XLINK) && IsXMLToken( aLocalName, XML_HREF ) ) + if( aIter.getToken() == XML_ELEMENT(XLINK, XML_HREF) ) { assert(msHyperlink.pData); - msHyperlink = xAttrList->getValueByIndex( i ); - break; + msHyperlink = aIter.toString(); } + else + XMLOFF_WARN_UNKNOWN("xmloff", aIter); } } @@ -55,7 +51,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLShapeLinkContext: sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { - SvXMLShapeContext* pContext = GetImport().GetShapeImport()->CreateGroupChildContext( GetImport(), nElement, xAttrList, mxParent); + SvXMLShapeContext* pContext = XMLShapeImportHelper::CreateGroupChildContext( GetImport(), nElement, xAttrList, mxParent); if( pContext ) { diff --git a/xmloff/source/draw/ximplink.hxx b/xmloff/source/draw/ximplink.hxx index 3055d85204af..274365fb5a90 100644 --- a/xmloff/source/draw/ximplink.hxx +++ b/xmloff/source/draw/ximplink.hxx @@ -37,7 +37,7 @@ class SdXMLShapeLinkContext : public SvXMLShapeContext public: SdXMLShapeLinkContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes); virtual ~SdXMLShapeLinkContext() override; diff --git a/xmloff/source/draw/ximppage.cxx b/xmloff/source/draw/ximppage.cxx index 8b8342bd0edc..b9492b96a776 100644 --- a/xmloff/source/draw/ximppage.cxx +++ b/xmloff/source/draw/ximppage.cxx @@ -264,7 +264,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLGenericPageContex else { // call GroupChildContext function at common ShapeImport - auto p = GetImport().GetShapeImport()->CreateGroupChildContext(GetImport(), nElement, xAttrList, mxShapes); + auto p = XMLShapeImportHelper::CreateGroupChildContext(GetImport(), nElement, xAttrList, mxShapes); if (p) return p; } diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx index 520bc682e6bf..5ae4680332ae 100644 --- a/xmloff/source/draw/ximpshap.cxx +++ b/xmloff/source/draw/ximpshap.cxx @@ -141,7 +141,7 @@ static bool ImpIsEmptyURL( std::u16string_view rURL ) SdXMLShapeContext::SdXMLShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes, bool bTemporaryShape) : SvXMLShapeContext( rImport, bTemporaryShape ) @@ -169,53 +169,37 @@ SdXMLShapeContext::~SdXMLShapeContext() { } -SvXMLImportContextRef SdXMLShapeContext::CreateChildContext( sal_uInt16 p_nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList>& xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLShapeContext::createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { SvXMLImportContextRef xContext; - // #i68101# - if( p_nPrefix == XML_NAMESPACE_SVG && - (IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) ) + 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) ) { - xContext = new SdXMLDescriptionContext( GetImport(), p_nPrefix, rLocalName, xAttrList, mxShape ); + xContext = new SdXMLDescriptionContext( GetImport(), nElement, mxShape ); } - else if( p_nPrefix == XML_NAMESPACE_LO_EXT && IsXMLToken( rLocalName, XML_SIGNATURELINE ) ) + else if( nElement == XML_ELEMENT(LO_EXT, XML_SIGNATURELINE) ) { - xContext = new SignatureLineContext( GetImport(), p_nPrefix, rLocalName, xAttrList, mxShape ); + xContext = new SignatureLineContext( GetImport(), nElement, xAttrList, mxShape ); } - else if( p_nPrefix == XML_NAMESPACE_LO_EXT && IsXMLToken( rLocalName, XML_QRCODE ) ) + else if( nElement == XML_ELEMENT(LO_EXT, XML_QRCODE) ) { - xContext = new QRCodeContext( GetImport(), p_nPrefix, rLocalName, xAttrList, mxShape ); + xContext = new QRCodeContext( GetImport(), nElement, xAttrList, mxShape ); } - else if( p_nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) ) + else if( nElement == XML_ELEMENT(OFFICE, XML_EVENT_LISTENERS) ) { - xContext = new SdXMLEventsContext( GetImport(), p_nPrefix, rLocalName, xAttrList, mxShape ); + xContext = new SdXMLEventsContext( GetImport(), mxShape ); } - else if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_GLUE_POINT ) ) + else if( nElement == XML_ELEMENT(DRAW, XML_GLUE_POINT) ) { addGluePoint( xAttrList ); } - else if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_THUMBNAIL ) ) + else if( nElement == XML_ELEMENT(DRAW, XML_THUMBNAIL) ) { // search attributes for xlink:href - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for(sal_Int16 i=0; i < nAttrCount; i++) - { - OUString sAttrName = xAttrList->getNameByIndex( i ); - OUString aLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - - if( nPrefix == XML_NAMESPACE_XLINK ) - { - if( IsXMLToken( aLocalName, XML_HREF ) ) - { - maThumbnailURL = xAttrList->getValueByIndex( i ); - break; - } - } - } + maThumbnailURL = xAttrList->getOptionalValue(XML_ELEMENT(XLINK, XML_HREF)); } else { @@ -245,15 +229,18 @@ SvXMLImportContextRef SdXMLShapeContext::CreateChildContext( sal_uInt16 p_nPrefi if( mxCursor.is() ) { xContext = GetImport().GetTextImport()->CreateTextChildContext( - GetImport(), p_nPrefix, rLocalName, xAttrList, + GetImport(), nElement, xAttrList, ( mbTextBox ? XMLTextType::TextBox : XMLTextType::Shape ) ); } } - return xContext; + if (!xContext) + XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); + + return xContext.get(); } -void SdXMLShapeContext::addGluePoint( const uno::Reference< xml::sax::XAttributeList>& xAttrList ) +void SdXMLShapeContext::addGluePoint( const uno::Reference< xml::sax::XFastAttributeList>& xAttrList ) { // get the glue points container for this shape if it's not already there if( !mxGluePoints.is() ) @@ -279,46 +266,40 @@ void SdXMLShapeContext::addGluePoint( const uno::Reference< xml::sax::XAttribute sal_Int32 nId = -1; // read attributes for the 3DScene - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for(sal_Int16 i=0; i < nAttrCount; i++) + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { - OUString sAttrName = xAttrList->getNameByIndex( i ); - OUString aLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - const OUString sValue( xAttrList->getValueByIndex( i ) ); - - if( nPrefix == XML_NAMESPACE_SVG ) + switch(aIter.getToken()) { - if( IsXMLToken( aLocalName, XML_X ) ) - { + case XML_ELEMENT(SVG, XML_X): + case XML_ELEMENT(SVG_COMPAT, XML_X): GetImport().GetMM100UnitConverter().convertMeasureToCore( - aGluePoint.Position.X, sValue); - } - else if( IsXMLToken( aLocalName, XML_Y ) ) - { + aGluePoint.Position.X, aIter.toString()); + break; + case XML_ELEMENT(SVG, XML_Y): + case XML_ELEMENT(SVG_COMPAT, XML_Y): GetImport().GetMM100UnitConverter().convertMeasureToCore( - aGluePoint.Position.Y, sValue); - } - } - else if( nPrefix == XML_NAMESPACE_DRAW ) - { - if( IsXMLToken( aLocalName, XML_ID ) ) - { - nId = sValue.toInt32(); - } - else if( IsXMLToken( aLocalName, XML_ALIGN ) ) + aGluePoint.Position.Y, aIter.toString()); + break; + case XML_ELEMENT(DRAW, XML_ID): + nId = aIter.toInt32(); + break; + case XML_ELEMENT(DRAW, XML_ALIGN): { drawing::Alignment eKind; - if( SvXMLUnitConverter::convertEnum( eKind, sValue, aXML_GlueAlignment_EnumMap ) ) + if( SvXMLUnitConverter::convertEnum( eKind, aIter.toString(), aXML_GlueAlignment_EnumMap ) ) { aGluePoint.PositionAlignment = eKind; aGluePoint.IsRelative = false; } + break; } - else if( IsXMLToken( aLocalName, XML_ESCAPE_DIRECTION ) ) + case XML_ELEMENT(DRAW, XML_ESCAPE_DIRECTION): { - SvXMLUnitConverter::convertEnum( aGluePoint.Escape, sValue, aXML_GlueEscapeDirection_EnumMap ); + SvXMLUnitConverter::convertEnum( aGluePoint.Escape, aIter.toString(), aXML_GlueEscapeDirection_EnumMap ); + break; } + default: + XMLOFF_WARN_UNKNOWN("xmloff", aIter); } } @@ -801,125 +782,110 @@ void SdXMLShapeContext::SetThumbnail() } // this is called from the parent group for each unparsed attribute in the attribute list -void SdXMLShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) +bool SdXMLShapeContext::processAttribute( sal_Int32 nElement, const OUString& rValue ) { - if( (XML_NAMESPACE_DRAW == nPrefix) || (XML_NAMESPACE_DRAW_EXT == nPrefix) ) + sal_Int32 nTmp; + switch (nElement) { - if( IsXMLToken( rLocalName, XML_ZINDEX ) ) - { + case XML_ELEMENT(DRAW, XML_ZINDEX): + case XML_ELEMENT(DRAW_EXT, XML_ZINDEX): mnZOrder = rValue.toInt32(); - } - else if( IsXMLToken( rLocalName, XML_ID ) ) - { + break; + case XML_ELEMENT(DRAW, XML_ID): + case XML_ELEMENT(DRAW_EXT, XML_ID): if (!mbHaveXmlId) { maShapeId = rValue; } - } - else if( IsXMLToken( rLocalName, XML_NAME ) ) - { + break; + case XML_ELEMENT(DRAW, XML_NAME): + case XML_ELEMENT(DRAW_EXT, XML_NAME): maShapeName = rValue; - } - else if( IsXMLToken( rLocalName, XML_STYLE_NAME ) ) - { + break; + case XML_ELEMENT(DRAW, XML_STYLE_NAME): + case XML_ELEMENT(DRAW_EXT, XML_STYLE_NAME): maDrawStyleName = rValue; - } - else if( IsXMLToken( rLocalName, XML_TEXT_STYLE_NAME ) ) - { + break; + case XML_ELEMENT(DRAW, XML_TEXT_STYLE_NAME): + case XML_ELEMENT(DRAW_EXT, XML_TEXT_STYLE_NAME): maTextStyleName = rValue; - } - else if( IsXMLToken( rLocalName, XML_LAYER ) ) - { + break; + case XML_ELEMENT(DRAW, XML_LAYER): + case XML_ELEMENT(DRAW_EXT, XML_LAYER): maLayerName = rValue; - } - else if( IsXMLToken( rLocalName, XML_TRANSFORM ) ) - { + break; + case XML_ELEMENT(DRAW, XML_TRANSFORM): + case XML_ELEMENT(DRAW_EXT, XML_TRANSFORM): mnTransform.SetString(rValue, GetImport().GetMM100UnitConverter()); - } - else if( IsXMLToken( rLocalName, XML_DISPLAY ) ) - { + break; + case XML_ELEMENT(DRAW, XML_DISPLAY): + case XML_ELEMENT(DRAW_EXT, XML_DISPLAY): mbVisible = IsXMLToken( rValue, XML_ALWAYS ) || IsXMLToken( rValue, XML_SCREEN ); mbPrintable = IsXMLToken( rValue, XML_ALWAYS ) || IsXMLToken( rValue, XML_PRINTER ); - } - } - else if( XML_NAMESPACE_PRESENTATION == nPrefix ) - { - if( IsXMLToken( rLocalName, XML_USER_TRANSFORMED ) ) - { + break; + case XML_ELEMENT(PRESENTATION, XML_USER_TRANSFORMED): mbIsUserTransformed = IsXMLToken( rValue, XML_TRUE ); - } - else if( IsXMLToken( rLocalName, XML_PLACEHOLDER ) ) - { + break; + case XML_ELEMENT(PRESENTATION, XML_PLACEHOLDER): mbIsPlaceholder = IsXMLToken( rValue, XML_TRUE ); if( mbIsPlaceholder ) mbClearDefaultAttributes = false; - } - else if( IsXMLToken( rLocalName, XML_CLASS ) ) - { + break; + case XML_ELEMENT(PRESENTATION, XML_CLASS): maPresentationClass = rValue; - } - else if( IsXMLToken( rLocalName, XML_STYLE_NAME ) ) - { + break; + case XML_ELEMENT(PRESENTATION, XML_STYLE_NAME): maDrawStyleName = rValue; mnStyleFamily = XmlStyleFamily::SD_PRESENTATION_ID; - } - } - else if( XML_NAMESPACE_SVG == nPrefix ) - { - if( IsXMLToken( rLocalName, XML_X ) ) - { + break; + case XML_ELEMENT(SVG, XML_X): + case XML_ELEMENT(SVG_COMPAT, XML_X): GetImport().GetMM100UnitConverter().convertMeasureToCore( maPosition.X, rValue); - } - else if( IsXMLToken( rLocalName, XML_Y ) ) - { + break; + case XML_ELEMENT(SVG, XML_Y): + case XML_ELEMENT(SVG_COMPAT, XML_Y): GetImport().GetMM100UnitConverter().convertMeasureToCore( maPosition.Y, rValue); - } - else if( IsXMLToken( rLocalName, XML_WIDTH ) ) - { + break; + case XML_ELEMENT(SVG, XML_WIDTH): + case XML_ELEMENT(SVG_COMPAT, XML_WIDTH): GetImport().GetMM100UnitConverter().convertMeasureToCore( maSize.Width, rValue); if (maSize.Width > 0) maSize.Width = o3tl::saturating_add<sal_Int32>(maSize.Width, 1); else if (maSize.Width < 0) maSize.Width = o3tl::saturating_add<sal_Int32>(maSize.Width, -1); - } - else if( IsXMLToken( rLocalName, XML_HEIGHT ) ) - { + break; + case XML_ELEMENT(SVG, XML_HEIGHT): + case XML_ELEMENT(SVG_COMPAT, XML_HEIGHT): GetImport().GetMM100UnitConverter().convertMeasureToCore( maSize.Height, rValue); if (maSize.Height > 0) maSize.Height = o3tl::saturating_add<sal_Int32>(maSize.Height, 1); else if (maSize.Height < 0) maSize.Height = o3tl::saturating_add<sal_Int32>(maSize.Height, -1); - } - else if( IsXMLToken( rLocalName, XML_TRANSFORM ) ) - { + break; + case XML_ELEMENT(SVG, XML_TRANSFORM): + case XML_ELEMENT(SVG_COMPAT, XML_TRANSFORM): // because of #85127# take svg:transform into account and handle like // draw:transform for compatibility mnTransform.SetString(rValue, GetImport().GetMM100UnitConverter()); - } - } - else if (nPrefix == XML_NAMESPACE_STYLE) - { - sal_Int32 nTmp; - if (IsXMLToken(rLocalName, XML_REL_WIDTH)) - { + break; + case XML_ELEMENT(STYLE, XML_REL_WIDTH): if (sax::Converter::convertPercent(nTmp, rValue)) mnRelWidth = static_cast<sal_Int16>(nTmp); - } - else if (IsXMLToken(rLocalName, XML_REL_HEIGHT)) - { + break; + case XML_ELEMENT(STYLE, XML_REL_HEIGHT): if (sax::Converter::convertPercent(nTmp, rValue)) mnRelHeight = static_cast<sal_Int16>(nTmp); - } - } - else if( (XML_NAMESPACE_NONE == nPrefix) || (XML_NAMESPACE_XML == nPrefix) ) - { - if( IsXMLToken( rLocalName, XML_ID ) ) - { + break; + case XML_ELEMENT(NONE, XML_ID): + case XML_ELEMENT(XML, XML_ID): maShapeId = rValue; mbHaveXmlId = true; - } + break; + default: + return false; } + return true; } bool SdXMLShapeContext::isPresentationShape() const @@ -943,7 +909,7 @@ bool SdXMLShapeContext::isPresentationShape() const SdXMLRectShapeContext::SdXMLRectShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes, bool bTemporaryShape) : SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ), @@ -956,19 +922,18 @@ SdXMLRectShapeContext::~SdXMLRectShapeContext() } // this is called from the parent group for each unparsed attribute in the attribute list -void SdXMLRectShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) +bool SdXMLRectShapeContext::processAttribute( sal_Int32 nElement, const OUString& rValue ) { - if( XML_NAMESPACE_DRAW == nPrefix ) + switch (nElement) { - if( IsXMLToken( rLocalName, XML_CORNER_RADIUS ) ) - { + case XML_ELEMENT(DRAW, XML_CORNER_RADIUS): GetImport().GetMM100UnitConverter().convertMeasureToCore( mnRadius, rValue); - return; - } + break; + default: + return SdXMLShapeContext::processAttribute( nElement, rValue ); } - - SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); + return true; } void SdXMLRectShapeContext::startFastElement (sal_Int32 nElement, @@ -1007,7 +972,7 @@ void SdXMLRectShapeContext::startFastElement (sal_Int32 nElement, SdXMLLineShapeContext::SdXMLLineShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes, bool bTemporaryShape) : SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ), @@ -1023,37 +988,34 @@ SdXMLLineShapeContext::~SdXMLLineShapeContext() } // this is called from the parent group for each unparsed attribute in the attribute list -void SdXMLLineShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) +bool SdXMLLineShapeContext::processAttribute( sal_Int32 nElement, const OUString& rValue ) { - if( XML_NAMESPACE_SVG == nPrefix ) + switch (nElement) { - if( IsXMLToken( rLocalName, XML_X1 ) ) - { + case XML_ELEMENT(SVG, XML_X1): + case XML_ELEMENT(SVG_COMPAT, XML_X1): GetImport().GetMM100UnitConverter().convertMeasureToCore( mnX1, rValue); - return; - } - if( IsXMLToken( rLocalName, XML_Y1 ) ) - { + break; + case XML_ELEMENT(SVG, XML_Y1): + case XML_ELEMENT(SVG_COMPAT, XML_Y1): GetImport().GetMM100UnitConverter().convertMeasureToCore( mnY1, rValue); - return; - } - if( IsXMLToken( rLocalName, XML_X2 ) ) - { + break; + case XML_ELEMENT(SVG, XML_X2): + case XML_ELEMENT(SVG_COMPAT, XML_X2): GetImport().GetMM100UnitConverter().convertMeasureToCore( mnX2, rValue); - return; - } - if( IsXMLToken( rLocalName, XML_Y2 ) ) - { + break; + case XML_ELEMENT(SVG, XML_Y2): + case XML_ELEMENT(SVG_COMPAT, XML_Y2): GetImport().GetMM100UnitConverter().convertMeasureToCore( mnY2, rValue); - return; - } + break; + default: + return SdXMLShapeContext::processAttribute( nElement, rValue ); } - - SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); + return true; } void SdXMLLineShapeContext::startFastElement (sal_Int32 nElement, @@ -1119,7 +1081,7 @@ void SdXMLLineShapeContext::startFastElement (sal_Int32 nElement, SdXMLEllipseShapeContext::SdXMLEllipseShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes, bool bTemporaryShape) : SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ), @@ -1138,67 +1100,58 @@ SdXMLEllipseShapeContext::~SdXMLEllipseShapeContext() } // this is called from the parent group for each unparsed attribute in the attribute list -void SdXMLEllipseShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) +bool SdXMLEllipseShapeContext::processAttribute( sal_Int32 nElement, const OUString& rValue ) { - if( XML_NAMESPACE_SVG == nPrefix ) + switch (nElement) { - if( IsXMLToken( rLocalName, XML_RX ) ) - { + case XML_ELEMENT(SVG, XML_RX): + case XML_ELEMENT(SVG_COMPAT, XML_RX): GetImport().GetMM100UnitConverter().convertMeasureToCore( mnRX, rValue); - return; - } - if( IsXMLToken( rLocalName, XML_RY ) ) - { + break; + case XML_ELEMENT(SVG, XML_RY): + case XML_ELEMENT(SVG_COMPAT, XML_RY): GetImport().GetMM100UnitConverter().convertMeasureToCore( mnRY, rValue); - return; - } - if( IsXMLToken( rLocalName, XML_CX ) ) - { + break; + case XML_ELEMENT(SVG, XML_CX): + case XML_ELEMENT(SVG_COMPAT, XML_CX): GetImport().GetMM100UnitConverter().convertMeasureToCore( mnCX, rValue); - return; - } - if( IsXMLToken( rLocalName, XML_CY ) ) - { + break; + case XML_ELEMENT(SVG, XML_CY): + case XML_ELEMENT(SVG_COMPAT, XML_CY): GetImport().GetMM100UnitConverter().convertMeasureToCore( mnCY, rValue); - return; - } - if( IsXMLToken( rLocalName, XML_R ) ) - { + break; + case XML_ELEMENT(SVG, XML_R): + case XML_ELEMENT(SVG_COMPAT, XML_R): // single radius, it's a circle and both radii are the same GetImport().GetMM100UnitConverter().convertMeasureToCore( mnRX, rValue); mnRY = mnRX; - return; - } - } - else if( XML_NAMESPACE_DRAW == nPrefix ) - { - if( IsXMLToken( rLocalName, XML_KIND ) ) - { + break; + case XML_ELEMENT(DRAW, XML_KIND): SvXMLUnitConverter::convertEnum( meKind, rValue, aXML_CircleKind_EnumMap ); - return; - } - if( IsXMLToken( rLocalName, XML_START_ANGLE ) ) + break; + case XML_ELEMENT(DRAW, XML_START_ANGLE): { double dStartAngle; if (::sax::Converter::convertDouble( dStartAngle, rValue )) mnStartAngle = static_cast<sal_Int32>(dStartAngle * 100.0); - return; + break; } - if( IsXMLToken( rLocalName, XML_END_ANGLE ) ) + case XML_ELEMENT(DRAW, XML_END_ANGLE): { double dEndAngle; if (::sax::Converter::convertDouble( dEndAngle, rValue )) mnEndAngle = static_cast<sal_Int32>(dEndAngle * 100.0); - return; + break; } + default: + return SdXMLShapeContext::processAttribute( nElement, rValue ); } - - SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); + return true; } void SdXMLEllipseShapeContext::startFastElement (sal_Int32 nElement, @@ -1242,7 +1195,7 @@ void SdXMLEllipseShapeContext::startFastElement (sal_Int32 nElement, SdXMLPolygonShapeContext::SdXMLPolygonShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes, bool bClosed, bool bTemporaryShape) : SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ), mbClosed( bClosed ) @@ -1250,26 +1203,21 @@ SdXMLPolygonShapeContext::SdXMLPolygonShapeContext( } // this is called from the parent group for each unparsed attribute in the attribute list -void SdXMLPolygonShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) +bool SdXMLPolygonShapeContext::processAttribute( sal_Int32 nElement, const OUString& rValue ) { - if( XML_NAMESPACE_SVG == nPrefix ) + switch (nElement) { - if( IsXMLToken( rLocalName, XML_VIEWBOX ) ) - { + case XML_ELEMENT(SVG, XML_VIEWBOX): + case XML_ELEMENT(SVG_COMPAT, XML_VIEWBOX): maViewBox = rValue; - return; - } - } - else if( XML_NAMESPACE_DRAW == nPrefix ) - { - if( IsXMLToken( rLocalName, XML_POINTS ) ) - { + break; + case XML_ELEMENT(DRAW, XML_POINTS): maPoints = rValue; - return; - } + break; + default: + return SdXMLShapeContext::processAttribute( nElement, rValue ); } - - SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); + return true; } SdXMLPolygonShapeContext::~SdXMLPolygonShapeContext() @@ -1350,7 +1298,7 @@ void SdXMLPolygonShapeContext::startFastElement (sal_Int32 nElement, SdXMLPathShapeContext::SdXMLPathShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes, bool bTemporaryShape) : SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ) @@ -1362,23 +1310,22 @@ SdXMLPathShapeContext::~SdXMLPathShapeContext() } // this is called from the parent group for each unparsed attribute in the attribute list -void SdXMLPathShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) +bool SdXMLPathShapeContext::processAttribute( sal_Int32 nElement, const OUString& rValue ) { - if( XML_NAMESPACE_SVG == nPrefix ) + switch (nElement) { - if( IsXMLToken( rLocalName, XML_VIEWBOX ) ) - { + case XML_ELEMENT(SVG, XML_VIEWBOX): + case XML_ELEMENT(SVG_COMPAT, XML_VIEWBOX): maViewBox = rValue; - return; - } - else if( IsXMLToken( rLocalName, XML_D ) ) - { + break; + case XML_ELEMENT(SVG, XML_D): + case XML_ELEMENT(SVG_COMPAT, XML_D): maD = rValue; - return; - } + break; + default: + return SdXMLShapeContext::processAttribute( nElement, rValue ); } - - SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); + return true; } void SdXMLPathShapeContext::startFastElement (sal_Int32 nElement, @@ -1502,7 +1449,7 @@ void SdXMLPathShapeContext::startFastElement (sal_Int32 nElement, SdXMLTextBoxShapeContext::SdXMLTextBoxShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes) : SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ ), mnRadius(0), @@ -1515,26 +1462,21 @@ SdXMLTextBoxShapeContext::~SdXMLTextBoxShapeContext() } // this is called from the parent group for each unparsed attribute in the attribute list -void SdXMLTextBoxShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) +bool SdXMLTextBoxShapeContext::processAttribute( sal_Int32 nElement, const OUString& rValue ) { - if( XML_NAMESPACE_DRAW == nPrefix ) + switch (nElement) { - if( IsXMLToken( rLocalName, XML_CORNER_RADIUS ) ) - { + case XML_ELEMENT(DRAW, XML_CORNER_RADIUS): GetImport().GetMM100UnitConverter().convertMeasureToCore( mnRadius, rValue); - return; - } - - if( IsXMLToken( rLocalName, XML_CHAIN_NEXT_NAME ) ) - { + break; + case XML_ELEMENT(DRAW, XML_CHAIN_NEXT_NAME): maChainNextName = rValue; - return; - } - + break; + default: + return SdXMLShapeContext::processAttribute( nElement, rValue ); } - - SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); + return true; } void SdXMLTextBoxShapeContext::startFastElement (sal_Int32 nElement, @@ -1689,7 +1631,7 @@ void SdXMLTextBoxShapeContext::startFastElement (sal_Int32 nElement, SdXMLControlShapeContext::SdXMLControlShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes, bool bTemporaryShape) : SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ) @@ -1701,18 +1643,17 @@ SdXMLControlShapeContext::~SdXMLControlShapeContext() } // this is called from the parent group for each unparsed attribute in the attribute list -void SdXMLControlShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) +bool SdXMLControlShapeContext::processAttribute( sal_Int32 nElement, const OUString& rValue ) { - if( XML_NAMESPACE_DRAW == nPrefix ) + switch (nElement) { - if( IsXMLToken( rLocalName, XML_CONTROL ) ) - { + case XML_ELEMENT(DRAW, XML_CONTROL): maFormId = rValue; - return; - } + break; + default: + return SdXMLShapeContext::processAttribute( nElement, rValue ); } - - SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); + return true; } void SdXMLControlShapeContext::startFastElement (sal_Int32 nElement, @@ -1752,7 +1693,7 @@ void SdXMLControlShapeContext::startFastElement (sal_Int32 nElement, SdXMLConnectorShapeContext::SdXMLConnectorShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes, bool bTemporaryShape) : SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ), @@ -1790,33 +1731,23 @@ bool SvXMLImport::needFixPositionAfterZ() const // this is called from the parent group for each unparsed attribute in the attribute list -void SdXMLConnectorShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) +bool SdXMLConnectorShapeContext::processAttribute( sal_Int32 nElement, const OUString& rValue ) { - switch( nPrefix ) + switch( nElement ) { - case XML_NAMESPACE_DRAW: - { - if( IsXMLToken( rLocalName, XML_START_SHAPE ) ) - { + case XML_ELEMENT(DRAW, XML_START_SHAPE): maStartShapeId = rValue; - return; - } - if( IsXMLToken( rLocalName, XML_START_GLUE_POINT ) ) - { + break; + case XML_ELEMENT(DRAW, XML_START_GLUE_POINT): mnStartGlueId = rValue.toInt32(); - return; - } - if( IsXMLToken( rLocalName, XML_END_SHAPE ) ) - { + break; + case XML_ELEMENT(DRAW, XML_END_SHAPE): maEndShapeId = rValue; - return; - } - if( IsXMLToken( rLocalName, XML_END_GLUE_POINT ) ) - { + break; + case XML_ELEMENT(DRAW, XML_END_GLUE_POINT): mnEndGlueId = rValue.toInt32(); - return; - } - if( IsXMLToken( rLocalName, XML_LINE_SKEW ) ) + break; + case XML_ELEMENT(DRAW, XML_LINE_SKEW): { SvXMLTokenEnumerator aTokenEnum( rValue ); OUString aToken; @@ -1835,48 +1766,40 @@ void SdXMLConnectorShapeContext::processAttribute( sal_uInt16 nPrefix, const OUS } } } - return; + break; } - if( IsXMLToken( rLocalName, XML_TYPE ) ) + case XML_ELEMENT(DRAW, XML_TYPE): { (void)SvXMLUnitConverter::convertEnum( mnType, rValue, aXML_ConnectionKind_EnumMap ); - return; + break; } // #121965# draw:transform may be used in ODF1.2, e.g. exports from MS seem to use these - else if( IsXMLToken( rLocalName, XML_TRANSFORM ) ) - { + case XML_ELEMENT(DRAW, XML_TRANSFORM): mnTransform.SetString(rValue, GetImport().GetMM100UnitConverter()); - } - } - break; + break; - case XML_NAMESPACE_SVG: - { - if( IsXMLToken( rLocalName, XML_X1 ) ) - { + case XML_ELEMENT(SVG, XML_X1): + case XML_ELEMENT(SVG_COMPAT, XML_X1): GetImport().GetMM100UnitConverter().convertMeasureToCore( maStart.X, rValue); - return; - } - if( IsXMLToken( rLocalName, XML_Y1 ) ) - { + break; + case XML_ELEMENT(SVG, XML_Y1): + case XML_ELEMENT(SVG_COMPAT, XML_Y1): GetImport().GetMM100UnitConverter().convertMeasureToCore( maStart.Y, rValue); - return; - } - if( IsXMLToken( rLocalName, XML_X2 ) ) - { + break; + case XML_ELEMENT(SVG, XML_X2): + case XML_ELEMENT(SVG_COMPAT, XML_X2): GetImport().GetMM100UnitConverter().convertMeasureToCore( maEnd.X, rValue); - return; - } - if( IsXMLToken( rLocalName, XML_Y2 ) ) - { + break; + case XML_ELEMENT(SVG, XML_Y2): + case XML_ELEMENT(SVG_COMPAT, XML_Y2): GetImport().GetMM100UnitConverter().convertMeasureToCore( maEnd.Y, rValue); - return; - } - if( IsXMLToken( rLocalName, XML_D ) ) + break; + case XML_ELEMENT(SVG, XML_D): + case XML_ELEMENT(SVG_COMPAT, XML_D): { basegfx::B2DPolyPolygon aPolyPolygon; @@ -1892,11 +1815,12 @@ void SdXMLConnectorShapeContext::processAttribute( sal_uInt16 nPrefix, const OUS maPath <<= aSourcePolyPolygon; } } + break; } + default: + return SdXMLShapeContext::processAttribute( nElement, rValue ); } - } - - SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); + return true; } void SdXMLConnectorShapeContext::startFastElement (sal_Int32 nElement, @@ -2057,7 +1981,7 @@ void SdXMLConnectorShapeContext::startFastElement (sal_Int32 nElement, SdXMLMeasureShapeContext::SdXMLMeasureShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes, bool bTemporaryShape) : SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ), @@ -2071,40 +1995,42 @@ SdXMLMeasureShapeContext::~SdXMLMeasureShapeContext() } // this is called from the parent group for each unparsed attribute in the attribute list -void SdXMLMeasureShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) +bool SdXMLMeasureShapeContext::processAttribute( sal_Int32 nElement, const OUString& rValue ) { - switch( nPrefix ) - { - case XML_NAMESPACE_SVG: + switch( nElement ) { - if( IsXMLToken( rLocalName, XML_X1 ) ) + case XML_ELEMENT(SVG, XML_X1): + case XML_ELEMENT(SVG_COMPAT, XML_X1): { GetImport().GetMM100UnitConverter().convertMeasureToCore( maStart.X, rValue); - return; + break; } - if( IsXMLToken( rLocalName, XML_Y1 ) ) + case XML_ELEMENT(SVG, XML_Y1): + case XML_ELEMENT(SVG_COMPAT, XML_Y1): { GetImport().GetMM100UnitConverter().convertMeasureToCore( maStart.Y, rValue); - return; + break; } - if( IsXMLToken( rLocalName, XML_X2 ) ) + case XML_ELEMENT(SVG, XML_X2): + case XML_ELEMENT(SVG_COMPAT, XML_X2): { GetImport().GetMM100UnitConverter().convertMeasureToCore( maEnd.X, rValue); - return; + break; } - if( IsXMLToken( rLocalName, XML_Y2 ) ) + case XML_ELEMENT(SVG, XML_Y2): + case XML_ELEMENT(SVG_COMPAT, XML_Y2): { GetImport().GetMM100UnitConverter().convertMeasureToCore( maEnd.Y, rValue); - return; + break; } + default: + return SdXMLShapeContext::processAttribute( nElement, rValue ); } - } - - SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); + return true; } void SdXMLMeasureShapeContext::startFastElement (sal_Int32 nElement, @@ -2161,7 +2087,7 @@ void SdXMLMeasureShapeContext::endFastElement(sal_Int32 nElement) SdXMLPageShapeContext::SdXMLPageShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes, bool bTemporaryShape) : SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ), mnPageNumber(0) @@ -2174,18 +2100,13 @@ SdXMLPageShapeContext::~SdXMLPageShapeContext() } // this is called from the parent group for each unparsed attribute in the attribute list -void SdXMLPageShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) +bool SdXMLPageShapeContext::processAttribute( sal_Int32 nElement, const OUString& rValue ) { - if( XML_NAMESPACE_DRAW == nPrefix ) - { - if( IsXMLToken( rLocalName, XML_PAGE_NUMBER ) ) - { - mnPageNumber = rValue.toInt32(); - return; - } - } - - SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); + if( nElement == XML_ELEMENT(DRAW, XML_PAGE_NUMBER) ) + mnPageNumber = rValue.toInt32(); + else + return SdXMLShapeContext::processAttribute( nElement, rValue ); + return true; } void SdXMLPageShapeContext::startFastElement (sal_Int32 nElement, @@ -2247,7 +2168,7 @@ void SdXMLPageShapeContext::startFastElement (sal_Int32 nElement, SdXMLCaptionShapeContext::SdXMLCaptionShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes, bool bTemporaryShape) : SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ), @@ -2317,36 +2238,32 @@ void SdXMLCaptionShapeContext::startFastElement (sal_Int32 nElement, } // this is called from the parent group for each unparsed attribute in the attribute list -void SdXMLCaptionShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) +bool SdXMLCaptionShapeContext::processAttribute( sal_Int32 nElement, const OUString& rValue ) { - if( XML_NAMESPACE_DRAW == nPrefix ) + switch (nElement) { - if( IsXMLToken( rLocalName, XML_CAPTION_POINT_X ) ) - { + case XML_ELEMENT(DRAW, XML_CAPTION_POINT_X): GetImport().GetMM100UnitConverter().convertMeasureToCore( maCaptionPoint.X, rValue); - return; - } - if( IsXMLToken( rLocalName, XML_CAPTION_POINT_Y ) ) - { + break; + case XML_ELEMENT(DRAW, XML_CAPTION_POINT_Y): GetImport().GetMM100UnitConverter().convertMeasureToCore( maCaptionPoint.Y, rValue); - return; - } - if( IsXMLToken( rLocalName, XML_CORNER_RADIUS ) ) - { + break; + case XML_ELEMENT(DRAW, XML_CORNER_RADIUS): GetImport().GetMM100UnitConverter().convertMeasureToCore( mnRadius, rValue); - return; - } + break; + default: + return SdXMLShapeContext::processAttribute( nElement, rValue ); } - SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); + return true; } SdXMLGraphicObjectShapeContext::SdXMLGraphicObjectShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes) : SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ ), maURL() @@ -2354,18 +2271,13 @@ SdXMLGraphicObjectShapeContext::SdXMLGraphicObjectShapeContext( } // this is called from the parent group for each unparsed attribute in the attribute list -void SdXMLGraphicObjectShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) +bool SdXMLGraphicObjectShapeContext::processAttribute( sal_Int32 nElement, const OUString& rValue ) { - if( XML_NAMESPACE_XLINK == nPrefix ) - { - if( IsXMLToken( rLocalName, XML_HREF ) ) - { - maURL = rValue; - return; - } - } - - SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); + if( nElement == XML_ELEMENT(XLINK, XML_HREF) ) + maURL = rValue; + else + return SdXMLShapeContext::processAttribute( nElement, rValue ); + return true; } void SdXMLGraphicObjectShapeContext::startFastElement (sal_Int32 nElement, @@ -2461,30 +2373,31 @@ void SdXMLGraphicObjectShapeContext::endFastElement(sal_Int32 nElement) SdXMLShapeContext::endFastElement(nElement); } -SvXMLImportContextRef SdXMLGraphicObjectShapeContext::CreateChildContext( - sal_uInt16 nPrefix, const OUString& rLocalName, - const uno::Reference<xml::sax::XAttributeList>& xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLGraphicObjectShapeContext::createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { - SvXMLImportContextRef xContext; + css::uno::Reference< css::xml::sax::XFastContextHandler > xContext; - if( (XML_NAMESPACE_OFFICE == nPrefix) && - xmloff::token::IsXMLToken( rLocalName, xmloff::token::XML_BINARY_DATA ) ) + if( nElement == XML_ELEMENT(OFFICE, XML_BINARY_DATA) ) { if( maURL.isEmpty() && !mxBase64Stream.is() ) { mxBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64(); if( mxBase64Stream.is() ) - xContext = new XMLBase64ImportContext( GetImport(), nPrefix, - rLocalName, xAttrList, + xContext = new XMLBase64ImportContext( GetImport(), mxBase64Stream ); } } // delegate to parent class if no context could be created if (!xContext) - xContext = SdXMLShapeContext::CreateChildContext(nPrefix, rLocalName, + xContext = SdXMLShapeContext::createFastChildContext(nElement, xAttrList); + if (!xContext) + XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); + return xContext; } @@ -2496,7 +2409,7 @@ SdXMLGraphicObjectShapeContext::~SdXMLGraphicObjectShapeContext() SdXMLChartShapeContext::SdXMLChartShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes, bool bTemporaryShape) : SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ) @@ -2583,14 +2496,14 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLChartShapeContext const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { if( mxChartContext.is() ) - return mxChartContext->createFastChildContextFallback( nElement, xAttrList ); + return mxChartContext->createFastChildContext( nElement, xAttrList ); return nullptr; } SdXMLObjectShapeContext::SdXMLObjectShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes) : SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ ) { @@ -2732,27 +2645,20 @@ void SdXMLObjectShapeContext::endFastElement(sal_Int32 nElement) } // this is called from the parent group for each unparsed attribute in the attribute list -void SdXMLObjectShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) +bool SdXMLObjectShapeContext::processAttribute( sal_Int32 nElement, const OUString& rValue ) { - switch( nPrefix ) + switch( nElement ) { - case XML_NAMESPACE_DRAW: - if( IsXMLToken( rLocalName, XML_CLASS_ID ) ) - { + case XML_ELEMENT(DRAW, XML_CLASS_ID): maCLSID = rValue; - return; - } - break; - case XML_NAMESPACE_XLINK: - if( IsXMLToken( rLocalName, XML_HREF ) ) - { + break; + case XML_ELEMENT(XLINK, XML_HREF): maHref = rValue; - return; - } - break; + break; + default: + return SdXMLShapeContext::processAttribute( nElement, rValue ); } - - SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); + return true; } css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLObjectShapeContext::createFastChildContext( @@ -2786,24 +2692,13 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLObjectShapeContex } return xEContext.get(); } - return nullptr; -} - -SvXMLImportContextRef SdXMLObjectShapeContext::CreateChildContext( - sal_uInt16 nPrefix, const OUString& rLocalName, - const uno::Reference<xml::sax::XAttributeList>& xAttrList ) -{ - SvXMLImportContextRef xContext; // delegate to parent class if no context could be created - if (!xContext) - xContext = SdXMLShapeContext::CreateChildContext(nPrefix, rLocalName, xAttrList); - - return xContext; + return SdXMLShapeContext::createFastChildContext(nElement, xAttrList); } SdXMLAppletShapeContext::SdXMLAppletShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes) : SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ ), mbIsScript( false ) @@ -2830,37 +2725,26 @@ void SdXMLAppletShapeContext::startFastElement (sal_Int32 /*nElement*/, } // this is called from the parent group for each unparsed attribute in the attribute list -void SdXMLAppletShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) +bool SdXMLAppletShapeContext::processAttribute( sal_Int32 nElement, const OUString& rValue ) { - switch( nPrefix ) + switch( nElement ) { - case XML_NAMESPACE_DRAW: - if( IsXMLToken( rLocalName, XML_APPLET_NAME ) ) - { + case XML_ELEMENT(DRAW, XML_APPLET_NAME): maAppletName = rValue; - return; - } - if( IsXMLToken( rLocalName, XML_CODE ) ) - { + break; + case XML_ELEMENT(DRAW, XML_CODE): maAppletCode = rValue; - return; - } - if( IsXMLToken( rLocalName, XML_MAY_SCRIPT ) ) - { + break; + case XML_ELEMENT(DRAW, XML_MAY_SCRIPT): mbIsScript = IsXMLToken( rValue, XML_TRUE ); - return; - } - break; - case XML_NAMESPACE_XLINK: - if( IsXMLToken( rLocalName, XML_HREF ) ) - { + break; + case XML_ELEMENT(XLINK, XML_HREF): maHref = GetImport().GetAbsoluteReference(rValue); - return; - } - break; + break; + default: + return SdXMLShapeContext::processAttribute( nElement, rValue ); } - - SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); + return true; } void SdXMLAppletShapeContext::endFastElement(sal_Int32 nElement) @@ -2909,31 +2793,20 @@ void SdXMLAppletShapeContext::endFastElement(sal_Int32 nElement) SdXMLShapeContext::endFastElement(nElement); } -SvXMLImportContextRef SdXMLAppletShapeContext::CreateChildContext( sal_uInt16 p_nPrefix, const OUString& rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLAppletShapeContext::createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { - if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_PARAM ) ) + if( nElement == XML_ELEMENT(DRAW, XML_PARAM) ) { OUString aParamName, aParamValue; - const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; // now parse the attribute list and look for draw:name and draw:value - for(sal_Int16 a(0); a < nAttrCount; a++) + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { - const OUString& rAttrName = xAttrList->getNameByIndex(a); - OUString aLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName); - const OUString aValue( xAttrList->getValueByIndex(a) ); - - if( nPrefix == XML_NAMESPACE_DRAW ) - { - if( IsXMLToken( aLocalName, XML_NAME ) ) - { - aParamName = aValue; - } - else if( IsXMLToken( aLocalName, XML_VALUE ) ) - { - aParamValue = aValue; - } - } + if( aIter.getToken() == XML_ELEMENT(DRAW, XML_NAME) ) + aParamName = aIter.toString(); + if( aIter.getToken() == XML_ELEMENT(DRAW, XML_VALUE) ) + aParamValue = aIter.toString(); } if( !aParamName.isEmpty() ) @@ -2946,15 +2819,15 @@ SvXMLImportContextRef SdXMLAppletShapeContext::CreateChildContext( sal_uInt16 p_ maParams[nIndex].State = beans::PropertyState_DIRECT_VALUE; } - return new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); + return new SvXMLImportContext( GetImport() ); } - return SdXMLShapeContext::CreateChildContext( p_nPrefix, rLocalName, xAttrList ); + return SdXMLShapeContext::createFastChildContext( nElement, xAttrList ); } SdXMLPluginShapeContext::SdXMLPluginShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes) : SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ ), mbMedia( false ) @@ -3044,27 +2917,20 @@ lcl_GetMediaReference(SvXMLImport const& rImport, OUString const& rURL) } // this is called from the parent group for each unparsed attribute in the attribute list -void SdXMLPluginShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) +bool SdXMLPluginShapeContext::processAttribute( sal_Int32 nElement, const OUString& rValue ) { - switch( nPrefix ) + switch( nElement ) { - case XML_NAMESPACE_DRAW: - if( IsXMLToken( rLocalName, XML_MIME_TYPE ) ) - { + case XML_ELEMENT(DRAW, XML_MIME_TYPE): maMimeType = rValue; - return; - } - break; - case XML_NAMESPACE_XLINK: - if( IsXMLToken( rLocalName, XML_HREF ) ) - { + break; + case XML_ELEMENT(XLINK, XML_HREF): maHref = lcl_GetMediaReference(GetImport(), rValue); - return; - } - break; + break; + default: + return SdXMLShapeContext::processAttribute( nElement, rValue ); } - - SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); + return true; } void SdXMLPluginShapeContext::endFastElement(sal_Int32 nElement) @@ -3172,52 +3038,41 @@ void SdXMLPluginShapeContext::endFastElement(sal_Int32 nElement) SdXMLShapeContext::endFastElement(nElement); } -SvXMLImportContextRef SdXMLPluginShapeContext::CreateChildContext( sal_uInt16 p_nPrefix, const OUString& rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLPluginShapeContext::createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { - if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_PARAM ) ) + if( nElement == XML_ELEMENT(DRAW, XML_PARAM) ) { OUString aParamName, aParamValue; - const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; // now parse the attribute list and look for draw:name and draw:value - for(sal_Int16 a(0); a < nAttrCount; a++) + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { - const OUString& rAttrName = xAttrList->getNameByIndex(a); - OUString aLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName); - const OUString aValue( xAttrList->getValueByIndex(a) ); - - if( nPrefix == XML_NAMESPACE_DRAW ) - { - if( IsXMLToken( aLocalName, XML_NAME ) ) - { - aParamName = aValue; - } - else if( IsXMLToken( aLocalName, XML_VALUE ) ) - { - aParamValue = aValue; - } - } + if( aIter.getToken() == XML_ELEMENT(DRAW, XML_NAME) ) + aParamName = aIter.toString(); + else if( aIter.getToken() == XML_ELEMENT(DRAW, XML_VALUE) ) + aParamValue = aIter.toString(); + } - if( !aParamName.isEmpty() ) - { - sal_Int32 nIndex = maParams.getLength(); - maParams.realloc( nIndex + 1 ); - maParams[nIndex].Name = aParamName; - maParams[nIndex].Handle = -1; - maParams[nIndex].Value <<= aParamValue; - maParams[nIndex].State = beans::PropertyState_DIRECT_VALUE; - } + if( !aParamName.isEmpty() ) + { + sal_Int32 nIndex = maParams.getLength(); + maParams.realloc( nIndex + 1 ); + maParams[nIndex].Name = aParamName; + maParams[nIndex].Handle = -1; + maParams[nIndex].Value <<= aParamValue; + maParams[nIndex].State = beans::PropertyState_DIRECT_VALUE; } - return new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); + return new SvXMLImportContext( GetImport() ); } - return SdXMLShapeContext::CreateChildContext( p_nPrefix, rLocalName, xAttrList ); + return SdXMLShapeContext::createFastChildContext( nElement, xAttrList ); } SdXMLFloatingFrameShapeContext::SdXMLFloatingFrameShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes) : SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ ) { @@ -3260,27 +3115,20 @@ void SdXMLFloatingFrameShapeContext::startFastElement (sal_Int32 /*nElement*/, } // this is called from the parent group for each unparsed attribute in the attribute list -void SdXMLFloatingFrameShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) +bool SdXMLFloatingFrameShapeContext::processAttribute( sal_Int32 nElement, const OUString& rValue ) { - switch( nPrefix ) + switch( nElement ) { - case XML_NAMESPACE_DRAW: - if( IsXMLToken( rLocalName, XML_FRAME_NAME ) ) - { + case XML_ELEMENT(DRAW, XML_FRAME_NAME): maFrameName = rValue; - return; - } - break; - case XML_NAMESPACE_XLINK: - if( IsXMLToken( rLocalName, XML_HREF ) ) - { + break; + case XML_ELEMENT(XLINK, XML_HREF): maHref = GetImport().GetAbsoluteReference(rValue); - return; - } - break; + break; + default: + return SdXMLShapeContext::processAttribute( nElement, rValue ); } - - SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); + return true; } void SdXMLFloatingFrameShapeContext::endFastElement(sal_Int32 nElement) @@ -3303,7 +3151,7 @@ void SdXMLFloatingFrameShapeContext::endFastElement(sal_Int32 nElement) SdXMLFrameShapeContext::SdXMLFrameShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes, bool bTemporaryShape) : SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ), @@ -3316,8 +3164,7 @@ SdXMLFrameShapeContext::SdXMLFrameShapeContext( SvXMLImport& rImport, if( xClone.is() ) mxAttrList.set( xClone->createClone(), uno::UNO_QUERY ); else - mxAttrList = new SvXMLAttributeList( xAttrList ); - + mxAttrList = new sax_fastparser::FastAttributeList(xAttrList); } SdXMLFrameShapeContext::~SdXMLFrameShapeContext() @@ -3411,16 +3258,15 @@ OUString SdXMLFrameShapeContext::getGraphicPackageURLFromImportContext(const SvX return aRetval; } -SvXMLImportContextRef SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList>& xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLFrameShapeContext::createFastChildContext( + sal_Int32 nElement, + const uno::Reference< xml::sax::XFastAttributeList>& xAttrList ) { SvXMLImportContextRef xContext; - if( !mxImplContext.is() ) { - SvXMLShapeContext* pShapeContext= GetImport().GetShapeImport()->CreateFrameChildContext( - GetImport(), nPrefix, rLocalName, xAttrList, mxShapes, mxAttrList ); + SvXMLShapeContext* pShapeContext = XMLShapeImportHelper::CreateFrameChildContext( + GetImport(), nElement, xAttrList, mxShapes, mxAttrList ); xContext = pShapeContext; @@ -3428,20 +3274,21 @@ SvXMLImportContextRef SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPr if ( !msHyperlink.isEmpty() ) pShapeContext->setHyperlink( msHyperlink ); + auto nToken = nElement & TOKEN_MASK; // Ignore gltf model if necessary and so the fallback image will be imported - if( IsXMLToken(rLocalName, XML_PLUGIN ) ) + if( nToken == XML_PLUGIN ) { SdXMLPluginShapeContext* pPluginContext = dynamic_cast<SdXMLPluginShapeContext*>(pShapeContext); if( pPluginContext && pPluginContext->getMimeType() == "model/vnd.gltf+json" ) { mxImplContext = nullptr; - return new SvXMLImportContext(GetImport(), nPrefix, rLocalName); + return new SvXMLImportContext(GetImport()); } } mxImplContext = xContext; - mbSupportsReplacement = IsXMLToken(rLocalName, XML_OBJECT ) || IsXMLToken(rLocalName, XML_OBJECT_OLE); - setSupportsMultipleContents(IsXMLToken(rLocalName, XML_IMAGE)); + mbSupportsReplacement = (nToken == XML_OBJECT ) || (nToken == XML_OBJECT_OLE); + setSupportsMultipleContents(nToken == XML_IMAGE); if(getSupportsMultipleContents() && dynamic_cast< SdXMLGraphicObjectShapeContext* >(xContext.get())) { @@ -3451,11 +3298,11 @@ SvXMLImportContextRef SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPr addContent(*mxImplContext); } } - else if(getSupportsMultipleContents() && XML_NAMESPACE_DRAW == nPrefix && IsXMLToken(rLocalName, XML_IMAGE)) + else if(getSupportsMultipleContents() && nElement == XML_ELEMENT(DRAW, XML_IMAGE)) { // read another image - xContext = GetImport().GetShapeImport()->CreateFrameChildContext( - GetImport(), nPrefix, rLocalName, xAttrList, mxShapes, mxAttrList); + xContext = XMLShapeImportHelper::CreateFrameChildContext( + GetImport(), nElement, xAttrList, mxShapes, mxAttrList); mxImplContext = xContext; if(dynamic_cast< SdXMLGraphicObjectShapeContext* >(xContext.get())) @@ -3464,8 +3311,7 @@ SvXMLImportContextRef SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPr } } else if( mbSupportsReplacement && !mxReplImplContext.is() && - XML_NAMESPACE_DRAW == nPrefix && - IsXMLToken( rLocalName, XML_IMAGE ) ) + nElement == XML_ELEMENT(DRAW, XML_IMAGE) ) { // read replacement image SvXMLImportContext *pImplContext = mxImplContext.get(); @@ -3478,17 +3324,18 @@ SvXMLImportContextRef SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPr if( xPropSet.is() ) { xContext = new XMLReplacementImageContext( GetImport(), - nPrefix, rLocalName, xAttrList, xPropSet ); + nElement, xAttrList, xPropSet ); mxReplImplContext = xContext; } } } - else if( - ( nPrefix == XML_NAMESPACE_SVG && // #i68101# - (IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) ) || - (nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) ) || - (nPrefix == XML_NAMESPACE_DRAW && (IsXMLToken( rLocalName, XML_GLUE_POINT ) || - IsXMLToken( rLocalName, XML_THUMBNAIL ) ) ) ) + else if( nElement == XML_ELEMENT(SVG, XML_TITLE) || // #i68101# + nElement == XML_ELEMENT(SVG_COMPAT, XML_TITLE) || + nElement == XML_ELEMENT(SVG, XML_DESC) || + nElement == XML_ELEMENT(SVG_COMPAT, XML_DESC) || + nElement == XML_ELEMENT(OFFICE, XML_EVENT_LISTENERS) || + nElement == XML_ELEMENT(DRAW, XML_GLUE_POINT) || + nElement == XML_ELEMENT(DRAW, XML_THUMBNAIL) ) { if (getSupportsMultipleContents()) { // tdf#103567 ensure props are set on surviving shape @@ -3496,10 +3343,10 @@ SvXMLImportContextRef SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPr mxImplContext = solveMultipleImages(); } SvXMLImportContext *pImplContext = mxImplContext.get(); - xContext = dynamic_cast<SdXMLShapeContext&>(*pImplContext).CreateChildContext( nPrefix, - rLocalName, xAttrList ); + xContext = static_cast<SvXMLImportContext*>(dynamic_cast<SdXMLShapeContext&>(*pImplContext).createFastChildContext( nElement, + xAttrList ).get()); } - else if ( (XML_NAMESPACE_DRAW == nPrefix) && IsXMLToken( rLocalName, XML_IMAGE_MAP ) ) + else if ( nElement == XML_ELEMENT(DRAW, XML_IMAGE_MAP) ) { if (getSupportsMultipleContents()) { // tdf#103567 ensure props are set on surviving shape @@ -3512,11 +3359,11 @@ SvXMLImportContextRef SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPr uno::Reference < beans::XPropertySet > xPropSet( pSContext->getShape(), uno::UNO_QUERY ); if (xPropSet.is()) { - xContext = new XMLImageMapContext(GetImport(), nPrefix, rLocalName, xPropSet); + xContext = new XMLImageMapContext(GetImport(), xPropSet); } } } - else if ((XML_NAMESPACE_LO_EXT == nPrefix) && IsXMLToken(rLocalName, XML_SIGNATURELINE)) + else if ( nElement == XML_ELEMENT(LO_EXT, XML_SIGNATURELINE) ) { SdXMLShapeContext* pSContext = dynamic_cast<SdXMLShapeContext*>(mxImplContext.get()); if (pSContext) @@ -3524,12 +3371,12 @@ SvXMLImportContextRef SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPr uno::Reference<beans::XPropertySet> xPropSet(pSContext->getShape(), uno::UNO_QUERY); if (xPropSet.is()) { - xContext = new SignatureLineContext(GetImport(), nPrefix, rLocalName, xAttrList, + xContext = new SignatureLineContext(GetImport(), nElement, xAttrList, pSContext->getShape()); } } } - else if ((XML_NAMESPACE_LO_EXT == nPrefix) && IsXMLToken(rLocalName, XML_QRCODE)) + else if ( nElement == XML_ELEMENT(LO_EXT, XML_QRCODE)) { SdXMLShapeContext* pSContext = dynamic_cast<SdXMLShapeContext*>(mxImplContext.get()); if (pSContext) @@ -3537,13 +3384,13 @@ SvXMLImportContextRef SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPr uno::Reference<beans::XPropertySet> xPropSet(pSContext->getShape(), uno::UNO_QUERY); if (xPropSet.is()) { - xContext = new QRCodeContext(GetImport(), nPrefix, rLocalName, xAttrList, + xContext = new QRCodeContext(GetImport(), nElement, xAttrList, pSContext->getShape()); } } } - return xContext; + return xContext.get(); } void SdXMLFrameShapeContext::startFastElement (sal_Int32 /*nElement*/, @@ -3568,28 +3415,23 @@ void SdXMLFrameShapeContext::endFastElement(sal_Int32 nElement) if( !mxImplContext.is() ) { // now check if this is an empty presentation object - sal_Int16 nAttrCount = mxAttrList.is() ? mxAttrList->getLength() : 0; - for(sal_Int16 a(0); a < nAttrCount; a++) + for( auto& aIter : sax_fastparser::castToFastAttributeList(mxAttrList) ) { - OUString aLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(mxAttrList->getNameByIndex(a), &aLocalName); - - if( nPrefix == XML_NAMESPACE_PRESENTATION ) + switch (aIter.getToken()) { - if( IsXMLToken( aLocalName, XML_PLACEHOLDER ) ) - { - mbIsPlaceholder = IsXMLToken( mxAttrList->getValueByIndex(a), XML_TRUE ); - } - else if( IsXMLToken( aLocalName, XML_CLASS ) ) - { - maPresentationClass = mxAttrList->getValueByIndex(a); - } + case XML_ELEMENT(PRESENTATION, XML_PLACEHOLDER): + mbIsPlaceholder = IsXMLToken( aIter.toString(), XML_TRUE ); + break; + case XML_ELEMENT(PRESENTATION, XML_CLASS): + maPresentationClass = aIter.toString(); + break; + default:; } } if( (!maPresentationClass.isEmpty()) && mbIsPlaceholder ) { - uno::Reference< xml::sax::XAttributeList> xEmpty; + uno::Reference< xml::sax::XFastAttributeList> xEmpty; enum XMLTokenEnum eToken = XML_TEXT_BOX; @@ -3609,14 +3451,14 @@ void SdXMLFrameShapeContext::endFastElement(sal_Int32 nElement) eToken = XML_OBJECT; } - mxImplContext = GetImport().GetShapeImport()->CreateFrameChildContext( - GetImport(), XML_NAMESPACE_DRAW, GetXMLToken( eToken ), mxAttrList, mxShapes, xEmpty ); + auto x = XML_ELEMENT(DRAW, eToken); + mxImplContext = XMLShapeImportHelper::CreateFrameChildContext( + GetImport(), x, mxAttrList, mxShapes, xEmpty ); if( mxImplContext.is() ) { - auto nElement2 = XML_ELEMENT(DRAW, eToken); - mxImplContext->StartElement( mxAttrList ); - mxImplContext->endFastElement(nElement2); + mxImplContext->startFastElement( x, mxAttrList ); + mxImplContext->endFastElement(x); } } } @@ -3625,45 +3467,40 @@ void SdXMLFrameShapeContext::endFastElement(sal_Int32 nElement) SdXMLShapeContext::endFastElement(nElement); } -void SdXMLFrameShapeContext::processAttribute( sal_uInt16 nPrefix, - const OUString& rLocalName, const OUString& rValue ) +bool SdXMLFrameShapeContext::processAttribute( sal_Int32 nElement, const OUString& rValue ) { bool bId( false ); - switch ( nPrefix ) + switch ( nElement ) { - case XML_NAMESPACE_DRAW : - case XML_NAMESPACE_DRAW_EXT : - bId = IsXMLToken( rLocalName, XML_ID ); - break; - case XML_NAMESPACE_NONE : - case XML_NAMESPACE_XML : - bId = IsXMLToken( rLocalName, XML_ID ); + case XML_ELEMENT(DRAW, XML_ID): + case XML_ELEMENT(DRAW_EXT, XML_ID): + case XML_ELEMENT(NONE, XML_ID): + case XML_ELEMENT(XML, XML_ID) : + bId = true; break; + default:; } if ( bId ) - SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); + return SdXMLShapeContext::processAttribute( nElement, rValue ); + return true; // deliberately ignoring other attributes } SdXMLCustomShapeContext::SdXMLCustomShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes) : SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ ) { // See the XMLTextFrameContext ctor, a frame has Writer content (and not // editeng) if its autostyle has a parent style. Do the same for shapes as well. - 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 = GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName); - if (nPrefix == XML_NAMESPACE_DRAW && IsXMLToken(aLocalName, XML_STYLE_NAME)) + if (aIter.getToken() == XML_ELEMENT(DRAW, XML_STYLE_NAME)) { - OUString aStyleName = xAttrList->getValueByIndex(i); + OUString aStyleName = aIter.toString(); if(!aStyleName.isEmpty()) { rtl::Reference<XMLTextImportHelper> xTxtImport = GetImport().GetTextImport(); @@ -3684,22 +3521,19 @@ SdXMLCustomShapeContext::~SdXMLCustomShapeContext() } // this is called from the parent group for each unparsed attribute in the attribute list -void SdXMLCustomShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) +bool SdXMLCustomShapeContext::processAttribute( sal_Int32 nElement, const OUString& rValue ) { - if( XML_NAMESPACE_DRAW == nPrefix ) + if( nElement == XML_ELEMENT(DRAW, XML_ENGINE) ) { - if( IsXMLToken( rLocalName, XML_ENGINE ) ) - { - maCustomShapeEngine = rValue; - return; - } - if ( IsXMLToken( rLocalName, XML_DATA ) ) - { - maCustomShapeData = rValue; - return; - } + maCustomShapeEngine = rValue; + } + else if (nElement == XML_ELEMENT(DRAW, XML_DATA) ) + { + maCustomShapeData = rValue; } - SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); + else + return SdXMLShapeContext::processAttribute( nElement, rValue ); + return true; } void SdXMLCustomShapeContext::startFastElement (sal_Int32 nElement, @@ -3861,28 +3695,25 @@ void SdXMLCustomShapeContext::endFastElement(sal_Int32 nElement) } } -SvXMLImportContextRef SdXMLCustomShapeContext::CreateChildContext( - sal_uInt16 nPrefix, const OUString& rLocalName, - const uno::Reference<xml::sax::XAttributeList>& xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLCustomShapeContext::createFastChildContext( + sal_Int32 nElement, + const uno::Reference< xml::sax::XFastAttributeList>& xAttrList ) { - SvXMLImportContextRef xContext; - if ( XML_NAMESPACE_DRAW == nPrefix ) + css::uno::Reference< css::xml::sax::XFastContextHandler > xContext; + if ( nElement == XML_ELEMENT(DRAW, XML_ENHANCED_GEOMETRY) ) { - if ( IsXMLToken( rLocalName, XML_ENHANCED_GEOMETRY ) ) - { - uno::Reference< beans::XPropertySet > xPropSet( mxShape,uno::UNO_QUERY ); - if ( xPropSet.is() ) - xContext = new XMLEnhancedCustomShapeContext( GetImport(), mxShape, nPrefix, rLocalName, maCustomShapeGeometry ); - } + uno::Reference< beans::XPropertySet > xPropSet( mxShape,uno::UNO_QUERY ); + if ( xPropSet.is() ) + xContext = new XMLEnhancedCustomShapeContext( GetImport(), mxShape, maCustomShapeGeometry ); } // delegate to parent class if no context could be created if (!xContext) - xContext = SdXMLShapeContext::CreateChildContext( nPrefix, rLocalName, + xContext = SdXMLShapeContext::createFastChildContext( nElement, xAttrList); return xContext; } -SdXMLTableShapeContext::SdXMLTableShapeContext( SvXMLImport& rImport, const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes ) +SdXMLTableShapeContext::SdXMLTableShapeContext( SvXMLImport& rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes ) : SdXMLShapeContext( rImport, xAttrList, rShapes, false ) { } @@ -3990,11 +3821,11 @@ void SdXMLTableShapeContext::endFastElement(sal_Int32 nElement) } // this is called from the parent group for each unparsed attribute in the attribute list -void SdXMLTableShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) +bool SdXMLTableShapeContext::processAttribute( sal_Int32 nElement, const OUString& rValue ) { - if( nPrefix == XML_NAMESPACE_TABLE ) + if( IsTokenInNamespace(nElement, XML_NAMESPACE_TABLE) ) { - if( IsXMLToken( rLocalName, XML_TEMPLATE_NAME ) ) + if( (nElement & TOKEN_MASK) == XML_TEMPLATE_NAME ) { msTemplateStyleName = rValue; } @@ -4004,7 +3835,7 @@ void SdXMLTableShapeContext::processAttribute( sal_uInt16 nPrefix, const OUStrin const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0]; while( pEntry->msApiName && (i < 6) ) { - if( IsXMLToken( rLocalName, pEntry->meXMLName ) ) + if( (nElement & TOKEN_MASK) == pEntry->meXMLName ) { if( IsXMLToken( rValue, XML_TRUE ) ) maTemplateStylesUsed[i] = true; @@ -4015,7 +3846,7 @@ void SdXMLTableShapeContext::processAttribute( sal_uInt16 nPrefix, const OUStrin } } } - SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); + return SdXMLShapeContext::processAttribute( nElement, rValue ); } css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLTableShapeContext::createFastChildContext( @@ -4023,7 +3854,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLTableShapeContext const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { if( mxTableImportContext.is() && IsTokenInNamespace(nElement, XML_NAMESPACE_TABLE) ) - return mxTableImportContext->createFastChildContextFallback(nElement, xAttrList); + return mxTableImportContext->createFastChildContext(nElement, xAttrList); return SdXMLShapeContext::createFastChildContext(nElement, xAttrList); } diff --git a/xmloff/source/draw/ximpshap.hxx b/xmloff/source/draw/ximpshap.hxx index 49d70c5b3c37..6ad30c5a6bd1 100644 --- a/xmloff/source/draw/ximpshap.hxx +++ b/xmloff/source/draw/ximpshap.hxx @@ -48,7 +48,7 @@ protected: css::uno::Reference< css::drawing::XShapes > mxShapes; css::uno::Reference< css::text::XTextCursor > mxCursor; css::uno::Reference< css::text::XTextCursor > mxOldCursor; - css::uno::Reference< css::xml::sax::XAttributeList> mxAttrList; + css::uno::Reference< css::xml::sax::XFastAttributeList> mxAttrList; css::uno::Reference< css::container::XIdentifierContainer > mxGluePoints; css::uno::Reference< css::document::XActionLockable > mxLockable; @@ -92,14 +92,14 @@ protected: using SvXMLImportContext::GetImport; - void addGluePoint( const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ); + void addGluePoint( const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList ); bool isPresentationShape() const; public: SdXMLShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes, bool bTemporaryShape); virtual ~SdXMLShapeContext() override; @@ -108,12 +108,11 @@ public: sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; virtual void SAL_CALL endFastElement(sal_Int32 nElement) 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; // this is called from the parent group for each unparsed attribute in the attribute list - virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ); + virtual bool processAttribute( sal_Int32 nElement, const OUString& rValue ); }; @@ -126,7 +125,7 @@ class SdXMLRectShapeContext : public SdXMLShapeContext public: SdXMLRectShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes, bool bTemporaryShape); virtual ~SdXMLRectShapeContext() override; @@ -135,7 +134,7 @@ public: const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; // this is called from the parent group for each unparsed attribute in the attribute list - virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) override; + virtual bool processAttribute( sal_Int32 nElement, const OUString& rValue ) override; }; // draw:line context @@ -150,7 +149,7 @@ class SdXMLLineShapeContext : public SdXMLShapeContext public: SdXMLLineShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes, bool bTemporaryShape); virtual ~SdXMLLineShapeContext() override; @@ -159,7 +158,7 @@ public: const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; // this is called from the parent group for each unparsed attribute in the attribute list - virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) override; + virtual bool processAttribute( sal_Int32 nElement, const OUString& rValue ) override; }; // draw:ellipse and draw:circle context @@ -177,7 +176,7 @@ class SdXMLEllipseShapeContext : public SdXMLShapeContext public: SdXMLEllipseShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes, bool bTemporaryShape); virtual ~SdXMLEllipseShapeContext() override; @@ -186,7 +185,7 @@ public: const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; // this is called from the parent group for each unparsed attribute in the attribute list - virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) override; + virtual bool processAttribute( sal_Int32 nElement, const OUString& rValue ) override; }; // draw:polyline and draw:polygon context @@ -200,7 +199,7 @@ class SdXMLPolygonShapeContext : public SdXMLShapeContext public: SdXMLPolygonShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes, bool bClosed, bool bTemporaryShape); virtual ~SdXMLPolygonShapeContext() override; virtual void SAL_CALL startFastElement( @@ -208,7 +207,7 @@ public: const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; // this is called from the parent group for each unparsed attribute in the attribute list - virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) override; + virtual bool processAttribute( sal_Int32 nElement, const OUString& rValue ) override; }; // draw:path context @@ -221,7 +220,7 @@ class SdXMLPathShapeContext : public SdXMLShapeContext public: SdXMLPathShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes, bool bTemporaryShape); virtual ~SdXMLPathShapeContext() override; @@ -230,7 +229,7 @@ public: const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; // this is called from the parent group for each unparsed attribute in the attribute list - virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) override; + virtual bool processAttribute( sal_Int32 nElement, const OUString& rValue ) override; }; // draw:text-box context @@ -243,7 +242,7 @@ class SdXMLTextBoxShapeContext : public SdXMLShapeContext public: SdXMLTextBoxShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes); virtual ~SdXMLTextBoxShapeContext() override; virtual void SAL_CALL startFastElement( @@ -251,7 +250,7 @@ public: const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; // this is called from the parent group for each unparsed attribute in the attribute list - virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) override; + virtual bool processAttribute( sal_Int32 nElement, const OUString& rValue ) override; }; // draw:control context @@ -264,7 +263,7 @@ private: public: SdXMLControlShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes, bool bTemporaryShape); virtual ~SdXMLControlShapeContext() override; @@ -273,7 +272,7 @@ public: const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; // this is called from the parent group for each unparsed attribute in the attribute list - virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) override; + virtual bool processAttribute( sal_Int32 nElement, const OUString& rValue ) override; }; // draw:connector context @@ -301,7 +300,7 @@ private: public: SdXMLConnectorShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes, bool bTemporaryShape); virtual ~SdXMLConnectorShapeContext() override; @@ -310,7 +309,7 @@ public: const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; // this is called from the parent group for each unparsed attribute in the attribute list - virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) override; + virtual bool processAttribute( sal_Int32 nElement, const OUString& rValue ) override; }; // draw:measure context @@ -324,7 +323,7 @@ private: public: SdXMLMeasureShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes, bool bTemporaryShape); virtual ~SdXMLMeasureShapeContext() override; @@ -334,7 +333,7 @@ public: virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; // this is called from the parent group for each unparsed attribute in the attribute list - virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) override; + virtual bool processAttribute( sal_Int32 nElement, const OUString& rValue ) override; }; // draw:page context @@ -346,7 +345,7 @@ private: public: SdXMLPageShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes, bool bTemporaryShape); virtual ~SdXMLPageShapeContext() override; @@ -355,7 +354,7 @@ public: const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; // this is called from the parent group for each unparsed attribute in the attribute list - virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) override; + virtual bool processAttribute( sal_Int32 nElement, const OUString& rValue ) override; }; // draw:caption context @@ -369,7 +368,7 @@ private: public: SdXMLCaptionShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes, bool bTemporaryShape); virtual ~SdXMLCaptionShapeContext() override; @@ -378,7 +377,7 @@ public: const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; // this is called from the parent group for each unparsed attribute in the attribute list - virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) override; + virtual bool processAttribute( sal_Int32 nElement, const OUString& rValue ) override; }; // office:image context @@ -392,7 +391,7 @@ private: public: SdXMLGraphicObjectShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes); virtual ~SdXMLGraphicObjectShapeContext() override; @@ -400,11 +399,12 @@ public: sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; virtual void SAL_CALL endFastElement(sal_Int32 nElement) 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 >& xAttrList ) override; // this is called from the parent group for each unparsed attribute in the attribute list - virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) override; + virtual bool processAttribute( sal_Int32 nElement, const OUString& rValue ) override; }; // chart:chart context @@ -416,7 +416,7 @@ class SdXMLChartShapeContext : public SdXMLShapeContext public: SdXMLChartShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes, bool bTemporaryShape); @@ -442,7 +442,7 @@ private: public: SdXMLObjectShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes); virtual ~SdXMLObjectShapeContext() override; @@ -454,11 +454,8 @@ 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; - // this is called from the parent group for each unparsed attribute in the attribute list - virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) override; + virtual bool processAttribute( sal_Int32 nElement, const OUString& rValue ) override; }; // draw:applet @@ -476,7 +473,7 @@ private: public: SdXMLAppletShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes); virtual ~SdXMLAppletShapeContext() override; @@ -484,12 +481,12 @@ public: sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; virtual void SAL_CALL endFastElement(sal_Int32 nElement) 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 >& xAttrList ) override; // this is called from the parent group for each unparsed attribute in the attribute list - virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) override; + virtual bool processAttribute( sal_Int32 nElement, const OUString& rValue ) override; }; // draw:plugin @@ -506,7 +503,7 @@ private: public: SdXMLPluginShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes); virtual ~SdXMLPluginShapeContext() override; @@ -514,12 +511,12 @@ public: sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; virtual void SAL_CALL endFastElement(sal_Int32 nElement) 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 >& xAttrList ) override; // this is called from the parent group for each unparsed attribute in the attribute list - virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) override; + virtual bool processAttribute( sal_Int32 nElement, const OUString& rValue ) override; const OUString& getMimeType() const { return maMimeType; } }; @@ -535,7 +532,7 @@ private: public: SdXMLFloatingFrameShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes); virtual ~SdXMLFloatingFrameShapeContext() override; @@ -545,7 +542,7 @@ public: virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; // this is called from the parent group for each unparsed attribute in the attribute list - virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) override; + virtual bool processAttribute( sal_Int32 nElement, const OUString& rValue ) override; }; // draw:-frame @@ -566,20 +563,20 @@ protected: public: SdXMLFrameShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes, bool bTemporaryShape); virtual ~SdXMLFrameShapeContext() 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 startFastElement( sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; - virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) override; + virtual bool processAttribute( sal_Int32 nElement, const OUString& rValue ) override; }; class SdXMLCustomShapeContext : public SdXMLShapeContext @@ -593,7 +590,7 @@ public: SdXMLCustomShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes); virtual ~SdXMLCustomShapeContext() override; @@ -601,12 +598,11 @@ public: sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; virtual void SAL_CALL endFastElement(sal_Int32 nElement) 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; // this is called from the parent group for each unparsed attribute in the attribute list - virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) override; + virtual bool processAttribute( sal_Int32 nElement, const OUString& rValue ) override; }; // draw:table @@ -616,7 +612,7 @@ class SdXMLTableShapeContext : public SdXMLShapeContext public: SdXMLTableShapeContext( SvXMLImport& rImport, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes ); virtual ~SdXMLTableShapeContext() override; @@ -629,7 +625,7 @@ public: sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override; // this is called from the parent group for each unparsed attribute in the attribute list - virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) override; + virtual bool processAttribute( sal_Int32 nElement, const OUString& rValue ) override; private: SvXMLImportContextRef mxTableImportContext; diff --git a/xmloff/source/table/XMLTableImport.cxx b/xmloff/source/table/XMLTableImport.cxx index 7a54c1478acc..a03fa8445524 100644 --- a/xmloff/source/table/XMLTableImport.cxx +++ b/xmloff/source/table/XMLTableImport.cxx @@ -70,9 +70,7 @@ struct ColumnInfo class XMLProxyContext : public SvXMLImportContext { public: - XMLProxyContext( SvXMLImport& rImport, const SvXMLImportContextRef& xParent, sal_uInt16 nPrfx, const OUString& rLName ); - - virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList ) override; + XMLProxyContext( SvXMLImport& rImport, const SvXMLImportContextRef& xParent ); virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override; @@ -104,14 +102,13 @@ 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 Reference< XAttributeList >& xAttrList ) override; virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; void InitColumns(); - SvXMLImportContextRef ImportColumn( const Reference< XAttributeList >& xAttrList ); - SvXMLImportContext * ImportRow( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList ); + SvXMLImportContextRef ImportColumn( const Reference< XFastAttributeList >& xAttrList ); + SvXMLImportContext * ImportRow( const Reference< XFastAttributeList >& xAttrList ); SvXMLImportContextRef ImportCell( sal_Int32 nElement, const Reference< XFastAttributeList >& xAttrList ); OUString GetDefaultCellStyleName() const; @@ -183,23 +180,16 @@ private: } -XMLProxyContext::XMLProxyContext( SvXMLImport& rImport, const SvXMLImportContextRef& xParent, sal_uInt16 nPrfx, const OUString& rLName ) -: SvXMLImportContext( rImport, nPrfx, rLName ) +XMLProxyContext::XMLProxyContext( SvXMLImport& rImport, const SvXMLImportContextRef& xParent ) +: SvXMLImportContext( rImport ) , mxParent( xParent ) { } -SvXMLImportContextRef XMLProxyContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList ) -{ - if( mxParent.is() ) - return mxParent->CreateChildContext( nPrefix, rLocalName, xAttrList ); - return nullptr; -} - - css::uno::Reference< css::xml::sax::XFastContextHandler > XMLProxyContext::createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > XMLProxyContext::createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& xAttrList ) { if( mxParent.is() ) - return mxParent->createFastChildContextFallback( nElement, xAttrList ); + return mxParent->createFastChildContext( nElement, xAttrList ); return nullptr; } @@ -383,7 +373,7 @@ XMLTableImportContext::XMLTableImportContext( const rtl::Reference< XMLTableImpo { } -SvXMLImportContextRef XMLTableImportContext::ImportColumn( const Reference< XAttributeList >& xAttrList ) +SvXMLImportContextRef XMLTableImportContext::ImportColumn( const Reference< XFastAttributeList >& xAttrList ) { if( mxColumns.is() && (mnCurrentRow == -1) ) try { @@ -392,33 +382,22 @@ SvXMLImportContextRef XMLTableImportContext::ImportColumn( const Reference< XAtt sal_Int32 nRepeated = 1; // read attributes for the table-column - 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 sAttrName( xAttrList->getNameByIndex( i ) ); - const OUString sValue( xAttrList->getValueByIndex( i ) ); - OUString aLocalName; - - sal_uInt16 nPrefix2 = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - if( XML_NAMESPACE_TABLE == nPrefix2 ) + switch (aIter.getToken()) { - if( IsXMLToken( aLocalName, XML_NUMBER_COLUMNS_REPEATED ) ) - { - nRepeated = sValue.toInt32(); - } - else if( IsXMLToken( aLocalName, XML_STYLE_NAME ) ) - { - xInfo->msStyleName = sValue; - } - else if( IsXMLToken( aLocalName, XML_DEFAULT_CELL_STYLE_NAME ) ) - { - xInfo->msDefaultCellStyleName = sValue; - } - } - else if ( (XML_NAMESPACE_XML == nPrefix2) && - IsXMLToken(aLocalName, XML_ID) ) - { -//FIXME: TODO + case XML_ELEMENT(TABLE, XML_NUMBER_COLUMNS_REPEATED): + nRepeated = aIter.toInt32(); + break; + case XML_ELEMENT(TABLE, XML_STYLE_NAME): + xInfo->msStyleName = aIter.toString(); + break; + case XML_ELEMENT(TABLE, XML_DEFAULT_CELL_STYLE_NAME): + xInfo->msDefaultCellStyleName = aIter.toString(); + break; + case XML_ELEMENT(XML, XML_ID): + //FIXME: TODO + break; } } @@ -478,7 +457,7 @@ void XMLTableImportContext::InitColumns() } } -SvXMLImportContext * XMLTableImportContext::ImportRow( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList ) +SvXMLImportContext * XMLTableImportContext::ImportRow( const Reference< XFastAttributeList >& xAttrList ) { if( mxRows.is() ) { @@ -500,30 +479,19 @@ SvXMLImportContext * XMLTableImportContext::ImportRow( sal_uInt16 nPrefix, const OUString sStyleName; // read attributes for the table-row - 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 sAttrName( xAttrList->getNameByIndex( i ) ); - const OUString sValue( xAttrList->getValueByIndex( i ) ); - OUString aLocalName; - - sal_uInt16 nPrefix2 = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - if( nPrefix2 == XML_NAMESPACE_TABLE ) - { - if( IsXMLToken( aLocalName, XML_STYLE_NAME ) ) - { - sStyleName = sValue; - } - else if( IsXMLToken( aLocalName, XML_DEFAULT_CELL_STYLE_NAME ) ) - { - msDefaultCellStyleName = sValue; - } - } - else if ( (XML_NAMESPACE_XML == nPrefix2) && - IsXMLToken(aLocalName, XML_ID) ) + switch(aIter.getToken()) { - (void) sValue; -//FIXME: TODO + case XML_ELEMENT(TABLE, XML_STYLE_NAME): + sStyleName = aIter.toString(); + break; + case XML_ELEMENT(TABLE, XML_DEFAULT_CELL_STYLE_NAME): + msDefaultCellStyleName = aIter.toString(); + break; + case XML_ELEMENT(XML, XML_ID): + //FIXME: TODO + break; } } @@ -545,7 +513,7 @@ SvXMLImportContext * XMLTableImportContext::ImportRow( sal_uInt16 nPrefix, const } SvXMLImportContextRef xThis( this ); - return new XMLProxyContext( GetImport(), xThis, nPrefix, rLocalName ); + return new XMLProxyContext( GetImport(), xThis ); } SvXMLImportContextRef XMLTableImportContext::ImportCell( sal_Int32 nElement, const Reference< XFastAttributeList >& xAttrList ) @@ -585,24 +553,20 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLTableImportContext: sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { - if( nElement == XML_ELEMENT(TABLE, XML_TABLE_CELL) || - nElement == XML_ELEMENT(TABLE, XML_COVERED_TABLE_CELL) ) - return ImportCell( nElement, xAttrList ).get(); - return nullptr; -} - -SvXMLImportContextRef XMLTableImportContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList ) -{ - if( nPrefix == XML_NAMESPACE_TABLE ) + switch (nElement) { - if( IsXMLToken( rLocalName, XML_TABLE_COLUMN ) ) - return ImportColumn( xAttrList ); - else if( IsXMLToken( rLocalName, XML_TABLE_ROW ) ) - return ImportRow( nPrefix, rLocalName, xAttrList ); - else if( IsXMLToken( rLocalName, XML_TABLE_COLUMNS ) || IsXMLToken( rLocalName, XML_TABLE_ROWS ) ) + case XML_ELEMENT(TABLE, XML_TABLE_CELL): + case XML_ELEMENT(TABLE, XML_COVERED_TABLE_CELL): + return ImportCell( nElement, xAttrList ).get(); + case XML_ELEMENT(TABLE, XML_TABLE_COLUMN): + return ImportColumn( xAttrList ).get(); + case XML_ELEMENT(TABLE, XML_TABLE_ROW): + return ImportRow( xAttrList ); + case XML_ELEMENT(TABLE, XML_TABLE_COLUMNS): + case XML_ELEMENT(TABLE, XML_TABLE_ROWS): { SvXMLImportContextRef xThis( this ); - return new XMLProxyContext( GetImport(), xThis, nPrefix, rLocalName ); + return new XMLProxyContext( GetImport(), xThis ); } } SAL_WARN("xmloff", "unknown element"); diff --git a/xmloff/source/text/XMLAutoMarkFileContext.cxx b/xmloff/source/text/XMLAutoMarkFileContext.cxx index f5968308b339..1582465af597 100644 --- a/xmloff/source/text/XMLAutoMarkFileContext.cxx +++ b/xmloff/source/text/XMLAutoMarkFileContext.cxx @@ -41,10 +41,8 @@ using ::xmloff::token::XML_HREF; XMLAutoMarkFileContext::XMLAutoMarkFileContext( - SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName) : - SvXMLImportContext(rImport, nPrefix, rLocalName) + SvXMLImport& rImport) : + SvXMLImportContext(rImport) { } diff --git a/xmloff/source/text/XMLAutoMarkFileContext.hxx b/xmloff/source/text/XMLAutoMarkFileContext.hxx index 0165e04b7122..01f124d15b4a 100644 --- a/xmloff/source/text/XMLAutoMarkFileContext.hxx +++ b/xmloff/source/text/XMLAutoMarkFileContext.hxx @@ -35,9 +35,7 @@ class XMLAutoMarkFileContext : public SvXMLImportContext public: XMLAutoMarkFileContext( - SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLocalName); + SvXMLImport& rImport); virtual ~XMLAutoMarkFileContext() override; diff --git a/xmloff/source/text/XMLCalculationSettingsContext.cxx b/xmloff/source/text/XMLCalculationSettingsContext.cxx index 39702467e894..338080a3b643 100644 --- a/xmloff/source/text/XMLCalculationSettingsContext.cxx +++ b/xmloff/source/text/XMLCalculationSettingsContext.cxx @@ -23,6 +23,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/text/XTextDocument.hpp> +#include <sal/log.hxx> #include <sax/tools/converter.hxx> #include <xmloff/xmlimp.hxx> @@ -37,30 +38,21 @@ using namespace ::com::sun::star::text; using namespace ::xmloff::token; XMLCalculationSettingsContext::XMLCalculationSettingsContext( SvXMLImport& rImport, - sal_uInt16 p_nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) -: SvXMLImportContext ( rImport, p_nPrefix, rLocalName ) + sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) +: SvXMLImportContext ( rImport ) , nYear( 1930 ) { - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for( sal_Int16 i=0; i < nAttrCount; i++ ) + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { - OUString sAttrName = xAttrList->getNameByIndex( i ); - OUString aLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( - sAttrName, &aLocalName ); - OUString sValue = xAttrList->getValueByIndex( i ); - - if (nPrefix == XML_NAMESPACE_TABLE) + if (aIter.getToken() == XML_ELEMENT(TABLE, XML_NULL_YEAR) ) { - if ( IsXMLToken( aLocalName, XML_NULL_YEAR ) ) - { - sal_Int32 nTemp; - ::sax::Converter::convertNumber(nTemp, sValue); - nYear= static_cast <sal_Int16> (nTemp); - } + sal_Int32 nTemp; + ::sax::Converter::convertNumber(nTemp, aIter.toString()); + nYear= static_cast <sal_Int16> (nTemp); } + else + XMLOFF_WARN_UNKNOWN("xmloff", aIter); } } diff --git a/xmloff/source/text/XMLCalculationSettingsContext.hxx b/xmloff/source/text/XMLCalculationSettingsContext.hxx index 0a7cbc879a1a..a6f0e620d2c1 100644 --- a/xmloff/source/text/XMLCalculationSettingsContext.hxx +++ b/xmloff/source/text/XMLCalculationSettingsContext.hxx @@ -27,9 +27,8 @@ class XMLCalculationSettingsContext : public SvXMLImportContext sal_Int16 nYear; public: XMLCalculationSettingsContext( SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ); + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ); virtual ~XMLCalculationSettingsContext() override; virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; diff --git a/xmloff/source/text/XMLChangedRegionImportContext.cxx b/xmloff/source/text/XMLChangedRegionImportContext.cxx index a0f11b97d3ff..400f18a9b44e 100644 --- a/xmloff/source/text/XMLChangedRegionImportContext.cxx +++ b/xmloff/source/text/XMLChangedRegionImportContext.cxx @@ -109,12 +109,9 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLChangedRegionImport else XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); - if (!xContext) - { - // illegal element content! TODO: discard the redlines - // for the moment -> use text - // or default if text fail - } + // illegal element content! TODO: discard the redlines + // for the moment -> use text + // or default if text fail return xContext.get(); } diff --git a/xmloff/source/text/XMLFootnoteImportContext.cxx b/xmloff/source/text/XMLFootnoteImportContext.cxx index a43e27b28c53..451026002afb 100644 --- a/xmloff/source/text/XMLFootnoteImportContext.cxx +++ b/xmloff/source/text/XMLFootnoteImportContext.cxx @@ -20,6 +20,7 @@ #include "XMLFootnoteImportContext.hxx" #include <rtl/ustring.hxx> +#include <sal/log.hxx> #include <xmloff/xmlimp.hxx> #include <xmloff/txtimp.hxx> #include <xmloff/namespacemap.hxx> diff --git a/xmloff/source/text/XMLIndexTOCContext.cxx b/xmloff/source/text/XMLIndexTOCContext.cxx index 829bf0a74c45..4801a81f95f1 100644 --- a/xmloff/source/text/XMLIndexTOCContext.cxx +++ b/xmloff/source/text/XMLIndexTOCContext.cxx @@ -45,6 +45,7 @@ #include <xmloff/xmluconv.hxx> #include <xmloff/xmlement.hxx> #include <rtl/ustring.hxx> +#include <sal/log.hxx> #include <osl/diagnose.h> @@ -95,14 +96,14 @@ SvXMLEnumMapEntry<IndexTypeEnum> const aIndexTypeMap[] = XMLIndexTOCContext::XMLIndexTOCContext(SvXMLImport& rImport, - sal_uInt16 nPrfx, const OUString& rLocalName) - : SvXMLImportContext(rImport, nPrfx, rLocalName) + sal_Int32 nElement) + : SvXMLImportContext(rImport) , eIndexType(TEXT_INDEX_UNKNOWN) , bValid(false) { - if (XML_NAMESPACE_TEXT == nPrfx) + if (IsTokenInNamespace(nElement, XML_NAMESPACE_TEXT)) { - if (SvXMLUnitConverter::convertEnum(eIndexType, rLocalName, aIndexTypeMap)) + if (SvXMLUnitConverter::convertEnum(eIndexType, SvXMLImport::getNameFromToken(nElement), aIndexTypeMap)) { // check for array index: OSL_ENSURE(unsigned(eIndexType) < (SAL_N_ELEMENTS(aIndexServiceMap)), "index out of range"); @@ -119,7 +120,7 @@ XMLIndexTOCContext::~XMLIndexTOCContext() } void XMLIndexTOCContext::startFastElement( - sal_Int32 /*nElement*/, + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { if (!bValid) @@ -206,7 +207,7 @@ void XMLIndexTOCContext::startFastElement( catch(const IllegalArgumentException& e) { // illegal argument? Then we can't accept indices here! - Sequence<OUString> aSeq { GetLocalName() }; + Sequence<OUString> aSeq { SvXMLImport::getNameFromToken(nElement) }; GetImport().SetError( XMLERROR_FLAG_ERROR | XMLERROR_NO_INDEX_ALLOWED_HERE, aSeq, e.Message, nullptr ); diff --git a/xmloff/source/text/XMLIndexTOCContext.hxx b/xmloff/source/text/XMLIndexTOCContext.hxx index b179d35013a9..5319d8e95058 100644 --- a/xmloff/source/text/XMLIndexTOCContext.hxx +++ b/xmloff/source/text/XMLIndexTOCContext.hxx @@ -65,10 +65,7 @@ class XMLIndexTOCContext final : public SvXMLImportContext public: - XMLIndexTOCContext( - SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLocalName ); + XMLIndexTOCContext( SvXMLImport& rImport, sal_Int32 nElement ); virtual ~XMLIndexTOCContext() override; diff --git a/xmloff/source/text/XMLSectionImportContext.cxx b/xmloff/source/text/XMLSectionImportContext.cxx index 4cf133e11225..25da4d0a2eba 100644 --- a/xmloff/source/text/XMLSectionImportContext.cxx +++ b/xmloff/source/text/XMLSectionImportContext.cxx @@ -331,9 +331,13 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLSectionImportContex // section-source (-dde) elements if ( nElement == XML_ELEMENT(TEXT, XML_SECTION_SOURCE) ) { + return new XMLSectionSourceImportContext(GetImport(), + xSectionPropertySet); } else if ( nElement == XML_ELEMENT(OFFICE, XML_DDE_SOURCE) ) { + return new XMLSectionSourceDDEImportContext(GetImport(), + xSectionPropertySet); } else { @@ -348,32 +352,6 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLSectionImportContex XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); return pContext; } - return nullptr; -} - -SvXMLImportContextRef XMLSectionImportContext::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference<XAttributeList> & /*xAttrList*/ ) -{ - SvXMLImportContext* pContext = nullptr; - - // section-source (-dde) elements - if ( (XML_NAMESPACE_TEXT == nPrefix) && - IsXMLToken(rLocalName, XML_SECTION_SOURCE) ) - { - pContext = new XMLSectionSourceImportContext(GetImport(), - xSectionPropertySet); - } - else if ( (XML_NAMESPACE_OFFICE == nPrefix) && - IsXMLToken(rLocalName, XML_DDE_SOURCE) ) - { - pContext = new XMLSectionSourceDDEImportContext(GetImport(), - nPrefix, rLocalName, - xSectionPropertySet); - } - - return pContext; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/text/XMLSectionImportContext.hxx b/xmloff/source/text/XMLSectionImportContext.hxx index bad10a2e6a24..4f017c9bc2e9 100644 --- a/xmloff/source/text/XMLSectionImportContext.hxx +++ b/xmloff/source/text/XMLSectionImportContext.hxx @@ -74,11 +74,6 @@ private: 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; - void ProcessAttributes( const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList ); }; diff --git a/xmloff/source/text/XMLSectionSourceDDEImportContext.cxx b/xmloff/source/text/XMLSectionSourceDDEImportContext.cxx index c45c3ffe1a2b..08f6ab51b53e 100644 --- a/xmloff/source/text/XMLSectionSourceDDEImportContext.cxx +++ b/xmloff/source/text/XMLSectionSourceDDEImportContext.cxx @@ -41,10 +41,8 @@ using namespace ::xmloff::token; XMLSectionSourceDDEImportContext::XMLSectionSourceDDEImportContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLocalName, Reference<XPropertySet> & rSectPropSet) : - SvXMLImportContext(rImport, nPrfx, rLocalName), + SvXMLImportContext(rImport), rSectionPropertySet(rSectPropSet) { } diff --git a/xmloff/source/text/XMLSectionSourceDDEImportContext.hxx b/xmloff/source/text/XMLSectionSourceDDEImportContext.hxx index b7af6c0d3372..95cd7e6fe591 100644 --- a/xmloff/source/text/XMLSectionSourceDDEImportContext.hxx +++ b/xmloff/source/text/XMLSectionSourceDDEImportContext.hxx @@ -34,11 +34,8 @@ class XMLSectionSourceDDEImportContext : public SvXMLImportContext public: - XMLSectionSourceDDEImportContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLocalName, css::uno::Reference<css::beans::XPropertySet> & rSectPropSet); virtual ~XMLSectionSourceDDEImportContext() override; diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx index 3da588ddffb7..066b5d124a99 100644 --- a/xmloff/source/text/XMLTextFrameContext.cxx +++ b/xmloff/source/text/XMLTextFrameContext.cxx @@ -125,8 +125,6 @@ public: XMLTextFrameTitleOrDescContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, OUString& rTitleOrDesc ); virtual void SAL_CALL characters( const OUString& rText ) override; @@ -136,10 +134,8 @@ public: XMLTextFrameTitleOrDescContext_Impl::XMLTextFrameTitleOrDescContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, OUString& rTitleOrDesc ) - : SvXMLImportContext( rImport, nPrfx, rLName ) + : SvXMLImportContext( rImport ) , mrTitleOrDesc( rTitleOrDesc ) { } @@ -199,9 +195,8 @@ class XMLTextFrameContourContext_Impl : public SvXMLImportContext public: - XMLTextFrameContourContext_Impl( SvXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList, + XMLTextFrameContourContext_Impl( SvXMLImport& rImport, sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList, const Reference < XPropertySet >& rPropSet, bool bPath ); }; @@ -210,11 +205,11 @@ public: XMLTextFrameContourContext_Impl::XMLTextFrameContourContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrfx, const OUString& rLName, - const Reference< XAttributeList > & xAttrList, + sal_Int32 /*nElement*/, + const Reference< XFastAttributeList > & xAttrList, const Reference < XPropertySet >& rPropSet, bool bPath ) : - SvXMLImportContext( rImport, nPrfx, rLName ), + SvXMLImportContext( rImport ), xPropSet( rPropSet ) { OUString sD, sPoints, sViewBox; @@ -223,48 +218,42 @@ XMLTextFrameContourContext_Impl::XMLTextFrameContourContext_Impl( sal_Int32 nWidth = 0; sal_Int32 nHeight = 0; - const SvXMLTokenMap& rTokenMap = - GetImport().GetTextImport()->GetTextContourAttrTokenMap(); - - 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 ); - const OUString& rValue = xAttrList->getValueByIndex( i ); - - OUString aLocalName; - sal_uInt16 nPrefix = - GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, - &aLocalName ); - switch( rTokenMap.Get( nPrefix, aLocalName ) ) + OUString sValue = aIter.toString(); + switch( aIter.getToken() ) { - case XML_TOK_TEXT_CONTOUR_VIEWBOX: - sViewBox = rValue; + case XML_ELEMENT(SVG, XML_VIEWBOX): + case XML_ELEMENT(SVG_COMPAT, XML_VIEWBOX): + sViewBox = sValue; break; - case XML_TOK_TEXT_CONTOUR_D: + case XML_ELEMENT(SVG, XML_D): + case XML_ELEMENT(SVG_COMPAT, XML_D): if( bPath ) - sD = rValue; + sD = sValue; break; - case XML_TOK_TEXT_CONTOUR_POINTS: + case XML_ELEMENT(DRAW,XML_POINTS): if( !bPath ) - sPoints = rValue; + sPoints = sValue; break; - case XML_TOK_TEXT_CONTOUR_WIDTH: - if (::sax::Converter::convertMeasurePx(nWidth, rValue)) + case XML_ELEMENT(SVG, XML_WIDTH): + case XML_ELEMENT(SVG_COMPAT, XML_WIDTH): + if (::sax::Converter::convertMeasurePx(nWidth, sValue)) bPixelWidth = true; else GetImport().GetMM100UnitConverter().convertMeasureToCore( - nWidth, rValue); + nWidth, sValue); break; - case XML_TOK_TEXT_CONTOUR_HEIGHT: - if (::sax::Converter::convertMeasurePx(nHeight, rValue)) + case XML_ELEMENT(SVG, XML_HEIGHT): + case XML_ELEMENT(SVG_COMPAT, XML_HEIGHT): + if (::sax::Converter::convertMeasurePx(nHeight, sValue)) bPixelHeight = true; else GetImport().GetMM100UnitConverter().convertMeasureToCore( - nHeight, rValue); + nHeight, sValue); break; - case XML_TOK_TEXT_CONTOUR_AUTO: - bAuto = IsXMLToken(rValue, XML_TRUE); + case XML_ELEMENT(DRAW, XML_RECREATE_ON_EDIT): + bAuto = IsXMLToken(sValue, XML_TRUE); break; } } @@ -389,12 +378,11 @@ public: const OUString& GetHRef() const { return sHRef; } XMLTextFrameContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference<css::xml::sax::XAttributeList > & rAttrList, + sal_Int32 nElement, + const css::uno::Reference<css::xml::sax::XFastAttributeList > & rAttrList, css::text::TextContentAnchorType eAnchorType, sal_uInt16 nType, - const css::uno::Reference<css::xml::sax::XAttributeList > & rFrameAttrList, + const css::uno::Reference<css::xml::sax::XFastAttributeList > & rFrameAttrList, bool bMultipleContent = false ); virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; @@ -818,13 +806,13 @@ bool XMLTextFrameContext_Impl::CreateIfNotThere() XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrfx, const OUString& rLName, - const Reference< XAttributeList > & rAttrList, + sal_Int32 /*nElement*/, + const Reference< XFastAttributeList > & rAttrList, TextContentAnchorType eATyp, sal_uInt16 nNewType, - const Reference< XAttributeList > & rFrameAttrList, + const Reference< XFastAttributeList > & rFrameAttrList, bool bMultipleContent ) -: SvXMLImportContext( rImport, nPrfx, rLName ) +: SvXMLImportContext( rImport ) , mbListContextPushed( false ) , nType( nNewType ) , eAnchorType( eATyp ) @@ -848,40 +836,24 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( bOwnBase64Stream = false; mbMultipleContent = bMultipleContent; - rtl::Reference < XMLTextImportHelper > xTxtImport = - GetImport().GetTextImport(); - const SvXMLTokenMap& rTokenMap = - xTxtImport->GetTextFrameAttrTokenMap(); - - sal_Int16 nAttrCount = rAttrList.is() ? rAttrList->getLength() : 0; - sal_Int16 nTotalAttrCount = nAttrCount + (rFrameAttrList.is() ? rFrameAttrList->getLength() : 0); - for( sal_Int16 i=0; i < nTotalAttrCount; i++ ) + auto processAttr = [&](sal_Int32 nElement, OUString rValue) -> void { - const OUString& rAttrName = - i < nAttrCount ? rAttrList->getNameByIndex( i ) : rFrameAttrList->getNameByIndex( i-nAttrCount ); - const OUString& rValue = - i < nAttrCount ? rAttrList->getValueByIndex( i ): rFrameAttrList->getValueByIndex( i-nAttrCount ); - - OUString aLocalName; - sal_uInt16 nPrefix = - GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, - &aLocalName ); - switch( rTokenMap.Get( nPrefix, aLocalName ) ) + switch( nElement ) { - case XML_TOK_TEXT_FRAME_STYLE_NAME: + case XML_ELEMENT(DRAW, XML_STYLE_NAME): sStyleName = rValue; break; - case XML_TOK_TEXT_FRAME_NAME: + case XML_ELEMENT(DRAW, XML_NAME): m_sOrigName = rValue; sName = rValue; break; - case XML_TOK_TEXT_FRAME_FRAME_NAME: + case XML_ELEMENT(DRAW, XML_FRAME_NAME): sFrameName = rValue; break; - case XML_TOK_TEXT_FRAME_APPLET_NAME: + case XML_ELEMENT(DRAW, XML_APPLET_NAME): sAppletName = rValue; break; - case XML_TOK_TEXT_FRAME_ANCHOR_TYPE: + case XML_ELEMENT(TEXT, XML_ANCHOR_TYPE): if( TextContentAnchorType_AT_PARAGRAPH == eAnchorType || TextContentAnchorType_AT_CHARACTER == eAnchorType || TextContentAnchorType_AS_CHARACTER == eAnchorType ) @@ -896,22 +868,25 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( eAnchorType = eNew; } break; - case XML_TOK_TEXT_FRAME_ANCHOR_PAGE_NUMBER: + case XML_ELEMENT(TEXT, XML_ANCHOR_PAGE_NUMBER): { sal_Int32 nTmp; if (::sax::Converter::convertNumber(nTmp, rValue, 1, SHRT_MAX)) nPage = static_cast<sal_Int16>(nTmp); } break; - case XML_TOK_TEXT_FRAME_X: + case XML_ELEMENT(SVG, XML_X): + case XML_ELEMENT(SVG_COMPAT, XML_X): GetImport().GetMM100UnitConverter().convertMeasureToCore( nX, rValue); break; - case XML_TOK_TEXT_FRAME_Y: + case XML_ELEMENT(SVG, XML_Y): + case XML_ELEMENT(SVG_COMPAT, XML_Y): GetImport().GetMM100UnitConverter().convertMeasureToCore( nY, rValue ); break; - case XML_TOK_TEXT_FRAME_WIDTH: + case XML_ELEMENT(SVG, XML_WIDTH): + case XML_ELEMENT(SVG_COMPAT, XML_WIDTH): // relative widths are obsolete since SRC617. Remove them some day! if( rValue.indexOf( '%' ) != -1 ) { @@ -925,7 +900,7 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( nWidth, rValue, 0 ); } break; - case XML_TOK_TEXT_FRAME_REL_WIDTH: + case XML_ELEMENT(STYLE, XML_REL_WIDTH): if( IsXMLToken(rValue, XML_SCALE) ) { bSyncWidth = true; @@ -937,7 +912,8 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( nRelWidth = static_cast<sal_Int16>(nTmp); } break; - case XML_TOK_TEXT_FRAME_MIN_WIDTH: + case XML_ELEMENT(FO, XML_MIN_WIDTH): + case XML_ELEMENT(FO_COMPAT, XML_MIN_WIDTH): if( rValue.indexOf( '%' ) != -1 ) { sal_Int32 nTmp; @@ -951,7 +927,8 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( } bMinWidth = true; break; - case XML_TOK_TEXT_FRAME_HEIGHT: + case XML_ELEMENT(SVG, XML_HEIGHT): + case XML_ELEMENT(SVG_COMPAT, XML_HEIGHT): // relative heights are obsolete since SRC617. Remove them some day! if( rValue.indexOf( '%' ) != -1 ) { @@ -965,7 +942,7 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( nHeight, rValue, 0 ); } break; - case XML_TOK_TEXT_FRAME_REL_HEIGHT: + case XML_ELEMENT(STYLE, XML_REL_HEIGHT): if( IsXMLToken( rValue, XML_SCALE ) ) { bSyncHeight = true; @@ -982,7 +959,8 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( nRelHeight = static_cast<sal_Int16>(nTmp); } break; - case XML_TOK_TEXT_FRAME_MIN_HEIGHT: + case XML_ELEMENT(FO, XML_MIN_HEIGHT): + case XML_ELEMENT(FO_COMPAT, XML_MIN_HEIGHT): if( rValue.indexOf( '%' ) != -1 ) { sal_Int32 nTmp; @@ -996,16 +974,16 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( } bMinHeight = true; break; - case XML_TOK_TEXT_FRAME_Z_INDEX: + case XML_ELEMENT(DRAW, XML_ZINDEX): ::sax::Converter::convertNumber( nZIndex, rValue, -1 ); break; - case XML_TOK_TEXT_FRAME_NEXT_CHAIN_NAME: + case XML_ELEMENT(DRAW, XML_CHAIN_NEXT_NAME): sNextName = rValue; break; - case XML_TOK_TEXT_FRAME_HREF: + case XML_ELEMENT(XLINK, XML_HREF): sHRef = rValue; break; - case XML_TOK_TEXT_FRAME_TRANSFORM: + case XML_ELEMENT(DRAW, XML_TRANSFORM): { // RotateFlyFrameFix: im/export full 'draw:transform' using existing tooling // Currently only rotation is used, but combinations with 'draw:transform' @@ -1066,24 +1044,33 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( } } break; - case XML_TOK_TEXT_FRAME_CODE: + case XML_ELEMENT(DRAW, XML_CODE): sCode = rValue; break; - case XML_TOK_TEXT_FRAME_OBJECT: + case XML_ELEMENT(DRAW, XML_OBJECT): break; - case XML_TOK_TEXT_FRAME_ARCHIVE: + case XML_ELEMENT(DRAW, XML_ARCHIVE): break; - case XML_TOK_TEXT_FRAME_MAY_SCRIPT: + case XML_ELEMENT(DRAW, XML_MAY_SCRIPT): bMayScript = IsXMLToken( rValue, XML_TRUE ); break; - case XML_TOK_TEXT_FRAME_MIME_TYPE: + case XML_ELEMENT(DRAW, XML_MIME_TYPE): + case XML_ELEMENT(LO_EXT, XML_MIME_TYPE): sMimeType = rValue; break; - case XML_TOK_TEXT_FRAME_NOTIFY_ON_UPDATE: + case XML_ELEMENT(DRAW, XML_NOTIFY_ON_UPDATE_OF_RANGES): + case XML_ELEMENT(DRAW, XML_NOTIFY_ON_UPDATE_OF_TABLE): sTblName = rValue; break; + default: + XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nElement, rValue); } - } + }; + + for( auto& aIter : sax_fastparser::castToFastAttributeList(rAttrList) ) + processAttr(aIter.getToken(), aIter.toString()); + for( auto& aIter : sax_fastparser::castToFastAttributeList(rFrameAttrList) ) + processAttr(aIter.getToken(), aIter.toString()); if( ( (XML_TEXT_FRAME_GRAPHIC == nType || XML_TEXT_FRAME_OBJECT == nType || @@ -1330,11 +1317,11 @@ bool XMLTextFrameContext::CreateIfNotThere( css::uno::Reference < css::beans::XP XMLTextFrameContext::XMLTextFrameContext( SvXMLImport& rImport, - const Reference< XAttributeList > & xAttrList, + const Reference< XFastAttributeList > & xAttrList, TextContentAnchorType eATyp ) : SvXMLImportContext( rImport ) , MultiImageImportHelper() -, m_xAttrList( new SvXMLAttributeList( xAttrList ) ) +, m_xAttrList( new sax_fastparser::FastAttributeList( xAttrList ) ) // Implement Title/Description Elements UI (#i73249#) , m_sTitle() , m_sDesc() @@ -1343,42 +1330,39 @@ XMLTextFrameContext::XMLTextFrameContext( , m_HasAutomaticStyleWithoutParentStyle( false ) , m_bSupportsReplacement( false ) { - 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 = - GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName ); // New distinguish attribute between Writer objects and Draw objects is: // Draw objects have an automatic style without a parent style (#i51726#) - if ( XML_NAMESPACE_DRAW == nPrefix && - IsXMLToken( aLocalName, XML_STYLE_NAME ) ) + switch (aIter.getToken()) { - OUString aStyleName = xAttrList->getValueByIndex( i ); - if( !aStyleName.isEmpty() ) + case XML_ELEMENT(DRAW, XML_STYLE_NAME): { - rtl::Reference < XMLTextImportHelper > xTxtImport = - GetImport().GetTextImport(); - XMLPropStyleContext* pStyle = xTxtImport->FindAutoFrameStyle( aStyleName ); - if ( pStyle && pStyle->GetParentName().isEmpty() ) + OUString aStyleName = aIter.toString(); + if( !aStyleName.isEmpty() ) { - m_HasAutomaticStyleWithoutParentStyle = true; + rtl::Reference < XMLTextImportHelper > xTxtImport = + GetImport().GetTextImport(); + XMLPropStyleContext* pStyle = xTxtImport->FindAutoFrameStyle( aStyleName ); + if ( pStyle && pStyle->GetParentName().isEmpty() ) + { + m_HasAutomaticStyleWithoutParentStyle = true; + } } + break; + } + case XML_ELEMENT(TEXT, XML_ANCHOR_TYPE): + { + TextContentAnchorType eNew; + if( XMLAnchorTypePropHdl::convert( aIter.toString(), + eNew ) && + ( TextContentAnchorType_AT_PARAGRAPH == eNew || + TextContentAnchorType_AT_CHARACTER == eNew || + TextContentAnchorType_AS_CHARACTER == eNew || + TextContentAnchorType_AT_PAGE == eNew) ) + m_eDefaultAnchorType = eNew; + break; } - } - else if ( XML_NAMESPACE_TEXT == nPrefix && - IsXMLToken( aLocalName, XML_ANCHOR_TYPE ) ) - { - TextContentAnchorType eNew; - if( XMLAnchorTypePropHdl::convert( xAttrList->getValueByIndex(i), - eNew ) && - ( TextContentAnchorType_AT_PARAGRAPH == eNew || - TextContentAnchorType_AT_CHARACTER == eNew || - TextContentAnchorType_AS_CHARACTER == eNew || - TextContentAnchorType_AT_PAGE == eNew) ) - m_eDefaultAnchorType = eNew; } } } @@ -1428,79 +1412,37 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLTextFrameContext::c const uno::Reference< xml::sax::XFastAttributeList>& xAttrList ) { SvXMLImportContextRef xContext; - if( !m_xImplContext.is() ) - { - } - else if(getSupportsMultipleContents() && nElement == XML_ELEMENT(DRAW, XML_IMAGE)) - { - } - else if( m_bSupportsReplacement && !m_xReplImplContext.is() && - nElement == XML_ELEMENT(DRAW, XML_IMAGE) ) - { - } - else if( nullptr != dynamic_cast< const XMLTextFrameContext_Impl*>( m_xImplContext.get() )) - { - } - // #i68101# - else 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 ) ) - { - if (getSupportsMultipleContents()) - { // tdf#103567 ensure props are set on surviving shape - // note: no more draw:image can be added once we get here - m_xImplContext = solveMultipleImages(); - } - xContext = &dynamic_cast<SvXMLImportContext&>(*m_xImplContext->createFastChildContextFallback( nElement, xAttrList )); - } - else if (nElement == XML_ELEMENT(LO_EXT, XML_SIGNATURELINE)) - { - if (getSupportsMultipleContents()) - { // tdf#103567 ensure props are set on surviving shape - // note: no more draw:image can be added once we get here - m_xImplContext = solveMultipleImages(); - } - xContext = &dynamic_cast<SvXMLImportContext&>(*m_xImplContext->createFastChildContextFallback(nElement, xAttrList)); - } - else if (nElement == XML_ELEMENT(LO_EXT, XML_QRCODE)) - { - if (getSupportsMultipleContents()) - { // tdf#103567 ensure props are set on surviving shape - // note: no more draw:image can be added once we get here - m_xImplContext = solveMultipleImages(); - } - xContext = &dynamic_cast<SvXMLImportContext&>(*m_xImplContext->createFastChildContextFallback(nElement, xAttrList)); - } - - return xContext.get(); -} - -SvXMLImportContextRef XMLTextFrameContext::CreateChildContext( - sal_uInt16 p_nPrefix, - const OUString& rLocalName, - const Reference< XAttributeList > & xAttrList ) -{ - SvXMLImportContextRef xContext; if( !m_xImplContext.is() ) { // no child exists - if( XML_NAMESPACE_DRAW == p_nPrefix ) + if( IsTokenInNamespace(nElement, XML_NAMESPACE_DRAW) ) { sal_uInt16 nFrameType = USHRT_MAX; - if( IsXMLToken( rLocalName, XML_TEXT_BOX ) ) - nFrameType = XML_TEXT_FRAME_TEXTBOX; - else if( IsXMLToken( rLocalName, XML_IMAGE ) ) - nFrameType = XML_TEXT_FRAME_GRAPHIC; - else if( IsXMLToken( rLocalName, XML_OBJECT ) ) - nFrameType = XML_TEXT_FRAME_OBJECT; - else if( IsXMLToken( rLocalName, XML_OBJECT_OLE ) ) - nFrameType = XML_TEXT_FRAME_OBJECT_OLE; - else if( IsXMLToken( rLocalName, XML_APPLET) ) - nFrameType = XML_TEXT_FRAME_APPLET; - else if( IsXMLToken( rLocalName, XML_PLUGIN ) ) - nFrameType = XML_TEXT_FRAME_PLUGIN; - else if( IsXMLToken( rLocalName, XML_FLOATING_FRAME ) ) - nFrameType = XML_TEXT_FRAME_FLOATING_FRAME; + switch (nElement & TOKEN_MASK) + { + case XML_TEXT_BOX: + nFrameType = XML_TEXT_FRAME_TEXTBOX; + break; + case XML_IMAGE: + nFrameType = XML_TEXT_FRAME_GRAPHIC; + break; + case XML_OBJECT: + nFrameType = XML_TEXT_FRAME_OBJECT; + break; + case XML_OBJECT_OLE: + nFrameType = XML_TEXT_FRAME_OBJECT_OLE; + break; + case XML_APPLET: + nFrameType = XML_TEXT_FRAME_APPLET; + break; + case XML_PLUGIN: + nFrameType = XML_TEXT_FRAME_PLUGIN; + break; + case XML_FLOATING_FRAME: + nFrameType = XML_TEXT_FRAME_FLOATING_FRAME; + break; + } if( USHRT_MAX != nFrameType ) { @@ -1510,34 +1452,31 @@ SvXMLImportContextRef XMLTextFrameContext::CreateChildContext( m_HasAutomaticStyleWithoutParentStyle ) { Reference < XShapes > xShapes; - xContext = GetImport().GetShapeImport()->CreateFrameChildContext( - GetImport(), p_nPrefix, rLocalName, xAttrList, xShapes, m_xAttrList ); + xContext = XMLShapeImportHelper::CreateFrameChildContext( + GetImport(), nElement, xAttrList, xShapes, m_xAttrList.get() ); } else if( XML_TEXT_FRAME_PLUGIN == nFrameType ) { bool bMedia = false; // check, if we have a media object - for( sal_Int16 n = 0, nAttrCount = ( xAttrList.is() ? xAttrList->getLength() : 0 ); n < nAttrCount; ++n ) + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { - OUString aLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( n ), &aLocalName ); - - if( nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( aLocalName, XML_MIME_TYPE ) ) + if( aIter.getToken() == XML_ELEMENT(DRAW, XML_MIME_TYPE) ) { - if( xAttrList->getValueByIndex( n ) == "application/vnd.sun.star.media" ) + if( aIter.toString() == "application/vnd.sun.star.media" ) bMedia = true; // leave this loop - n = nAttrCount - 1; + break; } } if( bMedia ) { Reference < XShapes > xShapes; - xContext = GetImport().GetShapeImport()->CreateFrameChildContext( - GetImport(), p_nPrefix, rLocalName, xAttrList, xShapes, m_xAttrList ); + xContext = XMLShapeImportHelper::CreateFrameChildContext( + GetImport(), nElement, xAttrList, xShapes, m_xAttrList.get() ); } } else if( XML_TEXT_FRAME_OBJECT == nFrameType || @@ -1547,16 +1486,16 @@ SvXMLImportContextRef XMLTextFrameContext::CreateChildContext( } else if(XML_TEXT_FRAME_GRAPHIC == nFrameType) { - setSupportsMultipleContents(IsXMLToken(rLocalName, XML_IMAGE)); + setSupportsMultipleContents( (nElement & TOKEN_MASK) == XML_IMAGE ); } if (!xContext) { - xContext = new XMLTextFrameContext_Impl( GetImport(), p_nPrefix, - rLocalName, xAttrList, + xContext = new XMLTextFrameContext_Impl( GetImport(), nElement, + xAttrList, m_eDefaultAnchorType, nFrameType, - m_xAttrList ); + m_xAttrList.get() ); } m_xImplContext = xContext; @@ -1568,106 +1507,100 @@ SvXMLImportContextRef XMLTextFrameContext::CreateChildContext( } } } - else if(getSupportsMultipleContents() && XML_NAMESPACE_DRAW == p_nPrefix && IsXMLToken(rLocalName, XML_IMAGE)) + else if(getSupportsMultipleContents() && nElement == XML_ELEMENT(DRAW, XML_IMAGE)) { // read another image xContext = new XMLTextFrameContext_Impl( - GetImport(), p_nPrefix, rLocalName, xAttrList, - m_eDefaultAnchorType, XML_TEXT_FRAME_GRAPHIC, m_xAttrList, true); + GetImport(), nElement, xAttrList, + m_eDefaultAnchorType, XML_TEXT_FRAME_GRAPHIC, m_xAttrList.get(), true); m_xImplContext = xContext; addContent(*m_xImplContext); } else if( m_bSupportsReplacement && !m_xReplImplContext.is() && - XML_NAMESPACE_DRAW == p_nPrefix && - IsXMLToken( rLocalName, XML_IMAGE ) ) + nElement == XML_ELEMENT(DRAW, XML_IMAGE) ) { // read replacement image Reference < XPropertySet > xPropSet; if( CreateIfNotThere( xPropSet ) ) { xContext = new XMLReplacementImageContext( GetImport(), - p_nPrefix, rLocalName, xAttrList, xPropSet ); + nElement, xAttrList, xPropSet ); m_xReplImplContext = xContext; } } else if( nullptr != dynamic_cast< const XMLTextFrameContext_Impl*>( m_xImplContext.get() )) { // the child is a writer frame - if( XML_NAMESPACE_SVG == p_nPrefix ) + if( IsTokenInNamespace(nElement, XML_NAMESPACE_SVG) || + IsTokenInNamespace(nElement, XML_NAMESPACE_SVG_COMPAT) ) { // Implement Title/Description Elements UI (#i73249#) const bool bOld = SvXMLImport::OOo_2x >= GetImport().getGeneratorVersion(); if ( bOld ) { - if ( IsXMLToken( rLocalName, XML_DESC ) ) + if ( (nElement & TOKEN_MASK) == XML_DESC ) { xContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(), - p_nPrefix, - rLocalName, m_sTitle ); } } else { - if( IsXMLToken( rLocalName, XML_TITLE ) ) + if( (nElement & TOKEN_MASK) == XML_TITLE ) { if (getSupportsMultipleContents()) { // tdf#103567 ensure props are set on surviving shape m_xImplContext = solveMultipleImages(); } xContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(), - p_nPrefix, - rLocalName, m_sTitle ); } - else if ( IsXMLToken( rLocalName, XML_DESC ) ) + else if ( (nElement & TOKEN_MASK) == XML_DESC ) { if (getSupportsMultipleContents()) { // tdf#103567 ensure props are set on surviving shape m_xImplContext = solveMultipleImages(); } xContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(), - p_nPrefix, - rLocalName, m_sDesc ); } } } - else if( XML_NAMESPACE_DRAW == p_nPrefix ) + else if( IsTokenInNamespace(nElement, XML_NAMESPACE_DRAW) ) { Reference < XPropertySet > xPropSet; - if( IsXMLToken( rLocalName, XML_CONTOUR_POLYGON ) ) + if( (nElement & TOKEN_MASK) == XML_CONTOUR_POLYGON ) { if (getSupportsMultipleContents()) { // tdf#103567 ensure props are set on surviving shape m_xImplContext = solveMultipleImages(); } if( CreateIfNotThere( xPropSet ) ) - xContext = new XMLTextFrameContourContext_Impl( GetImport(), p_nPrefix, rLocalName, + xContext = new XMLTextFrameContourContext_Impl( GetImport(), nElement, xAttrList, xPropSet, false ); } - else if( IsXMLToken( rLocalName, XML_CONTOUR_PATH ) ) + else if( (nElement & TOKEN_MASK) == XML_CONTOUR_PATH ) { if (getSupportsMultipleContents()) { // tdf#103567 ensure props are set on surviving shape m_xImplContext = solveMultipleImages(); } if( CreateIfNotThere( xPropSet ) ) - xContext = new XMLTextFrameContourContext_Impl( GetImport(), p_nPrefix, rLocalName, + xContext = new XMLTextFrameContourContext_Impl( GetImport(), nElement, xAttrList, xPropSet, true ); } - else if( IsXMLToken( rLocalName, XML_IMAGE_MAP ) ) + else if( (nElement & TOKEN_MASK) == XML_IMAGE_MAP ) { if (getSupportsMultipleContents()) { // tdf#103567 ensure props are set on surviving shape m_xImplContext = solveMultipleImages(); } if( CreateIfNotThere( xPropSet ) ) - xContext = new XMLImageMapContext( GetImport(), p_nPrefix, rLocalName, xPropSet ); + xContext = new XMLImageMapContext( GetImport(), xPropSet ); } } - else if( (XML_NAMESPACE_OFFICE == p_nPrefix) && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) ) + else if( nElement == XML_ELEMENT(OFFICE, XML_EVENT_LISTENERS) ) { if (getSupportsMultipleContents()) { // tdf#103567 ensure props are set on surviving shape @@ -1687,24 +1620,43 @@ SvXMLImportContextRef XMLTextFrameContext::CreateChildContext( } } } - else if( p_nPrefix == XML_NAMESPACE_SVG && // #i68101# - (IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) ) + // #i68101# + else 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 ) ) { + if (getSupportsMultipleContents()) + { // tdf#103567 ensure props are set on surviving shape + // note: no more draw:image can be added once we get here + m_xImplContext = solveMultipleImages(); + } + xContext = &dynamic_cast<SvXMLImportContext&>(*m_xImplContext->createFastChildContext( nElement, xAttrList )); } - else if (p_nPrefix == XML_NAMESPACE_LO_EXT && (IsXMLToken(rLocalName, XML_SIGNATURELINE))) + else if (nElement == XML_ELEMENT(LO_EXT, XML_SIGNATURELINE)) { + if (getSupportsMultipleContents()) + { // tdf#103567 ensure props are set on surviving shape + // note: no more draw:image can be added once we get here + m_xImplContext = solveMultipleImages(); + } + xContext = &dynamic_cast<SvXMLImportContext&>(*m_xImplContext->createFastChildContext(nElement, xAttrList)); } - else if (p_nPrefix == XML_NAMESPACE_LO_EXT && (IsXMLToken(rLocalName, XML_QRCODE))) + else if (nElement == XML_ELEMENT(LO_EXT, XML_QRCODE)) { + if (getSupportsMultipleContents()) + { // tdf#103567 ensure props are set on surviving shape + // note: no more draw:image can be added once we get here + m_xImplContext = solveMultipleImages(); + } + xContext = &dynamic_cast<SvXMLImportContext&>(*m_xImplContext->createFastChildContext(nElement, xAttrList)); } else { // the child is a drawing shape - xContext = XMLShapeImportHelper::CreateFrameChildContext( - m_xImplContext.get(), p_nPrefix, rLocalName, xAttrList ); + return XMLShapeImportHelper::CreateFrameChildContext( + m_xImplContext.get(), nElement, xAttrList ); } - return xContext; + return xContext.get(); } void XMLTextFrameContext::SetHyperlink( const OUString& rHRef, diff --git a/xmloff/source/text/XMLTextFrameContext.hxx b/xmloff/source/text/XMLTextFrameContext.hxx index 1f3787e9e9fc..ebefa1e8f4b5 100644 --- a/xmloff/source/text/XMLTextFrameContext.hxx +++ b/xmloff/source/text/XMLTextFrameContext.hxx @@ -34,7 +34,7 @@ class XMLTextFrameContextHyperlink_Impl; class XMLTextFrameContext : public SvXMLImportContext, public MultiImageImportHelper { - css::uno::Reference< css::xml::sax::XAttributeList > m_xAttrList; + rtl::Reference< sax_fastparser::FastAttributeList > m_xAttrList; SvXMLImportContextRef m_xImplContext; SvXMLImportContextRef m_xReplImplContext; @@ -68,16 +68,13 @@ public: XMLTextFrameContext( SvXMLImport& rImport, const css::uno::Reference< - css::xml::sax::XAttributeList > & xAttrList, + css::xml::sax::XFastAttributeList > & xAttrList, css::text::TextContentAnchorType eDfltAnchorType ); 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; - SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override; void SetHyperlink( const OUString& rHRef, const OUString& rName, diff --git a/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx b/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx index 126c55aa8eef..a6e717f2a879 100644 --- a/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx +++ b/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/log.hxx> #include <sax/tools/converter.hxx> #include <xmloff/xmlimp.hxx> @@ -37,64 +38,6 @@ namespace drawing = com::sun::star::drawing; XMLTextFrameHyperlinkContext::XMLTextFrameHyperlinkContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, const OUString& rLName, - const Reference< XAttributeList > & xAttrList, - TextContentAnchorType eATyp ) : - SvXMLImportContext( rImport, nPrfx, rLName ), - eDefaultAnchorType( eATyp ), - bMap( false ) -{ - OUString sShow; - const SvXMLTokenMap& rTokenMap = - GetImport().GetTextImport()->GetTextHyperlinkAttrTokenMap(); - - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for( sal_Int16 i=0; i < nAttrCount; i++ ) - { - const OUString& rAttrName = xAttrList->getNameByIndex( i ); - const OUString& rValue = xAttrList->getValueByIndex( i ); - - OUString aLocalName; - sal_uInt16 nPrefix = - GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, - &aLocalName ); - switch( rTokenMap.Get( nPrefix, aLocalName ) ) - { - case XML_TOK_TEXT_HYPERLINK_HREF: - sHRef = GetImport().GetAbsoluteReference( rValue ); - break; - case XML_TOK_TEXT_HYPERLINK_NAME: - sName = rValue; - break; - case XML_TOK_TEXT_HYPERLINK_TARGET_FRAME: - sTargetFrameName = rValue; - break; - case XML_TOK_TEXT_HYPERLINK_SHOW: - sShow = rValue; - break; - case XML_TOK_TEXT_HYPERLINK_SERVER_MAP: - { - bool bTmp(false); - if (::sax::Converter::convertBool( bTmp, rValue )) - { - bMap = bTmp; - } - } - break; - } - } - - if( !sShow.isEmpty() && sTargetFrameName.isEmpty() ) - { - if( IsXMLToken( sShow, XML_NEW ) ) - sTargetFrameName = "_blank"; - else if( IsXMLToken( sShow, XML_REPLACE ) ) - sTargetFrameName = "_self"; - } -} - -XMLTextFrameHyperlinkContext::XMLTextFrameHyperlinkContext( - SvXMLImport& rImport, sal_Int32 /*nElement*/, const Reference< XFastAttributeList > & xAttrList, TextContentAnchorType eATyp ) : @@ -103,6 +46,7 @@ XMLTextFrameHyperlinkContext::XMLTextFrameHyperlinkContext( bMap( false ) { OUString sShow; + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { OUString sValue = aIter.toString(); @@ -131,7 +75,7 @@ XMLTextFrameHyperlinkContext::XMLTextFrameHyperlinkContext( break; default: XMLOFF_WARN_UNKNOWN("xmloff", aIter); - } + } } if( !sShow.isEmpty() && sTargetFrameName.isEmpty() ) @@ -147,28 +91,26 @@ XMLTextFrameHyperlinkContext::~XMLTextFrameHyperlinkContext() { } -SvXMLImportContextRef XMLTextFrameHyperlinkContext::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference< XAttributeList > & xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > XMLTextFrameHyperlinkContext::createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList ) { SvXMLImportContext *pContext = nullptr; XMLTextFrameContext *pTextFrameContext = nullptr; - if( XML_NAMESPACE_DRAW == nPrefix ) + if( nElement == XML_ELEMENT(DRAW, XML_FRAME) ) { - if( IsXMLToken( rLocalName, XML_FRAME ) ) - pTextFrameContext = new XMLTextFrameContext( GetImport(), xAttrList, + pTextFrameContext = new XMLTextFrameContext( GetImport(), + xAttrList, eDefaultAnchorType ); - } - - if( pTextFrameContext ) - { pTextFrameContext->SetHyperlink( sHRef, sName, sTargetFrameName, bMap ); pContext = pTextFrameContext; xFrameContext = pContext; } + if (!pContext) + XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); + return pContext; } diff --git a/xmloff/source/text/XMLTextFrameHyperlinkContext.hxx b/xmloff/source/text/XMLTextFrameHyperlinkContext.hxx index b1c6fdec5cd6..38f6752a8834 100644 --- a/xmloff/source/text/XMLTextFrameHyperlinkContext.hxx +++ b/xmloff/source/text/XMLTextFrameHyperlinkContext.hxx @@ -41,21 +41,14 @@ class XMLTextFrameHyperlinkContext : public SvXMLImportContext public: - - XMLTextFrameHyperlinkContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList, - css::text::TextContentAnchorType eDefaultAnchorType ); XMLTextFrameHyperlinkContext( SvXMLImport& rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList, css::text::TextContentAnchorType eDefaultAnchorType ); virtual ~XMLTextFrameHyperlinkContext() override; - 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; css::text::TextContentAnchorType GetAnchorType() const; diff --git a/xmloff/source/text/XMLTextListBlockContext.cxx b/xmloff/source/text/XMLTextListBlockContext.cxx index 71eb988a9e24..28e86eeac159 100644 --- a/xmloff/source/text/XMLTextListBlockContext.cxx +++ b/xmloff/source/text/XMLTextListBlockContext.cxx @@ -217,194 +217,6 @@ XMLTextListBlockContext::XMLTextListBlockContext( } } -// OD 2008-05-07 #refactorlists# -// add optional parameter <bRestartNumberingAtSubList> and its handling -XMLTextListBlockContext::XMLTextListBlockContext( - SvXMLImport& rImport, - XMLTextImportHelper& rTxtImp, - sal_uInt16 nPrfx, - const OUString& rLName, - const Reference< xml::sax::XAttributeList > & xAttrList, - const bool bRestartNumberingAtSubList ) -: SvXMLImportContext( rImport, nPrfx, rLName ) -, mrTxtImport( rTxtImp ) -, msListStyleName() -, mxParentListBlock( ) -, mnLevel( 0 ) -, mbRestartNumbering( false ) -, mbSetDefaults( false ) -, msListId() -, msContinueListId() -{ - static const char s_PropNameDefaultListId[] = "DefaultListId"; - { - // get the parent list block context (if any); this is a bit ugly... - XMLTextListBlockContext * pLB(nullptr); - XMLTextListItemContext * pLI(nullptr); - XMLNumberedParaContext * pNP(nullptr); - rTxtImp.GetTextListHelper().ListContextTop(pLB, pLI, pNP); - mxParentListBlock = pLB; - } - // Inherit style name from parent list, as well as the flags whether - // numbering must be restarted and formats have to be created. - OUString sParentListStyleName; - if( mxParentListBlock.is() ) - { - XMLTextListBlockContext *pParent = mxParentListBlock.get(); - msListStyleName = pParent->msListStyleName; - sParentListStyleName = msListStyleName; - mxNumRules = pParent->GetNumRules(); - mnLevel = pParent->GetLevel() + 1; - mbRestartNumbering = pParent->IsRestartNumbering() || - bRestartNumberingAtSubList; - mbSetDefaults = pParent->mbSetDefaults; - msListId = pParent->GetListId(); - msContinueListId = pParent->GetContinueListId(); - } - - const SvXMLTokenMap& rTokenMap = mrTxtImport.GetTextListBlockAttrTokenMap(); - - bool bIsContinueNumberingAttributePresent( false ); - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for( sal_Int16 i=0; i < nAttrCount; i++ ) - { - const OUString& rAttrName = xAttrList->getNameByIndex( i ); - const OUString& rValue = xAttrList->getValueByIndex( i ); - - OUString aLocalName; - sal_uInt16 nPrefix = - GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, - &aLocalName ); - switch( rTokenMap.Get( nPrefix, aLocalName ) ) - { - case XML_TOK_TEXT_LIST_BLOCK_XMLID: -//FIXME: there is no UNO API for lists - // xml:id is also the list ID (#i92221#) - if ( mnLevel == 0 ) // root <list> element - { - msListId = rValue; - } - break; - case XML_TOK_TEXT_LIST_BLOCK_CONTINUE_NUMBERING: - mbRestartNumbering = !IsXMLToken(rValue, XML_TRUE); - bIsContinueNumberingAttributePresent = true; - break; - case XML_TOK_TEXT_LIST_BLOCK_STYLE_NAME: - msListStyleName = rValue; - break; - case XML_TOK_TEXT_LIST_BLOCK_CONTINUE_LIST: - if ( mnLevel == 0 ) // root <list> element - { - msContinueListId = rValue; - } - break; - } - } - - // Remember this list block. - mrTxtImport.GetTextListHelper().PushListContext( this ); - - mxNumRules = XMLTextListsHelper::MakeNumRule(GetImport(), mxNumRules, - sParentListStyleName, msListStyleName, - mnLevel, &mbRestartNumbering, &mbSetDefaults ); - if( !mxNumRules.is() ) - return; - - if ( mnLevel != 0 ) // root <list> element - return; - - XMLTextListsHelper& rTextListsHelper( mrTxtImport.GetTextListHelper() ); - // Inconsistent behavior regarding lists (#i92811#) - OUString sListStyleDefaultListId; - { - uno::Reference< beans::XPropertySet > xNumRuleProps( mxNumRules, UNO_QUERY ); - if ( xNumRuleProps.is() ) - { - uno::Reference< beans::XPropertySetInfo > xNumRulePropSetInfo( - xNumRuleProps->getPropertySetInfo()); - if (xNumRulePropSetInfo.is() && - xNumRulePropSetInfo->hasPropertyByName( - s_PropNameDefaultListId)) - { - xNumRuleProps->getPropertyValue(s_PropNameDefaultListId) - >>= sListStyleDefaultListId; - SAL_WARN_IF( sListStyleDefaultListId.isEmpty(), "xmloff", - "no default list id found at numbering rules instance. Serious defect." ); - } - } - } - if ( msListId.isEmpty() ) // no text:id property found - { - sal_Int32 nUPD( 0 ); - sal_Int32 nBuild( 0 ); - const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild ); - if ( rImport.IsTextDocInOOoFileFormat() || - ( bBuildIdFound && nUPD == 680 ) ) - { - /* handling former documents written by OpenOffice.org: - use default list id of numbering rules instance, if existing - (#i92811#) - */ - if ( !sListStyleDefaultListId.isEmpty() ) - { - msListId = sListStyleDefaultListId; - if ( !bIsContinueNumberingAttributePresent && - !mbRestartNumbering && - rTextListsHelper.IsListProcessed( msListId ) ) - { - mbRestartNumbering = true; - } - } - } - if ( msListId.isEmpty() ) - { - // generate a new list id for the list - msListId = rTextListsHelper.GenerateNewListId(); - } - } - - if ( bIsContinueNumberingAttributePresent && !mbRestartNumbering && - msContinueListId.isEmpty() ) - { - const OUString& Last( rTextListsHelper.GetLastProcessedListId() ); - if ( rTextListsHelper.GetListStyleOfLastProcessedList() == msListStyleName - && Last != msListId ) - { - msContinueListId = Last; - } - } - - if ( !msContinueListId.isEmpty() ) - { - if ( !rTextListsHelper.IsListProcessed( msContinueListId ) ) - { - msContinueListId.clear(); - } - else - { - // search continue list chain for master list and - // continue the master list. - OUString sTmpStr = - rTextListsHelper.GetContinueListIdOfProcessedList( msContinueListId ); - while ( !sTmpStr.isEmpty() ) - { - msContinueListId = sTmpStr; - - sTmpStr = - rTextListsHelper.GetContinueListIdOfProcessedList( msContinueListId ); - } - } - } - - if ( !rTextListsHelper.IsListProcessed( msListId ) ) - { - // Inconsistent behavior regarding lists (#i92811#) - rTextListsHelper.KeepListAsProcessed( - msListId, msListStyleName, msContinueListId, - sListStyleDefaultListId ); - } -} - XMLTextListBlockContext::~XMLTextListBlockContext() { } @@ -447,7 +259,6 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLTextListBlockContex XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); } - return pContext; } diff --git a/xmloff/source/text/XMLTextListBlockContext.hxx b/xmloff/source/text/XMLTextListBlockContext.hxx index 7419613d244a..cc0bb99ec6db 100644 --- a/xmloff/source/text/XMLTextListBlockContext.hxx +++ b/xmloff/source/text/XMLTextListBlockContext.hxx @@ -52,13 +52,6 @@ public: XMLTextListBlockContext( SvXMLImport& rImport, XMLTextImportHelper& rTxtImp, - sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList, - const bool bRestartNumberingAtSubList = false ); - XMLTextListBlockContext( - SvXMLImport& rImport, - XMLTextImportHelper& rTxtImp, const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList, const bool bRestartNumberingAtSubList = false ); virtual ~XMLTextListBlockContext() override; diff --git a/xmloff/source/text/XMLTextShapeImportHelper.cxx b/xmloff/source/text/XMLTextShapeImportHelper.cxx index 506ad146e4ff..3c64ffd58e0a 100644 --- a/xmloff/source/text/XMLTextShapeImportHelper.cxx +++ b/xmloff/source/text/XMLTextShapeImportHelper.cxx @@ -26,6 +26,7 @@ #include <xmloff/txtimp.hxx> #include <xmloff/xmluconv.hxx> #include <xmloff/namespacemap.hxx> +#include <xmloff/xmlnamespace.hxx> #include "XMLAnchorTypePropHdl.hxx" #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/drawing/XDrawPageSupplier.hpp> @@ -40,6 +41,7 @@ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::text; using namespace ::com::sun::star::container; using namespace ::com::sun::star::xml::sax; +using namespace ::xmloff::token; constexpr OUStringLiteral gsAnchorType(u"AnchorType"); constexpr OUStringLiteral gsAnchorPageNo(u"AnchorPageNo"); @@ -67,7 +69,7 @@ XMLTextShapeImportHelper::~XMLTextShapeImportHelper() void XMLTextShapeImportHelper::addShape( Reference< XShape >& rShape, - const Reference< XAttributeList >& xAttrList, + const Reference< XFastAttributeList >& xAttrList, Reference< XShapes >& rShapes ) { if( rShapes.is() ) @@ -83,40 +85,32 @@ void XMLTextShapeImportHelper::addShape( rtl::Reference < XMLTextImportHelper > xTxtImport = rImport.GetTextImport(); - const SvXMLTokenMap& rTokenMap = - xTxtImport->GetTextFrameAttrTokenMap(); - 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 ); - const OUString& rValue = xAttrList->getValueByIndex( i ); - - OUString aLocalName; - sal_uInt16 nPrefix = - rImport.GetNamespaceMap().GetKeyByAttrName( rAttrName, - &aLocalName ); - switch( rTokenMap.Get( nPrefix, aLocalName ) ) + const OUString sValue = aIter.toString(); + switch( aIter.getToken() ) { - case XML_TOK_TEXT_FRAME_ANCHOR_TYPE: + case XML_ELEMENT(TEXT, XML_ANCHOR_TYPE): { TextContentAnchorType eNew; // OD 2004-06-01 #i26791# - allow all anchor types - if ( XMLAnchorTypePropHdl::convert( rValue, eNew ) ) + if ( XMLAnchorTypePropHdl::convert( sValue, eNew ) ) { eAnchorType = eNew; } } break; - case XML_TOK_TEXT_FRAME_ANCHOR_PAGE_NUMBER: + case XML_ELEMENT(TEXT, XML_ANCHOR_PAGE_NUMBER): { sal_Int32 nTmp; - if (::sax::Converter::convertNumber(nTmp, rValue, 1, SHRT_MAX)) + if (::sax::Converter::convertNumber(nTmp, sValue, 1, SHRT_MAX)) nPage = static_cast<sal_Int16>(nTmp); } break; - case XML_TOK_TEXT_FRAME_Y: - rImport.GetMM100UnitConverter().convertMeasureToCore( nY, rValue ); + case XML_ELEMENT(SVG, XML_Y): + case XML_ELEMENT(SVG_COMPAT, XML_Y): + rImport.GetMM100UnitConverter().convertMeasureToCore( nY, sValue ); break; } } diff --git a/xmloff/source/text/XMLTrackedChangesImportContext.cxx b/xmloff/source/text/XMLTrackedChangesImportContext.cxx index b08743a1d57f..2346005a7015 100644 --- a/xmloff/source/text/XMLTrackedChangesImportContext.cxx +++ b/xmloff/source/text/XMLTrackedChangesImportContext.cxx @@ -20,6 +20,7 @@ #include "XMLTrackedChangesImportContext.hxx" #include "XMLChangedRegionImportContext.hxx" #include <com/sun/star/uno/Reference.h> +#include <sal/log.hxx> #include <sax/tools/converter.hxx> #include <xmloff/xmlimp.hxx> #include <xmloff/xmlnamespace.hxx> @@ -34,10 +35,8 @@ using namespace ::xmloff::token; XMLTrackedChangesImportContext::XMLTrackedChangesImportContext( - SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName) : - SvXMLImportContext(rImport, nPrefix, rLocalName) + SvXMLImport& rImport) : + SvXMLImportContext(rImport) { } @@ -62,6 +61,8 @@ void XMLTrackedChangesImportContext::startFastElement( sal_Int32 /*nElement*/, } break; } + else + XMLOFF_WARN_UNKNOWN("xmloff", aIter); } // set tracked changes diff --git a/xmloff/source/text/XMLTrackedChangesImportContext.hxx b/xmloff/source/text/XMLTrackedChangesImportContext.hxx index cbef26c59cbf..c45bfa7e22d1 100644 --- a/xmloff/source/text/XMLTrackedChangesImportContext.hxx +++ b/xmloff/source/text/XMLTrackedChangesImportContext.hxx @@ -34,14 +34,12 @@ class XMLTrackedChangesImportContext : public SvXMLImportContext { public: - XMLTrackedChangesImportContext( - SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName); + XMLTrackedChangesImportContext(SvXMLImport& rImport); virtual ~XMLTrackedChangesImportContext() override; - virtual void SAL_CALL startFastElement( sal_Int32 nElement, + virtual void SAL_CALL startFastElement( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx index 798a103799aa..084a19e0f05b 100644 --- a/xmloff/source/text/txtfldi.cxx +++ b/xmloff/source/text/txtfldi.cxx @@ -118,26 +118,13 @@ const char sAPI_true[] = "TRUE"; XMLTextFieldImportContext::XMLTextFieldImportContext( SvXMLImport& rImport, XMLTextImportHelper& rHlp, - const char* pService, - sal_uInt16 nPrefix, const OUString& rElementName) -: SvXMLImportContext( rImport, nPrefix, rElementName ) -, rTextImportHelper(rHlp) -, sServicePrefix(sAPI_textfield_prefix) -, bValid(false) -{ - DBG_ASSERT(nullptr != pService, "Need service name!"); - sServiceName = OUString::createFromAscii(pService); -} - -XMLTextFieldImportContext::XMLTextFieldImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, const char* pService) : SvXMLImportContext( rImport ) , rTextImportHelper(rHlp) , sServicePrefix(sAPI_textfield_prefix) , bValid(false) { - DBG_ASSERT(nullptr != pService, "Need service name!"); + assert(nullptr != pService && "Need service name!"); sServiceName = OUString::createFromAscii(pService); } @@ -162,7 +149,6 @@ OUString const & XMLTextFieldImportContext::GetContent() void XMLTextFieldImportContext::endFastElement(sal_Int32 ) { - DBG_ASSERT(!GetServiceName().isEmpty(), "no service name for element!"); if (bValid) { @@ -229,303 +215,235 @@ XMLTextFieldImportContext* XMLTextFieldImportContext::CreateTextFieldImportContext( SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_Int32 nElement) -{ - const OUString& rPrefix = SvXMLImport::getNamespacePrefixFromToken(nElement, &rImport.GetNamespaceMap()); - const OUString& rLocalName = SvXMLImport::getNameFromToken( nElement ); - OUString aName = rPrefix.isEmpty() ? rLocalName : rPrefix + SvXMLImport::aNamespaceSeparator + rLocalName; - OUString aLocalName; - sal_uInt16 nPrefix = - rImport.GetNamespaceMap().GetKeyByAttrName( aName, &aLocalName ); - const SvXMLTokenMap& rTokenMap = - rImport.GetTextImport()->GetTextPElemTokenMap(); - sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName ); - return CreateTextFieldImportContext(rImport, rHlp, nPrefix, rLocalName, nToken); -} - -/// create the appropriate field context from -XMLTextFieldImportContext* -XMLTextFieldImportContext::CreateTextFieldImportContext( - SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrefix, - const OUString& rName, - sal_uInt16 nToken) + sal_Int32 nToken) { XMLTextFieldImportContext* pContext = nullptr; switch (nToken) { - case XML_TOK_TEXT_SENDER_FIRSTNAME: - case XML_TOK_TEXT_SENDER_LASTNAME: - case XML_TOK_TEXT_SENDER_INITIALS: - case XML_TOK_TEXT_SENDER_TITLE: - case XML_TOK_TEXT_SENDER_POSITION: - case XML_TOK_TEXT_SENDER_EMAIL: - case XML_TOK_TEXT_SENDER_PHONE_PRIVATE: - case XML_TOK_TEXT_SENDER_FAX: - case XML_TOK_TEXT_SENDER_COMPANY: - case XML_TOK_TEXT_SENDER_PHONE_WORK: - case XML_TOK_TEXT_SENDER_STREET: - case XML_TOK_TEXT_SENDER_CITY: - case XML_TOK_TEXT_SENDER_POSTAL_CODE: - case XML_TOK_TEXT_SENDER_COUNTRY: - case XML_TOK_TEXT_SENDER_STATE_OR_PROVINCE: + case XML_ELEMENT(TEXT, XML_SENDER_FIRSTNAME): + case XML_ELEMENT(TEXT, XML_SENDER_LASTNAME): + case XML_ELEMENT(LO_EXT, XML_SENDER_INITIALS): + case XML_ELEMENT(TEXT, XML_SENDER_INITIALS): + case XML_ELEMENT(TEXT, XML_SENDER_TITLE): + case XML_ELEMENT(TEXT, XML_SENDER_POSITION): + case XML_ELEMENT(TEXT, XML_SENDER_EMAIL): + case XML_ELEMENT(TEXT, XML_SENDER_PHONE_PRIVATE): + + case XML_ELEMENT(TEXT, XML_SENDER_FAX): + case XML_ELEMENT(TEXT, XML_SENDER_COMPANY): + case XML_ELEMENT(TEXT, XML_SENDER_PHONE_WORK): + case XML_ELEMENT(TEXT, XML_SENDER_STREET): + case XML_ELEMENT(TEXT, XML_SENDER_CITY): + case XML_ELEMENT(TEXT, XML_SENDER_POSTAL_CODE): + case XML_ELEMENT(TEXT, XML_SENDER_COUNTRY): + case XML_ELEMENT(TEXT, XML_SENDER_STATE_OR_PROVINCE): pContext = - new XMLSenderFieldImportContext( rImport, rHlp, - nPrefix, rName ); + new XMLSenderFieldImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_AUTHOR_NAME: - case XML_TOK_TEXT_AUTHOR_INITIALS: + case XML_ELEMENT(TEXT, XML_AUTHOR_NAME): + case XML_ELEMENT(TEXT, XML_AUTHOR_INITIALS): pContext = - new XMLAuthorFieldImportContext( rImport, rHlp, - nPrefix, rName ); + new XMLAuthorFieldImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_PLACEHOLDER: + case XML_ELEMENT(TEXT, XML_PLACEHOLDER): pContext = - new XMLPlaceholderFieldImportContext( rImport, rHlp, - nPrefix, rName); + new XMLPlaceholderFieldImportContext( rImport, rHlp); break; - case XML_TOK_TEXT_SEQUENCE: + case XML_ELEMENT(TEXT, XML_SEQUENCE): pContext = - new XMLSequenceFieldImportContext( rImport, rHlp, - nPrefix, rName ); + new XMLSequenceFieldImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_TEXT_INPUT: + case XML_ELEMENT(TEXT, XML_TEXT_INPUT): pContext = - new XMLTextInputFieldImportContext( rImport, rHlp, - nPrefix, rName ); + new XMLTextInputFieldImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_EXPRESSION: + case XML_ELEMENT(TEXT, XML_EXPRESSION): pContext = - new XMLExpressionFieldImportContext( rImport, rHlp, - nPrefix, rName ); + new XMLExpressionFieldImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_VARIABLE_SET: + case XML_ELEMENT(TEXT, XML_VARIABLE_SET): pContext = - new XMLVariableSetFieldImportContext( rImport, rHlp, - nPrefix, rName ); + new XMLVariableSetFieldImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_VARIABLE_INPUT: + case XML_ELEMENT(TEXT, XML_VARIABLE_INPUT): pContext = - new XMLVariableInputFieldImportContext( rImport, rHlp, - nPrefix, rName ); + new XMLVariableInputFieldImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_VARIABLE_GET: + case XML_ELEMENT(TEXT, XML_VARIABLE_GET): pContext = - new XMLVariableGetFieldImportContext( rImport, rHlp, - nPrefix, rName ); + new XMLVariableGetFieldImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_USER_FIELD_GET: - pContext = new XMLUserFieldImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_USER_FIELD_GET): + pContext = new XMLUserFieldImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_USER_FIELD_INPUT: - pContext = new XMLUserFieldInputImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_USER_FIELD_INPUT): + pContext = new XMLUserFieldInputImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_TIME: - pContext = new XMLTimeFieldImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_TIME): + pContext = new XMLTimeFieldImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_PAGE_CONTINUATION_STRING: - case XML_TOK_TEXT_PAGE_CONTINUATION: - pContext = new XMLPageContinuationImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_PAGE_CONTINUATION_STRING): + case XML_ELEMENT(TEXT, XML_PAGE_CONTINUATION): + pContext = new XMLPageContinuationImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_PAGE_NUMBER: - pContext = new XMLPageNumberImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_PAGE_NUMBER): + pContext = new XMLPageNumberImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_DATE: - pContext = new XMLDateFieldImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_DATE): + pContext = new XMLDateFieldImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_DATABASE_NAME: - pContext = new XMLDatabaseNameImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_DATABASE_NAME): + pContext = new XMLDatabaseNameImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_DATABASE_NEXT: - pContext = new XMLDatabaseNextImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_DATABASE_NEXT): + pContext = new XMLDatabaseNextImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_DATABASE_SELECT: - pContext = new XMLDatabaseSelectImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_DATABASE_ROW_SELECT): + pContext = new XMLDatabaseSelectImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_DATABASE_ROW_NUMBER: - pContext = new XMLDatabaseNumberImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_DATABASE_ROW_NUMBER): + pContext = new XMLDatabaseNumberImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_DATABASE_DISPLAY: - pContext = new XMLDatabaseDisplayImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_DATABASE_DISPLAY): + pContext = new XMLDatabaseDisplayImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_CONDITIONAL_TEXT: - pContext = new XMLConditionalTextImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_CONDITIONAL_TEXT): + pContext = new XMLConditionalTextImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_HIDDEN_TEXT: - pContext = new XMLHiddenTextImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_HIDDEN_TEXT): + pContext = new XMLHiddenTextImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_HIDDEN_PARAGRAPH: - pContext = new XMLHiddenParagraphImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_HIDDEN_PARAGRAPH): + pContext = new XMLHiddenParagraphImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_DOCUMENT_DESCRIPTION: - case XML_TOK_TEXT_DOCUMENT_TITLE: - case XML_TOK_TEXT_DOCUMENT_SUBJECT: - case XML_TOK_TEXT_DOCUMENT_KEYWORDS: + case XML_ELEMENT(TEXT, XML_DESCRIPTION): + case XML_ELEMENT(TEXT, XML_TITLE): + case XML_ELEMENT(TEXT, XML_SUBJECT): + case XML_ELEMENT(TEXT, XML_KEYWORDS): pContext = new XMLSimpleDocInfoImportContext( rImport, rHlp, - nPrefix, rName, nToken, true, false ); break; - case XML_TOK_TEXT_DOCUMENT_CREATION_AUTHOR: - case XML_TOK_TEXT_DOCUMENT_PRINT_AUTHOR: - case XML_TOK_TEXT_DOCUMENT_SAVE_AUTHOR: + case XML_ELEMENT(TEXT, XML_INITIAL_CREATOR): + case XML_ELEMENT(TEXT, XML_PRINTED_BY): + case XML_ELEMENT(TEXT, XML_CREATOR): pContext = new XMLSimpleDocInfoImportContext( rImport, rHlp, - nPrefix, rName, nToken, false, true ); break; - case XML_TOK_TEXT_DOCUMENT_CREATION_DATE: - case XML_TOK_TEXT_DOCUMENT_CREATION_TIME: - case XML_TOK_TEXT_DOCUMENT_PRINT_DATE: - case XML_TOK_TEXT_DOCUMENT_PRINT_TIME: - case XML_TOK_TEXT_DOCUMENT_SAVE_DATE: - case XML_TOK_TEXT_DOCUMENT_SAVE_TIME: - case XML_TOK_TEXT_DOCUMENT_EDIT_DURATION: + case XML_ELEMENT(TEXT, XML_CREATION_DATE): + case XML_ELEMENT(TEXT, XML_CREATION_TIME): + case XML_ELEMENT(TEXT, XML_PRINT_DATE): + case XML_ELEMENT(TEXT, XML_PRINT_TIME): + case XML_ELEMENT(TEXT, XML_MODIFICATION_DATE): + case XML_ELEMENT(TEXT, XML_MODIFICATION_TIME): + case XML_ELEMENT(TEXT, XML_EDITING_DURATION): pContext = new XMLDateTimeDocInfoImportContext( rImport, rHlp, - nPrefix, rName, nToken ); break; - case XML_TOK_TEXT_DOCUMENT_REVISION: + case XML_ELEMENT(TEXT, XML_EDITING_CYCLES): pContext = new XMLRevisionDocInfoImportContext( rImport, rHlp, - nPrefix, rName, nToken ); break; - case XML_TOK_TEXT_DOCUMENT_USER_DEFINED: + case XML_ELEMENT(TEXT, XML_USER_DEFINED): pContext = new XMLUserDocInfoImportContext( rImport, rHlp, - nPrefix, rName, nToken ); break; - case XML_TOK_TEXT_FILENAME: - pContext = new XMLFileNameImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_FILE_NAME): + pContext = new XMLFileNameImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_CHAPTER: - pContext = new XMLChapterImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_CHAPTER): + pContext = new XMLChapterImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_TEMPLATENAME: - pContext = new XMLTemplateNameImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_TEMPLATE_NAME): + pContext = new XMLTemplateNameImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_WORD_COUNT: - case XML_TOK_TEXT_PARAGRAPH_COUNT: - case XML_TOK_TEXT_TABLE_COUNT: - case XML_TOK_TEXT_CHARACTER_COUNT: - case XML_TOK_TEXT_IMAGE_COUNT: - case XML_TOK_TEXT_OBJECT_COUNT: - case XML_TOK_TEXT_PAGE_COUNT: - pContext = new XMLCountFieldImportContext( rImport, rHlp, - nPrefix, rName, nToken); + case XML_ELEMENT(TEXT, XML_WORD_COUNT): + case XML_ELEMENT(TEXT, XML_PARAGRAPH_COUNT): + case XML_ELEMENT(TEXT, XML_TABLE_COUNT): + case XML_ELEMENT(TEXT, XML_CHARACTER_COUNT): + case XML_ELEMENT(TEXT, XML_IMAGE_COUNT): + case XML_ELEMENT(TEXT, XML_OBJECT_COUNT): + case XML_ELEMENT(TEXT, XML_PAGE_COUNT): + pContext = new XMLCountFieldImportContext( rImport, rHlp, nToken); break; - case XML_TOK_TEXT_GET_PAGE_VAR: - pContext = new XMLPageVarGetFieldImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_PAGE_VARIABLE_GET): + pContext = new XMLPageVarGetFieldImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_SET_PAGE_VAR: - pContext = new XMLPageVarSetFieldImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_PAGE_VARIABLE_SET): + pContext = new XMLPageVarSetFieldImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_MACRO: - pContext = new XMLMacroFieldImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_EXECUTE_MACRO): + pContext = new XMLMacroFieldImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_DDE: - pContext = new XMLDdeFieldImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_DDE_CONNECTION): + pContext = new XMLDdeFieldImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_REFERENCE_REF: - case XML_TOK_TEXT_BOOKMARK_REF: - case XML_TOK_TEXT_NOTE_REF: - case XML_TOK_TEXT_SEQUENCE_REF: - pContext = new XMLReferenceFieldImportContext( rImport, rHlp, - nToken, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_REFERENCE_REF): + case XML_ELEMENT(TEXT, XML_BOOKMARK_REF): + case XML_ELEMENT(TEXT, XML_NOTE_REF): + case XML_ELEMENT(TEXT, XML_SEQUENCE_REF): + pContext = new XMLReferenceFieldImportContext( rImport, rHlp, nToken ); break; - case XML_TOK_TEXT_SHEET_NAME: - pContext = new XMLSheetNameImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_SHEET_NAME): + pContext = new XMLSheetNameImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_PAGE_NAME: - pContext = new XMLPageNameFieldImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_PAGE_NAME): + case XML_ELEMENT(LO_EXT, XML_PAGE_NAME): + pContext = new XMLPageNameFieldImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_BIBLIOGRAPHY_MARK: - pContext = new XMLBibliographyFieldImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_BIBLIOGRAPHY_MARK): + pContext = new XMLBibliographyFieldImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_ANNOTATION: - case XML_TOK_TEXT_ANNOTATION_END: - pContext = new XMLAnnotationImportContext( rImport, rHlp, - nToken, - nPrefix, rName); + case XML_ELEMENT(OFFICE, XML_ANNOTATION): + case XML_ELEMENT(OFFICE, XML_ANNOTATION_END): + pContext = new XMLAnnotationImportContext( rImport, rHlp, nToken); break; - case XML_TOK_TEXT_SCRIPT: - pContext = new XMLScriptImportContext( rImport, rHlp, - nPrefix, rName); + case XML_ELEMENT(TEXT, XML_SCRIPT): + pContext = new XMLScriptImportContext( rImport, rHlp); break; - case XML_TOK_TEXT_MEASURE: - pContext = new XMLMeasureFieldImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_MEASURE): + pContext = new XMLMeasureFieldImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_TABLE_FORMULA: - pContext = new XMLTableFormulaImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_TABLE_FORMULA): + pContext = new XMLTableFormulaImportContext( rImport, rHlp ); break; - case XML_TOK_TEXT_DROP_DOWN: - pContext = new XMLDropDownFieldImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(TEXT, XML_DROP_DOWN): + pContext = new XMLDropDownFieldImportContext( rImport, rHlp ); break; - case XML_TOK_DRAW_HEADER: - pContext = new XMLHeaderFieldImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(PRESENTATION, XML_HEADER): + pContext = new XMLHeaderFieldImportContext( rImport, rHlp ); break; - case XML_TOK_DRAW_FOOTER: - pContext = new XMLFooterFieldImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(PRESENTATION, XML_FOOTER): + pContext = new XMLFooterFieldImportContext( rImport, rHlp ); break; - case XML_TOK_DRAW_DATE_TIME: - pContext = new XMLDateTimeFieldImportContext( rImport, rHlp, - nPrefix, rName ); + case XML_ELEMENT(PRESENTATION, XML_DATE_TIME): + pContext = new XMLDateTimeFieldImportContext( rImport, rHlp ); break; default: @@ -561,9 +479,8 @@ void XMLTextFieldImportContext::ForceUpdate( constexpr OUStringLiteral gsPropertyFieldSubType(u"UserDataType"); XMLSenderFieldImportContext::XMLSenderFieldImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& sLocalName) - : XMLTextFieldImportContext(rImport, rHlp, "ExtendedUser", nPrfx, sLocalName) + SvXMLImport& rImport, XMLTextImportHelper& rHlp) + : XMLTextFieldImportContext(rImport, rHlp, "ExtendedUser") , nSubType(0) , sPropertyFixed(sAPI_is_fixed) , sPropertyContent(sAPI_content) @@ -625,6 +542,7 @@ void XMLSenderFieldImportContext::startFastElement( break; default: bValid = false; + XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); break; } @@ -682,9 +600,8 @@ void XMLSenderFieldImportContext::PrepareField( constexpr OUStringLiteral gsPropertyAuthorFullName(u"FullName"); XMLAuthorFieldImportContext::XMLAuthorFieldImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& sLocalName) -: XMLSenderFieldImportContext(rImport, rHlp, nPrfx, sLocalName) + SvXMLImport& rImport, XMLTextImportHelper& rHlp) +: XMLSenderFieldImportContext(rImport, rHlp) , bAuthorFullName(true) , sPropertyFixed(sAPI_is_fixed) , sPropertyContent(sAPI_content) @@ -757,9 +674,8 @@ SvXMLEnumMapEntry<PageNumberType> const lcl_aSelectPageAttrMap[] = constexpr OUStringLiteral gsPropertyUserText(u"UserText"); XMLPageContinuationImportContext::XMLPageContinuationImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx, - const OUString& sLocalName) -: XMLTextFieldImportContext(rImport, rHlp, sAPI_page_number, nPrfx, sLocalName) + SvXMLImport& rImport, XMLTextImportHelper& rHlp) +: XMLTextFieldImportContext(rImport, rHlp, sAPI_page_number) , sPropertySubType(sAPI_sub_type) , sPropertyNumberingType(sAPI_numbering_type) , eSelectPage(PageNumberType_CURRENT) @@ -813,9 +729,8 @@ void XMLPageContinuationImportContext::PrepareField( XMLPageNumberImportContext::XMLPageNumberImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx, - const OUString& sLocalName) -: XMLTextFieldImportContext(rImport, rHlp, sAPI_page_number, nPrfx, sLocalName) + SvXMLImport& rImport, XMLTextImportHelper& rHlp) +: XMLTextFieldImportContext(rImport, rHlp, sAPI_page_number) , sPropertySubType(sAPI_sub_type) , sPropertyNumberingType(sAPI_numbering_type) , sPropertyOffset(sAPI_offset) @@ -914,9 +829,8 @@ constexpr OUStringLiteral gsPropertyPlaceholderType(u"PlaceHolderType"); constexpr OUStringLiteral gsPropertyPlaceholder(u"PlaceHolder"); XMLPlaceholderFieldImportContext::XMLPlaceholderFieldImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& sLocalName) -: XMLTextFieldImportContext(rImport, rHlp, "JumpEdit", nPrfx, sLocalName) + SvXMLImport& rImport, XMLTextImportHelper& rHlp) +: XMLTextFieldImportContext(rImport, rHlp, "JumpEdit") , sPropertyHint(sAPI_hint) , nPlaceholderType(PlaceholderType::TEXT) { @@ -996,9 +910,8 @@ void XMLPlaceholderFieldImportContext::PrepareField( constexpr OUStringLiteral gsPropertyAdjust(u"Adjust"); XMLTimeFieldImportContext::XMLTimeFieldImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& sLocalName) -: XMLTextFieldImportContext(rImport, rHlp, sAPI_date_time, nPrfx, sLocalName) + SvXMLImport& rImport, XMLTextImportHelper& rHlp) +: XMLTextFieldImportContext(rImport, rHlp, sAPI_date_time) , sPropertyNumberFormat(sAPI_number_format) , sPropertyFixed(sAPI_is_fixed) , sPropertyDateTimeValue(sAPI_date_time_value) @@ -1129,9 +1042,8 @@ void XMLTimeFieldImportContext::PrepareField( XMLDateFieldImportContext::XMLDateFieldImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& sLocalName) : - XMLTimeFieldImportContext(rImport, rHlp, nPrfx, sLocalName) + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : + XMLTimeFieldImportContext(rImport, rHlp) { bIsDate = true; // always a date! } @@ -1164,7 +1076,7 @@ void XMLDateFieldImportContext::ProcessAttribute( break; default: // all others: delegate to super-class - XMLTimeFieldImportContext::ProcessAttribute(nAttrToken, + return XMLTimeFieldImportContext::ProcessAttribute(nAttrToken, sAttrValue); break; } @@ -1182,9 +1094,8 @@ constexpr OUStringLiteral gsPropertyIsVisible(u"IsVisible"); XMLDatabaseFieldImportContext::XMLDatabaseFieldImportContext( SvXMLImport& rImport, XMLTextImportHelper& rHlp, - const char* pServiceName, sal_uInt16 nPrfx, - const OUString& sLocalName, bool bUseDisplay) -: XMLTextFieldImportContext(rImport, rHlp, pServiceName, nPrfx, sLocalName) + const char* pServiceName, bool bUseDisplay) +: XMLTextFieldImportContext(rImport, rHlp, pServiceName) , m_nCommandType( sdb::CommandType::TABLE ) , m_bCommandTypeOK(false) , m_bDisplay( true ) @@ -1308,10 +1219,8 @@ void XMLDatabaseFieldImportContext::PrepareField( XMLDatabaseNameImportContext::XMLDatabaseNameImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& sLocalName) : - XMLDatabaseFieldImportContext(rImport, rHlp, "DatabaseName", - nPrfx, sLocalName, true) + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : + XMLDatabaseFieldImportContext(rImport, rHlp, "DatabaseName", true) { } @@ -1329,10 +1238,8 @@ void XMLDatabaseNameImportContext::ProcessAttribute( XMLDatabaseNextImportContext::XMLDatabaseNextImportContext( SvXMLImport& rImport, XMLTextImportHelper& rHlp, - const char* pServiceName, sal_uInt16 nPrfx, - const OUString& sLocalName) : - XMLDatabaseFieldImportContext(rImport, rHlp, pServiceName, - nPrfx, sLocalName, false), + const char* pServiceName) : + XMLDatabaseFieldImportContext(rImport, rHlp, pServiceName, false), sPropertyCondition(sAPI_condition), sTrue(sAPI_true), sCondition(), @@ -1341,9 +1248,8 @@ XMLDatabaseNextImportContext::XMLDatabaseNextImportContext( } XMLDatabaseNextImportContext::XMLDatabaseNextImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& sLocalName) -: XMLDatabaseFieldImportContext(rImport, rHlp, "DatabaseNextSet", nPrfx, sLocalName, false) + SvXMLImport& rImport, XMLTextImportHelper& rHlp) +: XMLDatabaseFieldImportContext(rImport, rHlp, "DatabaseNextSet", false) , sPropertyCondition(sAPI_condition) , sTrue(sAPI_true) , bConditionOK(false) @@ -1391,10 +1297,8 @@ void XMLDatabaseNextImportContext::PrepareField( XMLDatabaseSelectImportContext::XMLDatabaseSelectImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& sLocalName) : - XMLDatabaseNextImportContext(rImport, rHlp, "DatabaseNumberOfSet", - nPrfx, sLocalName), + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : + XMLDatabaseNextImportContext(rImport, rHlp, "DatabaseNumberOfSet"), sPropertySetNumber(sAPI_set_number), nNumber(0), bNumberOK(false) @@ -1436,10 +1340,8 @@ void XMLDatabaseSelectImportContext::PrepareField( XMLDatabaseNumberImportContext::XMLDatabaseNumberImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& sLocalName) : - XMLDatabaseFieldImportContext(rImport, rHlp, "DatabaseSetNumber", - nPrfx, sLocalName, true), + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : + XMLDatabaseFieldImportContext(rImport, rHlp, "DatabaseSetNumber", true), sPropertyNumberingType( sAPI_numbering_type), sPropertySetNumber(sAPI_set_number), @@ -1505,9 +1407,9 @@ void XMLDatabaseNumberImportContext::PrepareField( XMLSimpleDocInfoImportContext::XMLSimpleDocInfoImportContext( SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& sLocalName, sal_uInt16 nToken, + sal_Int32 nElementToken, bool bContent, bool bAuthor) -: XMLTextFieldImportContext(rImport, rHlp, MapTokenToServiceName(nToken),nPrfx, sLocalName) +: XMLTextFieldImportContext(rImport, rHlp, MapTokenToServiceName(nElementToken) ) , sPropertyFixed(sAPI_is_fixed) , sPropertyContent(sAPI_content) , sPropertyAuthor(sAPI_author) @@ -1577,63 +1479,63 @@ void XMLSimpleDocInfoImportContext::PrepareField( } const char* XMLSimpleDocInfoImportContext::MapTokenToServiceName( - sal_uInt16 nToken) + sal_Int32 nElementToken) { const char* pServiceName = nullptr; - switch(nToken) + switch(nElementToken) { - case XML_TOK_TEXT_DOCUMENT_CREATION_AUTHOR: + case XML_ELEMENT(TEXT, XML_INITIAL_CREATOR): pServiceName = "DocInfo.CreateAuthor"; break; - case XML_TOK_TEXT_DOCUMENT_CREATION_DATE: + case XML_ELEMENT(TEXT, XML_CREATION_DATE): pServiceName = sAPI_docinfo_create_date_time; break; - case XML_TOK_TEXT_DOCUMENT_CREATION_TIME: + case XML_ELEMENT(TEXT, XML_CREATION_TIME): pServiceName = sAPI_docinfo_create_date_time; break; - case XML_TOK_TEXT_DOCUMENT_DESCRIPTION: + case XML_ELEMENT(TEXT, XML_DESCRIPTION): pServiceName = "DocInfo.Description"; break; - case XML_TOK_TEXT_DOCUMENT_EDIT_DURATION: + case XML_ELEMENT(TEXT, XML_EDITING_DURATION): pServiceName = "DocInfo.EditTime"; break; - case XML_TOK_TEXT_DOCUMENT_USER_DEFINED: + case XML_ELEMENT(TEXT, XML_USER_DEFINED): pServiceName = sAPI_docinfo_custom; break; - case XML_TOK_TEXT_DOCUMENT_PRINT_AUTHOR: + case XML_ELEMENT(TEXT, XML_PRINTED_BY): pServiceName = "DocInfo.PrintAuthor"; break; - case XML_TOK_TEXT_DOCUMENT_PRINT_DATE: + case XML_ELEMENT(TEXT, XML_PRINT_DATE): pServiceName = sAPI_docinfo_print_date_time; break; - case XML_TOK_TEXT_DOCUMENT_PRINT_TIME: + case XML_ELEMENT(TEXT, XML_PRINT_TIME): pServiceName = sAPI_docinfo_print_date_time; break; - case XML_TOK_TEXT_DOCUMENT_KEYWORDS: + case XML_ELEMENT(TEXT, XML_KEYWORDS): pServiceName = "DocInfo.KeyWords"; break; - case XML_TOK_TEXT_DOCUMENT_SUBJECT: + case XML_ELEMENT(TEXT, XML_SUBJECT): pServiceName = "DocInfo.Subject"; break; - case XML_TOK_TEXT_DOCUMENT_REVISION: + case XML_ELEMENT(TEXT, XML_EDITING_CYCLES): pServiceName = "DocInfo.Revision"; break; - case XML_TOK_TEXT_DOCUMENT_SAVE_AUTHOR: + case XML_ELEMENT(TEXT, XML_CREATOR): pServiceName = "DocInfo.ChangeAuthor"; break; - case XML_TOK_TEXT_DOCUMENT_SAVE_DATE: + case XML_ELEMENT(TEXT, XML_MODIFICATION_DATE): pServiceName = sAPI_docinfo_change_date_time; break; - case XML_TOK_TEXT_DOCUMENT_SAVE_TIME: + case XML_ELEMENT(TEXT, XML_MODIFICATION_TIME): pServiceName = sAPI_docinfo_change_date_time; break; - case XML_TOK_TEXT_DOCUMENT_TITLE: + case XML_ELEMENT(TEXT, XML_TITLE): pServiceName = "DocInfo.Title"; break; default: - OSL_FAIL("no docinfo field token"); + XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElementToken); pServiceName = nullptr; break; } @@ -1647,10 +1549,8 @@ const char* XMLSimpleDocInfoImportContext::MapTokenToServiceName( constexpr OUStringLiteral sPropertyRevision(u"Revision"); XMLRevisionDocInfoImportContext::XMLRevisionDocInfoImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx, - const OUString& sLocalName, sal_uInt16 nToken) : - XMLSimpleDocInfoImportContext(rImport, rHlp, nPrfx, sLocalName, - nToken, false, false) + SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_Int32 nElement) : + XMLSimpleDocInfoImportContext(rImport, rHlp, nElement, false, false) { bValid = true; } @@ -1685,9 +1585,8 @@ void XMLRevisionDocInfoImportContext::PrepareField( XMLDateTimeDocInfoImportContext::XMLDateTimeDocInfoImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx, - const OUString& sLocalName, sal_uInt16 nToken) - : XMLSimpleDocInfoImportContext(rImport, rHlp, nPrfx, sLocalName,nToken, false, false) + SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_Int32 nElement) + : XMLSimpleDocInfoImportContext(rImport, rHlp, nElement, false, false) , sPropertyNumberFormat(sAPI_number_format) , sPropertyIsDate(sAPI_is_date) , sPropertyIsFixedLanguage(sAPI_is_fixed_language) @@ -1702,27 +1601,27 @@ XMLDateTimeDocInfoImportContext::XMLDateTimeDocInfoImportContext( // because times and time durations are presented differently! bValid = true; - switch (nToken) + switch (nElement) { - case XML_TOK_TEXT_DOCUMENT_CREATION_DATE: - case XML_TOK_TEXT_DOCUMENT_PRINT_DATE: - case XML_TOK_TEXT_DOCUMENT_SAVE_DATE: + case XML_ELEMENT(TEXT, XML_CREATION_DATE): + case XML_ELEMENT(TEXT, XML_PRINT_DATE): + case XML_ELEMENT(TEXT, XML_MODIFICATION_DATE): bIsDate = true; bHasDateTime = true; break; - case XML_TOK_TEXT_DOCUMENT_CREATION_TIME: - case XML_TOK_TEXT_DOCUMENT_PRINT_TIME: - case XML_TOK_TEXT_DOCUMENT_SAVE_TIME: + case XML_ELEMENT(TEXT, XML_CREATION_TIME): + case XML_ELEMENT(TEXT, XML_PRINT_TIME): + case XML_ELEMENT(TEXT, XML_MODIFICATION_TIME): bIsDate = false; bHasDateTime = true; break; - case XML_TOK_TEXT_DOCUMENT_EDIT_DURATION: + case XML_ELEMENT(TEXT, XML_EDITING_DURATION): bIsDate = false; bHasDateTime = false; break; default: - OSL_FAIL( - "XMLDateTimeDocInfoImportContext needs date/time doc. fields"); + XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); + OSL_FAIL("XMLDateTimeDocInfoImportContext needs date/time doc. fields"); bValid = false; break; } @@ -1787,10 +1686,8 @@ void XMLDateTimeDocInfoImportContext::PrepareField( XMLUserDocInfoImportContext::XMLUserDocInfoImportContext( SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& sLocalName, sal_uInt16 nToken) : - XMLSimpleDocInfoImportContext(rImport, rHlp, nPrfx, - sLocalName, nToken, - false, false) + sal_Int32 nElement) : + XMLSimpleDocInfoImportContext(rImport, rHlp, nElement, false, false) , sPropertyName(sAPI_name) , sPropertyNumberFormat(sAPI_number_format) , sPropertyIsFixedLanguage(sAPI_is_fixed_language) @@ -1866,10 +1763,8 @@ void XMLUserDocInfoImportContext::PrepareField( XMLHiddenParagraphImportContext::XMLHiddenParagraphImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& sLocalName) : - XMLTextFieldImportContext(rImport, rHlp, "HiddenParagraph", - nPrfx, sLocalName), + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : + XMLTextFieldImportContext(rImport, rHlp, "HiddenParagraph"), sPropertyCondition(sAPI_condition), sPropertyIsHidden(sAPI_is_hidden), sCondition(), @@ -1921,10 +1816,8 @@ constexpr OUStringLiteral gsPropertyFalseContent(u"FalseContent"); constexpr OUStringLiteral gsPropertyIsConditionTrue(u"IsConditionTrue"); XMLConditionalTextImportContext::XMLConditionalTextImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& sLocalName) : - XMLTextFieldImportContext(rImport, rHlp, "ConditionalText", - nPrfx, sLocalName), + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : + XMLTextFieldImportContext(rImport, rHlp, "ConditionalText"), sPropertyCondition(sAPI_condition), sPropertyCurrentPresentation(sAPI_current_presentation), bConditionOK(false), @@ -1993,10 +1886,8 @@ void XMLConditionalTextImportContext::PrepareField( XMLHiddenTextImportContext::XMLHiddenTextImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& sLocalName) : - XMLTextFieldImportContext(rImport, rHlp, "HiddenText", - nPrfx, sLocalName), + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : + XMLTextFieldImportContext(rImport, rHlp, "HiddenText"), sPropertyCondition(sAPI_condition), sPropertyContent(sAPI_content), sPropertyIsHidden(sAPI_is_hidden), @@ -2069,10 +1960,8 @@ const SvXMLEnumMapEntry<sal_uInt16> aFilenameDisplayMap[] = }; XMLFileNameImportContext::XMLFileNameImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx, - const OUString& sLocalName) : - XMLTextFieldImportContext(rImport, rHlp, "FileName", - nPrfx, sLocalName), + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : + XMLTextFieldImportContext(rImport, rHlp, "FileName"), sPropertyFixed(sAPI_is_fixed), sPropertyFileFormat(sAPI_file_format), sPropertyCurrentPresentation( @@ -2155,10 +2044,8 @@ const SvXMLEnumMapEntry<sal_uInt16> aTemplateDisplayMap[] = XMLTemplateNameImportContext::XMLTemplateNameImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx, - const OUString& sLocalName) : - XMLTextFieldImportContext(rImport, rHlp, "TemplateName", - nPrfx, sLocalName), + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : + XMLTextFieldImportContext(rImport, rHlp, "TemplateName"), sPropertyFileFormat(sAPI_file_format), nFormat(TemplateDisplayFormat::FULL) { @@ -2212,10 +2099,8 @@ constexpr OUStringLiteral gsPropertyChapterFormat(u"ChapterFormat"); constexpr OUStringLiteral gsPropertyLevel(u"Level"); XMLChapterImportContext::XMLChapterImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& sLocalName) : - XMLTextFieldImportContext(rImport, rHlp, "Chapter", - nPrfx, sLocalName), + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : + XMLTextFieldImportContext(rImport, rHlp, "Chapter"), nFormat(ChapterFormat::NAME_NUMBER), nLevel(0) { @@ -2272,9 +2157,8 @@ void XMLChapterImportContext::PrepareField( XMLCountFieldImportContext::XMLCountFieldImportContext( SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& sLocalName, sal_uInt16 nToken) : - XMLTextFieldImportContext(rImport, rHlp, MapTokenToServiceName(nToken), - nPrfx, sLocalName), + sal_Int32 nElement) : + XMLTextFieldImportContext(rImport, rHlp, MapTokenToServiceName(nElement)), sPropertyNumberingType( sAPI_numbering_type), sNumberFormat(), @@ -2326,34 +2210,35 @@ void XMLCountFieldImportContext::PrepareField( } const char* XMLCountFieldImportContext::MapTokenToServiceName( - sal_uInt16 nToken) + sal_Int32 nElement) { const char* pServiceName = nullptr; - switch (nToken) + switch (nElement) { - case XML_TOK_TEXT_WORD_COUNT: + case XML_ELEMENT(TEXT, XML_WORD_COUNT): pServiceName = "WordCount"; break; - case XML_TOK_TEXT_PARAGRAPH_COUNT: + case XML_ELEMENT(TEXT, XML_PARAGRAPH_COUNT): pServiceName = "ParagraphCount"; break; - case XML_TOK_TEXT_TABLE_COUNT: + case XML_ELEMENT(TEXT, XML_TABLE_COUNT): pServiceName = "TableCount"; break; - case XML_TOK_TEXT_CHARACTER_COUNT: + case XML_ELEMENT(TEXT, XML_CHARACTER_COUNT): pServiceName = "CharacterCount"; break; - case XML_TOK_TEXT_IMAGE_COUNT: + case XML_ELEMENT(TEXT, XML_IMAGE_COUNT): pServiceName = "GraphicObjectCount"; break; - case XML_TOK_TEXT_OBJECT_COUNT: + case XML_ELEMENT(TEXT, XML_OBJECT_COUNT): pServiceName = "EmbeddedObjectCount"; break; - case XML_TOK_TEXT_PAGE_COUNT: + case XML_ELEMENT(TEXT, XML_PAGE_COUNT): pServiceName = "PageCount"; break; default: + XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); pServiceName = nullptr; OSL_FAIL("unknown count field!"); break; @@ -2367,10 +2252,8 @@ const char* XMLCountFieldImportContext::MapTokenToServiceName( XMLPageVarGetFieldImportContext::XMLPageVarGetFieldImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& sLocalName) : - XMLTextFieldImportContext(rImport, rHlp, "ReferencePageGet", - nPrfx, sLocalName), + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : + XMLTextFieldImportContext(rImport, rHlp, "ReferencePageGet"), sNumberFormat(), sLetterSync(), bNumberFormatOK(false) @@ -2420,10 +2303,8 @@ void XMLPageVarGetFieldImportContext::PrepareField( XMLPageVarSetFieldImportContext::XMLPageVarSetFieldImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx, - const OUString& sLocalName) : - XMLTextFieldImportContext(rImport, rHlp, "ReferencePageSet", - nPrfx, sLocalName), + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : + XMLTextFieldImportContext(rImport, rHlp, "ReferencePageSet"), nAdjust(0), bActive(true) { @@ -2472,10 +2353,8 @@ void XMLPageVarSetFieldImportContext::PrepareField( XMLMacroFieldImportContext::XMLMacroFieldImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx, - const OUString& sLocalName) : - XMLTextFieldImportContext(rImport, rHlp, "Macro", - nPrfx, sLocalName), + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : + XMLTextFieldImportContext(rImport, rHlp, "Macro"), bDescriptionOK(false) { } @@ -2589,8 +2468,8 @@ void XMLMacroFieldImportContext::PrepareField( XMLReferenceFieldImportContext::XMLReferenceFieldImportContext( SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nToken, sal_uInt16 nPrfx, const OUString& sLocalName) -: XMLTextFieldImportContext(rImport, rHlp, "GetReference", nPrfx, sLocalName) + sal_Int32 nToken) +: XMLTextFieldImportContext(rImport, rHlp, "GetReference") , nElementToken(nToken) , nSource(0) , nType(ReferenceFieldPart::PAGE_DESC) @@ -2622,21 +2501,21 @@ void XMLReferenceFieldImportContext::startFastElement( bTypeOK = true; switch (nElementToken) { - case XML_TOK_TEXT_REFERENCE_REF: + case XML_ELEMENT(TEXT, XML_REFERENCE_REF): nSource = ReferenceFieldSource::REFERENCE_MARK; break; - case XML_TOK_TEXT_BOOKMARK_REF: + case XML_ELEMENT(TEXT, XML_BOOKMARK_REF): nSource = ReferenceFieldSource::BOOKMARK; break; - case XML_TOK_TEXT_NOTE_REF: + case XML_ELEMENT(TEXT, XML_NOTE_REF): nSource = ReferenceFieldSource::FOOTNOTE; break; - case XML_TOK_TEXT_SEQUENCE_REF: + case XML_ELEMENT(TEXT, XML_SEQUENCE_REF): nSource = ReferenceFieldSource::SEQUENCE_FIELD; break; default: + XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElementToken); bTypeOK = false; - OSL_FAIL("unknown reference field"); break; } @@ -2668,7 +2547,7 @@ void XMLReferenceFieldImportContext::ProcessAttribute( } // check for sequence-only-attributes - if ( (XML_TOK_TEXT_SEQUENCE_REF != nElementToken) && + if ( (XML_ELEMENT(TEXT, XML_SEQUENCE_REF) != nElementToken) && ( (nType == ReferenceFieldPart::CATEGORY_AND_NUMBER) || (nType == ReferenceFieldPart::ONLY_CAPTION) || (nType == ReferenceFieldPart::ONLY_SEQUENCE_NUMBER) ) ) @@ -2700,16 +2579,16 @@ void XMLReferenceFieldImportContext::PrepareField( xPropertySet->setPropertyValue("ReferenceFieldLanguage", Any(sLanguage)); switch (nElementToken) { - case XML_TOK_TEXT_REFERENCE_REF: - case XML_TOK_TEXT_BOOKMARK_REF: + case XML_ELEMENT(TEXT, XML_REFERENCE_REF): + case XML_ELEMENT(TEXT, XML_BOOKMARK_REF): xPropertySet->setPropertyValue("SourceName", Any(sName)); break; - case XML_TOK_TEXT_NOTE_REF: + case XML_ELEMENT(TEXT, XML_NOTE_REF): GetImportHelper().ProcessFootnoteReference(sName, xPropertySet); break; - case XML_TOK_TEXT_SEQUENCE_REF: + case XML_ELEMENT(TEXT, XML_SEQUENCE_REF): GetImportHelper().ProcessSequenceReference(sName, xPropertySet); break; } @@ -2744,9 +2623,8 @@ const SvXMLTokenMapEntry aDdeDeclAttrTokenMap[] = }; -XMLDdeFieldDeclsImportContext::XMLDdeFieldDeclsImportContext( - SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& sLocalName) : - SvXMLImportContext(rImport, nPrfx, sLocalName) +XMLDdeFieldDeclsImportContext::XMLDdeFieldDeclsImportContext(SvXMLImport& rImport) : + SvXMLImportContext(rImport) { } @@ -2879,10 +2757,8 @@ void XMLDdeFieldDeclImportContext::startFastElement( XMLDdeFieldImportContext::XMLDdeFieldImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& sLocalName) : - XMLTextFieldImportContext(rImport, rHlp, sAPI_dde, - nPrfx, sLocalName), + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : + XMLTextFieldImportContext(rImport, rHlp, sAPI_dde), sName() ,sPropertyContent(sAPI_content) { @@ -2958,11 +2834,8 @@ void XMLDdeFieldImportContext::PrepareField( XMLSheetNameImportContext::XMLSheetNameImportContext( SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName) : - XMLTextFieldImportContext(rImport, rHlp, "SheetName", - nPrfx, sLocalName) + XMLTextImportHelper& rHlp) : + XMLTextFieldImportContext(rImport, rHlp, "SheetName") { bValid = true; // always valid! } @@ -2985,10 +2858,8 @@ void XMLSheetNameImportContext::PrepareField( XMLPageNameFieldImportContext::XMLPageNameFieldImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& sLocalName) /// element name w/o prefix -: XMLTextFieldImportContext(rImport, rHlp, "PageName", nPrfx, sLocalName ) + XMLTextImportHelper& rHlp) /// Text import helper +: XMLTextFieldImportContext(rImport, rHlp, "PageName" ) { bValid = true; } @@ -3055,11 +2926,8 @@ void XMLUrlFieldImportContext::PrepareField( XMLBibliographyFieldImportContext::XMLBibliographyFieldImportContext( SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName) : - XMLTextFieldImportContext(rImport, rHlp, "Bibliography", - nPrfx, sLocalName), + XMLTextImportHelper& rHlp) : + XMLTextFieldImportContext(rImport, rHlp, "Bibliography"), aValues() { bValid = true; @@ -3106,15 +2974,16 @@ void XMLBibliographyFieldImportContext::startFastElement( { if (IsTokenInNamespace(aIter.getToken(), XML_NAMESPACE_TEXT)) { + auto nToken = aIter.getToken() & TOKEN_MASK; PropertyValue aValue; aValue.Name = OUString::createFromAscii( - MapBibliographyFieldName(SvXMLImport::getNameFromToken(aIter.getToken()))); + MapBibliographyFieldName(nToken)); Any aAny; // special treatment for bibliography type // biblio vs bibilio: #96658#; also read old documents - if ((aIter.getToken() & TOKEN_MASK) == XML_BIBILIOGRAPHIC_TYPE || - (aIter.getToken() & TOKEN_MASK) == XML_BIBLIOGRAPHY_TYPE ) + if (nToken == XML_BIBILIOGRAPHIC_TYPE || + nToken == XML_BIBLIOGRAPHY_TYPE ) { sal_uInt16 nTmp; if (SvXMLUnitConverter::convertEnum( @@ -3303,6 +3172,114 @@ const char* XMLBibliographyFieldImportContext::MapBibliographyFieldName( return pName; } +const char* XMLBibliographyFieldImportContext::MapBibliographyFieldName( + sal_Int32 nElement) +{ + const char* pName = nullptr; + + switch (nElement & TOKEN_MASK) + { + case XML_IDENTIFIER: + pName = "Identifier"; + break; + case XML_BIBILIOGRAPHIC_TYPE: + case XML_BIBLIOGRAPHY_TYPE: + // biblio... vs bibilio...: #96658#: also read old documents + pName = "BibiliographicType"; + break; + case XML_ADDRESS: + pName = "Address"; + break; + case XML_ANNOTE: + pName = "Annote"; + break; + case XML_AUTHOR: + pName = "Author"; + break; + case XML_BOOKTITLE: + pName = "Booktitle"; + break; + case XML_CHAPTER: + pName = "Chapter"; + break; + case XML_EDITION: + pName = "Edition"; + break; + case XML_EDITOR: + pName = "Editor"; + break; + case XML_HOWPUBLISHED: + pName = "Howpublished"; + break; + case XML_INSTITUTION: + pName = "Institution"; + break; + case XML_JOURNAL: + pName = "Journal"; + break; + case XML_MONTH: + pName = "Month"; + break; + case XML_NOTE: + pName = "Note"; + break; + case XML_NUMBER: + pName = "Number"; + break; + case XML_ORGANIZATIONS: + pName = "Organizations"; + break; + case XML_PAGES: + pName = "Pages"; + break; + case XML_PUBLISHER: + pName = "Publisher"; + break; + case XML_SCHOOL: + pName = "School"; + break; + case XML_SERIES: + pName = "Series"; + break; + case XML_TITLE: + pName = "Title"; + break; + case XML_REPORT_TYPE: + pName = "Report_Type"; + break; + case XML_VOLUME: + pName = "Volume"; + break; + case XML_YEAR: + pName = "Year"; + break; + case XML_URL: + pName = "URL"; + break; + case XML_CUSTOM1: + pName = "Custom1"; + break; + case XML_CUSTOM2: + pName = "Custom2"; + break; + case XML_CUSTOM3: + pName = "Custom3"; + break; + case XML_CUSTOM4: + pName = "Custom4"; + break; + case XML_CUSTOM5: + pName = "Custom5"; + break; + case XML_ISBN: + pName = "ISBN"; + break; + default: + assert(false && "Unknown bibliography info data"); + pName = nullptr; + } + return pName; +} // Annotation Field @@ -3310,12 +3287,9 @@ const char* XMLBibliographyFieldImportContext::MapBibliographyFieldName( XMLAnnotationImportContext::XMLAnnotationImportContext( SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nToken, - sal_uInt16 nPrfx, - const OUString& sLocalName) : - XMLTextFieldImportContext(rImport, rHlp, "Annotation", - nPrfx, sLocalName), - m_nToken(nToken) + sal_Int32 nElement) : + XMLTextFieldImportContext(rImport, rHlp, "Annotation"), + mnElement(nElement) { bValid = true; @@ -3384,7 +3358,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLAnnotationImportCon return new XMLStringBufferImportContext(GetImport(), aTextBuffer); } -void XMLAnnotationImportContext::endFastElement(sal_Int32 ) +void XMLAnnotationImportContext::endFastElement(sal_Int32 /*nElement*/) { DBG_ASSERT(!GetServiceName().isEmpty(), "no service name for element!"); if( mxCursor.is() ) @@ -3406,7 +3380,7 @@ void XMLAnnotationImportContext::endFastElement(sal_Int32 ) if ( bValid ) { - if ( m_nToken == XML_TOK_TEXT_ANNOTATION_END ) + if ( mnElement == XML_ELEMENT(OFFICE, XML_ANNOTATION_END) ) { // Search for a previous annotation with the same name. uno::Reference< text::XTextContent > xPrevField; @@ -3519,10 +3493,8 @@ void XMLAnnotationImportContext::PrepareField( XMLScriptImportContext::XMLScriptImportContext( SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName) -: XMLTextFieldImportContext(rImport, rHlp, "Script", nPrfx, sLocalName) + XMLTextImportHelper& rHlp) +: XMLTextFieldImportContext(rImport, rHlp, "Script") , bContentOK(false) { } @@ -3574,11 +3546,8 @@ void XMLScriptImportContext::PrepareField( XMLMeasureFieldImportContext::XMLMeasureFieldImportContext( SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName) : - XMLTextFieldImportContext(rImport, rHlp, "Measure", - nPrfx, sLocalName), + XMLTextImportHelper& rHlp) : + XMLTextFieldImportContext(rImport, rHlp, "Measure"), mnKind( 0 ) { } @@ -3620,11 +3589,8 @@ void XMLMeasureFieldImportContext::PrepareField( XMLDropDownFieldImportContext::XMLDropDownFieldImportContext( SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName) : - XMLTextFieldImportContext( rImport, rHlp, "DropDown", - nPrfx, sLocalName ), + XMLTextImportHelper& rHlp) : + XMLTextFieldImportContext( rImport, rHlp, "DropDown" ), aLabels(), sName(), nSelected( -1 ), @@ -3747,10 +3713,8 @@ void XMLDropDownFieldImportContext::PrepareField( XMLHeaderFieldImportContext::XMLHeaderFieldImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& sLocalName) /// element name w/o prefix -: XMLTextFieldImportContext(rImport, rHlp, "Header", nPrfx, sLocalName ) + XMLTextImportHelper& rHlp) /// Text import helper +: XMLTextFieldImportContext(rImport, rHlp, "Header" ) { sServicePrefix = sAPI_presentation_prefix; bValid = true; @@ -3771,10 +3735,8 @@ void XMLHeaderFieldImportContext::PrepareField(const Reference<XPropertySet> &) XMLFooterFieldImportContext::XMLFooterFieldImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& sLocalName) /// element name w/o prefix -: XMLTextFieldImportContext(rImport, rHlp, "Footer", nPrfx, sLocalName ) + XMLTextImportHelper& rHlp) /// Text import helper +: XMLTextFieldImportContext(rImport, rHlp, "Footer" ) { sServicePrefix = sAPI_presentation_prefix; bValid = true; @@ -3796,10 +3758,8 @@ void XMLFooterFieldImportContext::PrepareField(const Reference<XPropertySet> &) XMLDateTimeFieldImportContext::XMLDateTimeFieldImportContext( SvXMLImport& rImport, /// XML Import - XMLTextImportHelper& rHlp, /// Text import helper - sal_uInt16 nPrfx, /// namespace prefix - const OUString& sLocalName) /// element name w/o prefix -: XMLTextFieldImportContext(rImport, rHlp, "DateTime", nPrfx, sLocalName ) + XMLTextImportHelper& rHlp) /// Text import helper +: XMLTextFieldImportContext(rImport, rHlp, "DateTime" ) { sServicePrefix = sAPI_presentation_prefix; bValid = true; diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index e2ec5dc280b6..fea37cb2ba50 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -2135,132 +2135,82 @@ void XMLTextImportHelper::SetAutoStyles( SvXMLStylesContext *pStyles ) SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( SvXMLImport& rImport, - sal_Int32 Element, - const Reference< XFastAttributeList > & Attribs, - XMLTextType eType ) -{ - // fall back to slow-parser path - const OUString& rPrefix = SvXMLImport::getNamespacePrefixFromToken(Element, &GetXMLImport().GetNamespaceMap()); - const OUString& rLocalName = SvXMLImport::getNameFromToken( Element ); - OUString aName = rPrefix.isEmpty() ? rLocalName : rPrefix + SvXMLImport::aNamespaceSeparator + rLocalName; - OUString aLocalName; - sal_uInt16 nPrefix = - GetXMLImport().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, &GetXMLImport().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 CreateTextChildContext(rImport, nPrefix, aLocalName, maAttrList.get(), eType ); -} - -SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( - SvXMLImport& rImport, - sal_uInt16 nPrefix, const OUString& rLocalName, - const Reference< XAttributeList > & xAttrList, + sal_Int32 nElement, + const Reference< XFastAttributeList > & xAttrList, XMLTextType eType ) { SvXMLImportContext *pContext = nullptr; - const SvXMLTokenMap& rTokenMap = GetTextElemTokenMap(); - bool bHeading = false; bool bContent = true; - sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName ); - switch( nToken ) + switch( nElement ) { - case XML_TOK_TEXT_H: - bHeading = true; - [[fallthrough]]; - case XML_TOK_TEXT_P: + case XML_ELEMENT(TEXT, XML_H): + case XML_ELEMENT(TEXT, XML_P): + case XML_ELEMENT(LO_EXT, XML_P): pContext = new XMLParaContext( rImport, - nPrefix, rLocalName, - xAttrList, bHeading ); + nElement, + xAttrList ); if (m_xImpl->m_bProgress && XMLTextType::Shape != eType) { rImport.GetProgressBarHelper()->Increment(); } break; - case XML_TOK_TEXT_NUMBERED_PARAGRAPH: + // #i52127# + case XML_ELEMENT(TEXT, XML_NUMBERED_PARAGRAPH): pContext = new XMLNumberedParaContext( - rImport, nPrefix, rLocalName, xAttrList ); + rImport, nElement, xAttrList ); break; - case XML_TOK_TEXT_LIST: + break; + case XML_ELEMENT(TEXT, XML_LIST): pContext = new XMLTextListBlockContext( rImport, *this, - nPrefix, rLocalName, xAttrList ); break; - case XML_TOK_TABLE_TABLE: + case XML_ELEMENT(TABLE,XML_TABLE): + case XML_ELEMENT(LO_EXT, XML_TABLE): if( XMLTextType::Body == eType || XMLTextType::TextBox == eType || XMLTextType::Section == eType || XMLTextType::HeaderFooter == eType || XMLTextType::ChangedRegion == eType || XMLTextType::Cell == eType ) - pContext = CreateTableChildContext( rImport, nPrefix, rLocalName, - xAttrList ); + pContext = CreateTableChildContext( rImport, nElement, xAttrList ); break; - case XML_TOK_TEXT_SEQUENCE_DECLS: + case XML_ELEMENT(TEXT, XML_SEQUENCE_DECLS): if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted) || XMLTextType::HeaderFooter == eType ) { pContext = new XMLVariableDeclsImportContext( - rImport, *this, nPrefix, rLocalName, VarTypeSequence); + rImport, *this, VarTypeSequence); bContent = false; } break; - - case XML_TOK_TEXT_VARFIELD_DECLS: + case XML_ELEMENT(TEXT, XML_VARIABLE_DECLS): if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted) || XMLTextType::HeaderFooter == eType ) { pContext = new XMLVariableDeclsImportContext( - rImport, *this, nPrefix, rLocalName, VarTypeSimple); + rImport, *this, VarTypeSimple); bContent = false; } break; - - case XML_TOK_TEXT_USERFIELD_DECLS: + case XML_ELEMENT(TEXT, XML_USER_FIELD_DECLS): if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted)|| XMLTextType::HeaderFooter == eType ) { pContext = new XMLVariableDeclsImportContext( - rImport, *this, nPrefix, rLocalName, VarTypeUserField); + rImport, *this, VarTypeUserField); bContent = false; } break; - - case XML_TOK_TEXT_DDE_DECLS: + case XML_ELEMENT(TEXT, XML_DDE_CONNECTION_DECLS): if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted) || XMLTextType::HeaderFooter == eType ) { - pContext = new XMLDdeFieldDeclsImportContext( - rImport, nPrefix, rLocalName); + pContext = new XMLDdeFieldDeclsImportContext(rImport); bContent = false; } break; - - case XML_TOK_TEXT_FRAME_PAGE: + case XML_ELEMENT(DRAW, XML_FRAME): if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted) || XMLTextType::TextBox == eType || XMLTextType::ChangedRegion == eType ) @@ -2273,8 +2223,7 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( bContent = false; } break; - - case XML_TOK_DRAW_A_PAGE: + case XML_ELEMENT(DRAW, XML_A): if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted) || XMLTextType::TextBox == eType || XMLTextType::ChangedRegion == eType) @@ -2282,65 +2231,57 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( TextContentAnchorType eAnchorType = XMLTextType::TextBox == eType ? TextContentAnchorType_AT_FRAME : TextContentAnchorType_AT_PAGE; - pContext = new XMLTextFrameHyperlinkContext( rImport, nPrefix, - rLocalName, xAttrList, + pContext = new XMLTextFrameHyperlinkContext( rImport, nElement, + xAttrList, eAnchorType ); bContent = false; } break; - - case XML_TOK_TEXT_INDEX_TITLE: - case XML_TOK_TEXT_SECTION: + case XML_ELEMENT(TEXT, XML_INDEX_TITLE): + case XML_ELEMENT(TEXT, XML_SECTION): pContext = new XMLSectionImportContext( rImport ); break; - - case XML_TOK_TEXT_TOC: - case XML_TOK_TEXT_OBJECT_INDEX: - case XML_TOK_TEXT_TABLE_INDEX: - case XML_TOK_TEXT_ILLUSTRATION_INDEX: - case XML_TOK_TEXT_USER_INDEX: - case XML_TOK_TEXT_ALPHABETICAL_INDEX: - case XML_TOK_TEXT_BIBLIOGRAPHY_INDEX: + case XML_ELEMENT(TEXT, XML_TABLE_OF_CONTENT): + case XML_ELEMENT(TEXT, XML_OBJECT_INDEX): + case XML_ELEMENT(TEXT, XML_TABLE_INDEX): + case XML_ELEMENT(TEXT, XML_ILLUSTRATION_INDEX): + case XML_ELEMENT(TEXT, XML_USER_INDEX): + case XML_ELEMENT(TEXT, XML_ALPHABETICAL_INDEX): + case XML_ELEMENT(TEXT, XML_BIBLIOGRAPHY): if( XMLTextType::Shape != eType ) - pContext = new XMLIndexTOCContext( rImport, nPrefix, rLocalName ); + pContext = new XMLIndexTOCContext( rImport, nElement ); break; - - case XML_TOK_TEXT_TRACKED_CHANGES: - pContext = new XMLTrackedChangesImportContext( rImport, nPrefix, - rLocalName); + case XML_ELEMENT(TEXT, XML_TRACKED_CHANGES): + pContext = new XMLTrackedChangesImportContext( rImport ); bContent = false; break; - - case XML_TOK_TEXT_CHANGE: - case XML_TOK_TEXT_CHANGE_START: - case XML_TOK_TEXT_CHANGE_END: + case XML_ELEMENT(TEXT, XML_CHANGE): + case XML_ELEMENT(TEXT, XML_CHANGE_START): + case XML_ELEMENT(TEXT, XML_CHANGE_END): pContext = new XMLChangeImportContext( rImport, - ((nToken == XML_TOK_TEXT_CHANGE_END) + ((nElement == XML_ELEMENT(TEXT, XML_CHANGE_END)) ? XMLChangeImportContext::Element::END - : (nToken == XML_TOK_TEXT_CHANGE_START) + : (nElement == XML_ELEMENT(TEXT, XML_CHANGE_START)) ? XMLChangeImportContext::Element::START : XMLChangeImportContext::Element::POINT), true); break; - - case XML_TOK_TEXT_FORMS: + case XML_ELEMENT(OFFICE, XML_FORMS): pContext = xmloff::OFormLayerXMLImport::createOfficeFormsContext(rImport); bContent = false; break; - - case XML_TOK_TEXT_AUTOMARK: + case XML_ELEMENT(TEXT, XML_ALPHABETICAL_INDEX_AUTO_MARK_FILE): if( XMLTextType::Body == eType ) { - pContext = new XMLAutoMarkFileContext(rImport, nPrefix,rLocalName); + pContext = new XMLAutoMarkFileContext(rImport); } bContent = false; break; - - case XML_TOK_TEXT_CALCULATION_SETTINGS: - pContext = new XMLCalculationSettingsContext ( rImport, nPrefix, rLocalName, xAttrList); + case XML_ELEMENT(TABLE, XML_CALCULATION_SETTINGS): + pContext = new XMLCalculationSettingsContext ( rImport, nElement, xAttrList); bContent = false; - break; + break; default: if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted) || @@ -2348,16 +2289,16 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( XMLTextType::ChangedRegion == eType ) { Reference < XShapes > xShapes; - pContext = rImport.GetShapeImport()->CreateGroupChildContext( - rImport, nPrefix, rLocalName, xAttrList, xShapes ); + pContext = XMLShapeImportHelper::CreateGroupChildContext( + rImport, nElement, xAttrList, xShapes ); bContent = false; } } // handle open redlines - if ( (XML_TOK_TEXT_CHANGE != nToken) && - (XML_TOK_TEXT_CHANGE_END != nToken) && - (XML_TOK_TEXT_CHANGE_START != nToken) ) + if ( (XML_ELEMENT(TEXT, XML_CHANGE) != nElement) && + (XML_ELEMENT(TEXT, XML_CHANGE_END) != nElement) && + (XML_ELEMENT(TEXT, XML_CHANGE_START) != nElement) ) { // ResetOpenRedlineId(); } @@ -2367,15 +2308,19 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( m_xImpl->m_bBodyContentStarted = false; } - if( nToken != XML_TOK_TEXT_FRAME_PAGE ) + if( nElement != XML_ELEMENT(DRAW, XML_FRAME) ) ClearLastImportedTextFrameName(); + + if (!pContext) + XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); + return pContext; } SvXMLImportContext *XMLTextImportHelper::CreateTableChildContext( SvXMLImport&, - sal_uInt16 /*nPrefix*/, const OUString& /*rLocalName*/, - const Reference< XAttributeList > & ) + sal_Int32 /*nElement*/, + const Reference< XFastAttributeList > & ) { return nullptr; } diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx index 1c12e952cc73..aee55e50ae6c 100644 --- a/xmloff/source/text/txtparai.cxx +++ b/xmloff/source/text/txtparai.cxx @@ -105,43 +105,6 @@ public: } }; -XMLCharContext::XMLCharContext( - SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const Reference< xml::sax::XAttributeList > & xAttrList, - sal_Unicode c, - bool bCount ) : - SvXMLImportContext( rImport, nPrfx, rLName ) - ,m_nControl(0) - ,m_nCount(1) - ,m_c(c) -{ - if( !bCount ) - return; - - const SvXMLNamespaceMap& rMap = GetImport().GetNamespaceMap(); - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for( sal_Int16 i=0; i < nAttrCount; i++ ) - { - const OUString& rAttrName = xAttrList->getNameByIndex( i ); - - OUString aLocalName; - sal_uInt16 nPrefix =rMap.GetKeyByAttrName( rAttrName,&aLocalName ); - if( XML_NAMESPACE_TEXT == nPrefix && - IsXMLToken( aLocalName, XML_C ) ) - { - sal_Int32 nTmp = xAttrList->getValueByIndex(i).toInt32(); - if( nTmp > 0 ) - { - if( nTmp > SAL_MAX_UINT16 ) - m_nCount = SAL_MAX_UINT16; - else - m_nCount = static_cast<sal_uInt16>(nTmp); - } - } - } -} XMLCharContext::XMLCharContext( SvXMLImport& rImport, @@ -176,19 +139,6 @@ XMLCharContext::XMLCharContext( XMLCharContext::XMLCharContext( SvXMLImport& rImp, - sal_uInt16 nPrfx, - const OUString& rLName, - const Reference< xml::sax::XAttributeList > &, - sal_Int16 nControl ) : - SvXMLImportContext( rImp, nPrfx, rLName ) - ,m_nControl(nControl) - ,m_nCount(0) - ,m_c(0) -{ -} - -XMLCharContext::XMLCharContext( - SvXMLImport& rImp, sal_Int16 nControl ) : SvXMLImportContext( rImp ) ,m_nControl(nControl) @@ -1537,8 +1487,8 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLImpSpanContext_Impl Reference < XTextRange > xAnchorPos = rImport.GetTextImport()->GetCursor()->getStart(); XMLTextFrameContext *pTextFrameContext = - new XMLTextFrameContext( rImport, - rImport.convertToSlowAttrList(xAttrList), + new XMLTextFrameContext(rImport, + xAttrList, TextContentAnchorType_AS_CHARACTER ); // Remove check for text content. (#i33242#) // Check for text content is done on the processing of the hint @@ -1622,7 +1572,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLImpSpanContext_Impl nElement == XML_ELEMENT(DRAW, XML_CONTROL ) ) ) { Reference < XShapes > xShapes; - SvXMLShapeContext* pShapeContext = rImport.GetShapeImport()->CreateGroupChildContext( + SvXMLShapeContext* pShapeContext = XMLShapeImportHelper::CreateGroupChildContext( rImport, nElement, xAttrList, xShapes ); pContext = pShapeContext; // OD 2004-04-20 #i26791# - keep shape in a text frame hint to @@ -1666,117 +1616,6 @@ void XMLImpSpanContext_Impl::characters( const OUString& rChars ) XMLParaContext::XMLParaContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const Reference< xml::sax::XAttributeList > & xAttrList, - bool bHead ) : - SvXMLImportContext( rImport, nPrfx, rLName ), - xStart( rImport.GetTextImport()->GetCursorAsRange()->getStart() ), - m_bHaveAbout(false), - nOutlineLevel( IsXMLToken( rLName, XML_H ) ? 1 : -1 ), - // Lost outline numbering in master document (#i73509#) - mbOutlineLevelAttrFound( false ), - mbOutlineContentVisible(true), - bIgnoreLeadingSpace( true ), - bHeading( bHead ), - bIsListHeader( false ), - bIsRestart (false), - nStartValue(0), - nStarFontsConvFlags( 0 ) -{ - const SvXMLTokenMap& rTokenMap = - GetImport().GetTextImport()->GetTextPAttrTokenMap(); - - bool bHaveXmlId( false ); - OUString aCondStyleName; - - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for( sal_Int16 i=0; i < nAttrCount; i++ ) - { - const OUString& rAttrName = xAttrList->getNameByIndex( i ); - const OUString& rValue = xAttrList->getValueByIndex( i ); - - OUString aLocalName; - sal_uInt16 nPrefix = - GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, - &aLocalName ); - switch( rTokenMap.Get( nPrefix, aLocalName ) ) - { - case XML_TOK_TEXT_P_XMLID: - m_sXmlId = rValue; - bHaveXmlId = true; - break; - case XML_TOK_TEXT_P_ABOUT: - m_sAbout = rValue; - m_bHaveAbout = true; - break; - case XML_TOK_TEXT_P_PROPERTY: - m_sProperty = rValue; - break; - case XML_TOK_TEXT_P_CONTENT: - m_sContent = rValue; - break; - case XML_TOK_TEXT_P_DATATYPE: - m_sDatatype = rValue; - break; - case XML_TOK_TEXT_P_TEXTID: - if (!bHaveXmlId) { m_sXmlId = rValue; } - break; - case XML_TOK_TEXT_P_STYLE_NAME: - sStyleName = rValue; - break; - case XML_TOK_TEXT_P_COND_STYLE_NAME: - aCondStyleName = rValue; - break; - case XML_TOK_TEXT_P_LEVEL: - { - sal_Int32 nTmp = rValue.toInt32(); - if( nTmp > 0 ) - { - if( nTmp > 127 ) - nTmp = 127; - nOutlineLevel = static_cast<sal_Int8>(nTmp); - } - // Lost outline numbering in master document (#i73509#) - mbOutlineLevelAttrFound = true; - } - break; - case XML_TOK_TEXT_P_OUTLINE_CONTENT_VISIBLE: - { - bool bBool(false); - if (::sax::Converter::convertBool(bBool, rValue)) - mbOutlineContentVisible = bBool; - } - break; - case XML_TOK_TEXT_P_IS_LIST_HEADER: - { - bool bBool(false); - if (::sax::Converter::convertBool(bBool, rValue)) - bIsListHeader = bBool; - } - break; - case XML_TOK_TEXT_P_RESTART_NUMBERING: - { - bool bBool(false); - if (::sax::Converter::convertBool(bBool, rValue)) - bIsRestart = bBool; - } - break; - case XML_TOK_TEXT_P_START_VALUE: - { - nStartValue = sal::static_int_cast< sal_Int16 >( - rValue.toInt32()); - } - break; - } - } - - if( !aCondStyleName.isEmpty() ) - sStyleName = aCondStyleName; -} - -XMLParaContext::XMLParaContext( - SvXMLImport& rImport, sal_Int32 nElement, const Reference< xml::sax::XFastAttributeList > & xAttrList ) : SvXMLImportContext( rImport ), @@ -2180,10 +2019,9 @@ void XMLParaContext::characters( const OUString& rChars ) XMLNumberedParaContext::XMLNumberedParaContext( SvXMLImport& i_rImport, - sal_uInt16 i_nPrefix, - const OUString& i_rLocalName, - const Reference< xml::sax::XAttributeList > & i_xAttrList ) : - SvXMLImportContext( i_rImport, i_nPrefix, i_rLocalName ), + sal_Int32 /*nElement*/, + const Reference< xml::sax::XFastAttributeList > & xAttrList ) : + SvXMLImportContext( i_rImport ), m_Level(0), m_StartValue(-1), m_ListId(), @@ -2191,51 +2029,42 @@ XMLNumberedParaContext::XMLNumberedParaContext( { OUString StyleName; - const SvXMLTokenMap& rTokenMap( - i_rImport.GetTextImport()->GetTextNumberedParagraphAttrTokenMap() ); - - const sal_Int16 nAttrCount( i_xAttrList.is() ? - i_xAttrList->getLength() : 0 ); - for ( sal_Int16 i=0; i < nAttrCount; i++ ) + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { - const OUString& rAttrName( i_xAttrList->getNameByIndex( i ) ); - const OUString& rValue ( i_xAttrList->getValueByIndex( i ) ); - - OUString aLocalName; - const sal_uInt16 nPrefix( - GetImport().GetNamespaceMap().GetKeyByAttrName( - rAttrName, &aLocalName ) ); - switch( rTokenMap.Get( nPrefix, aLocalName ) ) + OUString sValue = aIter.toString(); + switch( aIter.getToken() ) { - case XML_TOK_TEXT_NUMBERED_PARAGRAPH_XMLID: + case XML_ELEMENT(XML, XML_ID): //FIXME: there is no UNO API for lists break; - case XML_TOK_TEXT_NUMBERED_PARAGRAPH_LIST_ID: - m_ListId = rValue; + case XML_ELEMENT(TEXT, XML_LIST_ID): + m_ListId = sValue; break; - case XML_TOK_TEXT_NUMBERED_PARAGRAPH_LEVEL: + case XML_ELEMENT(TEXT, XML_LEVEL): { - sal_Int32 nTmp = rValue.toInt32(); + sal_Int32 nTmp = sValue.toInt32(); if ( nTmp >= 1 && nTmp <= SHRT_MAX ) { m_Level = static_cast<sal_uInt16>(nTmp) - 1; } } break; - case XML_TOK_TEXT_NUMBERED_PARAGRAPH_STYLE_NAME: - StyleName = rValue; + case XML_ELEMENT(TEXT, XML_STYLE_NAME): + StyleName = sValue; break; - case XML_TOK_TEXT_NUMBERED_PARAGRAPH_CONTINUE_NUMBERING: + case XML_ELEMENT(TEXT, XML_CONTINUE_NUMBERING): // this attribute is deprecated -// ContinueNumbering = IsXMLToken(rValue, XML_TRUE); +// ContinueNumbering = IsXMLToken(sValue, XML_TRUE); break; - case XML_TOK_TEXT_NUMBERED_PARAGRAPH_START_VALUE: + case XML_ELEMENT(TEXT, XML_START_VALUE): { - sal_Int32 nTmp = rValue.toInt32(); + sal_Int32 nTmp = sValue.toInt32(); if ( nTmp >= 0 && nTmp <= SHRT_MAX ) { m_StartValue = static_cast<sal_Int16>(nTmp); } } break; + default: + XMLOFF_WARN_UNKNOWN("xmloff", aIter); } } diff --git a/xmloff/source/text/txtparai.hxx b/xmloff/source/text/txtparai.hxx index 8c8948a6ba9f..c5780bd28f20 100644 --- a/xmloff/source/text/txtparai.hxx +++ b/xmloff/source/text/txtparai.hxx @@ -60,11 +60,6 @@ public: XMLParaContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList, - bool bHeading ); - XMLParaContext( SvXMLImport& rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ); @@ -92,9 +87,8 @@ public: XMLNumberedParaContext( SvXMLImport& i_rImport, - sal_uInt16 i_nPrefix, - const OUString& i_rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList > & i_xAttrList ); + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList > & i_xAttrList ); virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; diff --git a/xmloff/source/text/txtvfldi.cxx b/xmloff/source/text/txtvfldi.cxx index abcbb51622fe..246ba52db6a8 100644 --- a/xmloff/source/text/txtvfldi.cxx +++ b/xmloff/source/text/txtvfldi.cxx @@ -80,14 +80,13 @@ using namespace ::xmloff::token; XMLVarFieldImportContext::XMLVarFieldImportContext( SvXMLImport& rImport, XMLTextImportHelper& rHlp, - const char* pServiceName, sal_uInt16 nPrfx, - const OUString& rLocalName, + const char* pServiceName, bool bFormula, bool bFormulaDefault, bool bDescription, bool bHelp, bool bHint, bool bVisible, bool bIsDisplayFormula, bool bType, bool bStyle, bool bValue, bool bPresentation) : - XMLTextFieldImportContext(rImport, rHlp, pServiceName, nPrfx, rLocalName), + XMLTextFieldImportContext(rImport, rHlp, pServiceName), aValueHelper(rImport, rHlp, bType, bStyle, bValue, false), bDisplayFormula(false), bDisplayNone(false), @@ -112,7 +111,7 @@ void XMLVarFieldImportContext::ProcessAttribute( const OUString& sAttrValue ) { switch (nAttrToken) - { + { case XML_ELEMENT(TEXT, XML_NAME): sName = sAttrValue; bValid = true; // we assume: field with name is valid! @@ -169,7 +168,7 @@ void XMLVarFieldImportContext::ProcessAttribute( // delegate all others to value helper aValueHelper.ProcessAttribute(nAttrToken, sAttrValue); break; - } + } } void XMLVarFieldImportContext::PrepareField( @@ -247,13 +246,11 @@ void XMLVarFieldImportContext::PrepareField( XMLSetVarFieldImportContext::XMLSetVarFieldImportContext( SvXMLImport& rImport, XMLTextImportHelper& rHlp, - const char* pServiceName, sal_uInt16 nPrfx, - const OUString& rLocalName, VarType eVarType, + const char* pServiceName, VarType eVarType, bool bFormula, bool bFormulaDefault, bool bDescription, bool bHelp, bool bHint, bool bVisible, bool bIsDisplayFormula, bool bType, bool bStyle, bool bValue, bool bPresentation) : XMLVarFieldImportContext(rImport, rHlp, pServiceName, - nPrfx, rLocalName, bFormula, bFormulaDefault, bDescription, bHelp, bHint, bVisible, bIsDisplayFormula, bType, bStyle, bValue, bPresentation), @@ -330,10 +327,9 @@ bool XMLSetVarFieldImportContext::FindFieldMaster( XMLSequenceFieldImportContext::XMLSequenceFieldImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& rLocalName) : + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : XMLSetVarFieldImportContext(rImport, rHlp, sAPI_set_expression, - nPrfx, rLocalName, VarTypeSequence, + VarTypeSequence, // formula true, true, false, false, false, false, @@ -395,10 +391,9 @@ void XMLSequenceFieldImportContext::PrepareField( XMLVariableSetFieldImportContext::XMLVariableSetFieldImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& rLocalName) : + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : XMLSetVarFieldImportContext(rImport, rHlp, sAPI_set_expression, - nPrfx, rLocalName, VarTypeSimple, + VarTypeSimple, // formula, value&type, style, // display none true, true, @@ -426,10 +421,9 @@ void XMLVariableSetFieldImportContext::PrepareField( XMLVariableInputFieldImportContext::XMLVariableInputFieldImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx, - const OUString& rLocalName) : + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : XMLSetVarFieldImportContext(rImport, rHlp, sAPI_set_expression, - nPrfx, rLocalName, VarTypeSimple, + VarTypeSimple, // description, display none/formula, // value&type, style, formula true, true, @@ -460,10 +454,9 @@ void XMLVariableInputFieldImportContext::PrepareField( XMLUserFieldImportContext::XMLUserFieldImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& rLocalName) : - XMLSetVarFieldImportContext(rImport, rHlp, sAPI_user, nPrfx, - rLocalName, VarTypeUserField, + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : + XMLSetVarFieldImportContext(rImport, rHlp, sAPI_user, + VarTypeUserField, // display none/formula, style false, false, false, false, false, true, @@ -479,10 +472,8 @@ XMLUserFieldImportContext::XMLUserFieldImportContext( // bug: doesn't work (SO API lacking) XMLUserFieldInputImportContext::XMLUserFieldInputImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx, - const OUString& rLocalName) : + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : XMLVarFieldImportContext(rImport, rHlp, "InputUser", - nPrfx, rLocalName, // description, style false, false, true, false, false, @@ -506,10 +497,8 @@ void XMLUserFieldInputImportContext::PrepareField( XMLVariableGetFieldImportContext::XMLVariableGetFieldImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& rLocalName) : + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : XMLVarFieldImportContext(rImport, rHlp, sAPI_get_expression, - nPrfx, rLocalName, // style, display formula false, false, false, false, false, @@ -534,10 +523,8 @@ void XMLVariableGetFieldImportContext::PrepareField( XMLExpressionFieldImportContext::XMLExpressionFieldImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& rLocalName) : + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : XMLVarFieldImportContext(rImport, rHlp, sAPI_get_expression, - nPrfx, rLocalName, // formula, type, style, display formula true, true, false, false, false, @@ -563,10 +550,8 @@ void XMLExpressionFieldImportContext::PrepareField( XMLTextInputFieldImportContext::XMLTextInputFieldImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, const OUString& sLocalName) : + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : XMLVarFieldImportContext(rImport, rHlp, "Input", - nPrfx, sLocalName, // description false, false, true, true, true, @@ -591,11 +576,8 @@ void XMLTextInputFieldImportContext::PrepareField( XMLTableFormulaImportContext::XMLTableFormulaImportContext( SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& rLocalName) : - XMLTextFieldImportContext(rImport, rHlp, "TableFormula", - nPrfx, rLocalName), + XMLTextImportHelper& rHlp) : + XMLTextFieldImportContext(rImport, rHlp, "TableFormula"), aValueHelper(rImport, rHlp, false, true, false, true), bIsShowFormula(false) { @@ -651,9 +633,8 @@ void XMLTableFormulaImportContext::PrepareField( XMLVariableDeclsImportContext::XMLVariableDeclsImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx, - const OUString& rLocalName, enum VarType eVarType) : - SvXMLImportContext(rImport, nPrfx, rLocalName), + SvXMLImport& rImport, XMLTextImportHelper& rHlp, enum VarType eVarType) : + SvXMLImportContext(rImport), eVarDeclsContextType(eVarType), rImportHelper(rHlp) { @@ -922,10 +903,8 @@ bool XMLVariableDeclImportContext::FindFieldMaster( XMLDatabaseDisplayImportContext::XMLDatabaseDisplayImportContext( - SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx, - const OUString& rLocalName) : - XMLDatabaseFieldImportContext(rImport, rHlp, sAPI_database, - nPrfx, rLocalName, false), + SvXMLImport& rImport, XMLTextImportHelper& rHlp) : + XMLDatabaseFieldImportContext(rImport, rHlp, sAPI_database, false), aValueHelper(rImport, rHlp, false, true, false, false), bColumnOK(false), bDisplay( true ), @@ -1104,7 +1083,7 @@ void XMLValueImportHelper::ProcessAttribute( { switch (nAttrToken) { - case XML_ELEMENT(TEXT, XML_VALUE_TYPE): + case XML_ELEMENT(TEXT, XML_VALUE_TYPE): // #i32362#: src680m48++ saves text:value-type case XML_ELEMENT(OFFICE, XML_VALUE_TYPE): { // convert enum |