[Libreoffice-commits] .: Branch 'libreoffice-3-3' - 3 commits - sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Thu Mar 3 11:26:57 PST 2011


 sc/source/core/inc/interpre.hxx  |    1 
 sc/source/core/tool/interpr4.cxx |    2 -
 sc/source/core/tool/interpr7.cxx |   38 +++++++++++++++++++++++++
 sc/source/core/tool/makefile.mk  |    1 
 sc/source/ui/view/tabview2.cxx   |   59 +++++++++------------------------------
 5 files changed, 55 insertions(+), 46 deletions(-)

New commits:
commit e301739e4439be4214de0ff9b1bd6c2142d6806e
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Fri Feb 11 19:31:30 2011 -0500

    Fixed incorrect cursor navigation. (fdo#33756)
    
    Block selection with keyboard was incorrect when the selected range
    included hidden cells.  This also fixes one crasher on block
    selection during formula reference mode i.e. type '=SUM(' and select
    range via keyboard afterward.

diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index b9cb8be..a4e75a4 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -441,8 +441,9 @@ void ScTabView::GetAreaMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, ScFollowMode
 {
     SCCOL nNewX = -1;
     SCROW nNewY = -1;
-    SCCOL nCurX = -1;
-    SCROW nCurY = -1;
+    // current cursor position.
+    SCCOL nCurX = aViewData.GetCurX();
+    SCROW nCurY = aViewData.GetCurY();
 
     if (aViewData.IsRefMode())
     {
@@ -456,8 +457,8 @@ void ScTabView::GetAreaMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, ScFollowMode
     }
     else
     {
-        nNewX = nCurX = aViewData.GetCurX();
-        nNewY = nCurY = aViewData.GetCurY();
+        nNewX = nCurX;
+        nNewY = nCurY;
     }
 
     ScDocument* pDoc = aViewData.GetDocument();
@@ -627,7 +628,7 @@ void ScTabView::SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsROW nOldY, S
 
 namespace {
 
-bool lcl_isCellQualified(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, bool bSelectLocked, bool bSelectUnlocked)
+bool isCellQualified(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, bool bSelectLocked, bool bSelectUnlocked)
 {
     bool bCellProtected = pDoc->HasAttrib(
         nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_PROTECTED);
@@ -641,33 +642,7 @@ bool lcl_isCellQualified(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, b
     return true;
 }
 
-void skipHiddenRows(ScDocument* pDoc, SCTAB nTab, SCROW& rRow, bool bForward)
-{
-    SCROW nFirst, nLast;
-    if (!pDoc->RowHidden(rRow, nTab, &nFirst, &nLast))
-        // This row is visible.  Nothing to do.
-        return;
-
-    if (bForward)
-        rRow = nLast < MAXROW ? nLast + 1 : MAXROW;
-    else
-        rRow = nFirst > 0 ? nFirst - 1 : 0;
-}
-
-void skipHiddenCols(ScDocument* pDoc, SCTAB nTab, SCCOL& rCol, bool bForward)
-{
-    SCCOL nFirst, nLast;
-    if (!pDoc->ColHidden(rCol, nTab, &nFirst, &nLast))
-        // This row is visible.  Nothing to do.
-        return;
-
-    if (bForward)
-        rCol = nLast < MAXCOL ? nLast + 1 : MAXCOL;
-    else
-        rCol = nFirst > 0 ? nFirst - 1 : 0;
-}
-
-void lcl_moveCursorByProtRule(
+void moveCursorByProtRule(
     SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY, SCTAB nTab, ScDocument* pDoc)
 {
     bool bSelectLocked = true;
@@ -685,10 +660,9 @@ void lcl_moveCursorByProtRule(
         {
             for (SCCOL i = 0; i < nMovX; ++i)
             {
-                if (!lcl_isCellQualified(pDoc, rCol+1, rRow, nTab, bSelectLocked, bSelectUnlocked))
+                if (!isCellQualified(pDoc, rCol+1, rRow, nTab, bSelectLocked, bSelectUnlocked))
                     break;
                 ++rCol;
-                skipHiddenCols(pDoc, nTab, rCol, true);
             }
         }
     }
@@ -699,10 +673,9 @@ void lcl_moveCursorByProtRule(
             nMovX = -nMovX;
             for (SCCOL i = 0; i < nMovX; ++i)
             {
-                if (!lcl_isCellQualified(pDoc, rCol-1, rRow, nTab, bSelectLocked, bSelectUnlocked))
+                if (!isCellQualified(pDoc, rCol-1, rRow, nTab, bSelectLocked, bSelectUnlocked))
                     break;
                 --rCol;
-                skipHiddenCols(pDoc, nTab, rCol, false);
             }
         }
     }
@@ -713,10 +686,9 @@ void lcl_moveCursorByProtRule(
         {
             for (SCROW i = 0; i < nMovY; ++i)
             {
-                if (!lcl_isCellQualified(pDoc, rCol, rRow+1, nTab, bSelectLocked, bSelectUnlocked))
+                if (!isCellQualified(pDoc, rCol, rRow+1, nTab, bSelectLocked, bSelectUnlocked))
                     break;
                 ++rRow;
-                skipHiddenRows(pDoc, nTab, rRow, true);
             }
         }
     }
@@ -727,10 +699,9 @@ void lcl_moveCursorByProtRule(
             nMovY = -nMovY;
             for (SCROW i = 0; i < nMovY; ++i)
             {
-                if (!lcl_isCellQualified(pDoc, rCol, rRow-1, nTab, bSelectLocked, bSelectUnlocked))
+                if (!isCellQualified(pDoc, rCol, rRow-1, nTab, bSelectLocked, bSelectUnlocked))
                     break;
                 --rRow;
-                skipHiddenRows(pDoc, nTab, rRow, false);
             }
         }
     }
@@ -769,7 +740,7 @@ void ScTabView::ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode)
             bSelectUnlocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
         }
 
-        lcl_moveCursorByProtRule(nNewX, nNewY, nMovX, nMovY, nRefTab, pDoc);
+        moveCursorByProtRule(nNewX, nNewY, nMovX, nMovY, nRefTab, pDoc);
 
         if (nMovX)
         {
@@ -781,7 +752,7 @@ void ScTabView::ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode)
                 else
                     --nTempX;
             }
-            if (lcl_isCellQualified(pDoc, nTempX, nNewY, nRefTab, bSelectLocked, bSelectUnlocked))
+            if (isCellQualified(pDoc, nTempX, nNewY, nRefTab, bSelectLocked, bSelectUnlocked))
                 nNewX = nTempX;
         }
 
@@ -795,7 +766,7 @@ void ScTabView::ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode)
                 else
                     --nTempY;
             }
-            if (lcl_isCellQualified(pDoc, nNewX, nTempY, nRefTab, bSelectLocked, bSelectUnlocked))
+            if (isCellQualified(pDoc, nNewX, nTempY, nRefTab, bSelectLocked, bSelectUnlocked))
                 nNewY = nTempY;
         }
 
@@ -812,7 +783,7 @@ void ScTabView::ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode)
         if (!IsBlockMode())
             InitBlockMode(aViewData.GetCurX(), aViewData.GetCurY(), nTab, true);
 
-        lcl_moveCursorByProtRule(nBlockEndX, nBlockEndY, nMovX, nMovY, nTab, pDoc);
+        moveCursorByProtRule(nBlockEndX, nBlockEndY, nMovX, nMovY, nTab, pDoc);
 
         if (nBlockEndX < 0)
             nBlockEndX = 0;
commit 3c9f5bcc67e077448aaade2f0aed597e9afc1326
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Wed Mar 2 21:33:09 2011 -0500

    Better fix for fdo#31939.
    
    Turns out that the token array's recalc mode is set to "recalc always"
    when it contains a volatile token during compilation.  We can re-use
    that to mark the token array volatile before the interpretation starts.
    The end result is the same, with better performance since we can avoid
    re-scanning of the token array.
    
    Signed-off-by: Michael Meeks <michael.meeks at novell.com>

diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index e2eae90..6e5fd10 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -813,13 +813,6 @@ double GetGammaDistPDF(double fX, double fAlpha, double fLambda);
 // cumulative distribution function; fLambda is "scale" parameter
 double GetGammaDist(double fX, double fAlpha, double fLambda);
 
-/**
- * Go through all tokens to see if the array contains a volatile token.  We
- * need to do this since a conditional token such as IF function may skip
- * some tokens and it may incorrectly mark the token array non-volatile.
- */
-void CheckForVolatileToken();
-
 public:
     ScInterpreter( ScFormulaCell* pCell, ScDocument* pDoc,
                     const ScAddress&, ScTokenArray& );
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 6751531..502c62a 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3594,7 +3594,7 @@ ScInterpreter::ScInterpreter( ScFormulaCell* pCell, ScDocument* pDoc,
     pFormatter( pDoc->GetFormatTable() ),
     mnStringNoValueError( errNoValue),
     bCalcAsShown( pDoc->GetDocOptions().IsCalcAsShown() ),
-    meVolaileType(NOT_VOLATILE)
+    meVolaileType(r.IsRecalcModeAlways() ? VOLATILE : NOT_VOLATILE)
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScTTT" );
 //  pStack = new ScToken*[ MAXSTACK ];
@@ -3663,8 +3663,6 @@ StackVar ScInterpreter::Interpret()
     // so reassure exceptions are really off.
     SAL_MATH_FPEXCEPTIONS_OFF();
 
-    CheckForVolatileToken();
-
     aCode.Reset();
     while( ( pCur = aCode.Next() ) != NULL
             && (!nGlobalError || nErrorFunction <= nErrorFunctionCount) )
diff --git a/sc/source/core/tool/interpr7.cxx b/sc/source/core/tool/interpr7.cxx
index c7674d6..ffac3d6 100644
--- a/sc/source/core/tool/interpr7.cxx
+++ b/sc/source/core/tool/interpr7.cxx
@@ -32,18 +32,7 @@
 // INCLUDE ---------------------------------------------------------------
 
 #include "interpre.hxx"
-#include "formula/FormulaCompiler.hxx"
 
-void ScInterpreter::CheckForVolatileToken()
-{
-    for (const formula::FormulaToken* p = aCode.First(); p; p = aCode.Next())
-    {
-        if (formula::FormulaCompiler::IsOpCodeVolatile(p->GetOpCode()))
-        {
-            meVolaileType = VOLATILE;
-            return;
-        }
-    }
-}
+// TODO: Add new methods for ScInterpreter here.
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 2108280e847a78da3cc401dd07dbcfd9bab3e7d1
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Wed Mar 2 20:44:56 2011 -0500

    Go through all tokens to look for a volatile one. (fdo#31939)
    
    When a volatile token is inside a conditional function (such as IF),
    *and* the evaluation of that conditional skips the volatile token
    it would incorrectly mark the cell non-volatile.  The solution is
    to scan through all tokens in the token array in the beginning of
    the calculation and mark the cell volatile if one is found.

diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index f356dbe..e2eae90 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -813,7 +813,13 @@ double GetGammaDistPDF(double fX, double fAlpha, double fLambda);
 // cumulative distribution function; fLambda is "scale" parameter
 double GetGammaDist(double fX, double fAlpha, double fLambda);
 
-//----------------------------------------------------------------------------
+/**
+ * Go through all tokens to see if the array contains a volatile token.  We
+ * need to do this since a conditional token such as IF function may skip
+ * some tokens and it may incorrectly mark the token array non-volatile.
+ */
+void CheckForVolatileToken();
+
 public:
     ScInterpreter( ScFormulaCell* pCell, ScDocument* pDoc,
                     const ScAddress&, ScTokenArray& );
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index a1be445..6751531 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3663,6 +3663,8 @@ StackVar ScInterpreter::Interpret()
     // so reassure exceptions are really off.
     SAL_MATH_FPEXCEPTIONS_OFF();
 
+    CheckForVolatileToken();
+
     aCode.Reset();
     while( ( pCur = aCode.Next() ) != NULL
             && (!nGlobalError || nErrorFunction <= nErrorFunctionCount) )
diff --git a/sc/source/core/tool/interpr7.cxx b/sc/source/core/tool/interpr7.cxx
new file mode 100644
index 0000000..c7674d6
--- /dev/null
+++ b/sc/source/core/tool/interpr7.cxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Kohei Yoshida <kyoshida at novell.com> (Novell, Inc.)
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):  Kohei Yoshida <kyoshida at novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "interpre.hxx"
+#include "formula/FormulaCompiler.hxx"
+
+void ScInterpreter::CheckForVolatileToken()
+{
+    for (const formula::FormulaToken* p = aCode.First(); p; p = aCode.Next())
+    {
+        if (formula::FormulaCompiler::IsOpCodeVolatile(p->GetOpCode()))
+        {
+            meVolaileType = VOLATILE;
+            return;
+        }
+    }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/makefile.mk b/sc/source/core/tool/makefile.mk
index b1cad58..bd241b3 100644
--- a/sc/source/core/tool/makefile.mk
+++ b/sc/source/core/tool/makefile.mk
@@ -82,6 +82,7 @@ SLOFILES =  \
         $(SLO)$/interpr4.obj \
         $(SLO)$/interpr5.obj \
         $(SLO)$/interpr6.obj \
+        $(SLO)$/interpr7.obj \
         $(SLO)$/lookupcache.obj \
         $(SLO)$/navicfg.obj \
         $(SLO)$/odffmap.obj \


More information about the Libreoffice-commits mailing list