Kaydet (Commit) 7c8c2b5e authored tarafından Ashod Nakashian's avatar Ashod Nakashian Kaydeden (comit) Ashod Nakashian

sc: simplify ScColContainer

Less clutter, no indirection and smaller memory footprint.

Change-Id: Ic24272e9853a7af28df62298fd26e7edce554986
Reviewed-on: https://gerrit.libreoffice.org/45379Reviewed-by: 's avatarAshod Nakashian <ashnakash@gmail.com>
Tested-by: 's avatarAshod Nakashian <ashnakash@gmail.com>
üst ac5ecfeb
...@@ -107,7 +107,6 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ ...@@ -107,7 +107,6 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/core/data/cellvalues \ sc/source/core/data/cellvalues \
sc/source/core/data/clipcontext \ sc/source/core/data/clipcontext \
sc/source/core/data/clipparam \ sc/source/core/data/clipparam \
sc/source/core/data/colcontainer \
sc/source/core/data/column \ sc/source/core/data/column \
sc/source/core/data/column2 \ sc/source/core/data/column2 \
sc/source/core/data/column3 \ sc/source/core/data/column3 \
......
...@@ -22,30 +22,34 @@ ...@@ -22,30 +22,34 @@
#include "types.hxx" #include "types.hxx"
#include "address.hxx" #include "address.hxx"
#include "column.hxx"
#include <vector> #include <vector>
class ScColumn; class ScColContainer final
class ScDocument;
class ScColContainer
{ {
typedef std::vector<ScColumn*> ScColumnVector; std::vector<ScColumn> aCols;
ScColumnVector aCols;
ScDocument* pDocument;
public: public:
ScColContainer( ScDocument* pDoc, const size_t nSize );
~ScColContainer(); ScColContainer(const size_t nSize)
: aCols(nSize)
{
}
~ScColContainer()
{
Clear();
}
const ScColumn& operator[] ( const size_t nIndex ) const const ScColumn& operator[] ( const size_t nIndex ) const
{ {
return *aCols[nIndex]; return aCols[nIndex];
} }
ScColumn& operator[] ( const size_t nIndex ) ScColumn& operator[] ( const size_t nIndex )
{ {
return *aCols[nIndex]; return aCols[nIndex];
} }
SCCOL size() const SCCOL size() const
...@@ -58,9 +62,14 @@ public: ...@@ -58,9 +62,14 @@ public:
return aCols.empty(); return aCols.empty();
} }
void Clear(); void Clear()
}; {
for (ScColumn& rCol: aCols)
rCol.PrepareBroadcastersForDestruction();
aCols.clear();
}
};
#endif #endif
......
...@@ -18,32 +18,4 @@ ...@@ -18,32 +18,4 @@
*/ */
#include "colcontainer.hxx"
#include "column.hxx"
#include "document.hxx"
ScColContainer::ScColContainer( ScDocument* pDoc, const size_t nSize )
{
pDocument = pDoc;
aCols.resize( nSize );
for ( size_t nCol = 0; nCol < nSize; ++nCol )
aCols[nCol] = new ScColumn;
}
ScColContainer::~ScColContainer()
{
Clear();
}
void ScColContainer::Clear()
{
SCCOL nSize = size();
for ( SCCOL nIdx = 0; nIdx < nSize; ++nIdx )
{
aCols[nIdx]->PrepareBroadcastersForDestruction();
delete aCols[nIdx];
}
aCols.clear();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -237,7 +237,7 @@ bool SetOptimalHeightsToRows( ...@@ -237,7 +237,7 @@ bool SetOptimalHeightsToRows(
ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName, ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName,
bool bColInfo, bool bRowInfo ) : bool bColInfo, bool bRowInfo ) :
aCol( pDoc, MAXCOLCOUNT ), aCol( MAXCOLCOUNT ),
aName( rNewName ), aName( rNewName ),
aCodeName( rNewName ), aCodeName( rNewName ),
nLinkRefreshDelay( 0 ), nLinkRefreshDelay( 0 ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment