xref: /aoo42x/main/sc/source/ui/view/tabview4.cxx (revision b3f79822)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 
27 
28 
29 //------------------------------------------------------------------
30 
31 // INCLUDE ---------------------------------------------------------------
32 
33 #include <vcl/help.hxx>
34 #include <vcl/svapp.hxx>
35 
36 #include "tabview.hxx"
37 #include "document.hxx"
38 #include "docsh.hxx"
39 #include "scmod.hxx"
40 #include "gridwin.hxx"
41 #include "globstr.hrc"
42 #include "cell.hxx"
43 #include "dociter.hxx"
44 
45 extern sal_uInt16 nScFillModeMouseModifier;				// global.cxx
46 
47 // STATIC DATA -----------------------------------------------------------
48 
49 //==================================================================
50 
51 //
52 // ---	Referenz-Eingabe / Fill-Cursor
53 //
54 
HideTip()55 void ScTabView::HideTip()
56 {
57 	if ( nTipVisible )
58 	{
59 		Help::HideTip( nTipVisible );
60 		nTipVisible = 0;
61 	}
62 }
63 
ShowRefTip()64 void ScTabView::ShowRefTip()
65 {
66 	sal_Bool bDone = sal_False;
67 	if ( aViewData.GetRefType() == SC_REFTYPE_REF && Help::IsQuickHelpEnabled() )
68 	{
69 		SCCOL nStartX = aViewData.GetRefStartX();
70 		SCROW nStartY = aViewData.GetRefStartY();
71 		SCCOL nEndX   = aViewData.GetRefEndX();
72 		SCROW nEndY   = aViewData.GetRefEndY();
73 		if ( nEndX != nStartX || nEndY != nStartY )		// nicht fuer einzelne Zelle
74 		{
75 			sal_Bool bLeft = ( nEndX < nStartX );
76 			sal_Bool bTop  = ( nEndY < nStartY );
77 			PutInOrder( nStartX, nEndX );
78 			PutInOrder( nStartY, nEndY );
79 			SCCOL nCols = nEndX+1-nStartX;
80 			SCROW nRows = nEndY+1-nStartY;
81 
82 			String aHelp = ScGlobal::GetRscString( STR_QUICKHELP_REF );
83 			aHelp.SearchAndReplace( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("%1")),
84 									String::CreateFromInt32(nRows) );
85 			aHelp.SearchAndReplace( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("%2")),
86 									String::CreateFromInt32(nCols) );
87 
88 			ScSplitPos eWhich = aViewData.GetActivePart();
89 			Window* pWin = pGridWin[eWhich];
90 			if ( pWin )
91 			{
92 				Point aStart = aViewData.GetScrPos( nStartX, nStartY, eWhich );
93 				Point aEnd = aViewData.GetScrPos( nEndX+1, nEndY+1, eWhich );
94 
95 				Point aPos( bLeft ? aStart.X() : ( aEnd.X() + 3 ),
96 							bTop ? aStart.Y() : ( aEnd.Y() + 3 ) );
97 				sal_uInt16 nFlags = ( bLeft ? QUICKHELP_RIGHT : QUICKHELP_LEFT ) |
98 								( bTop ? QUICKHELP_BOTTOM : QUICKHELP_TOP );
99 
100 				// nicht ueber die editierte Formel
101 				if ( !bTop && aViewData.HasEditView( eWhich ) &&
102 						nEndY+1 == aViewData.GetEditViewRow() )
103 				{
104 					//	dann an der oberen Kante der editierten Zelle ausrichten
105 					aPos.Y() -= 2;		// die 3 von oben
106 					nFlags = ( nFlags & ~QUICKHELP_TOP ) | QUICKHELP_BOTTOM;
107 				}
108 
109 				Rectangle aRect( pWin->OutputToScreenPixel( aPos ), Size(1,1) );
110 
111 				//!	Test, ob geaendert ??
112 
113 				HideTip();
114 				nTipVisible = Help::ShowTip( pWin, aRect, aHelp, nFlags );
115 				bDone = sal_True;
116 			}
117 		}
118 	}
119 
120 	if (!bDone)
121 		HideTip();
122 }
123 
StopRefMode()124 void ScTabView::StopRefMode()
125 {
126 	if (aViewData.IsRefMode())
127 	{
128 		aViewData.SetRefMode( sal_False, SC_REFTYPE_NONE );
129 
130 		HideTip();
131         UpdateShrinkOverlay();
132 
133 		if ( aViewData.GetTabNo() >= aViewData.GetRefStartZ() &&
134 				aViewData.GetTabNo() <= aViewData.GetRefEndZ() )
135 		{
136 			ScDocument* pDoc = aViewData.GetDocument();
137 			SCCOL nStartX = aViewData.GetRefStartX();
138 			SCROW nStartY = aViewData.GetRefStartY();
139 			SCCOL nEndX = aViewData.GetRefEndX();
140 			SCROW nEndY = aViewData.GetRefEndY();
141 			if ( nStartX == nEndX && nStartY == nEndY )
142 				pDoc->ExtendMerge( nStartX, nStartY, nEndX, nEndY, aViewData.GetTabNo() );
143 
144 			PaintArea( nStartX,nStartY,nEndX,nEndY, SC_UPDATE_MARKS );
145 		}
146 
147 		pSelEngine->Reset();
148 		pSelEngine->SetAddMode( sal_False );		//! sollte das nicht bei Reset passieren?
149 
150 		ScSplitPos eOld = pSelEngine->GetWhich();
151 		ScSplitPos eNew = aViewData.GetActivePart();
152 		if ( eNew != eOld )
153 		{
154 			pSelEngine->SetWindow( pGridWin[ eNew ] );
155 			pSelEngine->SetWhich( eNew );
156 			pSelEngine->SetVisibleArea( Rectangle(Point(),
157 										pGridWin[eNew]->GetOutputSizePixel()) );
158 			pGridWin[eOld]->MoveMouseStatus(*pGridWin[eNew]);
159 		}
160 	}
161 
162 	//	AlignToCursor(SC_FOLLOW_NONE): Only switch active part.
163 	//	This must also be done if no RefMode was active (for RangeFinder dragging),
164 	//	but if RefMode was set, AlignToCursor must be after SelectionEngine reset,
165 	//	so the SelectionEngine SetWindow call from AlignToCursor doesn't capture
166 	//	the mouse again when called from Tracking/MouseButtonUp (#94562#).
167 	AlignToCursor( aViewData.GetCurX(), aViewData.GetCurY(), SC_FOLLOW_NONE );
168 }
169 
DoneRefMode(sal_Bool bContinue)170 void ScTabView::DoneRefMode( sal_Bool bContinue )
171 {
172 	ScDocument* pDoc = aViewData.GetDocument();
173 	if ( aViewData.GetRefType() == SC_REFTYPE_REF && bContinue )
174 		SC_MOD()->AddRefEntry();
175 
176 	sal_Bool bWasRef = aViewData.IsRefMode();
177 	aViewData.SetRefMode( sal_False, SC_REFTYPE_NONE );
178 
179 	HideTip();
180     UpdateShrinkOverlay();
181 
182 	//	Paint:
183 	if ( bWasRef && aViewData.GetTabNo() >= aViewData.GetRefStartZ() &&
184 					aViewData.GetTabNo() <= aViewData.GetRefEndZ() )
185 	{
186 		SCCOL nStartX = aViewData.GetRefStartX();
187 		SCROW nStartY = aViewData.GetRefStartY();
188 		SCCOL nEndX = aViewData.GetRefEndX();
189 		SCROW nEndY = aViewData.GetRefEndY();
190 		if ( nStartX == nEndX && nStartY == nEndY )
191 			pDoc->ExtendMerge( nStartX, nStartY, nEndX, nEndY, aViewData.GetTabNo() );
192 
193 		PaintArea( nStartX,nStartY,nEndX,nEndY, SC_UPDATE_MARKS );
194 	}
195 }
196 
UpdateRef(SCCOL nCurX,SCROW nCurY,SCTAB nCurZ)197 void ScTabView::UpdateRef( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ )
198 {
199 	ScDocument* pDoc = aViewData.GetDocument();
200 
201 	if (!aViewData.IsRefMode())
202 	{
203 		//	Das kommt vor, wenn bei einem Referenz-Dialog als erstes mit Control in die
204 		//	die Tabelle geklickt wird. Dann die neue Referenz an den alten Inhalt anhaengen:
205 
206 		ScModule* pScMod = SC_MOD();
207 		if (pScMod->IsFormulaMode())
208 			pScMod->AddRefEntry();
209 
210 		InitRefMode( nCurX, nCurY, nCurZ, SC_REFTYPE_REF );
211 	}
212 
213 	if ( nCurX != aViewData.GetRefEndX() || nCurY != aViewData.GetRefEndY() ||
214 		 nCurZ != aViewData.GetRefEndZ() )
215 	{
216 		ScMarkData& rMark = aViewData.GetMarkData();
217 		SCTAB nTab = aViewData.GetTabNo();
218 
219 		SCCOL nStartX = aViewData.GetRefStartX();
220 		SCROW nStartY = aViewData.GetRefStartY();
221 		SCCOL nEndX = aViewData.GetRefEndX();
222 		SCROW nEndY = aViewData.GetRefEndY();
223 		if ( nStartX == nEndX && nStartY == nEndY )
224 			pDoc->ExtendMerge( nStartX, nStartY, nEndX, nEndY, nTab );
225 		ScUpdateRect aRect( nStartX, nStartY, nEndX, nEndY );
226 
227 		aViewData.SetRefEnd( nCurX, nCurY, nCurZ );
228 
229 		nStartX = aViewData.GetRefStartX();
230 		nStartY = aViewData.GetRefStartY();
231 		nEndX = aViewData.GetRefEndX();
232 		nEndY = aViewData.GetRefEndY();
233 		if ( nStartX == nEndX && nStartY == nEndY )
234 			pDoc->ExtendMerge( nStartX, nStartY, nEndX, nEndY, nTab );
235 		aRect.SetNew( nStartX, nStartY, nEndX, nEndY );
236 
237 		ScRefType eType = aViewData.GetRefType();
238 		if ( eType == SC_REFTYPE_REF )
239 		{
240 			ScRange aRef(
241 					aViewData.GetRefStartX(), aViewData.GetRefStartY(), aViewData.GetRefStartZ(),
242 					aViewData.GetRefEndX(), aViewData.GetRefEndY(), aViewData.GetRefEndZ() );
243 			SC_MOD()->SetReference( aRef, pDoc, &rMark );
244 			ShowRefTip();
245 		}
246 		else if ( eType == SC_REFTYPE_EMBED_LT || eType == SC_REFTYPE_EMBED_RB )
247 		{
248 			PutInOrder(nStartX,nEndX);
249 			PutInOrder(nStartY,nEndY);
250 			pDoc->SetEmbedded( ScRange(nStartX,nStartY,nTab, nEndX,nEndY,nTab) );
251 			ScDocShell* pDocSh = aViewData.GetDocShell();
252 			pDocSh->UpdateOle( &aViewData, sal_True );
253 			pDocSh->SetDocumentModified();
254 		}
255 
256 		SCCOL nPaintStartX;
257 		SCROW nPaintStartY;
258 		SCCOL nPaintEndX;
259 		SCROW nPaintEndY;
260 		if (aRect.GetDiff( nPaintStartX, nPaintStartY, nPaintEndX, nPaintEndY ))
261 			PaintArea( nPaintStartX, nPaintStartY, nPaintEndX, nPaintEndY, SC_UPDATE_MARKS );
262 	}
263 
264 	//	Tip-Hilfe fuer Auto-Fill
265 
266 	if ( aViewData.GetRefType() == SC_REFTYPE_FILL && Help::IsQuickHelpEnabled() )
267 	{
268 		String aHelpStr;
269 		ScRange aMarkRange;
270 		aViewData.GetSimpleArea( aMarkRange );
271 		SCCOL nEndX = aViewData.GetRefEndX();
272 		SCROW nEndY = aViewData.GetRefEndY();
273 		ScRange aDelRange;
274 		if ( aViewData.GetFillMode() == SC_FILL_MATRIX && !(nScFillModeMouseModifier & KEY_MOD1) )
275 		{
276 			aHelpStr = ScGlobal::GetRscString( STR_TIP_RESIZEMATRIX );
277 			SCCOL nCols = nEndX + 1 - aViewData.GetRefStartX();	// Reihenfolge ist richtig
278 			SCROW nRows = nEndY + 1 - aViewData.GetRefStartY();
279 			aHelpStr.SearchAndReplace( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("%1")),
280 									   String::CreateFromInt32(nRows) );
281 			aHelpStr.SearchAndReplace( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("%2")),
282 									   String::CreateFromInt32(nCols) );
283 		}
284 		else if ( aViewData.GetDelMark( aDelRange ) )
285 			aHelpStr = ScGlobal::GetRscString( STR_QUICKHELP_DELETE );
286 		else if ( nEndX != aMarkRange.aEnd.Col() || nEndY != aMarkRange.aEnd.Row() )
287 			aHelpStr = pDoc->GetAutoFillPreview( aMarkRange, nEndX, nEndY );
288 
289 		//	je nach Richtung die obere oder untere Ecke:
290 		SCCOL nAddX = ( nEndX >= aMarkRange.aEnd.Col() ) ? 1 : 0;
291 		SCROW nAddY = ( nEndY >= aMarkRange.aEnd.Row() ) ? 1 : 0;
292 		Point aPos = aViewData.GetScrPos( nEndX+nAddX, nEndY+nAddY, aViewData.GetActivePart() );
293 		aPos.X() += 8;
294 		aPos.Y() += 4;
295 		Window* pWin = GetActiveWin();
296 		if ( pWin )
297 			aPos = pWin->OutputToScreenPixel( aPos );
298 		Rectangle aRect( aPos, aPos );
299 		sal_uInt16 nAlign = QUICKHELP_LEFT|QUICKHELP_TOP;
300 		Help::ShowQuickHelp(pWin, aRect, aHelpStr, nAlign);
301 	}
302 }
303 
InitRefMode(SCCOL nCurX,SCROW nCurY,SCTAB nCurZ,ScRefType eType,sal_Bool bPaint)304 void ScTabView::InitRefMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, ScRefType eType, sal_Bool bPaint )
305 {
306 	ScDocument* pDoc = aViewData.GetDocument();
307 	ScMarkData& rMark = aViewData.GetMarkData();
308 	if (!aViewData.IsRefMode())
309 	{
310 		aViewData.SetRefMode( sal_True, eType );
311 		aViewData.SetRefStart( nCurX, nCurY, nCurZ );
312 		aViewData.SetRefEnd( nCurX, nCurY, nCurZ );
313 
314 		if (nCurZ == aViewData.GetTabNo() && bPaint)
315 		{
316 			SCCOL nStartX = nCurX;
317 			SCROW nStartY = nCurY;
318 			SCCOL nEndX = nCurX;
319 			SCROW nEndY = nCurY;
320 			pDoc->ExtendMerge( nStartX, nStartY, nEndX, nEndY, aViewData.GetTabNo() );
321 
322 			//!	nur Markierung ueber Inhalte zeichnen!
323 			PaintArea( nStartX,nStartY,nEndX,nEndY, SC_UPDATE_MARKS );
324 
325 			//	SetReference ohne Merge-Anpassung
326 			ScRange aRef( nCurX,nCurY,nCurZ, nCurX,nCurY,nCurZ );
327 			SC_MOD()->SetReference( aRef, pDoc, &rMark );
328 		}
329 	}
330 }
331 
332 //UNUSED2008-05  void ScTabView::EndSelection()
333 //UNUSED2008-05  {
334 //UNUSED2008-05      ScModule* pScMod = SC_MOD();
335 //UNUSED2008-05      sal_Bool bRefMode = pScMod->IsFormulaMode();
336 //UNUSED2008-05      if ( bRefMode )
337 //UNUSED2008-05          pScMod->EndReference();
338 //UNUSED2008-05  }
339 
340 // static
SetScrollBar(ScrollBar & rScroll,long nRangeMax,long nVisible,long nPos,sal_Bool bLayoutRTL)341 void ScTabView::SetScrollBar( ScrollBar& rScroll, long nRangeMax, long nVisible, long nPos, sal_Bool bLayoutRTL )
342 {
343     if ( nVisible == 0 )
344         nVisible = 1;       // #i59893# don't use visible size 0
345 
346 	//	RTL layout uses a negative range to simulate a mirrored scroll bar.
347 	//	SetScrollBar/GetScrollBarPos hide this so outside of these functions normal cell
348 	//	addresses can be used.
349 
350 	if ( bLayoutRTL )
351 	{
352 		rScroll.SetRange( Range( -nRangeMax, 0 ) );
353 		rScroll.SetVisibleSize( nVisible );
354 		rScroll.SetThumbPos( -nPos - nVisible );
355 	}
356 	else
357 	{
358 		rScroll.SetRange( Range( 0, nRangeMax ) );
359 		rScroll.SetVisibleSize( nVisible );
360 		rScroll.SetThumbPos( nPos );
361 	}
362 }
363 
364 // static
GetScrollBarPos(ScrollBar & rScroll,sal_Bool bLayoutRTL)365 long ScTabView::GetScrollBarPos( ScrollBar& rScroll, sal_Bool bLayoutRTL )
366 {
367 	if ( bLayoutRTL )
368 		return -rScroll.GetThumbPos() - rScroll.GetVisibleSize();
369 	else
370 		return rScroll.GetThumbPos();
371 }
372 
373 //	UpdateScrollBars - sichtbaren Bereich und Scrollweite der Scrollbars einstellen
374 
lcl_UpdateBar(ScrollBar & rScroll,SCCOLROW nSize)375 long lcl_UpdateBar( ScrollBar& rScroll, SCCOLROW nSize )		// Size = (komplette) Zellen
376 {
377 	long nOldPos;
378 	long nNewPos;
379 
380 	nOldPos = rScroll.GetThumbPos();
381 	rScroll.SetPageSize( static_cast<long>(nSize) );
382 	nNewPos = rScroll.GetThumbPos();
383 #ifndef UNX
384 	rScroll.SetPageSize( 1 );				// immer moeglich !
385 #endif
386 
387 	return nNewPos - nOldPos;
388 }
389 
lcl_GetScrollRange(SCCOLROW nDocEnd,SCCOLROW nPos,SCCOLROW nVis,SCCOLROW nMax,SCCOLROW nStart)390 long lcl_GetScrollRange( SCCOLROW nDocEnd, SCCOLROW nPos, SCCOLROW nVis, SCCOLROW nMax, SCCOLROW nStart )
391 {
392 	// get the end (positive) of a scroll bar range that always starts at 0
393 
394 	++nVis;
395 	++nMax;		// for partially visible cells
396 	SCCOLROW nEnd = Max(nDocEnd, (SCCOLROW)(nPos+nVis)) + nVis;
397 	if (nEnd > nMax)
398 		nEnd = nMax;
399 
400 	return ( nEnd - nStart );		// for range starting at 0
401 }
402 
UpdateScrollBars()403 void ScTabView::UpdateScrollBars()
404 {
405 	long		nDiff;
406 	sal_Bool		bTop =   ( aViewData.GetVSplitMode() != SC_SPLIT_NONE );
407 	sal_Bool		bRight = ( aViewData.GetHSplitMode() != SC_SPLIT_NONE );
408 	ScDocument*	pDoc = aViewData.GetDocument();
409 	SCTAB		nTab = aViewData.GetTabNo();
410     sal_Bool        bMirror = pDoc->IsLayoutRTL( nTab ) != Application::GetSettings().GetLayoutRTL();
411 	SCCOL		nUsedX;
412 	SCROW		nUsedY;
413 	pDoc->GetTableArea( nTab, nUsedX, nUsedY );		//! cachen !!!!!!!!!!!!!!!
414 
415 	SCCOL nVisXL = 0;
416 	SCCOL nVisXR = 0;
417 	SCROW nVisYB = 0;
418 	SCROW nVisYT = 0;
419 
420 	SCCOL nStartX = 0;
421 	SCROW nStartY = 0;
422 	if (aViewData.GetHSplitMode()==SC_SPLIT_FIX)
423 		nStartX = aViewData.GetFixPosX();
424 	if (aViewData.GetVSplitMode()==SC_SPLIT_FIX)
425 		nStartY = aViewData.GetFixPosY();
426 
427 	nVisXL = aViewData.VisibleCellsX( SC_SPLIT_LEFT );
428 	long nMaxXL = lcl_GetScrollRange( nUsedX, aViewData.GetPosX(SC_SPLIT_LEFT), nVisXL, MAXCOL, 0 );
429     SetScrollBar( aHScrollLeft, nMaxXL, nVisXL, aViewData.GetPosX( SC_SPLIT_LEFT ), bMirror );
430 
431 	nVisYB = aViewData.VisibleCellsY( SC_SPLIT_BOTTOM );
432 	long nMaxYB = lcl_GetScrollRange( nUsedY, aViewData.GetPosY(SC_SPLIT_BOTTOM), nVisYB, MAXROW, nStartY );
433 	SetScrollBar( aVScrollBottom, nMaxYB, nVisYB, aViewData.GetPosY( SC_SPLIT_BOTTOM ) - nStartY, sal_False );
434 
435 	if (bRight)
436 	{
437 		nVisXR = aViewData.VisibleCellsX( SC_SPLIT_RIGHT );
438 		long nMaxXR = lcl_GetScrollRange( nUsedX, aViewData.GetPosX(SC_SPLIT_RIGHT), nVisXR, MAXCOL, nStartX );
439         SetScrollBar( aHScrollRight, nMaxXR, nVisXR, aViewData.GetPosX( SC_SPLIT_RIGHT ) - nStartX, bMirror );
440 	}
441 
442 	if (bTop)
443 	{
444 		nVisYT = aViewData.VisibleCellsY( SC_SPLIT_TOP );
445 		long nMaxYT = lcl_GetScrollRange( nUsedY, aViewData.GetPosY(SC_SPLIT_TOP), nVisYT, MAXROW, 0 );
446 		SetScrollBar( aVScrollTop, nMaxYT, nVisYT, aViewData.GetPosY( SC_SPLIT_TOP ), sal_False );
447 	}
448 
449 	//		Bereich testen
450 
451 	nDiff = lcl_UpdateBar( aHScrollLeft, nVisXL );
452 	if (nDiff) ScrollX( nDiff, SC_SPLIT_LEFT );
453 	if (bRight)
454 	{
455 		nDiff = lcl_UpdateBar( aHScrollRight, nVisXR );
456 		if (nDiff) ScrollX( nDiff, SC_SPLIT_RIGHT );
457 	}
458 
459 	nDiff = lcl_UpdateBar( aVScrollBottom, nVisYB );
460 	if (nDiff) ScrollY( nDiff, SC_SPLIT_BOTTOM );
461 	if (bTop)
462 	{
463 		nDiff = lcl_UpdateBar( aVScrollTop, nVisYT );
464 		if (nDiff) ScrollY( nDiff, SC_SPLIT_TOP );
465 	}
466 
467 	//		set visible area for online spelling
468 
469 	if ( aViewData.IsActive() )
470 	{
471 		ScSplitPos eActive = aViewData.GetActivePart();
472 		ScHSplitPos eHWhich = WhichH( eActive );
473 		ScVSplitPos eVWhich = WhichV( eActive );
474 		SCCOL nPosX = aViewData.GetPosX(eHWhich);
475 		SCROW nPosY = aViewData.GetPosY(eVWhich);
476 		SCCOL nEndX = nPosX + ( ( eHWhich == SC_SPLIT_LEFT ) ? nVisXL : nVisXR );
477 		SCROW nEndY = nPosY + ( ( eVWhich == SC_SPLIT_TOP ) ? nVisYT : nVisYB );
478 		if ( nEndX > MAXCOL ) nEndX = MAXCOL;
479 		if ( nEndY > MAXROW ) nEndY = MAXROW;
480 		ScRange aVisible( nPosX, nPosY, nTab, nEndX, nEndY, nTab );
481 		if ( pDoc->SetVisibleSpellRange( aVisible ) )
482 			SC_MOD()->AnythingChanged();				// if visible area has changed
483 	}
484 }
485 
486 #ifndef HDR_SLIDERSIZE
487 #define HDR_SLIDERSIZE		2
488 #endif
489 
InvertHorizontal(ScVSplitPos eWhich,long nDragPos)490 void ScTabView::InvertHorizontal( ScVSplitPos eWhich, long nDragPos )
491 {
492 	for (sal_uInt16 i=0; i<4; i++)
493 		if (WhichV((ScSplitPos)i)==eWhich)
494 		{
495 			ScGridWindow* pWin = pGridWin[i];
496 			if (pWin)
497 			{
498 				Rectangle aRect( 0,nDragPos, pWin->GetOutputSizePixel().Width()-1,nDragPos+HDR_SLIDERSIZE-1 );
499 				pWin->Update();
500 				pWin->DoInvertRect( aRect );	// Pixel
501 			}
502 		}
503 }
504 
InvertVertical(ScHSplitPos eWhich,long nDragPos)505 void ScTabView::InvertVertical( ScHSplitPos eWhich, long nDragPos )
506 {
507 	for (sal_uInt16 i=0; i<4; i++)
508 		if (WhichH((ScSplitPos)i)==eWhich)
509 		{
510 			ScGridWindow* pWin = pGridWin[i];
511 			if (pWin)
512 			{
513 				Rectangle aRect( nDragPos,0, nDragPos+HDR_SLIDERSIZE-1,pWin->GetOutputSizePixel().Height()-1 );
514 				pWin->Update();
515 				pWin->DoInvertRect( aRect );	// Pixel
516 			}
517 		}
518 }
519 
520 //==================================================================
521 
InterpretVisible()522 void ScTabView::InterpretVisible()
523 {
524 	//	make sure all visible cells are interpreted,
525 	//	so the next paint will not execute a macro function
526 
527 	ScDocument* pDoc = aViewData.GetDocument();
528 	if ( !pDoc->GetAutoCalc() )
529 		return;
530 
531 	SCTAB nTab = aViewData.GetTabNo();
532 	for (sal_uInt16 i=0; i<4; i++)
533 	{
534 		//	rely on gridwin pointers to find used panes
535 		//	no IsVisible test in case the whole view is not yet shown
536 
537 		if (pGridWin[i])
538 		{
539 			ScHSplitPos eHWhich = WhichH( ScSplitPos(i) );
540 			ScVSplitPos eVWhich = WhichV( ScSplitPos(i) );
541 
542 			SCCOL	nX1 = aViewData.GetPosX( eHWhich );
543 			SCROW	nY1 = aViewData.GetPosY( eVWhich );
544 			SCCOL	nX2 = nX1 + aViewData.VisibleCellsX( eHWhich );
545 			SCROW	nY2 = nY1 + aViewData.VisibleCellsY( eVWhich );
546 
547 			if (nX2 > MAXCOL) nX2 = MAXCOL;
548 			if (nY2 > MAXROW) nY2 = MAXROW;
549 
550 			ScCellIterator aIter( pDoc, nX1, nY1, nTab, nX2, nY2, nTab );
551 			ScBaseCell* pCell = aIter.GetFirst();
552 			while ( pCell )
553 			{
554 				if ( pCell->GetCellType() == CELLTYPE_FORMULA && ((ScFormulaCell*)pCell)->GetDirty() )
555 					((ScFormulaCell*)pCell)->Interpret();
556 
557 				pCell = aIter.GetNext();
558 			}
559 		}
560 	}
561 
562     // #i65047# repaint during the above loop may have set the bNeedsRepaint flag
563     CheckNeedsRepaint();
564 }
565 
566 
567 
568 
569 
570