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