[Libreoffice-commits] core.git: 2 commits - framework/source include/vcl sc/inc sc/source

Noel Grandin noel.grandin at collabora.co.uk
Sat Sep 2 11:05:11 UTC 2017


 framework/source/interaction/quietinteraction.cxx |    2 +-
 framework/source/services/desktop.cxx             |    2 +-
 include/vcl/errcode.hxx                           |    4 +---
 sc/inc/document.hxx                               |    2 +-
 sc/inc/table.hxx                                  |    3 +++
 sc/source/core/data/document.cxx                  |    2 +-
 sc/source/core/data/table2.cxx                    |   20 +++++++++++---------
 sc/source/core/data/table5.cxx                    |    7 +++----
 sc/source/filter/dif/difimp.cxx                   |    3 ++-
 sc/source/filter/excel/colrowst.cxx               |    5 +++--
 sc/source/ui/miscdlgs/datatableview.cxx           |    3 ++-
 sc/source/ui/unoobj/cellsuno.cxx                  |    6 +++---
 sc/source/ui/unoobj/docuno.cxx                    |    3 ++-
 13 files changed, 34 insertions(+), 28 deletions(-)

New commits:
commit 1463625ae26900d2461fd72a5a2c894b9f1b8726
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Aug 30 12:19:01 2017 +0200

    dynamic column container: fix some more for loops
    
    and add reverse-iterator functionality
    
    Change-Id: Ide7ee9d2152871d414246303d76c91da36557524
    Reviewed-on: https://gerrit.libreoffice.org/41727
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 45f450e59462..6e91927719a4 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2322,7 +2322,7 @@ public:
     void                SwapNonEmpty( sc::TableValues& rValues );
     void                finalizeOutlineImport();
 
-    ScColumnsRange      GetColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd) const;
+    SC_DLLPUBLIC ScColumnsRange GetColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd) const;
 
 private:
 
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 3113ef6d8cd0..4c734c7d7823 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -132,6 +132,7 @@ class ScColumnsRange final
         explicit Iterator(std::vector<ScColumn*>::const_iterator colIter) : maColIter(colIter) {}
 
         Iterator& operator++() { maColIter++; return *this;}
+        Iterator& operator--() { maColIter--; return *this;}
 
         bool operator==(Iterator other) const {return maColIter == other.maColIter;}
         bool operator!=(Iterator other) const {return !(*this == other);}
@@ -141,6 +142,8 @@ class ScColumnsRange final
     ScColumnsRange(Iterator nBegin, Iterator nEnd) : maBegin(nBegin), maEnd(nEnd) {}
     const Iterator & begin() { return maBegin; }
     const Iterator & end() { return maEnd; }
+    std::reverse_iterator<Iterator> rbegin() { return std::reverse_iterator<Iterator>(maEnd); }
+    std::reverse_iterator<Iterator> rend() { return std::reverse_iterator<Iterator>(maBegin); }
 private:
     const Iterator maBegin;
     const Iterator maEnd;
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 94a91edd96e7..9079c92d67f6 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -4569,7 +4569,7 @@ SCCOL ScDocument::GetNextDifferentChangedCol( SCTAB nTab, SCCOL nStart) const
     {
         CRFlags nStartFlags = maTabs[nTab]->GetColFlags(nStart);
         sal_uInt16 nStartWidth = maTabs[nTab]->GetOriginalWidth(nStart);
-        for (SCCOL nCol = nStart + 1; nCol <= MAXCOL; nCol++)
+        for (SCCOL nCol : maTabs[nTab]->GetColumnsRange( nStart + 1, MAXCOL))
         {
             if (((nStartFlags & CRFlags::ManualBreak) != (maTabs[nTab]->GetColFlags(nCol) & CRFlags::ManualBreak)) ||
                 (nStartWidth != maTabs[nTab]->GetOriginalWidth(nCol)) ||
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 8ae63775f3c4..d14e699db9a3 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -17,6 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <algorithm>
 #include <memory>
 #include "table.hxx"
 #include "patattr.hxx"
@@ -263,18 +264,19 @@ void ScTable::DeleteRow(
 
 bool ScTable::TestInsertCol( SCROW nStartRow, SCROW nEndRow, SCSIZE nSize ) const
 {
-    bool bTest = true;
-
-    if ( nStartRow==0 && nEndRow==MAXROW && pOutlineTable )
-        bTest = pOutlineTable->TestInsertCol(nSize);
-
     if ( nSize > static_cast<SCSIZE>(MAXCOL) )
-        bTest = false;
+        return false;
 
-    for (SCCOL i=MAXCOL; (i+static_cast<SCCOL>(nSize)>MAXCOL) && bTest; i--)
-        bTest = aCol[i].TestInsertCol(nStartRow, nEndRow);
+    if ( nStartRow==0 && nEndRow==MAXROW && pOutlineTable
+        && ! pOutlineTable->TestInsertCol(nSize) )
+            return false;
 
-    return bTest;
+    auto range = GetColumnsRange( MAXCOL - static_cast<SCCOL>(nSize) + 1, MAXCOL );
+    for (auto it = range.rbegin(); it != range.rend(); ++it )
+        if (! aCol[*it].TestInsertCol(nStartRow, nEndRow))
+            return false;
+
+    return true;
 }
 
 void ScTable::InsertCol(
diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx
index 14d38e5be129..de411231e13e 100644
--- a/sc/source/core/data/table5.cxx
+++ b/sc/source/core/data/table5.cxx
@@ -80,7 +80,6 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
     SfxItemSet* pStyleSet = &pStyle->GetItemSet();
     const SfxPoolItem* pItem;
 
-    SCCOL nX;
     SCCOL nStartCol = 0;
     SCROW nStartRow = 0;
     SCCOL nEndCol = MAXCOL;
@@ -99,7 +98,7 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
         {
             // Show nothing, when multiple ranges
 
-            for (nX=0; nX<MAXCOL; nX++)
+            for (SCCOL nX : GetColumnsRange(0, MAXCOL))
                 RemoveColBreak(nX, true, false);
 
             RemoveRowPageBreaks(0, MAXROW-1);
@@ -150,7 +149,7 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
 
         //  Beginning: Remove breaks
 
-    for (nX=0; nX<nStartCol; nX++)
+    for (SCCOL nX : GetColumnsRange(0, nStartCol-1))
         RemoveColBreak(nX, true, false);
     RemoveRowPageBreaks(0, nStartRow-1);
 
@@ -164,7 +163,7 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
     bool bRepeatCol = ( nRepeatStartX != SCCOL_REPEAT_NONE );
     bool bColFound = false;
     long nSizeX = 0;
-    for (nX=nStartCol; nX<=nEndCol; nX++)
+    for (SCCOL nX=nStartCol; nX<=nEndCol; nX++)
     {
         bool bStartOfPage = false;
         long nThisX = ColHidden(nX) ? 0 : pColWidth[nX];
diff --git a/sc/source/filter/dif/difimp.cxx b/sc/source/filter/dif/difimp.cxx
index 4d8c7084d632..7cd8190ecd3a 100644
--- a/sc/source/filter/dif/difimp.cxx
+++ b/sc/source/filter/dif/difimp.cxx
@@ -32,6 +32,7 @@
 #include "scerrors.hxx"
 #include "scitems.hxx"
 #include "stringutil.hxx"
+#include "table.hxx"
 #include <memory>
 
 const sal_Unicode pKeyTABLE[]   = { 'T', 'A', 'B', 'L', 'E', 0 };
@@ -686,7 +687,7 @@ void DifAttrCache::SetNumFormat( const SCCOL nCol, const SCROW nRow, const sal_u
 
 void DifAttrCache::Apply( ScDocument& rDoc, SCTAB nTab )
 {
-    for( SCCOL nCol = 0 ; nCol <= MAXCOL ; nCol++ )
+    for( SCCOL nCol : rDoc.GetColumnsRange(nTab, 0, MAXCOL) )
     {
         if( mvCols[ nCol ] )
             mvCols[ nCol ]->Apply( rDoc, nCol, nTab );
diff --git a/sc/source/filter/excel/colrowst.cxx b/sc/source/filter/excel/colrowst.cxx
index e1d12a0098cf..10563791fc9e 100644
--- a/sc/source/filter/excel/colrowst.cxx
+++ b/sc/source/filter/excel/colrowst.cxx
@@ -29,6 +29,7 @@
 #include "xistyle.hxx"
 #include "queryparam.hxx"
 #include "excimp8.hxx"
+#include "table.hxx"
 
 XclImpColRowSettings::XclImpColRowSettings( const XclImpRoot& rRoot ) :
     XclImpRoot( rRoot ),
@@ -188,7 +189,7 @@ void XclImpColRowSettings::Convert( SCTAB nScTab )
     // column widths ----------------------------------------------------------
 
     maColWidths.build_tree();
-    for( SCCOL nCol = 0; nCol <= MAXCOL; ++nCol )
+    for( SCCOL nCol : rDoc.GetColumnsRange(nScTab, 0, MAXCOL) )
     {
         sal_uInt16 nWidth = mnDefWidth;
         if (GetColFlag(nCol, ExcColRowFlags::Used))
@@ -280,7 +281,7 @@ void XclImpColRowSettings::ConvertHiddenFlags( SCTAB nScTab )
     ScDocument& rDoc = GetDoc();
 
     // hide the columns
-    for( SCCOL nCol = 0; nCol <= MAXCOL; ++nCol )
+    for( SCCOL nCol : rDoc.GetColumnsRange(nScTab, 0, MAXCOL) )
         if (GetColFlag(nCol, ExcColRowFlags::Hidden))
             rDoc.ShowCol( nCol, nScTab, false );
 
diff --git a/sc/source/ui/miscdlgs/datatableview.cxx b/sc/source/ui/miscdlgs/datatableview.cxx
index d149713ca347..fc0e68aa363a 100644
--- a/sc/source/ui/miscdlgs/datatableview.cxx
+++ b/sc/source/ui/miscdlgs/datatableview.cxx
@@ -23,6 +23,7 @@
 #include "viewdata.hxx"
 #include "output.hxx"
 #include "fillinfo.hxx"
+#include "table.hxx"
 
 constexpr double nPPTX = 0.06666;
 constexpr double nPPTY = 0.06666;
@@ -178,7 +179,7 @@ SCCOL findColFromPos(sal_uInt16 nPixelPos, const ScDocument* pDoc, SCCOL nStartC
 {
     nPixelPos -= nRowHeaderWidth;
     sal_uInt32 nPixelLength = 0;
-    for (SCCOL nCol = nStartCol; nCol <= MAXCOL; ++nCol)
+    for (SCCOL nCol : pDoc->GetColumnsRange(0, nStartCol, MAXCOL))
     {
         sal_uInt16 nColWidth = pDoc->GetColWidth(nCol, 0, true);
         sal_uInt32 nPixel = ScViewData::ToPixel(nColWidth, nPPTX);
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 5dece97adb2f..d51b82663b3d 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -131,6 +131,7 @@
 #include <sortparam.hxx>
 #include "condformatuno.hxx"
 #include "TablePivotCharts.hxx"
+#include "table.hxx"
 
 #include <list>
 #include <memory>
@@ -6932,8 +6933,7 @@ uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getColumnPage
         }
 
         SCCOL nCount = 0;
-        SCCOL nCol;
-        for (nCol=0; nCol<=MAXCOL; nCol++)
+        for (SCCOL nCol : rDoc.GetColumnsRange(nTab, 0, MAXCOL))
             if (rDoc.HasColBreak(nCol, nTab) != ScBreakType::NONE)
                 ++nCount;
 
@@ -6941,7 +6941,7 @@ uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getColumnPage
         uno::Sequence<sheet::TablePageBreakData> aSeq(nCount);
         sheet::TablePageBreakData* pAry = aSeq.getArray();
         sal_uInt16 nPos = 0;
-        for (nCol=0; nCol<=MAXCOL; nCol++)
+        for (SCCOL nCol : rDoc.GetColumnsRange(nTab, 0, MAXCOL))
         {
             ScBreakType nBreak = rDoc.HasColBreak(nCol, nTab);
             if (nBreak != ScBreakType::NONE)
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index b7b55293edd9..c6445c73d0dd 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -122,6 +122,7 @@
 #include "drtxtob.hxx"
 #include "transobj.hxx"
 #include "chgtrack.hxx"
+#include "table.hxx"
 
 #include "strings.hrc"
 
@@ -4315,7 +4316,7 @@ sal_Int32 SAL_CALL ScAnnotationsObj::getCount()
     if (pDocShell)
     {
         const ScDocument& rDoc = pDocShell->GetDocument();
-        for (SCCOL nCol = 0; nCol <= MAXCOL; ++nCol)
+        for (SCCOL nCol : rDoc.GetColumnsRange(nTab, 0, MAXCOL))
             nCount += rDoc.GetNoteCount(nTab, nCol);
     }
     return nCount;
commit fae405c522ce95bdfaedcbcae407226b4e1c487d
Author: Noel Grandin <noelgrandin at gmail.com>
Date:   Sat Sep 2 08:23:13 2017 +0200

    use more ErrCode.IsWarning()
    
    Change-Id: I92a84cbe3d9a9e794d3e875c60d8db7cb40ae5bd
    Reviewed-on: https://gerrit.libreoffice.org/41827
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/framework/source/interaction/quietinteraction.cxx b/framework/source/interaction/quietinteraction.cxx
index 0d2a7fb2f78d..10d96cd4d708 100644
--- a/framework/source/interaction/quietinteraction.cxx
+++ b/framework/source/interaction/quietinteraction.cxx
@@ -83,7 +83,7 @@ void SAL_CALL QuietInteraction::handle( const css::uno::Reference< css::task::XI
     {
         // warnings can be ignored   => approve
         // errors must break loading => abort
-        bool bWarning = (aErrorCodeRequest.ErrCode & ERRCODE_WARNING_MASK) == ERRCODE_WARNING_MASK;
+        bool bWarning = ErrCode(aErrorCodeRequest.ErrCode).IsWarning();
         if (xApprove.is() && bWarning)
             xApprove->select();
         else
diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx
index d9427c0f5529..580f42b0caeb 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -1269,7 +1269,7 @@ void SAL_CALL Desktop::handle( const css::uno::Reference< css::task::XInteractio
     css::task::ErrorCodeRequest          aErrorCodeRequest;
     if( aRequest >>= aErrorCodeRequest )
     {
-        bool bWarning = ((aErrorCodeRequest.ErrCode & ERRCODE_WARNING_MASK) == ERRCODE_WARNING_MASK);
+        bool bWarning = ErrCode(aErrorCodeRequest.ErrCode).IsWarning();
         if (xApprove.is() && bWarning)
             xApprove->select();
         else
diff --git a/include/vcl/errcode.hxx b/include/vcl/errcode.hxx
index 274a4a00ef03..6b6ffdede306 100644
--- a/include/vcl/errcode.hxx
+++ b/include/vcl/errcode.hxx
@@ -46,7 +46,6 @@ Warning           ||   ||      |
 
 #define ERRCODE_ERROR_MASK               0x3fffffffUL
 #define ERRCODE_WARNING_MASK             0x80000000UL
-#define ERRCODE_RES_MASK                 0x7fff
 
 #define ERRCODE_CLASS_SHIFT              8
 #define ERRCODE_AREA_SHIFT               13
@@ -54,7 +53,6 @@ Warning           ||   ||      |
 
 #define ERRCODE_CLASS_MASK               (31UL << ERRCODE_CLASS_SHIFT)
 
-#define ERRCODE_DYNAMIC_START            ( 1UL << ERRCODE_DYNAMIC_SHIFT)
 #define ERRCODE_DYNAMIC_COUNT            31UL
 #define ERRCODE_DYNAMIC_MASK             (31UL << ERRCODE_DYNAMIC_SHIFT)
 
@@ -127,7 +125,7 @@ public:
     }
 
     constexpr sal_uInt16 GetRest() const {
-        return m_value & ERRCODE_RES_MASK;
+        return m_value & 0x7fff;
     }
 
     OUString toHexString() const {


More information about the Libreoffice-commits mailing list