diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-12-06 14:04:11 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-12-06 15:45:47 +0100 |
commit | 387a7dcfe7c2a5c32b9fa7678f722845775041ba (patch) | |
tree | 9e4137fa47c8f82f5c3abd5dd79597ed0098ffbe | |
parent | b0e4f29560671d48c3943b6d0165c91c7ba91fd5 (diff) |
fastparser in XMLImpSpanContext_Impl
Change-Id: Iba1b61c607f5f748f5acf4ce16d2c0cce8dee72e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107281
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | include/xmloff/xmlimp.hxx | 3 | ||||
-rw-r--r-- | xmloff/inc/txtfldi.hxx | 12 | ||||
-rw-r--r-- | xmloff/source/core/xmlimp.cxx | 30 | ||||
-rw-r--r-- | xmloff/source/text/XMLChangeImportContext.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/text/XMLChangeImportContext.hxx | 2 | ||||
-rw-r--r-- | xmloff/source/text/XMLFootnoteImportContext.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/text/XMLFootnoteImportContext.hxx | 4 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextFrameContext.cxx | 3 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextFrameContext.hxx | 2 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextFrameHyperlinkContext.cxx | 53 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextFrameHyperlinkContext.hxx | 4 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextMarkImportContext.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextMarkImportContext.hxx | 4 | ||||
-rw-r--r-- | xmloff/source/text/txtfldi.cxx | 38 | ||||
-rw-r--r-- | xmloff/source/text/txtimp.cxx | 5 | ||||
-rw-r--r-- | xmloff/source/text/txtparai.cxx | 655 | ||||
-rw-r--r-- | xmloff/source/text/txtparai.hxx | 5 |
17 files changed, 406 insertions, 430 deletions
diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx index ae165a2201b8..4599bcbd751b 100644 --- a/include/xmloff/xmlimp.hxx +++ b/include/xmloff/xmlimp.hxx @@ -384,6 +384,9 @@ public: // get import helper for events XMLEventImportHelper& GetEventImport(); + css::uno::Reference< css::xml::sax::XAttributeList > convertToSlowAttrList( + const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs); + static const OUString & getNameFromToken( sal_Int32 nToken ); static OUString getPrefixAndNameFromToken( sal_Int32 nToken ); static OUString getNamespacePrefixFromToken(sal_Int32 nToken, const SvXMLNamespaceMap* pMap); diff --git a/xmloff/inc/txtfldi.hxx b/xmloff/inc/txtfldi.hxx index 10c33b3bfa31..b8560b17b3d6 100644 --- a/xmloff/inc/txtfldi.hxx +++ b/xmloff/inc/txtfldi.hxx @@ -69,6 +69,10 @@ public: 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 /// process character data: will be collected in member sContentBuffer virtual void SAL_CALL characters( const OUString& sContent ) override; @@ -89,6 +93,10 @@ public: sal_uInt16 nPrefix, const OUString& rName, sal_uInt16 nToken); + static XMLTextFieldImportContext* CreateTextFieldImportContext( + SvXMLImport& rImport, + XMLTextImportHelper& rHlp, + sal_Int32 nElement); protected: /// get helper @@ -985,9 +993,7 @@ class XMLUrlFieldImportContext final : public XMLTextFieldImportContext public: XMLUrlFieldImportContext(SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLTextImportHelper& rHlp); private: /// no attributes -> empty method diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 5178cd732b05..03e076c0cba3 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -1582,6 +1582,36 @@ 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/text/XMLChangeImportContext.cxx b/xmloff/source/text/XMLChangeImportContext.cxx index 6938c9cdf760..0ef536df90e7 100644 --- a/xmloff/source/text/XMLChangeImportContext.cxx +++ b/xmloff/source/text/XMLChangeImportContext.cxx @@ -32,11 +32,9 @@ using ::xmloff::token::XML_CHANGE_ID; XMLChangeImportContext::XMLChangeImportContext( SvXMLImport& rImport, - sal_Int16 nPrefix, - const OUString& rLocalName, Element const eElement, bool bOutsideOfParagraph) - : SvXMLImportContext(rImport, nPrefix, rLocalName) + : SvXMLImportContext(rImport) , m_Element(eElement) , m_bIsOutsideOfParagraph(bOutsideOfParagraph) { diff --git a/xmloff/source/text/XMLChangeImportContext.hxx b/xmloff/source/text/XMLChangeImportContext.hxx index 4040cc0f2413..4a5d42d83754 100644 --- a/xmloff/source/text/XMLChangeImportContext.hxx +++ b/xmloff/source/text/XMLChangeImportContext.hxx @@ -49,8 +49,6 @@ public: */ XMLChangeImportContext( SvXMLImport& rImport, - sal_Int16 nPrefix, - const OUString& rLocalName, Element eElement, /// true if change mark is encountered outside of a paragraph /// (usually before a section or table) diff --git a/xmloff/source/text/XMLFootnoteImportContext.cxx b/xmloff/source/text/XMLFootnoteImportContext.cxx index 7ea3ba22f4ac..a43e27b28c53 100644 --- a/xmloff/source/text/XMLFootnoteImportContext.cxx +++ b/xmloff/source/text/XMLFootnoteImportContext.cxx @@ -64,10 +64,8 @@ const SvXMLTokenMapEntry aFootnoteChildTokenMap[] = XMLFootnoteImportContext::XMLFootnoteImportContext( SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& rLocalName ) -: SvXMLImportContext(rImport, nPrfx, rLocalName) + XMLTextImportHelper& rHlp ) +: SvXMLImportContext(rImport) , mbListContextPushed(false) , rHelper(rHlp) { diff --git a/xmloff/source/text/XMLFootnoteImportContext.hxx b/xmloff/source/text/XMLFootnoteImportContext.hxx index 6c20b1a331cd..534fbabd8891 100644 --- a/xmloff/source/text/XMLFootnoteImportContext.hxx +++ b/xmloff/source/text/XMLFootnoteImportContext.hxx @@ -55,9 +55,7 @@ public: XMLFootnoteImportContext( SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& rLocalName ); + XMLTextImportHelper& rHlp ); protected: diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx index efa08da145f7..3da588ddffb7 100644 --- a/xmloff/source/text/XMLTextFrameContext.cxx +++ b/xmloff/source/text/XMLTextFrameContext.cxx @@ -1330,10 +1330,9 @@ bool XMLTextFrameContext::CreateIfNotThere( css::uno::Reference < css::beans::XP XMLTextFrameContext::XMLTextFrameContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, const OUString& rLName, const Reference< XAttributeList > & xAttrList, TextContentAnchorType eATyp ) -: SvXMLImportContext( rImport, nPrfx, rLName ) +: SvXMLImportContext( rImport ) , MultiImageImportHelper() , m_xAttrList( new SvXMLAttributeList( xAttrList ) ) // Implement Title/Description Elements UI (#i73249#) diff --git a/xmloff/source/text/XMLTextFrameContext.hxx b/xmloff/source/text/XMLTextFrameContext.hxx index 76cd68fe982a..1f3787e9e9fc 100644 --- a/xmloff/source/text/XMLTextFrameContext.hxx +++ b/xmloff/source/text/XMLTextFrameContext.hxx @@ -67,8 +67,6 @@ public: XMLTextFrameContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList, css::text::TextContentAnchorType eDfltAnchorType ); diff --git a/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx b/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx index 8514ef2f2aa0..126c55aa8eef 100644 --- a/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx +++ b/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx @@ -93,6 +93,56 @@ XMLTextFrameHyperlinkContext::XMLTextFrameHyperlinkContext( } } +XMLTextFrameHyperlinkContext::XMLTextFrameHyperlinkContext( + SvXMLImport& rImport, + sal_Int32 /*nElement*/, + const Reference< XFastAttributeList > & xAttrList, + TextContentAnchorType eATyp ) : + SvXMLImportContext( rImport ), + eDefaultAnchorType( eATyp ), + bMap( false ) +{ + OUString sShow; + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) + { + OUString sValue = aIter.toString(); + switch( aIter.getToken() ) + { + case XML_ELEMENT(XLINK, XML_HREF): + sHRef = GetImport().GetAbsoluteReference( sValue ); + break; + case XML_ELEMENT(OFFICE, XML_NAME): + sName = sValue; + break; + case XML_ELEMENT(OFFICE, XML_TARGET_FRAME_NAME): + sTargetFrameName = sValue; + break; + case XML_ELEMENT(XLINK, XML_SHOW): + sShow = sValue; + break; + case XML_ELEMENT(OFFICE, XML_SERVER_MAP): + { + bool bTmp(false); + if (::sax::Converter::convertBool( bTmp, sValue )) + { + bMap = bTmp; + } + } + break; + default: + XMLOFF_WARN_UNKNOWN("xmloff", aIter); + } + } + + if( !sShow.isEmpty() && sTargetFrameName.isEmpty() ) + { + if( IsXMLToken( sShow, XML_NEW ) ) + sTargetFrameName = "_blank"; + else if( IsXMLToken( sShow, XML_REPLACE ) ) + sTargetFrameName = "_self"; + } +} + XMLTextFrameHyperlinkContext::~XMLTextFrameHyperlinkContext() { } @@ -108,8 +158,7 @@ SvXMLImportContextRef XMLTextFrameHyperlinkContext::CreateChildContext( if( XML_NAMESPACE_DRAW == nPrefix ) { if( IsXMLToken( rLocalName, XML_FRAME ) ) - pTextFrameContext = new XMLTextFrameContext( GetImport(), nPrefix, - rLocalName, xAttrList, + pTextFrameContext = new XMLTextFrameContext( GetImport(), xAttrList, eDefaultAnchorType ); } diff --git a/xmloff/source/text/XMLTextFrameHyperlinkContext.hxx b/xmloff/source/text/XMLTextFrameHyperlinkContext.hxx index 1c66a7f3abb6..b1c6fdec5cd6 100644 --- a/xmloff/source/text/XMLTextFrameHyperlinkContext.hxx +++ b/xmloff/source/text/XMLTextFrameHyperlinkContext.hxx @@ -47,6 +47,10 @@ public: 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, diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx index 4aad5f380f70..b81152a3c211 100644 --- a/xmloff/source/text/XMLTextMarkImportContext.cxx +++ b/xmloff/source/text/XMLTextMarkImportContext.cxx @@ -91,10 +91,8 @@ void XMLFieldParamImportContext::startFastElement(sal_Int32 /*nElement*/, const XMLTextMarkImportContext::XMLTextMarkImportContext( SvXMLImport& rImport, XMLTextImportHelper& rHlp, - uno::Reference<uno::XInterface> & io_rxCrossRefHeadingBookmark, - sal_uInt16 nPrefix, - const OUString& rLocalName ) - : SvXMLImportContext(rImport, nPrefix, rLocalName) + uno::Reference<uno::XInterface> & io_rxCrossRefHeadingBookmark ) + : SvXMLImportContext(rImport) , m_rHelper(rHlp) , m_rxCrossRefHeadingBookmark(io_rxCrossRefHeadingBookmark) , m_bHaveAbout(false) diff --git a/xmloff/source/text/XMLTextMarkImportContext.hxx b/xmloff/source/text/XMLTextMarkImportContext.hxx index 616dec670b20..5082c151779e 100644 --- a/xmloff/source/text/XMLTextMarkImportContext.hxx +++ b/xmloff/source/text/XMLTextMarkImportContext.hxx @@ -79,9 +79,7 @@ public: XMLTextMarkImportContext( SvXMLImport& rImport, XMLTextImportHelper& rHlp, - css::uno::Reference<css::uno::XInterface> & io_rxCrossRefHeadingBookmark, - sal_uInt16 nPrfx, - const OUString& rLocalName ); + css::uno::Reference<css::uno::XInterface> & io_rxCrossRefHeadingBookmark ); virtual void SAL_CALL startFastElement( sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx index 96cfd80041f8..798a103799aa 100644 --- a/xmloff/source/text/txtfldi.cxx +++ b/xmloff/source/text/txtfldi.cxx @@ -129,6 +129,18 @@ XMLTextFieldImportContext::XMLTextFieldImportContext( 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!"); + sServiceName = OUString::createFromAscii(pService); +} + void XMLTextFieldImportContext::startFastElement( sal_Int32 /*nElement*/, const Reference<XFastAttributeList> & xAttrList) @@ -217,6 +229,25 @@ 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) @@ -2981,11 +3012,8 @@ void XMLPageNameFieldImportContext::PrepareField( XMLUrlFieldImportContext::XMLUrlFieldImportContext( SvXMLImport& rImport, - XMLTextImportHelper& rHlp, - sal_uInt16 nPrfx, - const OUString& sLocalName) : - XMLTextFieldImportContext(rImport, rHlp, sAPI_url, - nPrfx, sLocalName), + XMLTextImportHelper& rHlp) : + XMLTextFieldImportContext(rImport, rHlp, sAPI_url), bFrameOK(false) { } diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index 88695e599a8b..e2ec5dc280b6 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -2268,8 +2268,7 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( TextContentAnchorType eAnchorType = XMLTextType::TextBox == eType ? TextContentAnchorType_AT_FRAME : TextContentAnchorType_AT_PAGE; - pContext = new XMLTextFrameContext( rImport, nPrefix, - rLocalName, xAttrList, + pContext = new XMLTextFrameContext( rImport, xAttrList, eAnchorType ); bContent = false; } @@ -2316,7 +2315,7 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( case XML_TOK_TEXT_CHANGE_START: case XML_TOK_TEXT_CHANGE_END: pContext = new XMLChangeImportContext( - rImport, nPrefix, rLocalName, + rImport, ((nToken == XML_TOK_TEXT_CHANGE_END) ? XMLChangeImportContext::Element::END : (nToken == XML_TOK_TEXT_CHANGE_START) diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx index 84bf3ad1ba55..1c12e952cc73 100644 --- a/xmloff/source/text/txtparai.cxx +++ b/xmloff/source/text/txtparai.cxx @@ -240,14 +240,11 @@ public: // Do everything in constructor. Well ... XMLStartReferenceContext_Impl ( SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, XMLHints_Impl& rHints, - const Reference<xml::sax::XAttributeList> & xAttrList); + const Reference<xml::sax::XFastAttributeList> & xAttrList); static bool FindName( - SvXMLImport& rImport, - const Reference<xml::sax::XAttributeList> & xAttrList, + const Reference<xml::sax::XFastAttributeList> & xAttrList, OUString& rName); }; @@ -255,15 +252,13 @@ public: XMLStartReferenceContext_Impl::XMLStartReferenceContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, XMLHints_Impl& rHints, - const Reference<xml::sax::XAttributeList> & xAttrList) : - SvXMLImportContext(rImport, nPrefix, rLocalName) + const Reference<xml::sax::XFastAttributeList> & xAttrList) : + SvXMLImportContext(rImport) { OUString sName; - if (FindName(GetImport(), xAttrList, sName)) + if (FindName(xAttrList, sName)) { std::unique_ptr<XMLHint_Impl> pHint(new XMLReferenceHint_Impl( sName, rImport.GetTextImport()->GetCursor()->getStart())); @@ -276,26 +271,19 @@ XMLStartReferenceContext_Impl::XMLStartReferenceContext_Impl( } bool XMLStartReferenceContext_Impl::FindName( - SvXMLImport& rImport, - const Reference<xml::sax::XAttributeList> & xAttrList, + const Reference<xml::sax::XFastAttributeList> & xAttrList, OUString& rName) { bool bNameOK( false ); // find name attribute first - const sal_Int16 nLength( xAttrList->getLength() ); - for (sal_Int16 nAttr = 0; nAttr < nLength; nAttr++) + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { - OUString sLocalName; - const sal_uInt16 nPrefix = rImport.GetNamespaceMap(). - GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), - &sLocalName ); - - if ( (XML_NAMESPACE_TEXT == nPrefix) && - IsXMLToken(sLocalName, XML_NAME) ) + if ( aIter.getToken() == XML_ELEMENT(TEXT, XML_NAME) ) { - rName = xAttrList->getValueByIndex(nAttr); + rName = aIter.toString(); bNameOK = true; + break; } } @@ -312,26 +300,22 @@ public: // Do everything in constructor. Well ... XMLEndReferenceContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, const XMLHints_Impl& rHints, - const Reference<xml::sax::XAttributeList> & xAttrList); + const Reference<xml::sax::XFastAttributeList> & xAttrList); }; } XMLEndReferenceContext_Impl::XMLEndReferenceContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, const XMLHints_Impl& rHints, - const Reference<xml::sax::XAttributeList> & xAttrList) : - SvXMLImportContext(rImport, nPrefix, rLocalName) + const Reference<xml::sax::XFastAttributeList> & xAttrList) : + SvXMLImportContext(rImport) { OUString sName; // borrow from XMLStartReferenceContext_Impl - if (!XMLStartReferenceContext_Impl::FindName(GetImport(), xAttrList, sName)) + if (!XMLStartReferenceContext_Impl::FindName(xAttrList, sName)) return; // search for reference start @@ -366,28 +350,26 @@ public: XMLImpSpanContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const Reference< xml::sax::XAttributeList > & xAttrList, + sal_Int32 nElement, + const Reference< xml::sax::XFastAttributeList > & xAttrList, XMLHints_Impl& rHints, bool& rIgnLeadSpace, sal_uInt8 nSFConvFlags ); - virtual ~XMLImpSpanContext_Impl() override; - - static SvXMLImportContextRef CreateChildContext( + static css::uno::Reference< css::xml::sax::XFastContextHandler > CreateSpanContext( SvXMLImport& rImport, - sal_uInt16 nPrefix, const OUString& rLocalName, - const Reference< xml::sax::XAttributeList > & xAttrList, - sal_uInt16 nToken, XMLHints_Impl& rHints, + sal_Int32 nElement, + const Reference< xml::sax::XFastAttributeList > & xAttrList, + XMLHints_Impl& rHints, bool& rIgnLeadSpace, sal_uInt8 nStarFontsConvFlags = 0 ); - virtual SvXMLImportContextRef CreateChildContext( - sal_uInt16 nPrefix, const OUString& rLocalName, - const Reference< xml::sax::XAttributeList > & xAttrList ) override; + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override; + + virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override; virtual void SAL_CALL characters( const OUString& rChars ) override; }; @@ -403,17 +385,15 @@ public: XMLImpHyperlinkContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const Reference< xml::sax::XAttributeList > & xAttrList, + sal_Int32 nElement, + const Reference< xml::sax::XFastAttributeList > & xAttrList, XMLHints_Impl& rHints, bool& rIgnLeadSpace ); virtual ~XMLImpHyperlinkContext_Impl() override; - virtual SvXMLImportContextRef CreateChildContext( - sal_uInt16 nPrefix, const OUString& rLocalName, - const Reference< 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 characters( const OUString& rChars ) override; }; @@ -422,47 +402,42 @@ public: XMLImpHyperlinkContext_Impl::XMLImpHyperlinkContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const Reference< xml::sax::XAttributeList > & xAttrList, + sal_Int32 /*nElement*/, + const Reference< xml::sax::XFastAttributeList > & xAttrList, XMLHints_Impl& rHints, bool& rIgnLeadSpace ) - : SvXMLImportContext( rImport, nPrfx, rLName ) + : SvXMLImportContext( rImport ) , m_rHints( rHints ) , mpHint( new XMLHyperlinkHint_Impl( GetImport().GetTextImport()->GetCursorAsRange()->getStart() ) ) , mrbIgnoreLeadingSpace( rIgnLeadSpace ) { OUString sShow; - const SvXMLTokenMap& rTokenMap = GetImport().GetTextImport()->GetTextHyperlinkAttrTokenMap(); - 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; - 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_HYPERLINK_HREF: - mpHint->SetHRef( GetImport().GetAbsoluteReference( rValue ) ); + case XML_ELEMENT(XLINK, XML_HREF): + mpHint->SetHRef( GetImport().GetAbsoluteReference( sValue ) ); break; - case XML_TOK_TEXT_HYPERLINK_NAME: - mpHint->SetName( rValue ); + case XML_ELEMENT(OFFICE, XML_NAME): + mpHint->SetName( sValue ); break; - case XML_TOK_TEXT_HYPERLINK_TARGET_FRAME: - mpHint->SetTargetFrameName( rValue ); + case XML_ELEMENT(OFFICE, XML_TARGET_FRAME_NAME): + mpHint->SetTargetFrameName( sValue ); break; - case XML_TOK_TEXT_HYPERLINK_SHOW: - sShow = rValue; + case XML_ELEMENT(XLINK, XML_SHOW): + sShow = sValue; break; - case XML_TOK_TEXT_HYPERLINK_STYLE_NAME: - mpHint->SetStyleName( rValue ); + case XML_ELEMENT(TEXT, XML_STYLE_NAME): + mpHint->SetStyleName( sValue ); break; - case XML_TOK_TEXT_HYPERLINK_VIS_STYLE_NAME: - mpHint->SetVisitedStyleName( rValue ); + case XML_ELEMENT(TEXT, XML_VISITED_STYLE_NAME): + mpHint->SetVisitedStyleName( sValue ); break; + default: + XMLOFF_WARN_UNKNOWN("xmloff", aIter); } } @@ -495,12 +470,11 @@ XMLImpHyperlinkContext_Impl::~XMLImpHyperlinkContext_Impl() ->GetCursorAsRange()->getStart() ); } -SvXMLImportContextRef XMLImpHyperlinkContext_Impl::CreateChildContext( - sal_uInt16 nPrefix, const OUString& rLocalName, - const Reference< xml::sax::XAttributeList > & xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > XMLImpHyperlinkContext_Impl::createFastChildContext( + sal_Int32 nElement, + const uno::Reference< xml::sax::XFastAttributeList>& xAttrList ) { - if ( (nPrefix == XML_NAMESPACE_OFFICE) && - IsXMLToken(rLocalName, XML_EVENT_LISTENERS) ) + if ( nElement == XML_ELEMENT(OFFICE, XML_EVENT_LISTENERS) ) { XMLEventsImportContext* pCtxt = new XMLEventsImportContext(GetImport()); if (mpHint) @@ -509,13 +483,9 @@ SvXMLImportContextRef XMLImpHyperlinkContext_Impl::CreateChildContext( } else { - const SvXMLTokenMap& rTokenMap = - GetImport().GetTextImport()->GetTextPElemTokenMap(); - sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName ); - - return XMLImpSpanContext_Impl::CreateChildContext( - GetImport(), nPrefix, rLocalName, xAttrList, - nToken, m_rHints, mrbIgnoreLeadingSpace ); + return XMLImpSpanContext_Impl::CreateSpanContext( + GetImport(), nElement, xAttrList, + m_rHints, mrbIgnoreLeadingSpace ); } } @@ -537,15 +507,13 @@ public: XMLImpRubyBaseContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const Reference< xml::sax::XAttributeList > & xAttrList, + sal_Int32 nElement, + const Reference< xml::sax::XFastAttributeList > & xAttrList, XMLHints_Impl& rHints, bool& rIgnLeadSpace ); - virtual SvXMLImportContextRef CreateChildContext( - sal_uInt16 nPrefix, const OUString& rLocalName, - const Reference< 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 characters( const OUString& rChars ) override; }; @@ -554,28 +522,22 @@ public: XMLImpRubyBaseContext_Impl::XMLImpRubyBaseContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const Reference< xml::sax::XAttributeList > &, + sal_Int32 /*nElement*/, + const Reference< xml::sax::XFastAttributeList > &, XMLHints_Impl& rHints, bool& rIgnLeadSpace ) - : SvXMLImportContext( rImport, nPrfx, rLName ) + : SvXMLImportContext( rImport ) , m_rHints( rHints ) , rIgnoreLeadingSpace( rIgnLeadSpace ) { } -SvXMLImportContextRef XMLImpRubyBaseContext_Impl::CreateChildContext( - sal_uInt16 nPrefix, const OUString& rLocalName, - const Reference< xml::sax::XAttributeList > & xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > XMLImpRubyBaseContext_Impl::createFastChildContext( + sal_Int32 nElement, + const uno::Reference< xml::sax::XFastAttributeList>& xAttrList ) { - const SvXMLTokenMap& rTokenMap = - GetImport().GetTextImport()->GetTextPElemTokenMap(); - sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName ); - - return XMLImpSpanContext_Impl::CreateChildContext( GetImport(), nPrefix, - rLocalName, xAttrList, - nToken, m_rHints, rIgnoreLeadingSpace ); + return XMLImpSpanContext_Impl::CreateSpanContext( GetImport(), nElement, xAttrList, + m_rHints, rIgnoreLeadingSpace ); } void XMLImpRubyBaseContext_Impl::characters( const OUString& rChars ) @@ -601,17 +563,15 @@ public: XMLImpRubyContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const Reference< xml::sax::XAttributeList > & xAttrList, + sal_Int32 nElement, + const Reference< xml::sax::XFastAttributeList > & xAttrList, XMLHints_Impl& rHints, bool& rIgnLeadSpace ); virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; - virtual SvXMLImportContextRef CreateChildContext( - sal_uInt16 nPrefix, const OUString& rLocalName, - const Reference< 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; void SetTextStyleName( const OUString& s ) { m_sTextStyleName = s; } void AppendText( const OUString& s ) { m_sText += s; } @@ -626,9 +586,8 @@ public: XMLImpRubyTextContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const Reference< xml::sax::XAttributeList > & xAttrList, + sal_Int32 nElement, + const Reference< xml::sax::XFastAttributeList > & xAttrList, XMLImpRubyContext_Impl & rParent ); virtual void SAL_CALL characters( const OUString& rChars ) override; @@ -638,27 +597,17 @@ public: XMLImpRubyTextContext_Impl::XMLImpRubyTextContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const Reference< xml::sax::XAttributeList > & xAttrList, + sal_Int32 /*nElement*/, + const Reference< xml::sax::XFastAttributeList > & xAttrList, XMLImpRubyContext_Impl & rParent ) - : SvXMLImportContext( rImport, nPrfx, rLName ) + : SvXMLImportContext( rImport ) , m_rRubyContext( rParent ) { - 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 ); - if( XML_NAMESPACE_TEXT == nPrefix && - IsXMLToken( aLocalName, XML_STYLE_NAME ) ) + if( aIter.getToken() == XML_ELEMENT(TEXT, XML_STYLE_NAME) ) { - m_rRubyContext.SetTextStyleName( rValue ); + m_rRubyContext.SetTextStyleName( aIter.toString() ); break; } } @@ -672,30 +621,20 @@ void XMLImpRubyTextContext_Impl::characters( const OUString& rChars ) XMLImpRubyContext_Impl::XMLImpRubyContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const Reference< xml::sax::XAttributeList > & xAttrList, + sal_Int32 /*nElement*/, + const Reference< xml::sax::XFastAttributeList > & xAttrList, XMLHints_Impl& rHints, bool& rIgnLeadSpace ) - : SvXMLImportContext( rImport, nPrfx, rLName ) + : SvXMLImportContext( rImport ) , m_rHints( rHints ) , rIgnoreLeadingSpace( rIgnLeadSpace ) , m_xStart( GetImport().GetTextImport()->GetCursorAsRange()->getStart() ) { - 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 ); - if( XML_NAMESPACE_TEXT == nPrefix && - IsXMLToken( aLocalName, XML_STYLE_NAME ) ) + if( aIter.getToken() == XML_ELEMENT(TEXT, XML_STYLE_NAME) ) { - m_sStyleName = rValue; + m_sStyleName = aIter.toString(); break; } } @@ -718,27 +657,23 @@ void XMLImpRubyContext_Impl::endFastElement(sal_Int32 ) m_sStyleName, m_sTextStyleName, m_sText ); } -SvXMLImportContextRef XMLImpRubyContext_Impl::CreateChildContext( - sal_uInt16 nPrefix, const OUString& rLocalName, - const Reference< xml::sax::XAttributeList > & xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > XMLImpRubyContext_Impl::createFastChildContext( + sal_Int32 nElement, + const uno::Reference< xml::sax::XFastAttributeList>& xAttrList ) { - SvXMLImportContextRef xContext; - if( XML_NAMESPACE_TEXT == nPrefix ) - { - if( IsXMLToken( rLocalName, XML_RUBY_BASE ) ) - xContext = new XMLImpRubyBaseContext_Impl( GetImport(), nPrefix, - rLocalName, - xAttrList, - m_rHints, - rIgnoreLeadingSpace ); - else if( IsXMLToken( rLocalName, XML_RUBY_TEXT ) ) - xContext = new XMLImpRubyTextContext_Impl( GetImport(), nPrefix, - rLocalName, + if( nElement == XML_ELEMENT(TEXT, XML_RUBY_BASE) ) + return new XMLImpRubyBaseContext_Impl( GetImport(), nElement, + xAttrList, + m_rHints, + rIgnoreLeadingSpace ); + else if( nElement == XML_ELEMENT(TEXT, XML_RUBY_TEXT) ) + return new XMLImpRubyTextContext_Impl( GetImport(), nElement, xAttrList, *this ); - } + else + XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); - return xContext; + return nullptr; } namespace { @@ -761,8 +696,7 @@ public: XMLMetaImportContextBase( SvXMLImport& i_rImport, - const sal_uInt16 i_nPrefix, - const OUString& i_rLocalName, + const sal_Int32 nElement, XMLHints_Impl& i_rHints, bool & i_rIgnoreLeadingSpace ); @@ -772,9 +706,8 @@ public: virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; - virtual SvXMLImportContextRef CreateChildContext( - sal_uInt16 i_nPrefix, const OUString& i_rLocalName, - const Reference< xml::sax::XAttributeList > & i_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 characters( const OUString& i_rChars ) override; @@ -788,11 +721,10 @@ public: XMLMetaImportContextBase::XMLMetaImportContextBase( SvXMLImport& i_rImport, - const sal_uInt16 i_nPrefix, - const OUString& i_rLocalName, + const sal_Int32 /*i_nElement*/, XMLHints_Impl& i_rHints, bool & i_rIgnoreLeadingSpace ) - : SvXMLImportContext( i_rImport, i_nPrefix, i_rLocalName ) + : SvXMLImportContext( i_rImport ) , m_rHints( i_rHints ) , m_rIgnoreLeadingSpace( i_rIgnoreLeadingSpace ) , m_xStart( GetImport().GetTextImport()->GetCursorAsRange()->getStart() ) @@ -824,16 +756,12 @@ void XMLMetaImportContextBase::endFastElement(sal_Int32 ) InsertMeta(xInsertionCursor); } -SvXMLImportContextRef XMLMetaImportContextBase::CreateChildContext( - sal_uInt16 i_nPrefix, const OUString& i_rLocalName, - const Reference< xml::sax::XAttributeList > & i_xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > XMLMetaImportContextBase::createFastChildContext( + sal_Int32 nElement, + const uno::Reference< xml::sax::XFastAttributeList>& xAttrList ) { - const SvXMLTokenMap& rTokenMap( - GetImport().GetTextImport()->GetTextPElemTokenMap() ); - const sal_uInt16 nToken( rTokenMap.Get( i_nPrefix, i_rLocalName ) ); - - return XMLImpSpanContext_Impl::CreateChildContext( GetImport(), i_nPrefix, - i_rLocalName, i_xAttrList, nToken, m_rHints, m_rIgnoreLeadingSpace ); + return XMLImpSpanContext_Impl::CreateSpanContext( GetImport(), nElement, + xAttrList, m_rHints, m_rIgnoreLeadingSpace ); } void XMLMetaImportContextBase::characters( const OUString& i_rChars ) @@ -866,8 +794,7 @@ public: XMLMetaImportContext( SvXMLImport& i_rImport, - const sal_uInt16 i_nPrefix, - const OUString& i_rLocalName, + sal_Int32 nElement, XMLHints_Impl& i_rHints, bool & i_rIgnoreLeadingSpace ); @@ -881,11 +808,10 @@ public: XMLMetaImportContext::XMLMetaImportContext( SvXMLImport& i_rImport, - const sal_uInt16 i_nPrefix, - const OUString& i_rLocalName, + sal_Int32 nElement, XMLHints_Impl& i_rHints, bool & i_rIgnoreLeadingSpace ) - : XMLMetaImportContextBase( i_rImport, i_nPrefix, i_rLocalName, + : XMLMetaImportContextBase( i_rImport, nElement, i_rHints, i_rIgnoreLeadingSpace ) , m_bHaveAbout(false) { @@ -955,8 +881,7 @@ public: XMLMetaFieldImportContext( SvXMLImport& i_rImport, - const sal_uInt16 i_nPrefix, - const OUString& i_rLocalName, + sal_Int32 nElement, XMLHints_Impl& i_rHints, bool & i_rIgnoreLeadingSpace ); @@ -970,11 +895,10 @@ public: XMLMetaFieldImportContext::XMLMetaFieldImportContext( SvXMLImport& i_rImport, - const sal_uInt16 i_nPrefix, - const OUString& i_rLocalName, + sal_Int32 nElement, XMLHints_Impl& i_rHints, bool & i_rIgnoreLeadingSpace ) - : XMLMetaImportContextBase( i_rImport, i_nPrefix, i_rLocalName, + : XMLMetaImportContextBase( i_rImport, nElement, i_rHints, i_rIgnoreLeadingSpace ) { } @@ -1047,16 +971,12 @@ namespace { class XMLIndexMarkImportContext_Impl : public SvXMLImportContext { XMLHints_Impl& m_rHints; - const enum XMLTextPElemTokens eToken; OUString sID; public: XMLIndexMarkImportContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, - enum XMLTextPElemTokens nTok, XMLHints_Impl& rHints); void SAL_CALL startFastElement(sal_Int32 nElement, const Reference<xml::sax::XFastAttributeList> & xAttrList) override; @@ -1064,7 +984,7 @@ public: protected: /// process all attributes - void ProcessAttributes(const Reference<xml::sax::XFastAttributeList> & xAttrList, + void ProcessAttributes(sal_Int32 nElement, const Reference<xml::sax::XFastAttributeList> & xAttrList, Reference<beans::XPropertySet>& rPropSet); /** @@ -1075,12 +995,12 @@ protected: * This method tolerates an empty PropertySet; subclasses however * are not expected to. */ - virtual void ProcessAttribute(sal_Int32 nAttributeToken, + virtual void ProcessAttribute(sal_Int32 nElement, sal_Int32 nAttributeToken, const OUString& sValue, Reference<beans::XPropertySet>& rPropSet); static void GetServiceName(OUString& sServiceName, - enum XMLTextPElemTokens nToken); + sal_Int32 nElement); bool CreateMark(Reference<beans::XPropertySet>& rPropSet, const OUString& rServiceName); @@ -1090,18 +1010,14 @@ protected: XMLIndexMarkImportContext_Impl::XMLIndexMarkImportContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, - enum XMLTextPElemTokens eTok, XMLHints_Impl& rHints) - : SvXMLImportContext(rImport, nPrefix, rLocalName) + : SvXMLImportContext(rImport) , m_rHints(rHints) - , eToken(eTok) { } void XMLIndexMarkImportContext_Impl::startFastElement( - sal_Int32 /*nElement*/, + sal_Int32 nElement, const Reference<xml::sax::XFastAttributeList> & xAttrList) { // get Cursor position (needed for all cases) @@ -1109,18 +1025,18 @@ void XMLIndexMarkImportContext_Impl::startFastElement( GetImport().GetTextImport()->GetCursor()->getStart()); Reference<beans::XPropertySet> xMark; - switch (eToken) + switch (nElement) { - case XML_TOK_TEXT_TOC_MARK: - case XML_TOK_TEXT_USER_INDEX_MARK: - case XML_TOK_TEXT_ALPHA_INDEX_MARK: + case XML_ELEMENT(TEXT, XML_TOC_MARK): + case XML_ELEMENT(TEXT, XML_USER_INDEX_MARK): + case XML_ELEMENT(TEXT, XML_ALPHABETICAL_INDEX_MARK): { // single mark: create mark and insert OUString sService; - GetServiceName(sService, eToken); + GetServiceName(sService, nElement); if (CreateMark(xMark, sService)) { - ProcessAttributes(xAttrList, xMark); + ProcessAttributes(nElement, xAttrList, xMark); m_rHints.push_back( std::make_unique<XMLIndexMarkHint_Impl>(xMark, xPos)); } @@ -1128,16 +1044,16 @@ void XMLIndexMarkImportContext_Impl::startFastElement( break; } - case XML_TOK_TEXT_TOC_MARK_START: - case XML_TOK_TEXT_USER_INDEX_MARK_START: - case XML_TOK_TEXT_ALPHA_INDEX_MARK_START: + case XML_ELEMENT(TEXT, XML_TOC_MARK_START): + case XML_ELEMENT(TEXT, XML_USER_INDEX_MARK_START): + case XML_ELEMENT(TEXT, XML_ALPHABETICAL_INDEX_MARK_START): { // start: create mark and insert (if ID is found) OUString sService; - GetServiceName(sService, eToken); + GetServiceName(sService, nElement); if (CreateMark(xMark, sService)) { - ProcessAttributes(xAttrList, xMark); + ProcessAttributes(nElement, xAttrList, xMark); if (!sID.isEmpty()) { // process only if we find an ID @@ -1150,14 +1066,14 @@ void XMLIndexMarkImportContext_Impl::startFastElement( break; } - case XML_TOK_TEXT_TOC_MARK_END: - case XML_TOK_TEXT_USER_INDEX_MARK_END: - case XML_TOK_TEXT_ALPHA_INDEX_MARK_END: + case XML_ELEMENT(TEXT, XML_TOC_MARK_END): + case XML_ELEMENT(TEXT, XML_USER_INDEX_MARK_END): + case XML_ELEMENT(TEXT, XML_ALPHABETICAL_INDEX_MARK_END): { // end: search for ID and set end of mark // call process attributes with empty XPropertySet: - ProcessAttributes(xAttrList, xMark); + ProcessAttributes(nElement, xAttrList, xMark); if (!sID.isEmpty()) { // if we have an ID, find the hint and set the end position @@ -1177,17 +1093,19 @@ void XMLIndexMarkImportContext_Impl::startFastElement( } void XMLIndexMarkImportContext_Impl::ProcessAttributes( + sal_Int32 nElement, const Reference<xml::sax::XFastAttributeList> & xAttrList, Reference<beans::XPropertySet>& rPropSet) { // process attributes for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList )) { - ProcessAttribute(aIter.getToken(), aIter.toString(), rPropSet); + ProcessAttribute(nElement, aIter.getToken(), aIter.toString(), rPropSet); } } void XMLIndexMarkImportContext_Impl::ProcessAttribute( + sal_Int32 nElement, sal_Int32 nAttributeToken, const OUString& sValue, Reference<beans::XPropertySet>& rPropSet) @@ -1195,11 +1113,11 @@ void XMLIndexMarkImportContext_Impl::ProcessAttribute( // we only know ID + string-value attribute; // (former: marks, latter: -start + -end-marks) // the remainder is handled in sub-classes - switch (eToken) + switch (nElement) { - case XML_TOK_TEXT_TOC_MARK: - case XML_TOK_TEXT_USER_INDEX_MARK: - case XML_TOK_TEXT_ALPHA_INDEX_MARK: + case XML_ELEMENT(TEXT, XML_TOC_MARK): + case XML_ELEMENT(TEXT, XML_USER_INDEX_MARK): + case XML_ELEMENT(TEXT, XML_ALPHABETICAL_INDEX_MARK): if ( nAttributeToken == XML_ELEMENT(TEXT, XML_STRING_VALUE) ) { rPropSet->setPropertyValue("AlternativeText", uno::makeAny(sValue)); @@ -1207,12 +1125,12 @@ void XMLIndexMarkImportContext_Impl::ProcessAttribute( // else: ignore! break; - case XML_TOK_TEXT_TOC_MARK_START: - case XML_TOK_TEXT_USER_INDEX_MARK_START: - case XML_TOK_TEXT_ALPHA_INDEX_MARK_START: - case XML_TOK_TEXT_TOC_MARK_END: - case XML_TOK_TEXT_USER_INDEX_MARK_END: - case XML_TOK_TEXT_ALPHA_INDEX_MARK_END: + case XML_ELEMENT(TEXT, XML_TOC_MARK_START): + case XML_ELEMENT(TEXT, XML_USER_INDEX_MARK_START): + case XML_ELEMENT(TEXT, XML_ALPHABETICAL_INDEX_MARK_START): + case XML_ELEMENT(TEXT, XML_TOC_MARK_END): + case XML_ELEMENT(TEXT, XML_USER_INDEX_MARK_END): + case XML_ELEMENT(TEXT, XML_ALPHABETICAL_INDEX_MARK_END): if ( nAttributeToken == XML_ELEMENT(TEXT, XML_ID) ) { sID = sValue; @@ -1221,7 +1139,7 @@ void XMLIndexMarkImportContext_Impl::ProcessAttribute( break; default: - SAL_WARN("xmloff.text", "unknown index mark type!"); + XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttributeToken, sValue); break; } } @@ -1229,29 +1147,29 @@ void XMLIndexMarkImportContext_Impl::ProcessAttribute( void XMLIndexMarkImportContext_Impl::GetServiceName( OUString& sServiceName, - enum XMLTextPElemTokens eToken) + sal_Int32 nElement) { - switch (eToken) + switch (nElement) { - case XML_TOK_TEXT_TOC_MARK: - case XML_TOK_TEXT_TOC_MARK_START: - case XML_TOK_TEXT_TOC_MARK_END: + case XML_ELEMENT(TEXT, XML_TOC_MARK): + case XML_ELEMENT(TEXT, XML_TOC_MARK_START): + case XML_ELEMENT(TEXT, XML_TOC_MARK_END): { sServiceName = "com.sun.star.text.ContentIndexMark"; break; } - case XML_TOK_TEXT_USER_INDEX_MARK: - case XML_TOK_TEXT_USER_INDEX_MARK_START: - case XML_TOK_TEXT_USER_INDEX_MARK_END: + case XML_ELEMENT(TEXT, XML_USER_INDEX_MARK): + case XML_ELEMENT(TEXT, XML_USER_INDEX_MARK_START): + case XML_ELEMENT(TEXT, XML_USER_INDEX_MARK_END): { sServiceName = "com.sun.star.text.UserIndexMark"; break; } - case XML_TOK_TEXT_ALPHA_INDEX_MARK: - case XML_TOK_TEXT_ALPHA_INDEX_MARK_START: - case XML_TOK_TEXT_ALPHA_INDEX_MARK_END: + case XML_ELEMENT(TEXT, XML_ALPHABETICAL_INDEX_MARK): + case XML_ELEMENT(TEXT, XML_ALPHABETICAL_INDEX_MARK_START): + case XML_ELEMENT(TEXT, XML_ALPHABETICAL_INDEX_MARK_END): { sServiceName = "com.sun.star.text.DocumentIndexMark"; break; @@ -1259,7 +1177,7 @@ void XMLIndexMarkImportContext_Impl::GetServiceName( default: { - SAL_WARN("xmloff.text", "unknown index mark type!"); + XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); sServiceName.clear(); break; } @@ -1292,15 +1210,12 @@ public: XMLTOCMarkImportContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, - enum XMLTextPElemTokens nTok, XMLHints_Impl& rHints); protected: /** process outline level */ - virtual void ProcessAttribute(sal_Int32 nAttributeToken, + virtual void ProcessAttribute(sal_Int32 nElement, sal_Int32 nAttributeToken, const OUString& sValue, Reference<beans::XPropertySet>& rPropSet) override; }; @@ -1308,14 +1223,13 @@ protected: } XMLTOCMarkImportContext_Impl::XMLTOCMarkImportContext_Impl( - SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, - enum XMLTextPElemTokens nTok, XMLHints_Impl& rHints) : - XMLIndexMarkImportContext_Impl(rImport, nPrefix, rLocalName, - nTok, rHints) + SvXMLImport& rImport, XMLHints_Impl& rHints) : + XMLIndexMarkImportContext_Impl(rImport, rHints) { } void XMLTOCMarkImportContext_Impl::ProcessAttribute( + sal_Int32 nElement, sal_Int32 nAttributeToken, const OUString& sValue, Reference<beans::XPropertySet>& rPropSet) @@ -1341,7 +1255,7 @@ void XMLTOCMarkImportContext_Impl::ProcessAttribute( default: // else: delegate to superclass XMLIndexMarkImportContext_Impl::ProcessAttribute( - nAttributeToken, sValue, rPropSet); + nElement, nAttributeToken, sValue, rPropSet); } } @@ -1353,15 +1267,12 @@ public: XMLUserIndexMarkImportContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, - enum XMLTextPElemTokens nTok, XMLHints_Impl& rHints); protected: /** process index name */ - virtual void ProcessAttribute(sal_Int32 nAttributeToken, + virtual void ProcessAttribute(sal_Int32 nElement, sal_Int32 nAttributeToken, const OUString& sValue, Reference<beans::XPropertySet>& rPropSet) override; }; @@ -1369,15 +1280,13 @@ protected: } XMLUserIndexMarkImportContext_Impl::XMLUserIndexMarkImportContext_Impl( - SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, - enum XMLTextPElemTokens nTok, XMLHints_Impl& rHints) : - XMLIndexMarkImportContext_Impl(rImport, nPrefix, rLocalName, - nTok, rHints) + SvXMLImport& rImport, XMLHints_Impl& rHints) : + XMLIndexMarkImportContext_Impl(rImport, rHints) { } void XMLUserIndexMarkImportContext_Impl::ProcessAttribute( - sal_Int32 nAttributeToken, const OUString& sValue, + sal_Int32 nElement, sal_Int32 nAttributeToken, const OUString& sValue, Reference<beans::XPropertySet>& rPropSet) { switch (nAttributeToken) @@ -1401,7 +1310,7 @@ void XMLUserIndexMarkImportContext_Impl::ProcessAttribute( default: // else: unknown text property: delegate to super class XMLIndexMarkImportContext_Impl::ProcessAttribute( - nAttributeToken, sValue, rPropSet); + nElement, nAttributeToken, sValue, rPropSet); } } @@ -1413,15 +1322,12 @@ public: XMLAlphaIndexMarkImportContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, - enum XMLTextPElemTokens nTok, XMLHints_Impl& rHints); protected: /** process primary + secondary keys */ - virtual void ProcessAttribute(sal_Int32 nAttributeToken, + virtual void ProcessAttribute(sal_Int32 nElement, sal_Int32 nAttributeToken, const OUString& sValue, Reference<beans::XPropertySet>& rPropSet) override; }; @@ -1429,15 +1335,13 @@ protected: } XMLAlphaIndexMarkImportContext_Impl::XMLAlphaIndexMarkImportContext_Impl( - SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, - enum XMLTextPElemTokens nTok, XMLHints_Impl& rHints) : - XMLIndexMarkImportContext_Impl(rImport, nPrefix, rLocalName, - nTok, rHints) + SvXMLImport& rImport, XMLHints_Impl& rHints) : + XMLIndexMarkImportContext_Impl(rImport, rHints) { } void XMLAlphaIndexMarkImportContext_Impl::ProcessAttribute( - sal_Int32 nAttributeToken, const OUString& sValue, + sal_Int32 nElement, sal_Int32 nAttributeToken, const OUString& sValue, Reference<beans::XPropertySet>& rPropSet) { switch (nAttributeToken) @@ -1470,21 +1374,19 @@ void XMLAlphaIndexMarkImportContext_Impl::ProcessAttribute( } default: XMLIndexMarkImportContext_Impl::ProcessAttribute( - nAttributeToken, sValue, rPropSet); + nElement, nAttributeToken, sValue, rPropSet); } } XMLImpSpanContext_Impl::XMLImpSpanContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const Reference< xml::sax::XAttributeList > & xAttrList, + sal_Int32 /*nElement*/, + const Reference< xml::sax::XFastAttributeList > & xAttrList, XMLHints_Impl& rHints, bool& rIgnLeadSpace, - sal_uInt8 nSFConvFlags - ) -: SvXMLImportContext( rImport, nPrfx, rLName ) + sal_uInt8 nSFConvFlags) +: SvXMLImportContext( rImport ) , m_rHints( rHints ) , pHint( nullptr ) , rIgnoreLeadingSpace( rIgnLeadSpace ) @@ -1492,18 +1394,13 @@ XMLImpSpanContext_Impl::XMLImpSpanContext_Impl( { OUString aStyleName; - 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( XML_NAMESPACE_TEXT == nPrefix && - IsXMLToken( aLocalName, XML_STYLE_NAME ) ) - aStyleName = xAttrList->getValueByIndex( i ); + if( aIter.getToken() == XML_ELEMENT(TEXT, XML_STYLE_NAME) ) + { + aStyleName = aIter.toString(); + break; + } } if( !aStyleName.isEmpty() ) @@ -1514,7 +1411,7 @@ XMLImpSpanContext_Impl::XMLImpSpanContext_Impl( } } -XMLImpSpanContext_Impl::~XMLImpSpanContext_Impl() +void XMLImpSpanContext_Impl::endFastElement(sal_Int32 ) { if (!pHint) return; @@ -1526,11 +1423,10 @@ XMLImpSpanContext_Impl::~XMLImpSpanContext_Impl() pHint->SetEnd(xCrsrRange->getStart()); } -SvXMLImportContextRef XMLImpSpanContext_Impl::CreateChildContext( +css::uno::Reference< css::xml::sax::XFastContextHandler > XMLImpSpanContext_Impl::CreateSpanContext( SvXMLImport& rImport, - sal_uInt16 nPrefix, const OUString& rLocalName, - const Reference< xml::sax::XAttributeList > & xAttrList, - sal_uInt16 nToken, + sal_Int32 nElement, + const Reference< xml::sax::XFastAttributeList > & xAttrList, XMLHints_Impl& rHints, bool& rIgnoreLeadingSpace, sal_uInt8 nStarFontsConvFlags @@ -1538,39 +1434,34 @@ SvXMLImportContextRef XMLImpSpanContext_Impl::CreateChildContext( { SvXMLImportContext *pContext = nullptr; - switch( nToken ) + switch( nElement ) { - case XML_TOK_TEXT_SPAN: - pContext = new XMLImpSpanContext_Impl( rImport, nPrefix, - rLocalName, xAttrList, + case XML_ELEMENT(TEXT, XML_SPAN): + pContext = new XMLImpSpanContext_Impl( rImport, nElement, + xAttrList, rHints, rIgnoreLeadingSpace ,nStarFontsConvFlags ); break; - case XML_TOK_TEXT_TAB_STOP: - pContext = new XMLCharContext( rImport, nPrefix, - rLocalName, xAttrList, + case XML_ELEMENT(TEXT, XML_TAB): + pContext = new XMLCharContext( rImport, xAttrList, 0x0009, false ); rIgnoreLeadingSpace = false; break; - case XML_TOK_TEXT_LINE_BREAK: - pContext = new XMLCharContext( rImport, nPrefix, - rLocalName, xAttrList, - ControlCharacter::LINE_BREAK ); + case XML_ELEMENT(TEXT, XML_LINE_BREAK): + pContext = new XMLCharContext( rImport, ControlCharacter::LINE_BREAK ); rIgnoreLeadingSpace = false; break; - case XML_TOK_TEXT_S: - pContext = new XMLCharContext( rImport, nPrefix, - rLocalName, xAttrList, - 0x0020, true ); + case XML_ELEMENT(TEXT, XML_S): + pContext = new XMLCharContext( rImport, xAttrList, 0x0020, true ); rIgnoreLeadingSpace = false; break; - case XML_TOK_TEXT_HYPERLINK: + case XML_ELEMENT(TEXT, XML_A): { // test for HyperLinkURL property. If present, insert link as // text property (StarWriter), else try to insert as text @@ -1581,16 +1472,14 @@ SvXMLImportContextRef XMLImpSpanContext_Impl::CreateChildContext( { pContext = new XMLImpHyperlinkContext_Impl( rImport, - nPrefix, - rLocalName, + nElement, xAttrList, rHints, rIgnoreLeadingSpace ); } else { - pContext = new XMLUrlFieldImportContext(rImport, *rImport.GetTextImport(), nPrefix, - rLocalName); + pContext = new XMLUrlFieldImportContext(rImport, *rImport.GetTextImport()); //whitespace handling like other fields rIgnoreLeadingSpace = false; @@ -1598,64 +1487,58 @@ SvXMLImportContextRef XMLImpSpanContext_Impl::CreateChildContext( break; } - case XML_TOK_TEXT_RUBY: - pContext = new XMLImpRubyContext_Impl( rImport, nPrefix, - rLocalName, xAttrList, + case XML_ELEMENT(TEXT, XML_RUBY): + pContext = new XMLImpRubyContext_Impl( rImport, nElement, + xAttrList, rHints, rIgnoreLeadingSpace ); break; - case XML_TOK_TEXT_NOTE: + case XML_ELEMENT(TEXT, XML_NOTE): if (rImport.GetTextImport()->IsInFrame()) { // we must not insert footnotes into text frames - pContext = new SvXMLImportContext( rImport, nPrefix, - rLocalName ); + pContext = new SvXMLImportContext( rImport ); } else { - pContext = new XMLFootnoteImportContext(rImport, *rImport.GetTextImport(), nPrefix, - rLocalName); + pContext = new XMLFootnoteImportContext(rImport, *rImport.GetTextImport()); } rIgnoreLeadingSpace = false; break; - case XML_TOK_TEXT_REFERENCE: - case XML_TOK_TEXT_BOOKMARK: - case XML_TOK_TEXT_BOOKMARK_START: - case XML_TOK_TEXT_BOOKMARK_END: + case XML_ELEMENT(TEXT, XML_REFERENCE_MARK): + case XML_ELEMENT(TEXT, XML_BOOKMARK): + case XML_ELEMENT(TEXT, XML_BOOKMARK_START): + case XML_ELEMENT(TEXT, XML_BOOKMARK_END): pContext = new XMLTextMarkImportContext(rImport, *rImport.GetTextImport(), - rHints.GetCrossRefHeadingBookmark(), nPrefix, - rLocalName); + rHints.GetCrossRefHeadingBookmark()); break; - case XML_TOK_TEXT_FIELDMARK: - case XML_TOK_TEXT_FIELDMARK_START: - case XML_TOK_TEXT_FIELDMARK_END: + case XML_ELEMENT(FIELD, XML_FIELDMARK): + case XML_ELEMENT(FIELD, XML_FIELDMARK_START): + case XML_ELEMENT(FIELD, XML_FIELDMARK_END): pContext = new XMLTextMarkImportContext(rImport, *rImport.GetTextImport(), - rHints.GetCrossRefHeadingBookmark(), nPrefix, - rLocalName); + rHints.GetCrossRefHeadingBookmark()); break; - case XML_TOK_TEXT_REFERENCE_START: + case XML_ELEMENT(TEXT, XML_REFERENCE_MARK_START): pContext = new XMLStartReferenceContext_Impl( rImport, - nPrefix, rLocalName, rHints, xAttrList ); break; - case XML_TOK_TEXT_REFERENCE_END: + case XML_ELEMENT(TEXT, XML_REFERENCE_MARK_END): pContext = new XMLEndReferenceContext_Impl( rImport, - nPrefix, rLocalName, rHints, xAttrList ); break; - case XML_TOK_TEXT_FRAME: + case XML_ELEMENT(DRAW, XML_FRAME): { Reference < XTextRange > xAnchorPos = rImport.GetTextImport()->GetCursor()->getStart(); XMLTextFrameContext *pTextFrameContext = - new XMLTextFrameContext( rImport, nPrefix, - rLocalName, xAttrList, + new XMLTextFrameContext( rImport, + rImport.convertToSlowAttrList(xAttrList), TextContentAnchorType_AS_CHARACTER ); // Remove check for text content. (#i33242#) // Check for text content is done on the processing of the hint @@ -1669,83 +1552,78 @@ SvXMLImportContextRef XMLImpSpanContext_Impl::CreateChildContext( rIgnoreLeadingSpace = false; } break; - case XML_TOK_DRAW_A: + case XML_ELEMENT(DRAW, XML_A): { Reference < XTextRange > xAnchorPos(rImport.GetTextImport()->GetCursor()->getStart()); pContext = - new XMLTextFrameHyperlinkContext( rImport, nPrefix, - rLocalName, xAttrList, + new XMLTextFrameHyperlinkContext( rImport, nElement, + xAttrList, TextContentAnchorType_AS_CHARACTER ); rHints.push_back( std::make_unique<XMLTextFrameHint_Impl>(pContext, xAnchorPos)); } break; - case XML_TOK_TEXT_TOC_MARK: - case XML_TOK_TEXT_TOC_MARK_START: + case XML_ELEMENT(TEXT, XML_TOC_MARK): + case XML_ELEMENT(TEXT, XML_TOC_MARK_START): pContext = new XMLTOCMarkImportContext_Impl( - rImport, nPrefix, rLocalName, - static_cast<enum XMLTextPElemTokens>(nToken), rHints); + rImport, rHints); break; - case XML_TOK_TEXT_USER_INDEX_MARK: - case XML_TOK_TEXT_USER_INDEX_MARK_START: + case XML_ELEMENT(TEXT, XML_USER_INDEX_MARK): + case XML_ELEMENT(TEXT, XML_USER_INDEX_MARK_START): pContext = new XMLUserIndexMarkImportContext_Impl( - rImport, nPrefix, rLocalName, - static_cast<enum XMLTextPElemTokens>(nToken), rHints); + rImport, rHints); break; - case XML_TOK_TEXT_ALPHA_INDEX_MARK: - case XML_TOK_TEXT_ALPHA_INDEX_MARK_START: + case XML_ELEMENT(TEXT, XML_ALPHABETICAL_INDEX_MARK): + case XML_ELEMENT(TEXT, XML_ALPHABETICAL_INDEX_MARK_START): pContext = new XMLAlphaIndexMarkImportContext_Impl( - rImport, nPrefix, rLocalName, - static_cast<enum XMLTextPElemTokens>(nToken), rHints); + rImport, rHints); break; - case XML_TOK_TEXT_TOC_MARK_END: - case XML_TOK_TEXT_USER_INDEX_MARK_END: - case XML_TOK_TEXT_ALPHA_INDEX_MARK_END: + case XML_ELEMENT(TEXT, XML_TOC_MARK_END): + case XML_ELEMENT(TEXT, XML_USER_INDEX_MARK_END): + case XML_ELEMENT(TEXT, XML_ALPHABETICAL_INDEX_MARK_END): pContext = new XMLIndexMarkImportContext_Impl( - rImport, nPrefix, rLocalName, static_cast<enum XMLTextPElemTokens>(nToken), - rHints); + rImport, rHints); break; - case XML_TOK_TEXTP_CHANGE_START: - case XML_TOK_TEXTP_CHANGE_END: - case XML_TOK_TEXTP_CHANGE: + case XML_ELEMENT(TEXT, XML_CHANGE_START): + case XML_ELEMENT(TEXT, XML_CHANGE_END): + case XML_ELEMENT(TEXT, XML_CHANGE): pContext = new XMLChangeImportContext( - rImport, nPrefix, rLocalName, - ((nToken == XML_TOK_TEXTP_CHANGE_END) + rImport, + ((nElement == XML_ELEMENT(TEXT, XML_CHANGE_END)) ? XMLChangeImportContext::Element::END - : (nToken == XML_TOK_TEXTP_CHANGE_START) + : (nElement == XML_ELEMENT(TEXT, XML_CHANGE_START)) ? XMLChangeImportContext::Element::START : XMLChangeImportContext::Element::POINT), false); break; - case XML_TOK_TEXT_META: - pContext = new XMLMetaImportContext(rImport, nPrefix, rLocalName, + case XML_ELEMENT(TEXT, XML_META): + pContext = new XMLMetaImportContext(rImport, nElement, rHints, rIgnoreLeadingSpace ); break; - case XML_TOK_TEXT_META_FIELD: - pContext = new XMLMetaFieldImportContext(rImport, nPrefix, rLocalName, + case XML_ELEMENT(TEXT, XML_META_FIELD): + pContext = new XMLMetaFieldImportContext(rImport, nElement, rHints, rIgnoreLeadingSpace ); break; default: // none of the above? then it's probably a text field! pContext = XMLTextFieldImportContext::CreateTextFieldImportContext( - rImport, *rImport.GetTextImport(), nPrefix, rLocalName, nToken); + rImport, *rImport.GetTextImport(), nElement); // #108784# import draw elements (except control shapes in headers) if( pContext == nullptr && !( rImport.GetTextImport()->IsInHeaderFooter() && - nPrefix == XML_NAMESPACE_DRAW && - IsXMLToken( rLocalName, XML_CONTROL ) ) ) + nElement == XML_ELEMENT(DRAW, XML_CONTROL ) ) ) { Reference < XShapes > xShapes; SvXMLShapeContext* pShapeContext = rImport.GetShapeImport()->CreateGroupChildContext( - rImport, nPrefix, rLocalName, xAttrList, xShapes ); + rImport, nElement, xAttrList, xShapes ); pContext = pShapeContext; // OD 2004-04-20 #i26791# - keep shape in a text frame hint to // adjust its anchor position, if its at-character anchored @@ -1758,19 +1636,17 @@ SvXMLImportContextRef XMLImpSpanContext_Impl::CreateChildContext( rIgnoreLeadingSpace = false; } + if (!pContext) + XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); return pContext; } -SvXMLImportContextRef XMLImpSpanContext_Impl::CreateChildContext( - sal_uInt16 nPrefix, const OUString& rLocalName, - const Reference< xml::sax::XAttributeList > & xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > XMLImpSpanContext_Impl::createFastChildContext( + sal_Int32 nElement, + const uno::Reference< xml::sax::XFastAttributeList>& xAttrList ) { - const SvXMLTokenMap& rTokenMap = - GetImport().GetTextImport()->GetTextPElemTokenMap(); - sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName ); - - return CreateChildContext( GetImport(), nPrefix, rLocalName, xAttrList, - nToken, m_rHints, rIgnoreLeadingSpace + return CreateSpanContext( GetImport(), nElement, xAttrList, + m_rHints, rIgnoreLeadingSpace ,nStarFontsConvFlags ); } @@ -2280,18 +2156,15 @@ void XMLParaContext::endFastElement(sal_Int32 ) m_xHints.reset(); } -SvXMLImportContextRef XMLParaContext::CreateChildContext( - sal_uInt16 nPrefix, const OUString& rLocalName, - const Reference< xml::sax::XAttributeList > & xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > XMLParaContext::createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { - const SvXMLTokenMap& rTokenMap = - GetImport().GetTextImport()->GetTextPElemTokenMap(); - sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName ); if (!m_xHints) m_xHints.reset(new XMLHints_Impl); - return XMLImpSpanContext_Impl::CreateChildContext( - GetImport(), nPrefix, rLocalName, xAttrList, - nToken, *m_xHints, bIgnoreLeadingSpace, + return XMLImpSpanContext_Impl::CreateSpanContext( + GetImport(), nElement, xAttrList, + *m_xHints, bIgnoreLeadingSpace, nStarFontsConvFlags); } diff --git a/xmloff/source/text/txtparai.hxx b/xmloff/source/text/txtparai.hxx index 3f64045c593d..8c8948a6ba9f 100644 --- a/xmloff/source/text/txtparai.hxx +++ b/xmloff/source/text/txtparai.hxx @@ -70,9 +70,8 @@ public: 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; virtual void SAL_CALL characters( const OUString& rChars ) override; |