Skip to content

Instantly share code, notes, and snippets.

@dennisfrancis dennisfrancis/LO16KCOLS.patch Secret
Last active Oct 8, 2015

Embed
What would you like to do?
Initial patch for 16K cols with wrapping std::vector of ScColumn's
commit 47bb29345bcf2846fe74eb3e5f75d3ec2b3b74db
Author: Dennis Francis <dennisfrancis.in@gmail.com>
Date: Tue Oct 6 11:34:15 2015 +0530
16 K cols using dynamic column container - initial attempt
Change-Id: I23a7d0690c8be3a73c02e1a4f40095f781c7818d
diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index 460ca2c..d9ea5d5 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -58,17 +58,21 @@ const SCSIZE SCSIZE_MAX = ::std::numeric_limits<SCSIZE>::max();
// The maximum values. Defines are needed for preprocessor checks, for example
// in bcaslot.cxx, otherwise type safe constants are preferred.
#define MAXROWCOUNT_DEFINE 1048576
+//#define MAXCOLCOUNT_DEFINE 16384
#define MAXCOLCOUNT_DEFINE 1024
+// The minimum number of columns to be allocated
+#define MINCOLCOUNT_DEFINE 1024
// Count values
const SCROW MAXROWCOUNT = MAXROWCOUNT_DEFINE;
const SCCOL MAXCOLCOUNT = MAXCOLCOUNT_DEFINE;
+const SCCOL MINCOLCOUNT = MINCOLCOUNT_DEFINE;
/// limiting to 10000 for now, problem with 32 bit builds for now
const SCTAB MAXTABCOUNT = 10000;
const SCCOLROW MAXCOLROWCOUNT = MAXROWCOUNT;
// Maximum values
const SCROW MAXROW = MAXROWCOUNT - 1;
-const SCCOL MAXCOL = MAXCOLCOUNT - 1;
+const SCCOL MAXCOL = MINCOLCOUNT - 1;
const SCTAB MAXTAB = MAXTABCOUNT - 1;
const SCCOLROW MAXCOLROW = MAXROW;
// Limit the initial tab count to prevent users to set the count too high,
diff --git a/sc/inc/colcontainer.hxx b/sc/inc/colcontainer.hxx
new file mode 100644
index 0000000..b7a5fcc
--- /dev/null
+++ b/sc/inc/colcontainer.hxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SC_INC_COLCONTAINER_HXX
+#define INCLUDED_SC_INC_COLCONTAINER_HXX
+
+#include "types.hxx"
+#include "address.hxx"
+
+#include <vector>
+
+template <class T>
+class ScColContainer
+{
+public:
+ typedef std::vector<T> ScColVec;
+private:
+ ScColVec aCols;
+ SCCOL nCols;
+public:
+ ScColContainer():
+ aCols(MINCOLCOUNT),
+ nCols(MINCOLCOUNT)
+ {}
+ ScColContainer(const int nSize):
+ aCols(nSize),
+ nCols(nSize)
+ {}
+
+ const T& operator[] (const int nIndex) const
+ {
+ if ( nIndex < int(nCols) && nIndex >= 0)
+ return aCols[nIndex];
+ else
+ return aCols[nCols - 1];
+ }
+ const T& operator[] (SCCOL nIndex) const
+ {
+ return (*this)[static_cast<const int>(nIndex)];
+ }
+ const T& operator[] (size_t nIndex) const
+ {
+ return (*this)[static_cast<const int>(nIndex)];
+ }
+
+ T& operator[] (const int nIndex)
+ {
+ if ( nIndex < int(nCols) && nIndex >= 0)
+ return aCols[nIndex];
+ else
+ return aCols[nCols - 1];
+ }
+ T& operator[] (SCCOL nIndex)
+ {
+ return (*this)[static_cast<const int>(nIndex)];
+ }
+ T& operator[] (size_t nIndex)
+ {
+ return (*this)[static_cast<const int>(nIndex)];
+ }
+
+ SCCOL GetMaxCols() const { return nCols; }
+ void SetMaxCols(SCCOL nSize)
+ {
+ if ( nSize == nCols )
+ return;
+ // Do not reduce size below MINCOLCOUNT
+ if ( nSize < MINCOLCOUNT && nCols == MINCOLCOUNT )
+ return;
+ // Do not allocate more than MAXCOLCOUNT
+ if ( nSize > MAXCOLCOUNT )
+ nSize = MAXCOLCOUNT;
+ aCols.resize( nSize );
+ nCols = nSize;
+ return;
+ }
+ const T* GetArray() const { return aCols.data(); }
+ T* GetArray() { return aCols.data(); }
+ void Clear()
+ {
+ aCols.resize(0);
+ nCols = 0;
+ return;
+ }
+};
+
+#endif // INCLUDED_SC_INC_COLCONTAINER_HXX
diff --git a/sc/inc/markdata.hxx b/sc/inc/markdata.hxx
index fc7aec6..32d4200 100644
--- a/sc/inc/markdata.hxx
+++ b/sc/inc/markdata.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_SC_INC_MARKDATA_HXX
#include "address.hxx"
+#include "colcontainer.hxx"
#include "scdllapi.h"
#include <set>
@@ -43,17 +44,18 @@ class SC_DLLPUBLIC ScMarkData
{
public:
typedef std::set<SCTAB> MarkedTabsType;
+ typedef ScColContainer<ScMarkArray> ScMarkArrayContainer;
private:
MarkedTabsType maTabMarked;
ScRange aMarkRange; // area
ScRange aMultiRange; // maximum area altogether
- ScMarkArray* pMultiSel; // multi selection
- bool bMarked:1; // rectangle marked
- bool bMultiMarked:1;
+ ScMarkArrayContainer aMultiSel; // multi selection
+ bool bMarked:1; // rectangle marked
+ bool bMultiMarked:1;
- bool bMarking:1; // area is being marked -> no MarkToMulti
- bool bMarkIsNeg:1; // cancel if multi selection
+ bool bMarking:1; // area is being marked -> no MarkToMulti
+ bool bMarkIsNeg:1; // cancel if multi selection
public:
ScMarkData();
@@ -95,7 +97,7 @@ public:
bool GetMarkingFlag() const { return bMarking; }
// for FillInfo / Document etc.
- const ScMarkArray* GetArray() const { return pMultiSel; }
+ const ScMarkArray* GetArray() const { return aMultiSel.GetArray(); }
bool IsCellMarked( SCCOL nCol, SCROW nRow, bool bNoSimple = false ) const;
void FillRangeListWithMarks( ScRangeList* pList, bool bClear ) const;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 45ed469..1c6a23f 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -33,6 +33,7 @@
#include "cellvalue.hxx"
#include <formula/types.hxx>
#include "calcmacros.hxx"
+#include "colcontainer.hxx"
#include <set>
#include <map>
@@ -119,7 +120,7 @@ class ScTable : boost::noncopyable
private:
typedef ::std::vector< ScRange > ScRangeVec;
- ScColumn aCol[MAXCOLCOUNT];
+ ScColContainer<ScColumn> aCol;
OUString aName;
OUString aCodeName;
diff --git a/sc/source/core/data/markdata.cxx b/sc/source/core/data/markdata.cxx
index 28d5dc9..16aaf02 100644
--- a/sc/source/core/data/markdata.cxx
+++ b/sc/source/core/data/markdata.cxx
@@ -31,7 +31,7 @@
ScMarkData::ScMarkData() :
maTabMarked(),
- pMultiSel( NULL )
+ aMultiSel(0)
{
ResetMark();
}
@@ -40,18 +40,19 @@ ScMarkData::ScMarkData(const ScMarkData& rData) :
maTabMarked( rData.maTabMarked ),
aMarkRange( rData.aMarkRange ),
aMultiRange( rData.aMultiRange ),
- pMultiSel( NULL )
+ aMultiSel(0)
{
bMarked = rData.bMarked;
bMultiMarked = rData.bMultiMarked;
bMarking = rData.bMarking;
bMarkIsNeg = rData.bMarkIsNeg;
- if (rData.pMultiSel)
+ SCCOL nSourceCols = rData.aMultiSel.GetMaxCols();
+ if ( nSourceCols )
{
- pMultiSel = new ScMarkArray[MAXCOLCOUNT];
- for (SCCOL j=0; j<MAXCOLCOUNT; j++)
- rData.pMultiSel[j].CopyMarksTo( pMultiSel[j] );
+ aMultiSel.SetMaxCols((MINCOLCOUNT > nSourceCols) ? MINCOLCOUNT : nSourceCols);
+ for (SCCOL j=0; j<nSourceCols; j++)
+ rData.aMultiSel[j].CopyMarksTo( aMultiSel[j] );
}
}
@@ -60,8 +61,7 @@ ScMarkData& ScMarkData::operator=(const ScMarkData& rData)
if ( &rData == this )
return *this;
- delete[] pMultiSel;
- pMultiSel = NULL;
+ aMultiSel.Clear();
aMarkRange = rData.aMarkRange;
aMultiRange = rData.aMultiRange;
@@ -72,11 +72,12 @@ ScMarkData& ScMarkData::operator=(const ScMarkData& rData)
maTabMarked = rData.maTabMarked;
- if (rData.pMultiSel)
+ SCCOL nSourceCols = rData.aMultiSel.GetMaxCols();
+ if ( nSourceCols )
{
- pMultiSel = new ScMarkArray[MAXCOLCOUNT];
- for (SCCOL j=0; j<MAXCOLCOUNT; j++)
- rData.pMultiSel[j].CopyMarksTo( pMultiSel[j] );
+ aMultiSel.SetMaxCols((MINCOLCOUNT > nSourceCols) ? MINCOLCOUNT : nSourceCols);
+ for (SCCOL j=0; j<nSourceCols; j++)
+ rData.aMultiSel[j].CopyMarksTo( aMultiSel[j] );
}
return *this;
@@ -84,13 +85,11 @@ ScMarkData& ScMarkData::operator=(const ScMarkData& rData)
ScMarkData::~ScMarkData()
{
- delete[] pMultiSel;
}
void ScMarkData::ResetMark()
{
- delete[] pMultiSel;
- pMultiSel = NULL;
+ aMultiSel.Clear();
bMarked = bMultiMarked = false;
bMarking = bMarkIsNeg = false;
@@ -123,9 +122,15 @@ void ScMarkData::GetMultiMarkArea( ScRange& rRange ) const
void ScMarkData::SetMultiMarkArea( const ScRange& rRange, bool bMark )
{
- if (!pMultiSel)
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCROW nStartRow = rRange.aStart.Row();
+ SCCOL nEndCol = rRange.aEnd.Col();
+ SCROW nEndRow = rRange.aEnd.Row();
+
+ if (!aMultiSel.GetMaxCols())
{
- pMultiSel = new ScMarkArray[MAXCOL+1];
+ aMultiSel.SetMaxCols(MINCOLCOUNT);
+ aMultiSel.SetMaxCols(((nStartCol > nEndCol) ? nStartCol : nEndCol) + 1);
// if simple mark range is set, copy to multi marks
if ( bMarked && !bMarkIsNeg )
@@ -135,16 +140,12 @@ void ScMarkData::SetMultiMarkArea( const ScRange& rRange, bool bMark )
}
}
- SCCOL nStartCol = rRange.aStart.Col();
- SCROW nStartRow = rRange.aStart.Row();
- SCCOL nEndCol = rRange.aEnd.Col();
- SCROW nEndRow = rRange.aEnd.Row();
PutInOrder( nStartRow, nEndRow );
PutInOrder( nStartCol, nEndCol );
SCCOL nCol;
for (nCol=nStartCol; nCol<=nEndCol; nCol++)
- pMultiSel[nCol].SetMarkArea( nStartRow, nEndRow, bMark );
+ aMultiSel[nCol].SetMarkArea( nStartRow, nEndRow, bMark );
if ( bMultiMarked ) // Update aMultiRange
{
@@ -247,7 +248,7 @@ void ScMarkData::MarkToSimple()
if ( bMultiMarked )
{
- OSL_ENSURE(pMultiSel, "bMultiMarked, but pMultiSel == 0");
+ OSL_ENSURE(aMultiSel.GetMaxCols(), "bMultiMarked, but aMultiSel.GetMaxCols() == 0");
ScRange aNew = aMultiRange;
@@ -255,19 +256,19 @@ void ScMarkData::MarkToSimple()
SCCOL nStartCol = aNew.aStart.Col();
SCCOL nEndCol = aNew.aEnd.Col();
- while ( nStartCol < nEndCol && !pMultiSel[nStartCol].HasMarks() )
+ while ( nStartCol < nEndCol && !aMultiSel[nStartCol].HasMarks() )
++nStartCol;
- while ( nStartCol < nEndCol && !pMultiSel[nEndCol].HasMarks() )
+ while ( nStartCol < nEndCol && !aMultiSel[nEndCol].HasMarks() )
--nEndCol;
// Rows are only taken from MarkArray
SCROW nStartRow, nEndRow;
- if ( pMultiSel[nStartCol].HasOneMark( nStartRow, nEndRow ) )
+ if ( aMultiSel[nStartCol].HasOneMark( nStartRow, nEndRow ) )
{
bOk = true;
SCROW nCmpStart, nCmpEnd;
for (SCCOL nCol=nStartCol+1; nCol<=nEndCol && bOk; nCol++)
- if ( !pMultiSel[nCol].HasOneMark( nCmpStart, nCmpEnd )
+ if ( !aMultiSel[nCol].HasOneMark( nCmpStart, nCmpEnd )
|| nCmpStart != nStartRow || nCmpEnd != nEndRow )
bOk = false;
}
@@ -298,8 +299,8 @@ bool ScMarkData::IsCellMarked( SCCOL nCol, SCROW nRow, bool bNoSimple ) const
{
//TODO: test here for negative Marking ?
- OSL_ENSURE(pMultiSel, "bMultiMarked, but pMultiSel == 0");
- return pMultiSel[nCol].GetMark( nRow );
+ OSL_ENSURE(aMultiSel.GetMaxCols(), "bMultiMarked, but aMultiSel.GetMaxCols() == 0");
+ return aMultiSel[nCol].GetMark( nRow );
}
return false;
@@ -315,7 +316,7 @@ bool ScMarkData::IsColumnMarked( SCCOL nCol ) const
aMarkRange.aStart.Row() == 0 && aMarkRange.aEnd.Row() == MAXROW )
return true;
- if ( bMultiMarked && pMultiSel[nCol].IsAllMarked(0,MAXROW) )
+ if ( bMultiMarked && aMultiSel[nCol].IsAllMarked(0,MAXROW) )
return true;
return false;
@@ -333,9 +334,9 @@ bool ScMarkData::IsRowMarked( SCROW nRow ) const
if ( bMultiMarked )
{
- OSL_ENSURE(pMultiSel, "bMultiMarked, but pMultiSel == 0");
- for (SCCOL nCol=0; nCol<=MAXCOL; nCol++)
- if (!pMultiSel[nCol].GetMark(nRow))
+ OSL_ENSURE(aMultiSel.GetMaxCols(), "bMultiMarked, but aMultiSel.GetMaxCols() == 0");
+ for (SCCOL nCol=0; nCol<aMultiSel.GetMaxCols(); nCol++)
+ if (!aMultiSel[nCol].GetMark(nRow))
return false;
return true;
}
@@ -381,7 +382,7 @@ void ScMarkData::FillRangeListWithMarks( ScRangeList* pList, bool bClear ) const
if ( bMultiMarked )
{
- OSL_ENSURE(pMultiSel, "bMultiMarked, but pMultiSel == 0");
+ OSL_ENSURE(aMultiSel.GetMaxCols(), "bMultiMarked, but aMultiSel.GetMaxCols() == 0");
SCTAB nTab = aMultiRange.aStart.Tab();
@@ -389,7 +390,7 @@ void ScMarkData::FillRangeListWithMarks( ScRangeList* pList, bool bClear ) const
SCCOL nEndCol = aMultiRange.aEnd.Col();
for (SCCOL nCol=nStartCol; nCol<=nEndCol; nCol++)
{
- if (pMultiSel[nCol].HasMarks())
+ if (aMultiSel[nCol].HasMarks())
{
// Feeding column-wise fragments to ScRangeList::Join() is a
// huge bottleneck, speed this up for multiple columns
@@ -399,13 +400,13 @@ void ScMarkData::FillRangeListWithMarks( ScRangeList* pList, bool bClear ) const
SCCOL nToCol = nCol+1;
for ( ; nToCol <= nEndCol; ++nToCol)
{
- if (!pMultiSel[nCol].HasEqualRowsMarked( pMultiSel[nToCol]))
+ if (!aMultiSel[nCol].HasEqualRowsMarked( aMultiSel[nToCol]))
break;
}
--nToCol;
ScRange aRange( nCol, 0, nTab, nToCol, 0, nTab );
SCROW nTop, nBottom;
- ScMarkArrayIter aMarkIter( &pMultiSel[nCol] );
+ ScMarkArrayIter aMarkIter( &aMultiSel[nCol] );
while ( aMarkIter.Next( nTop, nBottom ) )
{
aRange.aStart.SetRow( nTop );
@@ -486,7 +487,7 @@ bool ScMarkData::IsAllMarked( const ScRange& rRange ) const
if ( !bMultiMarked )
return false;
- OSL_ENSURE(pMultiSel, "bMultiMarked, but pMultiSel == 0");
+ OSL_ENSURE(aMultiSel.GetMaxCols(), "bMultiMarked, but aMultiSel.GetMaxCols() == 0");
SCCOL nStartCol = rRange.aStart.Col();
SCROW nStartRow = rRange.aStart.Row();
@@ -494,7 +495,7 @@ bool ScMarkData::IsAllMarked( const ScRange& rRange ) const
SCROW nEndRow = rRange.aEnd.Row();
bool bOk = true;
for (SCCOL nCol=nStartCol; nCol<=nEndCol && bOk; nCol++)
- if ( !pMultiSel[nCol].IsAllMarked( nStartRow, nEndRow ) )
+ if ( !aMultiSel[nCol].IsAllMarked( nStartRow, nEndRow ) )
bOk = false;
return bOk;
@@ -505,9 +506,9 @@ SCsROW ScMarkData::GetNextMarked( SCCOL nCol, SCsROW nRow, bool bUp ) const
if ( !bMultiMarked )
return nRow;
- OSL_ENSURE(pMultiSel, "bMultiMarked, but pMultiSel == 0");
+ OSL_ENSURE(aMultiSel.GetMaxCols(), "bMultiMarked, but aMultiSel.GetMaxCols() == 0");
- return pMultiSel[nCol].GetNextMarked( nRow, bUp );
+ return aMultiSel[nCol].GetNextMarked( nRow, bUp );
}
bool ScMarkData::HasMultiMarks( SCCOL nCol ) const
@@ -515,9 +516,9 @@ bool ScMarkData::HasMultiMarks( SCCOL nCol ) const
if ( !bMultiMarked )
return false;
- OSL_ENSURE(pMultiSel, "bMultiMarked, but pMultiSel == 0");
+ OSL_ENSURE(aMultiSel.GetMaxCols(), "bMultiMarked, but aMultiSel.GetMaxCols() == 0");
- return pMultiSel[nCol].HasMarks();
+ return aMultiSel[nCol].HasMarks();
}
bool ScMarkData::HasAnyMultiMarks() const
@@ -525,10 +526,10 @@ bool ScMarkData::HasAnyMultiMarks() const
if ( !bMultiMarked )
return false;
- OSL_ENSURE(pMultiSel, "bMultiMarked, but pMultiSel == 0");
+ OSL_ENSURE(aMultiSel.GetMaxCols(), "bMultiMarked, but aMultiSel.GetMaxCols() == 0");
- for (SCCOL nCol=0; nCol<=MAXCOL; nCol++)
- if ( pMultiSel[nCol].HasMarks() )
+ for (SCCOL nCol=0; nCol<aMultiSel.GetMaxCols(); nCol++)
+ if ( aMultiSel[nCol].HasMarks() )
return true;
return false; // no
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 3ad5b2f..68a7d1a 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -478,7 +478,7 @@ bool ScTable::SetOptimalHeight(
rCxt.getHeightArray().resize(nCount, 0);
- GetOptimalHeightsInColumn(rCxt, aCol, nStartRow, nEndRow, pProgress, nProgressStart);
+ GetOptimalHeightsInColumn(rCxt, aCol.GetArray(), nStartRow, nEndRow, pProgress, nProgressStart);
SetRowHeightRangeFunc aFunc(this, rCxt.getPPTX(), rCxt.getPPTY());
bool bChanged = SetOptimalHeightsToRows(rCxt, aFunc, pRowFlags, nStartRow, nEndRow);
@@ -505,7 +505,7 @@ void ScTable::SetOptimalHeightOnly(
rCxt.getHeightArray().resize(nCount, 0);
- GetOptimalHeightsInColumn(rCxt, aCol, nStartRow, nEndRow, pProgress, nProgressStart);
+ GetOptimalHeightsInColumn(rCxt, aCol.GetArray(), nStartRow, nEndRow, pProgress, nProgressStart);
SetRowHeightOnlyFunc aFunc(this);
SetOptimalHeightsToRows(rCxt, aFunc, pRowFlags, nStartRow, nEndRow);
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 1b6a5bc..43fd148 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -249,7 +249,7 @@ void ScTable::DeleteRow(
std::vector<SCCOL> aRegroupCols;
rRegroupCols.getColumns(nTab, aRegroupCols);
std::for_each(
- aRegroupCols.begin(), aRegroupCols.end(), ColumnRegroupFormulaCells(aCol, pGroupPos));
+ aRegroupCols.begin(), aRegroupCols.end(), ColumnRegroupFormulaCells(aCol.GetArray(), pGroupPos));
InvalidatePageBreaks();
@@ -323,7 +323,7 @@ void ScTable::InsertCol(
std::vector<SCCOL> aRegroupCols;
rRegroupCols.getColumns(nTab, aRegroupCols);
- std::for_each(aRegroupCols.begin(), aRegroupCols.end(), ColumnRegroupFormulaCells(aCol, NULL));
+ std::for_each(aRegroupCols.begin(), aRegroupCols.end(), ColumnRegroupFormulaCells(aCol.GetArray(), NULL));
if (nStartCol>0) // copy old attributes
{
@@ -410,7 +410,7 @@ void ScTable::DeleteCol(
std::vector<SCCOL> aRegroupCols;
rRegroupCols.getColumns(nTab, aRegroupCols);
- std::for_each(aRegroupCols.begin(), aRegroupCols.end(), ColumnRegroupFormulaCells(aCol, NULL));
+ std::for_each(aRegroupCols.begin(), aRegroupCols.end(), ColumnRegroupFormulaCells(aCol.GetArray(), NULL));
InvalidatePageBreaks();
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 706e0e5..af3c6c1 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -479,7 +479,7 @@ ScSortInfoArray* ScTable::CreateSortInfoArray( const sc::ReorderParam& rParam )
pArray->SetUpdateRefs(rParam.mbUpdateRefs);
initDataRows(
- *pArray, *this, aCol, nCol1, nRow1, nCol2, nRow2,
+ *pArray, *this, aCol.GetArray(), nCol1, nRow1, nCol2, nRow2,
rParam.mbPattern, rParam.mbHiddenFiltered);
}
else
@@ -523,7 +523,7 @@ ScSortInfoArray* ScTable::CreateSortInfoArray(
}
initDataRows(
- *pArray, *this, aCol, rSortParam.nCol1, nInd1, rSortParam.nCol2, nInd2,
+ *pArray, *this, aCol.GetArray(), rSortParam.nCol1, nInd1, rSortParam.nCol2, nInd2,
rSortParam.bIncludePattern, bKeepQuery);
}
else
diff --git a/sc/source/ui/dbgui/pfiltdlg.cxx b/sc/source/ui/dbgui/pfiltdlg.cxx
index 078fbfc..5c9dec5 100644
--- a/sc/source/ui/dbgui/pfiltdlg.cxx
+++ b/sc/source/ui/dbgui/pfiltdlg.cxx
@@ -75,8 +75,8 @@ ScPivotFilterDlg::ScPivotFilterDlg(vcl::Window* pParent, const SfxItemSet& rArgS
get(m_pBtnUnique, "unique");
get(m_pFtDbArea, "dbarea");
- for (sal_uInt16 i=0; i<=MAXCOL; i++)
- pEntryLists[i] = NULL;
+ for (sal_uInt16 i=0; i<aEntryLists.GetMaxCols(); i++)
+ aEntryLists[i] = NULL;
Init( rArgSet );
}
@@ -88,8 +88,8 @@ ScPivotFilterDlg::~ScPivotFilterDlg()
void ScPivotFilterDlg::dispose()
{
- for (sal_uInt16 i=0; i<=MAXCOL; i++)
- delete pEntryLists[i];
+ for (sal_uInt16 i=0; i<aEntryLists.GetMaxCols(); i++)
+ delete aEntryLists[i];
delete pOutItem;
m_pLbField1.clear();
@@ -307,7 +307,9 @@ void ScPivotFilterDlg::UpdateValueList( sal_uInt16 nList )
if ( pDoc && nFieldSelPos )
{
SCCOL nColumn = theQueryData.nCol1 + static_cast<SCCOL>(nFieldSelPos) - 1;
- if (!pEntryLists[nColumn])
+ if ( nColumn > (aEntryLists.GetMaxCols() - 1) )
+ aEntryLists.SetMaxCols( nColumn + 1 );
+ if (!aEntryLists[nColumn])
{
WaitObject aWaiter( this );
@@ -317,12 +319,12 @@ void ScPivotFilterDlg::UpdateValueList( sal_uInt16 nList )
nFirstRow++;
bool bHasDates = false;
bool bCaseSens = m_pBtnCase->IsChecked();
- pEntryLists[nColumn] = new std::vector<ScTypedStrData>;
+ aEntryLists[nColumn] = new std::vector<ScTypedStrData>;
pDoc->GetFilterEntriesArea(
- nColumn, nFirstRow, nLastRow, nTab, bCaseSens, *pEntryLists[nColumn], bHasDates);
+ nColumn, nFirstRow, nLastRow, nTab, bCaseSens, *aEntryLists[nColumn], bHasDates);
}
- std::vector<ScTypedStrData>* pColl = pEntryLists[nColumn];
+ std::vector<ScTypedStrData>* pColl = aEntryLists[nColumn];
std::vector<ScTypedStrData>::const_iterator it = pColl->begin(), itEnd = pColl->end();
for (; it != itEnd; ++it)
{
@@ -525,8 +527,8 @@ IMPL_LINK_TYPED( ScPivotFilterDlg, CheckBoxHdl, Button*, pBox, void )
if (pBox == m_pBtnCase) // value lists
{
- for (sal_uInt16 i=0; i<=MAXCOL; i++)
- DELETEZ( pEntryLists[i] );
+ for (sal_uInt16 i=0; i<aEntryLists.GetMaxCols(); i++)
+ DELETEZ( aEntryLists[i] );
OUString aCurVal1 = m_pEdVal1->GetText();
OUString aCurVal2 = m_pEdVal2->GetText();
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 9860e53..4e3a58d 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -1041,7 +1041,7 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium )
// Set optimal col width after import?
bool bSetColWidths = false;
bool bSetSimpleTextColWidths = false;
- ScColWidthParam aColWidthParam[MAXCOLCOUNT];
+ ScColContainer<ScColWidthParam> aColWidthParam;
ScRange aColWidthRange;
// Set optimal row height after import?
bool bSetRowHeights = false;
@@ -1473,6 +1473,8 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium )
// Order is important: First width, then height
if ( bSetColWidths )
{
+ if ( nEndCol > (aColWidthParam.GetMaxCols() - 1) )
+ aColWidthParam.SetMaxCols(nEndCol + 1);
for ( SCCOL nCol=0; nCol <= nEndCol; nCol++ )
{
if (!bSetSimpleTextColWidths)
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index 5813bd2..4f80d5c 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -287,7 +287,7 @@ static void lcl_setScalesToColumns(ScDocument& rDoc, const vector<long>& rScales
#endif // HAVE_FEATURE_DBCONNECTIVITY
sal_uLong ScDocShell::DBaseImport( const OUString& rFullFileName, rtl_TextEncoding eCharSet,
- ScColWidthParam aColWidthParam[MAXCOLCOUNT], ScFlatBoolRowSegments& rRowHeightsRecalc )
+ ScColContainer<ScColWidthParam>& aColWidthParam, ScFlatBoolRowSegments& rRowHeightsRecalc )
{
#if !HAVE_FEATURE_DBCONNECTIVITY
(void) rFullFileName;
@@ -350,9 +350,9 @@ sal_uLong ScDocShell::DBaseImport( const OUString& rFullFileName, rtl_TextEncodi
if ( xMeta.is() )
nColCount = xMeta->getColumnCount(); // this is the number of real columns
- if ( nColCount > MAXCOL+1 )
+ if ( nColCount > MAXCOLCOUNT )
{
- nColCount = MAXCOL+1;
+ nColCount = MAXCOLCOUNT;
nErr = SCWARN_IMPORT_COLUMN_OVERFLOW; // warning
}
@@ -360,6 +360,9 @@ sal_uLong ScDocShell::DBaseImport( const OUString& rFullFileName, rtl_TextEncodi
OSL_ENSURE( xRow.is(), "can't get Row" );
if (!xRow.is()) return SCERR_IMPORT_CONNECT;
+ if ( nColCount > aColWidthParam.GetMaxCols() )
+ aColWidthParam.SetMaxCols( nColCount );
+
// currency flag is not needed for dBase
uno::Sequence<sal_Int32> aColTypes( nColCount ); // column types
sal_Int32* pTypeArr = aColTypes.getArray();
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 0b5fdcd..1f81e67 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -34,6 +34,7 @@
#include "shellids.hxx"
#include "optutil.hxx"
#include "docuno.hxx"
+#include "colcontainer.hxx"
#include <config_telepathy.h>
#include <memory>
@@ -137,7 +138,7 @@ class SC_DLLPUBLIC ScDocShell: public SfxObjectShell, public SfxListener
SAL_DLLPRIVATE bool SaveCurrentChart( SfxMedium& rMedium );
SAL_DLLPRIVATE sal_uLong DBaseImport( const OUString& rFullFileName, rtl_TextEncoding eCharSet,
- ScColWidthParam aColWidthParam[MAXCOLCOUNT], ScFlatBoolRowSegments& rRowHeightsRecalc );
+ ScColContainer<ScColWidthParam>& aColWidthParam, ScFlatBoolRowSegments& rRowHeightsRecalc );
SAL_DLLPRIVATE sal_uLong DBaseExport(
const OUString& rFullFileName, rtl_TextEncoding eCharSet, bool& bHasMemo );
diff --git a/sc/source/ui/inc/pfiltdlg.hxx b/sc/source/ui/inc/pfiltdlg.hxx
index 07480b3..89e76ae 100644
--- a/sc/source/ui/inc/pfiltdlg.hxx
+++ b/sc/source/ui/inc/pfiltdlg.hxx
@@ -28,6 +28,7 @@
#include <vcl/lstbox.hxx>
#include <vcl/combobox.hxx>
#include "address.hxx"
+#include "colcontainer.hxx"
#include "queryparam.hxx"
class ScViewData;
@@ -80,7 +81,7 @@ private:
VclPtr<ListBox> aFieldLbArr[3];
VclPtr<ListBox> aCondLbArr[3];
- std::vector<ScTypedStrData>* pEntryLists[MAXCOLCOUNT];
+ ScColContainer<std::vector<ScTypedStrData>*> aEntryLists;
private:
void Init ( const SfxItemSet& rArgSet );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.