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

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Nov 29 16:23:29 PST 2010


 sc/source/ui/inc/gridwin.hxx   |    1 
 sc/source/ui/inc/tabview.hxx   |    1 
 sc/source/ui/view/gridwin2.cxx |   16 +++++
 sc/source/ui/view/gridwin4.cxx |  110 +++++++++++++++++++----------------------
 sc/source/ui/view/tabview.cxx  |   11 ++++
 sc/source/ui/view/tabview3.cxx |    8 +-
 6 files changed, 85 insertions(+), 62 deletions(-)

New commits:
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 )


More information about the Libreoffice-commits mailing list