[Libreoffice-commits] core.git: sc/inc sc/qa sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Thu Feb 27 18:36:44 PST 2014


 sc/inc/columnspanset.hxx               |    2 
 sc/inc/markdata.hxx                    |    3 
 sc/qa/unit/subsequent_filters-test.cxx |    8 +-
 sc/source/core/data/markdata.cxx       |  114 ---------------------------------
 sc/source/ui/docshell/docfunc.cxx      |   38 +++++------
 sc/source/ui/inc/docfunc.hxx           |   13 ++-
 sc/source/ui/inc/undoblk.hxx           |    5 -
 sc/source/ui/inc/viewfunc.hxx          |   14 ++--
 sc/source/ui/undo/undoblk2.cxx         |    9 +-
 sc/source/ui/unoobj/cellsuno.cxx       |   26 +++----
 sc/source/ui/unoobj/docuno.cxx         |   27 +++----
 sc/source/ui/vba/vbarange.cxx          |   32 +++------
 sc/source/ui/view/colrowba.cxx         |   41 +++--------
 sc/source/ui/view/preview.cxx          |    6 -
 sc/source/ui/view/viewfunc.cxx         |   80 +++++++++++------------
 15 files changed, 139 insertions(+), 279 deletions(-)

New commits:
commit cf70996311af2081b2e5920ad27094a0774bdd05
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Thu Feb 27 21:29:30 2014 -0500

    Remove all uses of GetMarkRowRanges() and use GetMarkedRowSpans().
    
    And ditto with its column variant.  The former created a heap array of
    1 million elements (=MAXROWCOUNT). There is no need for this memory
    wastage.
    
    Change-Id: I07845966c51cdcbdc676cd0d249f6420a19b9c5e

diff --git a/sc/inc/columnspanset.hxx b/sc/inc/columnspanset.hxx
index 7da9896..60dae41 100644
--- a/sc/inc/columnspanset.hxx
+++ b/sc/inc/columnspanset.hxx
@@ -33,7 +33,7 @@ struct RowSpan
     RowSpan(SCROW nRow1, SCROW nRow2);
 };
 
-struct ColRowSpan
+struct SC_DLLPUBLIC ColRowSpan
 {
     SCCOLROW mnStart;
     SCCOLROW mnEnd;
diff --git a/sc/inc/markdata.hxx b/sc/inc/markdata.hxx
index 6733036..da225f5 100644
--- a/sc/inc/markdata.hxx
+++ b/sc/inc/markdata.hxx
@@ -106,9 +106,6 @@ public:
 
     void        MarkFromRangeList( const ScRangeList& rList, bool bReset );
 
-    SCCOLROW    GetMarkColumnRanges( SCCOLROW* pRanges );
-    SCCOLROW    GetMarkRowRanges( SCCOLROW* pRanges );
-
     std::vector<sc::ColRowSpan> GetMarkedRowSpans() const;
     std::vector<sc::ColRowSpan> GetMarkedColSpans() const;
 
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 474700b..4df450c 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -48,6 +48,7 @@
 #include "dpsave.hxx"
 #include "dpshttab.hxx"
 #include <scopetools.hxx>
+#include <columnspanset.hxx>
 
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <com/sun/star/drawing/XControlShape.hpp>
@@ -2335,12 +2336,11 @@ void ScFiltersTest::testOptimalHeightReset()
     nHeight =  sc::TwipsToHMM( pDoc->GetRowHeight(nRow, nTab, false) );
 
     // set optimal height for empty row 2
-    SCCOLROW nRowArr[2];
-    nRowArr[0] = nRowArr[1] = 2;
-    rFunc.SetWidthOrHeight( false, 1, nRowArr, nTab, SC_SIZE_OPTIMAL, 0, true, true );
+    std::vector<sc::ColRowSpan> aRowArr(1, sc::ColRowSpan(2,2));
+    rFunc.SetWidthOrHeight(false, aRowArr, nTab, SC_SIZE_OPTIMAL, 0, true, true);
 
     // retrieve optimal height
-    int nOptimalHeight = sc::TwipsToHMM( pDoc->GetRowHeight( nRowArr[0], nTab, false) );
+    int nOptimalHeight = sc::TwipsToHMM( pDoc->GetRowHeight(aRowArr[0].mnStart, nTab, false) );
 
     // check if the new height of A1 ( after delete ) is now the optimal height of an empty cell
     CPPUNIT_ASSERT_EQUAL(nOptimalHeight, nHeight );
diff --git a/sc/source/core/data/markdata.cxx b/sc/source/core/data/markdata.cxx
index 0ca8ebc..04277bf 100644
--- a/sc/source/core/data/markdata.cxx
+++ b/sc/source/core/data/markdata.cxx
@@ -437,120 +437,6 @@ ScRangeList ScMarkData::GetMarkedRanges() const
     return aRet;
 }
 
-SCCOLROW ScMarkData::GetMarkColumnRanges( SCCOLROW* pRanges )
-{
-    if (bMarked)
-        MarkToMulti();
-
-    if (!bMultiMarked)
-        return 0;
-
-    OSL_ENSURE(pMultiSel, "bMultiMarked, but pMultiSel == 0");
-
-    const SCCOLROW nMultiStart = aMultiRange.aStart.Col();
-    const SCCOLROW nMultiEnd = aMultiRange.aEnd.Col();
-    if (nMultiStart == 0 && nMultiEnd == MAXCOL)
-    {
-        // One or more entire rows.
-        pRanges[0] = 0;
-        pRanges[1] = MAXCOL;
-        return 1;
-    }
-
-    SCCOLROW nRangeCnt = 0;
-    SCCOLROW nStart = nMultiStart;
-    while (nStart <= nMultiEnd)
-    {
-        while (nStart < nMultiEnd && !pMultiSel[nStart].HasMarks())
-            ++nStart;
-        if (pMultiSel[nStart].HasMarks())
-        {
-            SCCOLROW nEnd = nStart;
-            while (nEnd < nMultiEnd && pMultiSel[nEnd].HasMarks())
-                ++nEnd;
-            if (!pMultiSel[nEnd].HasMarks())
-                --nEnd;
-            pRanges[2*nRangeCnt  ] = nStart;
-            pRanges[2*nRangeCnt+1] = nEnd;
-            ++nRangeCnt;
-            nStart = nEnd+1;
-        }
-        else
-            nStart = nMultiEnd+1;
-    }
-
-    return nRangeCnt;
-}
-
-SCCOLROW ScMarkData::GetMarkRowRanges( SCCOLROW* pRanges )
-{
-    if (bMarked)
-        MarkToMulti();
-
-    if (!bMultiMarked)
-        return 0;
-
-    OSL_ENSURE(pMultiSel, "bMultiMarked, but pMultiSel == 0");
-
-    // Which rows are marked?
-
-    // Optimized to not loop over MAXCOL*MAXROW as worst case, i.e. Ctrl+A
-
-    const SCCOLROW nMultiStart = aMultiRange.aStart.Row();
-    const SCCOLROW nMultiEnd = aMultiRange.aEnd.Row();
-
-    bool*   bRowMarked = new bool[MAXROWCOUNT];
-    memset( bRowMarked, 0, sizeof(bool) * MAXROWCOUNT);
-    SCROW  nRow;
-    SCCOL  nCol;
-
-    SCROW nTop = -1, nBottom = -1;
-    for (nCol = aMultiRange.aStart.Col(); nCol <= aMultiRange.aEnd.Col(); ++nCol)
-    {
-        ScMarkArrayIter aMarkIter( &pMultiSel[nCol] );
-        while (aMarkIter.Next( nTop, nBottom ))
-            for (nRow=nTop; nRow<=nBottom; nRow++)
-                bRowMarked[nRow] = true;
-        if (nTop == nMultiStart && nBottom == nMultiEnd)
-            break;  // for, all relevant rows marked
-    }
-
-    if (nTop == nMultiStart && nBottom == nMultiEnd)
-    {
-        pRanges[0] = nTop;
-        pRanges[1] = nBottom;
-        delete[] bRowMarked;
-        return 1;
-    }
-
-    // Combine to ranges of rows.
-
-    SCCOLROW nRangeCnt = 0;
-    SCCOLROW nStart = nMultiStart;
-    while (nStart <= nMultiEnd)
-    {
-        while (nStart < nMultiEnd && !bRowMarked[nStart])
-            ++nStart;
-        if (bRowMarked[nStart])
-        {
-            SCCOLROW nEnd = nStart;
-            while (nEnd < nMultiEnd && bRowMarked[nEnd])
-                ++nEnd;
-            if (!bRowMarked[nEnd])
-                --nEnd;
-            pRanges[2*nRangeCnt  ] = nStart;
-            pRanges[2*nRangeCnt+1] = nEnd;
-            ++nRangeCnt;
-            nStart = nEnd+1;
-        }
-        else
-            nStart = nMultiEnd+1;
-    }
-
-    delete[] bRowMarked;
-    return nRangeCnt;
-}
-
 std::vector<sc::ColRowSpan> ScMarkData::GetMarkedRowSpans() const
 {
     typedef mdds::flat_segment_tree<SCCOLROW, bool> SpansType;
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index c9254a2..4df2b5f 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -3385,13 +3385,13 @@ static sal_uInt16 lcl_GetOptimalColWidth( ScDocShell& rDocShell, SCCOL nCol, SCT
     return nTwips;
 }
 
-bool ScDocFunc::SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRanges, SCTAB nTab,
-                                        ScSizeMode eMode, sal_uInt16 nSizeTwips,
-                                        bool bRecord, bool bApi )
+bool ScDocFunc::SetWidthOrHeight(
+    bool bWidth, const std::vector<sc::ColRowSpan>& rRanges, SCTAB nTab,
+    ScSizeMode eMode, sal_uInt16 nSizeTwips, bool bRecord, bool bApi )
 {
     ScDocShellModificator aModificator( rDocShell );
 
-    if (!nRangeCnt)
+    if (rRanges.empty())
         return true;
 
     ScDocument* pDoc = rDocShell.GetDocument();
@@ -3407,8 +3407,8 @@ bool ScDocFunc::SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRa
     }
 
     bool bSuccess = false;
-    SCCOLROW nStart = pRanges[0];
-    SCCOLROW nEnd = pRanges[2*nRangeCnt-1];
+    SCCOLROW nStart = rRanges[0].mnStart;
+    SCCOLROW nEnd = rRanges[0].mnEnd;
 
     bool bFormula = false;
     if ( eMode == SC_SIZE_OPTIMAL )
@@ -3418,7 +3418,7 @@ bool ScDocFunc::SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRa
 
     ScDocument*     pUndoDoc = NULL;
     ScOutlineTable* pUndoTab = NULL;
-    SCCOLROW*       pUndoRanges = NULL;
+    std::vector<sc::ColRowSpan> aUndoRanges;
 
     if ( bRecord )
     {
@@ -3436,8 +3436,7 @@ bool ScDocFunc::SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRa
             pDoc->CopyToDocument( 0, static_cast<SCROW>(nStart), nTab, MAXCOL, static_cast<SCROW>(nEnd), nTab, IDF_NONE, false, pUndoDoc );
         }
 
-        pUndoRanges = new SCCOLROW[ 2*nRangeCnt ];
-        memcpy( pUndoRanges, pRanges, 2*nRangeCnt*sizeof(SCCOLROW) );
+        aUndoRanges = rRanges;
 
         ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
         if (pTable)
@@ -3447,10 +3446,10 @@ bool ScDocFunc::SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRa
     bool bShow = nSizeTwips > 0 || eMode != SC_SIZE_DIRECT;
     bool bOutline = false;
 
-    for (SCCOLROW nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++)
+    for (size_t i = 0, n = rRanges.size(); i < n; ++i)
     {
-        SCCOLROW nStartNo = *(pRanges++);
-        SCCOLROW nEndNo = *(pRanges++);
+        SCCOLROW nStartNo = rRanges[i].mnStart;
+        SCCOLROW nEndNo   = rRanges[i].mnEnd;
 
         if ( !bWidth )                      // Hoehen immer blockweise
         {
@@ -3542,10 +3541,9 @@ bool ScDocFunc::SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRa
         ScMarkData aMark;
         aMark.SelectOneTable( nTab );
         rDocShell.GetUndoManager()->AddUndoAction(
-            new ScUndoWidthOrHeight( &rDocShell, aMark,
-                                     nStart, nTab, nEnd, nTab,
-                                     pUndoDoc, nRangeCnt, pUndoRanges,
-                                     pUndoTab, eMode, nSizeTwips, bWidth ) );
+            new ScUndoWidthOrHeight(
+                &rDocShell, aMark, nStart, nTab, nEnd, nTab, pUndoDoc,
+                aUndoRanges, pUndoTab, eMode, nSizeTwips, bWidth));
     }
 
     pDoc->UpdatePageBreaks( nTab );
@@ -4026,14 +4024,14 @@ bool ScDocFunc::AutoFormat( const ScRange& rRange, const ScMarkData* pTabMark,
 
         if (bSize)
         {
-            SCCOLROW nCols[2] = { nStartCol, nEndCol };
-            SCCOLROW nRows[2] = { nStartRow, nEndRow };
+            std::vector<sc::ColRowSpan> aCols(1, sc::ColRowSpan(nStartCol,nEndCol));
+            std::vector<sc::ColRowSpan> aRows(1, sc::ColRowSpan(nStartRow,nEndRow));
 
             ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
             for (; itr != itrEnd && *itr < nTabCount; ++itr)
             {
-                SetWidthOrHeight( true, 1, nCols, *itr, SC_SIZE_VISOPT, STD_EXTRA_WIDTH, false, true);
-                SetWidthOrHeight( false, 1, nRows, *itr, SC_SIZE_VISOPT, 0, false, false);
+                SetWidthOrHeight(true, aCols, *itr, SC_SIZE_VISOPT, STD_EXTRA_WIDTH, false, true);
+                SetWidthOrHeight(false, aRows, *itr, SC_SIZE_VISOPT, 0, false, false);
                 rDocShell.PostPaint( 0,0,*itr, MAXCOL,MAXROW,*itr,
                                 PAINT_GRID | PAINT_LEFT | PAINT_TOP );
             }
diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx
index d40c794..36c984a 100644
--- a/sc/source/ui/inc/docfunc.hxx
+++ b/sc/source/ui/inc/docfunc.hxx
@@ -46,6 +46,12 @@ struct ScCellMergeOption;
 class ScConditionalFormat;
 class ScConditionalFormatList;
 
+namespace sc {
+
+struct ColRowSpan;
+
+}
+
 // ---------------------------------------------------------------------------
 
 class ScDocFunc
@@ -137,10 +143,9 @@ public:
 
     bool            SetLayoutRTL( SCTAB nTab, bool bRTL, bool bApi );
 
-    SC_DLLPUBLIC bool
-                    SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRanges,
-                                              SCTAB nTab, ScSizeMode eMode, sal_uInt16 nSizeTwips,
-                                              bool bRecord, bool bApi );
+    SC_DLLPUBLIC bool SetWidthOrHeight(
+        bool bWidth, const std::vector<sc::ColRowSpan>& rRanges, SCTAB nTab,
+        ScSizeMode eMode, sal_uInt16 nSizeTwips, bool bRecord, bool bApi );
 
     bool            InsertPageBreak( bool bColumn, const ScAddress& rPos,
                                              bool bRecord, bool bSetModified, bool bApi );
diff --git a/sc/source/ui/inc/undoblk.hxx b/sc/source/ui/inc/undoblk.hxx
index 29e82ac..e2cb6f6 100644
--- a/sc/source/ui/inc/undoblk.hxx
+++ b/sc/source/ui/inc/undoblk.hxx
@@ -374,7 +374,7 @@ public:
                                          SCCOLROW nNewStart, SCTAB nNewStartTab,
                                          SCCOLROW nNewEnd, SCTAB nNewEndTab,
                                          ScDocument* pNewUndoDoc,
-                                         SCCOLROW nNewCnt, SCCOLROW* pNewRanges,
+                                         const std::vector<sc::ColRowSpan>& rRanges,
                                          ScOutlineTable* pNewUndoTab,
                                          ScSizeMode eNewMode, sal_uInt16 nNewSizeTwips,
                                          bool bNewWidth );
@@ -395,8 +395,7 @@ private:
     SCTAB           nEndTab;
     ScDocument*     pUndoDoc;
     ScOutlineTable* pUndoTab;
-    SCCOLROW        nRangeCnt;
-    SCCOLROW*       pRanges;
+    std::vector<sc::ColRowSpan> maRanges;
     sal_uInt16      nNewSize;
     bool            bWidth;
     ScSizeMode      eMode;
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index 9ef8671..241a09c 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -52,6 +52,12 @@ class ScTableProtection;
 
 namespace editeng { class SvxBorderLine; }
 
+namespace sc {
+
+struct ColRowSpan;
+
+}
+
 namespace com { namespace sun { namespace star { namespace datatransfer { class XTransferable; } } } }
 
 //==================================================================
@@ -196,10 +202,10 @@ public:
 
     void            DeleteContents( sal_uInt16 nFlags, bool bRecord = true );
 
-    void            SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRanges,
-                                        ScSizeMode eMode, sal_uInt16 nSizeTwips,
-                                        bool bRecord = true, bool bPaint = true,
-                                        ScMarkData* pMarkData = NULL );
+    void SetWidthOrHeight(
+        bool bWidth, const std::vector<sc::ColRowSpan>& rRanges, ScSizeMode eMode,
+        sal_uInt16 nSizeTwips, bool bRecord = true, bool bPaint = true, ScMarkData* pMarkData = NULL );
+
     void            SetMarkedWidthOrHeight( bool bWidth, ScSizeMode eMode, sal_uInt16 nSizeTwips,
                                         bool bRecord = true, bool bPaint = true );
     void            ShowMarkedColumns( bool bShow, bool bRecord = true );
diff --git a/sc/source/ui/undo/undoblk2.cxx b/sc/source/ui/undo/undoblk2.cxx
index dd4ec09..4815ed3 100644
--- a/sc/source/ui/undo/undoblk2.cxx
+++ b/sc/source/ui/undo/undoblk2.cxx
@@ -36,7 +36,7 @@ TYPEINIT1(ScUndoWidthOrHeight,      SfxUndoAction);
 ScUndoWidthOrHeight::ScUndoWidthOrHeight( ScDocShell* pNewDocShell,
                 const ScMarkData& rMark,
                 SCCOLROW nNewStart, SCTAB nNewStartTab, SCCOLROW nNewEnd, SCTAB nNewEndTab,
-                ScDocument* pNewUndoDoc, SCCOLROW nNewCnt, SCCOLROW* pNewRanges,
+                ScDocument* pNewUndoDoc, const std::vector<sc::ColRowSpan>& rRanges,
                 ScOutlineTable* pNewUndoTab,
                 ScSizeMode eNewMode, sal_uInt16 nNewSizeTwips, bool bNewWidth ) :
     ScSimpleUndo( pNewDocShell ),
@@ -47,8 +47,7 @@ ScUndoWidthOrHeight::ScUndoWidthOrHeight( ScDocShell* pNewDocShell,
     nEndTab( nNewEndTab ),
     pUndoDoc( pNewUndoDoc ),
     pUndoTab( pNewUndoTab ),
-    nRangeCnt( nNewCnt ),
-    pRanges( pNewRanges ),
+    maRanges(rRanges),
     nNewSize( nNewSizeTwips ),
     bWidth( bNewWidth ),
     eMode( eNewMode ),
@@ -59,7 +58,6 @@ ScUndoWidthOrHeight::ScUndoWidthOrHeight( ScDocShell* pNewDocShell,
 
 ScUndoWidthOrHeight::~ScUndoWidthOrHeight()
 {
-    delete[] pRanges;
     delete pUndoDoc;
     delete pUndoTab;
     DeleteSdrUndoAction( pDrawUndo );
@@ -152,7 +150,8 @@ void ScUndoWidthOrHeight::Redo()
             pViewShell->SetTabNo( nStartTab );
 
         // SetWidthOrHeight changes current sheet!
-        pViewShell->SetWidthOrHeight( bWidth, nRangeCnt, pRanges, eMode, nNewSize, false, true, &aMarkData );
+        pViewShell->SetWidthOrHeight(
+            bWidth, maRanges, eMode, nNewSize, false, true, &aMarkData);
     }
 
     // paint grid if selection was changed directly at the MarkData
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index ac2c96d..83a68a8 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -8848,8 +8848,7 @@ void ScTableColumnObj::SetOnePropertyValue(const SfxItemPropertySimpleEntry* pEn
         SCTAB nTab = rRange.aStart.Tab();
         ScDocFunc &rFunc = pDocSh->GetDocFunc();
 
-        SCCOLROW nColArr[2];
-        nColArr[0] = nColArr[1] = nCol;
+        std::vector<sc::ColRowSpan> aColArr(1, sc::ColRowSpan(nCol,nCol));
 
         if ( pEntry->nWID == SC_WID_UNO_CELLWID )
         {
@@ -8858,23 +8857,23 @@ void ScTableColumnObj::SetOnePropertyValue(const SfxItemPropertySimpleEntry* pEn
             {
                 //  property is 1/100mm, column width is twips
                 nNewWidth = HMMToTwips(nNewWidth);
-                rFunc.SetWidthOrHeight( true, 1, nColArr, nTab, SC_SIZE_ORIGINAL,
-                                        (sal_uInt16)nNewWidth, true, true );
+                rFunc.SetWidthOrHeight(
+                    true, aColArr, nTab, SC_SIZE_ORIGINAL, (sal_uInt16)nNewWidth, true, true);
             }
         }
         else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
         {
             sal_Bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
             ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
-            rFunc.SetWidthOrHeight( true, 1, nColArr, nTab, eMode, 0, true, true );
+            rFunc.SetWidthOrHeight(true, aColArr, nTab, eMode, 0, true, true);
             //  SC_SIZE_DIRECT mit Groesse 0 blendet aus
         }
         else if ( pEntry->nWID == SC_WID_UNO_OWIDTH )
         {
             sal_Bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
             if (bOpt)
-                rFunc.SetWidthOrHeight( true, 1, nColArr, nTab,
-                                        SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH, true, true );
+                rFunc.SetWidthOrHeight(
+                    true, aColArr, nTab, SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH, true, true);
             // sal_False bei Spalten momentan ohne Auswirkung
         }
         else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE || pEntry->nWID == SC_WID_UNO_MANPAGE )
@@ -8991,8 +8990,7 @@ void ScTableRowObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntr
         SCTAB nTab = rRange.aStart.Tab();
         ScDocFunc &rFunc = pDocSh->GetDocFunc();
 
-        SCCOLROW nRowArr[2];
-        nRowArr[0] = nRowArr[1] = nRow;
+        std::vector<sc::ColRowSpan> aRowArr(1, sc::ColRowSpan(nRow,nRow));
 
         if ( pEntry->nWID == SC_WID_UNO_CELLHGT )
         {
@@ -9001,15 +8999,15 @@ void ScTableRowObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntr
             {
                 //  property is 1/100mm, row height is twips
                 nNewHeight = HMMToTwips(nNewHeight);
-                rFunc.SetWidthOrHeight( false, 1, nRowArr, nTab, SC_SIZE_ORIGINAL,
-                                        (sal_uInt16)nNewHeight, true, true );
+                rFunc.SetWidthOrHeight(
+                    false, aRowArr, nTab, SC_SIZE_ORIGINAL, (sal_uInt16)nNewHeight, true, true);
             }
         }
         else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
         {
             sal_Bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
             ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
-            rFunc.SetWidthOrHeight( false, 1, nRowArr, nTab, eMode, 0, true, true );
+            rFunc.SetWidthOrHeight(false, aRowArr, nTab, eMode, 0, true, true);
             //  SC_SIZE_DIRECT mit Groesse 0 blendet aus
         }
         else if ( pEntry->nWID == SC_WID_UNO_CELLFILT )
@@ -9022,12 +9020,12 @@ void ScTableRowObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntr
         {
             sal_Bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
             if (bOpt)
-                rFunc.SetWidthOrHeight( false, 1, nRowArr, nTab, SC_SIZE_OPTIMAL, 0, true, true );
+                rFunc.SetWidthOrHeight(false, aRowArr, nTab, SC_SIZE_OPTIMAL, 0, true, true);
             else
             {
                 //  set current height again manually
                 sal_uInt16 nHeight = pDoc->GetOriginalHeight( nRow, nTab );
-                rFunc.SetWidthOrHeight( false, 1, nRowArr, nTab, SC_SIZE_ORIGINAL, nHeight, true, true );
+                rFunc.SetWidthOrHeight(false, aRowArr, nTab, SC_SIZE_ORIGINAL, nHeight, true, true);
             }
         }
         else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE || pEntry->nWID == SC_WID_UNO_MANPAGE )
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index e743cec..8a1cd1c 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -96,6 +96,7 @@
 #include "platforminfo.hxx"
 #include "interpre.hxx"
 #include "formulagroup.hxx"
+#include <columnspanset.hxx>
 
 using namespace com::sun::star;
 
@@ -3088,9 +3089,7 @@ void SAL_CALL ScTableColumnsObj::setPropertyValue(
     if (!pDocShell)
         throw uno::RuntimeException();
 
-    SCCOLROW nColArr[2];
-    nColArr[0] = nStartCol;
-    nColArr[1] = nEndCol;
+    std::vector<sc::ColRowSpan> aColArr(1, sc::ColRowSpan(nStartCol,nEndCol));
     OUString aNameString(aPropertyName);
     ScDocFunc& rFunc = pDocShell->GetDocFunc();
 
@@ -3098,22 +3097,22 @@ void SAL_CALL ScTableColumnsObj::setPropertyValue(
     {
         sal_Int32 nNewWidth = 0;
         if ( aValue >>= nNewWidth )
-            rFunc.SetWidthOrHeight( true, 1, nColArr, nTab, SC_SIZE_ORIGINAL,
-                                    (sal_uInt16)HMMToTwips(nNewWidth), true, true );
+            rFunc.SetWidthOrHeight(
+                true, aColArr, nTab, SC_SIZE_ORIGINAL, (sal_uInt16)HMMToTwips(nNewWidth), true, true);
     }
     else if ( aNameString.equalsAscii( SC_UNONAME_CELLVIS ) )
     {
         sal_Bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
         ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
-        rFunc.SetWidthOrHeight( true, 1, nColArr, nTab, eMode, 0, true, true );
+        rFunc.SetWidthOrHeight(true, aColArr, nTab, eMode, 0, true, true);
         //  SC_SIZE_DIRECT with size 0: hide
     }
     else if ( aNameString.equalsAscii( SC_UNONAME_OWIDTH ) )
     {
         sal_Bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
         if (bOpt)
-            rFunc.SetWidthOrHeight( true, 1, nColArr, nTab,
-                                    SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH, true, true );
+            rFunc.SetWidthOrHeight(
+                true, aColArr, nTab, SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH, true, true);
         // sal_False for columns currently has no effect
     }
     else if ( aNameString.equalsAscii( SC_UNONAME_NEWPAGE ) || aNameString.equalsAscii( SC_UNONAME_MANPAGE ) )
@@ -3311,9 +3310,7 @@ void SAL_CALL ScTableRowsObj::setPropertyValue(
 
     ScDocFunc& rFunc = pDocShell->GetDocFunc();
     ScDocument* pDoc = pDocShell->GetDocument();
-    SCCOLROW nRowArr[2];
-    nRowArr[0] = nStartRow;
-    nRowArr[1] = nEndRow;
+    std::vector<sc::ColRowSpan> aRowArr(1, sc::ColRowSpan(nStartRow,nEndRow));
     OUString aNameString(aPropertyName);
 
     if ( aNameString.equalsAscii( SC_UNONAME_OHEIGHT ) )
@@ -3331,7 +3328,7 @@ void SAL_CALL ScTableRowsObj::setPropertyValue(
         {
             sal_Bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
             if (bOpt)
-                rFunc.SetWidthOrHeight( false, 1, nRowArr, nTab, SC_SIZE_OPTIMAL, 0, true, true );
+                rFunc.SetWidthOrHeight(false, aRowArr, nTab, SC_SIZE_OPTIMAL, 0, true, true);
             else
             {
                 //! manually set old heights again?
@@ -3352,15 +3349,15 @@ void SAL_CALL ScTableRowsObj::setPropertyValue(
                 pDoc->SetManualHeight( nStartRow, nEndRow, nTab, true );
             }
             else
-                rFunc.SetWidthOrHeight( false, 1, nRowArr, nTab, SC_SIZE_ORIGINAL,
-                                        (sal_uInt16)HMMToTwips(nNewHeight), true, true );
+                rFunc.SetWidthOrHeight(
+                    false, aRowArr, nTab, SC_SIZE_ORIGINAL, (sal_uInt16)HMMToTwips(nNewHeight), true, true);
         }
     }
     else if ( aNameString.equalsAscii( SC_UNONAME_CELLVIS ) )
     {
         sal_Bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
         ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
-        rFunc.SetWidthOrHeight( false, 1, nRowArr, nTab, eMode, 0, true, true );
+        rFunc.SetWidthOrHeight(false, aRowArr, nTab, eMode, 0, true, true);
         //  SC_SIZE_DIRECT with size 0: hide
     }
     else if ( aNameString.equalsAscii( SC_UNONAME_VISFLAG ) )
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 1edab8c..ef2ab64 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -172,6 +172,7 @@
 #include <com/sun/star/bridge/oleautomation/Date.hpp>
 #include "tokenarray.hxx"
 #include "tokenuno.hxx"
+#include <columnspanset.hxx>
 
 #include <boost/scoped_ptr.hpp>
 
@@ -3862,13 +3863,10 @@ ScVbaRange::setColumnWidth( const uno::Any& _columnwidth ) throw (uno::RuntimeEx
         table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
         sal_uInt16 nTwips = lcl_pointsToTwips( nColWidth );
 
-        SCCOLROW nColArr[2];
-        nColArr[0] = thisAddress.StartColumn;
-        nColArr[1] = thisAddress.EndColumn;
+        std::vector<sc::ColRowSpan> aColArr(1, sc::ColRowSpan(thisAddress.StartColumn, thisAddress.EndColumn));
         // #163561# use mode SC_SIZE_DIRECT: hide for width 0, show for other values
-        pDocShell->GetDocFunc().SetWidthOrHeight( true, 1, nColArr, thisAddress.Sheet,
-                                                  SC_SIZE_DIRECT, nTwips, true, true );
-
+        pDocShell->GetDocFunc().SetWidthOrHeight(
+            true, aColArr, thisAddress.Sheet, SC_SIZE_DIRECT, nTwips, true, true);
     }
 }
 
@@ -4026,11 +4024,9 @@ ScVbaRange::setRowHeight( const uno::Any& _rowheight) throw (uno::RuntimeExcepti
     sal_uInt16 nTwips = lcl_pointsToTwips( nHeight );
 
     ScDocShell* pDocShell = getDocShellFromRange( mxRange );
-    SCCOLROW nRowArr[2];
-    nRowArr[0] = thisAddress.StartRow;
-    nRowArr[1] = thisAddress.EndRow;
-    pDocShell->GetDocFunc().SetWidthOrHeight( false, 1, nRowArr, thisAddress.Sheet, SC_SIZE_ORIGINAL,
-                                                                        nTwips, true, true );
+    std::vector<sc::ColRowSpan> aRowArr(1, sc::ColRowSpan(thisAddress.StartRow, thisAddress.EndRow));
+    pDocShell->GetDocFunc().SetWidthOrHeight(
+        false, aRowArr, thisAddress.Sheet, SC_SIZE_ORIGINAL, nTwips, true, true);
 }
 
 uno::Any SAL_CALL
@@ -4739,18 +4735,16 @@ ScVbaRange::Autofit() throw (uno::RuntimeException, std::exception)
             RangeHelper thisRange( mxRange );
             table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
 
-            SCCOLROW nColArr[2];
-            nColArr[0] = thisAddress.StartColumn;
-            nColArr[1] = thisAddress.EndColumn;
-            sal_Bool bDirection = sal_True;
+            std::vector<sc::ColRowSpan> aColArr(1, sc::ColRowSpan(thisAddress.StartColumn,thisAddress.EndColumn));
+            bool bDirection = true;
             if ( mbIsRows )
             {
                 bDirection = false;
-                nColArr[0] = thisAddress.StartRow;
-                nColArr[1] = thisAddress.EndRow;
+                aColArr[0].mnStart = thisAddress.StartRow;
+                aColArr[0].mnEnd = thisAddress.EndRow;
             }
-            pDocShell->GetDocFunc().SetWidthOrHeight( bDirection, 1, nColArr, thisAddress.Sheet,
-                                                      SC_SIZE_OPTIMAL, 0, true, true );
+            pDocShell->GetDocFunc().SetWidthOrHeight(
+                bDirection, aColArr, thisAddress.Sheet, SC_SIZE_OPTIMAL, 0, true, true);
     }
 }
 
diff --git a/sc/source/ui/view/colrowba.cxx b/sc/source/ui/view/colrowba.cxx
index 94871b4..415bce1 100644
--- a/sc/source/ui/view/colrowba.cxx
+++ b/sc/source/ui/view/colrowba.cxx
@@ -28,6 +28,7 @@
 #include "appoptio.hxx"
 #include "globstr.hrc"
 #include "markdata.hxx"
+#include <columnspanset.hxx>
 
 // STATIC DATA -----------------------------------------------------------
 
@@ -112,8 +113,7 @@ void ScColBar::SetEntrySize( SCCOLROW nPos, sal_uInt16 nNewSize )
 
     ScMarkData& rMark = pViewData->GetMarkData();
 
-    SCCOLROW* pRanges = new SCCOLROW[MAXCOL+1];
-    SCCOL nRangeCnt = 0;
+    std::vector<sc::ColRowSpan> aRanges;
     if ( rMark.IsColumnMarked( static_cast<SCCOL>(nPos) ) )
     {
         SCCOL nStart = 0;
@@ -128,9 +128,7 @@ void ScColBar::SetEntrySize( SCCOLROW nPos, sal_uInt16 nNewSize )
                     ++nEnd;
                 if (!rMark.IsColumnMarked(nEnd))
                     --nEnd;
-                pRanges[static_cast<size_t>(2*nRangeCnt)  ] = nStart;
-                pRanges[static_cast<size_t>(2*nRangeCnt+1)] = nEnd;
-                ++nRangeCnt;
+                aRanges.push_back(sc::ColRowSpan(nStart,nEnd));
                 nStart = nEnd+1;
             }
             else
@@ -139,21 +137,16 @@ void ScColBar::SetEntrySize( SCCOLROW nPos, sal_uInt16 nNewSize )
     }
     else
     {
-        pRanges[0] = nPos;
-        pRanges[1] = nPos;
-        nRangeCnt = 1;
+        aRanges.push_back(sc::ColRowSpan(nPos,nPos));
     }
 
-    pViewData->GetView()->SetWidthOrHeight( true, nRangeCnt, pRanges, eMode, nSizeTwips );
-    delete[] pRanges;
+    pViewData->GetView()->SetWidthOrHeight(true, aRanges, eMode, nSizeTwips);
 }
 
 void ScColBar::HideEntries( SCCOLROW nStart, SCCOLROW nEnd )
 {
-    SCCOLROW nRange[2];
-    nRange[0] = nStart;
-    nRange[1] = nEnd;
-    pViewData->GetView()->SetWidthOrHeight( true, 1, nRange, SC_SIZE_DIRECT, 0 );
+    std::vector<sc::ColRowSpan> aRanges(1, sc::ColRowSpan(nStart,nEnd));
+    pViewData->GetView()->SetWidthOrHeight(true, aRanges, SC_SIZE_DIRECT, 0);
 }
 
 void ScColBar::SetMarking( bool bSet )
@@ -276,8 +269,7 @@ void ScRowBar::SetEntrySize( SCCOLROW nPos, sal_uInt16 nNewSize )
 
     ScMarkData& rMark = pViewData->GetMarkData();
 
-    SCCOLROW* pRanges = new SCCOLROW[MAXROW+1];
-    SCROW nRangeCnt = 0;
+    std::vector<sc::ColRowSpan> aRanges;
     if ( rMark.IsRowMarked( nPos ) )
     {
         SCROW nStart = 0;
@@ -292,9 +284,7 @@ void ScRowBar::SetEntrySize( SCCOLROW nPos, sal_uInt16 nNewSize )
                     ++nEnd;
                 if (!rMark.IsRowMarked(nEnd))
                     --nEnd;
-                pRanges[static_cast<size_t>(2*nRangeCnt)  ] = nStart;
-                pRanges[static_cast<size_t>(2*nRangeCnt+1)] = nEnd;
-                ++nRangeCnt;
+                aRanges.push_back(sc::ColRowSpan(nStart,nEnd));
                 nStart = nEnd+1;
             }
             else
@@ -303,21 +293,16 @@ void ScRowBar::SetEntrySize( SCCOLROW nPos, sal_uInt16 nNewSize )
     }
     else
     {
-        pRanges[0] = nPos;
-        pRanges[1] = nPos;
-        nRangeCnt = 1;
+        aRanges.push_back(sc::ColRowSpan(nPos,nPos));
     }
 
-    pViewData->GetView()->SetWidthOrHeight( false, nRangeCnt, pRanges, eMode, nSizeTwips );
-    delete[] pRanges;
+    pViewData->GetView()->SetWidthOrHeight(false, aRanges, eMode, nSizeTwips);
 }
 
 void ScRowBar::HideEntries( SCCOLROW nStart, SCCOLROW nEnd )
 {
-    SCCOLROW nRange[2];
-    nRange[0] = nStart;
-    nRange[1] = nEnd;
-    pViewData->GetView()->SetWidthOrHeight( false, 1, nRange, SC_SIZE_DIRECT, 0 );
+    std::vector<sc::ColRowSpan> aRange(1, sc::ColRowSpan(nStart,nEnd));
+    pViewData->GetView()->SetWidthOrHeight(false, aRange, SC_SIZE_DIRECT, 0);
 }
 
 void ScRowBar::SetMarking( bool bSet )
diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx
index fbcc0fb..095ef72 100644
--- a/sc/source/ui/view/preview.cxx
+++ b/sc/source/ui/view/preview.cxx
@@ -59,6 +59,7 @@
 #include "AccessibilityHints.hxx"
 #include <vcl/svapp.hxx>
 #include "viewutil.hxx"
+#include <columnspanset.hxx>
 
 // STATIC DATA -----------------------------------------------------------
 
@@ -1217,7 +1218,7 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
             if( bMoveRulerAction )
             {
                 long  nNewColWidth = 0;
-                SCCOLROW nCols[2] = { nColNumberButttonDown, nColNumberButttonDown };
+                std::vector<sc::ColRowSpan> aCols(1, sc::ColRowSpan(nColNumberButttonDown,nColNumberButttonDown));
 
                 if( !bLayoutRTL )
                 {
@@ -1234,8 +1235,7 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
                 if( nNewColWidth >= 0 )
                 {
                     pDocShell->GetDocFunc().SetWidthOrHeight(
-                                                true, 1,nCols, nTab, SC_SIZE_DIRECT,
-                                                (sal_uInt16)nNewColWidth, true, true);
+                        true, aCols, nTab, SC_SIZE_DIRECT, (sal_uInt16)nNewColWidth, true, true);
                     pDocShell->SetModified(true);
                 }
                 if ( ValidTab( nTab ) )
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 88640ee..e897b8e 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1938,11 +1938,11 @@ void ScViewFunc::DeleteContents( sal_uInt16 nFlags, bool bRecord )
 
 //  column width/row height (via header) - undo OK
 
-void ScViewFunc::SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRanges,
-                                    ScSizeMode eMode, sal_uInt16 nSizeTwips,
-                                    bool bRecord, bool bPaint, ScMarkData* pMarkData )
+void ScViewFunc::SetWidthOrHeight(
+    bool bWidth, const std::vector<sc::ColRowSpan>& rRanges, ScSizeMode eMode,
+    sal_uInt16 nSizeTwips, bool bRecord, bool bPaint, ScMarkData* pMarkData )
 {
-    if (nRangeCnt == 0)
+    if (rRanges.empty())
         return;
 
     // use view's mark if none specified
@@ -1962,19 +1962,23 @@ void ScViewFunc::SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pR
     bool bAllowed = true;
     ScMarkData::iterator itr = pMarkData->begin(), itrEnd = pMarkData->end();
     for (; itr != itrEnd && bAllowed; ++itr)
-        for ( SCCOLROW i=0; i<nRangeCnt && bAllowed; i++ )
+    {
+        for (size_t i = 0, n = rRanges.size(); i < n && bAllowed; ++i)
         {
             bool bOnlyMatrix;
             if (bWidth)
-                bAllowed = pDoc->IsBlockEditable( *itr,
-                        static_cast<SCCOL>(pRanges[2*i]),0,
-                        static_cast<SCCOL>(pRanges[2*i+1]),MAXROW,
+            {
+                bAllowed = pDoc->IsBlockEditable(
+                    *itr, rRanges[i].mnStart, 0, rRanges[i].mnEnd, MAXROW,
                         &bOnlyMatrix ) || bOnlyMatrix;
+            }
             else
-                bAllowed = pDoc->IsBlockEditable( *itr, 0,pRanges[2*i],
-                        MAXCOL,pRanges[2*i+1], &bOnlyMatrix ) ||
-                    bOnlyMatrix;
+            {
+                bAllowed = pDoc->IsBlockEditable(
+                    *itr, 0, rRanges[i].mnStart, MAXCOL,rRanges[i].mnEnd, &bOnlyMatrix) || bOnlyMatrix;
+            }
         }
+    }
 
     // Allow users to resize cols/rows in readonly docs despite the r/o state.
     // It is frustrating to be unable to see content in mis-sized cells.
@@ -1984,8 +1988,8 @@ void ScViewFunc::SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pR
         return;
     }
 
-    SCCOLROW nStart = pRanges[0];
-    SCCOLROW nEnd = pRanges[2*nRangeCnt-1];
+    SCCOLROW nStart = rRanges[0].mnStart;
+    SCCOLROW nEnd = rRanges[0].mnEnd;
 
     bool bFormula = false;
     if ( eMode == SC_SIZE_OPTIMAL )
@@ -1996,7 +2000,7 @@ void ScViewFunc::SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pR
 
     ScDocument*     pUndoDoc = NULL;
     ScOutlineTable* pUndoTab = NULL;
-    SCCOLROW*       pUndoRanges = NULL;
+    std::vector<sc::ColRowSpan> aUndoRanges;
 
     if ( bRecord )
     {
@@ -2026,8 +2030,7 @@ void ScViewFunc::SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pR
             }
         }
 
-        pUndoRanges = new SCCOLROW[ 2*nRangeCnt ];
-        memcpy( pUndoRanges, pRanges, 2*nRangeCnt*sizeof(SCCOLROW) );
+        aUndoRanges = rRanges;
 
         //! outlines from all tab?
         ScOutlineTable* pTable = pDoc->GetOutlineTable( nCurTab );
@@ -2045,12 +2048,11 @@ void ScViewFunc::SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pR
     for (; itr != itrEnd; ++itr)
     {
         nTab = *itr;
-        const SCCOLROW* pTabRanges = pRanges;
 
-        for (SCCOLROW nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++)
+        for (size_t i = 0, n = rRanges.size(); i < n; ++i)
         {
-            SCCOLROW nStartNo = *(pTabRanges++);
-            SCCOLROW nEndNo = *(pTabRanges++);
+            SCCOLROW nStartNo = rRanges[i].mnStart;
+            SCCOLROW nEndNo = rRanges[i].mnEnd;
 
             if ( !bWidth )                      // height always blockwise
             {
@@ -2155,10 +2157,9 @@ void ScViewFunc::SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pR
     if (bRecord)
     {
         pDocSh->GetUndoManager()->AddUndoAction(
-            new ScUndoWidthOrHeight( pDocSh, *pMarkData,
-                                     nStart, nCurTab, nEnd, nCurTab,
-                                     pUndoDoc, nRangeCnt, pUndoRanges,
-                                     pUndoTab, eMode, nSizeTwips, bWidth ) );
+            new ScUndoWidthOrHeight(
+                pDocSh, *pMarkData, nStart, nCurTab, nEnd, nCurTab,
+                pUndoDoc, aUndoRanges, pUndoTab, eMode, nSizeTwips, bWidth));
     }
 
     // fdo#36247 Ensure that the drawing layer's map mode scaling factors match
@@ -2212,11 +2213,10 @@ void ScViewFunc::SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pR
             for (; itr != itrEnd; ++itr)
             {
                 nTab = *itr;
-                const SCCOLROW* pTabRanges = pRanges;
-                for ( SCCOLROW nRange = 0; nRange < nRangeCnt; ++nRange )
+                for (size_t i = 0, n = rRanges.size(); i < n; ++i)
                 {
-                    SCCOL nStartCol = static_cast< SCCOL >( *(pTabRanges++) );
-                    SCCOL nEndCol = static_cast< SCCOL >( *(pTabRanges++) );
+                    SCCOL nStartCol = rRanges[i].mnStart;
+                    SCCOL nEndCol   = rRanges[i].mnEnd;
                     for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol )
                     {
                         aChangeRanges.Append( ScRange( nCol, 0, nTab ) );
@@ -2247,17 +2247,11 @@ void ScViewFunc::SetMarkedWidthOrHeight( bool bWidth, ScSizeMode eMode, sal_uInt
         MarkDataChanged();
     }
 
-    SCCOLROW* pRanges = new SCCOLROW[MAXCOLROWCOUNT];
-    SCCOLROW nRangeCnt = 0;
-
-    if ( bWidth )
-        nRangeCnt = rMark.GetMarkColumnRanges( pRanges );
-    else
-        nRangeCnt = rMark.GetMarkRowRanges( pRanges );
+    std::vector<sc::ColRowSpan> aRanges =
+        bWidth ? rMark.GetMarkedColSpans() : rMark.GetMarkedRowSpans();
 
-    SetWidthOrHeight( bWidth, nRangeCnt, pRanges, eMode, nSizeTwips, bRecord, bPaint );
+    SetWidthOrHeight(bWidth, aRanges, eMode, nSizeTwips, bRecord, bPaint);
 
-    delete[] pRanges;
     rMark.MarkToSimple();
 }
 
@@ -2291,7 +2285,7 @@ void ScViewFunc::ModifyCellSize( ScDirection eDir, bool bOptimal )
 
     sal_uInt16 nWidth = pDoc->GetColWidth( nCol, nTab );
     sal_uInt16 nHeight = pDoc->GetRowHeight( nRow, nTab );
-    SCCOLROW nRange[2];
+    std::vector<sc::ColRowSpan> aRange(1, sc::ColRowSpan(0,0));
     if ( eDir == DIR_LEFT || eDir == DIR_RIGHT )
     {
         if (bOptimal)               // width of this single cell
@@ -2350,8 +2344,9 @@ void ScViewFunc::ModifyCellSize( ScDirection eDir, bool bOptimal )
             if ( nWidth < nStepX ) nWidth = nStepX;
             if ( nWidth > MAX_COL_WIDTH ) nWidth = MAX_COL_WIDTH;
         }
-        nRange[0] = nRange[1] = nCol;
-        SetWidthOrHeight( true, 1, nRange, SC_SIZE_DIRECT, nWidth );
+        aRange[0].mnStart = nCol;
+        aRange[0].mnEnd = nCol;
+        SetWidthOrHeight(true, aRange, SC_SIZE_DIRECT, nWidth);
 
         //  adjust height of this row if width demands/allows this
 
@@ -2384,8 +2379,9 @@ void ScViewFunc::ModifyCellSize( ScDirection eDir, bool bOptimal )
             if ( nHeight < nStepY ) nHeight = nStepY;
             if ( nHeight > MAX_ROW_HEIGHT ) nHeight = MAX_ROW_HEIGHT;
         }
-        nRange[0] = nRange[1] = nRow;
-        SetWidthOrHeight( false, 1, nRange, eMode, nHeight );
+        aRange[0].mnStart = nRow;
+        aRange[0].mnEnd = nRow;
+        SetWidthOrHeight(false, aRange, eMode, nHeight);
     }
 
     if ( bAnyEdit )


More information about the Libreoffice-commits mailing list