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