Update ooo320-m1
[ooovba.git] / sc / source / ui / view / tabvwsh4.cxx
blob0becaa6587795bc3b87ac51d47ac96eea8a0be5b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tabvwsh4.cxx,v $
10 * $Revision: 1.76.102.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 // INCLUDE ---------------------------------------------------------------
38 #include <sfx2/topfrm.hxx>
39 #include "scitems.hxx"
40 #include <svx/eeitem.hxx>
42 #include <sfx2/app.hxx>
43 #include <svx/extrusionbar.hxx>
44 #include <svx/fontworkbar.hxx>
45 #include <svx/boxitem.hxx>
46 #include <svx/fmshell.hxx>
47 #include <svx/sizeitem.hxx>
48 #include <svx/boxitem.hxx>
49 #include <svx/prtqry.hxx>
50 #include <sfx2/request.hxx>
51 #include <sfx2/printer.hxx>
52 #include <sfx2/dispatch.hxx>
53 #include <svtools/printdlg.hxx>
54 #include <svtools/whiter.hxx>
55 #include <svtools/moduleoptions.hxx>
56 #include <rtl/logfile.hxx>
57 #include <tools/urlobj.hxx>
58 #include <sfx2/docfile.hxx>
60 #include "tabvwsh.hxx"
61 #include "sc.hrc"
62 #include "globstr.hrc"
63 #include "stlpool.hxx"
64 #include "stlsheet.hxx"
65 #include "docsh.hxx"
66 #include "scmod.hxx"
67 #include "appoptio.hxx"
68 #include "rangeutl.hxx"
69 #include "printfun.hxx"
70 #include "drawsh.hxx"
71 #include "drformsh.hxx"
72 #include "editsh.hxx"
73 #include "pivotsh.hxx"
74 #include "auditsh.hxx"
75 #include "drtxtob.hxx"
76 #include "inputhdl.hxx"
77 #include "editutil.hxx"
78 #include "inputopt.hxx"
79 #include "inputwin.hxx"
80 #include "scresid.hxx"
81 #include "dbcolect.hxx" // fuer ReImport
82 #include "reffact.hxx"
83 #include "viewuno.hxx"
84 #include "dispuno.hxx"
85 #include "anyrefdg.hxx"
86 #include "chgtrack.hxx"
87 #include "cellsh.hxx"
88 #include "oleobjsh.hxx"
89 #include "chartsh.hxx"
90 #include "graphsh.hxx"
91 #include "mediash.hxx"
92 #include "pgbrksh.hxx"
93 #include "dpobject.hxx"
94 #include "prevwsh.hxx"
95 #include "tpprint.hxx"
96 #include "scextopt.hxx"
97 #include "printopt.hxx"
98 #include "drawview.hxx"
99 #include "fupoor.hxx"
100 #include "navsett.hxx"
101 #include "sc.hrc" //CHINA001
102 #include "scabstdlg.hxx" //CHINA001
103 #include "externalrefmgr.hxx"
105 void ActivateOlk( ScViewData* pViewData );
106 void DeActivateOlk( ScViewData* pViewData );
108 extern SfxViewShell* pScActiveViewShell; // global.cxx
110 using namespace com::sun::star;
112 // STATIC DATA -----------------------------------------------------------
114 USHORT ScTabViewShell::nInsertCtrlState = SID_INSERT_GRAPHIC;
115 USHORT ScTabViewShell::nInsCellsCtrlState = 0;
116 USHORT ScTabViewShell::nInsObjCtrlState = SID_INSERT_DIAGRAM;
118 // -----------------------------------------------------------------------
120 void __EXPORT ScTabViewShell::Activate(BOOL bMDI)
122 SfxViewShell::Activate(bMDI);
124 // hier kein GrabFocus, sonst gibt's Probleme wenn etwas inplace editiert wird!
126 if ( bMDI )
128 // fuer Eingabezeile (ClearCache)
129 ScModule* pScMod = SC_MOD();
130 pScMod->ViewShellChanged();
132 ActivateView( TRUE, bFirstActivate );
133 ActivateOlk( GetViewData() );
135 // #56870# AutoCorrect umsetzen, falls der Writer seins neu angelegt hat
136 UpdateDrawTextOutliner();
138 // RegisterNewTargetNames gibts nicht mehr
140 SfxViewFrame* pThisFrame = GetViewFrame();
141 if ( pInputHandler && pThisFrame->HasChildWindow(FID_INPUTLINE_STATUS) )
143 // eigentlich nur beim Reload (letzte Version) noetig:
144 // Das InputWindow bleibt stehen, aber die View mitsamt InputHandler wird
145 // neu angelegt, darum muss der InputHandler am InputWindow gesetzt werden.
146 SfxChildWindow* pChild = pThisFrame->GetChildWindow(FID_INPUTLINE_STATUS);
147 if (pChild)
149 ScInputWindow* pWin = (ScInputWindow*)pChild->GetWindow();
150 if (pWin && pWin->IsVisible())
153 ScInputHandler* pOldHdl=pWin->GetInputHandler();
155 TypeId aScType = TYPE(ScTabViewShell);
157 SfxViewShell* pSh = SfxViewShell::GetFirst( &aScType );
158 while ( pSh!=NULL && pOldHdl!=NULL)
160 if (((ScTabViewShell*)pSh)->GetInputHandler() == pOldHdl)
162 pOldHdl->ResetDelayTimer();
163 break;
165 pSh = SfxViewShell::GetNext( *pSh, &aScType );
168 pWin->SetInputHandler( pInputHandler );
173 UpdateInputHandler( TRUE );
175 if ( bFirstActivate )
177 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_NAVIGATOR_UPDATEALL ) );
178 bFirstActivate = FALSE;
180 if ( aPendingUserData.hasElements() )
182 // #89897# read user data from print preview now, after ctor
183 DoReadUserDataSequence( aPendingUserData );
184 aPendingUserData.realloc( 0 );
187 // #116278# ReadExtOptions (view settings from Excel import) must also be done
188 // after the ctor, because of the potential calls to Window::Show.
189 // Even after the fix for #104887# (Window::Show no longer notifies the access
190 // bridge, it's done in ImplSetReallyVisible), there are problems if Window::Show
191 // is called during the ViewShell ctor and reschedules asynchronous calls
192 // (for example from the FmFormShell ctor).
193 ScExtDocOptions* pExtOpt = GetViewData()->GetDocument()->GetExtDocOptions();
194 if ( pExtOpt && pExtOpt->IsChanged() )
196 GetViewData()->ReadExtOptions(*pExtOpt); // Excel view settings
197 SetTabNo( GetViewData()->GetTabNo(), TRUE );
198 pExtOpt->SetChanged( false );
202 pScActiveViewShell = this;
204 ScInputHandler* pHdl = pScMod->GetInputHdl(this);
205 if (pHdl)
207 pHdl->SetRefScale( GetViewData()->GetZoomX(), GetViewData()->GetZoomY() );
210 // Aenderungs-Dialog aktualisieren
212 if ( pThisFrame->HasChildWindow(FID_CHG_ACCEPT) )
214 SfxChildWindow* pChild = pThisFrame->GetChildWindow(FID_CHG_ACCEPT);
215 if (pChild)
217 ((ScAcceptChgDlgWrapper*)pChild)->ReInitDlg();
221 if(pScMod->IsRefDialogOpen())
223 USHORT nModRefDlgId=pScMod->GetCurRefDlgId();
224 SfxChildWindow* pChildWnd = pThisFrame->GetChildWindow( nModRefDlgId );
225 if ( pChildWnd )
227 IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
228 pRefDlg->ViewShellChanged(this);
233 // don't call CheckSelectionTransfer here - activating a view should not change the
234 // primary selection (may be happening just because the mouse was moved over the window)
236 // Wenn Referenzeingabe-Tip-Hilfe hier wieder angezeigt werden soll (ShowRefTip),
237 // muss sie beim Verschieben der View angepasst werden (gibt sonst Probleme unter OS/2
238 // beim Umschalten zwischen Dokumenten)
241 void __EXPORT ScTabViewShell::Deactivate(BOOL bMDI)
243 HideTip();
245 ScDocument* pDoc=GetViewData()->GetDocument();
247 ScChangeTrack* pChanges=pDoc->GetChangeTrack();
249 if(pChanges!=NULL)
251 Link aLink;
252 pChanges->SetModifiedLink(aLink);
255 SfxViewShell::Deactivate(bMDI);
257 ScInputHandler* pHdl = SC_MOD()->GetInputHdl(this);
259 if( bMDI )
261 // #85421# during shell deactivation, shells must not be switched, or the loop
262 // through the shell stack (in SfxDispatcher::DoDeactivate_Impl) will not work
263 BOOL bOldDontSwitch = bDontSwitch;
264 bDontSwitch = TRUE;
266 DeActivateOlk( GetViewData() );
267 ActivateView( FALSE, FALSE );
269 if ( GetViewFrame()->GetFrame()->IsInPlace() ) // inplace
270 GetViewData()->GetDocShell()->UpdateOle(GetViewData(),TRUE);
272 if ( pHdl )
273 pHdl->NotifyChange( NULL, TRUE ); // Timer-verzoegert wg. Dokumentwechsel
275 if (pScActiveViewShell == this)
276 pScActiveViewShell = NULL;
278 bDontSwitch = bOldDontSwitch;
280 else
282 HideNoteMarker(); // Notiz-Anzeige
284 if ( pHdl )
285 pHdl->HideTip(); // Formel-AutoEingabe-Tip abschalten
289 void ScTabViewShell::SetActive()
291 // Die Sfx-View moechte sich gerne selbst aktivieren, weil dabei noch
292 // magische Dinge geschehen (z.B. stuerzt sonst evtl. der Gestalter ab)
293 ActiveGrabFocus();
295 #if 0
296 SfxViewFrame* pFrame = GetViewFrame();
297 if ( pFrame->ISA(SfxTopViewFrame) )
298 pFrame->GetFrame()->Appear();
300 SFX_APP()->SetViewFrame( pFrame ); // immer erst Appear, dann SetViewFrame (#29290#)
301 #endif
304 USHORT __EXPORT ScTabViewShell::PrepareClose(BOOL bUI, BOOL bForBrowsing)
306 // Call EnterHandler even in formula mode here,
307 // so a formula change in an embedded object isn't lost
308 // (ScDocShell::PrepareClose isn't called then).
309 ScInputHandler* pHdl = SC_MOD()->GetInputHdl( this );
310 if ( pHdl && pHdl->IsInputMode() )
311 pHdl->EnterHandler();
313 // #110797# draw text edit mode must be closed
314 FuPoor* pPoor = GetDrawFuncPtr();
315 if ( pPoor && ( IsDrawTextShell() || pPoor->GetSlotID() == SID_DRAW_NOTEEDIT ) )
317 // "clean" end of text edit, including note handling, subshells and draw func switching,
318 // as in FuDraw and ScTabView::DrawDeselectAll
319 GetViewData()->GetDispatcher().Execute( pPoor->GetSlotID(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD );
321 ScDrawView* pDrView = GetScDrawView();
322 if ( pDrView )
324 // force end of text edit, to be safe
325 // #128314# ScEndTextEdit must always be used, to ensure correct UndoManager
326 pDrView->ScEndTextEdit();
329 if ( pFormShell )
331 USHORT nRet = pFormShell->PrepareClose(bUI, bForBrowsing);
332 if (nRet!=TRUE)
333 return nRet;
335 return SfxViewShell::PrepareClose(bUI,bForBrowsing);
338 //------------------------------------------------------------------
340 Size __EXPORT ScTabViewShell::GetOptimalSizePixel() const
342 Size aOptSize;
344 SCTAB nCurTab = GetViewData()->GetTabNo();
345 ScDocument* pDoc = GetViewData()->GetDocument();
346 ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
347 SfxStyleSheetBase* pStyleSheet = pStylePool->Find(
348 pDoc->GetPageStyle( nCurTab ),
349 SFX_STYLE_FAMILY_PAGE );
351 DBG_ASSERT( pStyleSheet, "PageStyle not found :-/" );
353 if ( pStyleSheet )
355 const SfxItemSet& rSet = pStyleSheet->GetItemSet();
356 const SvxSizeItem& rItem = (const SvxSizeItem&)rSet.Get( ATTR_PAGE_SIZE );
357 const Size& rPageSize = rItem.GetSize();
359 aOptSize.Width() = (long) (rPageSize.Width() * GetViewData()->GetPPTX());
360 aOptSize.Height() = (long) (rPageSize.Height() * GetViewData()->GetPPTY());
363 return aOptSize;
366 //------------------------------------------------------------------
368 // Zoom fuer In-Place berechnen
369 // aus Verhaeltnis von VisArea und Fenstergroesse des GridWin
371 void ScTabViewShell::UpdateOleZoom()
373 ScDocShell* pDocSh = GetViewData()->GetDocShell();
374 if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
376 //TODO/LATER: is there a difference between the two GetVisArea methods?
377 Size aObjSize = ((const SfxObjectShell*)pDocSh)->GetVisArea().GetSize();
378 if ( aObjSize.Width() > 0 && aObjSize.Height() > 0 )
380 Window* pWin = GetActiveWin();
381 Size aWinHMM = pWin->PixelToLogic( pWin->GetOutputSizePixel(), MAP_100TH_MM );
382 SetZoomFactor( Fraction( aWinHMM.Width(),aObjSize.Width() ),
383 Fraction( aWinHMM.Height(),aObjSize.Height() ) );
388 void __EXPORT ScTabViewShell::AdjustPosSizePixel( const Point &rPos, const Size &rSize )
390 OuterResizePixel( rPos, rSize );
393 void __EXPORT ScTabViewShell::InnerResizePixel( const Point &rOfs, const Size &rSize )
395 Size aNewSize( rSize );
396 if ( GetViewFrame()->GetFrame()->IsInPlace() )
398 SvBorder aBorder;
399 GetBorderSize( aBorder, rSize );
400 SetBorderPixel( aBorder );
402 Size aObjSize = GetObjectShell()->GetVisArea().GetSize();
404 Size aSize( rSize );
405 aSize.Width() -= (aBorder.Left() + aBorder.Right());
406 aSize.Height() -= (aBorder.Top() + aBorder.Bottom());
408 if ( aObjSize.Width() > 0 && aObjSize.Height() > 0 )
410 Size aLogicSize = GetWindow()->PixelToLogic( aSize, MAP_100TH_MM );
411 SfxViewShell::SetZoomFactor( Fraction( aLogicSize.Width(),aObjSize.Width() ),
412 Fraction( aLogicSize.Height(),aObjSize.Height() ) );
415 Point aPos( rOfs );
416 aPos.X() += aBorder.Left();
417 aPos.Y() += aBorder.Top();
418 GetWindow()->SetPosSizePixel( aPos, aSize );
420 else
422 SvBorder aBorder;
423 GetBorderSize( aBorder, rSize );
424 SetBorderPixel( aBorder );
425 aNewSize.Width() += aBorder.Left() + aBorder.Right();
426 aNewSize.Height() += aBorder.Top() + aBorder.Bottom();
429 DoResize( rOfs, aNewSize, TRUE ); // rSize = Groesse von gridwin
431 UpdateOleZoom(); // Zoom fuer In-Place berechnen
433 // GetViewData()->GetDocShell()->UpdateOle( GetViewData() );
434 GetViewData()->GetDocShell()->SetDocumentModified();
437 void __EXPORT ScTabViewShell::OuterResizePixel( const Point &rOfs, const Size &rSize )
439 SvBorder aBorder;
440 GetBorderSize( aBorder, rSize );
441 SetBorderPixel( aBorder );
443 DoResize( rOfs, rSize ); // Position und Groesse von tabview wie uebergeben
445 // ForceMove als Ersatz fuer den Sfx-Move-Mechanismus
446 // (aWinPos muss aktuell gehalten werden, damit ForceMove beim Ole-Deaktivieren klappt)
448 ForceMove();
451 void __EXPORT ScTabViewShell::SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY )
453 // fuer OLE...
455 Fraction aFrac20( 1,5 );
456 Fraction aFrac400( 4,1 );
458 Fraction aNewX( rZoomX );
459 if ( aNewX < aFrac20 )
460 aNewX = aFrac20;
461 if ( aNewX > aFrac400 )
462 aNewX = aFrac400;
463 Fraction aNewY( rZoomY );
464 if ( aNewY < aFrac20 )
465 aNewY = aFrac20;
466 if ( aNewY > aFrac400 )
467 aNewY = aFrac400;
469 GetViewData()->UpdateScreenZoom( aNewX, aNewY );
470 SetZoom( aNewX, aNewY, TRUE );
472 PaintGrid();
473 PaintTop();
474 PaintLeft();
476 SfxViewShell::SetZoomFactor( rZoomX, rZoomY );
479 void __EXPORT ScTabViewShell::QueryObjAreaPixel( Rectangle& rRect ) const
481 // auf ganze Zellen anpassen (in 1/100 mm)
483 Size aPixelSize = rRect.GetSize();
484 Window* pWin = ((ScTabViewShell*)this)->GetActiveWin();
485 Size aLogicSize = pWin->PixelToLogic( aPixelSize );
487 const ScViewData* pViewData = GetViewData();
488 ScDocument* pDoc = pViewData->GetDocument();
489 ScSplitPos ePos = pViewData->GetActivePart();
490 SCCOL nCol = pViewData->GetPosX(WhichH(ePos));
491 SCROW nRow = pViewData->GetPosY(WhichV(ePos));
492 SCTAB nTab = pViewData->GetTabNo();
493 BOOL bNegativePage = pDoc->IsNegativePage( nTab );
495 Rectangle aLogicRect = pDoc->GetMMRect( nCol, nRow, nCol, nRow, nTab );
496 if ( bNegativePage )
498 // use right edge of aLogicRect, and aLogicSize
499 aLogicRect.Left() = aLogicRect.Right() - aLogicSize.Width() + 1; // Right() is set below
501 aLogicRect.SetSize( aLogicSize );
503 pDoc->SnapVisArea( aLogicRect );
505 rRect.SetSize( pWin->LogicToPixel( aLogicRect.GetSize() ) );
507 #if 0
508 // auf ganze Zellen anpassen (in Pixeln)
510 ScViewData* pViewData = ((ScTabViewShell*)this)->GetViewData();
511 Size aSize = rRect.GetSize();
513 ScSplitPos ePos = pViewData->GetActivePart();
514 Window* pWin = ((ScTabViewShell*)this)->GetActiveWin();
516 Point aTest( aSize.Width(), aSize.Height() );
517 SCsCOL nPosX;
518 SCsROW nPosY;
519 pViewData->GetPosFromPixel( aTest.X(), aTest.Y(), ePos, nPosX, nPosY );
520 BOOL bLeft;
521 BOOL bTop;
522 pViewData->GetMouseQuadrant( aTest, ePos, nPosX, nPosY, bLeft, bTop );
523 if (!bLeft)
524 ++nPosX;
525 if (!bTop)
526 ++nPosY;
527 aTest = pViewData->GetScrPos( (SCCOL)nPosX, (SCROW)nPosY, ePos, TRUE );
529 rRect.SetSize(Size(aTest.X(),aTest.Y()));
530 #endif
533 //------------------------------------------------------------------
535 void __EXPORT ScTabViewShell::Move()
537 Point aNewPos = GetViewFrame()->GetWindow().OutputToScreenPixel(Point());
539 if (aNewPos != aWinPos)
541 StopMarking();
542 aWinPos = aNewPos;
546 //------------------------------------------------------------------
548 void __EXPORT ScTabViewShell::ShowCursor(FASTBOOL /* bOn */)
550 /*!!! ShowCursor wird nicht paarweise wie im gridwin gerufen.
551 Der CursorLockCount am Gridwin muss hier direkt auf 0 gesetzt werden
553 if (bOn)
554 ShowAllCursors();
555 else
556 HideAllCursors();
560 //------------------------------------------------------------------
562 void __EXPORT ScTabViewShell::WriteUserData(String& rData, BOOL /* bBrowse */)
564 GetViewData()->WriteUserData(rData);
567 void ScTabViewShell::WriteUserDataSequence (uno::Sequence < beans::PropertyValue >& rSettings, sal_Bool /* bBrowse */ )
569 GetViewData()->WriteUserDataSequence (rSettings);
572 void __EXPORT ScTabViewShell::ReadUserData(const String& rData, BOOL /* bBrowse */)
574 if ( !GetViewData()->GetDocShell()->IsPreview() )
575 DoReadUserData( rData );
578 void ScTabViewShell::ReadUserDataSequence (const uno::Sequence < beans::PropertyValue >& rSettings, sal_Bool /* bBrowse */ )
580 if ( !GetViewData()->GetDocShell()->IsPreview() )
581 DoReadUserDataSequence( rSettings );
584 void ScTabViewShell::DoReadUserDataSequence( const uno::Sequence < beans::PropertyValue >& rSettings )
586 Window* pOldWin = GetActiveWin();
587 BOOL bFocus = pOldWin && pOldWin->HasFocus();
589 GetViewData()->ReadUserDataSequence(rSettings);
590 SetTabNo( GetViewData()->GetTabNo(), TRUE );
592 if ( GetViewData()->IsPagebreakMode() )
593 SetCurSubShell( GetCurObjectSelectionType(), TRUE );
595 Window* pNewWin = GetActiveWin();
596 if (pNewWin && pNewWin != pOldWin)
598 SetWindow( pNewWin ); //! ist diese ViewShell immer aktiv???
599 if (bFocus)
600 pNewWin->GrabFocus();
601 WindowChanged(); // Drawing-Layer (z.B. #56771#)
604 if (GetViewData()->GetHSplitMode() == SC_SPLIT_FIX ||
605 GetViewData()->GetVSplitMode() == SC_SPLIT_FIX)
607 InvalidateSplit();
610 ZoomChanged();
612 TestHintWindow();
614 //! if ViewData has more tables than document, remove tables in ViewData
615 UIFeatureChanged();
618 // DoReadUserData is also called from ctor when switching from print preview
620 void ScTabViewShell::DoReadUserData( const String& rData )
622 Window* pOldWin = GetActiveWin();
623 BOOL bFocus = pOldWin && pOldWin->HasFocus();
625 GetViewData()->ReadUserData(rData);
626 SetTabNo( GetViewData()->GetTabNo(), TRUE );
628 if ( GetViewData()->IsPagebreakMode() )
629 SetCurSubShell( GetCurObjectSelectionType(), TRUE );
631 Window* pNewWin = GetActiveWin();
632 if (pNewWin && pNewWin != pOldWin)
634 SetWindow( pNewWin ); //! ist diese ViewShell immer aktiv???
635 if (bFocus)
636 pNewWin->GrabFocus();
637 WindowChanged(); // Drawing-Layer (z.B. #56771#)
640 if (GetViewData()->GetHSplitMode() == SC_SPLIT_FIX ||
641 GetViewData()->GetVSplitMode() == SC_SPLIT_FIX)
643 InvalidateSplit();
646 ZoomChanged();
648 TestHintWindow();
650 //! if ViewData has more tables than document, remove tables in ViewData
651 UIFeatureChanged();
654 //------------------------------------------------------------------
656 //UNUSED2008-05 void ScTabViewShell::ExecuteShowNIY( SfxRequest& /* rReq */ )
657 //UNUSED2008-05 {
658 //UNUSED2008-05 ErrorMessage(STR_BOX_YNI);
659 //UNUSED2008-05 }
660 //UNUSED2008-05
661 //UNUSED2008-05 //------------------------------------------------------------------
662 //UNUSED2008-05
663 //UNUSED2008-05 void ScTabViewShell::StateDisabled( SfxItemSet& rSet )
664 //UNUSED2008-05 {
665 //UNUSED2008-05 SfxWhichIter aIter( rSet );
666 //UNUSED2008-05 USHORT nWhich = aIter.FirstWhich();
667 //UNUSED2008-05
668 //UNUSED2008-05 while ( nWhich )
669 //UNUSED2008-05 {
670 //UNUSED2008-05 rSet.DisableItem( nWhich );
671 //UNUSED2008-05 nWhich = aIter.NextWhich();
672 //UNUSED2008-05 }
673 //UNUSED2008-05 }
675 void ScTabViewShell::SetDrawShellOrSub()
677 bActiveDrawSh = TRUE;
679 if(bActiveDrawFormSh)
681 SetCurSubShell(OST_DrawForm);
683 else if(bActiveGraphicSh)
685 SetCurSubShell(OST_Graphic);
687 else if(bActiveMediaSh)
689 SetCurSubShell(OST_Media);
691 else if(bActiveChartSh)
693 SetCurSubShell(OST_Chart);
695 else if(bActiveOleObjectSh)
697 SetCurSubShell(OST_OleObject);
699 else
701 SetCurSubShell(OST_Drawing, true /* force: different toolbars are
702 visible concerning shape type
703 and shape state */);
707 void ScTabViewShell::SetDrawShell( BOOL bActive )
709 if(bActive)
711 SetCurSubShell(OST_Drawing, true /* force: different toolbars are
712 visible concerning shape type
713 and shape state */);
715 else
717 if(bActiveDrawFormSh || bActiveDrawSh ||
718 bActiveGraphicSh || bActiveMediaSh || bActiveOleObjectSh||
719 bActiveChartSh || bActiveDrawTextSh)
721 SetCurSubShell(OST_Cell);
723 bActiveDrawFormSh=FALSE;
724 bActiveGraphicSh=FALSE;
725 bActiveMediaSh=FALSE;
726 bActiveOleObjectSh=FALSE;
727 bActiveChartSh=FALSE;
730 BOOL bWasDraw = bActiveDrawSh || bActiveDrawTextSh;
732 bActiveDrawSh = bActive;
733 bActiveDrawTextSh = FALSE;
735 if ( !bActive )
737 ResetDrawDragMode(); // Mirror / Rotate aus
739 if (bWasDraw && (GetViewData()->GetHSplitMode() == SC_SPLIT_FIX ||
740 GetViewData()->GetVSplitMode() == SC_SPLIT_FIX))
742 // Aktiven Teil an Cursor anpassen, etc.
743 MoveCursorAbs( GetViewData()->GetCurX(), GetViewData()->GetCurY(),
744 SC_FOLLOW_NONE, FALSE, FALSE, TRUE );
749 void ScTabViewShell::SetDrawTextShell( BOOL bActive )
751 bActiveDrawTextSh = bActive;
752 if ( bActive )
754 bActiveDrawFormSh=FALSE;
755 bActiveGraphicSh=FALSE;
756 bActiveMediaSh=FALSE;
757 bActiveOleObjectSh=FALSE;
758 bActiveChartSh=FALSE;
759 bActiveDrawSh = FALSE;
760 SetCurSubShell(OST_DrawText);
762 else
763 SetCurSubShell(OST_Cell);
767 void ScTabViewShell::SetPivotShell( BOOL bActive )
769 bActivePivotSh = bActive;
771 // #68771# #76198# SetPivotShell is called from CursorPosChanged every time
772 // -> don't change anything except switching between cell and pivot shell
774 if ( eCurOST == OST_Pivot || eCurOST == OST_Cell )
776 if ( bActive )
778 bActiveDrawTextSh = bActiveDrawSh = FALSE;
779 bActiveDrawFormSh=FALSE;
780 bActiveGraphicSh=FALSE;
781 bActiveMediaSh=FALSE;
782 bActiveOleObjectSh=FALSE;
783 bActiveChartSh=FALSE;
784 SetCurSubShell(OST_Pivot);
786 else
787 SetCurSubShell(OST_Cell);
791 void ScTabViewShell::SetAuditShell( BOOL bActive )
793 bActiveAuditingSh = bActive;
794 if ( bActive )
796 bActiveDrawTextSh = bActiveDrawSh = FALSE;
797 bActiveDrawFormSh=FALSE;
798 bActiveGraphicSh=FALSE;
799 bActiveMediaSh=FALSE;
800 bActiveOleObjectSh=FALSE;
801 bActiveChartSh=FALSE;
802 SetCurSubShell(OST_Auditing);
804 else
805 SetCurSubShell(OST_Cell);
808 void ScTabViewShell::SetDrawFormShell( BOOL bActive )
810 bActiveDrawFormSh = bActive;
812 if(bActiveDrawFormSh)
813 SetCurSubShell(OST_DrawForm);
815 void ScTabViewShell::SetChartShell( BOOL bActive )
817 bActiveChartSh = bActive;
819 if(bActiveChartSh)
820 SetCurSubShell(OST_Chart);
823 void ScTabViewShell::SetGraphicShell( BOOL bActive )
825 bActiveGraphicSh = bActive;
827 if(bActiveGraphicSh)
828 SetCurSubShell(OST_Graphic);
831 void ScTabViewShell::SetMediaShell( BOOL bActive )
833 bActiveMediaSh = bActive;
835 if(bActiveMediaSh)
836 SetCurSubShell(OST_Media);
839 void ScTabViewShell::SetOleObjectShell( BOOL bActive )
841 bActiveOleObjectSh = bActive;
843 if(bActiveOleObjectSh)
844 SetCurSubShell(OST_OleObject);
845 else
846 SetCurSubShell(OST_Cell);
849 void ScTabViewShell::SetEditShell(EditView* pView, BOOL bActive )
851 if(bActive)
853 if (pEditShell)
854 pEditShell->SetEditView( pView );
855 else
856 pEditShell = new ScEditShell( pView, GetViewData() );
858 SetCurSubShell(OST_Editing);
860 else if(bActiveEditSh)
862 SetCurSubShell(OST_Cell);
864 bActiveEditSh = bActive;
867 void ScTabViewShell::SetCurSubShell(ObjectSelectionType eOST, BOOL bForce)
869 ScViewData* pViewData = GetViewData();
870 ScDocShell* pDocSh = pViewData->GetDocShell();
872 if(bDontSwitch) return;
874 if(!pCellShell) //Wird eh immer gebraucht.
876 pCellShell = new ScCellShell( GetViewData() );
877 pCellShell->SetRepeatTarget( &aTarget );
880 BOOL bPgBrk=pViewData->IsPagebreakMode();
882 if(bPgBrk && !pPageBreakShell)
884 pPageBreakShell = new ScPageBreakShell( this );
885 pPageBreakShell->SetRepeatTarget( &aTarget );
889 if ( eOST!=eCurOST || bForce )
891 BOOL bCellBrush = FALSE; // "format paint brush" allowed for cells
892 BOOL bDrawBrush = FALSE; // "format paint brush" allowed for drawing objects
894 if(eCurOST!=OST_NONE) RemoveSubShell();
896 if (pFormShell && !bFormShellAtTop)
897 AddSubShell(*pFormShell); // add below own subshells
899 switch(eOST)
901 case OST_Cell:
903 AddSubShell(*pCellShell);
904 if(bPgBrk) AddSubShell(*pPageBreakShell);
905 bCellBrush = TRUE;
907 break;
908 case OST_Editing:
910 AddSubShell(*pCellShell);
911 if(bPgBrk) AddSubShell(*pPageBreakShell);
913 if(pEditShell)
915 AddSubShell(*pEditShell);
918 break;
919 case OST_DrawText:
921 if ( !pDrawTextShell )
923 pDocSh->MakeDrawLayer();
924 pDrawTextShell = new ScDrawTextObjectBar( GetViewData() );
926 AddSubShell(*pDrawTextShell);
928 break;
929 case OST_Drawing:
931 if (svx::checkForSelectedCustomShapes(
932 GetScDrawView(), true /* bOnlyExtruded */ )) {
933 if (pExtrusionBarShell == 0)
934 pExtrusionBarShell = new svx::ExtrusionBar(this);
935 AddSubShell( *pExtrusionBarShell );
937 sal_uInt32 nCheckStatus = 0;
938 if (svx::checkForSelectedFontWork(
939 GetScDrawView(), nCheckStatus )) {
940 if (pFontworkBarShell == 0)
941 pFontworkBarShell = new svx::FontworkBar(this);
942 AddSubShell( *pFontworkBarShell );
945 if ( !pDrawShell )
947 pDocSh->MakeDrawLayer();
948 pDrawShell = new ScDrawShell( GetViewData() );
949 pDrawShell->SetRepeatTarget( &aTarget );
951 AddSubShell(*pDrawShell);
952 bDrawBrush = TRUE;
954 break;
956 case OST_DrawForm:
958 if ( !pDrawFormShell )
960 pDocSh->MakeDrawLayer();
961 pDrawFormShell = new ScDrawFormShell( GetViewData() );
962 pDrawFormShell->SetRepeatTarget( &aTarget );
964 AddSubShell(*pDrawFormShell);
965 bDrawBrush = TRUE;
967 break;
969 case OST_Chart:
971 if ( !pChartShell )
973 pDocSh->MakeDrawLayer();
974 pChartShell = new ScChartShell( GetViewData() );
975 pChartShell->SetRepeatTarget( &aTarget );
977 AddSubShell(*pChartShell);
978 bDrawBrush = TRUE;
980 break;
982 case OST_OleObject:
984 if ( !pOleObjectShell )
986 pDocSh->MakeDrawLayer();
987 pOleObjectShell = new ScOleObjectShell( GetViewData() );
988 pOleObjectShell->SetRepeatTarget( &aTarget );
990 AddSubShell(*pOleObjectShell);
991 bDrawBrush = TRUE;
993 break;
995 case OST_Graphic:
997 if ( !pGraphicShell)
999 pDocSh->MakeDrawLayer();
1000 pGraphicShell = new ScGraphicShell( GetViewData() );
1001 pGraphicShell->SetRepeatTarget( &aTarget );
1003 AddSubShell(*pGraphicShell);
1004 bDrawBrush = TRUE;
1006 break;
1008 case OST_Media:
1010 if ( !pMediaShell)
1012 pDocSh->MakeDrawLayer();
1013 pMediaShell = new ScMediaShell( GetViewData() );
1014 pMediaShell->SetRepeatTarget( &aTarget );
1016 AddSubShell(*pMediaShell);
1018 break;
1020 case OST_Pivot:
1022 AddSubShell(*pCellShell);
1023 if(bPgBrk) AddSubShell(*pPageBreakShell);
1025 if ( !pPivotShell )
1027 pPivotShell = new ScPivotShell( this );
1028 pPivotShell->SetRepeatTarget( &aTarget );
1030 AddSubShell(*pPivotShell);
1031 bCellBrush = TRUE;
1033 break;
1034 case OST_Auditing:
1036 AddSubShell(*pCellShell);
1037 if(bPgBrk) AddSubShell(*pPageBreakShell);
1039 if ( !pAuditingShell )
1041 pDocSh->MakeDrawLayer(); // die Wartezeit lieber jetzt als beim Klick
1043 pAuditingShell = new ScAuditingShell( GetViewData() );
1044 pAuditingShell->SetRepeatTarget( &aTarget );
1046 AddSubShell(*pAuditingShell);
1047 bCellBrush = TRUE;
1049 break;
1050 default:
1051 DBG_ERROR("Falsche Shell angefordert");
1052 break;
1055 if (pFormShell && bFormShellAtTop)
1056 AddSubShell(*pFormShell); // add on top of own subshells
1058 eCurOST=eOST;
1060 // abort "format paint brush" when switching to an incompatible shell
1061 if ( ( GetBrushDocument() && !bCellBrush ) || ( GetDrawBrushSet() && !bDrawBrush ) )
1062 ResetBrushDocument();
1066 void ScTabViewShell::SetFormShellAtTop( BOOL bSet )
1068 if ( pFormShell && !bSet )
1069 pFormShell->ForgetActiveControl(); // let the FormShell know it no longer has the focus
1071 if ( bFormShellAtTop != bSet )
1073 bFormShellAtTop = bSet;
1074 SetCurSubShell( GetCurObjectSelectionType(), TRUE );
1078 IMPL_LINK( ScTabViewShell, FormControlActivated, FmFormShell*, EMPTYARG )
1080 // a form control got the focus, so the form shell has to be on top
1081 SetFormShellAtTop( TRUE );
1082 return 0;
1085 ObjectSelectionType ScTabViewShell::GetCurObjectSelectionType()
1087 return eCurOST;
1090 // GetMySubShell / SetMySubShell: altes Verhalten simulieren,
1091 // dass es nur eine SubShell gibt (nur innerhalb der 5 eignenen SubShells)
1093 SfxShell* ScTabViewShell::GetMySubShell() const
1095 // GetSubShell() war frueher const, und GetSubShell(USHORT) sollte es auch sein...
1097 USHORT nPos = 0;
1098 SfxShell* pSub = ((ScTabViewShell*)this)->GetSubShell(nPos);
1099 while (pSub)
1101 if ( pSub == pDrawShell || pSub == pDrawTextShell || pSub == pEditShell ||
1102 pSub == pPivotShell || pSub == pAuditingShell || pSub == pDrawFormShell ||
1103 pSub == pCellShell || pSub == pOleObjectShell|| pSub == pChartShell ||
1104 pSub == pGraphicShell || pSub == pMediaShell || pSub == pPageBreakShell)
1105 return pSub; // gefunden
1107 pSub = ((ScTabViewShell*)this)->GetSubShell(++nPos);
1109 return NULL; // keine von meinen dabei
1112 //UNUSED2008-05 void ScTabViewShell::SetMySubShell( SfxShell* pShell )
1113 //UNUSED2008-05 {
1114 //UNUSED2008-05 SfxShell* pOld = GetMySubShell();
1115 //UNUSED2008-05 if ( pOld != pShell )
1116 //UNUSED2008-05 {
1117 //UNUSED2008-05 if (pOld)
1118 //UNUSED2008-05 RemoveSubShell(pOld); // alte SubShell entfernen
1119 //UNUSED2008-05 if (pShell)
1120 //UNUSED2008-05 AddSubShell(*pShell); // neue setzen
1121 //UNUSED2008-05 }
1122 //UNUSED2008-05 }
1124 BOOL ScTabViewShell::IsDrawTextShell() const
1126 return ( pDrawTextShell && ( GetMySubShell() == pDrawTextShell ) );
1129 BOOL ScTabViewShell::IsAuditShell() const
1131 return ( pAuditingShell && ( GetMySubShell() == pAuditingShell ) );
1134 void ScTabViewShell::SetDrawTextUndo( SfxUndoManager* pNewUndoMgr )
1136 // Default: Undo-Manager der DocShell
1137 if (!pNewUndoMgr)
1138 pNewUndoMgr = GetViewData()->GetDocShell()->GetUndoManager();
1140 if (pDrawTextShell)
1142 pDrawTextShell->SetUndoManager(pNewUndoMgr);
1143 ScDocShell* pDocSh = GetViewData()->GetDocShell();
1144 if ( pNewUndoMgr == pDocSh->GetUndoManager() &&
1145 !pDocSh->GetDocument()->IsUndoEnabled() )
1147 pNewUndoMgr->SetMaxUndoActionCount( 0 );
1150 else
1152 DBG_ERROR("SetDrawTextUndo ohne DrawTextShell");
1156 //------------------------------------------------------------------
1158 ScTabViewShell* ScTabViewShell::GetActiveViewShell()
1160 return PTR_CAST(ScTabViewShell,Current());
1163 //------------------------------------------------------------------
1165 SfxPrinter* __EXPORT ScTabViewShell::GetPrinter( BOOL bCreate )
1167 // Drucker ist immer da (wird fuer die FontListe schon beim Starten angelegt)
1168 return GetViewData()->GetDocShell()->GetPrinter(bCreate);
1171 USHORT __EXPORT ScTabViewShell::SetPrinter( SfxPrinter *pNewPrinter, USHORT nDiffFlags, bool )
1173 return GetViewData()->GetDocShell()->SetPrinter( pNewPrinter, nDiffFlags );
1176 PrintDialog* __EXPORT ScTabViewShell::CreatePrintDialog( Window *pParent )
1178 ScDocShell* pDocShell = GetViewData()->GetDocShell();
1179 ScDocument* pDoc = pDocShell->GetDocument();
1181 pDoc->SetPrintOptions(); // Optionen aus OFA am Printer setzen
1182 SfxPrinter* pPrinter = GetPrinter();
1184 String aStrRange;
1185 PrintDialog* pDlg = new PrintDialog( pParent, true );
1186 SCTAB nTabCount = pDoc->GetTableCount();
1187 long nDocPageMax = 0;
1189 pDlg->EnableSheetRange( true, PRINTSHEETS_ALL );
1190 pDlg->EnableSheetRange( true, PRINTSHEETS_SELECTED_SHEETS );
1191 pDlg->EnableSheetRange( true, PRINTSHEETS_SELECTED_CELLS );
1192 bool bAllTabs = SC_MOD()->GetPrintOptions().GetAllSheets();
1193 pDlg->CheckSheetRange( bAllTabs ? PRINTSHEETS_ALL : PRINTSHEETS_SELECTED_SHEETS );
1195 // update all pending row heights with a single progress bar,
1196 // instead of a separate progress for each sheet from ScPrintFunc
1197 pDocShell->UpdatePendingRowHeights( MAXTAB, true );
1199 ScMarkData aMarkData;
1200 aMarkData.SelectTable( GetViewData()->GetTabNo(), TRUE );
1202 for ( SCTAB i=0; i<nTabCount; i++ )
1204 if ( !bAllTabs && !aMarkData.GetTableSelect( i ) )
1205 continue;
1206 ScPrintFunc aPrintFunc( pDocShell, pPrinter, i );
1207 nDocPageMax += aPrintFunc.GetTotalPages();
1210 if ( nDocPageMax > 0 )
1212 aStrRange = '1';
1213 if ( nDocPageMax > 1 )
1215 aStrRange += '-';
1216 aStrRange += String::CreateFromInt32( nDocPageMax );
1220 pDlg->SetRangeText ( aStrRange );
1221 pDlg->EnableRange ( PRINTDIALOG_ALL );
1222 pDlg->EnableRange ( PRINTDIALOG_RANGE );
1223 pDlg->SetFirstPage ( 1 );
1224 pDlg->SetMinPage ( 1 );
1225 pDlg->SetLastPage ( (USHORT)nDocPageMax );
1226 pDlg->SetMaxPage ( (USHORT)nDocPageMax );
1227 pDlg->EnableCollate ();
1229 return pDlg;
1232 SfxTabPage* ScTabViewShell::CreatePrintOptionsPage( Window *pParent, const SfxItemSet &rOptions )
1234 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
1235 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
1236 //CHINA001 return ScTpPrintOptions::Create( pParent, rOptions );
1237 ::CreateTabPage ScTpPrintOptionsCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_PRINT );
1238 if ( ScTpPrintOptionsCreate )
1239 return (*ScTpPrintOptionsCreate)( pParent, rOptions);
1240 return 0;
1243 void __EXPORT ScTabViewShell::PreparePrint( PrintDialog* pPrintDialog )
1245 ScDocShell* pDocShell = GetViewData()->GetDocShell();
1247 SfxViewShell::PreparePrint( pPrintDialog );
1248 pDocShell->PreparePrint( pPrintDialog, &GetViewData()->GetMarkData() );
1251 ErrCode ScTabViewShell::DoPrint( SfxPrinter *pPrinter,
1252 PrintDialog *pPrintDialog, BOOL bSilent, BOOL bIsAPI )
1254 // #72527# if SID_PRINTDOCDIRECT is executed and there's a selection,
1255 // ask if only the selection should be printed
1257 const ScMarkData& rMarkData = GetViewData()->GetMarkData();
1258 if ( !pPrintDialog && !bSilent && !bIsAPI && ( rMarkData.IsMarked() || rMarkData.IsMultiMarked() ) )
1260 SvxPrtQryBox aQuery( GetDialogParent() );
1261 short nBtn = aQuery.Execute();
1263 if ( nBtn == RET_CANCEL )
1264 return ERRCODE_IO_ABORT;
1266 if ( nBtn == RET_OK )
1267 bPrintSelected = TRUE;
1270 ErrCode nRet = ERRCODE_IO_ABORT;
1272 ScDocShell* pDocShell = GetViewData()->GetDocShell();
1273 if ( pDocShell->CheckPrint( pPrintDialog, &GetViewData()->GetMarkData(), bPrintSelected, bIsAPI ) )
1275 // get the list of affected sheets before SfxViewShell::Print
1276 bool bAllTabs = ( pPrintDialog ? ( pPrintDialog->GetCheckedSheetRange() == PRINTSHEETS_ALL ) : SC_MOD()->GetPrintOptions().GetAllSheets() );
1278 uno::Sequence<sal_Int32> aSheets;
1279 SCTAB nTabCount = pDocShell->GetDocument()->GetTableCount();
1280 USHORT nPrinted = 0;
1281 for ( SCTAB nTab=0; nTab<nTabCount; nTab++ )
1282 if ( bAllTabs || rMarkData.GetTableSelect(nTab) )
1284 aSheets.realloc( nPrinted + 1 );
1285 aSheets[nPrinted] = nTab;
1286 ++nPrinted;
1289 uno::Sequence < beans::PropertyValue > aProps(1);
1290 aProps[0].Name=::rtl::OUString::createFromAscii("PrintSheets");
1291 aProps[0].Value <<= aSheets;
1292 SetAdditionalPrintOptions( aProps );
1294 // SfxViewShell::DoPrint calls Print (after StartJob etc.)
1295 nRet = SfxViewShell::DoPrint( pPrinter, pPrintDialog, bSilent, bIsAPI );
1298 bPrintSelected = FALSE;
1300 return nRet;
1303 USHORT __EXPORT ScTabViewShell::Print( SfxProgress& rProgress, BOOL bIsAPI,
1304 PrintDialog* pPrintDialog )
1306 ScDocShell* pDocShell = GetViewData()->GetDocShell();
1307 pDocShell->GetDocument()->SetPrintOptions(); // Optionen aus OFA am Printer setzen
1309 SfxViewShell::Print( rProgress, bIsAPI, pPrintDialog );
1310 pDocShell->Print( rProgress, pPrintDialog, &GetViewData()->GetMarkData(),
1311 GetDialogParent(), bPrintSelected, bIsAPI );
1312 return 0;
1315 void ScTabViewShell::StopEditShell()
1317 if ( pEditShell != NULL && !bDontSwitch )
1318 SetEditShell(NULL, FALSE );
1321 //------------------------------------------------------------------
1323 // close handler to ensure function of dialog:
1325 IMPL_LINK( ScTabViewShell, SimpleRefClose, String*, EMPTYARG )
1327 SfxInPlaceClient* pClient = GetIPClient();
1328 if ( pClient && pClient->IsObjectInPlaceActive() )
1330 // If range selection was started with an active embedded object,
1331 // switch back to original sheet (while the dialog is still open).
1333 SetTabNo( GetViewData()->GetRefTabNo() );
1336 ScSimpleRefDlgWrapper::SetAutoReOpen( TRUE );
1337 return 0;
1340 // handlers to call UNO listeners:
1342 ScTabViewObj* lcl_GetViewObj( ScTabViewShell& rShell )
1344 ScTabViewObj* pRet = NULL;
1345 SfxViewFrame* pViewFrame = rShell.GetViewFrame();
1346 if (pViewFrame)
1348 SfxFrame* pFrame = pViewFrame->GetFrame();
1349 if (pFrame)
1351 uno::Reference<frame::XController> xController = pFrame->GetController();
1352 if (xController.is())
1353 pRet = ScTabViewObj::getImplementation( xController );
1356 return pRet;
1359 IMPL_LINK( ScTabViewShell, SimpleRefDone, String*, pResult )
1361 ScTabViewObj* pImpObj = lcl_GetViewObj( *this );
1362 if ( pImpObj && pResult )
1363 pImpObj->RangeSelDone( *pResult );
1364 return 0;
1367 IMPL_LINK( ScTabViewShell, SimpleRefAborted, String*, pResult )
1369 ScTabViewObj* pImpObj = lcl_GetViewObj( *this );
1370 if ( pImpObj && pResult )
1371 pImpObj->RangeSelAborted( *pResult );
1372 return 0;
1375 IMPL_LINK( ScTabViewShell, SimpleRefChange, String*, pResult )
1377 ScTabViewObj* pImpObj = lcl_GetViewObj( *this );
1378 if ( pImpObj && pResult )
1379 pImpObj->RangeSelChanged( *pResult );
1380 return 0;
1383 void ScTabViewShell::StartSimpleRefDialog(
1384 const String& rTitle, const String& rInitVal,
1385 BOOL bCloseOnButtonUp, BOOL bSingleCell, BOOL bMultiSelection )
1387 SfxViewFrame* pViewFrm = GetViewFrame();
1389 if ( GetActiveViewShell() != this )
1391 // #i18833# / #i34499# The API method can be called for a view that's not active.
1392 // Then the view has to be activated first, the same way as in Execute for SID_CURRENTDOC.
1393 // Can't use GrabFocus here, because it needs to take effect immediately.
1395 if ( pViewFrm->ISA(SfxTopViewFrame) )
1396 pViewFrm->GetFrame()->Appear();
1399 USHORT nId = ScSimpleRefDlgWrapper::GetChildWindowId();
1401 SC_MOD()->SetRefDialog( nId, TRUE, pViewFrm );
1403 ScSimpleRefDlgWrapper* pWnd = (ScSimpleRefDlgWrapper*)pViewFrm->GetChildWindow( nId );
1404 if (pWnd)
1406 pWnd->SetCloseHdl( LINK( this, ScTabViewShell, SimpleRefClose ) );
1407 pWnd->SetUnoLinks( LINK( this, ScTabViewShell, SimpleRefDone ),
1408 LINK( this, ScTabViewShell, SimpleRefAborted ),
1409 LINK( this, ScTabViewShell, SimpleRefChange ) );
1410 pWnd->SetRefString( rInitVal );
1411 pWnd->SetFlags( bCloseOnButtonUp, bSingleCell, bMultiSelection );
1412 pWnd->SetAutoReOpen( FALSE );
1413 Window* pWin = pWnd->GetWindow();
1414 pWin->SetText( rTitle );
1415 pWnd->StartRefInput();
1419 void ScTabViewShell::StopSimpleRefDialog()
1421 SfxViewFrame* pViewFrm = GetViewFrame();
1422 USHORT nId = ScSimpleRefDlgWrapper::GetChildWindowId();
1424 ScSimpleRefDlgWrapper* pWnd = (ScSimpleRefDlgWrapper*)pViewFrm->GetChildWindow( nId );
1425 if (pWnd)
1427 Window* pWin = pWnd->GetWindow();
1428 if (pWin && pWin->IsSystemWindow())
1429 ((SystemWindow*)pWin)->Close(); // calls abort handler
1433 //------------------------------------------------------------------
1435 BOOL ScTabViewShell::TabKeyInput(const KeyEvent& rKEvt)
1437 ScModule* pScMod = SC_MOD();
1439 SfxViewFrame* pThisFrame = GetViewFrame();
1440 if ( pThisFrame->GetChildWindow( SID_OPENDLG_FUNCTION ) )
1441 return FALSE;
1443 KeyCode aCode = rKEvt.GetKeyCode();
1444 BOOL bShift = aCode.IsShift();
1445 BOOL bControl = aCode.IsMod1();
1446 BOOL bAlt = aCode.IsMod2();
1447 USHORT nCode = aCode.GetCode();
1448 BOOL bUsed = FALSE;
1449 BOOL bInPlace = pScMod->IsEditMode(); // Editengine bekommt alles
1450 BOOL bAnyEdit = pScMod->IsInputMode(); // nur Zeichen & Backspace
1451 BOOL bDraw = IsDrawTextEdit();
1453 HideNoteMarker(); // Notiz-Anzeige
1455 // don't do extra HideCursor/ShowCursor calls if EnterHandler will switch to a different sheet
1456 BOOL bOnRefSheet = ( GetViewData()->GetRefTabNo() == GetViewData()->GetTabNo() );
1457 BOOL bHideCursor = ( ( nCode == KEY_RETURN && bInPlace ) || nCode == KEY_TAB ) && bOnRefSheet;
1459 if (bHideCursor)
1460 HideAllCursors();
1462 ScDocument* pDoc = GetViewData()->GetDocument();
1463 if ( pDoc )
1464 pDoc->KeyInput( rKEvt ); // TimerDelays etc.
1466 if( bInPlace )
1468 bUsed = pScMod->InputKeyEvent( rKEvt ); // Eingabe
1469 if( !bUsed )
1470 bUsed = sal::static_int_cast<BOOL>(SfxViewShell::KeyInput( rKEvt )); // accelerators
1472 else if( bAnyEdit )
1474 BOOL bIsType = FALSE;
1475 USHORT nModi = aCode.GetModifier();
1476 USHORT nGroup = aCode.GetGroup();
1478 if ( nGroup == KEYGROUP_NUM || nGroup == KEYGROUP_ALPHA || nGroup == 0 )
1479 if ( !bControl && !bAlt )
1480 bIsType = TRUE;
1482 if ( nGroup == KEYGROUP_MISC )
1483 switch ( nCode )
1485 case KEY_RETURN:
1486 bIsType = bControl && !bAlt; // Control, Shift-Control-Return
1487 if ( !bIsType && nModi == 0 )
1489 // Will der InputHandler auch ein einfaches Return?
1491 ScInputHandler* pHdl = pScMod->GetInputHdl(this);
1492 bIsType = pHdl && pHdl->TakesReturn();
1494 break;
1495 case KEY_SPACE:
1496 bIsType = !bControl && !bAlt; // ohne Modifier oder Shift-Space
1497 break;
1498 case KEY_ESCAPE:
1499 case KEY_BACKSPACE:
1500 bIsType = (nModi == 0); // nur ohne Modifier
1501 break;
1502 default:
1503 bIsType = TRUE;
1506 if( bIsType )
1507 bUsed = pScMod->InputKeyEvent( rKEvt ); // Eingabe
1509 if( !bUsed )
1510 bUsed = sal::static_int_cast<BOOL>(SfxViewShell::KeyInput( rKEvt )); // accelerators
1512 if ( !bUsed && !bIsType && nCode != KEY_RETURN ) // Eingabe nochmal hinterher
1513 bUsed = pScMod->InputKeyEvent( rKEvt );
1515 else
1517 // #51889# Spezialfall: Copy/Cut bei Mehrfachselektion -> Fehlermeldung
1518 // (Slot ist disabled, SfxViewShell::KeyInput wuerde also kommentarlos verschluckt)
1519 KeyFuncType eFunc = aCode.GetFunction();
1520 if ( eFunc == KEYFUNC_CUT )
1522 ScRange aDummy;
1523 ScMarkType eMarkType = GetViewData()->GetSimpleArea( aDummy );
1524 if ( eMarkType != SC_MARK_SIMPLE &&
1525 !(eFunc == KEYFUNC_COPY && eMarkType == SC_MARK_SIMPLE_FILTERED) )
1527 ErrorMessage(STR_NOMULTISELECT);
1528 bUsed = TRUE;
1531 if (!bUsed)
1532 bUsed = sal::static_int_cast<BOOL>(SfxViewShell::KeyInput( rKEvt )); // accelerators
1534 // #74696# during inplace editing, some slots are handled by the
1535 // container app and are executed during Window::KeyInput.
1536 // -> don't pass keys to input handler that would be used there
1537 // but should call slots instead.
1538 BOOL bParent = ( GetViewFrame()->GetFrame()->IsInPlace() && eFunc != KEYFUNC_DONTKNOW );
1540 if( !bUsed && !bDraw && nCode != KEY_RETURN && !bParent )
1541 bUsed = pScMod->InputKeyEvent( rKEvt, TRUE ); // Eingabe
1544 if (!bInPlace && !bUsed && !bDraw)
1546 switch (nCode)
1548 case KEY_RETURN:
1550 BOOL bNormal = !bControl && !bAlt;
1551 if ( !bAnyEdit && bNormal )
1553 // je nach Optionen mit Enter in den Edit-Modus schalten
1555 const ScInputOptions& rOpt = pScMod->GetInputOptions();
1556 if ( rOpt.GetEnterEdit() )
1558 pScMod->SetInputMode( SC_INPUT_TABLE );
1559 bUsed = TRUE;
1563 BOOL bEditReturn = bControl && !bShift; // An Edit-Engine weiter
1564 if ( !bUsed && !bEditReturn )
1566 if ( bOnRefSheet )
1567 HideAllCursors();
1569 BYTE nMode = SC_ENTER_NORMAL;
1570 if ( bShift && bControl )
1571 nMode = SC_ENTER_MATRIX;
1572 else if ( bAlt )
1573 nMode = SC_ENTER_BLOCK;
1574 pScMod->InputEnterHandler(nMode);
1576 if (nMode == SC_ENTER_NORMAL)
1578 if( bShift )
1579 GetViewData()->GetDispatcher().Execute( SID_CURSORENTERUP,
1580 SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD );
1581 else
1582 GetViewData()->GetDispatcher().Execute( SID_CURSORENTERDOWN,
1583 SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD );
1585 else
1586 UpdateInputHandler(TRUE);
1588 if ( bOnRefSheet )
1589 ShowAllCursors();
1591 // hier kein UpdateInputHandler, weil bei Referenzeingabe auf ein
1592 // anderes Dokument diese ViewShell nicht die ist, auf der eingegeben
1593 // wird!
1595 bUsed = TRUE;
1598 break;
1602 // Alt-Cursortasten hart codiert, weil Alt nicht konfigurierbar ist
1604 if ( !bUsed && bAlt && !bControl )
1606 USHORT nSlotId = 0;
1607 switch (nCode)
1609 case KEY_UP:
1610 ModifyCellSize( DIR_TOP, bShift );
1611 bUsed = TRUE;
1612 break;
1613 case KEY_DOWN:
1614 ModifyCellSize( DIR_BOTTOM, bShift );
1615 bUsed = TRUE;
1616 break;
1617 case KEY_LEFT:
1618 ModifyCellSize( DIR_LEFT, bShift );
1619 bUsed = TRUE;
1620 break;
1621 case KEY_RIGHT:
1622 ModifyCellSize( DIR_RIGHT, bShift );
1623 bUsed = TRUE;
1624 break;
1625 case KEY_PAGEUP:
1626 nSlotId = bShift ? SID_CURSORPAGELEFT_SEL : SID_CURSORPAGELEFT_;
1627 break;
1628 case KEY_PAGEDOWN:
1629 nSlotId = bShift ? SID_CURSORPAGERIGHT_SEL : SID_CURSORPAGERIGHT_;
1630 break;
1632 if ( nSlotId )
1634 GetViewData()->GetDispatcher().Execute( nSlotId, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD );
1635 bUsed = TRUE;
1639 if (bHideCursor)
1640 ShowAllCursors();
1642 return bUsed;
1645 BOOL ScTabViewShell::SfxKeyInput(const KeyEvent& rKeyEvent)
1647 return sal::static_int_cast<BOOL>(SfxViewShell::KeyInput( rKeyEvent ));
1650 FASTBOOL __EXPORT ScTabViewShell::KeyInput( const KeyEvent &rKeyEvent )
1652 // return SfxViewShell::KeyInput( rKeyEvent );
1653 return TabKeyInput( rKeyEvent );
1656 //------------------------------------------------------------------
1658 // SfxViewShell( pViewFrame, SFX_VIEW_MAXIMIZE_FIRST | SFX_VIEW_DISABLE_ACCELS ),
1660 #define __INIT_ScTabViewShell \
1661 eCurOST(OST_NONE), \
1662 nDrawSfxId(0), \
1663 nCtrlSfxId(USHRT_MAX), \
1664 nFormSfxId(USHRT_MAX), \
1665 pDrawShell(NULL), \
1666 pDrawTextShell(NULL), \
1667 pEditShell(NULL), \
1668 pPivotShell(NULL), \
1669 pAuditingShell(NULL), \
1670 pDrawFormShell(NULL), \
1671 pCellShell(NULL), \
1672 pOleObjectShell(NULL), \
1673 pChartShell(NULL), \
1674 pGraphicShell(NULL), \
1675 pMediaShell(NULL), \
1676 pPageBreakShell(NULL), \
1677 pExtrusionBarShell(NULL), \
1678 pFontworkBarShell(NULL), \
1679 pFormShell(NULL), \
1680 pInputHandler(NULL), \
1681 pCurFrameLine(NULL), \
1682 aTarget( this ), \
1683 pDialogDPObject(NULL), \
1684 pNavSettings(NULL), \
1685 bActiveDrawSh(FALSE), \
1686 bActiveDrawTextSh(FALSE), \
1687 bActivePivotSh(FALSE), \
1688 bActiveAuditingSh(FALSE), \
1689 bActiveDrawFormSh(FALSE), \
1690 bActiveOleObjectSh(FALSE), \
1691 bActiveChartSh(FALSE), \
1692 bActiveGraphicSh(FALSE), \
1693 bActiveMediaSh(FALSE), \
1694 bActiveEditSh(FALSE), \
1695 bFormShellAtTop(FALSE), \
1696 bDontSwitch(FALSE), \
1697 bInFormatDialog(FALSE), \
1698 bPrintSelected(FALSE), \
1699 bReadOnly(FALSE), \
1700 pScSbxObject(NULL), \
1701 /*bChartDlgIsEdit(FALSE),*/ \
1702 bChartAreaValid(FALSE), \
1703 nCurRefDlgId(0), \
1704 pAccessibilityBroadcaster(NULL)
1707 //------------------------------------------------------------------
1709 void ScTabViewShell::Construct( BYTE nForceDesignMode )
1711 SfxApplication* pSfxApp = SFX_APP();
1712 ScDocShell* pDocSh = GetViewData()->GetDocShell();
1713 ScDocument* pDoc = pDocSh->GetDocument();
1715 bReadOnly = pDocSh->IsReadOnly();
1717 SetName( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("View")) ); // fuer SBX
1718 Color aColBlack( COL_BLACK );
1719 // SetPool( &pSfxApp->GetPool() );
1720 SetPool( &SC_MOD()->GetPool() );
1721 SetWindow( GetActiveWin() );
1723 pCurFrameLine = new SvxBorderLine( &aColBlack, 20, 0, 0 );
1724 pPivotSource = new ScArea;
1725 StartListening(*GetViewData()->GetDocShell(),TRUE);
1726 StartListening(*GetViewFrame(),TRUE);
1727 StartListening(*pSfxApp,TRUE); // #i62045# #i62046# application is needed for Calc's own hints
1729 SfxViewFrame* pFirst = SfxViewFrame::GetFirst(pDocSh);
1730 BOOL bFirstView = !pFirst
1731 || (pFirst == GetViewFrame() && !SfxViewFrame::GetNext(*pFirst,pDocSh));
1733 if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
1735 //TODO/LATER: is there a difference between the two GetVisArea methods?
1736 Rectangle aVisArea = ((const SfxObjectShell*)pDocSh)->GetVisArea();
1738 SCTAB nVisTab = pDoc->GetVisibleTab();
1739 if (!pDoc->HasTable(nVisTab))
1741 nVisTab = 0;
1742 pDoc->SetVisibleTab(nVisTab);
1744 SetTabNo( nVisTab );
1745 BOOL bNegativePage = pDoc->IsNegativePage( nVisTab );
1746 // show the right cells
1747 GetViewData()->SetScreenPos( bNegativePage ? aVisArea.TopRight() : aVisArea.TopLeft() );
1749 if ( GetViewFrame()->GetFrame()->IsInPlace() ) // inplace
1751 pDocSh->SetInplace( TRUE ); // schon so initialisiert
1752 if (pDoc->IsEmbedded())
1753 pDoc->ResetEmbedded(); // keine blaue Markierung
1755 else if ( bFirstView )
1757 pDocSh->SetInplace( FALSE );
1758 GetViewData()->RefreshZoom(); // recalculate PPT
1759 if (!pDoc->IsEmbedded())
1760 pDoc->SetEmbedded( aVisArea ); // VisArea markieren
1764 // ViewInputHandler
1765 // #48721# jeder Task hat neuerdings sein eigenes InputWindow,
1766 // darum muesste eigentlich entweder jeder Task seinen InputHandler bekommen,
1767 // oder das InputWindow muesste sich beim App-InputHandler anmelden, wenn der
1768 // Task aktiv wird, oder das InputWindow muesste sich den InputHandler selbst
1769 // anlegen (dann immer ueber das InputWindow suchen, und nur wenn das nicht da
1770 // ist, den InputHandler von der App nehmen).
1771 // Als Sofortloesung bekommt erstmal jede View ihren Inputhandler, das gibt
1772 // nur noch Probleme, wenn zwei Views in einem Task-Fenster sind.
1774 pInputHandler = new ScInputHandler;
1776 // Alte Version:
1777 // if ( !GetViewFrame()->ISA(SfxTopViewFrame) ) // OLE oder Plug-In
1778 // pInputHandler = new ScInputHandler;
1780 // FormShell vor MakeDrawView anlegen, damit die DrawView auf jeden Fall
1781 // an der FormShell angemeldet werden kann
1782 // Gepusht wird die FormShell im ersten Activate
1783 pFormShell = new FmFormShell(this);
1784 pFormShell->SetControlActivationHandler( LINK( this, ScTabViewShell, FormControlActivated ) );
1786 // DrawView darf nicht im TabView - ctor angelegt werden,
1787 // wenn die ViewShell noch nicht kostruiert ist...
1788 if (pDoc->GetDrawLayer())
1789 MakeDrawView( nForceDesignMode );
1790 ViewOptionsHasChanged(FALSE); // legt auch evtl. DrawView an
1792 SfxUndoManager* pMgr = pDocSh->GetUndoManager();
1793 SetUndoManager( pMgr );
1794 pFormShell->SetUndoManager( pMgr );
1795 if ( !pDoc->IsUndoEnabled() )
1797 pMgr->SetMaxUndoActionCount( 0 );
1799 SetRepeatTarget( &aTarget );
1800 pFormShell->SetRepeatTarget( &aTarget );
1801 SetHelpId( HID_SCSHELL_TABVWSH );
1803 if ( bFirstView ) // first view?
1805 pDoc->SetDocVisible( TRUE ); // used when creating new sheets
1806 if ( pDocSh->IsEmpty() )
1808 // set first sheet's RTL flag (following will already be initialized because of SetDocVisible)
1809 pDoc->SetLayoutRTL( 0, ScGlobal::IsSystemRTL() );
1811 // append additional sheets (not for OLE object)
1812 if ( pDocSh->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
1814 SCTAB nInitTabCount = 3; //! konfigurierbar !!!
1815 for (SCTAB i=1; i<nInitTabCount; i++)
1816 pDoc->MakeTable(i,false);
1819 pDocSh->SetEmpty( FALSE ); // #i6232# make sure this is done only once
1822 // ReadExtOptions is now in Activate
1824 // Link-Update nicht verschachteln
1825 if ( pDocSh->GetCreateMode() != SFX_CREATE_MODE_INTERNAL &&
1826 pDocSh->IsUpdateEnabled() ) // #105575#; update only in the first creation of the ViewShell
1828 // Check if there are any external data.
1829 bool bLink = pDoc->GetExternalRefManager()->hasExternalData();
1830 if (!bLink)
1832 // #i100042# sheet links can still exist independently from external formula references
1833 SCTAB nTabCount = pDoc->GetTableCount();
1834 for (SCTAB i=0; i<nTabCount && !bLink; i++)
1835 if (pDoc->IsLinked(i))
1836 bLink = true;
1838 if (!bLink)
1839 if (pDoc->HasDdeLinks() || pDoc->HasAreaLinks())
1840 bLink = TRUE;
1841 if (bLink)
1843 if ( !pFirst )
1844 pFirst = GetViewFrame();
1846 if(SC_MOD()->GetCurRefDlgId()==0)
1848 pFirst->GetDispatcher()->Execute( SID_UPDATETABLINKS,
1849 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
1853 BOOL bReImport = FALSE; // importierte Daten aktualisieren
1854 ScDBCollection* pDBColl = pDoc->GetDBCollection();
1855 if ( pDBColl )
1857 USHORT nCount = pDBColl->GetCount();
1858 for (USHORT i=0; i<nCount && !bReImport; i++)
1860 ScDBData* pData = (*pDBColl)[i];
1861 if ( pData->IsStripData() &&
1862 pData->HasImportParam() && !pData->HasImportSelection() )
1863 bReImport = TRUE;
1866 if (bReImport)
1868 if ( !pFirst )
1869 pFirst = GetViewFrame();
1870 if(SC_MOD()->GetCurRefDlgId()==0)
1872 pFirst->GetDispatcher()->Execute( SID_REIMPORT_AFTER_LOAD,
1873 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
1879 UpdateAutoFillMark();
1881 // ScDispatchProviderInterceptor registers itself in ctor
1882 xDisProvInterceptor = new ScDispatchProviderInterceptor( this );
1884 bFirstActivate = TRUE; // NavigatorUpdate aufschieben bis Activate()
1886 // #105575#; update only in the first creation of the ViewShell
1887 pDocSh->SetUpdateEnabled(FALSE);
1889 if ( GetViewFrame()->GetFrame()->IsInPlace() )
1890 UpdateHeaderWidth(); // The implace activation requires headers to be calculated
1892 SvBorder aBorder;
1893 GetBorderSize( aBorder, Size() );
1894 SetBorderPixel( aBorder );
1897 //------------------------------------------------------------------
1899 //UNUSED2008-05 ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame,
1900 //UNUSED2008-05 const ScTabViewShell& rWin ) :
1901 //UNUSED2008-05 SfxViewShell( pViewFrame, SFX_VIEW_MAXIMIZE_FIRST | SFX_VIEW_CAN_PRINT | SFX_VIEW_HAS_PRINTOPTIONS ),
1902 //UNUSED2008-05 ScDBFunc( &pViewFrame->GetWindow(), rWin, this ),
1903 //UNUSED2008-05 __INIT_ScTabViewShell
1904 //UNUSED2008-05 {
1905 //UNUSED2008-05 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScTabViewShell::ScTabViewShell" );
1906 //UNUSED2008-05
1907 //UNUSED2008-05 Construct();
1908 //UNUSED2008-05
1909 //UNUSED2008-05 UpdatePageBreakData();
1910 //UNUSED2008-05
1911 //UNUSED2008-05 /*uno::Reference<frame::XFrame> xFrame = pViewFrame->GetFrame()->GetFrameInterface();
1912 //UNUSED2008-05 if (xFrame.is())
1913 //UNUSED2008-05 xFrame->setComponent( uno::Reference<awt::XWindow>(), new ScTabViewObj( this ) );*/
1914 //UNUSED2008-05 // make Controller known to SFX
1915 //UNUSED2008-05 new ScTabViewObj( this );
1916 //UNUSED2008-05
1917 //UNUSED2008-05 SetCurSubShell(OST_Cell);
1918 //UNUSED2008-05 SvBorder aBorder;
1919 //UNUSED2008-05 GetBorderSize( aBorder, Size() );
1920 //UNUSED2008-05 SetBorderPixel( aBorder );
1921 //UNUSED2008-05 }
1923 //------------------------------------------------------------------
1925 ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame,
1926 SfxViewShell* pOldSh ) :
1927 SfxViewShell( pViewFrame, SFX_VIEW_MAXIMIZE_FIRST | SFX_VIEW_CAN_PRINT | SFX_VIEW_HAS_PRINTOPTIONS ),
1928 ScDBFunc( &pViewFrame->GetWindow(), (ScDocShell&)*pViewFrame->GetObjectShell(), this ),
1929 __INIT_ScTabViewShell
1931 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScTabViewShell::ScTabViewShell" );
1933 const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions();
1935 // if switching back from print preview,
1936 // restore the view settings that were active when creating the preview
1937 // #89897# ReadUserData must not happen from ctor, because the view's edit window
1938 // has to be shown by the sfx. ReadUserData is deferred until the first Activate call.
1939 // #106334# old DesignMode state from form layer must be restored, too
1941 BYTE nForceDesignMode = SC_FORCEMODE_NONE;
1942 if ( pOldSh && pOldSh->ISA( ScPreviewShell ) )
1944 ScPreviewShell* pPreviewShell = ((ScPreviewShell*)pOldSh);
1945 aPendingUserData = pPreviewShell->GetSourceData(); // used in Activate
1946 nForceDesignMode = pPreviewShell->GetSourceDesignMode();
1949 Construct( nForceDesignMode );
1951 if ( GetViewData()->GetDocShell()->IsPreview() )
1953 // preview for template dialog: always show whole page
1954 SetZoomType( SVX_ZOOM_WHOLEPAGE, TRUE ); // zoom value is recalculated at next Resize
1956 else
1958 Fraction aFract( rAppOpt.GetZoom(), 100 );
1959 SetZoom( aFract, aFract, TRUE );
1960 SetZoomType( rAppOpt.GetZoomType(), TRUE );
1963 /*uno::Reference<frame::XFrame> xFrame = pViewFrame->GetFrame()->GetFrameInterface();
1964 if (xFrame.is())
1965 xFrame->setComponent( uno::Reference<awt::XWindow>(), new ScTabViewObj( this ) );*/
1966 // make Controller known to SFX
1967 new ScTabViewObj( this );
1969 SetCurSubShell(OST_Cell);
1970 SvBorder aBorder;
1971 GetBorderSize( aBorder, Size() );
1972 SetBorderPixel( aBorder );
1974 // #114409#
1975 MakeDrawLayer();
1978 #undef __INIT_ScTabViewShell
1980 //------------------------------------------------------------------
1982 __EXPORT ScTabViewShell::~ScTabViewShell()
1984 ScDocShell* pDocSh = GetViewData()->GetDocShell();
1985 EndListening(*pDocSh);
1986 EndListening(*GetViewFrame());
1987 EndListening(*SFX_APP()); // #i62045# #i62046# needed now - SfxViewShell no longer does it
1989 SC_MOD()->ViewShellGone(this);
1991 RemoveSubShell(); // alle
1992 SetWindow(0);
1994 // #54104# alles auf NULL, falls aus dem TabView-dtor noch darauf zugegriffen wird
1995 //! (soll eigentlich nicht !??!?!)
1997 DELETEZ(pFontworkBarShell);
1998 DELETEZ(pExtrusionBarShell);
1999 DELETEZ(pCellShell);
2000 DELETEZ(pPageBreakShell);
2001 DELETEZ(pDrawShell);
2002 DELETEZ(pDrawFormShell);
2003 DELETEZ(pOleObjectShell);
2004 DELETEZ(pChartShell);
2005 DELETEZ(pGraphicShell);
2006 DELETEZ(pMediaShell);
2007 DELETEZ(pDrawTextShell);
2008 DELETEZ(pEditShell);
2009 DELETEZ(pPivotShell);
2010 DELETEZ(pAuditingShell);
2011 DELETEZ(pCurFrameLine);
2012 DELETEZ(pInputHandler);
2013 DELETEZ(pPivotSource);
2014 DELETEZ(pDialogDPObject);
2015 DELETEZ(pNavSettings);
2017 DELETEZ(pFormShell);
2018 DELETEZ(pAccessibilityBroadcaster);
2021 //------------------------------------------------------------------
2023 void ScTabViewShell::SetDialogDPObject( const ScDPObject* pObj )
2025 delete pDialogDPObject;
2026 if (pObj)
2027 pDialogDPObject = new ScDPObject( *pObj );
2028 else
2029 pDialogDPObject = NULL;
2032 //------------------------------------------------------------------
2034 void ScTabViewShell::FillFieldData( ScHeaderFieldData& rData )
2036 ScDocShell* pDocShell = GetViewData()->GetDocShell();
2037 ScDocument* pDoc = pDocShell->GetDocument();
2038 SCTAB nTab = GetViewData()->GetTabNo();
2039 pDoc->GetName( nTab, rData.aTabName );
2041 rData.aTitle = pDocShell->GetTitle();
2042 const INetURLObject& rURLObj = pDocShell->GetMedium()->GetURLObject();
2043 rData.aLongDocName = rURLObj.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
2044 if ( rData.aLongDocName.Len() )
2045 rData.aShortDocName = rURLObj.GetName( INetURLObject::DECODE_UNAMBIGUOUS );
2046 else
2047 rData.aShortDocName = rData.aLongDocName = rData.aTitle;
2048 rData.nPageNo = 1;
2049 rData.nTotalPages = 99;
2051 // eNumType kennt der Dialog selber
2054 //------------------------------------------------------------------
2056 void ScTabViewShell::SetChartArea( const ScRangeListRef& rSource, const Rectangle& rDest )
2058 bChartAreaValid = TRUE;
2059 aChartSource = rSource;
2060 aChartPos = rDest;
2061 nChartDestTab = GetViewData()->GetTabNo();
2064 //UNUSED2008-05 void ScTabViewShell::ResetChartArea()
2065 //UNUSED2008-05 {
2066 //UNUSED2008-05 bChartAreaValid = FALSE;
2067 //UNUSED2008-05 }
2069 BOOL ScTabViewShell::GetChartArea( ScRangeListRef& rSource, Rectangle& rDest, SCTAB& rTab ) const
2071 rSource = aChartSource;
2072 rDest = aChartPos;
2073 rTab = nChartDestTab;
2074 return bChartAreaValid;
2077 //UNUSED2008-05 BOOL ScTabViewShell::IsChartDlgEdit() const
2078 //UNUSED2008-05 {
2079 //UNUSED2008-05 return bChartDlgIsEdit;
2080 //UNUSED2008-05 }
2081 //UNUSED2008-05
2082 //UNUSED2008-05 const String& ScTabViewShell::GetEditChartName() const
2083 //UNUSED2008-05 {
2084 //UNUSED2008-05 return aEditChartName;
2085 //UNUSED2008-05 }
2087 ScNavigatorSettings* ScTabViewShell::GetNavigatorSettings()
2089 if( !pNavSettings )
2090 pNavSettings = new ScNavigatorSettings;
2091 return pNavSettings;
2095 //------------------------------------------------------------------
2097 void ScTabViewShell::ExecTbx( SfxRequest& rReq )
2099 const SfxItemSet* pReqArgs = rReq.GetArgs();
2100 USHORT nSlot = rReq.GetSlot();
2101 const SfxPoolItem* pItem = NULL;
2102 if ( pReqArgs )
2103 pReqArgs->GetItemState( nSlot, TRUE, &pItem );
2105 switch ( nSlot )
2107 case SID_TBXCTL_INSERT:
2108 if ( pItem )
2109 nInsertCtrlState = ((const SfxUInt16Item*)pItem)->GetValue();
2110 break;
2111 case SID_TBXCTL_INSCELLS:
2112 if ( pItem )
2113 nInsCellsCtrlState = ((const SfxUInt16Item*)pItem)->GetValue();
2114 break;
2115 case SID_TBXCTL_INSOBJ:
2116 if ( pItem )
2117 nInsObjCtrlState = ((const SfxUInt16Item*)pItem)->GetValue();
2118 break;
2119 default:
2120 DBG_ERROR("Slot im Wald");
2122 GetViewFrame()->GetBindings().Invalidate( nSlot );
2125 void ScTabViewShell::GetTbxState( SfxItemSet& rSet )
2127 rSet.Put( SfxUInt16Item( SID_TBXCTL_INSERT, nInsertCtrlState ) );
2128 rSet.Put( SfxUInt16Item( SID_TBXCTL_INSCELLS, nInsCellsCtrlState ) );
2130 // ohne installiertes Chart darf Chart nicht Default sein...
2131 if ( nInsObjCtrlState == SID_DRAW_CHART && !SvtModuleOptions().IsChart() )
2132 nInsObjCtrlState = SID_INSERT_OBJECT;
2134 rSet.Put( SfxUInt16Item( SID_TBXCTL_INSOBJ, nInsObjCtrlState ) );