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