xref: /aoo41x/main/sc/source/ui/view/tabcont.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sc.hxx"
30 
31 
32 
33 // INCLUDE ---------------------------------------------------------------
34 
35 #include <sfx2/viewfrm.hxx>
36 #include <sfx2/dispatch.hxx>
37 #include <sfx2/docfile.hxx>
38 #include <vcl/sound.hxx>
39 #include <tools/urlobj.hxx>
40 #include <vcl/svapp.hxx>
41 #include "tabcont.hxx"
42 #include "tabvwsh.hxx"
43 #include "docsh.hxx"
44 #include "scmod.hxx"
45 #include "scresid.hxx"
46 #include "sc.hrc"
47 #include "globstr.hrc"
48 #include "transobj.hxx"
49 #include "clipparam.hxx"
50 
51 
52 // STATIC DATA -----------------------------------------------------------
53 
54 //==================================================================
55 
56 ScTabControl::ScTabControl( Window* pParent, ScViewData* pData ) :
57 			TabBar( pParent, WinBits( WB_BORDER | WB_3DLOOK | WB_SCROLL |
58 									WB_RANGESELECT | WB_MULTISELECT | WB_DRAG | WB_SIZEABLE ) ),
59 			DropTargetHelper( this ),
60 			DragSourceHelper( this ),
61 			pViewData( pData ),
62             nMouseClickPageId( TabBar::PAGE_NOT_FOUND ),
63             nSelPageIdByMouse( TabBar::PAGE_NOT_FOUND ),
64             bErrorShown( sal_False )
65 {
66 	ScDocument* pDoc = pViewData->GetDocument();
67 
68 	String aString;
69     Color aTabBgColor;
70 	SCTAB nCount = pDoc->GetTableCount();
71 	for (SCTAB i=0; i<nCount; i++)
72 	{
73 		if (pDoc->IsVisible(i))
74 		{
75 			if (pDoc->GetName(i,aString))
76 			{
77 				if ( pDoc->IsScenario(i) )
78 					InsertPage( static_cast<sal_uInt16>(i)+1, aString, TPB_SPECIAL );
79 				else
80 					InsertPage( static_cast<sal_uInt16>(i)+1, aString );
81                 if ( !pDoc->IsDefaultTabBgColor(i) )
82                 {
83                     aTabBgColor = pDoc->GetTabBgColor(i);
84                     SetTabBgColor( static_cast<sal_uInt16>(i)+1, aTabBgColor );
85                 }
86 			}
87 		}
88 	}
89 
90 	SetCurPageId( static_cast<sal_uInt16>(pViewData->GetTabNo()) + 1 );
91 
92 	SetSizePixel( Size(SC_TABBAR_DEFWIDTH, 0) );
93 
94 	SetSplitHdl( LINK( pViewData->GetView(), ScTabView, TabBarResize ) );
95 
96 	EnableEditMode();
97 }
98 
99 ScTabControl::~ScTabControl()
100 {
101 }
102 
103 sal_uInt16 ScTabControl::GetMaxId() const
104 {
105 	sal_uInt16 nVisCnt = GetPageCount();
106 	if (nVisCnt)
107 		return GetPageId(nVisCnt-1);
108 
109 	return 0;
110 }
111 
112 SCTAB ScTabControl::GetPrivatDropPos(const Point& rPos )
113 {
114 	sal_uInt16 nPos = ShowDropPos(rPos);
115 
116 	SCTAB nRealPos = static_cast<SCTAB>(nPos);
117 
118 	if(nPos !=0 )
119 	{
120 		ScDocument* pDoc = pViewData->GetDocument();
121 
122 		SCTAB nCount = pDoc->GetTableCount();
123 
124 		sal_uInt16 nViewPos=0;
125 		nRealPos = nCount;
126 		for (SCTAB i=0; i<nCount; i++)
127 		{
128 			if (pDoc->IsVisible(i))
129 			{
130 				nViewPos++;
131 				if(nViewPos==nPos)
132 				{
133 					SCTAB j;
134 					for (j=i+1; j<nCount; j++)
135 					{
136 						if (pDoc->IsVisible(j))
137 						{
138 							break;
139 						}
140 					}
141 					nRealPos =j;
142 					break;
143 				}
144 			}
145 		}
146 	}
147 	return nRealPos ;
148 }
149 
150 void ScTabControl::MouseButtonDown( const MouseEvent& rMEvt )
151 {
152 	ScModule* pScMod = SC_MOD();
153 	if ( !pScMod->IsModalMode() && !pScMod->IsFormulaMode() && !IsInEditMode() )
154 	{
155 		//	View aktivieren
156 		pViewData->GetViewShell()->SetActive();			// Appear und SetViewFrame
157 		pViewData->GetView()->ActiveGrabFocus();
158 	}
159 
160     /*  #47745# Click into free area -> insert new sheet (like in Draw).
161         Needing clean left click without modifiers (may be context menu).
162         #106948# Remember clicks to all pages, to be able to move mouse pointer later. */
163     if( rMEvt.IsLeft() && (rMEvt.GetModifier() == 0) )
164         nMouseClickPageId = GetPageId( rMEvt.GetPosPixel() );
165     else
166         nMouseClickPageId = TabBar::PAGE_NOT_FOUND;
167 
168 	TabBar::MouseButtonDown( rMEvt );
169 }
170 
171 void ScTabControl::MouseButtonUp( const MouseEvent& rMEvt )
172 {
173     Point aPos = PixelToLogic( rMEvt.GetPosPixel() );
174 
175     // mouse button down and up on same page?
176     if( nMouseClickPageId != GetPageId( aPos ) )
177         nMouseClickPageId = TabBar::PAGE_NOT_FOUND;
178 
179     if ( rMEvt.GetClicks() == 2 && rMEvt.IsLeft() && nMouseClickPageId != 0 && nMouseClickPageId != TAB_PAGE_NOTFOUND )
180     {
181         SfxDispatcher* pDispatcher = pViewData->GetViewShell()->GetViewFrame()->GetDispatcher();
182         pDispatcher->Execute( FID_TAB_MENU_RENAME, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD );
183     }
184 
185     if( nMouseClickPageId == 0 )
186     {
187         // Click in the area next to the existing tabs:
188         // #i70320# if several sheets are selected, deselect all ecxept the current sheet,
189         // otherwise add new sheet
190         sal_uInt16 nSlot = ( GetSelectPageCount() > 1 ) ? FID_TAB_DESELECTALL : FID_INS_TABLE;
191         SfxDispatcher* pDispatcher = pViewData->GetViewShell()->GetViewFrame()->GetDispatcher();
192         pDispatcher->Execute( nSlot, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD );
193         // forget page ID, to be really sure that the dialog is not called twice
194         nMouseClickPageId = TabBar::PAGE_NOT_FOUND;
195     }
196 
197 	TabBar::MouseButtonUp( rMEvt );
198 }
199 
200 void ScTabControl::Select()
201 {
202     /*  Remember last clicked page ID. */
203     nSelPageIdByMouse = nMouseClickPageId;
204     /*  Reset nMouseClickPageId, so that next Select() call may invalidate
205         nSelPageIdByMouse (i.e. if called from keyboard). */
206     nMouseClickPageId = TabBar::PAGE_NOT_FOUND;
207 
208 	ScModule* pScMod = SC_MOD();
209 	ScDocument* pDoc = pViewData->GetDocument();
210 	ScMarkData& rMark = pViewData->GetMarkData();
211 	SCTAB nCount = pDoc->GetTableCount();
212 	SCTAB i;
213 
214 	if ( pScMod->IsTableLocked() )		// darf jetzt nicht umgeschaltet werden ?
215 	{
216 		//	den alten Zustand des TabControls wiederherstellen:
217 
218 		for (i=0; i<nCount; i++)
219 			SelectPage( static_cast<sal_uInt16>(i)+1, rMark.GetTableSelect(i) );
220 		SetCurPageId( static_cast<sal_uInt16>(pViewData->GetTabNo()) + 1 );
221 
222 		Sound::Beep();
223 		return;
224 	}
225 
226 	sal_uInt16 nCurId = GetCurPageId();
227 	if (!nCurId) return;			// kann vorkommen, wenn bei Excel-Import alles versteckt ist
228 	sal_uInt16 nPage = nCurId - 1;
229 
230 	// OLE-inplace deaktivieren
231 	if ( nPage != static_cast<sal_uInt16>(pViewData->GetTabNo()) )
232 		pViewData->GetView()->DrawMarkListHasChanged();
233 
234 	//	InputEnterHandler nur wenn nicht Referenzeingabe
235 
236 	sal_Bool bRefMode = pScMod->IsFormulaMode();
237 	if (!bRefMode)
238 		pScMod->InputEnterHandler();
239 
240 	for (i=0; i<nCount; i++)
241 		rMark.SelectTable( i, IsPageSelected(static_cast<sal_uInt16>(i)+1) );
242 
243 /*		Markierungen werden per Default nicht pro Tabelle gehalten
244 	sal_uInt16 nSelCnt = GetSelectPageCount();
245 	if (nSelCnt>1)
246 		pDoc->ExtendMarksFromTable( nPage );
247 */
248 
249 	SfxDispatcher& rDisp = pViewData->GetDispatcher();
250 	if (rDisp.IsLocked())
251 		pViewData->GetView()->SetTabNo( static_cast<SCTAB>(nPage) );
252 	else
253 	{
254 		//	Tabelle fuer Basic ist 1-basiert
255 		SfxUInt16Item aItem( SID_CURRENTTAB, nPage + 1 );
256 		rDisp.Execute( SID_CURRENTTAB, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
257 								&aItem, (void*) NULL );
258 	}
259 
260 	SfxBindings& rBind = pViewData->GetBindings();
261 	rBind.Invalidate( FID_FILL_TAB );
262     rBind.Invalidate( FID_TAB_DESELECTALL );
263 
264 	rBind.Invalidate( FID_INS_TABLE );
265 	rBind.Invalidate( FID_TAB_APPEND );
266 	rBind.Invalidate( FID_TAB_MOVE );
267 	rBind.Invalidate( FID_TAB_RENAME );
268 	rBind.Invalidate( FID_DELETE_TABLE );
269 	rBind.Invalidate( FID_TABLE_SHOW );
270 	rBind.Invalidate( FID_TABLE_HIDE );
271     rBind.Invalidate( FID_TAB_SET_TAB_BG_COLOR );
272 
273 		//	SetReference nur wenn der Konsolidieren-Dialog offen ist
274 		//	(fuer Referenzen ueber mehrere Tabellen)
275 		//	bei anderen gibt das nur unnoetiges Gezappel
276 
277 	if ( bRefMode && pViewData->GetRefType() == SC_REFTYPE_REF )
278 		if ( pViewData->GetViewShell()->GetViewFrame()->HasChildWindow(SID_OPENDLG_CONSOLIDATE) )
279 		{
280 			ScRange aRange(
281 					pViewData->GetRefStartX(), pViewData->GetRefStartY(), pViewData->GetRefStartZ(),
282 					pViewData->GetRefEndX(), pViewData->GetRefEndY(), pViewData->GetRefEndZ() );
283 			pScMod->SetReference( aRange, pDoc, &rMark );
284 			pScMod->EndReference();						// wegen Auto-Hide
285 		}
286 }
287 
288 void ScTabControl::UpdateStatus()
289 {
290 	ScDocument* pDoc = pViewData->GetDocument();
291 	ScMarkData& rMark = pViewData->GetMarkData();
292 	sal_Bool bActive = pViewData->IsActive();
293 
294 	SCTAB nCount = pDoc->GetTableCount();
295 	SCTAB i;
296 	String aString;
297 	SCTAB nMaxCnt = Max( nCount, static_cast<SCTAB>(GetMaxId()) );
298     Color aTabBgColor;
299 
300 	sal_Bool bModified = sal_False;										// Tabellen-Namen
301 	for (i=0; i<nMaxCnt && !bModified; i++)
302 	{
303 		if (pDoc->IsVisible(i))
304         {
305 			pDoc->GetName(i,aString);
306             aTabBgColor = pDoc->GetTabBgColor(i);
307         }
308 		else
309         {
310 			aString.Erase();
311         }
312 
313         if ( (GetPageText(static_cast<sal_uInt16>(i)+1) != aString) || (GetTabBgColor(static_cast<sal_uInt16>(i)+1) != aTabBgColor) )
314 			bModified = sal_True;
315 	}
316 
317 	if (bModified)
318 	{
319 		Clear();
320 		for (i=0; i<nCount; i++)
321 		{
322 			if (pDoc->IsVisible(i))
323 			{
324 				if (pDoc->GetName(i,aString))
325 				{
326 					if ( pDoc->IsScenario(i) )
327 						InsertPage( static_cast<sal_uInt16>(i)+1, aString, TPB_SPECIAL );
328 					else
329 						InsertPage( static_cast<sal_uInt16>(i)+1, aString );
330                     if ( !pDoc->IsDefaultTabBgColor(i) )
331                     {
332                         aTabBgColor = pDoc->GetTabBgColor(i);
333                         SetTabBgColor( static_cast<sal_uInt16>(i)+1, aTabBgColor );
334                     }
335 				}
336 			}
337 		}
338 	}
339 	SetCurPageId( static_cast<sal_uInt16>(pViewData->GetTabNo()) + 1 );
340 
341 	if (bActive)
342 	{
343 		bModified = sal_False;											// Selektion
344 		for (i=0; i<nMaxCnt && !bModified; i++)
345 			if ( rMark.GetTableSelect(i) != IsPageSelected(static_cast<sal_uInt16>(i)+1) )
346 				bModified = sal_True;
347 
348         // #i99576# the following loop is mis-optimized on unxsoli4 and the reason
349         // why this file is in NOOPTFILES.
350 		if ( bModified )
351 			for (i=0; i<nCount; i++)
352 				SelectPage( static_cast<sal_uInt16>(i)+1, rMark.GetTableSelect(i) );
353 	}
354 	else
355 	{
356 	}
357 }
358 
359 void ScTabControl::ActivateView(sal_Bool bActivate)
360 {
361 //	ScDocument* pDoc = pViewData->GetDocument();
362 	ScMarkData& rMark = pViewData->GetMarkData();
363 
364 //	ResetMark direkt in TabView
365 //	pDoc->ResetMark();
366 
367 	sal_uInt16 nCurId = GetCurPageId();
368 	if (!nCurId) return;			// kann vorkommen, wenn bei Excel-Import alles versteckt ist
369 	sal_uInt16 nPage = nCurId - 1;
370 //    sal_uInt16 nCount = GetMaxId();
371 
372 	/*
373 	sal_uInt16 i;
374 	for (i=0; i<nCount; i++)
375 	{
376 		SelectPage( i+1, sal_False );
377 		if (bActivate)
378 			rMark.SelectTable( i, sal_False );
379 	}
380 	*/
381 	if (bActivate)
382 	{
383 		SelectPage( nPage+1, sal_True );
384 		rMark.SelectTable( static_cast<SCTAB>(nPage), sal_True );
385 	}
386 	Invalidate();
387 }
388 
389 void ScTabControl::SetSheetLayoutRTL( sal_Bool bSheetRTL )
390 {
391     SetEffectiveRTL( bSheetRTL );
392     nSelPageIdByMouse = TabBar::PAGE_NOT_FOUND;
393 }
394 
395 
396 void ScTabControl::Command( const CommandEvent& rCEvt )
397 {
398 	ScModule*		pScMod	 = SC_MOD();
399 	ScTabViewShell* pViewSh  = pViewData->GetViewShell();
400 	sal_Bool 			bDisable = pScMod->IsFormulaMode() || pScMod->IsModalMode();
401 
402 	// ViewFrame erstmal aktivieren (Bug 19493):
403 	pViewSh->SetActive();
404 
405 	sal_uInt16 nCmd = rCEvt.GetCommand();
406 	if ( nCmd == COMMAND_CONTEXTMENU )
407 	{
408 		if (!bDisable)
409 		{
410             // #i18735# select the page that is under the mouse cursor
411             // if multiple tables are selected and the one under the cursor
412             // is not part of them then unselect them
413 			sal_uInt16 nId = GetPageId( rCEvt.GetMousePosPixel() );
414 			if (nId)
415 			{
416                 sal_Bool bAlreadySelected = IsPageSelected( nId );
417                 //make the clicked page the current one
418                 SetCurPageId( nId );
419                 //change the selection when the current one is not already
420                 //selected or part of a multi selection
421                 if(!bAlreadySelected)
422                 {
423                     sal_uInt16 nCount = GetMaxId();
424 
425                     for (sal_uInt16 i=1; i<=nCount; i++)
426                         SelectPage( i, i==nId );
427                     Select();
428                 }
429 			}
430 
431             // #i52073# OLE inplace editing has to be stopped before showing the sheet tab context menu
432             pViewSh->DeactivateOle();
433 
434 			//	Popup-Menu:
435 			//	get Dispatcher from ViewData (ViewFrame) instead of Shell (Frame), so it can't be null
436 			pViewData->GetDispatcher().ExecutePopup( ScResId(RID_POPUP_TAB) );
437 		}
438 	}
439 }
440 
441 void ScTabControl::StartDrag( sal_Int8 /* nAction */, const Point& rPosPixel )
442 {
443 	ScModule* pScMod = SC_MOD();
444 	sal_Bool bDisable = pScMod->IsFormulaMode() || pScMod->IsModalMode();
445 
446 	if (!bDisable)
447 	{
448 		Region aRegion( Rectangle(0,0,0,0) );
449 		CommandEvent aCEvt( rPosPixel, COMMAND_STARTDRAG, sal_True );	// needed for StartDrag
450 		if (TabBar::StartDrag( aCEvt, aRegion ))
451 			DoDrag( aRegion );
452 	}
453 }
454 
455 void ScTabControl::DoDrag( const Region& /* rRegion */ )
456 {
457 	ScDocShell* pDocSh = pViewData->GetDocShell();
458 	ScDocument* pDoc = pDocSh->GetDocument();
459 
460 	SCTAB nTab = pViewData->GetTabNo();
461     ScRange aTabRange( 0, 0, nTab, MAXCOL, MAXROW, nTab );
462 	ScMarkData aTabMark = pViewData->GetMarkData();
463 	aTabMark.ResetMark();	// doesn't change marked table information
464     aTabMark.SetMarkArea( aTabRange );
465 
466 	ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
467     ScClipParam aClipParam(aTabRange, false);
468     pDoc->CopyToClip(aClipParam, pClipDoc, &aTabMark, false);
469 
470 	TransferableObjectDescriptor aObjDesc;
471 	pDocSh->FillTransferableObjectDescriptor( aObjDesc );
472 	aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
473 	// maSize is set in ScTransferObj ctor
474 
475 	ScTransferObj* pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
476 	com::sun::star::uno::Reference<com::sun::star::datatransfer::XTransferable> xTransferable( pTransferObj );
477 
478 	pTransferObj->SetDragSourceFlags( SC_DROP_TABLE );
479 
480 	pTransferObj->SetDragSource( pDocSh, aTabMark );
481 
482 	Window* pWindow = pViewData->GetActiveWin();
483 	SC_MOD()->SetDragObject( pTransferObj, NULL );		// for internal D&D
484 	pTransferObj->StartDrag( pWindow, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
485 }
486 
487 sal_uInt16 lcl_DocShellNr( ScDocument* pDoc )
488 {
489 	sal_uInt16 nShellCnt = 0;
490 	SfxObjectShell* pShell = SfxObjectShell::GetFirst();
491 	while ( pShell )
492 	{
493 		if ( pShell->Type() == TYPE(ScDocShell) )
494 		{
495 			if ( ((ScDocShell*)pShell)->GetDocument() == pDoc )
496 				return nShellCnt;
497 
498 			++nShellCnt;
499 		}
500 		pShell = SfxObjectShell::GetNext( *pShell );
501 	}
502 
503 	DBG_ERROR("Dokument nicht gefunden");
504 	return 0;
505 }
506 
507 sal_Int8 ScTabControl::ExecuteDrop( const ExecuteDropEvent& rEvt )
508 {
509 	EndSwitchPage();
510 
511 	ScDocument* pDoc = pViewData->GetDocument();
512 	const ScDragData& rData = SC_MOD()->GetDragData();
513 	if ( rData.pCellTransfer && ( rData.pCellTransfer->GetDragSourceFlags() & SC_DROP_TABLE ) &&
514 			rData.pCellTransfer->GetSourceDocument() == pDoc )
515 	{
516 		// moving of tables within the document
517 		SCTAB nPos = GetPrivatDropPos( rEvt.maPosPixel );
518 		HideDropPos();
519 
520         if ( nPos == rData.pCellTransfer->GetVisibleTab() && rEvt.mnAction == DND_ACTION_MOVE )
521         {
522             // #i83005# do nothing - don't move to the same position
523             // (too easily triggered unintentionally, and might take a long time in large documents)
524         }
525         else
526         {
527             if ( !pDoc->GetChangeTrack() && pDoc->IsDocEditable() )
528             {
529                 //! use table selection from the tab control where dragging was started?
530                 pViewData->GetView()->MoveTable( lcl_DocShellNr(pDoc), nPos, rEvt.mnAction != DND_ACTION_MOVE );
531 
532                 rData.pCellTransfer->SetDragWasInternal();          // don't delete
533                 return sal_True;
534             }
535             else
536                 Sound::Beep();
537         }
538 	}
539 
540 	return 0;
541 }
542 
543 sal_Int8 ScTabControl::AcceptDrop( const AcceptDropEvent& rEvt )
544 {
545 	if ( rEvt.mbLeaving )
546 	{
547 		EndSwitchPage();
548 		HideDropPos();
549 		return rEvt.mnAction;
550 	}
551 
552 	const ScDocument* pDoc = pViewData->GetDocument();
553 	const ScDragData& rData = SC_MOD()->GetDragData();
554 	if ( rData.pCellTransfer && ( rData.pCellTransfer->GetDragSourceFlags() & SC_DROP_TABLE ) &&
555 			rData.pCellTransfer->GetSourceDocument() == pDoc )
556 	{
557 		// moving of tables within the document
558 		if ( !pDoc->GetChangeTrack() && pDoc->IsDocEditable() )
559 		{
560 			ShowDropPos( rEvt.maPosPixel );
561 			return rEvt.mnAction;
562 		}
563 	}
564 	else 					// switch sheets for all formats
565 	{
566 		SwitchPage( rEvt.maPosPixel );		// switch sheet after timeout
567 		return 0;							// nothing can be dropped here
568 	}
569 
570 	return 0;
571 }
572 
573 long ScTabControl::StartRenaming()
574 {
575 	if ( pViewData->GetDocument()->IsDocEditable() )
576         return TABBAR_RENAMING_YES;
577 	else
578         return TABBAR_RENAMING_NO;
579 }
580 
581 long ScTabControl::AllowRenaming()
582 {
583 	ScTabViewShell* pViewSh = pViewData->GetViewShell();
584 	DBG_ASSERT( pViewSh, "pViewData->GetViewShell()" );
585 
586     long nRet = TABBAR_RENAMING_CANCEL;
587 	sal_uInt16 nId = GetEditPageId();
588 	if ( nId )
589 	{
590 		SCTAB nTab = nId - 1;
591 		String aNewName = GetEditText();
592 		sal_Bool bDone = pViewSh->RenameTable( aNewName, nTab );
593 		if ( bDone )
594             nRet = TABBAR_RENAMING_YES;
595 		else if ( bErrorShown )
596 		{
597 			//	if the error message from this TabControl is currently visible,
598 			//	don't end edit mode now, to avoid problems when returning to
599 			//	the other call (showing the error) - this should not happen
600 			DBG_ERROR("ScTabControl::AllowRenaming: nested calls");
601             nRet = TABBAR_RENAMING_NO;
602 		}
603 		else if ( Application::IsInModalMode() )
604 		{
605 			//	#73472# don't show error message above any modal dialog
606 			//	instead cancel renaming without error message
607             nRet = TABBAR_RENAMING_CANCEL;
608 		}
609 		else
610 		{
611 			bErrorShown = sal_True;
612 			pViewSh->ErrorMessage( STR_INVALIDTABNAME );
613 			bErrorShown = sal_False;
614             nRet = TABBAR_RENAMING_NO;
615 		}
616 	}
617 	return nRet;
618 }
619 
620 void ScTabControl::EndRenaming()
621 {
622 	if ( HasFocus() )
623 		pViewData->GetView()->ActiveGrabFocus();
624 }
625 
626 void ScTabControl::Mirror()
627 {
628     TabBar::Mirror();
629     if( nSelPageIdByMouse != TabBar::PAGE_NOT_FOUND )
630     {
631         Rectangle aRect( GetPageRect( GetCurPageId() ) );
632         if( !aRect.IsEmpty() )
633             SetPointerPosPixel( aRect.Center() );
634         nSelPageIdByMouse = TabBar::PAGE_NOT_FOUND;  // only once after a Select()
635     }
636 }
637 
638 
639 
640