xref: /aoo41x/main/sc/source/ui/view/tabview5.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 // INCLUDE ---------------------------------------------------------------
30 
31 #include "scitems.hxx"
32 #include <editeng/eeitem.hxx>
33 
34 
35 #include <svx/fmshell.hxx>
36 #include <svx/svdobj.hxx>
37 #include <svx/svdoutl.hxx>
38 #include <sfx2/bindings.hxx>
39 #include <sfx2/dispatch.hxx>
40 #include <sfx2/objsh.hxx>
41 #include <tools/ref.hxx>
42 
43 #include "tabview.hxx"
44 #include "tabvwsh.hxx"
45 #include "document.hxx"
46 #include "gridwin.hxx"
47 #include "olinewin.hxx"
48 #include "tabsplit.hxx"
49 #include "colrowba.hxx"
50 #include "tabcont.hxx"
51 #include "hintwin.hxx"
52 #include "sc.hrc"
53 #include "pagedata.hxx"
54 #include "hiranges.hxx"
55 #include "drawview.hxx"
56 #include "drwlayer.hxx"
57 #include "fusel.hxx"                // Start-Function
58 #include "seltrans.hxx"
59 #include "scmod.hxx"
60 #include "AccessibilityHints.hxx"
61 #include "docsh.hxx"
62 #include "viewuno.hxx"
63 
64 #include <vcl/svapp.hxx>
65 
66 using namespace com::sun::star;
67 
68 // STATIC DATA -----------------------------------------------------------
69 
70 
Init()71 void __EXPORT ScTabView::Init()
72 {
73     /*  RTL layout of the view windows is done manually, because it depends on
74         the sheet orientation, not the UI setting. Note: controls that are
75         already constructed (e.g. scroll bars) have the RTL setting of the GUI.
76         Eventually this has to be disabled manually (see below). */
77     pFrameWin->EnableRTL( sal_False );
78 
79 	sal_uInt16 i;
80 
81 	aScrollTimer.SetTimeout(10);
82 	aScrollTimer.SetTimeoutHdl( LINK( this, ScTabView, TimerHdl ) );
83 
84 	for (i=0; i<4; i++)
85 		pGridWin[i] = NULL;
86 	pGridWin[SC_SPLIT_BOTTOMLEFT] = new ScGridWindow( pFrameWin, &aViewData, SC_SPLIT_BOTTOMLEFT );
87 
88 	pSelEngine = new ScViewSelectionEngine( pGridWin[SC_SPLIT_BOTTOMLEFT], this,
89 												SC_SPLIT_BOTTOMLEFT );
90 	aFunctionSet.SetSelectionEngine( pSelEngine );
91 
92 	pHdrSelEng = new ScHeaderSelectionEngine( pFrameWin, &aHdrFunc );
93 
94 	pColBar[SC_SPLIT_LEFT] = new ScColBar( pFrameWin, &aViewData, SC_SPLIT_LEFT,
95 												&aHdrFunc, pHdrSelEng );
96 	pColBar[SC_SPLIT_RIGHT] = NULL;
97 	pRowBar[SC_SPLIT_BOTTOM] = new ScRowBar( pFrameWin, &aViewData, SC_SPLIT_BOTTOM,
98 												&aHdrFunc, pHdrSelEng );
99 	pRowBar[SC_SPLIT_TOP] = NULL;
100 	for (i=0; i<2; i++)
101 		pColOutline[i] = pRowOutline[i] = NULL;
102 
103 	pHSplitter = new ScTabSplitter( pFrameWin, WinBits( WB_HSCROLL ), &aViewData );
104 	pVSplitter = new ScTabSplitter( pFrameWin, WinBits( WB_VSCROLL ), &aViewData );
105 
106     // SSA: override default keyboard step size to allow snap to row/column
107     pHSplitter->SetKeyboardStepSize( 1 );
108     pVSplitter->SetKeyboardStepSize( 1 );
109 
110 	pTabControl = new ScTabControl( pFrameWin, &aViewData );
111     /*  #i97900# The tab control has to remain in RTL mode if GUI is RTL, this
112         is needed to draw the 3D effect correctly. The base TabBar implementes
113         mirroring independent from the GUI direction. Have to set RTL mode
114         explicitly because the parent frame window is already RTL disabled. */
115     pTabControl->EnableRTL( Application::GetSettings().GetLayoutRTL() );
116 
117 	InitScrollBar( aHScrollLeft,	MAXCOL+1 );
118 	InitScrollBar( aHScrollRight,	MAXCOL+1 );
119 	InitScrollBar( aVScrollTop, 	MAXROW+1 );
120 	InitScrollBar( aVScrollBottom,	MAXROW+1 );
121     /*  #i97900# scrollbars remain in correct RTL mode, needed mirroring etc.
122         is now handled correctly at the respective places. */
123 
124 	//	Hier noch nichts anzeigen (Show), weil noch falsch angeordnet ist
125 	//	Show kommt dann aus UpdateShow beim ersten Resize
126 	//		pTabControl, pGridWin, aHScrollLeft, aVScrollBottom,
127 	//		aCornerButton, aScrollBarBox, pHSplitter, pVSplitter
128 
129 	//		Splitter
130 
131 	pHSplitter->SetSplitHdl( LINK( this, ScTabView, SplitHdl ) );
132 	pVSplitter->SetSplitHdl( LINK( this, ScTabView, SplitHdl ) );
133 
134 	//	UpdateShow kommt beim Resize, oder bei Kopie einer bestehenden View aus dem ctor
135 
136 	pDrawActual = NULL;
137 	pDrawOld	= NULL;
138 
139 			//	DrawView darf nicht im TabView - ctor angelegt werden,
140 			//	wenn die ViewShell noch nicht konstruiert ist...
141 			//	Das gilt auch fuer ViewOptionsHasChanged()
142 
143 	TestHintWindow();
144 }
145 
~ScTabView()146 __EXPORT ScTabView::~ScTabView()
147 {
148 	sal_uInt16 i;
149 
150 	//	remove selection object
151 	ScModule* pScMod = SC_MOD();
152 	ScSelectionTransferObj* pOld = pScMod->GetSelectionTransfer();
153 	if ( pOld && pOld->GetView() == this )
154 	{
155 		pOld->ForgetView();
156 		pScMod->SetSelectionTransfer( NULL );
157 		TransferableHelper::ClearSelection( GetActiveWin() );		// may delete pOld
158 	}
159 
160     DELETEZ(pBrushDocument);
161     DELETEZ(pDrawBrushSet);
162 
163 	DELETEZ(pPageBreakData);
164 	DELETEZ(pHighlightRanges);
165 
166 	DELETEZ(pDrawOld);
167 	DELETEZ(pDrawActual);
168 
169 	aViewData.KillEditView();			// solange GridWin's noch existieren
170 
171 	DELETEZ(pInputHintWindow);
172 
173 	if (pDrawView)
174 	{
175 		for (i=0; i<4; i++)
176 			if (pGridWin[i])
177 			{
178 				pDrawView->VCRemoveWin(pGridWin[i]);
179 				pDrawView->DeleteWindowFromPaintView(pGridWin[i]);
180 			}
181 
182 		pDrawView->HideSdrPage();
183 		delete pDrawView;
184 	}
185 
186 	delete pSelEngine;
187 
188 	for (i=0; i<4; i++)
189 		delete pGridWin[i];
190 
191 	delete pHdrSelEng;
192 
193 	for (i=0; i<2; i++)
194 	{
195 		delete pColBar[i];
196 		delete pRowBar[i];
197 		delete pColOutline[i];
198 		delete pRowOutline[i];
199 	}
200 
201 	delete pHSplitter;
202 	delete pVSplitter;
203 
204 	delete pTabControl;
205 }
206 
MakeDrawView(sal_uInt8 nForceDesignMode)207 void ScTabView::MakeDrawView( sal_uInt8 nForceDesignMode )
208 {
209 	if (!pDrawView)
210 	{
211 		ScDrawLayer* pLayer = aViewData.GetDocument()->GetDrawLayer();
212 		DBG_ASSERT(pLayer, "wo ist der Draw Layer ??");
213 
214 		sal_uInt16 i;
215 		pDrawView = new ScDrawView( pGridWin[SC_SPLIT_BOTTOMLEFT], &aViewData );
216 		for (i=0; i<4; i++)
217 			if (pGridWin[i])
218 			{
219 				if ( SC_SPLIT_BOTTOMLEFT != (ScSplitPos)i )
220 					pDrawView->AddWindowToPaintView(pGridWin[i]);
221 				pDrawView->VCAddWin(pGridWin[i]);
222 			}
223 		pDrawView->RecalcScale();
224 		for (i=0; i<4; i++)
225 			if (pGridWin[i])
226 			{
227 				pGridWin[i]->SetMapMode(pGridWin[i]->GetDrawMapMode());
228 
229 				pGridWin[i]->Update();		// wegen Invalidate im DrawView ctor (ShowPage),
230 											// damit gleich gezeichnet werden kann
231 			}
232 		SfxRequest aSfxRequest(SID_OBJECT_SELECT, 0,aViewData.GetViewShell()->GetPool());
233 		SetDrawFuncPtr(new FuSelection( aViewData.GetViewShell(), GetActiveWin(), pDrawView,
234 										pLayer,aSfxRequest));
235 
236 		//	#106334# used when switching back from page preview: restore saved design mode state
237 		//	(otherwise, keep the default from the draw view ctor)
238 		if ( nForceDesignMode != SC_FORCEMODE_NONE )
239 			pDrawView->SetDesignMode( (sal_Bool)nForceDesignMode );
240 
241 		//	an der FormShell anmelden
242 		FmFormShell* pFormSh = aViewData.GetViewShell()->GetFormShell();
243 		if (pFormSh)
244 			pFormSh->SetView(pDrawView);
245 
246 	    if (aViewData.GetViewShell()->HasAccessibilityObjects())
247 		    aViewData.GetViewShell()->BroadcastAccessibility(SfxSimpleHint(SC_HINT_ACC_MAKEDRAWLAYER));
248 
249 	}
250 }
251 
DoAddWin(ScGridWindow * pWin)252 void ScTabView::DoAddWin( ScGridWindow* pWin )
253 {
254 	if (pDrawView)
255 	{
256 		pDrawView->AddWindowToPaintView(pWin);
257 		pDrawView->VCAddWin(pWin);
258 
259 		// #114409#
260 		pWin->DrawLayerCreated();
261 	}
262 }
263 
264 //==================================================================
265 
TabChanged(bool bSameTabButMoved)266 void ScTabView::TabChanged( bool bSameTabButMoved )
267 {
268 	if (pDrawView)
269 	{
270 		DrawDeselectAll();		// beendet auch Text-Edit-Modus
271 
272 		sal_uInt16 i;
273 		for (i=0; i<4; i++)
274 			if (pGridWin[i])
275 				pDrawView->VCRemoveWin(pGridWin[i]);	// fuer alte Page
276 
277 		SCTAB nTab = aViewData.GetTabNo();
278 		pDrawView->HideSdrPage();
279 		pDrawView->ShowSdrPage(pDrawView->GetModel()->GetPage(nTab));
280 
281 		UpdateLayerLocks();
282 
283 		pDrawView->RecalcScale();
284 		pDrawView->UpdateWorkArea();	// #54782# PageSize ist pro Page unterschiedlich
285 
286 		for (i=0; i<4; i++)
287 			if (pGridWin[i])
288 				pDrawView->VCAddWin(pGridWin[i]);		// fuer neue Page
289 	}
290 
291 	SfxBindings& rBindings = aViewData.GetBindings();
292 
293 	//	Es gibt keine einfache Moeglichkeit, alle Slots der FormShell zu invalidieren
294 	//	(fuer disablete Slots auf geschuetzten Tabellen), darum hier einfach alles...
295 	rBindings.InvalidateAll(sal_False);
296 
297 #if 0
298 	rBindings.Invalidate( SID_SELECT_SCENARIO );
299 	rBindings.Invalidate( FID_PROTECT_TABLE );
300 	rBindings.Invalidate( FID_DELETE_TABLE );
301 	rBindings.Invalidate( FID_TABLE_SHOW );
302 	rBindings.Invalidate( FID_TABLE_HIDE );
303 
304 				// Auswirkungen von geschuetzten Tabellen.
305 	rBindings.Invalidate( FID_TAB_RENAME );
306 	rBindings.Invalidate( FID_TAB_MOVE );
307 	rBindings.Invalidate( SID_DEL_ROWS );
308 	rBindings.Invalidate( SID_DEL_COLS );
309 	rBindings.Invalidate( FID_INS_ROW );
310 	rBindings.Invalidate( FID_INS_COLUMN );
311 	rBindings.Invalidate( FID_INS_CELL );
312 	rBindings.Invalidate( FID_INS_CELLSDOWN	);
313 	rBindings.Invalidate( FID_INS_CELLSRIGHT );
314 	rBindings.Invalidate( FID_DELETE_CELL );
315 
316 	rBindings.Invalidate( SID_OPENDLG_CHART );
317 	rBindings.Invalidate( SID_INSERT_OBJECT );
318 	rBindings.Invalidate( SID_INSERT_DIAGRAM );
319 	rBindings.Invalidate( SID_INSERT_SMATH );
320 	rBindings.Invalidate( SID_INSERT_GRAPHIC );
321 #endif
322 
323 	if (aViewData.GetViewShell()->HasAccessibilityObjects())
324 	{
325 		SfxSimpleHint aAccHint(SC_HINT_ACC_TABLECHANGED);
326 		aViewData.GetViewShell()->BroadcastAccessibility(aAccHint);
327 	}
328 
329     // notification for XActivationBroadcaster
330     SfxViewFrame* pViewFrame = aViewData.GetViewShell()->GetViewFrame();
331     if (pViewFrame)
332     {
333         uno::Reference<frame::XController> xController = pViewFrame->GetFrame().GetController();
334         if (xController.is())
335         {
336             ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
337             if (pImp)
338                 pImp->SheetChanged( bSameTabButMoved );
339         }
340     }
341 }
342 
UpdateLayerLocks()343 void ScTabView::UpdateLayerLocks()
344 {
345 	if (pDrawView)
346 	{
347 		SCTAB nTab = aViewData.GetTabNo();
348 		sal_Bool bEx = aViewData.GetViewShell()->IsDrawSelMode();
349 		sal_Bool bProt = aViewData.GetDocument()->IsTabProtected( nTab ) ||
350 					 aViewData.GetSfxDocShell()->IsReadOnly();
351         sal_Bool bShared = aViewData.GetDocShell()->IsDocShared();
352 
353 		SdrLayer* pLayer;
354 		SdrLayerAdmin& rAdmin = pDrawView->GetModel()->GetLayerAdmin();
355 		pLayer = rAdmin.GetLayerPerID(SC_LAYER_BACK);
356 		if (pLayer)
357 			pDrawView->SetLayerLocked( pLayer->GetName(), bProt || !bEx || bShared );
358 		pLayer = rAdmin.GetLayerPerID(SC_LAYER_INTERN);
359 		if (pLayer)
360 			pDrawView->SetLayerLocked( pLayer->GetName(), sal_True );
361 		pLayer = rAdmin.GetLayerPerID(SC_LAYER_FRONT);
362 		if (pLayer)
363 			pDrawView->SetLayerLocked( pLayer->GetName(), bProt || bShared );
364 		pLayer = rAdmin.GetLayerPerID(SC_LAYER_CONTROLS);
365 		if (pLayer)
366 			pDrawView->SetLayerLocked( pLayer->GetName(), bProt || bShared );
367 		pLayer = rAdmin.GetLayerPerID(SC_LAYER_HIDDEN);
368 		if (pLayer)
369         {
370 			pDrawView->SetLayerLocked( pLayer->GetName(), bProt || bShared );
371             pDrawView->SetLayerVisible( pLayer->GetName(), sal_False);
372         }
373 	}
374 }
375 
DrawDeselectAll()376 void ScTabView::DrawDeselectAll()
377 {
378 	if (pDrawView)
379 	{
380 		ScTabViewShell* pViewSh = aViewData.GetViewShell();
381 		if ( pDrawActual &&
382 			( pViewSh->IsDrawTextShell() || pDrawActual->GetSlotID() == SID_DRAW_NOTEEDIT ) )
383 		{
384 			// end text edit (as if escape pressed, in FuDraw)
385 			aViewData.GetDispatcher().Execute( pDrawActual->GetSlotID(),
386 										SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD );
387 		}
388 
389 		pDrawView->ScEndTextEdit();
390 		pDrawView->UnmarkAll();
391 
392 		if (!pViewSh->IsDrawSelMode())
393 			pViewSh->SetDrawShell( sal_False );
394 	}
395 }
396 
IsDrawTextEdit() const397 sal_Bool ScTabView::IsDrawTextEdit() const
398 {
399 	if (pDrawView)
400 		return pDrawView->IsTextEdit();
401 	else
402 		return sal_False;
403 }
404 
405 //UNUSED2008-05  String ScTabView::GetSelectedChartName() const
406 //UNUSED2008-05  {
407 //UNUSED2008-05      if (pDrawView)
408 //UNUSED2008-05          return pDrawView->GetSelectedChartName();
409 //UNUSED2008-05      else
410 //UNUSED2008-05          return EMPTY_STRING;
411 //UNUSED2008-05  }
412 
GetZoomType() const413 SvxZoomType ScTabView::GetZoomType() const
414 {
415     return aViewData.GetZoomType();
416 }
417 
SetZoomType(SvxZoomType eNew,sal_Bool bAll)418 void ScTabView::SetZoomType( SvxZoomType eNew, sal_Bool bAll )
419 {
420     aViewData.SetZoomType( eNew, bAll );
421 }
422 
SetZoom(const Fraction & rNewX,const Fraction & rNewY,sal_Bool bAll)423 void ScTabView::SetZoom( const Fraction& rNewX, const Fraction& rNewY, sal_Bool bAll )
424 {
425     aViewData.SetZoom( rNewX, rNewY, bAll );
426 	if (pDrawView)
427 		pDrawView->RecalcScale();
428 	ZoomChanged();				// einzeln wegen CLOOKs
429 }
430 
RefreshZoom()431 void ScTabView::RefreshZoom()
432 {
433     aViewData.RefreshZoom();
434     if (pDrawView)
435         pDrawView->RecalcScale();
436     ZoomChanged();
437 }
438 
SetPagebreakMode(sal_Bool bSet)439 void ScTabView::SetPagebreakMode( sal_Bool bSet )
440 {
441 	aViewData.SetPagebreakMode(bSet);
442 	if (pDrawView)
443 		pDrawView->RecalcScale();
444 	ZoomChanged();				// einzeln wegen CLOOKs
445 }
446 
ResetDrawDragMode()447 void ScTabView::ResetDrawDragMode()
448 {
449 	if (pDrawView)
450 		pDrawView->SetDragMode( SDRDRAG_MOVE );
451 }
452 
ViewOptionsHasChanged(sal_Bool bHScrollChanged,sal_Bool bGraphicsChanged)453 void ScTabView::ViewOptionsHasChanged( sal_Bool bHScrollChanged, sal_Bool bGraphicsChanged )
454 {
455 	//	DrawView erzeugen, wenn Gitter angezeigt werden soll
456 	if ( !pDrawView && aViewData.GetOptions().GetGridOptions().GetGridVisible() )
457 		MakeDrawLayer();
458 
459 	if (pDrawView)
460 		pDrawView->UpdateUserViewOptions();
461 
462 	if (bGraphicsChanged)
463 		DrawEnableAnim(sal_True);	// DrawEnableAnim checks the options state
464 
465 	// if TabBar is set to visible, make sure its size is not 0
466 	sal_Bool bGrow = ( aViewData.IsTabMode() && pTabControl->GetSizePixel().Width() <= 0 );
467 
468 	// if ScrollBar is set to visible, TabBar must make room
469 	sal_Bool bShrink = ( bHScrollChanged && aViewData.IsTabMode() && aViewData.IsHScrollMode() &&
470 						pTabControl->GetSizePixel().Width() > SC_TABBAR_DEFWIDTH );
471 
472 	if ( bGrow || bShrink )
473 	{
474 		Size aSize = pTabControl->GetSizePixel();
475 		aSize.Width() = SC_TABBAR_DEFWIDTH;				// initial size
476 		pTabControl->SetSizePixel(aSize);				// DoResize is called later...
477 	}
478 }
479 
480 // Helper-Funktion gegen das Include des Drawing Layers
481 
GetSdrView()482 SdrView* ScTabView::GetSdrView()
483 {
484 	return pDrawView;
485 }
486 
DrawMarkListHasChanged()487 void ScTabView::DrawMarkListHasChanged()
488 {
489 	if ( pDrawView )
490 		pDrawView->MarkListHasChanged();
491 }
492 
UpdateAnchorHandles()493 void ScTabView::UpdateAnchorHandles()
494 {
495 	if ( pDrawView )
496 		pDrawView->AdjustMarkHdl();
497 }
498 
UpdateIMap(SdrObject * pObj)499 void ScTabView::UpdateIMap( SdrObject* pObj )
500 {
501 	if ( pDrawView )
502 		pDrawView->UpdateIMap( pObj );
503 }
504 
DrawMarkRect(const Rectangle & rRect)505 void ScTabView::DrawMarkRect( const Rectangle& rRect )
506 {
507 	//!	store rectangle for repaint during drag
508 
509 	for (sal_uInt16 i=0; i<4; i++)
510 	{
511 		if ( pGridWin[i] && pGridWin[i]->IsVisible() )
512 		{
513 			RasterOp aROp = pGridWin[i]->GetRasterOp();
514 			sal_Bool bHasLine = pGridWin[i]->IsLineColor();
515 			Color aLine	  = pGridWin[i]->GetLineColor();
516 			sal_Bool bHasFill = pGridWin[i]->IsFillColor();
517 			Color aFill   = pGridWin[i]->GetFillColor();
518 
519 			pGridWin[i]->SetRasterOp( ROP_INVERT );
520 			pGridWin[i]->SetLineColor( COL_BLACK );
521 			pGridWin[i]->SetFillColor();
522 
523 			pGridWin[i]->DrawRect(rRect);
524 
525 			pGridWin[i]->SetRasterOp(aROp);
526 			if (bHasLine)
527 				pGridWin[i]->SetLineColor(aLine);
528 			else
529 				pGridWin[i]->SetLineColor();
530 			if (bHasFill)
531 				pGridWin[i]->SetFillColor(aFill);
532 			else
533 				pGridWin[i]->SetFillColor();
534 		}
535 	}
536 }
537 
DrawEnableAnim(sal_Bool bSet)538 void ScTabView::DrawEnableAnim(sal_Bool bSet)
539 {
540 	sal_uInt16 i;
541 	if ( pDrawView )
542 	{
543 		//	#71040# dont start animations if display of graphics is disabled
544 		//	graphics are controlled by VOBJ_TYPE_OLE
545 		if ( bSet && aViewData.GetOptions().GetObjMode(VOBJ_TYPE_OLE) == VOBJ_MODE_SHOW )
546 		{
547 			if ( !pDrawView->IsAnimationEnabled() )
548 			{
549 				pDrawView->SetAnimationEnabled(sal_True);
550 
551 				//	Animierte GIFs muessen wieder gestartet werden:
552 				ScDocument* pDoc = aViewData.GetDocument();
553 				for (i=0; i<4; i++)
554 					if ( pGridWin[i] && pGridWin[i]->IsVisible() )
555 						pDoc->StartAnimations( aViewData.GetTabNo(), pGridWin[i] );
556 			}
557 		}
558 		else
559 		{
560 			pDrawView->SetAnimationEnabled(sal_False);
561 		}
562 	}
563 }
564 
565 //HMHvoid ScTabView::DrawShowMarkHdl(sal_Bool bShow)
566 //HMH{
567 	//HMHif (!pDrawView)
568 	//HMH	return;
569 
570 	//HMHif (bShow)
571 	//HMH{
572 	//HMH	if (!pDrawView->IsDisableHdl())
573 	//HMH		pDrawView->ShowMarkHdl();
574 	//HMH}
575 	//HMHelse
576 	//HMH	pDrawView->HideMarkHdl();
577 //HMH}
578 
UpdateDrawTextOutliner()579 void ScTabView::UpdateDrawTextOutliner()
580 {
581 	if ( pDrawView )
582 	{
583 		Outliner* pOL = pDrawView->GetTextEditOutliner();
584 		if (pOL)
585 			aViewData.UpdateOutlinerFlags( *pOL );
586 	}
587 }
588 
DigitLanguageChanged()589 void ScTabView::DigitLanguageChanged()
590 {
591 	LanguageType eNewLang = SC_MOD()->GetOptDigitLanguage();
592 	for (sal_uInt16 i=0; i<4; i++)
593 		if ( pGridWin[i] )
594 			pGridWin[i]->SetDigitLanguage( eNewLang );
595 }
596 
597 //---------------------------------------------------------------
598 
ScrollToObject(SdrObject * pDrawObj)599 void ScTabView::ScrollToObject( SdrObject* pDrawObj )
600 {
601 	if ( pDrawObj )
602     {
603         // #i118524# use the BoundRect, this defines the visible area
604 		MakeVisible(pDrawObj->GetCurrentBoundRect());
605     }
606 }
607 
MakeVisible(const Rectangle & rHMMRect)608 void ScTabView::MakeVisible( const Rectangle& rHMMRect )
609 {
610 	Window* pWin = GetActiveWin();
611 	Size aWinSize = pWin->GetOutputSizePixel();
612 	SCTAB nTab = aViewData.GetTabNo();
613 
614 	Rectangle aRect = pWin->LogicToPixel( rHMMRect );
615 
616 	long nScrollX=0, nScrollY=0;		// Pixel
617 
618 	if ( aRect.Right() >= aWinSize.Width() )				// rechts raus
619 	{
620 		nScrollX = aRect.Right() - aWinSize.Width() + 1;	// rechter Rand sichtbar
621 		if ( aRect.Left() < nScrollX )
622 			nScrollX = aRect.Left();						// links sichtbar (falls zu gross)
623 	}
624 	if ( aRect.Bottom() >= aWinSize.Height() )				// unten raus
625 	{
626 		nScrollY = aRect.Bottom() - aWinSize.Height() + 1;	// unterer Rand sichtbar
627 		if ( aRect.Top() < nScrollY )
628 			nScrollY = aRect.Top();							// oben sichtbar (falls zu gross)
629 	}
630 
631 	if ( aRect.Left() < 0 )				// links raus
632 		nScrollX = aRect.Left();		// linker Rand sichtbar
633 	if ( aRect.Top() < 0 )				// oben raus
634 		nScrollY = aRect.Top();			// oberer Rand sichtbar
635 
636 	if (nScrollX || nScrollY)
637 	{
638 		ScDocument* pDoc = aViewData.GetDocument();
639 		if ( pDoc->IsNegativePage( nTab ) )
640 			nScrollX = -nScrollX;
641 
642 		double nPPTX = aViewData.GetPPTX();
643 		double nPPTY = aViewData.GetPPTY();
644 		ScSplitPos eWhich = aViewData.GetActivePart();
645 		SCCOL nPosX = aViewData.GetPosX(WhichH(eWhich));
646 		SCROW nPosY = aViewData.GetPosY(WhichV(eWhich));
647 
648 		long nLinesX=0, nLinesY=0;		// Spalten/Zeilen - um mindestens nScrollX/Y scrollen
649 
650 		if (nScrollX > 0)
651 			while (nScrollX > 0 && nPosX < MAXCOL)
652 			{
653 				nScrollX -= (long) ( pDoc->GetColWidth(nPosX, nTab) * nPPTX );
654 				++nPosX;
655 				++nLinesX;
656 			}
657 		else if (nScrollX < 0)
658 			while (nScrollX < 0 && nPosX > 0)
659 			{
660 				--nPosX;
661 				nScrollX += (long) ( pDoc->GetColWidth(nPosX, nTab) * nPPTX );
662 				--nLinesX;
663 			}
664 
665 		if (nScrollY > 0)
666 			while (nScrollY > 0 && nPosY < MAXROW)
667 			{
668 				nScrollY -= (long) ( pDoc->GetRowHeight(nPosY, nTab) * nPPTY );
669 				++nPosY;
670 				++nLinesY;
671 			}
672 		else if (nScrollY < 0)
673 			while (nScrollY < 0 && nPosY > 0)
674 			{
675 				--nPosY;
676 				nScrollY += (long) ( pDoc->GetRowHeight(nPosY, nTab) * nPPTY );
677 				--nLinesY;
678 			}
679 
680 		ScrollLines( nLinesX, nLinesY );					// ausfuehren
681 	}
682 }
683 
684 //---------------------------------------------------------------
685 
SetBrushDocument(ScDocument * pNew,sal_Bool bLock)686 void ScTabView::SetBrushDocument( ScDocument* pNew, sal_Bool bLock )
687 {
688     delete pBrushDocument;
689     delete pDrawBrushSet;
690 
691     pBrushDocument = pNew;
692     pDrawBrushSet = NULL;
693 
694     bLockPaintBrush = bLock;
695 
696     aViewData.GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
697 }
698 
SetDrawBrushSet(SfxItemSet * pNew,sal_Bool bLock)699 void ScTabView::SetDrawBrushSet( SfxItemSet* pNew, sal_Bool bLock )
700 {
701     delete pBrushDocument;
702     delete pDrawBrushSet;
703 
704     pBrushDocument = NULL;
705     pDrawBrushSet = pNew;
706 
707     bLockPaintBrush = bLock;
708 
709     aViewData.GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
710 }
711 
ResetBrushDocument()712 void ScTabView::ResetBrushDocument()
713 {
714     if ( HasPaintBrush() )
715     {
716         SetBrushDocument( NULL, sal_False );
717         SetActivePointer( Pointer( POINTER_ARROW ) );   // switch pointers also when ended with escape key
718     }
719 }
720 
721 
722