Update ooo320-m1
[ooovba.git] / applied_patches / 0192-calc-perf-lazy-overlay-objects.diff
blobdca94549b1f6801c7af27cfa08cd3254a0ccd59e
1 diff --git sc/source/ui/inc/gridwin.hxx sc/source/ui/inc/gridwin.hxx
2 index aae0353..7b9bac5 100644
3 --- sc/source/ui/inc/gridwin.hxx
4 +++ sc/source/ui/inc/gridwin.hxx
5 @@ -42,6 +42,7 @@
7 #include <vector>
8 #include <memory>
9 +#include <boost/shared_ptr.hpp>
11 // ---------------------------------------------------------------------------
13 @@ -115,6 +116,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 e591f86..9754ccd 100644
41 --- sc/source/ui/view/gridwin.cxx
42 +++ sc/source/ui/view/gridwin.cxx
43 @@ -159,7 +159,19 @@ extern USHORT nScFillModeMouseModifier; // global.cxx
45 #define SC_FILTERLISTBOX_LINES 12
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 class ScFilterListBox : public ListBox
64 @@ -372,6 +384,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 @@ -1352,30 +1365,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 @@ -5189,6 +5189,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 @@ -5359,6 +5362,7 @@ void ScGridWindow::UpdateSelectionOverlay()
120 void ScGridWindow::DeleteAutoFillOverlay()
122 DELETEZ( mpOOAutoFill );
123 + mpAutoFillRect.reset();
126 void ScGridWindow::UpdateAutoFillOverlay()
127 @@ -5379,6 +5383,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 @@ -5394,7 +5403,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)));
146 // #i70788# get the OverlayManager safely
147 ::sdr::overlay::OverlayManager* pOverlayManager = getOverlayManager();
148 @@ -5407,7 +5416,7 @@ void ScGridWindow::UpdateAutoFillOverlay()
149 aHandleColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::CALCPAGEBREAKAUTOMATIC).nColor;
150 std::vector< basegfx::B2DRange > aRanges;
151 const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation());
152 - basegfx::B2DRange aRB(aFillRect.Left(), aFillRect.Top(), aFillRect.Right() + 1, aFillRect.Bottom() + 1);
153 + basegfx::B2DRange aRB(mpAutoFillRect->Left(), mpAutoFillRect->Top(), mpAutoFillRect->Right() + 1, mpAutoFillRect->Bottom() + 1);
155 aRB.transform(aTransform);
156 aRanges.push_back(aRB);
157 @@ -5422,10 +5431,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 23edc22..8e456d2 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;