summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-02-28 15:56:40 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-03-02 07:44:26 +0100
commit0cf5d0fa5e1a7d5dafa7e899e065edb042764f44 (patch)
tree32eea22346cc65464a477882f39257f1931dec73
parent201a7652092c6a7796a59e6ddee144e4f0c9ece9 (diff)
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.grandin@collabora.co.uk>
-rw-r--r--dbaccess/source/filter/xml/xmlTableFilterPattern.cxx10
-rw-r--r--dbaccess/source/filter/xml/xmlTableFilterPattern.hxx3
-rw-r--r--include/xmloff/XMLBase64ImportContext.hxx2
-rw-r--r--reportdesign/source/filter/xml/xmlCondPrtExpr.hxx1
-rw-r--r--xmloff/source/chart/SchXMLPlotAreaContext.cxx9
-rw-r--r--xmloff/source/chart/SchXMLPlotAreaContext.hxx2
-rw-r--r--xmloff/source/core/DocumentSettingsContext.cxx59
-rw-r--r--xmloff/source/core/XMLBase64ImportContext.cxx28
-rw-r--r--xmloff/source/text/XMLTextFrameContext.cxx89
9 files changed, 97 insertions, 106 deletions
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,