update ooo310-m15
[ooovba.git] / applied_patches / 0875-calc-perf-lazy-overlay-objects.diff
blobecdbe0db7f286d630b2e202a6a85dfc04d8c8309
1 diff --git sc/source/ui/inc/gridwin.hxx sc/source/ui/inc/gridwin.hxx
2 index f6be077..944ac44 100644
3 --- sc/source/ui/inc/gridwin.hxx
4 +++ sc/source/ui/inc/gridwin.hxx
5 @@ -40,6 +40,7 @@
7 #include <vector>
8 #include <memory>
9 +#include <boost/shared_ptr.hpp>
11 // ---------------------------------------------------------------------------
13 @@ -152,6 +153,25 @@ private:
14 ::sdr::overlay::OverlayObjectList* mpOOHeader;
15 ::sdr::overlay::OverlayObjectList* mpOOShrink;
17 + ::boost::shared_ptr<Rectangle> mpAutoFillRect;
19 + /**
20 + * Stores current visible column and row ranges, used to avoid expensive
21 + * operations on objects that are outside visible area.
22 + */
23 + struct VisibleRange
24 + {
25 + SCCOL mnCol1;
26 + SCCOL mnCol2;
27 + SCROW mnRow1;
28 + SCROW mnRow2;
30 + VisibleRange();
32 + bool isInside(SCCOL nCol, SCROW nRow) const;
33 + };
34 + VisibleRange maVisibleRange;
36 private:
37 ScViewData* pViewData;
38 ScSplitPos eWhich;
39 diff --git sc/source/ui/view/gridwin.cxx sc/source/ui/view/gridwin.cxx
40 index b5bb7c6..e842c7d 100644
41 --- sc/source/ui/view/gridwin.cxx
42 +++ sc/source/ui/view/gridwin.cxx
43 @@ -389,7 +389,19 @@ sal_Bool lcl_GetHyperlinkCell(ScDocument* pDoc, SCCOL& rPosX, SCROW& rPosY, SCTA
44 return bFound;
47 -//==================================================================
48 +// ============================================================================
50 +ScGridWindow::VisibleRange::VisibleRange() :
51 + mnCol1(0), mnCol2(MAXCOL), mnRow1(0), mnRow2(MAXROW)
55 +bool ScGridWindow::VisibleRange::isInside(SCCOL nCol, SCROW nRow) const
57 + return mnCol1 <= nCol && nCol <= mnCol2 && mnRow1 <= nRow && nRow <= mnRow2;
60 +// ============================================================================
62 // WB_DIALOGCONTROL noetig fuer UNO-Controls
63 ScGridWindow::ScGridWindow( Window* pParent, ScViewData* pData, ScSplitPos eWhichPos )
64 @@ -403,6 +415,7 @@ ScGridWindow::ScGridWindow( Window* pParent, ScViewData* pData, ScSplitPos eWhic
65 mpOODragRect( NULL ),
66 mpOOHeader( NULL ),
67 mpOOShrink( NULL ),
68 + mpAutoFillRect(static_cast<Rectangle*>(NULL)),
69 pViewData( pData ),
70 eWhich( eWhichPos ),
71 pNoteMarker( NULL ),
72 @@ -1301,30 +1314,17 @@ BOOL ScGridWindow::TestMouse( const MouseEvent& rMEvt, BOOL bAction )
73 ScRange aMarkRange;
74 if (pViewData->GetSimpleArea( aMarkRange ) == SC_MARK_SIMPLE)
76 - if ( aMarkRange.aStart.Tab() == pViewData->GetTabNo() )
77 + if (aMarkRange.aStart.Tab() == pViewData->GetTabNo() && mpAutoFillRect)
79 - // Block-Ende wie in DrawAutoFillMark
80 - SCCOL nX = aMarkRange.aEnd.Col();
81 - SCROW nY = aMarkRange.aEnd.Row();
83 - Point aFillPos = pViewData->GetScrPos( nX, nY, eWhich, TRUE );
84 - long nSizeXPix;
85 - long nSizeYPix;
86 - pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix );
87 - aFillPos.X() += nSizeXPix * nLayoutSign;
88 - aFillPos.Y() += nSizeYPix;
89 - if ( bLayoutRTL )
90 - aFillPos.X() -= 1;
92 Point aMousePos = rMEvt.GetPosPixel();
93 - // Abfrage hier passend zu DrawAutoFillMark
94 - // (ein Pixel mehr als markiert)
95 - if ( aMousePos.X() >= aFillPos.X()-3 && aMousePos.X() <= aFillPos.X()+4 &&
96 - aMousePos.Y() >= aFillPos.Y()-3 && aMousePos.Y() <= aFillPos.Y()+4 )
97 + if (mpAutoFillRect->IsInside(aMousePos))
99 - SetPointer( Pointer( POINTER_CROSS ) ); //! dickeres Kreuz ?
100 + SetPointer( Pointer( POINTER_CROSS ) ); //! dickeres Kreuz ?
101 if (bAction)
103 + SCCOL nX = aMarkRange.aEnd.Col();
104 + SCROW nY = aMarkRange.aEnd.Row();
106 if ( lcl_IsEditableMatrix( pViewData->GetDocument(), aMarkRange ) )
107 pViewData->SetDragMode(
108 aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), nX, nY, SC_FILL_MATRIX );
109 @@ -5274,6 +5274,9 @@ void ScGridWindow::UpdateCursorOverlay()
110 SCCOL nX = pViewData->GetCurX();
111 SCROW nY = pViewData->GetCurY();
113 + if (!maVisibleRange.isInside(nX, nY))
114 + return;
116 // don't show the cursor in overlapped cells
118 ScDocument* pDoc = pViewData->GetDocument();
119 @@ -5444,6 +5447,7 @@ void ScGridWindow::UpdateSelectionOverlay()
120 void ScGridWindow::DeleteAutoFillOverlay()
122 DELETEZ( mpOOAutoFill );
123 + mpAutoFillRect.reset();
126 void ScGridWindow::UpdateAutoFillOverlay()
127 @@ -5464,6 +5468,11 @@ void ScGridWindow::UpdateAutoFillOverlay()
129 SCCOL nX = aAutoMarkPos.Col();
130 SCROW nY = aAutoMarkPos.Row();
132 + if (!maVisibleRange.isInside(nX, nY))
133 + // Autofill mark is not visible. Bail out.
134 + return;
136 SCTAB nTab = pViewData->GetTabNo();
137 ScDocument* pDoc = pViewData->GetDocument();
138 BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
139 @@ -5479,7 +5488,7 @@ void ScGridWindow::UpdateAutoFillOverlay()
141 aFillPos.Y() += nSizeYPix;
142 aFillPos.Y() -= 2;
143 - Rectangle aFillRect( aFillPos, Size(6,6) );
144 + mpAutoFillRect.reset(new Rectangle(aFillPos, Size(6, 6)));
147 // convert into logic units
148 @@ -5487,7 +5496,7 @@ void ScGridWindow::UpdateAutoFillOverlay()
150 sdr::overlay::OverlayObjectCell::RangeVector aRanges;
152 - Rectangle aLogic( PixelToLogic( aFillRect, aDrawMode ) );
153 + Rectangle aLogic( PixelToLogic( *mpAutoFillRect, aDrawMode ) );
155 const basegfx::B2DPoint aTopLeft(aLogic.Left(), aLogic.Top());
156 const basegfx::B2DPoint aBottomRight(aLogic.Right(), aLogic.Bottom());
157 @@ -5511,10 +5520,10 @@ void ScGridWindow::UpdateAutoFillOverlay()
158 mpOOAutoFill = new ::sdr::overlay::OverlayObjectList;
159 mpOOAutoFill->append(*pOverlay);
163 - if ( aOldMode != aDrawMode )
164 - SetMapMode( aOldMode );
165 + if ( aOldMode != aDrawMode )
166 + SetMapMode( aOldMode );
170 void ScGridWindow::DeleteDragRectOverlay()
171 diff --git sc/source/ui/view/gridwin4.cxx sc/source/ui/view/gridwin4.cxx
172 index 73e9bb4..a3bf178 100644
173 --- sc/source/ui/view/gridwin4.cxx
174 +++ sc/source/ui/view/gridwin4.cxx
175 @@ -451,6 +451,12 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
176 SCROW nYBottom = nPosY + pViewData->VisibleCellsY(eVWhich);
177 if (nYBottom > MAXROW) nYBottom = MAXROW;
179 + // Store the current visible range.
180 + maVisibleRange.mnCol1 = nPosX;
181 + maVisibleRange.mnCol2 = nXRight;
182 + maVisibleRange.mnRow1 = nPosY;
183 + maVisibleRange.mnRow2 = nYBottom;
185 if (nX1 > nXRight || nY1 > nYBottom)
186 return; // unsichtbar
187 if (nX2 > nXRight) nX2 = nXRight;