summaryrefslogtreecommitdiff
path: root/sc/source/core
diff options
context:
space:
mode:
authorLászló Németh <laszlo.nemeth@collabora.com>2015-01-26 15:45:05 +0100
committerLászló Németh <laszlo.nemeth@collabora.com>2015-01-26 15:54:01 +0100
commitace8f9c2a31795cc2329c6bb27deacde9f4c18df (patch)
treec7c30cb015863693e098be4ab56f25339beaebf6 /sc/source/core
parentc221a1b93dd70a14b897c3a96b8e032cd97b9593 (diff)
fdo#88810 avoid unnecessary massive O(U)String allocations in XLSX export
Change-Id: Ie6a024463e7ee9b0f4492b2431533708a578faf0
Diffstat (limited to 'sc/source/core')
-rw-r--r--sc/source/core/tool/address.cxx45
1 files changed, 45 insertions, 0 deletions
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index 1efcac723c3f..bb7a1bf4fc6d 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -1745,6 +1745,51 @@ static OUString getFileNameFromDoc( const ScDocument* pDoc )
return sFileName;
}
+/** Tries to obtain a simple address without OUString/OString allocation
+ *
+ * @returns TRUE at success (it is enough to call OUString Format() at FALSE)
+ *
+ */
+
+bool ScAddress::TryFormat(char * s, sal_uInt16 nFlags, const ScDocument* pDoc,
+ const Details& rDetails) const
+{
+ if( nFlags & SCA_VALID )
+ nFlags |= ( SCA_VALID_ROW | SCA_VALID_COL | SCA_VALID_TAB );
+ if(( pDoc && (nFlags & SCA_VALID_TAB ) && ( nTab >= pDoc->GetTableCount() || ( nFlags & SCA_TAB_3D ))) ||
+ ! (nFlags & SCA_VALID_COL) || ! (nFlags & SCA_VALID_ROW) ||
+ (nFlags & SCA_COL_ABSOLUTE) != 0 || (nFlags & SCA_ROW_ABSOLUTE) != 0 )
+ {
+ return false;
+ }
+
+ switch( rDetails.eConv )
+ {
+ default :
+ // Note: length of s (defined by SIMPLEADDRESSLEN) supports the following simple addresses
+ case formula::FormulaGrammar::CONV_OOO:
+ case formula::FormulaGrammar::CONV_XL_A1:
+ case formula::FormulaGrammar::CONV_XL_OOX:
+ if (nCol >= 26 * 26)
+ // TODO: extend it for full column range
+ return false;
+ if( nCol < 26 )
+ *s = 'A' + nCol;
+ else
+ {
+ *s = 'A' + nCol / 26 - 1;
+ s++;
+ *s = 'A' + nCol % 26;
+ }
+ sprintf(s + 1, "%d", nRow + 1);
+ break;
+ case formula::FormulaGrammar::CONV_XL_R1C1:
+ // not used in XLSX export
+ return false;
+ }
+ return true;
+}
+
OUString ScAddress::Format(sal_uInt16 nFlags, const ScDocument* pDoc,
const Details& rDetails) const
{