[Libreoffice-commits] .: 20 commits - sc/source

Jan Holesovsky kendy at kemper.freedesktop.org
Mon Dec 20 04:19:56 PST 2010


 sc/source/core/tool/compiler.cxx      |   38 +++++++-
 sc/source/filter/excel/exctools.cxx   |   13 ++
 sc/source/filter/inc/otlnbuff.hxx     |    1 
 sc/source/ui/docshell/docfunc.cxx     |    4 
 sc/source/ui/inc/cellmergeoption.hxx  |   46 ++++------
 sc/source/ui/inc/datafdlg.hrc         |    2 
 sc/source/ui/inc/gridwin.hxx          |    1 
 sc/source/ui/inc/tabview.hxx          |    4 
 sc/source/ui/miscdlgs/datafdlg.cxx    |   18 +++-
 sc/source/ui/src/datafdlg.src         |    4 
 sc/source/ui/view/cellmergeoption.cxx |   58 +++++++------
 sc/source/ui/view/gridwin2.cxx        |   16 +++
 sc/source/ui/view/gridwin4.cxx        |  102 ++++++++++-------------
 sc/source/ui/view/tabview.cxx         |   11 ++
 sc/source/ui/view/tabview2.cxx        |  150 ++++++++++++++++++++++++++++++++++
 sc/source/ui/view/tabview3.cxx        |   90 +-------------------
 16 files changed, 355 insertions(+), 203 deletions(-)

New commits:
commit ad40841bd6c32732f86c403a51fd8b2dbb0b3798
Merge: 3f7bde1... f67ffb5...
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Mon Dec 20 13:12:56 2010 +0100

    Merge branch 'master' of ssh://git.freedesktop.org/git/libreoffice/calc

commit 3f7bde145d8ae85e0700b2d75dac36098c9722f0
Merge: d1dd018... a619953...
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Mon Dec 20 01:15:52 2010 +0100

    Merge commit 'libreoffice-3.3.0.2'

commit a619953e638d7579f688674e9f7ce3a1042d5db5
Author: Petr Mladek <pmladek at suse.cz>
Date:   Sat Dec 18 20:35:15 2010 +0100

    Version 3.3.0.2, tag libreoffice-3.3.0.2 (3.3-rc2)
commit c1fe450afdc7234c549de3dfac61a620ff213169
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Dec 13 16:02:21 2010 -0500

    Remove trailing spaces too when parsing csv's simple numbers.

diff --git a/sc/inc/stringutil.hxx b/sc/inc/stringutil.hxx
index dcf6d57..e9a60a5 100644
--- a/sc/inc/stringutil.hxx
+++ b/sc/inc/stringutil.hxx
@@ -77,6 +77,8 @@ public:
      * don't do any elaborate parsing here; we only check for the simplest 
      * case of decimal number format. 
      *
+     * Note that preceding and trailing spaces are ignored during parsing.
+     *
      * @param rStr string to parse
      * @param dsep decimal separator
      * @param gsep group separator (aka thousands separator)
diff --git a/sc/source/core/tool/stringutil.cxx b/sc/source/core/tool/stringutil.cxx
index 83e31f7..1953aae 100644
--- a/sc/source/core/tool/stringutil.cxx
+++ b/sc/source/core/tool/stringutil.cxx
@@ -58,13 +58,14 @@ bool ScStringUtil::parseSimpleNumber(
         gsep = 0x0020;
 
     OUStringBuffer aBuf;
+
+    sal_Int32 i = 0;
     sal_Int32 n = rStr.getLength();
     const sal_Unicode* p = rStr.getStr();
+    const sal_Unicode* pLast = p + (n-1);
     sal_Int32 nPosDSep = -1, nPosGSep = -1;
     sal_uInt32 nDigitCount = 0;
 
-    sal_Int32 i = 0;
-
     // Skip preceding spaces.
     for (i = 0; i < n; ++i, ++p)
     {
@@ -78,7 +79,16 @@ bool ScStringUtil::parseSimpleNumber(
         // the whole string is space.  Fail.
         return false;
 
-    n -= i; // Subtract the length of preceding space.
+    n -= i; // Subtract the length of the preceding spaces.
+
+    // Determine the last non-space character.
+    for (; p != pLast; --pLast, --n)
+    {
+        sal_Unicode c = *pLast;
+        if (c != 0x0020 && c != 0x00A0)
+            // Non space character. Exit.
+            break;
+    }
 
     for (i = 0; i < n; ++i, ++p)
     {
commit d81a90edf1c9e17eaaff77cb00d49051a5a7d151
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Dec 13 20:53:21 2010 +0000

    WaE, shadowed warning

diff --git a/sc/source/core/tool/stringutil.cxx b/sc/source/core/tool/stringutil.cxx
index dbd9306..83e31f7 100644
--- a/sc/source/core/tool/stringutil.cxx
+++ b/sc/source/core/tool/stringutil.cxx
@@ -80,7 +80,7 @@ bool ScStringUtil::parseSimpleNumber(
 
     n -= i; // Subtract the length of preceding space.
 
-    for (sal_Int32 i = 0; i < n; ++i, ++p)
+    for (i = 0; i < n; ++i, ++p)
     {
         sal_Unicode c = *p;
         if (c == 0x00A0)
commit c2e6be18f38240106a3811445d993d35be12a790
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Dec 13 15:37:45 2010 -0500

    We need to reset i to 0 after parsing spaces.

diff --git a/sc/source/core/tool/stringutil.cxx b/sc/source/core/tool/stringutil.cxx
index 136b0be..dbd9306 100644
--- a/sc/source/core/tool/stringutil.cxx
+++ b/sc/source/core/tool/stringutil.cxx
@@ -74,7 +74,13 @@ bool ScStringUtil::parseSimpleNumber(
             break;
     }
 
-    for (; i < n; ++i, ++p)
+    if (i == n)
+        // the whole string is space.  Fail.
+        return false;
+
+    n -= i; // Subtract the length of preceding space.
+
+    for (sal_Int32 i = 0; i < n; ++i, ++p)
     {
         sal_Unicode c = *p;
         if (c == 0x00A0)
commit 6a28e8397ae7a913dc7af1d2bcb3590ce975c1ac
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Dec 13 15:17:30 2010 -0500

    The previous commit would skip *all* spaces.  This is the right fix.

diff --git a/sc/source/core/tool/stringutil.cxx b/sc/source/core/tool/stringutil.cxx
index 31efe6a..136b0be 100644
--- a/sc/source/core/tool/stringutil.cxx
+++ b/sc/source/core/tool/stringutil.cxx
@@ -63,17 +63,24 @@ bool ScStringUtil::parseSimpleNumber(
     sal_Int32 nPosDSep = -1, nPosGSep = -1;
     sal_uInt32 nDigitCount = 0;
 
-    for (sal_Int32 i = 0; i < n; ++i, ++p)
+    sal_Int32 i = 0;
+
+    // Skip preceding spaces.
+    for (i = 0; i < n; ++i, ++p)
+    {
+        sal_Unicode c = *p;
+        if (c != 0x0020 && c != 0x00A0)
+            // first non-space character.  Exit.
+            break;
+    }
+
+    for (; i < n; ++i, ++p)
     {
         sal_Unicode c = *p;
         if (c == 0x00A0)
             // unicode space to ascii space
             c = 0x0020;
 
-        if (c == 0x0020)
-            // Skip preceding spaces.
-            continue;
-
         if (sal_Unicode('0') <= c && c <= sal_Unicode('9'))
         {
             // this is a digit.
commit 15254fc821d2bbed205e814c689b19cafaf1eb8a
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Dec 13 14:55:13 2010 -0500

    When parsing numbers, ignore preceding spaces.
    
    Also, increment the char pointer and use it directly, which is
    faster than accessing char via [] in each iteration.

diff --git a/sc/source/core/tool/stringutil.cxx b/sc/source/core/tool/stringutil.cxx
index ae73746..31efe6a 100644
--- a/sc/source/core/tool/stringutil.cxx
+++ b/sc/source/core/tool/stringutil.cxx
@@ -63,13 +63,17 @@ bool ScStringUtil::parseSimpleNumber(
     sal_Int32 nPosDSep = -1, nPosGSep = -1;
     sal_uInt32 nDigitCount = 0;
 
-    for (sal_Int32 i = 0; i < n; ++i)
+    for (sal_Int32 i = 0; i < n; ++i, ++p)
     {
-        sal_Unicode c = p[i];
+        sal_Unicode c = *p;
         if (c == 0x00A0)
             // unicode space to ascii space
             c = 0x0020;
 
+        if (c == 0x0020)
+            // Skip preceding spaces.
+            continue;
+
         if (sal_Unicode('0') <= c && c <= sal_Unicode('9'))
         {
             // this is a digit.
commit a0bdbcf6481ab9176a7c763284991887d00161ff
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Dec 7 23:02:02 2010 -0500

    Make the string 'New Record' localizable. (fdo#32209)
    
    This string was hard-coded in the code to be always in English.  This
    change makes it localizable.
    
    Signed-off-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/source/ui/inc/datafdlg.hrc b/sc/source/ui/inc/datafdlg.hrc
index eb6b3fe..b32e0a9 100644
--- a/sc/source/ui/inc/datafdlg.hrc
+++ b/sc/source/ui/inc/datafdlg.hrc
@@ -38,3 +38,5 @@
 
 #define FT_DATAFORM_FIXEDTEXT1    2001
 #define ED_DATAFORM_EDIT1         2002
+
+#define STR_NEW_RECORD            2003
diff --git a/sc/source/ui/miscdlgs/datafdlg.cxx b/sc/source/ui/miscdlgs/datafdlg.cxx
index 50503e2..3e859e9 100644
--- a/sc/source/ui/miscdlgs/datafdlg.cxx
+++ b/sc/source/ui/miscdlgs/datafdlg.cxx
@@ -286,7 +286,7 @@ void ScDataFormDlg::FillCtrls(SCROW /*nCurrentRow*/)
         aFixedText.SetText(aBuf.makeStringAndClear());
     }
     else
-        aFixedText.SetText(String::CreateFromAscii("New Record"));
+        aFixedText.SetText(String(ScResId(STR_NEW_RECORD)));
 
     aSlider.SetThumbPos(aCurrentRow-nStartRow-1);
 }
diff --git a/sc/source/ui/src/datafdlg.src b/sc/source/ui/src/datafdlg.src
index 2c07a70..1cb3578 100644
--- a/sc/source/ui/src/datafdlg.src
+++ b/sc/source/ui/src/datafdlg.src
@@ -91,5 +91,9 @@ ModalDialog RID_SCDLG_DATAFORM
         HScroll = FALSE ;
         TabStop = FALSE ;
     };
+    String STR_NEW_RECORD
+    {
+        Text [ en-US ] = "New Record" ;
+    };
 };
 //end
commit 9e338f0677ab068e1bf792db11123b646938edbc
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Dec 7 17:06:16 2010 -0500

    Display correct record information in Data Form dialog. (fdo#32196)
    
    I had accidentally removed the part that constructed correct string
    to display.  Recovered it, and modified it to use OUStringBuffer
    instead of sprintf to construct the string.
    
    Signed-off-by: Norbert Thiebaud <nthiebaud at gmail.com>

diff --git a/sc/source/ui/miscdlgs/datafdlg.cxx b/sc/source/ui/miscdlgs/datafdlg.cxx
index 377213f..50503e2 100644
--- a/sc/source/ui/miscdlgs/datafdlg.cxx
+++ b/sc/source/ui/miscdlgs/datafdlg.cxx
@@ -42,8 +42,12 @@
 #include "refundo.hxx"
 #include "undodat.hxx"
 
+#include "rtl/ustrbuf.hxx"
+
 #define HDL(hdl)            LINK( this, ScDataFormDlg, hdl )
 
+using ::rtl::OUStringBuffer;
+
 //zhangyun
 ScDataFormDlg::ScDataFormDlg( Window* pParent, ScTabViewShell*  pTabViewShellOri) :
     ModalDialog     ( pParent, ScResId( RID_SCDLG_DATAFORM ) ),
@@ -272,9 +276,15 @@ void ScDataFormDlg::FillCtrls(SCROW /*nCurrentRow*/)
                 pEdits[i]->SetText(String());
         }
     }
-    char sRecordStr[256];
-    if (aCurrentRow<=nEndRow)
-        aFixedText.SetText(String::CreateFromAscii(sRecordStr));
+
+    if (aCurrentRow <= nEndRow)
+    {
+        OUStringBuffer aBuf;
+        aBuf.append(static_cast<sal_Int32>(aCurrentRow - nStartRow));
+        aBuf.appendAscii(" / ");
+        aBuf.append(static_cast<sal_Int32>(nEndRow - nStartRow));
+        aFixedText.SetText(aBuf.makeStringAndClear());
+    }
     else
         aFixedText.SetText(String::CreateFromAscii("New Record"));
 
commit 7dc09f19bc5c182ebabb52482db10f828882aad0
Author: Petr Mladek <pmladek at suse.cz>
Date:   Wed Dec 1 15:55:50 2010 +0100

    Version 3.3.0.1, tag LIBREOFFICE_3_3_0_1 (3.3-rc1)
commit c10648b5aa8b023b6ec3508e8f593c03fb782340
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Nov 30 14:10:25 2010 -0500

    Changed header license for new files from ooo-build.

diff --git a/sc/source/ui/inc/cellmergeoption.hxx b/sc/source/ui/inc/cellmergeoption.hxx
index 01fa0eb..ad5fe34 100644
--- a/sc/source/ui/inc/cellmergeoption.hxx
+++ b/sc/source/ui/inc/cellmergeoption.hxx
@@ -1,33 +1,30 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2010 by Novell, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: docfunc.hxx,v $
- * $Revision: 1.18.30.2 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org.  If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
+/*
+ * 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> ]
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * 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.
+ */
 
 #ifndef SC_CELLMERGEOPTION_HXX
 #define SC_CELLMERGEOPTION_HXX
diff --git a/sc/source/ui/view/cellmergeoption.cxx b/sc/source/ui/view/cellmergeoption.cxx
index 2352f07..61f2d8b 100644
--- a/sc/source/ui/view/cellmergeoption.cxx
+++ b/sc/source/ui/view/cellmergeoption.cxx
@@ -1,33 +1,30 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
  *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 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/
  *
- * Copyright 2010 by Novell, Inc.
+ * 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.
  *
- * OpenOffice.org - a multi-platform office productivity suite
+ * The Initial Developer of the Original Code is
+ *       [ Kohei Yoshida <kyoshida at novell.com> ]
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
  *
- * $RCSfile: docfunc.hxx,v $
- * $Revision: 1.18.30.2 $
+ * Contributor(s): 
  *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org.  If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
+ * 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.
+ */
 
 #include "cellmergeoption.hxx"
 #include "address.hxx"
commit 6683ad4daa97331d1ce06136421cd8ec56190b24
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Nov 30 13:55:00 2010 -0500

    Don't forget to store sheet index of merged cell range to be re-merged.
    
    This fixes fdo#31805.

diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index be84aa5..abe1c58 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -2200,9 +2200,7 @@ BOOL ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
 
         if( !pDoc->HasAttrib( aRange, HASATTR_OVERLAPPED | HASATTR_MERGED ) )
         {
-            ScCellMergeOption aMergeOption(
-                aRange.aStart.Col(), aRange.aStart.Row(),
-                aRange.aEnd.Col(), aRange.aEnd.Row() );
+            ScCellMergeOption aMergeOption(aRange);
             MergeCells( aMergeOption, FALSE, TRUE, TRUE );
         }
         qDecreaseRange.pop_back();
diff --git a/sc/source/ui/inc/cellmergeoption.hxx b/sc/source/ui/inc/cellmergeoption.hxx
index 86e2416..01fa0eb 100644
--- a/sc/source/ui/inc/cellmergeoption.hxx
+++ b/sc/source/ui/inc/cellmergeoption.hxx
@@ -48,6 +48,7 @@ struct ScCellMergeOption
     bool mbCenter;
 
     explicit ScCellMergeOption();
+    explicit ScCellMergeOption(const ScRange& rRange);
     explicit ScCellMergeOption(SCCOL nStartCol, SCROW nStartRow,
                                SCCOL nEndCol, SCROW nEndRow,
                                bool bCenter = false);
diff --git a/sc/source/ui/view/cellmergeoption.cxx b/sc/source/ui/view/cellmergeoption.cxx
index ff5220e..2352f07 100644
--- a/sc/source/ui/view/cellmergeoption.cxx
+++ b/sc/source/ui/view/cellmergeoption.cxx
@@ -41,6 +41,19 @@ ScCellMergeOption::ScCellMergeOption() :
 {
 }
 
+ScCellMergeOption::ScCellMergeOption(const ScRange& rRange) :
+    mnStartCol(rRange.aStart.Col()),
+    mnStartRow(rRange.aStart.Row()),
+    mnEndCol(rRange.aEnd.Col()),
+    mnEndRow(rRange.aEnd.Row()),
+    mbCenter(false)
+{
+    SCTAB nTab1 = rRange.aStart.Tab();
+    SCTAB nTab2 = rRange.aEnd.Tab();
+    for (SCTAB i = nTab1; i <= nTab2; ++i)
+        maTabs.insert(i);
+}
+
 ScCellMergeOption::ScCellMergeOption(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool bCenter) :
     mnStartCol(nStartCol),
     mnStartRow(nStartRow),
commit 04608abcf80b8182509a9fc8b5f0d8088c47e045
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Nov 30 00:54:06 2010 -0500

    Skip hidden cells while expanding range selection.
    
    This commit happily fixes fdo#31796.

diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index b53b3d7..e459c93 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -201,8 +201,8 @@ private:
     void            GetAreaMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
                                            SCsCOL& rAreaX, SCsROW& rAreaY, ScFollowMode& rMode);
 
-    void            SkipCursorHorizontal(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nOldY, SCsROW nMovX);
-    void            SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nOldY, SCsROW nMovY);
+    void            SkipCursorHorizontal(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nMovX);
+    void            SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsROW nOldY, SCsROW nMovY);
 
 protected:
     void			UpdateHeaderWidth( const ScVSplitPos* pWhich = NULL,
diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index d875ca7..a42cb46 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -504,7 +504,7 @@ void ScTabView::GetAreaMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, ScFollowMode
     rMode = eMode;
 }
 
-void ScTabView::SkipCursorHorizontal(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nOldY, SCsROW nMovX)
+void ScTabView::SkipCursorHorizontal(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nMovX)
 {
     ScDocument* pDoc = aViewData.GetDocument();
     SCTAB nTab = aViewData.GetTabNo();
@@ -564,7 +564,7 @@ void ScTabView::SkipCursorHorizontal(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX,
     }
 }
 
-void ScTabView::SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nOldY, SCsROW nMovY)
+void ScTabView::SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsROW nOldY, SCsROW nMovY)
 {
     ScDocument* pDoc = aViewData.GetDocument();
     SCTAB nTab = aViewData.GetTabNo();
@@ -640,6 +640,32 @@ 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(
     SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY, SCTAB nTab, ScDocument* pDoc)
 {
@@ -661,6 +687,7 @@ void lcl_moveCursorByProtRule(
                 if (!lcl_isCellQualified(pDoc, rCol+1, rRow, nTab, bSelectLocked, bSelectUnlocked))
                     break;
                 ++rCol;
+                skipHiddenCols(pDoc, nTab, rCol, true);
             }
         }
     }
@@ -674,6 +701,7 @@ void lcl_moveCursorByProtRule(
                 if (!lcl_isCellQualified(pDoc, rCol-1, rRow, nTab, bSelectLocked, bSelectUnlocked))
                     break;
                 --rCol;
+                skipHiddenCols(pDoc, nTab, rCol, false);
             }
         }
     }
@@ -687,6 +715,7 @@ void lcl_moveCursorByProtRule(
                 if (!lcl_isCellQualified(pDoc, rCol, rRow+1, nTab, bSelectLocked, bSelectUnlocked))
                     break;
                 ++rRow;
+                skipHiddenRows(pDoc, nTab, rRow, true);
             }
         }
     }
@@ -700,6 +729,7 @@ void lcl_moveCursorByProtRule(
                 if (!lcl_isCellQualified(pDoc, rCol, rRow-1, nTab, bSelectLocked, bSelectUnlocked))
                     break;
                 --rRow;
+                skipHiddenRows(pDoc, nTab, rRow, false);
             }
         }
     }
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 8ca6279..d5a6f41 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -984,10 +984,10 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
     aViewData.ResetOldCursor();
 
     if (nMovX != 0 && VALIDCOLROW(nCurX,nCurY))
-        SkipCursorHorizontal(nCurX, nCurY, nOldX, nOldY, nMovX);
+        SkipCursorHorizontal(nCurX, nCurY, nOldX, nMovX);
 
     if (nMovY != 0 && VALIDCOLROW(nCurX,nCurY))
-        SkipCursorVertical(nCurX, nCurY, nOldX, nOldY, nMovY);
+        SkipCursorVertical(nCurX, nCurY, nOldY, nMovY);
 
     MoveCursorAbs( nCurX, nCurY, eMode, bShift, FALSE, TRUE, bKeepSel );
 }
commit 9938610417b58421ec07386406e0604815c77eaa
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Nov 29 22:27:55 2010 -0500

    Extracted methods that may be used in another place.

diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index 365af2c..b53b3d7 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -201,6 +201,9 @@ private:
     void            GetAreaMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
                                            SCsCOL& rAreaX, SCsROW& rAreaY, ScFollowMode& rMode);
 
+    void            SkipCursorHorizontal(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nOldY, SCsROW nMovX);
+    void            SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nOldY, SCsROW nMovY);
+
 protected:
     void			UpdateHeaderWidth( const ScVSplitPos* pWhich = NULL,
                                         const SCROW* pPosY = NULL );
diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index 6b7671b..d875ca7 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -504,6 +504,126 @@ void ScTabView::GetAreaMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, ScFollowMode
     rMode = eMode;
 }
 
+void ScTabView::SkipCursorHorizontal(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nOldY, SCsROW nMovX)
+{
+    ScDocument* pDoc = aViewData.GetDocument();
+    SCTAB nTab = aViewData.GetTabNo();
+
+    bool bSkipProtected = false, bSkipUnprotected = false;
+    ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+    if (pProtect && pProtect->isProtected())
+    {
+        bSkipProtected   = !pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
+        bSkipUnprotected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
+    }
+
+    bool bSkipCell = false;
+    bool bHFlip = false;
+    do
+    {
+        SCCOL nLastCol = -1;
+        bSkipCell = pDoc->ColHidden(rCurX, nTab, nLastCol) || pDoc->IsHorOverlapped(rCurX, rCurY, nTab);
+        if (bSkipProtected && !bSkipCell)
+            bSkipCell = pDoc->HasAttrib(rCurX, rCurY, nTab, rCurX, rCurY, nTab, HASATTR_PROTECTED);
+        if (bSkipUnprotected && !bSkipCell)
+            bSkipCell = !pDoc->HasAttrib(rCurX, rCurY, nTab, rCurX, rCurY, nTab, HASATTR_PROTECTED);
+
+        if (bSkipCell)
+        {
+            if (rCurX <= 0 || rCurX >= MAXCOL)
+            {
+                if (bHFlip)
+                {
+                    rCurX = nOldX;
+                    bSkipCell = false;
+                }
+                else
+                {
+                    nMovX = -nMovX;
+                    if (nMovX > 0)
+                        ++rCurX;
+                    else
+                        --rCurX;
+                    bHFlip = true;
+                }
+            }
+            else
+                if (nMovX > 0)
+                    ++rCurX;
+                else
+                    --rCurX;
+        }
+    }
+    while (bSkipCell);
+
+    if (pDoc->IsVerOverlapped(rCurX, rCurY, nTab))
+    {
+        aViewData.SetOldCursor(rCurX, rCurY);
+        while (pDoc->IsVerOverlapped(rCurX, rCurY, nTab))
+            --rCurY;
+    }
+}
+
+void ScTabView::SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nOldY, SCsROW nMovY)
+{
+    ScDocument* pDoc = aViewData.GetDocument();
+    SCTAB nTab = aViewData.GetTabNo();
+
+    bool bSkipProtected = false, bSkipUnprotected = false;
+    ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+    if (pProtect && pProtect->isProtected())
+    {
+        bSkipProtected   = !pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
+        bSkipUnprotected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
+    }
+
+    bool bSkipCell = false;
+    bool bVFlip = false;
+    do
+    {
+        SCROW nLastRow = -1;
+        bSkipCell = pDoc->RowHidden(rCurY, nTab, nLastRow) || pDoc->IsVerOverlapped( rCurX, rCurY, nTab );
+        if (bSkipProtected && !bSkipCell)
+            bSkipCell = pDoc->HasAttrib(rCurX, rCurY, nTab, rCurX, rCurY, nTab, HASATTR_PROTECTED);
+        if (bSkipUnprotected && !bSkipCell)
+            bSkipCell = !pDoc->HasAttrib(rCurX, rCurY, nTab, rCurX, rCurY, nTab, HASATTR_PROTECTED);
+
+        if (bSkipCell)
+        {
+            if (rCurY <= 0 || rCurY >= MAXROW)
+            {
+                if (bVFlip)
+                {
+                    rCurY = nOldY;
+                    bSkipCell = false;
+                }
+                else
+                {
+                    nMovY = -nMovY;
+                    if (nMovY > 0)
+                        ++rCurY;
+                    else
+                        --rCurY;
+                    bVFlip = true;
+                }
+            }
+            else
+                if (nMovY > 0)
+                    ++rCurY;
+                else
+                    --rCurY;
+        }
+    }
+    while (bSkipCell);
+
+    if (pDoc->IsHorOverlapped(rCurX, rCurY, nTab))
+    {
+        aViewData.SetOldCursor(rCurX, rCurY);
+        while (pDoc->IsHorOverlapped(rCurX, rCurY, nTab))
+            --rCurX;
+    }
+}
+
 namespace {
 
 bool lcl_isCellQualified(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, bool bSelectLocked, bool bSelectUnlocked)
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index fdccb1a..8ca6279 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -984,88 +984,10 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
     aViewData.ResetOldCursor();
 
     if (nMovX != 0 && VALIDCOLROW(nCurX,nCurY))
-    {
-        BOOL bHFlip = FALSE;
-        do
-        {
-            SCCOL nLastCol = -1;
-            bSkipCell = pDoc->ColHidden(nCurX, nTab, nLastCol) || pDoc->IsHorOverlapped( nCurX, nCurY, nTab );
-            if (bSkipProtected && !bSkipCell)
-                bSkipCell = pDoc->HasAttrib(nCurX, nCurY, nTab, nCurX, nCurY, nTab, HASATTR_PROTECTED);
-            if (bSkipUnprotected && !bSkipCell)
-                bSkipCell = !pDoc->HasAttrib(nCurX, nCurY, nTab, nCurX, nCurY, nTab, HASATTR_PROTECTED);
-
-            if (bSkipCell)
-            {
-                if ( nCurX<=0 || nCurX>=MAXCOL )
-                {
-                    if (bHFlip)
-                    {
-                        nCurX = nOldX;
-                        bSkipCell = FALSE;
-                    }
-                    else
-                    {
-                        nMovX = -nMovX;
-                        if (nMovX > 0) ++nCurX; else --nCurX;		// zuruecknehmen
-                        bHFlip = TRUE;
-                    }
-                }
-                else
-                    if (nMovX > 0) ++nCurX; else --nCurX;
-            }
-        }
-        while (bSkipCell);
-
-        if (pDoc->IsVerOverlapped( nCurX, nCurY, nTab ))
-        {
-            aViewData.SetOldCursor( nCurX,nCurY );
-            while (pDoc->IsVerOverlapped( nCurX, nCurY, nTab ))
-                --nCurY;
-        }
-    }
+        SkipCursorHorizontal(nCurX, nCurY, nOldX, nOldY, nMovX);
 
     if (nMovY != 0 && VALIDCOLROW(nCurX,nCurY))
-    {
-        BOOL bVFlip = FALSE;
-        do
-        {
-            SCROW nLastRow = -1;
-            bSkipCell = pDoc->RowHidden(nCurY, nTab, nLastRow) || pDoc->IsVerOverlapped( nCurX, nCurY, nTab );
-            if (bSkipProtected && !bSkipCell)
-                bSkipCell = pDoc->HasAttrib(nCurX, nCurY, nTab, nCurX, nCurY, nTab, HASATTR_PROTECTED);
-            if (bSkipUnprotected && !bSkipCell)
-                bSkipCell = !pDoc->HasAttrib(nCurX, nCurY, nTab, nCurX, nCurY, nTab, HASATTR_PROTECTED);
-
-            if (bSkipCell)
-            {
-                if ( nCurY<=0 || nCurY>=MAXROW )
-                {
-                    if (bVFlip)
-                    {
-                        nCurY = nOldY;
-                        bSkipCell = FALSE;
-                    }
-                    else
-                    {
-                        nMovY = -nMovY;
-                        if (nMovY > 0) ++nCurY; else --nCurY;		// zuruecknehmen
-                        bVFlip = TRUE;
-                    }
-                }
-                else
-                    if (nMovY > 0) ++nCurY; else --nCurY;
-            }
-        }
-        while (bSkipCell);
-
-        if (pDoc->IsHorOverlapped( nCurX, nCurY, nTab ))
-        {
-            aViewData.SetOldCursor( nCurX,nCurY );
-            while (pDoc->IsHorOverlapped( nCurX, nCurY, nTab ))
-                --nCurX;
-        }
-    }
+        SkipCursorVertical(nCurX, nCurY, nOldX, nOldY, nMovY);
 
     MoveCursorAbs( nCurX, nCurY, eMode, bShift, FALSE, TRUE, bKeepSel );
 }
commit cbdf7c36bd1128757d4e30d52976717d4ca67b8d
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Nov 29 20:36:22 2010 -0500

    Removed unused code.

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index f995cb2..fb5158a 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -596,12 +596,6 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
             aOutputData.SetEditCell( nEditCol, nEditRow );
         else
             bEditMode = FALSE;
-
-        //  nur Edit-Area zu zeichnen?
-        //! dann muss trotzdem noch der Rand / das Gitter gemalt werden!
-
-//      if ( nEditCol <= nX1 && nEditEndCol >= nX2 && nEditRow <= nY1 && nEditEndRow >= nY2 )
-//          bOnlyEdit = TRUE;
     }
 
     // define drawing layer map mode and paint rectangle
commit d8e814b2b0966efb1cc40223bd0025c96b1d825e
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Nov 29 19:54:35 2010 -0500

    Don't update visible ranges for invisible panes.

diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 7420db5..d465f80 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -1695,7 +1695,7 @@ void ScTabView::UpdateVisibleRange()
 {
     for (int i = 0; i < 4; ++i)
     {
-        if (!pGridWin[i])
+        if (!pGridWin[i] || !pGridWin[i]->IsVisible())
             continue;
 
         pGridWin[i]->UpdateVisibleRange();
commit 052488532d2237ea12a6cfd72d6e38350e5ae122
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Nov 29 19:20:22 2010 -0500

    Re-calculate visible range when switching sheets.
    
    Visible range of the current sheet is used to decide whether or not
    to render cell cursor.  Failing to do that was causing the cursor
    to disappear when switching sheets while the cursor on the current
    sheet was invisible. (fdo#31753)

diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index a2e6637..4bd6ced 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -394,6 +394,7 @@ public:
     void			CheckNeedsRepaint();
 
     void            UpdateDPFromFieldPopupMenu();
+    void            UpdateVisibleRange();
 
     // #114409#
     void CursorChanged();
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index 7cde207..365af2c 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -210,6 +210,7 @@ protected:
 
     void			ZoomChanged();
     void			UpdateShow();
+    void            UpdateVisibleRange();
     void			GetBorderSize( SvBorder& rBorder, const Size& rSize );
 
     void			ResetDrawDragMode();
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index 6f9f306..ccacee3 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -594,6 +594,22 @@ void ScGridWindow::UpdateDPFromFieldPopupMenu()
     aFunc.DataPilotUpdate(pDPObj, &aNewDPObj, true, false);
 }
 
+void ScGridWindow::UpdateVisibleRange()
+{
+    SCCOL nPosX = pViewData->GetPosX(eHWhich);
+    SCROW nPosY = pViewData->GetPosY(eVWhich);
+    SCCOL nXRight = nPosX + pViewData->VisibleCellsX(eHWhich);
+    if (nXRight > MAXCOL) nXRight = MAXCOL;
+    SCROW nYBottom = nPosY + pViewData->VisibleCellsY(eVWhich);
+    if (nYBottom > MAXROW) nYBottom = MAXROW;
+
+    // Store the current visible range.
+    maVisibleRange.mnCol1 = nPosX;
+    maVisibleRange.mnCol2 = nXRight;
+    maVisibleRange.mnRow1 = nPosY;
+    maVisibleRange.mnRow2 = nYBottom;
+}
+
 void ScGridWindow::DPMouseMove( const MouseEvent& rMEvt )
 {
     DPTestMouse( rMEvt, TRUE );
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index e4760fb..f995cb2 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -422,7 +422,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
 {
     ScModule* pScMod = SC_MOD();
     BOOL bTextWysiwyg = pScMod->GetInputOptions().GetTextWysiwyg();
-    BOOL bGridFirst = TRUE;		//! entscheiden!!!
+    BOOL bGridFirst = TRUE;     //! entscheiden!!!
 
     if (pViewData->IsMinimized())
         return;
@@ -432,36 +432,30 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
 
     DBG_ASSERT( ValidCol(nX2) && ValidRow(nY2), "GridWin Draw Bereich zu gross" );
 
-    SCCOL nPosX = pViewData->GetPosX( eHWhich );
-    SCROW nPosY = pViewData->GetPosY( eVWhich );
-    if (nX2 < nPosX || nY2 < nPosY)
-        return;											// unsichtbar
-    if (nX1 < nPosX) nX1 = nPosX;
-    if (nY1 < nPosY) nY1 = nPosY;
+    UpdateVisibleRange();
 
-    SCCOL nXRight = nPosX + pViewData->VisibleCellsX(eHWhich);
-    if (nXRight > MAXCOL) nXRight = MAXCOL;
-    SCROW nYBottom = nPosY + pViewData->VisibleCellsY(eVWhich);
-    if (nYBottom > MAXROW) nYBottom = MAXROW;
+    if (nX2 < maVisibleRange.mnCol1 || nY2 < maVisibleRange.mnRow1)
+        return;
+                    // unsichtbar
+    if (nX1 < maVisibleRange.mnCol1)
+        nX1 = maVisibleRange.mnCol1;
+    if (nY1 < maVisibleRange.mnRow1)
+        nY1 = maVisibleRange.mnRow1;
 
-    // Store the current visible range.
-    maVisibleRange.mnCol1 = nPosX;
-    maVisibleRange.mnCol2 = nXRight;
-    maVisibleRange.mnRow1 = nPosY;
-    maVisibleRange.mnRow2 = nYBottom;
+    if (nX1 > maVisibleRange.mnCol2 || nY1 > maVisibleRange.mnRow2)
+        return;
 
-    if (nX1 > nXRight || nY1 > nYBottom)
-        return;											// unsichtbar
-    if (nX2 > nXRight) nX2 = nXRight;
-    if (nY2 > nYBottom) nY2 = nYBottom;
+    if (nX2 > maVisibleRange.mnCol2)
+        nX2 = maVisibleRange.mnCol2;
+    if (nY2 > maVisibleRange.mnRow2)
+        nY2 = maVisibleRange.mnRow2;
 
-    if ( eMode != SC_UPDATE_MARKS )
-        if (nX2 < nXRight)
-            nX2 = nXRight;								// zum Weiterzeichnen
+    if ( eMode != SC_UPDATE_MARKS && nX2 < maVisibleRange.mnCol2)
+        nX2 = maVisibleRange.mnCol2;                                // zum Weiterzeichnen
 
-        //	ab hier kein return mehr
+        //  ab hier kein return mehr
 
-    ++nPaintCount;					// merken, dass gemalt wird (wichtig beim Invertieren)
+    ++nPaintCount;                  // merken, dass gemalt wird (wichtig beim Invertieren)
 
     ScDocShell* pDocSh = pViewData->GetDocShell();
     ScDocument* pDoc = pDocSh->GetDocument();
@@ -475,7 +469,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
     long nLayoutSign = bLayoutRTL ? -1 : 1;
     if ( bLayoutRTL )
     {
-        long nEndPixel = pViewData->GetScrPos( nX2+1, nPosY, eWhich ).X();
+        long nEndPixel = pViewData->GetScrPos( nX2+1, maVisibleRange.mnRow1, eWhich ).X();
         nMirrorWidth = aScrPos.X() - nEndPixel;
         aScrPos.X() = nEndPixel + 1;
     }
@@ -491,7 +485,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
     BOOL bCurVis = nCursorHideCount==0 &&
                     ( nCurEndX+1 >= nX1 && nCurX <= nX2+1 && nCurEndY+1 >= nY1 && nCurY <= nY2+1 );
 
-    //	AutoFill-Anfasser
+    //  AutoFill-Anfasser
     if ( !bCurVis && nCursorHideCount==0 && bAutoMarkVisible && aAutoMarkPos.Tab() == nTab &&
             ( aAutoMarkPos.Col() != nCurX || aAutoMarkPos.Row() != nCurY ) )
     {
@@ -499,9 +493,9 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
         SCROW nHdlY = aAutoMarkPos.Row();
         pDoc->ExtendMerge( nHdlX, nHdlY, nHdlX, nHdlY, nTab );
         bCurVis = ( nHdlX+1 >= nX1 && nHdlX <= nX2 && nHdlY+1 >= nY1 && nHdlY <= nY2 );
-        //	links und oben ist nicht betroffen
+        //  links und oben ist nicht betroffen
 
-        //!	AutoFill-Anfasser alleine (ohne Cursor) zeichnen ???
+        //! AutoFill-Anfasser alleine (ohne Cursor) zeichnen ???
     }
 
     double nPPTX = pViewData->GetPPTX();
@@ -526,14 +520,14 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
                                 nScrX, nScrY, nX1, nY1, nX2, nY2, nPPTX, nPPTY,
                                 &aZoomX, &aZoomY );
 
-    aOutputData.SetMirrorWidth( nMirrorWidth );			// needed for RTL
+    aOutputData.SetMirrorWidth( nMirrorWidth );         // needed for RTL
 
     std::auto_ptr< VirtualDevice > xFmtVirtDev;
     BOOL bLogicText = bTextWysiwyg;                     // call DrawStrings in logic MapMode?
 
     if ( bTextWysiwyg )
     {
-        //	use printer for text formatting
+        //  use printer for text formatting
 
         OutputDevice* pFmtDev = pDoc->GetPrinter();
         pFmtDev->SetMapMode( pViewData->GetLogicMode(eWhich) );
@@ -555,18 +549,18 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
     Color aGridColor( rColorCfg.GetColorValue( svtools::CALCGRID, FALSE ).nColor );
     if ( aGridColor.GetColor() == COL_TRANSPARENT )
     {
-        //	use view options' grid color only if color config has "automatic" color
+        //  use view options' grid color only if color config has "automatic" color
         aGridColor = rOpts.GetGridColor();
     }
 
-    aOutputData.SetSyntaxMode		( pViewData->IsSyntaxMode() );
-    aOutputData.SetGridColor		( aGridColor );
-    aOutputData.SetShowNullValues	( rOpts.GetOption( VOPT_NULLVALS ) );
-    aOutputData.SetShowFormulas		( bFormulaMode );
+    aOutputData.SetSyntaxMode       ( pViewData->IsSyntaxMode() );
+    aOutputData.SetGridColor        ( aGridColor );
+    aOutputData.SetShowNullValues   ( rOpts.GetOption( VOPT_NULLVALS ) );
+    aOutputData.SetShowFormulas     ( bFormulaMode );
     aOutputData.SetShowSpellErrors  ( pDoc->GetDocOptions().IsAutoSpell() );
-    aOutputData.SetMarkClipped		( bMarkClipped );
+    aOutputData.SetMarkClipped      ( bMarkClipped );
 
-    aOutputData.SetUseStyleColor( TRUE );		// always set in table view
+    aOutputData.SetUseStyleColor( TRUE );       // always set in table view
 
     aOutputData.SetEditObject( GetEditObject() );
     aOutputData.SetViewShell( pViewData->GetViewShell() );
@@ -582,14 +576,14 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
     }
 
     BOOL bPageMode = pViewData->IsPagebreakMode();
-    if (bPageMode)										// nach FindChanged
+    if (bPageMode)                                      // nach FindChanged
     {
         // SetPagebreakMode initialisiert auch bPrinted Flags
         aOutputData.SetPagebreakMode( pViewData->GetView()->GetPageBreakData() );
     }
 
-    EditView*	pEditView = NULL;
-    BOOL		bEditMode = pViewData->HasEditView(eWhich);
+    EditView*   pEditView = NULL;
+    BOOL        bEditMode = pViewData->HasEditView(eWhich);
     if ( bEditMode && pViewData->GetRefTabNo() == nTab )
     {
         SCCOL nEditCol;
@@ -603,11 +597,11 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
         else
             bEditMode = FALSE;
 
-        //	nur Edit-Area zu zeichnen?
-        //!	dann muss trotzdem noch der Rand / das Gitter gemalt werden!
+        //  nur Edit-Area zu zeichnen?
+        //! dann muss trotzdem noch der Rand / das Gitter gemalt werden!
 
-//		if ( nEditCol <= nX1 && nEditEndCol >= nX2 && nEditRow <= nY1 && nEditEndRow >= nY2 )
-//			bOnlyEdit = TRUE;
+//      if ( nEditCol <= nX1 && nEditEndCol >= nX2 && nEditRow <= nY1 && nEditEndRow >= nY2 )
+//          bOnlyEdit = TRUE;
     }
 
     // define drawing layer map mode and paint rectangle
@@ -642,7 +636,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
     }
 
     OutputDevice* pContentDev = this;       // device for document content, used by overlay manager
-    SdrPaintWindow* pTargetPaintWindow = 0;	// #i74769# work with SdrPaintWindow directly
+    SdrPaintWindow* pTargetPaintWindow = 0; // #i74769# work with SdrPaintWindow directly
 
     {
         // init redraw
@@ -671,7 +665,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
         }
     }
 
-    //	Rand (Wiese) (Pixel)
+    //  Rand (Wiese) (Pixel)
     if ( nX2==MAXCOL || nY2==MAXROW )
     {
         // save MapMode and set to pixel
@@ -741,7 +735,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
     aOutputData.DrawShadow();
     aOutputData.DrawFrame();
     if ( !bLogicText )
-        aOutputData.DrawStrings(FALSE);		// in pixel MapMode
+        aOutputData.DrawStrings(FALSE);     // in pixel MapMode
 
     // edit cells and printer-metrics text must be before the buttons
     // (DataPilot buttons contain labels in UI font)
@@ -767,10 +761,10 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
     }
     aOutputData.DrawClipMarks();
 
-    //	Szenario / ChangeTracking muss auf jeden Fall nach DrawGrid sein, auch bei !bGridFirst
+    //  Szenario / ChangeTracking muss auf jeden Fall nach DrawGrid sein, auch bei !bGridFirst
 
-    //!	Test, ob ChangeTrack-Anzeige aktiv ist
-    //!	Szenario-Rahmen per View-Optionen abschaltbar?
+    //! Test, ob ChangeTrack-Anzeige aktiv ist
+    //! Szenario-Rahmen per View-Optionen abschaltbar?
 
     SCTAB nTabCount = pDoc->GetTableCount();
     ScHighlightRanges* pHigh = pViewData->GetView()->GetHighlightRanges();
@@ -809,7 +803,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
     DrawRedraw( aOutputData, eMode, SC_LAYER_INTERN );
     DrawSdrGrid( aDrawingRectLogic, pContentDev );
 
-    if (!bIsInScroll)								// Drawing Markierungen
+    if (!bIsInScroll)                               // Drawing Markierungen
     {
         if(eMode == SC_UPDATE_CHANGED && aOutputData.SetChangedClip())
         {
@@ -832,7 +826,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
                                  aRefColor, FALSE );
     }
 
-        //	Range-Finder
+        //  Range-Finder
 
     ScInputHandler* pHdl = pScMod->GetInputHdl( pViewData->GetViewShell() );
     if (pHdl)
@@ -879,7 +873,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
         }
     }
 
-    //	InPlace Edit-View
+    //  InPlace Edit-View
     // moved after EndDrawLayers() to get it outside the overlay buffer and
     // on top of everything
     if ( bEditMode && (pViewData->GetRefTabNo() == pViewData->GetTabNo()) )
@@ -894,7 +888,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
         SetFillColor( pEditView->GetBackgroundColor() );
         Point aStart = pViewData->GetScrPos( nCol1, nRow1, eWhich );
         Point aEnd = pViewData->GetScrPos( nCol2+1, nRow2+1, eWhich );
-        aEnd.X() -= 2 * nLayoutSign;		// don't overwrite grid
+        aEnd.X() -= 2 * nLayoutSign;        // don't overwrite grid
         aEnd.Y() -= 2;
         DrawRect( Rectangle( aStart,aEnd ) );
 
@@ -916,11 +910,11 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
         SetMapMode(aDrawMode);
 
     if ( pNoteMarker )
-        pNoteMarker->Draw();		// ueber den Cursor, im Drawing-MapMode
+        pNoteMarker->Draw();        // ueber den Cursor, im Drawing-MapMode
 
     //
-    //	Wenn waehrend des Paint etwas invertiert wurde (Selektion geaendert aus Basic-Macro),
-    //	ist das jetzt durcheinandergekommen und es muss neu gemalt werden
+    //  Wenn waehrend des Paint etwas invertiert wurde (Selektion geaendert aus Basic-Macro),
+    //  ist das jetzt durcheinandergekommen und es muss neu gemalt werden
     //
 
     DBG_ASSERT(nPaintCount, "nPaintCount falsch");
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 365ed2d..7420db5 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -1691,6 +1691,17 @@ void ScTabView::UpdateShow()
     //!	neue Gridwindows eintragen
 }
 
+void ScTabView::UpdateVisibleRange()
+{
+    for (int i = 0; i < 4; ++i)
+    {
+        if (!pGridWin[i])
+            continue;
+
+        pGridWin[i]->UpdateVisibleRange();
+    }
+}
+
 // ---  Splitter  --------------------------------------------------------
 
 IMPL_LINK( ScTabView, SplitHdl, Splitter*, pSplitter )
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 5f13e02..fdccb1a 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -1638,13 +1638,13 @@ void ScTabView::SetTabNo( SCTAB nTab, BOOL bNew, BOOL bExtendSelection )
 
         if ( bRefMode )     // hide EditView if necessary (after aViewData.SetTabNo !)
         {
-            for ( USHORT i=0; i<4; i++ )
-                if ( pGridWin[i] )
-                    if ( pGridWin[i]->IsVisible() )
-                        pGridWin[i]->UpdateEditViewPos();
+            for (USHORT i = 0; i < 4; ++i)
+                if (pGridWin[i] && pGridWin[i]->IsVisible())
+                    pGridWin[i]->UpdateEditViewPos();
         }
 
         TabChanged();										// DrawView
+        UpdateVisibleRange();
 
         aViewData.GetViewShell()->WindowChanged();			// falls das aktive Fenster anders ist
         if ( !bUnoRefDialog )
commit 42485a770ac22f501b6bf6e94215dd42d267c48f
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Nov 29 16:07:40 2010 -0500

    Fixed use of incorrect integer type during import of outlines.
    
    I was supposed to use SCSIZE to store column / row position but was
    incorrectly using sal_uInt8.  This caused import of outlines from
    Excel document to entirely get screwed when the outline positions
    were > 255, and it was understandably so. :-P (fdo#31833)

diff --git a/sc/source/filter/excel/exctools.cxx b/sc/source/filter/excel/exctools.cxx
index f59fdff..527738e 100644
--- a/sc/source/filter/excel/exctools.cxx
+++ b/sc/source/filter/excel/exctools.cxx
@@ -97,6 +97,7 @@ RootData::~RootData()
 XclImpOutlineBuffer::XclImpOutlineBuffer( SCSIZE nNewSize ) :
     maLevels(0, nNewSize, 0),
     mpOutlineArray(NULL),
+    mnEndPos(nNewSize),
     mnMaxLevel(0),
     mbButtonAfter(true)
 {
@@ -125,12 +126,18 @@ void XclImpOutlineBuffer::MakeScOutline()
     if (!mpOutlineArray)
         return;
 
-    ::std::vector<sal_uInt8> aOutlineStack;
+    ::std::vector<SCSIZE> aOutlineStack;
     aOutlineStack.reserve(mnMaxLevel);
-    OutlineLevels::const_iterator itr = maLevels.begin(), itr_end = maLevels.end();
-    for (; itr != itr_end; ++itr)
+    OutlineLevels::const_iterator itr = maLevels.begin(), itrEnd = maLevels.end();
+    for (; itr != itrEnd; ++itr)
     {
         SCSIZE nPos = itr->first;
+        if (nPos >= mnEndPos)
+        {
+            // Don't go beyond the max allowed position.
+            DBG_ASSERT(aOutlineStack.empty(), "XclImpOutlineBuffer::MakeScOutline: outline stack not empty but expected to be.");
+            break;
+        }
         sal_uInt8 nLevel = itr->second;
         sal_uInt8 nCurLevel = static_cast<sal_uInt8>(aOutlineStack.size());
         if (nLevel > nCurLevel)
diff --git a/sc/source/filter/inc/otlnbuff.hxx b/sc/source/filter/inc/otlnbuff.hxx
index dd4d0eb..236e013 100644
--- a/sc/source/filter/inc/otlnbuff.hxx
+++ b/sc/source/filter/inc/otlnbuff.hxx
@@ -52,6 +52,7 @@ private:
     OutlineLevels       maLevels;
     ::std::set<SCSIZE>  maCollapsedPosSet;
     ScOutlineArray*     mpOutlineArray;
+    SCSIZE              mnEndPos;
     sal_uInt8           mnMaxLevel;
     bool                mbButtonAfter:1;
 };
commit 2ad4ec8e3a5960e1bbbcb0d917ac16acdf0f1729
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Nov 29 13:00:22 2010 -0500

    More strict parsing of external range names.
    
    This is to prevent parsing formula strings such as '=A#REF!' as valid
    external range names.  Ideally we should express any formula including
    invalid refs simply as '=#REF!' in all cases, but we are not there
    yet. (fdo#31741)

diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 536bd68..e93f25a 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -632,7 +632,7 @@ static bool lcl_parseExternalName(
 
             if (c == '\'')
             {
-                // Move to the next chart and loop until the second single
+                // Move to the next char and loop until the second single
                 // quote.
                 cPrev = c;
                 ++i; ++p;
@@ -649,8 +649,8 @@ static bool lcl_parseExternalName(
 
                         if (cPrev == '\'')
                         {
-                            // two consecutive quotes equals a single
-                            // quote in the file name.
+                            // two consecutive quotes equal a single quote in
+                            // the file name.
                             aTmpFile.Append(c);
                             cPrev = 'a';
                         }
@@ -662,12 +662,14 @@ static bool lcl_parseExternalName(
 
                     if (cPrev == '\'' && j != i)
                     {
-                        // this is not a quote but the previous one
-                        // is.  This ends the parsing of the quoted
-                        // segment.
+                        // this is not a quote but the previous one is.  This
+                        // ends the parsing of the quoted segment.  At this
+                        // point, the current char must equal the separator
+                        // char.
 
                         i = j;
                         bInName = true;
+                        aTmpName.Append(c); // Keep the separator as part of the name.
                         break;
                     }
                     aTmpFile.Append(c);
@@ -705,6 +707,7 @@ static bool lcl_parseExternalName(
             if (c == cSep)
             {
                 bInName = true;
+                aTmpName.Append(c); // Keep the separator as part of the name.
             }
             else
             {
@@ -746,8 +749,29 @@ static bool lcl_parseExternalName(
         return false;
     }
 
+    xub_StrLen nNameLen = aTmpName.Len();
+    if (nNameLen < 2)
+    {
+        // Name must be at least 2-char long (separator plus name).
+        return false;
+    }
+
+    if (aTmpName.GetChar(0) != cSep)
+    {
+        // 1st char of the name must equal the separator.
+        return false;
+    }
+
+    sal_Unicode cLast = aTmpName.GetChar(nNameLen-1);
+    if (cLast == sal_Unicode('!'))
+    {
+        // Check against #REF!.
+        if (aTmpName.EqualsAscii("#REF!"))
+            return false;
+    }
+
     rFile = aTmpFile;
-    rName = aTmpName;
+    rName = aTmpName.Copy(1); // Skip the first char as it is always the separator.
     return true;
 }
 


More information about the Libreoffice-commits mailing list