sc/inc/column.hxx | 7 +++++++ sc/qa/unit/ucalc.cxx | 16 ++++++++++++++++ sc/source/core/data/column.cxx | 1 + sc/source/core/data/column2.cxx | 12 ++++++++---- 4 files changed, 32 insertions(+), 4 deletions(-)
New commits: commit f8bba58996e07b66d3fc6f31b181dc8d67a5654e Author: Kohei Yoshida <[email protected]> Date: Fri Mar 15 15:15:57 2013 -0400 Unit test to catch the out-of-sync text width bug I just fixed today. Change-Id: I82d4199d7f8b7ba2dadb734a808dac53e845538f diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index f34dfb5..ec94652 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -6102,6 +6102,22 @@ void Test::testCellTextWidth() CPPUNIT_ASSERT_MESSAGE("Iterator should have ended.", !pIter->hasCell()); } + // Delete row 2 which shifts all cells below row 2 upward. After this, we + // should only have cells at rows 0 and 17. + m_pDoc->DeleteRow(0, 0, MAXCOL, MAXTAB, 2, 1); + { + // Full range again. + pIter.reset(new ScColumnTextWidthIterator(*m_pDoc, aTopCell, MAXROW)); + SCROW aRows[] = { 0, 17 }; + size_t n = SAL_N_ELEMENTS(aRows); + for (size_t i = 0; i < n; ++i, pIter->next()) + { + CPPUNIT_ASSERT_MESSAGE("Cell expected, but not there.", pIter->hasCell()); + CPPUNIT_ASSERT_EQUAL(aRows[i], pIter->getPos()); + } + CPPUNIT_ASSERT_MESSAGE("Iterator should have ended.", !pIter->hasCell()); + } + m_pDoc->DeleteTab(0); } commit 3ad7485967376871281116784900d26228482474 Author: Kohei Yoshida <[email protected]> Date: Fri Mar 15 15:06:25 2013 -0400 Set up new container to store cell text's script type. Change-Id: I0330dea1b2f85a8ba12cb232ab8b4263607ba225 diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index dd14b6a..2469a6c 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -91,12 +91,19 @@ struct ColEntry class ScColumn { typedef mdds::multi_type_vector<mdds::mtv::element_block_func> TextWidthType; + typedef mdds::multi_type_vector<mdds::mtv::element_block_func> ScriptType; // Only stores empty or unsigned short values. Empty values correspond // with empty cells. All non-empty cell positions must have unsigned short // values; either the reall text widths or TEXTWIDTH_DIRTY. TextWidthType maTextWidths; + // Empty elements represent unknown script types. For now, we store script + // type values as unsigned shorts. Once multi_type_vector supports char + // and unsigned char (due in 0.7.2), we can switch to that to save storage + // space. + ScriptType maScriptTypes; + SCCOL nCol; SCTAB nTab; diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index a53c8a8..b472e9e 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -61,6 +61,7 @@ ScNeededSizeOptions::ScNeededSizeOptions() : ScColumn::ScColumn() : maTextWidths(MAXROWCOUNT), + maScriptTypes(MAXROWCOUNT), nCol( 0 ), pAttrArray( NULL ), pDocument( NULL ) diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 84cc89d..2715fb9 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -1445,18 +1445,22 @@ void ScColumn::SetTextWidth(SCROW nRow, unsigned short nWidth) sal_uInt8 ScColumn::GetScriptType( SCROW nRow ) const { - if (!ValidRow(nRow)) + if (!ValidRow(nRow) || maScriptTypes.is_empty(nRow)) return SC_SCRIPTTYPE_UNKNOWN; - return SC_SCRIPTTYPE_UNKNOWN; + return maScriptTypes.get<unsigned short>(nRow); } -void ScColumn::SetScriptType( SCROW nRow, sal_uInt8 /*nType*/ ) +void ScColumn::SetScriptType( SCROW nRow, sal_uInt8 nType ) { if (!ValidRow(nRow)) return; - // TODO: Implement this. + if (nType == SC_SCRIPTTYPE_UNKNOWN) + // empty element represents unknown script type. + maScriptTypes.set_empty(nRow, nRow); + else + maScriptTypes.set<unsigned short>(nRow, nType); } void ScColumn::FindDataAreaPos(SCROW& rRow, bool bDown) const _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
