dbaccess/source/filter/xml/xmlTableFilterPattern.cxx | 10 +- dbaccess/source/filter/xml/xmlTableFilterPattern.hxx | 3 include/xmloff/XMLBase64ImportContext.hxx | 2 reportdesign/source/filter/xml/xmlCondPrtExpr.hxx | 1 xmloff/source/chart/SchXMLPlotAreaContext.cxx | 9 + xmloff/source/chart/SchXMLPlotAreaContext.hxx | 2 xmloff/source/core/DocumentSettingsContext.cxx | 59 ++++-------- xmloff/source/core/XMLBase64ImportContext.cxx | 28 +---- xmloff/source/text/XMLTextFrameContext.cxx | 89 +++++++++---------- 9 files changed, 97 insertions(+), 106 deletions(-)
New commits: commit 0cf5d0fa5e1a7d5dafa7e899e065edb042764f44 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Feb 28 15:56:40 2020 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Mar 2 07:44:26 2020 +0100 don't rely on parser ::characters callback only firing once which is true for the old parser, but not always so for the FastParser. So pre-emptively fix some stuff Change-Id: I405834f1dfd28c98cae87b6de38d238f723edafd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89712 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/dbaccess/source/filter/xml/xmlTableFilterPattern.cxx b/dbaccess/source/filter/xml/xmlTableFilterPattern.cxx index 0e60eec92290..0c4b2892d2b7 100644 --- a/dbaccess/source/filter/xml/xmlTableFilterPattern.cxx +++ b/dbaccess/source/filter/xml/xmlTableFilterPattern.cxx @@ -42,10 +42,16 @@ OXMLTableFilterPattern::~OXMLTableFilterPattern() void OXMLTableFilterPattern::characters( const OUString& rChars ) { + maBuffer.append(rChars); +} + +void OXMLTableFilterPattern::endFastElement( sal_Int32 ) +{ + OUString sChars = maBuffer.makeStringAndClear(); if ( m_bNameFilter ) - m_rParent.pushTableFilterPattern(rChars); + m_rParent.pushTableFilterPattern(sChars); else - m_rParent.pushTableTypeFilter(rChars); + m_rParent.pushTableTypeFilter(sChars); } } // namespace dbaxml diff --git a/dbaccess/source/filter/xml/xmlTableFilterPattern.hxx b/dbaccess/source/filter/xml/xmlTableFilterPattern.hxx index 81f479898a77..2c6fbb2c76bc 100644 --- a/dbaccess/source/filter/xml/xmlTableFilterPattern.hxx +++ b/dbaccess/source/filter/xml/xmlTableFilterPattern.hxx @@ -19,6 +19,7 @@ #ifndef INCLUDED_DBACCESS_SOURCE_FILTER_XML_XMLTABLEFILTERPATTERN_HXX #define INCLUDED_DBACCESS_SOURCE_FILTER_XML_XMLTABLEFILTERPATTERN_HXX +#include <rtl/ustrbuf.hxx> #include <xmloff/xmlictxt.hxx> namespace dbaxml @@ -28,6 +29,7 @@ namespace dbaxml { OXMLTableFilterList& m_rParent; bool m_bNameFilter; + OUStringBuffer maBuffer; public: OXMLTableFilterPattern( SvXMLImport& rImport ,bool _bNameFilter @@ -37,6 +39,7 @@ namespace dbaxml virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override; virtual void SAL_CALL characters( const OUString& rChars ) override; }; } // namespace dbaxml diff --git a/include/xmloff/XMLBase64ImportContext.hxx b/include/xmloff/XMLBase64ImportContext.hxx index ff302064bdf6..8169b64281eb 100644 --- a/include/xmloff/XMLBase64ImportContext.hxx +++ b/include/xmloff/XMLBase64ImportContext.hxx @@ -32,7 +32,7 @@ namespace com { namespace sun { namespace star { namespace io { class XMLOFF_DLLPUBLIC XMLBase64ImportContext final : public SvXMLImportContext { css::uno::Reference< css::io::XOutputStream > xOut; - OUString sBase64CharsLeft; + OUStringBuffer maCharBuffer; public: diff --git a/reportdesign/source/filter/xml/xmlCondPrtExpr.hxx b/reportdesign/source/filter/xml/xmlCondPrtExpr.hxx index 44460e4b0fdd..dfa7674e0e1a 100644 --- a/reportdesign/source/filter/xml/xmlCondPrtExpr.hxx +++ b/reportdesign/source/filter/xml/xmlCondPrtExpr.hxx @@ -30,6 +30,7 @@ namespace rptxml { css::uno::Reference< css::beans::XPropertySet > m_xComponent; OUStringBuffer m_aCharBuffer; + OXMLCondPrtExpr(const OXMLCondPrtExpr&) = delete; void operator =(const OXMLCondPrtExpr&) = delete; public: diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx index 471478a824ae..01fdcf769fb0 100644 --- a/xmloff/source/chart/SchXMLPlotAreaContext.cxx +++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx @@ -591,9 +591,14 @@ SchXMLDataLabelSpanContext::SchXMLDataLabelSpanContext( SvXMLImport& rImport, co { } -void SchXMLDataLabelSpanContext::Characters(const OUString& sChars) +void SchXMLDataLabelSpanContext::Characters(const OUString& rChars) { - mrLabels.push_back(sChars); + maCharBuffer.append(rChars); +} + +void SchXMLDataLabelSpanContext::EndElement() +{ + mrLabels.push_back(maCharBuffer.makeStringAndClear()); } SchXMLDataLabelParaContext::SchXMLDataLabelParaContext( SvXMLImport& rImport, const OUString& rLocalName, ::std::vector<OUString>& rLabels): diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.hxx b/xmloff/source/chart/SchXMLPlotAreaContext.hxx index 748aca4069e4..d43179db2981 100644 --- a/xmloff/source/chart/SchXMLPlotAreaContext.hxx +++ b/xmloff/source/chart/SchXMLPlotAreaContext.hxx @@ -141,9 +141,11 @@ class SchXMLDataLabelSpanContext: public SvXMLImportContext { private: ::std::vector<OUString>& mrLabels; + OUStringBuffer maCharBuffer; public: SchXMLDataLabelSpanContext( SvXMLImport& rImport, const OUString& rLocalName, ::std::vector<OUString>& rLabels); virtual void Characters( const OUString& rChars ) override; + virtual void EndElement() override; }; class SchXMLDataLabelParaContext: public SvXMLImportContext diff --git a/xmloff/source/core/DocumentSettingsContext.cxx b/xmloff/source/core/DocumentSettingsContext.cxx index 454cde1bcbcd..f7e4ea468ee3 100644 --- a/xmloff/source/core/DocumentSettingsContext.cxx +++ b/xmloff/source/core/DocumentSettingsContext.cxx @@ -142,11 +142,10 @@ public: class XMLConfigItemContext : public SvXMLImportContext { OUString msType; - OUString msValue; - uno::Sequence<sal_Int8> maDecoded; css::uno::Any& mrAny; const OUString mrItemName; XMLConfigBaseContext* mpBaseContext; + OUStringBuffer maCharBuffer; public: XMLConfigItemContext(SvXMLImport& rImport, @@ -411,89 +410,73 @@ XMLConfigItemContext::XMLConfigItemContext(SvXMLImport& rImport, void XMLConfigItemContext::characters( const OUString& rChars ) { + maCharBuffer.append(rChars); +} + +void XMLConfigItemContext::endFastElement(sal_Int32 ) +{ + OUString sValue; + uno::Sequence<sal_Int8> aDecoded; if (IsXMLToken(msType, XML_BASE64BINARY)) { - OUString sTrimmedChars( rChars.trim() ); - if( !sTrimmedChars.isEmpty() ) - { - OUString sChars; - if( !msValue.isEmpty() ) - { - sChars = msValue + sTrimmedChars; - msValue.clear(); - } - else - { - sChars = sTrimmedChars; - } - uno::Sequence<sal_Int8> aBuffer((sChars.getLength() / 4) * 3 ); - sal_Int32 const nCharsDecoded = - ::comphelper::Base64::decodeSomeChars( aBuffer, sChars ); - sal_uInt32 nStartPos(maDecoded.getLength()); - sal_uInt32 nCount(aBuffer.getLength()); - maDecoded.realloc(nStartPos + nCount); - std::copy(aBuffer.begin(), aBuffer.end(), std::next(maDecoded.begin(), nStartPos)); - if( nCharsDecoded != sChars.getLength() ) - msValue = sChars.copy( nCharsDecoded ); - } + OUString sChars = maCharBuffer.makeStringAndClear().trim(); + if( !sChars.isEmpty() ) + ::comphelper::Base64::decodeSomeChars( aDecoded, sChars ); } else - msValue += rChars; -} + sValue = maCharBuffer.makeStringAndClear(); -void XMLConfigItemContext::endFastElement(sal_Int32 ) -{ if (mpBaseContext) { if (IsXMLToken(msType, XML_BOOLEAN)) { bool bValue(false); - if (IsXMLToken(msValue, XML_TRUE)) + if (IsXMLToken(sValue, XML_TRUE)) bValue = true; mrAny <<= bValue; } else if (IsXMLToken(msType, XML_BYTE)) { sal_Int32 nValue(0); - ::sax::Converter::convertNumber(nValue, msValue); + ::sax::Converter::convertNumber(nValue, sValue); mrAny <<= static_cast<sal_Int8>(nValue); } else if (IsXMLToken(msType, XML_SHORT)) { sal_Int32 nValue(0); - ::sax::Converter::convertNumber(nValue, msValue); + ::sax::Converter::convertNumber(nValue, sValue); mrAny <<= static_cast<sal_Int16>(nValue); } else if (IsXMLToken(msType, XML_INT)) { sal_Int32 nValue(0); - ::sax::Converter::convertNumber(nValue, msValue); + ::sax::Converter::convertNumber(nValue, sValue); mrAny <<= nValue; } else if (IsXMLToken(msType, XML_LONG)) { - sal_Int64 nValue(msValue.toInt64()); + sal_Int64 nValue(sValue.toInt64()); mrAny <<= nValue; } else if (IsXMLToken(msType, XML_DOUBLE)) { double fValue(0.0); - ::sax::Converter::convertDouble(fValue, msValue); + ::sax::Converter::convertDouble(fValue, sValue); mrAny <<= fValue; } else if (IsXMLToken(msType, XML_STRING)) { - mrAny <<= msValue; + mrAny <<= sValue; } else if (IsXMLToken(msType, XML_DATETIME)) { util::DateTime aDateTime; - ::sax::Converter::parseDateTime(aDateTime, msValue); + ::sax::Converter::parseDateTime(aDateTime, sValue); mrAny <<= aDateTime; } else if (IsXMLToken(msType, XML_BASE64BINARY)) { - mrAny <<= maDecoded; + mrAny <<= aDecoded; } else { SAL_INFO("xmloff.core", diff --git a/xmloff/source/core/XMLBase64ImportContext.cxx b/xmloff/source/core/XMLBase64ImportContext.cxx index f39bd39cb80d..4e46b81811b0 100644 --- a/xmloff/source/core/XMLBase64ImportContext.cxx +++ b/xmloff/source/core/XMLBase64ImportContext.cxx @@ -44,31 +44,19 @@ XMLBase64ImportContext::~XMLBase64ImportContext() void XMLBase64ImportContext::EndElement() { + OUString sChars = maCharBuffer.makeStringAndClear().trim(); + if( !sChars.isEmpty() ) + { + Sequence< sal_Int8 > aBuffer( (sChars.getLength() / 4) * 3 ); + ::comphelper::Base64::decodeSomeChars( aBuffer, sChars ); + xOut->writeBytes( aBuffer ); + } xOut->closeOutput(); } void XMLBase64ImportContext::Characters( const OUString& rChars ) { - OUString sTrimmedChars( rChars. trim() ); - if( !sTrimmedChars.isEmpty() ) - { - OUString sChars; - if( !sBase64CharsLeft.isEmpty() ) - { - sChars = sBase64CharsLeft + sTrimmedChars; - sBase64CharsLeft.clear(); - } - else - { - sChars = sTrimmedChars; - } - Sequence< sal_Int8 > aBuffer( (sChars.getLength() / 4) * 3 ); - sal_Int32 const nCharsDecoded = - ::comphelper::Base64::decodeSomeChars( aBuffer, sChars ); - xOut->writeBytes( aBuffer ); - if( nCharsDecoded != sChars.getLength() ) - sBase64CharsLeft = sChars.copy( nCharsDecoded ); - } + maCharBuffer.append(rChars); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx index e8b04539dd81..7eb3b2b14109 100644 --- a/xmloff/source/text/XMLTextFrameContext.cxx +++ b/xmloff/source/text/XMLTextFrameContext.cxx @@ -360,6 +360,7 @@ class XMLTextFrameContext_Impl : public SvXMLImportContext OUString sFilterService; OUString sBase64CharsLeft; OUString sTblName; + OUStringBuffer maUrlBuffer; ParamMap aParamMap; @@ -1110,6 +1111,50 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( void XMLTextFrameContext_Impl::EndElement() { + if( ( XML_TEXT_FRAME_OBJECT_OLE == nType || + XML_TEXT_FRAME_GRAPHIC == nType) && + !xPropSet.is() && !bCreateFailed ) + { + OUString sTrimmedChars = maUrlBuffer.makeStringAndClear().trim(); + if( !sTrimmedChars.isEmpty() ) + { + if( !xBase64Stream.is() ) + { + if( XML_TEXT_FRAME_GRAPHIC == nType ) + { + xBase64Stream = + GetImport().GetStreamForGraphicObjectURLFromBase64(); + } + else + { + xBase64Stream = + GetImport().GetStreamForEmbeddedObjectURLFromBase64(); + } + if( xBase64Stream.is() ) + bOwnBase64Stream = true; + } + if( bOwnBase64Stream && xBase64Stream.is() ) + { + OUString sChars; + if( !sBase64CharsLeft.isEmpty() ) + { + sChars = sBase64CharsLeft + sTrimmedChars; + sBase64CharsLeft.clear(); + } + else + { + sChars = sTrimmedChars; + } + Sequence< sal_Int8 > aBuffer( (sChars.getLength() / 4) * 3 ); + sal_Int32 nCharsDecoded = + ::comphelper::Base64::decodeSomeChars( aBuffer, sChars ); + xBase64Stream->writeBytes( aBuffer ); + if( nCharsDecoded != sChars.getLength() ) + sBase64CharsLeft = sChars.copy( nCharsDecoded ); + } + } + } + CreateIfNotThere(); if( xOldTextCursor.is() ) @@ -1209,49 +1254,7 @@ SvXMLImportContextRef XMLTextFrameContext_Impl::CreateChildContext( void XMLTextFrameContext_Impl::Characters( const OUString& rChars ) { - if( ( XML_TEXT_FRAME_OBJECT_OLE == nType || - XML_TEXT_FRAME_GRAPHIC == nType) && - !xPropSet.is() && !bCreateFailed ) - { - OUString sTrimmedChars( rChars. trim() ); - if( !sTrimmedChars.isEmpty() ) - { - if( !xBase64Stream.is() ) - { - if( XML_TEXT_FRAME_GRAPHIC == nType ) - { - xBase64Stream = - GetImport().GetStreamForGraphicObjectURLFromBase64(); - } - else - { - xBase64Stream = - GetImport().GetStreamForEmbeddedObjectURLFromBase64(); - } - if( xBase64Stream.is() ) - bOwnBase64Stream = true; - } - if( bOwnBase64Stream && xBase64Stream.is() ) - { - OUString sChars; - if( !sBase64CharsLeft.isEmpty() ) - { - sChars = sBase64CharsLeft + sTrimmedChars; - sBase64CharsLeft.clear(); - } - else - { - sChars = sTrimmedChars; - } - Sequence< sal_Int8 > aBuffer( (sChars.getLength() / 4) * 3 ); - sal_Int32 nCharsDecoded = - ::comphelper::Base64::decodeSomeChars( aBuffer, sChars ); - xBase64Stream->writeBytes( aBuffer ); - if( nCharsDecoded != sChars.getLength() ) - sBase64CharsLeft = sChars.copy( nCharsDecoded ); - } - } - } + maUrlBuffer.append(rChars); } void XMLTextFrameContext_Impl::SetHyperlink( const OUString& rHRef, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits