xref: /AOO41X/main/sc/source/ui/view/tabvwsh4.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
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 "scitems.hxx"
36 #include <editeng/eeitem.hxx>
37 
38 #include <sfx2/app.hxx>
39 #include <svx/extrusionbar.hxx>
40 #include <svx/fontworkbar.hxx>
41 #include <editeng/boxitem.hxx>
42 #include <svx/fmshell.hxx>
43 #include <editeng/sizeitem.hxx>
44 #include <editeng/boxitem.hxx>
45 #include <svx/prtqry.hxx>
46 #include <sfx2/request.hxx>
47 #include <sfx2/printer.hxx>
48 #include <sfx2/dispatch.hxx>
49 #include <svl/whiter.hxx>
50 #include <unotools/moduleoptions.hxx>
51 #include <rtl/logfile.hxx>
52 #include <tools/urlobj.hxx>
53 #include <sfx2/docfile.hxx>
54 
55 #include "tabvwsh.hxx"
56 #include "sc.hrc"
57 #include "globstr.hrc"
58 #include "stlpool.hxx"
59 #include "stlsheet.hxx"
60 #include "docsh.hxx"
61 #include "scmod.hxx"
62 #include "appoptio.hxx"
63 #include "rangeutl.hxx"
64 #include "printfun.hxx"
65 #include "drawsh.hxx"
66 #include "drformsh.hxx"
67 #include "editsh.hxx"
68 #include "pivotsh.hxx"
69 #include "auditsh.hxx"
70 #include "drtxtob.hxx"
71 #include "inputhdl.hxx"
72 #include "editutil.hxx"
73 #include "inputopt.hxx"
74 #include "inputwin.hxx"
75 #include "scresid.hxx"
76 #include "dbcolect.hxx"		// fuer ReImport
77 #include "reffact.hxx"
78 #include "viewuno.hxx"
79 #include "dispuno.hxx"
80 #include "anyrefdg.hxx"
81 #include "chgtrack.hxx"
82 #include "cellsh.hxx"
83 #include "oleobjsh.hxx"
84 #include "chartsh.hxx"
85 #include "graphsh.hxx"
86 #include "mediash.hxx"
87 #include "pgbrksh.hxx"
88 #include "dpobject.hxx"
89 #include "prevwsh.hxx"
90 #include "tpprint.hxx"
91 #include "scextopt.hxx"
92 #include "printopt.hxx"
93 #include "drawview.hxx"
94 #include "fupoor.hxx"
95 #include "navsett.hxx"
96 #include "sc.hrc" //CHINA001
97 #include "scabstdlg.hxx" //CHINA001
98 #include "externalrefmgr.hxx"
99 
100 void ActivateOlk( ScViewData* pViewData );
101 void DeActivateOlk( ScViewData* pViewData );
102 
103 extern SfxViewShell* pScActiveViewShell;			// global.cxx
104 
105 using namespace com::sun::star;
106 
107 // STATIC DATA -----------------------------------------------------------
108 
109 sal_uInt16 ScTabViewShell::nInsertCtrlState = SID_INSERT_GRAPHIC;
110 sal_uInt16 ScTabViewShell::nInsCellsCtrlState = 0;
111 sal_uInt16 ScTabViewShell::nInsObjCtrlState = SID_INSERT_DIAGRAM;
112 
113 // -----------------------------------------------------------------------
114 
115 void __EXPORT ScTabViewShell::Activate(sal_Bool bMDI)
116 {
117 	SfxViewShell::Activate(bMDI);
118 
119 	//	hier kein GrabFocus, sonst gibt's Probleme wenn etwas inplace editiert wird!
120 
121 	if ( bMDI )
122 	{
123 		//	fuer Eingabezeile (ClearCache)
124 		ScModule* pScMod = SC_MOD();
125 		pScMod->ViewShellChanged();
126 
127 		ActivateView( sal_True, bFirstActivate );
128 		ActivateOlk( GetViewData() );
129 
130 		//	#56870# AutoCorrect umsetzen, falls der Writer seins neu angelegt hat
131 		UpdateDrawTextOutliner();
132 
133 		//	RegisterNewTargetNames gibts nicht mehr
134 
135 		SfxViewFrame* pThisFrame  = GetViewFrame();
136 		if ( pInputHandler && pThisFrame->HasChildWindow(FID_INPUTLINE_STATUS) )
137 		{
138 			//	eigentlich nur beim Reload (letzte Version) noetig:
139 			//	Das InputWindow bleibt stehen, aber die View mitsamt InputHandler wird
140 			//	neu angelegt, darum muss der InputHandler am InputWindow gesetzt werden.
141 			SfxChildWindow* pChild = pThisFrame->GetChildWindow(FID_INPUTLINE_STATUS);
142 			if (pChild)
143 			{
144 				ScInputWindow* pWin = (ScInputWindow*)pChild->GetWindow();
145 				if (pWin && pWin->IsVisible())
146 				{
147 
148 					ScInputHandler* pOldHdl=pWin->GetInputHandler();
149 
150 					TypeId aScType = TYPE(ScTabViewShell);
151 
152 					SfxViewShell* pSh = SfxViewShell::GetFirst( &aScType );
153 					while ( pSh!=NULL && pOldHdl!=NULL)
154 					{
155 						if (((ScTabViewShell*)pSh)->GetInputHandler() == pOldHdl)
156 						{
157 							pOldHdl->ResetDelayTimer();
158 							break;
159 						}
160 						pSh = SfxViewShell::GetNext( *pSh, &aScType );
161 					}
162 
163 					pWin->SetInputHandler( pInputHandler );
164 				}
165 			}
166 		}
167 
168 		UpdateInputHandler( sal_True );
169 
170 		if ( bFirstActivate )
171 		{
172 			SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_NAVIGATOR_UPDATEALL ) );
173 			bFirstActivate = sal_False;
174 
175             // #116278# ReadExtOptions (view settings from Excel import) must also be done
176             // after the ctor, because of the potential calls to Window::Show.
177             // Even after the fix for #104887# (Window::Show no longer notifies the access
178             // bridge, it's done in ImplSetReallyVisible), there are problems if Window::Show
179             // is called during the ViewShell ctor and reschedules asynchronous calls
180             // (for example from the FmFormShell ctor).
181             ScExtDocOptions* pExtOpt = GetViewData()->GetDocument()->GetExtDocOptions();
182             if ( pExtOpt && pExtOpt->IsChanged() )
183             {
184                 GetViewData()->ReadExtOptions(*pExtOpt);        // Excel view settings
185                 SetTabNo( GetViewData()->GetTabNo(), sal_True );
186                 pExtOpt->SetChanged( false );
187             }
188 		}
189 
190 		pScActiveViewShell = this;
191 
192 		ScInputHandler* pHdl = pScMod->GetInputHdl(this);
193 		if (pHdl)
194 		{
195 			pHdl->SetRefScale( GetViewData()->GetZoomX(), GetViewData()->GetZoomY() );
196 		}
197 
198 		//	Aenderungs-Dialog aktualisieren
199 
200 		if ( pThisFrame->HasChildWindow(FID_CHG_ACCEPT) )
201 		{
202 			SfxChildWindow* pChild = pThisFrame->GetChildWindow(FID_CHG_ACCEPT);
203 			if (pChild)
204 			{
205 				((ScAcceptChgDlgWrapper*)pChild)->ReInitDlg();
206 			}
207 		}
208 
209 		if(pScMod->IsRefDialogOpen())
210 		{
211 			sal_uInt16 nModRefDlgId=pScMod->GetCurRefDlgId();
212 			SfxChildWindow* pChildWnd = pThisFrame->GetChildWindow( nModRefDlgId );
213 			if ( pChildWnd )
214 			{
215 				IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
216 				pRefDlg->ViewShellChanged(this);
217 			}
218 		}
219 	}
220 
221 	//	don't call CheckSelectionTransfer here - activating a view should not change the
222 	//	primary selection (may be happening just because the mouse was moved over the window)
223 
224 	//	Wenn Referenzeingabe-Tip-Hilfe hier wieder angezeigt werden soll (ShowRefTip),
225 	//	muss sie beim Verschieben der View angepasst werden (gibt sonst Probleme unter OS/2
226 	//	beim Umschalten zwischen Dokumenten)
227 }
228 
229 void __EXPORT ScTabViewShell::Deactivate(sal_Bool bMDI)
230 {
231 	HideTip();
232 
233 	ScDocument*	pDoc=GetViewData()->GetDocument();
234 
235 	ScChangeTrack* pChanges=pDoc->GetChangeTrack();
236 
237 	if(pChanges!=NULL)
238 	{
239 		Link aLink;
240 		pChanges->SetModifiedLink(aLink);
241 	}
242 
243 	SfxViewShell::Deactivate(bMDI);
244 
245 	ScInputHandler* pHdl = SC_MOD()->GetInputHdl(this);
246 
247 	if( bMDI )
248 	{
249 		//	#85421# during shell deactivation, shells must not be switched, or the loop
250 		//	through the shell stack (in SfxDispatcher::DoDeactivate_Impl) will not work
251 		sal_Bool bOldDontSwitch = bDontSwitch;
252 		bDontSwitch = sal_True;
253 
254 		DeActivateOlk( GetViewData() );
255 		ActivateView( sal_False, sal_False );
256 
257         if ( GetViewFrame()->GetFrame().IsInPlace() ) // inplace
258 			GetViewData()->GetDocShell()->UpdateOle(GetViewData(),sal_True);
259 
260 		if ( pHdl )
261 			pHdl->NotifyChange( NULL, sal_True ); // Timer-verzoegert wg. Dokumentwechsel
262 
263 		if (pScActiveViewShell == this)
264 			pScActiveViewShell = NULL;
265 
266 		bDontSwitch = bOldDontSwitch;
267 	}
268 	else
269 	{
270 		HideNoteMarker();			// Notiz-Anzeige
271 
272 		if ( pHdl )
273 			pHdl->HideTip();		// Formel-AutoEingabe-Tip abschalten
274 	}
275 }
276 
277 void ScTabViewShell::SetActive()
278 {
279 	// Die Sfx-View moechte sich gerne selbst aktivieren, weil dabei noch
280 	// magische Dinge geschehen (z.B. stuerzt sonst evtl. der Gestalter ab)
281 	ActiveGrabFocus();
282 
283 #if 0
284 	SfxViewFrame* pFrame = GetViewFrame();
285 	pFrame->GetFrame().Appear();
286 
287 	SFX_APP()->SetViewFrame( pFrame );			// immer erst Appear, dann SetViewFrame (#29290#)
288 #endif
289 }
290 
291 sal_uInt16 __EXPORT ScTabViewShell::PrepareClose(sal_Bool bUI, sal_Bool bForBrowsing)
292 {
293     // Call EnterHandler even in formula mode here,
294     // so a formula change in an embedded object isn't lost
295     // (ScDocShell::PrepareClose isn't called then).
296     ScInputHandler* pHdl = SC_MOD()->GetInputHdl( this );
297     if ( pHdl && pHdl->IsInputMode() )
298         pHdl->EnterHandler();
299 
300     // #110797# draw text edit mode must be closed
301     FuPoor* pPoor = GetDrawFuncPtr();
302     if ( pPoor && ( IsDrawTextShell() || pPoor->GetSlotID() == SID_DRAW_NOTEEDIT ) )
303     {
304         // "clean" end of text edit, including note handling, subshells and draw func switching,
305         // as in FuDraw and ScTabView::DrawDeselectAll
306         GetViewData()->GetDispatcher().Execute( pPoor->GetSlotID(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD );
307     }
308     ScDrawView* pDrView = GetScDrawView();
309     if ( pDrView )
310     {
311         // force end of text edit, to be safe
312         // #128314# ScEndTextEdit must always be used, to ensure correct UndoManager
313         pDrView->ScEndTextEdit();
314     }
315 
316 	if ( pFormShell )
317 	{
318 		sal_uInt16 nRet = pFormShell->PrepareClose(bUI, bForBrowsing);
319 		if (nRet!=sal_True)
320 			return nRet;
321 	}
322 	return SfxViewShell::PrepareClose(bUI,bForBrowsing);
323 }
324 
325 //------------------------------------------------------------------
326 
327 Size __EXPORT ScTabViewShell::GetOptimalSizePixel() const
328 {
329 	Size aOptSize;
330 
331 	SCTAB				nCurTab		= GetViewData()->GetTabNo();
332 	ScDocument*			pDoc		= GetViewData()->GetDocument();
333 	ScStyleSheetPool*	pStylePool  = pDoc->GetStyleSheetPool();
334 	SfxStyleSheetBase*	pStyleSheet = pStylePool->Find(
335 										pDoc->GetPageStyle( nCurTab ),
336 										SFX_STYLE_FAMILY_PAGE );
337 
338 	DBG_ASSERT( pStyleSheet, "PageStyle not found :-/" );
339 
340 	if ( pStyleSheet )
341 	{
342 		const SfxItemSet&  rSet 	 = pStyleSheet->GetItemSet();
343 		const SvxSizeItem& rItem	 = (const SvxSizeItem&)rSet.Get( ATTR_PAGE_SIZE );
344 		const Size&		   rPageSize = rItem.GetSize();
345 
346 		aOptSize.Width()  = (long) (rPageSize.Width()  * GetViewData()->GetPPTX());
347 		aOptSize.Height() = (long) (rPageSize.Height() * GetViewData()->GetPPTY());
348 	}
349 
350 	return aOptSize;
351 }
352 
353 //------------------------------------------------------------------
354 
355 //	Zoom fuer In-Place berechnen
356 //	aus Verhaeltnis von VisArea und Fenstergroesse des GridWin
357 
358 void ScTabViewShell::UpdateOleZoom()
359 {
360 	ScDocShell* pDocSh = GetViewData()->GetDocShell();
361 	if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
362 	{
363         //TODO/LATER: is there a difference between the two GetVisArea methods?
364         Size aObjSize = ((const SfxObjectShell*)pDocSh)->GetVisArea().GetSize();
365 		if ( aObjSize.Width() > 0 && aObjSize.Height() > 0 )
366 		{
367 			Window* pWin = GetActiveWin();
368 			Size aWinHMM = pWin->PixelToLogic( pWin->GetOutputSizePixel(), MAP_100TH_MM );
369 			SetZoomFactor( Fraction( aWinHMM.Width(),aObjSize.Width() ),
370 							Fraction( aWinHMM.Height(),aObjSize.Height() ) );
371 		}
372 	}
373 }
374 
375 void __EXPORT ScTabViewShell::AdjustPosSizePixel( const Point &rPos, const Size &rSize )
376 {
377 	OuterResizePixel( rPos, rSize );
378 }
379 
380 void __EXPORT ScTabViewShell::InnerResizePixel( const Point &rOfs, const Size &rSize )
381 {
382 	Size aNewSize( rSize );
383     if ( GetViewFrame()->GetFrame().IsInPlace() )
384 	{
385 		SvBorder aBorder;
386 	   	GetBorderSize( aBorder, rSize );
387 		SetBorderPixel( aBorder );
388 
389 		Size aObjSize = GetObjectShell()->GetVisArea().GetSize();
390 
391       	Size aSize( rSize );
392         aSize.Width() -= (aBorder.Left() + aBorder.Right());
393         aSize.Height() -= (aBorder.Top() + aBorder.Bottom());
394 
395 		if ( aObjSize.Width() > 0 && aObjSize.Height() > 0 )
396     	{
397         	Size aLogicSize = GetWindow()->PixelToLogic( aSize, MAP_100TH_MM );
398         	SfxViewShell::SetZoomFactor( Fraction( aLogicSize.Width(),aObjSize.Width() ),
399                         	Fraction( aLogicSize.Height(),aObjSize.Height() ) );
400     	}
401 
402         Point aPos( rOfs );
403         aPos.X() += aBorder.Left();
404         aPos.Y() += aBorder.Top();
405         GetWindow()->SetPosSizePixel( aPos, aSize );
406 	}
407 	else
408     {
409         SvBorder aBorder;
410         GetBorderSize( aBorder, rSize );
411         SetBorderPixel( aBorder );
412         aNewSize.Width()  += aBorder.Left() + aBorder.Right();
413         aNewSize.Height() += aBorder.Top() + aBorder.Bottom();
414     }
415 
416 	DoResize( rOfs, aNewSize, sal_True );					// rSize = Groesse von gridwin
417 
418 	UpdateOleZoom();									//	Zoom fuer In-Place berechnen
419 
420 //	GetViewData()->GetDocShell()->UpdateOle( GetViewData() );
421 	GetViewData()->GetDocShell()->SetDocumentModified();
422 }
423 
424 void __EXPORT ScTabViewShell::OuterResizePixel( const Point &rOfs, const Size &rSize )
425 {
426 	SvBorder aBorder;
427 	GetBorderSize( aBorder, rSize );
428 	SetBorderPixel( aBorder );
429 
430 	DoResize( rOfs, rSize );					// Position und Groesse von tabview wie uebergeben
431 
432 	// ForceMove als Ersatz fuer den Sfx-Move-Mechanismus
433 	// (aWinPos muss aktuell gehalten werden, damit ForceMove beim Ole-Deaktivieren klappt)
434 
435 	ForceMove();
436 }
437 
438 void __EXPORT ScTabViewShell::SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY )
439 {
440 	//	fuer OLE...
441 
442 	Fraction aFrac20( 1,5 );
443 	Fraction aFrac400( 4,1 );
444 
445 	Fraction aNewX( rZoomX );
446 	if ( aNewX < aFrac20 )
447 		aNewX = aFrac20;
448 	if ( aNewX > aFrac400 )
449 		aNewX = aFrac400;
450 	Fraction aNewY( rZoomY );
451 	if ( aNewY < aFrac20 )
452 		aNewY = aFrac20;
453 	if ( aNewY > aFrac400 )
454 		aNewY = aFrac400;
455 
456 	GetViewData()->UpdateScreenZoom( aNewX, aNewY );
457     SetZoom( aNewX, aNewY, sal_True );
458 
459 	PaintGrid();
460 	PaintTop();
461 	PaintLeft();
462 
463 	SfxViewShell::SetZoomFactor( rZoomX, rZoomY );
464 }
465 
466 void __EXPORT ScTabViewShell::QueryObjAreaPixel( Rectangle& rRect ) const
467 {
468 	//	auf ganze Zellen anpassen (in 1/100 mm)
469 
470 	Size aPixelSize = rRect.GetSize();
471 	Window* pWin = ((ScTabViewShell*)this)->GetActiveWin();
472 	Size aLogicSize = pWin->PixelToLogic( aPixelSize );
473 
474 	const ScViewData* pViewData = GetViewData();
475 	ScDocument* pDoc = pViewData->GetDocument();
476 	ScSplitPos ePos = pViewData->GetActivePart();
477 	SCCOL nCol = pViewData->GetPosX(WhichH(ePos));
478 	SCROW nRow = pViewData->GetPosY(WhichV(ePos));
479 	SCTAB nTab = pViewData->GetTabNo();
480     sal_Bool bNegativePage = pDoc->IsNegativePage( nTab );
481 
482 	Rectangle aLogicRect = pDoc->GetMMRect( nCol, nRow, nCol, nRow, nTab );
483 	if ( bNegativePage )
484 	{
485 	    // use right edge of aLogicRect, and aLogicSize
486 	    aLogicRect.Left() = aLogicRect.Right() - aLogicSize.Width() + 1;    // Right() is set below
487 	}
488 	aLogicRect.SetSize( aLogicSize );
489 
490 	pDoc->SnapVisArea( aLogicRect );
491 
492 	rRect.SetSize( pWin->LogicToPixel( aLogicRect.GetSize() ) );
493 
494 #if 0
495 	//	auf ganze Zellen anpassen (in Pixeln)
496 
497 	ScViewData* pViewData = ((ScTabViewShell*)this)->GetViewData();
498 	Size aSize = rRect.GetSize();
499 
500 	ScSplitPos ePos = pViewData->GetActivePart();
501 	Window* pWin = ((ScTabViewShell*)this)->GetActiveWin();
502 
503 	Point aTest( aSize.Width(), aSize.Height() );
504 	SCsCOL nPosX;
505 	SCsROW nPosY;
506 	pViewData->GetPosFromPixel( aTest.X(), aTest.Y(), ePos, nPosX, nPosY );
507 	sal_Bool bLeft;
508 	sal_Bool bTop;
509 	pViewData->GetMouseQuadrant( aTest, ePos, nPosX, nPosY, bLeft, bTop );
510 	if (!bLeft)
511 		++nPosX;
512 	if (!bTop)
513 		++nPosY;
514 	aTest = pViewData->GetScrPos( (SCCOL)nPosX, (SCROW)nPosY, ePos, sal_True );
515 
516 	rRect.SetSize(Size(aTest.X(),aTest.Y()));
517 #endif
518 }
519 
520 //------------------------------------------------------------------
521 
522 void __EXPORT ScTabViewShell::Move()
523 {
524 	Point aNewPos = GetViewFrame()->GetWindow().OutputToScreenPixel(Point());
525 
526 	if (aNewPos != aWinPos)
527 	{
528 		StopMarking();
529 		aWinPos = aNewPos;
530 	}
531 }
532 
533 //------------------------------------------------------------------
534 
535 void __EXPORT ScTabViewShell::ShowCursor(FASTBOOL /* bOn */)
536 {
537 /*!!!	ShowCursor wird nicht paarweise wie im gridwin gerufen.
538 		Der CursorLockCount am Gridwin muss hier direkt auf 0 gesetzt werden
539 
540 	if (bOn)
541 		ShowAllCursors();
542 	else
543 		HideAllCursors();
544 */
545 }
546 
547 //------------------------------------------------------------------
548 
549 void __EXPORT ScTabViewShell::WriteUserData(String& rData, sal_Bool /* bBrowse */)
550 {
551 	GetViewData()->WriteUserData(rData);
552 }
553 
554 void ScTabViewShell::WriteUserDataSequence (uno::Sequence < beans::PropertyValue >& rSettings, sal_Bool /* bBrowse */ )
555 {
556 	GetViewData()->WriteUserDataSequence (rSettings);
557 }
558 
559 void __EXPORT ScTabViewShell::ReadUserData(const String& rData, sal_Bool /* bBrowse */)
560 {
561 	if ( !GetViewData()->GetDocShell()->IsPreview() )
562 		DoReadUserData( rData );
563 }
564 
565 void ScTabViewShell::ReadUserDataSequence (const uno::Sequence < beans::PropertyValue >& rSettings, sal_Bool /* bBrowse */ )
566 {
567     if ( !GetViewData()->GetDocShell()->IsPreview() )
568         DoReadUserDataSequence( rSettings );
569 }
570 
571 void ScTabViewShell::DoReadUserDataSequence( const uno::Sequence < beans::PropertyValue >& rSettings )
572 {
573 	Window* pOldWin = GetActiveWin();
574 	sal_Bool bFocus = pOldWin && pOldWin->HasFocus();
575 
576 	GetViewData()->ReadUserDataSequence(rSettings);
577 	SetTabNo( GetViewData()->GetTabNo(), sal_True );
578 
579 	if ( GetViewData()->IsPagebreakMode() )
580 		SetCurSubShell( GetCurObjectSelectionType(), sal_True );
581 
582 	Window* pNewWin = GetActiveWin();
583 	if (pNewWin && pNewWin != pOldWin)
584 	{
585 		SetWindow( pNewWin );		//! ist diese ViewShell immer aktiv???
586 		if (bFocus)
587 			pNewWin->GrabFocus();
588 		WindowChanged();			// Drawing-Layer (z.B. #56771#)
589 	}
590 
591 	if (GetViewData()->GetHSplitMode() == SC_SPLIT_FIX ||
592 		GetViewData()->GetVSplitMode() == SC_SPLIT_FIX)
593 	{
594 		InvalidateSplit();
595 	}
596 
597 	ZoomChanged();
598 
599 	TestHintWindow();
600 
601 	//!	if ViewData has more tables than document, remove tables in ViewData
602 }
603 
604 // DoReadUserData is also called from ctor when switching from print preview
605 
606 void ScTabViewShell::DoReadUserData( const String& rData )
607 {
608 	Window* pOldWin = GetActiveWin();
609 	sal_Bool bFocus = pOldWin && pOldWin->HasFocus();
610 
611 	GetViewData()->ReadUserData(rData);
612 	SetTabNo( GetViewData()->GetTabNo(), sal_True );
613 
614 	if ( GetViewData()->IsPagebreakMode() )
615 		SetCurSubShell( GetCurObjectSelectionType(), sal_True );
616 
617 	Window* pNewWin = GetActiveWin();
618 	if (pNewWin && pNewWin != pOldWin)
619 	{
620 		SetWindow( pNewWin );		//! ist diese ViewShell immer aktiv???
621 		if (bFocus)
622 			pNewWin->GrabFocus();
623 		WindowChanged();			// Drawing-Layer (z.B. #56771#)
624 	}
625 
626 	if (GetViewData()->GetHSplitMode() == SC_SPLIT_FIX ||
627 		GetViewData()->GetVSplitMode() == SC_SPLIT_FIX)
628 	{
629 		InvalidateSplit();
630 	}
631 
632 	ZoomChanged();
633 
634 	TestHintWindow();
635 
636 	//!	if ViewData has more tables than document, remove tables in ViewData
637 }
638 
639 //------------------------------------------------------------------
640 
641 void ScTabViewShell::UpdateDrawShell()
642 {
643     // Called after user interaction that may delete the selected drawing object.
644     // Remove DrawShell if nothing is selected.
645 
646     SdrView* pDrView = GetSdrView();
647     if ( pDrView && !pDrView->AreObjectsMarked() && !IsDrawSelMode() )
648         SetDrawShell( sal_False );
649 }
650 
651 void ScTabViewShell::SetDrawShellOrSub()
652 {
653 	bActiveDrawSh = sal_True;
654 
655 	if(bActiveDrawFormSh)
656 	{
657 		SetCurSubShell(OST_DrawForm);
658 	}
659 	else if(bActiveGraphicSh)
660 	{
661 		SetCurSubShell(OST_Graphic);
662 	}
663 	else if(bActiveMediaSh)
664 	{
665 		SetCurSubShell(OST_Media);
666 	}
667 	else if(bActiveChartSh)
668 	{
669 		SetCurSubShell(OST_Chart);
670 	}
671 	else if(bActiveOleObjectSh)
672 	{
673 		SetCurSubShell(OST_OleObject);
674 	}
675 	else
676 	{
677 		SetCurSubShell(OST_Drawing, true /* force: different toolbars are
678                                             visible concerning shape type
679                                             and shape state */);
680 	}
681 }
682 
683 void ScTabViewShell::SetDrawShell( sal_Bool bActive )
684 {
685 	if(bActive)
686 	{
687 		SetCurSubShell(OST_Drawing, true /* force: different toolbars are
688                                             visible concerning shape type
689                                             and shape state */);
690 	}
691 	else
692 	{
693 		if(bActiveDrawFormSh || bActiveDrawSh ||
694             bActiveGraphicSh || bActiveMediaSh || bActiveOleObjectSh||
695 			bActiveChartSh || bActiveDrawTextSh)
696 		{
697 			SetCurSubShell(OST_Cell);
698 		}
699 		bActiveDrawFormSh=sal_False;
700 		bActiveGraphicSh=sal_False;
701         bActiveMediaSh=sal_False;
702 		bActiveOleObjectSh=sal_False;
703 		bActiveChartSh=sal_False;
704 	}
705 
706 	sal_Bool bWasDraw = bActiveDrawSh || bActiveDrawTextSh;
707 
708 	bActiveDrawSh = bActive;
709 	bActiveDrawTextSh = sal_False;
710 
711 	if ( !bActive )
712 	{
713 		ResetDrawDragMode();		//	Mirror / Rotate aus
714 
715 		if (bWasDraw && (GetViewData()->GetHSplitMode() == SC_SPLIT_FIX ||
716 						 GetViewData()->GetVSplitMode() == SC_SPLIT_FIX))
717 		{
718 			//	Aktiven Teil an Cursor anpassen, etc.
719 			MoveCursorAbs( GetViewData()->GetCurX(), GetViewData()->GetCurY(),
720 							SC_FOLLOW_NONE, sal_False, sal_False, sal_True );
721 		}
722 	}
723 }
724 
725 void ScTabViewShell::SetDrawTextShell( sal_Bool bActive )
726 {
727 	bActiveDrawTextSh = bActive;
728 	if ( bActive )
729 	{
730 		bActiveDrawFormSh=sal_False;
731 		bActiveGraphicSh=sal_False;
732         bActiveMediaSh=sal_False;
733 		bActiveOleObjectSh=sal_False;
734 		bActiveChartSh=sal_False;
735 		bActiveDrawSh = sal_False;
736 		SetCurSubShell(OST_DrawText);
737 	}
738 	else
739 		SetCurSubShell(OST_Cell);
740 
741 }
742 
743 void ScTabViewShell::SetPivotShell( sal_Bool bActive )
744 {
745 	bActivePivotSh = bActive;
746 
747 	//	#68771# #76198# SetPivotShell is called from CursorPosChanged every time
748 	//	-> don't change anything except switching between cell and pivot shell
749 
750 	if ( eCurOST == OST_Pivot || eCurOST == OST_Cell )
751 	{
752 		if ( bActive )
753 		{
754 			bActiveDrawTextSh = bActiveDrawSh = sal_False;
755 			bActiveDrawFormSh=sal_False;
756 			bActiveGraphicSh=sal_False;
757             bActiveMediaSh=sal_False;
758 			bActiveOleObjectSh=sal_False;
759 			bActiveChartSh=sal_False;
760 			SetCurSubShell(OST_Pivot);
761 		}
762 		else
763 			SetCurSubShell(OST_Cell);
764 	}
765 }
766 
767 void ScTabViewShell::SetAuditShell( sal_Bool bActive )
768 {
769 	bActiveAuditingSh = bActive;
770 	if ( bActive )
771 	{
772 		bActiveDrawTextSh = bActiveDrawSh = sal_False;
773 		bActiveDrawFormSh=sal_False;
774 		bActiveGraphicSh=sal_False;
775         bActiveMediaSh=sal_False;
776 		bActiveOleObjectSh=sal_False;
777 		bActiveChartSh=sal_False;
778 		SetCurSubShell(OST_Auditing);
779 	}
780 	else
781 		SetCurSubShell(OST_Cell);
782 }
783 
784 void ScTabViewShell::SetDrawFormShell( sal_Bool bActive )
785 {
786 	bActiveDrawFormSh = bActive;
787 
788 	if(bActiveDrawFormSh)
789 		SetCurSubShell(OST_DrawForm);
790 }
791 void ScTabViewShell::SetChartShell( sal_Bool bActive )
792 {
793 	bActiveChartSh = bActive;
794 
795 	if(bActiveChartSh)
796 		SetCurSubShell(OST_Chart);
797 }
798 
799 void ScTabViewShell::SetGraphicShell( sal_Bool bActive )
800 {
801 	bActiveGraphicSh = bActive;
802 
803 	if(bActiveGraphicSh)
804 		SetCurSubShell(OST_Graphic);
805 }
806 
807 void ScTabViewShell::SetMediaShell( sal_Bool bActive )
808 {
809 	bActiveMediaSh = bActive;
810 
811 	if(bActiveMediaSh)
812 		SetCurSubShell(OST_Media);
813 }
814 
815 void ScTabViewShell::SetOleObjectShell( sal_Bool bActive )
816 {
817 	bActiveOleObjectSh = bActive;
818 
819 	if(bActiveOleObjectSh)
820 		SetCurSubShell(OST_OleObject);
821 	else
822 		SetCurSubShell(OST_Cell);
823 }
824 
825 void ScTabViewShell::SetEditShell(EditView* pView, sal_Bool bActive )
826 {
827 	if(bActive)
828 	{
829 		if (pEditShell)
830 			pEditShell->SetEditView( pView );
831 		else
832 			pEditShell = new ScEditShell( pView, GetViewData() );
833 
834 		SetCurSubShell(OST_Editing);
835 	}
836 	else if(bActiveEditSh)
837 	{
838 		SetCurSubShell(OST_Cell);
839 	}
840 	bActiveEditSh = bActive;
841 }
842 
843 void ScTabViewShell::SetCurSubShell(ObjectSelectionType	eOST, sal_Bool bForce)
844 {
845 	ScViewData* pViewData	= GetViewData();
846 	ScDocShell* pDocSh		= pViewData->GetDocShell();
847 
848 	if(bDontSwitch) return;
849 
850 	if(!pCellShell) //Wird eh immer gebraucht.
851 	{
852 		pCellShell = new ScCellShell( GetViewData() );
853 		pCellShell->SetRepeatTarget( &aTarget );
854 	}
855 
856 	sal_Bool bPgBrk=pViewData->IsPagebreakMode();
857 
858 	if(bPgBrk && !pPageBreakShell)
859 	{
860 		pPageBreakShell = new ScPageBreakShell( this );
861 		pPageBreakShell->SetRepeatTarget( &aTarget );
862 	}
863 
864 
865 	if ( eOST!=eCurOST || bForce )
866 	{
867         sal_Bool bCellBrush = sal_False;    // "format paint brush" allowed for cells
868         sal_Bool bDrawBrush = sal_False;    // "format paint brush" allowed for drawing objects
869 
870 		if(eCurOST!=OST_NONE) RemoveSubShell();
871 
872 		if (pFormShell && !bFormShellAtTop)
873 		    AddSubShell(*pFormShell);               // add below own subshells
874 
875 		switch(eOST)
876 		{
877 			case	OST_Cell:
878 					{
879 						AddSubShell(*pCellShell);
880 						if(bPgBrk) AddSubShell(*pPageBreakShell);
881                         bCellBrush = sal_True;
882 					}
883 					break;
884 			case	OST_Editing:
885 					{
886 						AddSubShell(*pCellShell);
887 						if(bPgBrk) AddSubShell(*pPageBreakShell);
888 
889 						if(pEditShell)
890 						{
891 							AddSubShell(*pEditShell);
892 						}
893 					}
894 					break;
895 			case	OST_DrawText:
896 					{
897 						if ( !pDrawTextShell )
898 						{
899 							pDocSh->MakeDrawLayer();
900 							pDrawTextShell = new ScDrawTextObjectBar( GetViewData() );
901 						}
902 						AddSubShell(*pDrawTextShell);
903 					}
904 					break;
905 			case	OST_Drawing:
906 					{
907                         if (svx::checkForSelectedCustomShapes(
908                                 GetScDrawView(), true /* bOnlyExtruded */ )) {
909                             if (pExtrusionBarShell == 0)
910                                 pExtrusionBarShell = new svx::ExtrusionBar(this);
911                             AddSubShell( *pExtrusionBarShell );
912                         }
913                         sal_uInt32 nCheckStatus = 0;
914                         if (svx::checkForSelectedFontWork(
915                                 GetScDrawView(), nCheckStatus )) {
916                             if (pFontworkBarShell == 0)
917                                 pFontworkBarShell = new svx::FontworkBar(this);
918                             AddSubShell( *pFontworkBarShell );
919                         }
920 
921 						if ( !pDrawShell )
922 						{
923 							pDocSh->MakeDrawLayer();
924 							pDrawShell = new ScDrawShell( GetViewData() );
925 							pDrawShell->SetRepeatTarget( &aTarget );
926 						}
927 						AddSubShell(*pDrawShell);
928 						bDrawBrush = sal_True;
929 					}
930 					break;
931 
932 			case	OST_DrawForm:
933 					{
934 						if ( !pDrawFormShell )
935 						{
936 							pDocSh->MakeDrawLayer();
937 							pDrawFormShell = new ScDrawFormShell( GetViewData() );
938 							pDrawFormShell->SetRepeatTarget( &aTarget );
939 						}
940 						AddSubShell(*pDrawFormShell);
941 						bDrawBrush = sal_True;
942 					}
943 					break;
944 
945 			case	OST_Chart:
946 					{
947 						if ( !pChartShell )
948 						{
949 							pDocSh->MakeDrawLayer();
950 							pChartShell = new ScChartShell( GetViewData() );
951 							pChartShell->SetRepeatTarget( &aTarget );
952 						}
953 						AddSubShell(*pChartShell);
954 						bDrawBrush = sal_True;
955 					}
956 					break;
957 
958 			case	OST_OleObject:
959 					{
960 						if ( !pOleObjectShell )
961 						{
962 							pDocSh->MakeDrawLayer();
963 							pOleObjectShell = new ScOleObjectShell( GetViewData() );
964 							pOleObjectShell->SetRepeatTarget( &aTarget );
965 						}
966 						AddSubShell(*pOleObjectShell);
967 						bDrawBrush = sal_True;
968 					}
969 					break;
970 
971 			case	OST_Graphic:
972 					{
973 						if ( !pGraphicShell)
974 						{
975 							pDocSh->MakeDrawLayer();
976 							pGraphicShell = new ScGraphicShell( GetViewData() );
977 							pGraphicShell->SetRepeatTarget( &aTarget );
978 						}
979 						AddSubShell(*pGraphicShell);
980 						bDrawBrush = sal_True;
981 					}
982 					break;
983 
984 			case	OST_Media:
985 					{
986 						if ( !pMediaShell)
987 						{
988 							pDocSh->MakeDrawLayer();
989 							pMediaShell = new ScMediaShell( GetViewData() );
990 							pMediaShell->SetRepeatTarget( &aTarget );
991 						}
992 						AddSubShell(*pMediaShell);
993 					}
994 					break;
995 
996 			case	OST_Pivot:
997 					{
998 						AddSubShell(*pCellShell);
999 						if(bPgBrk) AddSubShell(*pPageBreakShell);
1000 
1001 						if ( !pPivotShell )
1002 						{
1003 							pPivotShell = new ScPivotShell( this );
1004 							pPivotShell->SetRepeatTarget( &aTarget );
1005 						}
1006 						AddSubShell(*pPivotShell);
1007                         bCellBrush = sal_True;
1008 					}
1009 					break;
1010 			case	OST_Auditing:
1011 					{
1012 						AddSubShell(*pCellShell);
1013 						if(bPgBrk) AddSubShell(*pPageBreakShell);
1014 
1015 						if ( !pAuditingShell )
1016 						{
1017 							pDocSh->MakeDrawLayer();	// die Wartezeit lieber jetzt als beim Klick
1018 
1019 							pAuditingShell = new ScAuditingShell( GetViewData() );
1020 							pAuditingShell->SetRepeatTarget( &aTarget );
1021 						}
1022 						AddSubShell(*pAuditingShell);
1023                         bCellBrush = sal_True;
1024 					}
1025 					break;
1026 			default:
1027 					DBG_ERROR("Falsche Shell angefordert");
1028 					break;
1029 		}
1030 
1031 		if (pFormShell && bFormShellAtTop)
1032 		    AddSubShell(*pFormShell);               // add on top of own subshells
1033 
1034 		eCurOST=eOST;
1035 
1036         // abort "format paint brush" when switching to an incompatible shell
1037         if ( ( GetBrushDocument() && !bCellBrush ) || ( GetDrawBrushSet() && !bDrawBrush ) )
1038             ResetBrushDocument();
1039 	}
1040 }
1041 
1042 void ScTabViewShell::SetFormShellAtTop( sal_Bool bSet )
1043 {
1044     if ( pFormShell && !bSet )
1045         pFormShell->ForgetActiveControl();      // let the FormShell know it no longer has the focus
1046 
1047     if ( bFormShellAtTop != bSet )
1048     {
1049         bFormShellAtTop = bSet;
1050         SetCurSubShell( GetCurObjectSelectionType(), sal_True );
1051     }
1052 }
1053 
1054 IMPL_LINK( ScTabViewShell, FormControlActivated, FmFormShell*, EMPTYARG )
1055 {
1056     // a form control got the focus, so the form shell has to be on top
1057     SetFormShellAtTop( sal_True );
1058     return 0;
1059 }
1060 
1061 ObjectSelectionType ScTabViewShell::GetCurObjectSelectionType()
1062 {
1063 	return eCurOST;
1064 }
1065 
1066 //	GetMySubShell / SetMySubShell: altes Verhalten simulieren,
1067 //	dass es nur eine SubShell gibt (nur innerhalb der 5 eignenen SubShells)
1068 
1069 SfxShell* ScTabViewShell::GetMySubShell() const
1070 {
1071 	//	GetSubShell() war frueher const, und GetSubShell(sal_uInt16) sollte es auch sein...
1072 
1073 	sal_uInt16 nPos = 0;
1074 	SfxShell* pSub = ((ScTabViewShell*)this)->GetSubShell(nPos);
1075 	while (pSub)
1076 	{
1077 		if ( pSub == pDrawShell  || pSub == pDrawTextShell || pSub == pEditShell ||
1078 			 pSub == pPivotShell || pSub == pAuditingShell || pSub == pDrawFormShell ||
1079 			 pSub == pCellShell	 || pSub == pOleObjectShell|| pSub == pChartShell ||
1080 			 pSub == pGraphicShell || pSub == pMediaShell || pSub == pPageBreakShell)
1081 			return pSub;	// gefunden
1082 
1083 		pSub = ((ScTabViewShell*)this)->GetSubShell(++nPos);
1084 	}
1085 	return NULL;		// keine von meinen dabei
1086 }
1087 
1088 //UNUSED2008-05  void ScTabViewShell::SetMySubShell( SfxShell* pShell )
1089 //UNUSED2008-05  {
1090 //UNUSED2008-05      SfxShell* pOld = GetMySubShell();
1091 //UNUSED2008-05      if ( pOld != pShell )
1092 //UNUSED2008-05      {
1093 //UNUSED2008-05          if (pOld)
1094 //UNUSED2008-05              RemoveSubShell(pOld);   // alte SubShell entfernen
1095 //UNUSED2008-05          if (pShell)
1096 //UNUSED2008-05              AddSubShell(*pShell);   // neue setzen
1097 //UNUSED2008-05      }
1098 //UNUSED2008-05  }
1099 
1100 sal_Bool ScTabViewShell::IsDrawTextShell() const
1101 {
1102 	return ( pDrawTextShell && ( GetMySubShell() == pDrawTextShell ) );
1103 }
1104 
1105 sal_Bool ScTabViewShell::IsAuditShell() const
1106 {
1107 	return ( pAuditingShell && ( GetMySubShell() == pAuditingShell ) );
1108 }
1109 
1110 void ScTabViewShell::SetDrawTextUndo( ::svl::IUndoManager* pNewUndoMgr )
1111 {
1112 	// Default: Undo-Manager der DocShell
1113 	if (!pNewUndoMgr)
1114 		pNewUndoMgr = GetViewData()->GetDocShell()->GetUndoManager();
1115 
1116 	if (pDrawTextShell)
1117     {
1118 		pDrawTextShell->SetUndoManager(pNewUndoMgr);
1119         ScDocShell* pDocSh = GetViewData()->GetDocShell();
1120         if ( pNewUndoMgr == pDocSh->GetUndoManager() &&
1121              !pDocSh->GetDocument()->IsUndoEnabled() )
1122         {
1123             pNewUndoMgr->SetMaxUndoActionCount( 0 );
1124         }
1125     }
1126 	else
1127 	{
1128 		DBG_ERROR("SetDrawTextUndo ohne DrawTextShell");
1129 	}
1130 }
1131 
1132 //------------------------------------------------------------------
1133 
1134 ScTabViewShell* ScTabViewShell::GetActiveViewShell()
1135 {
1136 	return PTR_CAST(ScTabViewShell,Current());
1137 }
1138 
1139 //------------------------------------------------------------------
1140 
1141 SfxPrinter* __EXPORT ScTabViewShell::GetPrinter( sal_Bool bCreate )
1142 {
1143 	//	Drucker ist immer da (wird fuer die FontListe schon beim Starten angelegt)
1144 	return GetViewData()->GetDocShell()->GetPrinter(bCreate);
1145 }
1146 
1147 sal_uInt16 __EXPORT ScTabViewShell::SetPrinter( SfxPrinter *pNewPrinter, sal_uInt16 nDiffFlags, bool )
1148 {
1149 	return GetViewData()->GetDocShell()->SetPrinter( pNewPrinter, nDiffFlags );
1150 }
1151 
1152 SfxTabPage* ScTabViewShell::CreatePrintOptionsPage( Window *pParent, const SfxItemSet &rOptions )
1153 {
1154 	ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
1155 	DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
1156 	//CHINA001 return ScTpPrintOptions::Create( pParent, rOptions );
1157 	::CreateTabPage ScTpPrintOptionsCreate = 	pFact->GetTabPageCreatorFunc( RID_SCPAGE_PRINT );
1158 	if ( ScTpPrintOptionsCreate )
1159 		return  (*ScTpPrintOptionsCreate)( pParent, rOptions);
1160 	return 0;
1161 }
1162 
1163 void ScTabViewShell::StopEditShell()
1164 {
1165 	if ( pEditShell != NULL && !bDontSwitch )
1166 		SetEditShell(NULL, sal_False );
1167 }
1168 
1169 //------------------------------------------------------------------
1170 
1171 // close handler to ensure function of dialog:
1172 
1173 IMPL_LINK( ScTabViewShell, SimpleRefClose, String*, EMPTYARG )
1174 {
1175     SfxInPlaceClient* pClient = GetIPClient();
1176     if ( pClient && pClient->IsObjectInPlaceActive() )
1177     {
1178         // If range selection was started with an active embedded object,
1179         // switch back to original sheet (while the dialog is still open).
1180 
1181         SetTabNo( GetViewData()->GetRefTabNo() );
1182     }
1183 
1184 	ScSimpleRefDlgWrapper::SetAutoReOpen( sal_True );
1185 	return 0;
1186 }
1187 
1188 // handlers to call UNO listeners:
1189 
1190 ScTabViewObj* lcl_GetViewObj( ScTabViewShell& rShell )
1191 {
1192 	ScTabViewObj* pRet = NULL;
1193 	SfxViewFrame* pViewFrame = rShell.GetViewFrame();
1194 	if (pViewFrame)
1195 	{
1196 		SfxFrame& rFrame = pViewFrame->GetFrame();
1197 		uno::Reference<frame::XController> xController = rFrame.GetController();
1198 		if (xController.is())
1199 			pRet = ScTabViewObj::getImplementation( xController );
1200 	}
1201 	return pRet;
1202 }
1203 
1204 IMPL_LINK( ScTabViewShell, SimpleRefDone, String*, pResult )
1205 {
1206 	ScTabViewObj* pImpObj = lcl_GetViewObj( *this );
1207 	if ( pImpObj && pResult )
1208 		pImpObj->RangeSelDone( *pResult );
1209 	return 0;
1210 }
1211 
1212 IMPL_LINK( ScTabViewShell, SimpleRefAborted, String*, pResult )
1213 {
1214 	ScTabViewObj* pImpObj = lcl_GetViewObj( *this );
1215 	if ( pImpObj && pResult )
1216 		pImpObj->RangeSelAborted( *pResult );
1217 	return 0;
1218 }
1219 
1220 IMPL_LINK( ScTabViewShell, SimpleRefChange, String*, pResult )
1221 {
1222 	ScTabViewObj* pImpObj = lcl_GetViewObj( *this );
1223 	if ( pImpObj && pResult )
1224 		pImpObj->RangeSelChanged( *pResult );
1225 	return 0;
1226 }
1227 
1228 void ScTabViewShell::StartSimpleRefDialog(
1229             const String& rTitle, const String& rInitVal,
1230             sal_Bool bCloseOnButtonUp, sal_Bool bSingleCell, sal_Bool bMultiSelection )
1231 {
1232 	SfxViewFrame* pViewFrm = GetViewFrame();
1233 
1234     if ( GetActiveViewShell() != this )
1235     {
1236         // #i18833# / #i34499# The API method can be called for a view that's not active.
1237         // Then the view has to be activated first, the same way as in Execute for SID_CURRENTDOC.
1238         // Can't use GrabFocus here, because it needs to take effect immediately.
1239 
1240 		pViewFrm->GetFrame().Appear();
1241     }
1242 
1243 	sal_uInt16 nId = ScSimpleRefDlgWrapper::GetChildWindowId();
1244 
1245 	SC_MOD()->SetRefDialog( nId, sal_True, pViewFrm );
1246 
1247 	ScSimpleRefDlgWrapper* pWnd = (ScSimpleRefDlgWrapper*)pViewFrm->GetChildWindow( nId );
1248 	if (pWnd)
1249 	{
1250 		pWnd->SetCloseHdl( LINK( this, ScTabViewShell, SimpleRefClose ) );
1251 		pWnd->SetUnoLinks( LINK( this, ScTabViewShell, SimpleRefDone ),
1252 						   LINK( this, ScTabViewShell, SimpleRefAborted ),
1253 						   LINK( this, ScTabViewShell, SimpleRefChange ) );
1254 		pWnd->SetRefString( rInitVal );
1255         pWnd->SetFlags( bCloseOnButtonUp, bSingleCell, bMultiSelection );
1256 		pWnd->SetAutoReOpen( sal_False );
1257 		Window* pWin = pWnd->GetWindow();
1258 		pWin->SetText( rTitle );
1259 		pWnd->StartRefInput();
1260 	}
1261 }
1262 
1263 void ScTabViewShell::StopSimpleRefDialog()
1264 {
1265 	SfxViewFrame* pViewFrm = GetViewFrame();
1266 	sal_uInt16 nId = ScSimpleRefDlgWrapper::GetChildWindowId();
1267 
1268 	ScSimpleRefDlgWrapper* pWnd = (ScSimpleRefDlgWrapper*)pViewFrm->GetChildWindow( nId );
1269 	if (pWnd)
1270 	{
1271 		Window* pWin = pWnd->GetWindow();
1272 		if (pWin && pWin->IsSystemWindow())
1273 			((SystemWindow*)pWin)->Close();		// calls abort handler
1274 	}
1275 }
1276 
1277 //------------------------------------------------------------------
1278 
1279 sal_Bool ScTabViewShell::TabKeyInput(const KeyEvent& rKEvt)
1280 {
1281 	ScModule* pScMod = SC_MOD();
1282 
1283 	SfxViewFrame* pThisFrame = GetViewFrame();
1284 	if ( pThisFrame->GetChildWindow( SID_OPENDLG_FUNCTION ) )
1285 		return sal_False;
1286 
1287 	KeyCode aCode   = rKEvt.GetKeyCode();
1288 	sal_Bool bShift     = aCode.IsShift();
1289 	sal_Bool bControl   = aCode.IsMod1();
1290 	sal_Bool bAlt	    = aCode.IsMod2();
1291 	sal_uInt16 nCode	= aCode.GetCode();
1292 	sal_Bool bUsed	    = sal_False;
1293 	sal_Bool bInPlace   = pScMod->IsEditMode(); 	// Editengine bekommt alles
1294 	sal_Bool bAnyEdit   = pScMod->IsInputMode();	// nur Zeichen & Backspace
1295 	sal_Bool bDraw		= IsDrawTextEdit();
1296 
1297 	HideNoteMarker();	// Notiz-Anzeige
1298 
1299     // don't do extra HideCursor/ShowCursor calls if EnterHandler will switch to a different sheet
1300     sal_Bool bOnRefSheet = ( GetViewData()->GetRefTabNo() == GetViewData()->GetTabNo() );
1301     sal_Bool bHideCursor = ( ( nCode == KEY_RETURN && bInPlace ) || nCode == KEY_TAB ) && bOnRefSheet;
1302 
1303 	if (bHideCursor)
1304 		HideAllCursors();
1305 
1306 	ScDocument* pDoc = GetViewData()->GetDocument();
1307 	if ( pDoc )
1308 		pDoc->KeyInput( rKEvt );	// TimerDelays etc.
1309 
1310 	if( bInPlace )
1311 	{
1312 		bUsed = pScMod->InputKeyEvent( rKEvt );			// Eingabe
1313 		if( !bUsed )
1314             bUsed = sal::static_int_cast<sal_Bool>(SfxViewShell::KeyInput( rKEvt ));    // accelerators
1315 	}
1316 	else if( bAnyEdit )
1317 	{
1318 		sal_Bool bIsType = sal_False;
1319 		sal_uInt16 nModi = aCode.GetModifier();
1320 		sal_uInt16 nGroup = aCode.GetGroup();
1321 
1322 		if ( nGroup == KEYGROUP_NUM || nGroup == KEYGROUP_ALPHA || nGroup == 0 )
1323 			if ( !bControl && !bAlt )
1324 				bIsType = sal_True;
1325 
1326 		if ( nGroup == KEYGROUP_MISC )
1327 			switch ( nCode )
1328 			{
1329 				case KEY_RETURN:
1330 					bIsType = bControl && !bAlt;		// Control, Shift-Control-Return
1331 					if ( !bIsType && nModi == 0 )
1332 					{
1333 						//	Will der InputHandler auch ein einfaches Return?
1334 
1335 						ScInputHandler* pHdl = pScMod->GetInputHdl(this);
1336 						bIsType = pHdl && pHdl->TakesReturn();
1337 					}
1338 					break;
1339 				case KEY_SPACE:
1340 					bIsType = !bControl && !bAlt;		// ohne Modifier oder Shift-Space
1341 					break;
1342 				case KEY_ESCAPE:
1343 				case KEY_BACKSPACE:
1344 					bIsType = (nModi == 0);	// nur ohne Modifier
1345 					break;
1346 				default:
1347 					bIsType = sal_True;
1348 			}
1349 
1350 		if( bIsType )
1351 			bUsed = pScMod->InputKeyEvent( rKEvt );		// Eingabe
1352 
1353 		if( !bUsed )
1354             bUsed = sal::static_int_cast<sal_Bool>(SfxViewShell::KeyInput( rKEvt ));    // accelerators
1355 
1356 		if ( !bUsed && !bIsType && nCode != KEY_RETURN )	// Eingabe nochmal hinterher
1357 			bUsed = pScMod->InputKeyEvent( rKEvt );
1358 	}
1359 	else
1360 	{
1361 		//	#51889# Spezialfall: Copy/Cut bei Mehrfachselektion -> Fehlermeldung
1362 		//	(Slot ist disabled, SfxViewShell::KeyInput wuerde also kommentarlos verschluckt)
1363 		KeyFuncType eFunc = aCode.GetFunction();
1364 		if ( eFunc == KEYFUNC_CUT )
1365 		{
1366 			ScRange aDummy;
1367 			ScMarkType eMarkType = GetViewData()->GetSimpleArea( aDummy );
1368 			if ( eMarkType != SC_MARK_SIMPLE &&
1369                     !(eFunc == KEYFUNC_COPY && eMarkType == SC_MARK_SIMPLE_FILTERED) )
1370 			{
1371 				ErrorMessage(STR_NOMULTISELECT);
1372 				bUsed = sal_True;
1373 			}
1374 		}
1375 		if (!bUsed)
1376             bUsed = sal::static_int_cast<sal_Bool>(SfxViewShell::KeyInput( rKEvt ));    // accelerators
1377 
1378 		//	#74696# during inplace editing, some slots are handled by the
1379 		//	container app and are executed during Window::KeyInput.
1380 		//	-> don't pass keys to input handler that would be used there
1381 		//	but should call slots instead.
1382         sal_Bool bParent = ( GetViewFrame()->GetFrame().IsInPlace() && eFunc != KEYFUNC_DONTKNOW );
1383 
1384 		if( !bUsed && !bDraw && nCode != KEY_RETURN && !bParent )
1385 			bUsed = pScMod->InputKeyEvent( rKEvt, sal_True );		// Eingabe
1386 	}
1387 
1388 	if (!bInPlace && !bUsed && !bDraw)
1389 	{
1390 		switch (nCode)
1391 		{
1392 			case KEY_RETURN:
1393 				{
1394 					sal_Bool bNormal = !bControl && !bAlt;
1395 					if ( !bAnyEdit && bNormal )
1396 					{
1397 						//	je nach Optionen mit Enter in den Edit-Modus schalten
1398 
1399 						const ScInputOptions& rOpt = pScMod->GetInputOptions();
1400 						if ( rOpt.GetEnterEdit() )
1401 						{
1402 							pScMod->SetInputMode( SC_INPUT_TABLE );
1403 							bUsed = sal_True;
1404 						}
1405 					}
1406 
1407 					sal_Bool bEditReturn = bControl && !bShift; 		// An Edit-Engine weiter
1408 					if ( !bUsed && !bEditReturn )
1409 					{
1410 					    if ( bOnRefSheet )
1411     						HideAllCursors();
1412 
1413 						sal_uInt8 nMode = SC_ENTER_NORMAL;
1414 						if ( bShift && bControl )
1415 							nMode = SC_ENTER_MATRIX;
1416 						else if ( bAlt )
1417 							nMode = SC_ENTER_BLOCK;
1418 						pScMod->InputEnterHandler(nMode);
1419 
1420 						if (nMode == SC_ENTER_NORMAL)
1421 						{
1422 							if( bShift )
1423 								GetViewData()->GetDispatcher().Execute( SID_CURSORENTERUP,
1424 											SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD );
1425 							else
1426 								GetViewData()->GetDispatcher().Execute( SID_CURSORENTERDOWN,
1427 											SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD );
1428 						}
1429 						else
1430 							UpdateInputHandler(sal_True);
1431 
1432 					    if ( bOnRefSheet )
1433     						ShowAllCursors();
1434 
1435 						//	hier kein UpdateInputHandler, weil bei Referenzeingabe auf ein
1436 						//	anderes Dokument diese ViewShell nicht die ist, auf der eingegeben
1437 						//	wird!
1438 
1439 						bUsed = sal_True;
1440 					}
1441 				}
1442 				break;
1443 		}
1444 	}
1445 
1446 	//	Alt-Cursortasten hart codiert, weil Alt nicht konfigurierbar ist
1447 
1448 	if ( !bUsed && bAlt && !bControl )
1449 	{
1450 		sal_uInt16 nSlotId = 0;
1451 		switch (nCode)
1452 		{
1453 			case KEY_UP:
1454 				ModifyCellSize( DIR_TOP, bShift );
1455 				bUsed = sal_True;
1456 				break;
1457 			case KEY_DOWN:
1458 				ModifyCellSize( DIR_BOTTOM, bShift );
1459 				bUsed = sal_True;
1460 				break;
1461 			case KEY_LEFT:
1462 				ModifyCellSize( DIR_LEFT, bShift );
1463 				bUsed = sal_True;
1464 				break;
1465 			case KEY_RIGHT:
1466 				ModifyCellSize( DIR_RIGHT, bShift );
1467 				bUsed = sal_True;
1468 				break;
1469 			case KEY_PAGEUP:
1470 				nSlotId = bShift ? SID_CURSORPAGELEFT_SEL : SID_CURSORPAGELEFT_;
1471 				break;
1472 			case KEY_PAGEDOWN:
1473 				nSlotId = bShift ? SID_CURSORPAGERIGHT_SEL : SID_CURSORPAGERIGHT_;
1474 				break;
1475 		}
1476 		if ( nSlotId )
1477 		{
1478 			GetViewData()->GetDispatcher().Execute( nSlotId, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD );
1479 			bUsed = sal_True;
1480 		}
1481 	}
1482 
1483 	if (bHideCursor)
1484 		ShowAllCursors();
1485 
1486 	return bUsed;
1487 }
1488 
1489 sal_Bool ScTabViewShell::SfxKeyInput(const KeyEvent& rKeyEvent)
1490 {
1491     return sal::static_int_cast<sal_Bool>(SfxViewShell::KeyInput( rKeyEvent ));
1492 }
1493 
1494 FASTBOOL __EXPORT ScTabViewShell::KeyInput( const KeyEvent &rKeyEvent )
1495 {
1496 //	return SfxViewShell::KeyInput( rKeyEvent );
1497 	return TabKeyInput( rKeyEvent );
1498 }
1499 
1500 //------------------------------------------------------------------
1501 
1502 #define __INIT_ScTabViewShell \
1503 	eCurOST(OST_NONE),			\
1504 	nDrawSfxId(0),				\
1505 	nCtrlSfxId(USHRT_MAX),		\
1506 	nFormSfxId(USHRT_MAX),		\
1507 	pDrawShell(NULL),			\
1508 	pDrawTextShell(NULL),		\
1509 	pEditShell(NULL),			\
1510 	pPivotShell(NULL),			\
1511 	pAuditingShell(NULL),		\
1512 	pDrawFormShell(NULL),		\
1513 	pCellShell(NULL),			\
1514 	pOleObjectShell(NULL),		\
1515 	pChartShell(NULL),			\
1516 	pGraphicShell(NULL),		\
1517 	pMediaShell(NULL),			\
1518 	pPageBreakShell(NULL),		\
1519 	pExtrusionBarShell(NULL),	\
1520 	pFontworkBarShell(NULL),	\
1521 	pFormShell(NULL),			\
1522 	pInputHandler(NULL),		\
1523 	pCurFrameLine(NULL),		\
1524 	aTarget( this ),			\
1525 	pDialogDPObject(NULL),		\
1526     pNavSettings(NULL),         \
1527 	bActiveDrawSh(sal_False),		\
1528 	bActiveDrawTextSh(sal_False),	\
1529 	bActivePivotSh(sal_False),		\
1530 	bActiveAuditingSh(sal_False),	\
1531 	bActiveDrawFormSh(sal_False),	\
1532 	bActiveOleObjectSh(sal_False),	\
1533 	bActiveChartSh(sal_False),		\
1534 	bActiveGraphicSh(sal_False),	\
1535 	bActiveMediaSh(sal_False),		\
1536 	bActiveEditSh(sal_False),       \
1537 	bFormShellAtTop(sal_False),     \
1538 	bDontSwitch(sal_False),			\
1539 	bInFormatDialog(sal_False),		\
1540 	bPrintSelected(sal_False),		\
1541 	bReadOnly(sal_False),			\
1542 	pScSbxObject(NULL),			\
1543 	/*bChartDlgIsEdit(sal_False),*/		\
1544 	bChartAreaValid(sal_False),		\
1545     nCurRefDlgId(0),            \
1546 	pAccessibilityBroadcaster(NULL)
1547 
1548 
1549 //------------------------------------------------------------------
1550 
1551 void ScTabViewShell::Construct( sal_uInt8 nForceDesignMode )
1552 {
1553 	SfxApplication* pSfxApp  = SFX_APP();
1554 	ScDocShell* pDocSh = GetViewData()->GetDocShell();
1555 	ScDocument* pDoc = pDocSh->GetDocument();
1556 
1557 	bReadOnly = pDocSh->IsReadOnly();
1558 
1559 	SetName( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("View")) );	// fuer SBX
1560 	Color aColBlack( COL_BLACK );
1561 //	SetPool( &pSfxApp->GetPool() );
1562 	SetPool( &SC_MOD()->GetPool() );
1563 	SetWindow( GetActiveWin() );
1564 
1565 	pCurFrameLine	= new SvxBorderLine( &aColBlack, 20, 0, 0 );
1566 	pPivotSource	= new ScArea;
1567     StartListening(*GetViewData()->GetDocShell(),sal_True);
1568     StartListening(*GetViewFrame(),sal_True);
1569     StartListening(*pSfxApp,sal_True);              // #i62045# #i62046# application is needed for Calc's own hints
1570 
1571 	SfxViewFrame* pFirst = SfxViewFrame::GetFirst(pDocSh);
1572 	sal_Bool bFirstView = !pFirst
1573 		  || (pFirst == GetViewFrame() && !SfxViewFrame::GetNext(*pFirst,pDocSh));
1574 
1575 	if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
1576 	{
1577         //TODO/LATER: is there a difference between the two GetVisArea methods?
1578         Rectangle aVisArea = ((const SfxObjectShell*)pDocSh)->GetVisArea();
1579 
1580 		SCTAB nVisTab = pDoc->GetVisibleTab();
1581 		if (!pDoc->HasTable(nVisTab))
1582 		{
1583 			nVisTab = 0;
1584 			pDoc->SetVisibleTab(nVisTab);
1585 		}
1586 		SetTabNo( nVisTab );
1587         sal_Bool bNegativePage = pDoc->IsNegativePage( nVisTab );
1588         // show the right cells
1589         GetViewData()->SetScreenPos( bNegativePage ? aVisArea.TopRight() : aVisArea.TopLeft() );
1590 
1591         if ( GetViewFrame()->GetFrame().IsInPlace() )                         // inplace
1592 		{
1593 			pDocSh->SetInplace( sal_True );				// schon so initialisiert
1594 			if (pDoc->IsEmbedded())
1595 				pDoc->ResetEmbedded();				// keine blaue Markierung
1596 		}
1597 		else if ( bFirstView )
1598 		{
1599 			pDocSh->SetInplace( sal_False );
1600             GetViewData()->RefreshZoom();           // recalculate PPT
1601 			if (!pDoc->IsEmbedded())
1602 				pDoc->SetEmbedded( aVisArea );					// VisArea markieren
1603 		}
1604 	}
1605 
1606 	// ViewInputHandler
1607 	//	#48721# jeder Task hat neuerdings sein eigenes InputWindow,
1608 	//	darum muesste eigentlich entweder jeder Task seinen InputHandler bekommen,
1609 	//	oder das InputWindow muesste sich beim App-InputHandler anmelden, wenn der
1610 	//	Task aktiv wird, oder das InputWindow muesste sich den InputHandler selbst
1611 	//	anlegen (dann immer ueber das InputWindow suchen, und nur wenn das nicht da
1612 	//	ist, den InputHandler von der App nehmen).
1613 	//	Als Sofortloesung bekommt erstmal jede View ihren Inputhandler, das gibt
1614 	//	nur noch Probleme, wenn zwei Views in einem Task-Fenster sind.
1615 
1616 	pInputHandler = new ScInputHandler;
1617 
1618 	// Alte Version:
1619 	//	if ( !GetViewFrame()->ISA(SfxTopViewFrame) )		// OLE oder Plug-In
1620 	//		pInputHandler = new ScInputHandler;
1621 
1622 			//	FormShell vor MakeDrawView anlegen, damit die DrawView auf jeden Fall
1623 			//	an der FormShell angemeldet werden kann
1624 			//	Gepusht wird die FormShell im ersten Activate
1625 	pFormShell = new FmFormShell(this);
1626 	pFormShell->SetControlActivationHandler( LINK( this, ScTabViewShell, FormControlActivated ) );
1627 
1628 			//	DrawView darf nicht im TabView - ctor angelegt werden,
1629 			//	wenn die ViewShell noch nicht kostruiert ist...
1630 	if (pDoc->GetDrawLayer())
1631 		MakeDrawView( nForceDesignMode );
1632 	ViewOptionsHasChanged(sal_False);	// legt auch evtl. DrawView an
1633 
1634     ::svl::IUndoManager* pMgr = pDocSh->GetUndoManager();
1635     SetUndoManager( pMgr );
1636     pFormShell->SetUndoManager( pMgr );
1637     if ( !pDoc->IsUndoEnabled() )
1638     {
1639         pMgr->SetMaxUndoActionCount( 0 );
1640     }
1641 	SetRepeatTarget( &aTarget );
1642 	pFormShell->SetRepeatTarget( &aTarget );
1643 	SetHelpId( HID_SCSHELL_TABVWSH );
1644 
1645 	if ( bFirstView )	// first view?
1646 	{
1647 		pDoc->SetDocVisible( sal_True );		// used when creating new sheets
1648 		if ( pDocSh->IsEmpty() )
1649 		{
1650 			// set first sheet's RTL flag (following will already be initialized because of SetDocVisible)
1651 			pDoc->SetLayoutRTL( 0, ScGlobal::IsSystemRTL() );
1652 
1653 			// append additional sheets (not for OLE object)
1654 			if ( pDocSh->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
1655 			{
1656 				SCTAB nInitTabCount = 3;							//!	konfigurierbar !!!
1657 				for (SCTAB i=1; i<nInitTabCount; i++)
1658 					pDoc->MakeTable(i,false);
1659 			}
1660 
1661             pDocSh->SetEmpty( sal_False );          // #i6232# make sure this is done only once
1662 		}
1663 
1664 		// ReadExtOptions is now in Activate
1665 
1666 		//	Link-Update nicht verschachteln
1667 		if ( pDocSh->GetCreateMode() != SFX_CREATE_MODE_INTERNAL &&
1668              pDocSh->IsUpdateEnabled() )  // #105575#; update only in the first creation of the ViewShell
1669 		{
1670             // Check if there are any external data.
1671             bool bLink = pDoc->GetExternalRefManager()->hasExternalData();
1672             if (!bLink)
1673             {
1674                 // #i100042# sheet links can still exist independently from external formula references
1675                 SCTAB nTabCount = pDoc->GetTableCount();
1676                 for (SCTAB i=0; i<nTabCount && !bLink; i++)
1677                     if (pDoc->IsLinked(i))
1678                         bLink = true;
1679             }
1680 			if (!bLink)
1681 				if (pDoc->HasDdeLinks() || pDoc->HasAreaLinks())
1682 					bLink = sal_True;
1683 			if (bLink)
1684 			{
1685 				if ( !pFirst )
1686 					pFirst = GetViewFrame();
1687 
1688 				if(SC_MOD()->GetCurRefDlgId()==0)
1689 				{
1690 						pFirst->GetDispatcher()->Execute( SID_UPDATETABLINKS,
1691 											SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
1692 				}
1693 			}
1694 
1695 			sal_Bool bReImport = sal_False;								// importierte Daten aktualisieren
1696 			ScDBCollection* pDBColl = pDoc->GetDBCollection();
1697 			if ( pDBColl )
1698 			{
1699 				sal_uInt16 nCount = pDBColl->GetCount();
1700 				for (sal_uInt16 i=0; i<nCount && !bReImport; i++)
1701 				{
1702 					ScDBData* pData = (*pDBColl)[i];
1703 					if ( pData->IsStripData() &&
1704 							pData->HasImportParam() && !pData->HasImportSelection() )
1705 						bReImport = sal_True;
1706 				}
1707 			}
1708 			if (bReImport)
1709 			{
1710 				if ( !pFirst )
1711 					pFirst = GetViewFrame();
1712 				if(SC_MOD()->GetCurRefDlgId()==0)
1713 				{
1714 					pFirst->GetDispatcher()->Execute( SID_REIMPORT_AFTER_LOAD,
1715 											SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
1716 				}
1717 			}
1718 		}
1719 	}
1720 
1721 	UpdateAutoFillMark();
1722 
1723 	// ScDispatchProviderInterceptor registers itself in ctor
1724 	xDisProvInterceptor = new ScDispatchProviderInterceptor( this );
1725 
1726 	bFirstActivate = sal_True; // NavigatorUpdate aufschieben bis Activate()
1727 
1728     // #105575#; update only in the first creation of the ViewShell
1729     pDocSh->SetUpdateEnabled(sal_False);
1730 
1731 	if ( GetViewFrame()->GetFrame().IsInPlace() )
1732 		UpdateHeaderWidth(); // The implace activation requires headers to be calculated
1733 
1734 	SvBorder aBorder;
1735     GetBorderSize( aBorder, Size() );
1736 	SetBorderPixel( aBorder );
1737 }
1738 
1739 //------------------------------------------------------------------
1740 
1741 //UNUSED2008-05  ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame,
1742 //UNUSED2008-05                                  const ScTabViewShell& rWin ) :
1743 //UNUSED2008-05  SfxViewShell( pViewFrame, SFX_VIEW_MAXIMIZE_FIRST | SFX_VIEW_CAN_PRINT | SFX_VIEW_HAS_PRINTOPTIONS ),
1744 //UNUSED2008-05  ScDBFunc( &pViewFrame->GetWindow(), rWin, this ),
1745 //UNUSED2008-05  __INIT_ScTabViewShell
1746 //UNUSED2008-05  {
1747 //UNUSED2008-05      RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScTabViewShell::ScTabViewShell" );
1748 //UNUSED2008-05
1749 //UNUSED2008-05      Construct();
1750 //UNUSED2008-05
1751 //UNUSED2008-05      UpdatePageBreakData();
1752 //UNUSED2008-05
1753 //UNUSED2008-05      /*uno::Reference<frame::XFrame> xFrame = pViewFrame->GetFrame().GetFrameInterface();
1754 //UNUSED2008-05      if (xFrame.is())
1755 //UNUSED2008-05          xFrame->setComponent( uno::Reference<awt::XWindow>(), new ScTabViewObj( this ) );*/
1756 //UNUSED2008-05      // make Controller known to SFX
1757 //UNUSED2008-05      new ScTabViewObj( this );
1758 //UNUSED2008-05
1759 //UNUSED2008-05      SetCurSubShell(OST_Cell);
1760 //UNUSED2008-05      SvBorder aBorder;
1761 //UNUSED2008-05      GetBorderSize( aBorder, Size() );
1762 //UNUSED2008-05      SetBorderPixel( aBorder );
1763 //UNUSED2008-05  }
1764 
1765 //------------------------------------------------------------------
1766 
1767 ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame,
1768 								SfxViewShell* pOldSh ) :
1769     SfxViewShell( pViewFrame, SFX_VIEW_CAN_PRINT | SFX_VIEW_HAS_PRINTOPTIONS ),
1770     ScDBFunc( &pViewFrame->GetWindow(), (ScDocShell&)*pViewFrame->GetObjectShell(), this ),
1771     __INIT_ScTabViewShell
1772 {
1773 	RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScTabViewShell::ScTabViewShell" );
1774 
1775 	const ScAppOptions&	rAppOpt = SC_MOD()->GetAppOptions();
1776 
1777 	//	if switching back from print preview,
1778 	//	restore the view settings that were active when creating the preview
1779 	//	#89897# ReadUserData must not happen from ctor, because the view's edit window
1780 	//	has to be shown by the sfx. ReadUserData is deferred until the first Activate call.
1781 	//	#106334# old DesignMode state from form layer must be restored, too
1782 
1783 	sal_uInt8 nForceDesignMode = SC_FORCEMODE_NONE;
1784 	if ( pOldSh && pOldSh->ISA( ScPreviewShell ) )
1785 	{
1786 		ScPreviewShell* pPreviewShell = ((ScPreviewShell*)pOldSh);
1787 		nForceDesignMode = pPreviewShell->GetSourceDesignMode();
1788 	}
1789 
1790 	Construct( nForceDesignMode );
1791 
1792 	if ( GetViewData()->GetDocShell()->IsPreview() )
1793 	{
1794 		//	preview for template dialog: always show whole page
1795         SetZoomType( SVX_ZOOM_WHOLEPAGE, sal_True );    // zoom value is recalculated at next Resize
1796 	}
1797 	else
1798 	{
1799 		Fraction aFract( rAppOpt.GetZoom(), 100 );
1800         SetZoom( aFract, aFract, sal_True );
1801         SetZoomType( rAppOpt.GetZoomType(), sal_True );
1802 	}
1803 
1804     /*uno::Reference<frame::XFrame> xFrame = pViewFrame->GetFrame().GetFrameInterface();
1805 	if (xFrame.is())
1806         xFrame->setComponent( uno::Reference<awt::XWindow>(), new ScTabViewObj( this ) );*/
1807     // make Controller known to SFX
1808     new ScTabViewObj( this );
1809 
1810 	SetCurSubShell(OST_Cell);
1811 	SvBorder aBorder;
1812     GetBorderSize( aBorder, Size() );
1813 	SetBorderPixel( aBorder );
1814 
1815 	// #114409#
1816 	MakeDrawLayer();
1817 }
1818 
1819 #undef __INIT_ScTabViewShell
1820 
1821 //------------------------------------------------------------------
1822 
1823 __EXPORT ScTabViewShell::~ScTabViewShell()
1824 {
1825 	ScDocShell* pDocSh = GetViewData()->GetDocShell();
1826 	EndListening(*pDocSh);
1827 	EndListening(*GetViewFrame());
1828     EndListening(*SFX_APP());           // #i62045# #i62046# needed now - SfxViewShell no longer does it
1829 
1830 	SC_MOD()->ViewShellGone(this);
1831 
1832 	RemoveSubShell();			// alle
1833 	SetWindow(0);
1834 
1835 	//	#54104# alles auf NULL, falls aus dem TabView-dtor noch darauf zugegriffen wird
1836 	//!	(soll eigentlich nicht !??!?!)
1837 
1838 	DELETEZ(pFontworkBarShell);
1839 	DELETEZ(pExtrusionBarShell);
1840 	DELETEZ(pCellShell);
1841 	DELETEZ(pPageBreakShell);
1842 	DELETEZ(pDrawShell);
1843 	DELETEZ(pDrawFormShell);
1844 	DELETEZ(pOleObjectShell);
1845 	DELETEZ(pChartShell);
1846 	DELETEZ(pGraphicShell);
1847 	DELETEZ(pMediaShell);
1848 	DELETEZ(pDrawTextShell);
1849 	DELETEZ(pEditShell);
1850 	DELETEZ(pPivotShell);
1851 	DELETEZ(pAuditingShell);
1852 	DELETEZ(pCurFrameLine);
1853 	DELETEZ(pInputHandler);
1854 	DELETEZ(pPivotSource);
1855 	DELETEZ(pDialogDPObject);
1856     DELETEZ(pNavSettings);
1857 
1858 	DELETEZ(pFormShell);
1859 	DELETEZ(pAccessibilityBroadcaster);
1860 }
1861 
1862 //------------------------------------------------------------------
1863 
1864 void ScTabViewShell::SetDialogDPObject( const ScDPObject* pObj )
1865 {
1866 	delete pDialogDPObject;
1867 	if (pObj)
1868 		pDialogDPObject = new ScDPObject( *pObj );
1869 	else
1870 		pDialogDPObject = NULL;
1871 }
1872 
1873 //------------------------------------------------------------------
1874 
1875 void ScTabViewShell::FillFieldData( ScHeaderFieldData& rData )
1876 {
1877 	ScDocShell* pDocShell = GetViewData()->GetDocShell();
1878 	ScDocument* pDoc = pDocShell->GetDocument();
1879 	SCTAB nTab = GetViewData()->GetTabNo();
1880 	pDoc->GetName( nTab, rData.aTabName );
1881 
1882 	rData.aTitle		= pDocShell->GetTitle();
1883 	const INetURLObject& rURLObj = pDocShell->GetMedium()->GetURLObject();
1884 	rData.aLongDocName	= rURLObj.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
1885 	if ( rData.aLongDocName.Len() )
1886 		rData.aShortDocName = rURLObj.GetName( INetURLObject::DECODE_UNAMBIGUOUS );
1887 	else
1888 		rData.aShortDocName = rData.aLongDocName = rData.aTitle;
1889 	rData.nPageNo		= 1;
1890 	rData.nTotalPages	= 99;
1891 
1892 	//	eNumType kennt der Dialog selber
1893 }
1894 
1895 //------------------------------------------------------------------
1896 
1897 void ScTabViewShell::SetChartArea( const ScRangeListRef& rSource, const Rectangle& rDest )
1898 {
1899 	bChartAreaValid	= sal_True;
1900 	aChartSource	= rSource;
1901 	aChartPos		= rDest;
1902 	nChartDestTab	= GetViewData()->GetTabNo();
1903 }
1904 
1905 //UNUSED2008-05  void ScTabViewShell::ResetChartArea()
1906 //UNUSED2008-05  {
1907 //UNUSED2008-05      bChartAreaValid = sal_False;
1908 //UNUSED2008-05  }
1909 
1910 sal_Bool ScTabViewShell::GetChartArea( ScRangeListRef& rSource, Rectangle& rDest, SCTAB& rTab ) const
1911 {
1912 	rSource	= aChartSource;
1913 	rDest	= aChartPos;
1914 	rTab	= nChartDestTab;
1915 	return bChartAreaValid;
1916 }
1917 
1918 //UNUSED2008-05  sal_Bool ScTabViewShell::IsChartDlgEdit() const
1919 //UNUSED2008-05  {
1920 //UNUSED2008-05      return bChartDlgIsEdit;
1921 //UNUSED2008-05  }
1922 //UNUSED2008-05
1923 //UNUSED2008-05  const String& ScTabViewShell::GetEditChartName() const
1924 //UNUSED2008-05  {
1925 //UNUSED2008-05      return aEditChartName;
1926 //UNUSED2008-05  }
1927 
1928 ScNavigatorSettings* ScTabViewShell::GetNavigatorSettings()
1929 {
1930     if( !pNavSettings )
1931         pNavSettings = new ScNavigatorSettings;
1932     return pNavSettings;
1933 }
1934 
1935 
1936 //------------------------------------------------------------------
1937 
1938 void ScTabViewShell::ExecTbx( SfxRequest& rReq )
1939 {
1940 	const SfxItemSet* pReqArgs = rReq.GetArgs();
1941 	sal_uInt16 nSlot = rReq.GetSlot();
1942 	const SfxPoolItem* pItem = NULL;
1943 	if ( pReqArgs )
1944 		pReqArgs->GetItemState( nSlot, sal_True, &pItem );
1945 
1946 	switch ( nSlot )
1947 	{
1948 		case SID_TBXCTL_INSERT:
1949 			if ( pItem )
1950 				nInsertCtrlState = ((const SfxUInt16Item*)pItem)->GetValue();
1951 			break;
1952 		case SID_TBXCTL_INSCELLS:
1953 			if ( pItem )
1954 				nInsCellsCtrlState = ((const SfxUInt16Item*)pItem)->GetValue();
1955 			break;
1956 		case SID_TBXCTL_INSOBJ:
1957 			if ( pItem )
1958 				nInsObjCtrlState = ((const SfxUInt16Item*)pItem)->GetValue();
1959 			break;
1960 		default:
1961 			DBG_ERROR("Slot im Wald");
1962 	}
1963 	GetViewFrame()->GetBindings().Invalidate( nSlot );
1964 }
1965 
1966 void ScTabViewShell::GetTbxState( SfxItemSet& rSet )
1967 {
1968 	rSet.Put( SfxUInt16Item( SID_TBXCTL_INSERT,   nInsertCtrlState ) );
1969 	rSet.Put( SfxUInt16Item( SID_TBXCTL_INSCELLS, nInsCellsCtrlState ) );
1970 
1971 	//	ohne installiertes Chart darf Chart nicht Default sein...
1972 	if ( nInsObjCtrlState == SID_DRAW_CHART && !SvtModuleOptions().IsChart() )
1973 		nInsObjCtrlState = SID_INSERT_OBJECT;
1974 
1975 	rSet.Put( SfxUInt16Item( SID_TBXCTL_INSOBJ,   nInsObjCtrlState ) );
1976 }
1977 
1978 
1979 
1980 
1981 
1982