summaryrefslogtreecommitdiff
path: root/sc/source/filter/excel
diff options
context:
space:
mode:
authorLászló Németh <laszlo.nemeth@collabora.com>2015-01-27 09:17:50 +0100
committerLászló Németh <laszlo.nemeth@collabora.com>2015-01-27 09:20:14 +0100
commit779581feed4886313746a71e9e738d736977be1b (patch)
tree9b630f18061d7b07cb743866dfd1eb5e2747ee7d /sc/source/filter/excel
parent58a50c3dc74cc9bd298d6b4156e45a8dbbffc116 (diff)
tdf#88810 avoid unnecessary massive O(U)String allocations in XLSX export
Using OStringBuffer instead of fixed size character arrays. Change-Id: I06b705e2159a1ef5990f9eb0ffedd20fe277c616
Diffstat (limited to 'sc/source/filter/excel')
-rw-r--r--sc/source/filter/excel/xeroot.cxx1
-rw-r--r--sc/source/filter/excel/xestream.cxx10
-rw-r--r--sc/source/filter/excel/xetable.cxx10
3 files changed, 17 insertions, 4 deletions
diff --git a/sc/source/filter/excel/xeroot.cxx b/sc/source/filter/excel/xeroot.cxx
index 819fe93553db..29f655160771 100644
--- a/sc/source/filter/excel/xeroot.cxx
+++ b/sc/source/filter/excel/xeroot.cxx
@@ -57,6 +57,7 @@ XclExpRootData::XclExpRootData( XclBiff eBiff, SfxMedium& rMedium,
{
SvtSaveOptions aSaveOpt;
mbRelUrl = mrMedium.IsRemote() ? aSaveOpt.IsSaveRelINet() : aSaveOpt.IsSaveRelFSys();
+ maStringBuf = OStringBuffer(10); // for simple addresses, like ABC1000000
}
XclExpRootData::~XclExpRootData()
diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx
index e5ff50c431c7..04dbb5f0086a 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -718,6 +718,11 @@ OString XclXmlUtils::ToOString( const OUString& s )
return OUStringToOString( s, RTL_TEXTENCODING_UTF8 );
}
+bool XclXmlUtils::TryToOString( OStringBuffer& s, const ScAddress& rAddress )
+{
+ return rAddress.TryFormat(s, SCA_VALID, NULL, ScAddress::Details( FormulaGrammar::CONV_XL_A1));
+}
+
OString XclXmlUtils::ToOString( const ScAddress& rAddress )
{
OUString sAddress(rAddress.Format(SCA_VALID, NULL, ScAddress::Details( FormulaGrammar::CONV_XL_A1)));
@@ -760,6 +765,11 @@ static ScAddress lcl_ToAddress( const XclAddress& rAddress )
return aAddress;
}
+bool XclXmlUtils::TryToOString( OStringBuffer& s, const XclAddress& rAddress )
+{
+ return TryToOString( s, lcl_ToAddress( rAddress ));
+}
+
OString XclXmlUtils::ToOString( const XclAddress& rAddress )
{
return ToOString( lcl_ToAddress( rAddress ) );
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index 70f3373771b4..5919c6145c01 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -631,8 +631,9 @@ static OString lcl_GetStyleId( XclExpXmlStream& rStrm, const XclExpCellBase& rCe
void XclExpNumberCell::SaveXml( XclExpXmlStream& rStrm )
{
sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
+ OStringBuffer rBuf = rStrm.GetRoot().GetStringBuf();
rWorksheet->startElement( XML_c,
- XML_r, XclXmlUtils::ToOString( GetXclPos() ).getStr(),
+ XML_r, XclXmlUtils::TryToOString( rBuf, GetXclPos() ) ? rBuf.getStr() : XclXmlUtils::ToOString( GetXclPos() ).getStr(),
XML_s, lcl_GetStyleId( rStrm, *this ).getStr(),
XML_t, "n",
// OOXTODO: XML_cm, XML_vm, XML_ph
@@ -923,11 +924,11 @@ void XclExpFormulaCell::SaveXml( XclExpXmlStream& rStrm )
{
const char* sType = NULL;
OUString sValue;
-
XclXmlUtils::GetFormulaTypeAndValue( mrScFmlaCell, sType, sValue );
sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
+ OStringBuffer rBuf = rStrm.GetRoot().GetStringBuf();
rWorksheet->startElement( XML_c,
- XML_r, XclXmlUtils::ToOString( GetXclPos() ).getStr(),
+ XML_r, XclXmlUtils::TryToOString( rBuf, GetXclPos() ) ? rBuf.getStr() : XclXmlUtils::ToOString( GetXclPos() ).getStr(),
XML_s, lcl_GetStyleId( rStrm, *this ).getStr(),
XML_t, sType,
// OOXTODO: XML_cm, XML_vm, XML_ph
@@ -1308,8 +1309,9 @@ bool XclExpRkCell::TryMerge( const XclExpCellBase& rCell )
void XclExpRkCell::WriteXmlContents( XclExpXmlStream& rStrm, const XclAddress& rAddress, sal_uInt32 nXFId, sal_uInt16 nRelCol )
{
sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
+ OStringBuffer rBuf = rStrm.GetRoot().GetStringBuf();
rWorksheet->startElement( XML_c,
- XML_r, XclXmlUtils::ToOString( rAddress ).getStr(),
+ XML_r, XclXmlUtils::TryToOString( rBuf, rAddress ) ? rBuf.getStr() : XclXmlUtils::ToOString( rAddress ).getStr(),
XML_s, lcl_GetStyleId( rStrm, nXFId ).getStr(),
XML_t, "n",
// OOXTODO: XML_cm, XML_vm, XML_ph