1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
23 #include "scitems.hxx"
24 #include <editeng/eeitem.hxx>
26 #include <sfx2/app.hxx>
27 #include <svx/extrusionbar.hxx>
28 #include <svx/fontworkbar.hxx>
29 #include <editeng/boxitem.hxx>
30 #include <svx/fmpage.hxx>
31 #include <svx/fmshell.hxx>
32 #include <editeng/sizeitem.hxx>
33 #include <svx/prtqry.hxx>
34 #include <svx/sidebar/ContextChangeEventMultiplexer.hxx>
35 #include <sfx2/request.hxx>
36 #include <sfx2/printer.hxx>
37 #include <sfx2/dispatch.hxx>
38 #include <svl/whiter.hxx>
39 #include <unotools/moduleoptions.hxx>
40 #include <tools/urlobj.hxx>
41 #include <sfx2/docfile.hxx>
42 #include <vcl/openglwin.hxx>
44 #include "tabvwsh.hxx"
46 #include "globstr.hrc"
47 #include "stlpool.hxx"
48 #include "stlsheet.hxx"
51 #include "appoptio.hxx"
52 #include "rangeutl.hxx"
53 #include "printfun.hxx"
55 #include "drformsh.hxx"
57 #include "pivotsh.hxx"
58 #include "auditsh.hxx"
59 #include "drtxtob.hxx"
60 #include "inputhdl.hxx"
61 #include "editutil.hxx"
62 #include "inputopt.hxx"
63 #include "inputwin.hxx"
64 #include "scresid.hxx"
66 #include "reffact.hxx"
67 #include "viewuno.hxx"
68 #include "dispuno.hxx"
69 #include "anyrefdg.hxx"
70 #include "chgtrack.hxx"
72 #include "oleobjsh.hxx"
73 #include "chartsh.hxx"
74 #include "graphsh.hxx"
75 #include "mediash.hxx"
76 #include "pgbrksh.hxx"
77 #include "dpobject.hxx"
78 #include "prevwsh.hxx"
79 #include "tpprint.hxx"
80 #include "scextopt.hxx"
81 #include "printopt.hxx"
82 #include "drawview.hxx"
84 #include "navsett.hxx"
85 #include "scabstdlg.hxx"
86 #include "externalrefmgr.hxx"
87 #include "defaultsoptions.hxx"
88 #include "markdata.hxx"
89 #include "preview.hxx"
90 #include "docoptio.hxx"
91 #include <documentlinkmgr.hxx>
92 #include <gridwin.hxx>
94 #include <com/sun/star/document/XDocumentProperties.hpp>
95 #include <com/sun/star/chart2/X3DChartWindowProvider.hpp>
96 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
97 #include <com/sun/star/chart2/XCoordinateSystem.hpp>
98 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
99 #include <com/sun/star/chart2/XChartType.hpp>
101 extern SfxViewShell
* pScActiveViewShell
; // global.cxx
103 using namespace com::sun::star
;
105 // STATIC DATA -----------------------------------------------------------
107 sal_uInt16
ScTabViewShell::nInsertCtrlState
= SID_INSERT_GRAPHIC
;
108 sal_uInt16
ScTabViewShell::nInsCellsCtrlState
= 0;
109 sal_uInt16
ScTabViewShell::nInsObjCtrlState
= SID_INSERT_DIAGRAM
;
111 void ScTabViewShell::Activate(bool bMDI
)
113 SfxViewShell::Activate(bMDI
);
115 // hier kein GrabFocus, sonst gibt's Probleme wenn etwas inplace editiert wird!
119 // fuer Eingabezeile (ClearCache)
120 ScModule
* pScMod
= SC_MOD();
121 pScMod
->ViewShellChanged();
123 ActivateView( true, bFirstActivate
);
125 // AutoCorrect umsetzen, falls der Writer seins neu angelegt hat
126 UpdateDrawTextOutliner();
128 // RegisterNewTargetNames gibts nicht mehr
130 SfxViewFrame
* pThisFrame
= GetViewFrame();
131 if ( pInputHandler
&& pThisFrame
->HasChildWindow(FID_INPUTLINE_STATUS
) )
133 // eigentlich nur beim Reload (letzte Version) noetig:
134 // Das InputWindow bleibt stehen, aber die View mitsamt InputHandler wird
135 // neu angelegt, darum muss der InputHandler am InputWindow gesetzt werden.
136 SfxChildWindow
* pChild
= pThisFrame
->GetChildWindow(FID_INPUTLINE_STATUS
);
139 ScInputWindow
* pWin
= static_cast<ScInputWindow
*>(pChild
->GetWindow());
140 if (pWin
&& pWin
->IsVisible())
143 ScInputHandler
* pOldHdl
=pWin
->GetInputHandler();
145 TypeId aScType
= TYPE(ScTabViewShell
);
147 SfxViewShell
* pSh
= SfxViewShell::GetFirst( &aScType
);
148 while ( pSh
!=NULL
&& pOldHdl
!=NULL
)
150 if (static_cast<ScTabViewShell
*>(pSh
)->GetInputHandler() == pOldHdl
)
152 pOldHdl
->ResetDelayTimer();
155 pSh
= SfxViewShell::GetNext( *pSh
, &aScType
);
158 pWin
->SetInputHandler( pInputHandler
);
163 UpdateInputHandler( true );
165 if ( bFirstActivate
)
167 SfxGetpApp()->Broadcast( SfxSimpleHint( SC_HINT_NAVIGATOR_UPDATEALL
) );
168 bFirstActivate
= false;
170 // ReadExtOptions (view settings from Excel import) must also be done
171 // after the ctor, because of the potential calls to Window::Show.
172 // Even after a bugfix (Window::Show no longer notifies the access
173 // bridge, it's done in ImplSetReallyVisible), there are problems if Window::Show
174 // is called during the ViewShell ctor and reschedules asynchronous calls
175 // (for example from the FmFormShell ctor).
176 ScExtDocOptions
* pExtOpt
= GetViewData().GetDocument()->GetExtDocOptions();
177 if ( pExtOpt
&& pExtOpt
->IsChanged() )
179 GetViewData().ReadExtOptions(*pExtOpt
); // Excel view settings
180 SetTabNo( GetViewData().GetTabNo(), true );
181 pExtOpt
->SetChanged( false );
185 pScActiveViewShell
= this;
187 ScInputHandler
* pHdl
= pScMod
->GetInputHdl(this);
190 pHdl
->SetRefScale( GetViewData().GetZoomX(), GetViewData().GetZoomY() );
193 // Aenderungs-Dialog aktualisieren
195 if ( pThisFrame
->HasChildWindow(FID_CHG_ACCEPT
) )
197 SfxChildWindow
* pChild
= pThisFrame
->GetChildWindow(FID_CHG_ACCEPT
);
200 static_cast<ScAcceptChgDlgWrapper
*>(pChild
)->ReInitDlg();
204 if(pScMod
->IsRefDialogOpen())
206 sal_uInt16 nModRefDlgId
=pScMod
->GetCurRefDlgId();
207 SfxChildWindow
* pChildWnd
= pThisFrame
->GetChildWindow( nModRefDlgId
);
210 IAnyRefDialog
* pRefDlg
= dynamic_cast<IAnyRefDialog
*>(pChildWnd
->GetWindow());
214 pRefDlg
->ViewShellChanged();
220 // don't call CheckSelectionTransfer here - activating a view should not change the
221 // primary selection (may be happening just because the mouse was moved over the window)
223 // Wenn Referenzeingabe-Tip-Hilfe hier wieder angezeigt werden soll (ShowRefTip),
224 // muss sie beim Verschieben der View angepasst werden (gibt sonst Probleme unter OS/2
225 // beim Umschalten zwischen Dokumenten)
227 ContextChangeEventMultiplexer::NotifyContextChange(
229 ::sfx2::sidebar::EnumContext::Context_Default
);
232 void ScTabViewShell::Deactivate(bool bMDI
)
236 ScDocument
* pDoc
=GetViewData().GetDocument();
238 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
243 pChanges
->SetModifiedLink(aLink
);
246 SfxViewShell::Deactivate(bMDI
);
248 ScInputHandler
* pHdl
= SC_MOD()->GetInputHdl(this);
252 // during shell deactivation, shells must not be switched, or the loop
253 // through the shell stack (in SfxDispatcher::DoDeactivate_Impl) will not work
254 bool bOldDontSwitch
= bDontSwitch
;
257 ActivateView( false, false );
259 if ( GetViewFrame()->GetFrame().IsInPlace() ) // inplace
260 GetViewData().GetDocShell()->UpdateOle(&GetViewData(), true);
263 pHdl
->NotifyChange( NULL
, true ); // Timer-verzoegert wg. Dokumentwechsel
265 if (pScActiveViewShell
== this)
266 pScActiveViewShell
= NULL
;
268 bDontSwitch
= bOldDontSwitch
;
272 HideNoteMarker(); // Notiz-Anzeige
275 pHdl
->HideTip(); // Formel-AutoEingabe-Tip abschalten
279 void ScTabViewShell::SetActive()
281 // Die Sfx-View moechte sich gerne selbst aktivieren, weil dabei noch
282 // magische Dinge geschehen (z.B. stuerzt sonst evtl. der Gestalter ab)
286 bool ScTabViewShell::PrepareClose(bool bUI
)
288 // Call EnterHandler even in formula mode here,
289 // so a formula change in an embedded object isn't lost
290 // (ScDocShell::PrepareClose isn't called then).
291 ScInputHandler
* pHdl
= SC_MOD()->GetInputHdl( this );
292 if ( pHdl
&& pHdl
->IsInputMode() )
293 pHdl
->EnterHandler();
295 // draw text edit mode must be closed
296 FuPoor
* pPoor
= GetDrawFuncPtr();
297 if ( pPoor
&& ( IsDrawTextShell() || pPoor
->GetSlotID() == SID_DRAW_NOTEEDIT
) )
299 // "clean" end of text edit, including note handling, subshells and draw func switching,
300 // as in FuDraw and ScTabView::DrawDeselectAll
301 GetViewData().GetDispatcher().Execute( pPoor
->GetSlotID(), SfxCallMode::SLOT
| SfxCallMode::RECORD
);
303 ScDrawView
* pDrView
= GetScDrawView();
306 // force end of text edit, to be safe
307 // ScEndTextEdit must always be used, to ensure correct UndoManager
308 pDrView
->ScEndTextEdit();
313 bool nRet
= pFormShell
->PrepareClose(bUI
);
317 return SfxViewShell::PrepareClose(bUI
);
320 // Zoom fuer In-Place berechnen
321 // aus Verhaeltnis von VisArea und Fenstergroesse des GridWin
323 void ScTabViewShell::UpdateOleZoom()
325 ScDocShell
* pDocSh
= GetViewData().GetDocShell();
326 if ( pDocSh
->GetCreateMode() == SfxObjectCreateMode::EMBEDDED
)
328 //TODO/LATER: is there a difference between the two GetVisArea methods?
329 Size aObjSize
= ((const SfxObjectShell
*)pDocSh
)->GetVisArea().GetSize();
330 if ( aObjSize
.Width() > 0 && aObjSize
.Height() > 0 )
332 vcl::Window
* pWin
= GetActiveWin();
333 Size aWinHMM
= pWin
->PixelToLogic( pWin
->GetOutputSizePixel(), MAP_100TH_MM
);
334 SetZoomFactor( Fraction( aWinHMM
.Width(),aObjSize
.Width() ),
335 Fraction( aWinHMM
.Height(),aObjSize
.Height() ) );
340 void ScTabViewShell::AdjustPosSizePixel( const Point
&rPos
, const Size
&rSize
)
342 OuterResizePixel( rPos
, rSize
);
345 void ScTabViewShell::InnerResizePixel( const Point
&rOfs
, const Size
&rSize
)
347 Size
aNewSize( rSize
);
348 if ( GetViewFrame()->GetFrame().IsInPlace() )
351 GetBorderSize( aBorder
, rSize
);
352 SetBorderPixel( aBorder
);
354 Size aObjSize
= GetObjectShell()->GetVisArea().GetSize();
357 aSize
.Width() -= (aBorder
.Left() + aBorder
.Right());
358 aSize
.Height() -= (aBorder
.Top() + aBorder
.Bottom());
360 if ( aObjSize
.Width() > 0 && aObjSize
.Height() > 0 )
362 Size aLogicSize
= GetWindow()->PixelToLogic( aSize
, MAP_100TH_MM
);
363 SfxViewShell::SetZoomFactor( Fraction( aLogicSize
.Width(),aObjSize
.Width() ),
364 Fraction( aLogicSize
.Height(),aObjSize
.Height() ) );
368 aPos
.X() += aBorder
.Left();
369 aPos
.Y() += aBorder
.Top();
370 GetWindow()->SetPosSizePixel( aPos
, aSize
);
375 GetBorderSize( aBorder
, rSize
);
376 SetBorderPixel( aBorder
);
377 aNewSize
.Width() += aBorder
.Left() + aBorder
.Right();
378 aNewSize
.Height() += aBorder
.Top() + aBorder
.Bottom();
381 DoResize( rOfs
, aNewSize
, true ); // rSize = Groesse von gridwin
383 UpdateOleZoom(); // Zoom fuer In-Place berechnen
385 GetViewData().GetDocShell()->SetDocumentModified();
388 void ScTabViewShell::OuterResizePixel( const Point
&rOfs
, const Size
&rSize
)
391 GetBorderSize( aBorder
, rSize
);
392 SetBorderPixel( aBorder
);
394 DoResize( rOfs
, rSize
); // Position und Groesse von tabview wie uebergeben
396 // ForceMove als Ersatz fuer den Sfx-Move-Mechanismus
397 // (aWinPos muss aktuell gehalten werden, damit ForceMove beim Ole-Deaktivieren klappt)
402 void ScTabViewShell::SetZoomFactor( const Fraction
&rZoomX
, const Fraction
&rZoomY
)
406 Fraction
aFrac20( 1,5 );
407 Fraction
aFrac400( 4,1 );
409 Fraction
aNewX( rZoomX
);
410 if ( aNewX
< aFrac20
)
412 if ( aNewX
> aFrac400
)
414 Fraction
aNewY( rZoomY
);
415 if ( aNewY
< aFrac20
)
417 if ( aNewY
> aFrac400
)
420 GetViewData().UpdateScreenZoom( aNewX
, aNewY
);
421 SetZoom( aNewX
, aNewY
, true );
427 SfxViewShell::SetZoomFactor( rZoomX
, rZoomY
);
430 void ScTabViewShell::QueryObjAreaPixel( Rectangle
& rRect
) const
432 // auf ganze Zellen anpassen (in 1/100 mm)
434 Size aPixelSize
= rRect
.GetSize();
435 vcl::Window
* pWin
= const_cast<ScTabViewShell
*>(this)->GetActiveWin();
436 Size aLogicSize
= pWin
->PixelToLogic( aPixelSize
);
438 const ScViewData
& rViewData
= GetViewData();
439 ScDocument
* pDoc
= rViewData
.GetDocument();
440 ScSplitPos ePos
= rViewData
.GetActivePart();
441 SCCOL nCol
= rViewData
.GetPosX(WhichH(ePos
));
442 SCROW nRow
= rViewData
.GetPosY(WhichV(ePos
));
443 SCTAB nTab
= rViewData
.GetTabNo();
444 bool bNegativePage
= pDoc
->IsNegativePage( nTab
);
446 Rectangle aLogicRect
= pDoc
->GetMMRect( nCol
, nRow
, nCol
, nRow
, nTab
);
449 // use right edge of aLogicRect, and aLogicSize
450 aLogicRect
.Left() = aLogicRect
.Right() - aLogicSize
.Width() + 1; // Right() is set below
452 aLogicRect
.SetSize( aLogicSize
);
454 rViewData
.GetDocShell()->SnapVisArea( aLogicRect
);
456 rRect
.SetSize( pWin
->LogicToPixel( aLogicRect
.GetSize() ) );
459 void ScTabViewShell::Move()
461 Point aNewPos
= GetViewFrame()->GetWindow().OutputToScreenPixel(Point());
463 if (aNewPos
!= aWinPos
)
470 void ScTabViewShell::ShowCursor(bool /* bOn */)
472 /*!!! ShowCursor wird nicht paarweise wie im gridwin gerufen.
473 Der CursorLockCount am Gridwin muss hier direkt auf 0 gesetzt werden
482 void ScTabViewShell::WriteUserData(OUString
& rData
, bool /* bBrowse */)
484 GetViewData().WriteUserData(rData
);
487 void ScTabViewShell::WriteUserDataSequence (uno::Sequence
< beans::PropertyValue
>& rSettings
, bool /* bBrowse */ )
489 GetViewData().WriteUserDataSequence (rSettings
);
492 void ScTabViewShell::ReadUserData(const OUString
& rData
, bool /* bBrowse */)
494 if ( !GetViewData().GetDocShell()->IsPreview() )
495 DoReadUserData( rData
);
498 void ScTabViewShell::ReadUserDataSequence (const uno::Sequence
< beans::PropertyValue
>& rSettings
, bool /* bBrowse */ )
500 if ( !GetViewData().GetDocShell()->IsPreview() )
501 DoReadUserDataSequence( rSettings
);
504 void ScTabViewShell::DoReadUserDataSequence( const uno::Sequence
< beans::PropertyValue
>& rSettings
)
506 vcl::Window
* pOldWin
= GetActiveWin();
507 bool bFocus
= pOldWin
&& pOldWin
->HasFocus();
509 GetViewData().ReadUserDataSequence(rSettings
);
510 SetTabNo( GetViewData().GetTabNo(), true );
512 if ( GetViewData().IsPagebreakMode() )
513 SetCurSubShell( GetCurObjectSelectionType(), true );
515 vcl::Window
* pNewWin
= GetActiveWin();
516 if (pNewWin
&& pNewWin
!= pOldWin
)
518 SetWindow( pNewWin
); //! ist diese ViewShell immer aktiv???
520 pNewWin
->GrabFocus();
521 WindowChanged(); // Drawing-Layer (z.B. #56771#)
524 if (GetViewData().GetHSplitMode() == SC_SPLIT_FIX
||
525 GetViewData().GetVSplitMode() == SC_SPLIT_FIX
)
534 //! if ViewData has more tables than document, remove tables in ViewData
537 // DoReadUserData is also called from ctor when switching from print preview
539 void ScTabViewShell::DoReadUserData( const OUString
& rData
)
541 vcl::Window
* pOldWin
= GetActiveWin();
542 bool bFocus
= pOldWin
&& pOldWin
->HasFocus();
544 GetViewData().ReadUserData(rData
);
545 SetTabNo( GetViewData().GetTabNo(), true );
547 if ( GetViewData().IsPagebreakMode() )
548 SetCurSubShell( GetCurObjectSelectionType(), true );
550 vcl::Window
* pNewWin
= GetActiveWin();
551 if (pNewWin
&& pNewWin
!= pOldWin
)
553 SetWindow( pNewWin
); //! ist diese ViewShell immer aktiv???
555 pNewWin
->GrabFocus();
556 WindowChanged(); // Drawing-Layer (z.B. #56771#)
559 if (GetViewData().GetHSplitMode() == SC_SPLIT_FIX
||
560 GetViewData().GetVSplitMode() == SC_SPLIT_FIX
)
569 //! if ViewData has more tables than document, remove tables in ViewData
572 void ScTabViewShell::UpdateDrawShell()
574 // Called after user interaction that may delete the selected drawing object.
575 // Remove DrawShell if nothing is selected.
577 SdrView
* pDrView
= GetSdrView();
578 if ( pDrView
&& !pDrView
->AreObjectsMarked() && !IsDrawSelMode() )
579 SetDrawShell( false );
582 void ScTabViewShell::SetDrawShellOrSub()
584 bActiveDrawSh
= true;
586 if(bActiveDrawFormSh
)
588 SetCurSubShell(OST_DrawForm
);
590 else if(bActiveGraphicSh
)
592 SetCurSubShell(OST_Graphic
);
594 else if(bActiveMediaSh
)
596 SetCurSubShell(OST_Media
);
598 else if(bActiveChartSh
)
600 SetCurSubShell(OST_Chart
);
602 else if(bActiveOleObjectSh
)
604 SetCurSubShell(OST_OleObject
);
608 SetCurSubShell(OST_Drawing
, true /* force: different toolbars are
609 visible concerning shape type
614 void ScTabViewShell::SetDrawShell( bool bActive
)
618 SetCurSubShell(OST_Drawing
, true /* force: different toolbars are
619 visible concerning shape type
624 if(bActiveDrawFormSh
|| bActiveDrawSh
||
625 bActiveGraphicSh
|| bActiveMediaSh
|| bActiveOleObjectSh
||
626 bActiveChartSh
|| bActiveDrawTextSh
)
628 SetCurSubShell(OST_Cell
);
630 bActiveDrawFormSh
=false;
631 bActiveGraphicSh
=false;
632 bActiveMediaSh
=false;
633 bActiveOleObjectSh
=false;
634 bActiveChartSh
=false;
637 bool bWasDraw
= bActiveDrawSh
|| bActiveDrawTextSh
;
639 bActiveDrawSh
= bActive
;
640 bActiveDrawTextSh
= false;
644 ResetDrawDragMode(); // Mirror / Rotate aus
646 if (bWasDraw
&& (GetViewData().GetHSplitMode() == SC_SPLIT_FIX
||
647 GetViewData().GetVSplitMode() == SC_SPLIT_FIX
))
649 // Aktiven Teil an Cursor anpassen, etc.
650 MoveCursorAbs( GetViewData().GetCurX(), GetViewData().GetCurY(),
651 SC_FOLLOW_NONE
, false, false, true );
656 void ScTabViewShell::SetDrawTextShell( bool bActive
)
658 bActiveDrawTextSh
= bActive
;
661 bActiveDrawFormSh
=false;
662 bActiveGraphicSh
=false;
663 bActiveMediaSh
=false;
664 bActiveOleObjectSh
=false;
665 bActiveChartSh
=false;
666 bActiveDrawSh
= false;
667 SetCurSubShell(OST_DrawText
);
670 SetCurSubShell(OST_Cell
);
674 void ScTabViewShell::SetPivotShell( bool bActive
)
676 bActivePivotSh
= bActive
;
678 // SetPivotShell is called from CursorPosChanged every time
679 // -> don't change anything except switching between cell and pivot shell
681 if ( eCurOST
== OST_Pivot
|| eCurOST
== OST_Cell
)
685 bActiveDrawTextSh
= bActiveDrawSh
= false;
686 bActiveDrawFormSh
=false;
687 bActiveGraphicSh
=false;
688 bActiveMediaSh
=false;
689 bActiveOleObjectSh
=false;
690 bActiveChartSh
=false;
691 SetCurSubShell(OST_Pivot
);
694 SetCurSubShell(OST_Cell
);
698 void ScTabViewShell::SetAuditShell( bool bActive
)
700 bActiveAuditingSh
= bActive
;
703 bActiveDrawTextSh
= bActiveDrawSh
= false;
704 bActiveDrawFormSh
=false;
705 bActiveGraphicSh
=false;
706 bActiveMediaSh
=false;
707 bActiveOleObjectSh
=false;
708 bActiveChartSh
=false;
709 SetCurSubShell(OST_Auditing
);
712 SetCurSubShell(OST_Cell
);
715 void ScTabViewShell::SetDrawFormShell( bool bActive
)
717 bActiveDrawFormSh
= bActive
;
719 if(bActiveDrawFormSh
)
720 SetCurSubShell(OST_DrawForm
);
722 void ScTabViewShell::SetChartShell( bool bActive
)
724 bActiveChartSh
= bActive
;
727 SetCurSubShell(OST_Chart
);
730 void ScTabViewShell::SetGraphicShell( bool bActive
)
732 bActiveGraphicSh
= bActive
;
735 SetCurSubShell(OST_Graphic
);
738 void ScTabViewShell::SetMediaShell( bool bActive
)
740 bActiveMediaSh
= bActive
;
743 SetCurSubShell(OST_Media
);
746 void ScTabViewShell::SetOleObjectShell( bool bActive
)
748 bActiveOleObjectSh
= bActive
;
750 if(bActiveOleObjectSh
)
751 SetCurSubShell(OST_OleObject
);
753 SetCurSubShell(OST_Cell
);
756 void ScTabViewShell::SetEditShell(EditView
* pView
, bool bActive
)
761 pEditShell
->SetEditView( pView
);
763 pEditShell
= new ScEditShell( pView
, &GetViewData() );
765 SetCurSubShell(OST_Editing
);
767 else if(bActiveEditSh
)
769 SetCurSubShell(OST_Cell
);
771 bActiveEditSh
= bActive
;
774 void ScTabViewShell::SetCurSubShell(ObjectSelectionType eOST
, bool bForce
)
776 ScViewData
& rViewData
= GetViewData();
777 ScDocShell
* pDocSh
= rViewData
.GetDocShell();
779 if(bDontSwitch
) return;
781 if(!pCellShell
) //Wird eh immer gebraucht.
783 pCellShell
= new ScCellShell( &GetViewData() );
784 pCellShell
->SetRepeatTarget( &aTarget
);
787 bool bPgBrk
= rViewData
.IsPagebreakMode();
789 if(bPgBrk
&& !pPageBreakShell
)
791 pPageBreakShell
= new ScPageBreakShell( this );
792 pPageBreakShell
->SetRepeatTarget( &aTarget
);
795 if ( eOST
!=eCurOST
|| bForce
)
797 bool bCellBrush
= false; // "format paint brush" allowed for cells
798 bool bDrawBrush
= false; // "format paint brush" allowed for drawing objects
800 if(eCurOST
!=OST_NONE
) RemoveSubShell();
802 if (pFormShell
&& !bFormShellAtTop
)
803 AddSubShell(*pFormShell
); // add below own subshells
809 AddSubShell(*pCellShell
);
810 if(bPgBrk
) AddSubShell(*pPageBreakShell
);
816 AddSubShell(*pCellShell
);
817 if(bPgBrk
) AddSubShell(*pPageBreakShell
);
821 AddSubShell(*pEditShell
);
827 if ( !pDrawTextShell
)
829 pDocSh
->MakeDrawLayer();
830 pDrawTextShell
= new ScDrawTextObjectBar( &GetViewData() );
832 AddSubShell(*pDrawTextShell
);
837 if (svx::checkForSelectedCustomShapes(
838 GetScDrawView(), true /* bOnlyExtruded */ )) {
839 if (pExtrusionBarShell
== 0)
840 pExtrusionBarShell
= new svx::ExtrusionBar(this);
841 AddSubShell( *pExtrusionBarShell
);
843 sal_uInt32 nCheckStatus
= 0;
844 if (svx::checkForSelectedFontWork(
845 GetScDrawView(), nCheckStatus
)) {
846 if (pFontworkBarShell
== 0)
847 pFontworkBarShell
= new svx::FontworkBar(this);
848 AddSubShell( *pFontworkBarShell
);
853 pDocSh
->MakeDrawLayer();
854 pDrawShell
= new ScDrawShell( &GetViewData() );
855 pDrawShell
->SetRepeatTarget( &aTarget
);
857 AddSubShell(*pDrawShell
);
864 if ( !pDrawFormShell
)
866 pDocSh
->MakeDrawLayer();
867 pDrawFormShell
= new ScDrawFormShell( &GetViewData() );
868 pDrawFormShell
->SetRepeatTarget( &aTarget
);
870 AddSubShell(*pDrawFormShell
);
879 pDocSh
->MakeDrawLayer();
880 pChartShell
= new ScChartShell( &GetViewData() );
881 pChartShell
->SetRepeatTarget( &aTarget
);
883 AddSubShell(*pChartShell
);
890 if ( !pOleObjectShell
)
892 pDocSh
->MakeDrawLayer();
893 pOleObjectShell
= new ScOleObjectShell( &GetViewData() );
894 pOleObjectShell
->SetRepeatTarget( &aTarget
);
896 AddSubShell(*pOleObjectShell
);
905 pDocSh
->MakeDrawLayer();
906 pGraphicShell
= new ScGraphicShell( &GetViewData() );
907 pGraphicShell
->SetRepeatTarget( &aTarget
);
909 AddSubShell(*pGraphicShell
);
918 pDocSh
->MakeDrawLayer();
919 pMediaShell
= new ScMediaShell( &GetViewData() );
920 pMediaShell
->SetRepeatTarget( &aTarget
);
922 AddSubShell(*pMediaShell
);
928 AddSubShell(*pCellShell
);
929 if(bPgBrk
) AddSubShell(*pPageBreakShell
);
933 pPivotShell
= new ScPivotShell( this );
934 pPivotShell
->SetRepeatTarget( &aTarget
);
936 AddSubShell(*pPivotShell
);
942 AddSubShell(*pCellShell
);
943 if(bPgBrk
) AddSubShell(*pPageBreakShell
);
945 if ( !pAuditingShell
)
947 pDocSh
->MakeDrawLayer(); // die Wartezeit lieber jetzt als beim Klick
949 pAuditingShell
= new ScAuditingShell( &GetViewData() );
950 pAuditingShell
->SetRepeatTarget( &aTarget
);
952 AddSubShell(*pAuditingShell
);
957 OSL_FAIL("Falsche Shell angefordert");
961 if (pFormShell
&& bFormShellAtTop
)
962 AddSubShell(*pFormShell
); // add on top of own subshells
966 // abort "format paint brush" when switching to an incompatible shell
967 if ( ( GetBrushDocument() && !bCellBrush
) || ( GetDrawBrushSet() && !bDrawBrush
) )
968 ResetBrushDocument();
972 void ScTabViewShell::SetFormShellAtTop( bool bSet
)
974 if ( pFormShell
&& !bSet
)
975 pFormShell
->ForgetActiveControl(); // let the FormShell know it no longer has the focus
977 if ( bFormShellAtTop
!= bSet
)
979 bFormShellAtTop
= bSet
;
980 SetCurSubShell( GetCurObjectSelectionType(), true );
984 IMPL_LINK_NOARG(ScTabViewShell
, FormControlActivated
)
986 // a form control got the focus, so the form shell has to be on top
987 SetFormShellAtTop( true );
991 // GetMySubShell / SetMySubShell: altes Verhalten simulieren,
992 // dass es nur eine SubShell gibt (nur innerhalb der 5 eignenen SubShells)
994 SfxShell
* ScTabViewShell::GetMySubShell() const
996 // GetSubShell() war frueher const, und GetSubShell(sal_uInt16) sollte es auch sein...
999 SfxShell
* pSub
= const_cast<ScTabViewShell
*>(this)->GetSubShell(nPos
);
1002 if ( pSub
== pDrawShell
|| pSub
== pDrawTextShell
|| pSub
== pEditShell
||
1003 pSub
== pPivotShell
|| pSub
== pAuditingShell
|| pSub
== pDrawFormShell
||
1004 pSub
== pCellShell
|| pSub
== pOleObjectShell
|| pSub
== pChartShell
||
1005 pSub
== pGraphicShell
|| pSub
== pMediaShell
|| pSub
== pPageBreakShell
)
1006 return pSub
; // gefunden
1008 pSub
= const_cast<ScTabViewShell
*>(this)->GetSubShell(++nPos
);
1010 return NULL
; // keine von meinen dabei
1013 bool ScTabViewShell::IsDrawTextShell() const
1015 return ( pDrawTextShell
&& ( GetMySubShell() == pDrawTextShell
) );
1018 bool ScTabViewShell::IsAuditShell() const
1020 return ( pAuditingShell
&& ( GetMySubShell() == pAuditingShell
) );
1023 void ScTabViewShell::SetDrawTextUndo( ::svl::IUndoManager
* pNewUndoMgr
)
1025 // Default: Undo-Manager der DocShell
1027 pNewUndoMgr
= GetViewData().GetDocShell()->GetUndoManager();
1031 pDrawTextShell
->SetUndoManager(pNewUndoMgr
);
1032 ScDocShell
* pDocSh
= GetViewData().GetDocShell();
1033 if ( pNewUndoMgr
== pDocSh
->GetUndoManager() &&
1034 !pDocSh
->GetDocument().IsUndoEnabled() )
1036 pNewUndoMgr
->SetMaxUndoActionCount( 0 );
1041 OSL_FAIL("SetDrawTextUndo ohne DrawTextShell");
1045 ScTabViewShell
* ScTabViewShell::GetActiveViewShell()
1047 return PTR_CAST(ScTabViewShell
,Current());
1050 SfxPrinter
* ScTabViewShell::GetPrinter( bool bCreate
)
1052 // Drucker ist immer da (wird fuer die FontListe schon beim Starten angelegt)
1053 return GetViewData().GetDocShell()->GetPrinter(bCreate
);
1056 sal_uInt16
ScTabViewShell::SetPrinter( SfxPrinter
*pNewPrinter
, SfxPrinterChangeFlags nDiffFlags
, bool )
1058 return GetViewData().GetDocShell()->SetPrinter( pNewPrinter
, nDiffFlags
);
1061 bool ScTabViewShell::HasPrintOptionsPage() const
1066 VclPtr
<SfxTabPage
> ScTabViewShell::CreatePrintOptionsPage( vcl::Window
*pParent
, const SfxItemSet
&rOptions
)
1068 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1069 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
1070 ::CreateTabPage ScTpPrintOptionsCreate
= pFact
->GetTabPageCreatorFunc( RID_SCPAGE_PRINT
);
1071 if ( ScTpPrintOptionsCreate
)
1072 return ScTpPrintOptionsCreate( pParent
, &rOptions
);
1073 return VclPtr
<SfxTabPage
>();
1076 void ScTabViewShell::StopEditShell()
1078 if ( pEditShell
!= NULL
&& !bDontSwitch
)
1079 SetEditShell(NULL
, false );
1082 // close handler to ensure function of dialog:
1084 IMPL_LINK_NOARG(ScTabViewShell
, SimpleRefClose
)
1086 SfxInPlaceClient
* pClient
= GetIPClient();
1087 if ( pClient
&& pClient
->IsObjectInPlaceActive() )
1089 // If range selection was started with an active embedded object,
1090 // switch back to original sheet (while the dialog is still open).
1092 SetTabNo( GetViewData().GetRefTabNo() );
1095 ScSimpleRefDlgWrapper::SetAutoReOpen( true );
1099 // handlers to call UNO listeners:
1101 static ScTabViewObj
* lcl_GetViewObj( ScTabViewShell
& rShell
)
1103 ScTabViewObj
* pRet
= NULL
;
1104 SfxViewFrame
* pViewFrame
= rShell
.GetViewFrame();
1107 SfxFrame
& rFrame
= pViewFrame
->GetFrame();
1108 uno::Reference
<frame::XController
> xController
= rFrame
.GetController();
1109 if (xController
.is())
1110 pRet
= ScTabViewObj::getImplementation( xController
);
1115 IMPL_LINK( ScTabViewShell
, SimpleRefDone
, OUString
*, pResult
)
1117 ScTabViewObj
* pImpObj
= lcl_GetViewObj( *this );
1118 if ( pImpObj
&& pResult
)
1119 pImpObj
->RangeSelDone( *pResult
);
1123 IMPL_LINK( ScTabViewShell
, SimpleRefAborted
, OUString
*, pResult
)
1125 ScTabViewObj
* pImpObj
= lcl_GetViewObj( *this );
1126 if ( pImpObj
&& pResult
)
1127 pImpObj
->RangeSelAborted( *pResult
);
1131 IMPL_LINK( ScTabViewShell
, SimpleRefChange
, OUString
*, pResult
)
1133 ScTabViewObj
* pImpObj
= lcl_GetViewObj( *this );
1134 if ( pImpObj
&& pResult
)
1135 pImpObj
->RangeSelChanged( *pResult
);
1139 void ScTabViewShell::StartSimpleRefDialog(
1140 const OUString
& rTitle
, const OUString
& rInitVal
,
1141 bool bCloseOnButtonUp
, bool bSingleCell
, bool bMultiSelection
)
1143 SfxViewFrame
* pViewFrm
= GetViewFrame();
1145 if ( GetActiveViewShell() != this )
1147 // #i18833# / #i34499# The API method can be called for a view that's not active.
1148 // Then the view has to be activated first, the same way as in Execute for SID_CURRENTDOC.
1149 // Can't use GrabFocus here, because it needs to take effect immediately.
1151 pViewFrm
->GetFrame().Appear();
1154 sal_uInt16 nId
= ScSimpleRefDlgWrapper::GetChildWindowId();
1156 SC_MOD()->SetRefDialog( nId
, true, pViewFrm
);
1158 ScSimpleRefDlgWrapper
* pWnd
= static_cast<ScSimpleRefDlgWrapper
*>(pViewFrm
->GetChildWindow( nId
));
1161 pWnd
->SetCloseHdl( LINK( this, ScTabViewShell
, SimpleRefClose
) );
1162 pWnd
->SetUnoLinks( LINK( this, ScTabViewShell
, SimpleRefDone
),
1163 LINK( this, ScTabViewShell
, SimpleRefAborted
),
1164 LINK( this, ScTabViewShell
, SimpleRefChange
) );
1165 pWnd
->SetRefString( rInitVal
);
1166 pWnd
->SetFlags( bCloseOnButtonUp
, bSingleCell
, bMultiSelection
);
1167 ScSimpleRefDlgWrapper::SetAutoReOpen( false );
1168 vcl::Window
* pWin
= pWnd
->GetWindow();
1169 pWin
->SetText( rTitle
);
1170 pWnd
->StartRefInput();
1174 void ScTabViewShell::StopSimpleRefDialog()
1176 SfxViewFrame
* pViewFrm
= GetViewFrame();
1177 sal_uInt16 nId
= ScSimpleRefDlgWrapper::GetChildWindowId();
1179 ScSimpleRefDlgWrapper
* pWnd
= static_cast<ScSimpleRefDlgWrapper
*>(pViewFrm
->GetChildWindow( nId
));
1182 vcl::Window
* pWin
= pWnd
->GetWindow();
1183 if (pWin
&& pWin
->IsSystemWindow())
1184 static_cast<SystemWindow
*>(pWin
)->Close(); // calls abort handler
1188 bool ScTabViewShell::TabKeyInput(const KeyEvent
& rKEvt
)
1190 ScModule
* pScMod
= SC_MOD();
1192 SfxViewFrame
* pThisFrame
= GetViewFrame();
1193 if ( pThisFrame
->GetChildWindow( SID_OPENDLG_FUNCTION
) )
1196 vcl::KeyCode aCode
= rKEvt
.GetKeyCode();
1197 bool bShift
= aCode
.IsShift();
1198 bool bControl
= aCode
.IsMod1();
1199 bool bAlt
= aCode
.IsMod2();
1200 sal_uInt16 nCode
= aCode
.GetCode();
1202 bool bInPlace
= pScMod
->IsEditMode(); // Editengine bekommt alles
1203 bool bAnyEdit
= pScMod
->IsInputMode(); // nur Zeichen & Backspace
1204 bool bDraw
= IsDrawTextEdit();
1206 HideNoteMarker(); // Notiz-Anzeige
1208 // don't do extra HideCursor/ShowCursor calls if EnterHandler will switch to a different sheet
1209 bool bOnRefSheet
= ( GetViewData().GetRefTabNo() == GetViewData().GetTabNo() );
1210 bool bHideCursor
= ( ( nCode
== KEY_RETURN
&& bInPlace
) || nCode
== KEY_TAB
) && bOnRefSheet
;
1215 ScDocument
* pDoc
= GetViewData().GetDocument();
1217 pDoc
->KeyInput( rKEvt
); // TimerDelays etc.
1221 bUsed
= pScMod
->InputKeyEvent( rKEvt
); // Eingabe
1223 bUsed
= SfxViewShell::KeyInput( rKEvt
); // accelerators
1227 bool bIsType
= false;
1228 sal_uInt16 nModi
= aCode
.GetModifier();
1229 sal_uInt16 nGroup
= aCode
.GetGroup();
1231 if ( nGroup
== KEYGROUP_NUM
|| nGroup
== KEYGROUP_ALPHA
|| nGroup
== 0 )
1232 if ( !bControl
&& !bAlt
)
1235 if ( nGroup
== KEYGROUP_MISC
)
1239 bIsType
= bControl
&& !bAlt
; // Control, Shift-Control-Return
1240 if ( !bIsType
&& nModi
== 0 )
1242 // Will der InputHandler auch ein einfaches Return?
1244 ScInputHandler
* pHdl
= pScMod
->GetInputHdl(this);
1245 bIsType
= pHdl
&& pHdl
->TakesReturn();
1249 bIsType
= !bControl
&& !bAlt
; // ohne Modifier oder Shift-Space
1252 bIsType
= (nModi
== 0); // nur ohne Modifier
1259 bUsed
= pScMod
->InputKeyEvent( rKEvt
); // Eingabe
1262 bUsed
= SfxViewShell::KeyInput( rKEvt
); // accelerators
1264 if ( !bUsed
&& !bIsType
&& nCode
!= KEY_RETURN
) // Eingabe nochmal hinterher
1265 bUsed
= pScMod
->InputKeyEvent( rKEvt
);
1269 // Spezialfall: Copy/Cut bei Mehrfachselektion -> Fehlermeldung
1270 // (Slot ist disabled, SfxViewShell::KeyInput wuerde also kommentarlos verschluckt)
1271 KeyFuncType eFunc
= aCode
.GetFunction();
1272 if ( eFunc
== KeyFuncType::CUT
)
1275 ScMarkType eMarkType
= GetViewData().GetSimpleArea( aDummy
);
1276 if (eMarkType
!= SC_MARK_SIMPLE
)
1278 ErrorMessage(STR_NOMULTISELECT
);
1283 bUsed
= SfxViewShell::KeyInput( rKEvt
); // accelerators
1285 // during inplace editing, some slots are handled by the
1286 // container app and are executed during Window::KeyInput.
1287 // -> don't pass keys to input handler that would be used there
1288 // but should call slots instead.
1289 bool bParent
= ( GetViewFrame()->GetFrame().IsInPlace() && eFunc
!= KeyFuncType::DONTKNOW
);
1291 if( !bUsed
&& !bDraw
&& nCode
!= KEY_RETURN
&& !bParent
)
1292 bUsed
= pScMod
->InputKeyEvent( rKEvt
, true ); // Eingabe
1295 if (!bInPlace
&& !bUsed
&& !bDraw
)
1301 bool bNormal
= !bControl
&& !bAlt
;
1302 if ( !bAnyEdit
&& bNormal
)
1304 // je nach Optionen mit Enter in den Edit-Modus schalten
1306 const ScInputOptions
& rOpt
= pScMod
->GetInputOptions();
1307 if ( rOpt
.GetEnterEdit() )
1309 pScMod
->SetInputMode( SC_INPUT_TABLE
);
1314 bool bEditReturn
= bControl
&& !bShift
; // An Edit-Engine weiter
1315 if ( !bUsed
&& !bEditReturn
)
1320 sal_uInt8 nMode
= SC_ENTER_NORMAL
;
1321 if ( bShift
&& bControl
)
1322 nMode
= SC_ENTER_MATRIX
;
1324 nMode
= SC_ENTER_BLOCK
;
1325 pScMod
->InputEnterHandler(nMode
);
1327 if (nMode
== SC_ENTER_NORMAL
)
1330 GetViewData().GetDispatcher().Execute( SID_CURSORENTERUP
,
1331 SfxCallMode::SLOT
| SfxCallMode::RECORD
);
1333 GetViewData().GetDispatcher().Execute( SID_CURSORENTERDOWN
,
1334 SfxCallMode::SLOT
| SfxCallMode::RECORD
);
1337 UpdateInputHandler(true);
1342 // hier kein UpdateInputHandler, weil bei Referenzeingabe auf ein
1343 // anderes Dokument diese ViewShell nicht die ist, auf der eingegeben
1353 // Alt-Cursortasten hart codiert, weil Alt nicht konfigurierbar ist
1355 if ( !bUsed
&& bAlt
&& !bControl
)
1357 sal_uInt16 nSlotId
= 0;
1361 ModifyCellSize( DIR_TOP
, bShift
);
1365 ModifyCellSize( DIR_BOTTOM
, bShift
);
1369 ModifyCellSize( DIR_LEFT
, bShift
);
1373 ModifyCellSize( DIR_RIGHT
, bShift
);
1377 nSlotId
= bShift
? SID_CURSORPAGELEFT_SEL
: SID_CURSORPAGELEFT_
;
1380 nSlotId
= bShift
? SID_CURSORPAGERIGHT_SEL
: SID_CURSORPAGERIGHT_
;
1385 GetViewData().GetDispatcher().Execute( nSlotId
, SfxCallMode::SLOT
| SfxCallMode::RECORD
);
1390 // use Ctrl+Alt+Shift+arrow keys to move the cursor in cells
1391 // while keeping the last selection
1392 if ( !bUsed
&& bAlt
&& bControl
&& bShift
)
1394 sal_uInt16 nSlotId
= 0;
1398 nSlotId
= SID_CURSORUP
;
1401 nSlotId
= SID_CURSORDOWN
;
1404 nSlotId
= SID_CURSORLEFT
;
1407 nSlotId
= SID_CURSORRIGHT
;
1410 nSlotId
= SID_CURSORPAGEUP
;
1413 nSlotId
= SID_CURSORPAGEDOWN
;
1416 nSlotId
= SID_CURSORHOME
;
1419 nSlotId
= SID_CURSOREND
;
1427 sal_uInt16 nMode
= GetLockedModifiers();
1428 LockModifiers(KEY_MOD1
);
1429 GetViewData().GetDispatcher().Execute( nSlotId
, SfxCallMode::SLOT
| SfxCallMode::RECORD
);
1430 LockModifiers(nMode
);
1440 bool ScTabViewShell::SfxKeyInput(const KeyEvent
& rKeyEvent
)
1442 return SfxViewShell::KeyInput( rKeyEvent
);
1445 bool ScTabViewShell::KeyInput( const KeyEvent
&rKeyEvent
)
1447 return TabKeyInput( rKeyEvent
);
1450 void ScTabViewShell::Construct( TriState nForceDesignMode
)
1452 SfxApplication
* pSfxApp
= SfxGetpApp();
1453 ScDocShell
* pDocSh
= GetViewData().GetDocShell();
1454 ScDocument
& rDoc
= pDocSh
->GetDocument();
1455 bReadOnly
= pDocSh
->IsReadOnly();
1458 EnableAutoSpell(rDoc
.GetDocOptions().IsAutoSpell());
1460 SetName(OUString("View")); // fuer SBX
1461 Color
aColBlack( COL_BLACK
);
1462 SetPool( &SC_MOD()->GetPool() );
1463 SetWindow( GetActiveWin() );
1465 pCurFrameLine
= new ::editeng::SvxBorderLine(&aColBlack
, 20,
1466 table::BorderLineStyle::SOLID
);
1467 pPivotSource
= new ScArea
;
1468 StartListening(*GetViewData().GetDocShell(),true);
1469 StartListening(*GetViewFrame(),true);
1470 StartListening(*pSfxApp
,true); // #i62045# #i62046# application is needed for Calc's own hints
1472 SfxViewFrame
* pFirst
= SfxViewFrame::GetFirst(pDocSh
);
1473 bool bFirstView
= !pFirst
1474 || (pFirst
== GetViewFrame() && !SfxViewFrame::GetNext(*pFirst
,pDocSh
));
1476 if ( pDocSh
->GetCreateMode() == SfxObjectCreateMode::EMBEDDED
)
1478 //TODO/LATER: is there a difference between the two GetVisArea methods?
1479 Rectangle aVisArea
= ((const SfxObjectShell
*)pDocSh
)->GetVisArea();
1481 SCTAB nVisTab
= rDoc
.GetVisibleTab();
1482 if (!rDoc
.HasTable(nVisTab
))
1485 rDoc
.SetVisibleTab(nVisTab
);
1487 SetTabNo( nVisTab
);
1488 bool bNegativePage
= rDoc
.IsNegativePage( nVisTab
);
1489 // show the right cells
1490 GetViewData().SetScreenPos( bNegativePage
? aVisArea
.TopRight() : aVisArea
.TopLeft() );
1492 if ( GetViewFrame()->GetFrame().IsInPlace() ) // inplace
1494 pDocSh
->SetInplace( true ); // schon so initialisiert
1495 if (rDoc
.IsEmbedded())
1496 rDoc
.ResetEmbedded(); // keine blaue Markierung
1498 else if ( bFirstView
)
1500 pDocSh
->SetInplace( false );
1501 GetViewData().RefreshZoom(); // recalculate PPT
1502 if (!rDoc
.IsEmbedded())
1503 rDoc
.SetEmbedded( rDoc
.GetVisibleTab(), aVisArea
); // VisArea markieren
1508 // jeder Task hat neuerdings sein eigenes InputWindow,
1509 // darum muesste eigentlich entweder jeder Task seinen InputHandler bekommen,
1510 // oder das InputWindow muesste sich beim App-InputHandler anmelden, wenn der
1511 // Task aktiv wird, oder das InputWindow muesste sich den InputHandler selbst
1512 // anlegen (dann immer ueber das InputWindow suchen, und nur wenn das nicht da
1513 // ist, den InputHandler von der App nehmen).
1514 // Als Sofortloesung bekommt erstmal jede View ihren Inputhandler, das gibt
1515 // nur noch Probleme, wenn zwei Views in einem Task-Fenster sind.
1517 pInputHandler
= new ScInputHandler
;
1520 // if ( !GetViewFrame()->ISA(SfxTopViewFrame) ) // OLE oder Plug-In
1521 // pInputHandler = new ScInputHandler;
1523 // FormShell vor MakeDrawView anlegen, damit die DrawView auf jeden Fall
1524 // an der FormShell angemeldet werden kann
1525 // Gepusht wird die FormShell im ersten Activate
1526 pFormShell
= new FmFormShell(this);
1527 pFormShell
->SetControlActivationHandler( LINK( this, ScTabViewShell
, FormControlActivated
) );
1529 // DrawView darf nicht im TabView - ctor angelegt werden,
1530 // wenn die ViewShell noch nicht kostruiert ist...
1531 if (rDoc
.GetDrawLayer())
1532 MakeDrawView( nForceDesignMode
);
1533 ViewOptionsHasChanged(false); // legt auch evtl. DrawView an
1535 ::svl::IUndoManager
* pMgr
= pDocSh
->GetUndoManager();
1536 SetUndoManager( pMgr
);
1537 pFormShell
->SetUndoManager( pMgr
);
1538 if ( !rDoc
.IsUndoEnabled() )
1540 pMgr
->SetMaxUndoActionCount( 0 );
1542 SetRepeatTarget( &aTarget
);
1543 pFormShell
->SetRepeatTarget( &aTarget
);
1544 SetHelpId( HID_SCSHELL_TABVWSH
);
1546 if ( bFirstView
) // first view?
1548 rDoc
.SetDocVisible( true ); // used when creating new sheets
1549 if ( pDocSh
->IsEmpty() )
1551 // set first sheet's RTL flag (following will already be initialized because of SetDocVisible)
1552 rDoc
.SetLayoutRTL( 0, ScGlobal::IsSystemRTL() );
1554 // append additional sheets (not for OLE object)
1555 if ( pDocSh
->GetCreateMode() != SfxObjectCreateMode::EMBEDDED
)
1557 // Get the customized initial tab count
1558 const ScDefaultsOptions
& rOpt
= SC_MOD()->GetDefaultsOptions();
1559 SCTAB nInitTabCount
= rOpt
.GetInitTabCount();
1561 for (SCTAB i
=1; i
<nInitTabCount
; i
++)
1562 rDoc
.MakeTable(i
,false);
1565 pDocSh
->SetEmpty( false ); // #i6232# make sure this is done only once
1568 // ReadExtOptions is now in Activate
1570 // Link-Update nicht verschachteln
1571 if ( pDocSh
->GetCreateMode() != SfxObjectCreateMode::INTERNAL
&&
1572 pDocSh
->IsUpdateEnabled() ) // #105575#; update only in the first creation of the ViewShell
1574 // Check if there are any external data.
1575 bool bLink
= rDoc
.GetExternalRefManager()->hasExternalData();
1578 // #i100042# sheet links can still exist independently from external formula references
1579 SCTAB nTabCount
= rDoc
.GetTableCount();
1580 for (SCTAB i
=0; i
<nTabCount
&& !bLink
; i
++)
1581 if (rDoc
.IsLinked(i
))
1586 const sc::DocumentLinkManager
& rMgr
= rDoc
.GetDocLinkManager();
1587 if (rMgr
.hasDdeLinks() || rDoc
.HasAreaLinks())
1593 pFirst
= GetViewFrame();
1595 if(SC_MOD()->GetCurRefDlgId()==0)
1597 pFirst
->GetDispatcher()->Execute( SID_UPDATETABLINKS
,
1598 SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
1602 bool bReImport
= false; // importierte Daten aktualisieren
1603 ScDBCollection
* pDBColl
= rDoc
.GetDBCollection();
1606 const ScDBCollection::NamedDBs
& rDBs
= pDBColl
->getNamedDBs();
1607 ScDBCollection::NamedDBs::const_iterator itr
= rDBs
.begin(), itrEnd
= rDBs
.end();
1608 for (; itr
!= itrEnd
; ++itr
)
1610 if (itr
->IsStripData() && itr
->HasImportParam() && !itr
->HasImportSelection())
1620 pFirst
= GetViewFrame();
1621 if(SC_MOD()->GetCurRefDlgId()==0)
1623 pFirst
->GetDispatcher()->Execute( SID_REIMPORT_AFTER_LOAD
,
1624 SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
1630 UpdateAutoFillMark();
1632 // ScDispatchProviderInterceptor registers itself in ctor
1633 xDisProvInterceptor
= new ScDispatchProviderInterceptor( this );
1635 bFirstActivate
= true; // NavigatorUpdate aufschieben bis Activate()
1637 // #105575#; update only in the first creation of the ViewShell
1638 pDocSh
->SetUpdateEnabled(false);
1640 if ( GetViewFrame()->GetFrame().IsInPlace() )
1641 UpdateHeaderWidth(); // The implace activation requires headers to be calculated
1644 GetBorderSize( aBorder
, Size() );
1645 SetBorderPixel( aBorder
);
1648 ScTabViewShell::ScTabViewShell( SfxViewFrame
* pViewFrame
,
1649 SfxViewShell
* pOldSh
) :
1650 SfxViewShell( pViewFrame
, SfxViewShellFlags::CAN_PRINT
| SfxViewShellFlags::HAS_PRINTOPTIONS
),
1651 ScDBFunc( &pViewFrame
->GetWindow(), static_cast<ScDocShell
&>(*pViewFrame
->GetObjectShell()), this ),
1654 nCtrlSfxId(USHRT_MAX
),
1655 nFormSfxId(USHRT_MAX
),
1657 pDrawTextShell(NULL
),
1660 pAuditingShell(NULL
),
1661 pDrawFormShell(NULL
),
1663 pOleObjectShell(NULL
),
1665 pGraphicShell(NULL
),
1667 pPageBreakShell(NULL
),
1668 pExtrusionBarShell(NULL
),
1669 pFontworkBarShell(NULL
),
1671 pInputHandler(NULL
),
1672 pCurFrameLine(NULL
),
1674 pDialogDPObject(NULL
),
1676 bActiveDrawSh(false),
1677 bActiveDrawTextSh(false),
1678 bActivePivotSh(false),
1679 bActiveAuditingSh(false),
1680 bActiveDrawFormSh(false),
1681 bActiveOleObjectSh(false),
1682 bActiveChartSh(false),
1683 bActiveGraphicSh(false),
1684 bActiveMediaSh(false),
1685 bActiveEditSh(false),
1686 bFormShellAtTop(false),
1688 bInFormatDialog(false),
1689 bPrintSelected(false),
1692 bChartAreaValid(false),
1693 bForceFocusOnCurCell(false),
1695 pAccessibilityBroadcaster(NULL
),
1698 const ScAppOptions
& rAppOpt
= SC_MOD()->GetAppOptions();
1700 // if switching back from print preview,
1701 // restore the view settings that were active when creating the preview
1702 // ReadUserData must not happen from ctor, because the view's edit window
1703 // has to be shown by the sfx. ReadUserData is deferred until the first Activate call.
1704 // old DesignMode state from form layer must be restored, too
1706 TriState nForceDesignMode
= TRISTATE_INDET
;
1707 if ( pOldSh
&& pOldSh
->ISA( ScPreviewShell
) )
1709 ScPreviewShell
* pPreviewShell
= static_cast<ScPreviewShell
*>(pOldSh
);
1710 nForceDesignMode
= pPreviewShell
->GetSourceDesignMode();
1711 ScPreview
* p
= pPreviewShell
->GetPreview();
1713 GetViewData().GetMarkData().SetSelectedTabs(p
->GetSelectedTabs());
1716 Construct( nForceDesignMode
);
1718 if ( GetViewData().GetDocShell()->IsPreview() )
1720 // preview for template dialog: always show whole page
1721 SetZoomType( SvxZoomType::WHOLEPAGE
, true ); // zoom value is recalculated at next Resize
1725 Fraction
aFract( rAppOpt
.GetZoom(), 100 );
1726 SetZoom( aFract
, aFract
, true );
1727 SetZoomType( rAppOpt
.GetZoomType(), true );
1730 // make Controller known to SFX
1731 new ScTabViewObj( this );
1733 SetCurSubShell(OST_Cell
);
1735 GetBorderSize( aBorder
, Size() );
1736 SetBorderPixel( aBorder
);
1742 ScTabViewShell::~ScTabViewShell()
1744 ScDocShell
* pDocSh
= GetViewData().GetDocShell();
1745 EndListening(*pDocSh
);
1746 EndListening(*GetViewFrame());
1747 EndListening(*SfxGetpApp()); // #i62045# #i62046# needed now - SfxViewShell no longer does it
1749 SC_MOD()->ViewShellGone(this);
1751 RemoveSubShell(); // alle
1754 // alles auf NULL, falls aus dem TabView-dtor noch darauf zugegriffen wird
1755 //! (soll eigentlich nicht !??!?!)
1758 pInputHandler
->SetDocumentDisposing(true);
1760 DELETEZ(pFontworkBarShell
);
1761 DELETEZ(pExtrusionBarShell
);
1762 DELETEZ(pCellShell
);
1763 DELETEZ(pPageBreakShell
);
1764 DELETEZ(pDrawShell
);
1765 DELETEZ(pDrawFormShell
);
1766 DELETEZ(pOleObjectShell
);
1767 DELETEZ(pChartShell
);
1768 DELETEZ(pGraphicShell
);
1769 DELETEZ(pMediaShell
);
1770 DELETEZ(pDrawTextShell
);
1771 DELETEZ(pEditShell
);
1772 DELETEZ(pPivotShell
);
1773 DELETEZ(pAuditingShell
);
1774 DELETEZ(pCurFrameLine
);
1775 DELETEZ(pInputHandler
);
1776 DELETEZ(pPivotSource
);
1777 DELETEZ(pDialogDPObject
);
1778 DELETEZ(pNavSettings
);
1780 DELETEZ(pFormShell
);
1781 DELETEZ(pAccessibilityBroadcaster
);
1784 void ScTabViewShell::SetDialogDPObject( const ScDPObject
* pObj
)
1786 delete pDialogDPObject
;
1788 pDialogDPObject
= new ScDPObject( *pObj
);
1790 pDialogDPObject
= NULL
;
1793 void ScTabViewShell::FillFieldData( ScHeaderFieldData
& rData
)
1795 ScDocShell
* pDocShell
= GetViewData().GetDocShell();
1796 ScDocument
& rDoc
= pDocShell
->GetDocument();
1797 SCTAB nTab
= GetViewData().GetTabNo();
1799 rDoc
.GetName(nTab
, aTmp
);
1800 rData
.aTabName
= aTmp
;
1802 if( pDocShell
->getDocProperties()->getTitle().getLength() != 0 )
1803 rData
.aTitle
= pDocShell
->getDocProperties()->getTitle();
1805 rData
.aTitle
= pDocShell
->GetTitle();
1807 const INetURLObject
& rURLObj
= pDocShell
->GetMedium()->GetURLObject();
1808 rData
.aLongDocName
= rURLObj
.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS
);
1809 if ( !rData
.aLongDocName
.isEmpty() )
1810 rData
.aShortDocName
= rURLObj
.GetName( INetURLObject::DECODE_UNAMBIGUOUS
);
1812 rData
.aShortDocName
= rData
.aLongDocName
= rData
.aTitle
;
1814 rData
.nTotalPages
= 99;
1816 // eNumType kennt der Dialog selber
1819 bool ScTabViewShell::GetChartArea( ScRangeListRef
& rSource
, Rectangle
& rDest
, SCTAB
& rTab
) const
1821 rSource
= aChartSource
;
1823 rTab
= nChartDestTab
;
1824 return bChartAreaValid
;
1827 ScNavigatorSettings
* ScTabViewShell::GetNavigatorSettings()
1830 pNavSettings
= new ScNavigatorSettings
;
1831 return pNavSettings
;
1834 void ScTabViewShell::ExecTbx( SfxRequest
& rReq
)
1836 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
1837 sal_uInt16 nSlot
= rReq
.GetSlot();
1838 const SfxPoolItem
* pItem
= NULL
;
1840 pReqArgs
->GetItemState( nSlot
, true, &pItem
);
1844 case SID_TBXCTL_INSERT
:
1846 nInsertCtrlState
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
1848 case SID_TBXCTL_INSCELLS
:
1850 nInsCellsCtrlState
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
1852 case SID_TBXCTL_INSOBJ
:
1854 nInsObjCtrlState
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
1857 OSL_FAIL("Slot im Wald");
1859 GetViewFrame()->GetBindings().Invalidate( nSlot
);
1862 void ScTabViewShell::GetTbxState( SfxItemSet
& rSet
)
1864 rSet
.Put( SfxUInt16Item( SID_TBXCTL_INSERT
, nInsertCtrlState
) );
1865 rSet
.Put( SfxUInt16Item( SID_TBXCTL_INSCELLS
, nInsCellsCtrlState
) );
1867 // ohne installiertes Chart darf Chart nicht Default sein...
1868 if ( nInsObjCtrlState
== SID_DRAW_CHART
&& !SvtModuleOptions().IsChart() )
1869 nInsObjCtrlState
= SID_INSERT_OBJECT
;
1871 rSet
.Put( SfxUInt16Item( SID_TBXCTL_INSOBJ
, nInsObjCtrlState
) );
1874 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */