summaryrefslogtreecommitdiff
path: root/sc/inc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-13 10:10:01 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-14 08:28:15 +0200
commita4fb52ac0f48b10b72be330fe49d99a9a2471751 (patch)
treeeaf53307c7534a47ecdc5b5729e5109f50fafe1a /sc/inc
parentf70e0ec6b3c61a7c7caa469949b0ac8016c89854 (diff)
convert ScAttrArray to use std::vector
instead of re-implementing it ourselves. Which lead to some changes in Xf::AttrList since the import process wants to donate it's array to ScAttrArray. Change-Id: I176148131fb5f163e25691ad690f63398ba1a556 Reviewed-on: https://gerrit.libreoffice.org/42205 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/inc')
-rw-r--r--sc/inc/attarray.hxx31
-rw-r--r--sc/inc/documentimport.hxx9
2 files changed, 20 insertions, 20 deletions
diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index aa5d8ad91e61..726c5a831114 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -89,10 +89,7 @@ private:
SCTAB nTab;
ScDocument* pDocument;
- SCSIZE nCount;
- SCSIZE nLimit;
- std::unique_ptr<ScAttrEntry[]>
- pData;
+ std::vector<ScAttrEntry> mvData;
friend class ScDocument; // for FillInfo
friend class ScDocumentIterator;
@@ -145,7 +142,7 @@ public:
void ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, ScStyleSheet* pStyle );
void ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCache* pCache,
ScEditDataArray* pDataArray = nullptr, bool* const pIsChanged = nullptr );
- void SetAttrEntries(ScAttrEntry* pNewData, SCSIZE nSize);
+ void SetAttrEntries(std::vector<ScAttrEntry> && vNewData);
void ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow,
const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
@@ -210,7 +207,7 @@ public:
/* i123909: Pre-calculate needed memory, and pre-reserve enough memory */
bool Reserve( SCSIZE nReserve );
- SCSIZE Count() const { return nCount; }
+ SCSIZE Count() const { return mvData.size(); }
SCSIZE Count( SCROW nRow1, SCROW nRow2 ) const;
};
@@ -236,7 +233,7 @@ inline ScAttrIterator::ScAttrIterator( const ScAttrArray* pNewArray, SCROW nStar
nRow( nStart ),
nEndRow( nEnd )
{
- if ( pArray->nCount )
+ if ( pArray->Count() )
{
if ( nStart > 0 )
pArray->Search( nStart, nPos );
@@ -250,7 +247,7 @@ inline ScAttrIterator::ScAttrIterator( const ScAttrArray* pNewArray, SCROW nStar
inline const ScPatternAttr* ScAttrIterator::Next( SCROW& rTop, SCROW& rBottom )
{
const ScPatternAttr* pRet;
- if ( !pArray->nCount )
+ if ( !pArray->Count() )
{
if ( !nPos )
{
@@ -265,11 +262,11 @@ inline const ScPatternAttr* ScAttrIterator::Next( SCROW& rTop, SCROW& rBottom )
return nullptr;
}
- if ( nPos < pArray->nCount && nRow <= nEndRow )
+ if ( nPos < pArray->Count() && nRow <= nEndRow )
{
rTop = nRow;
- rBottom = std::min( pArray->pData[nPos].nEndRow, nEndRow );
- pRet = pArray->pData[nPos].pPattern;
+ rBottom = std::min( pArray->mvData[nPos].nEndRow, nEndRow );
+ pRet = pArray->mvData[nPos].pPattern;
nRow = rBottom + 1;
++nPos;
}
@@ -281,7 +278,7 @@ inline const ScPatternAttr* ScAttrIterator::Next( SCROW& rTop, SCROW& rBottom )
inline const ScPatternAttr* ScAttrIterator::Resync( SCROW nRowP, SCROW& rTop, SCROW& rBottom )
{
nRow = nRowP;
- if ( !pArray->nCount )
+ if ( !pArray->Count() )
{
nPos = 0;
return Next( rTop, rBottom );
@@ -290,13 +287,13 @@ inline const ScPatternAttr* ScAttrIterator::Resync( SCROW nRowP, SCROW& rTop, SC
// starting right there. Assume that Next() was called so nPos already
// advanced. Another high chance is that the change extended a previous or
// next pattern. In all these cases we don't need to search.
- if (3 <= nPos && nPos <= pArray->nCount && pArray->pData[nPos-3].nEndRow < nRowP &&
- nRowP <= pArray->pData[nPos-2].nEndRow)
+ if (3 <= nPos && nPos <= pArray->Count() && pArray->mvData[nPos-3].nEndRow < nRowP &&
+ nRowP <= pArray->mvData[nPos-2].nEndRow)
nPos -= 2;
- else if (2 <= nPos && nPos <= pArray->nCount && pArray->pData[nPos-2].nEndRow < nRowP &&
- nRowP <= pArray->pData[nPos-1].nEndRow)
+ else if (2 <= nPos && nPos <= pArray->Count() && pArray->mvData[nPos-2].nEndRow < nRowP &&
+ nRowP <= pArray->mvData[nPos-1].nEndRow)
--nPos;
- else if (pArray->nCount > 0 && nRowP <= pArray->pData[0].nEndRow)
+ else if (pArray->Count() > 0 && nRowP <= pArray->mvData[0].nEndRow)
nPos = 0;
else
pArray->Search( nRowP, nPos );
diff --git a/sc/inc/documentimport.hxx b/sc/inc/documentimport.hxx
index 5762d77a2ee4..00496cdaac2b 100644
--- a/sc/inc/documentimport.hxx
+++ b/sc/inc/documentimport.hxx
@@ -16,6 +16,7 @@
#include <rtl/ustring.hxx>
#include <memory>
+#include <vector>
class EditTextObject;
class ScDocument;
@@ -45,12 +46,14 @@ public:
struct SC_DLLPUBLIC Attrs
{
- ScAttrEntry* mpData;
- size_t mnSize;
+ std::vector<ScAttrEntry> mvData;
bool mbLatinNumFmtOnly;
Attrs();
+ ~Attrs();
+ Attrs& operator=( Attrs const & ) = delete; // MSVC2015 workaround
+ Attrs( Attrs const & ) = delete; // MSVC2015 workaround
};
ScDocumentImport() = delete;
@@ -106,7 +109,7 @@ public:
* transfers the ownership of the ScAttrEntry array from the caller to the
* column.
*/
- void setAttrEntries( SCTAB nTab, SCCOL nCol, Attrs& rAttrs );
+ void setAttrEntries( SCTAB nTab, SCCOL nCol, Attrs&& rAttrs );
void setRowsVisible(SCTAB nTab, SCROW nRowStart, SCROW nRowEnd, bool bVisible);