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>
97 extern SfxViewShell
* pScActiveViewShell
; // global.cxx
99 using namespace com::sun::star
;
101 // STATIC DATA -----------------------------------------------------------
103 sal_uInt16
ScTabViewShell::nInsertCtrlState
= SID_INSERT_GRAPHIC
;
104 sal_uInt16
ScTabViewShell::nInsCellsCtrlState
= 0;
105 sal_uInt16
ScTabViewShell::nInsObjCtrlState
= SID_INSERT_DIAGRAM
;
107 void ScTabViewShell::Activate(bool bMDI
)
109 SfxViewShell::Activate(bMDI
);
111 // hier kein GrabFocus, sonst gibt's Probleme wenn etwas inplace editiert wird!
115 // fuer Eingabezeile (ClearCache)
116 ScModule
* pScMod
= SC_MOD();
117 pScMod
->ViewShellChanged();
119 ActivateView( true, bFirstActivate
);
120 ActivateOlk( GetViewData() );
122 // AutoCorrect umsetzen, falls der Writer seins neu angelegt hat
123 UpdateDrawTextOutliner();
125 // RegisterNewTargetNames gibts nicht mehr
127 SfxViewFrame
* pThisFrame
= GetViewFrame();
128 if ( pInputHandler
&& pThisFrame
->HasChildWindow(FID_INPUTLINE_STATUS
) )
130 // eigentlich nur beim Reload (letzte Version) noetig:
131 // Das InputWindow bleibt stehen, aber die View mitsamt InputHandler wird
132 // neu angelegt, darum muss der InputHandler am InputWindow gesetzt werden.
133 SfxChildWindow
* pChild
= pThisFrame
->GetChildWindow(FID_INPUTLINE_STATUS
);
136 ScInputWindow
* pWin
= (ScInputWindow
*)pChild
->GetWindow();
137 if (pWin
&& pWin
->IsVisible())
140 ScInputHandler
* pOldHdl
=pWin
->GetInputHandler();
142 TypeId aScType
= TYPE(ScTabViewShell
);
144 SfxViewShell
* pSh
= SfxViewShell::GetFirst( &aScType
);
145 while ( pSh
!=NULL
&& pOldHdl
!=NULL
)
147 if (((ScTabViewShell
*)pSh
)->GetInputHandler() == pOldHdl
)
149 pOldHdl
->ResetDelayTimer();
152 pSh
= SfxViewShell::GetNext( *pSh
, &aScType
);
155 pWin
->SetInputHandler( pInputHandler
);
160 UpdateInputHandler( true );
162 if ( bFirstActivate
)
164 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_NAVIGATOR_UPDATEALL
) );
165 bFirstActivate
= false;
167 // ReadExtOptions (view settings from Excel import) must also be done
168 // after the ctor, because of the potential calls to Window::Show.
169 // Even after a bugfix (Window::Show no longer notifies the access
170 // bridge, it's done in ImplSetReallyVisible), there are problems if Window::Show
171 // is called during the ViewShell ctor and reschedules asynchronous calls
172 // (for example from the FmFormShell ctor).
173 ScExtDocOptions
* pExtOpt
= GetViewData()->GetDocument()->GetExtDocOptions();
174 if ( pExtOpt
&& pExtOpt
->IsChanged() )
176 GetViewData()->ReadExtOptions(*pExtOpt
); // Excel view settings
177 SetTabNo( GetViewData()->GetTabNo(), true );
178 pExtOpt
->SetChanged( false );
182 pScActiveViewShell
= this;
184 ScInputHandler
* pHdl
= pScMod
->GetInputHdl(this);
187 pHdl
->SetRefScale( GetViewData()->GetZoomX(), GetViewData()->GetZoomY() );
190 // Aenderungs-Dialog aktualisieren
192 if ( pThisFrame
->HasChildWindow(FID_CHG_ACCEPT
) )
194 SfxChildWindow
* pChild
= pThisFrame
->GetChildWindow(FID_CHG_ACCEPT
);
197 ((ScAcceptChgDlgWrapper
*)pChild
)->ReInitDlg();
201 if(pScMod
->IsRefDialogOpen())
203 sal_uInt16 nModRefDlgId
=pScMod
->GetCurRefDlgId();
204 SfxChildWindow
* pChildWnd
= pThisFrame
->GetChildWindow( nModRefDlgId
);
207 IAnyRefDialog
* pRefDlg
= dynamic_cast<IAnyRefDialog
*>(pChildWnd
->GetWindow());
211 pRefDlg
->ViewShellChanged();
217 // don't call CheckSelectionTransfer here - activating a view should not change the
218 // primary selection (may be happening just because the mouse was moved over the window)
220 // Wenn Referenzeingabe-Tip-Hilfe hier wieder angezeigt werden soll (ShowRefTip),
221 // muss sie beim Verschieben der View angepasst werden (gibt sonst Probleme unter OS/2
222 // beim Umschalten zwischen Dokumenten)
224 ContextChangeEventMultiplexer::NotifyContextChange(
226 ::sfx2::sidebar::EnumContext::Context_Default
);
229 void ScTabViewShell::Deactivate(bool bMDI
)
233 ScDocument
* pDoc
=GetViewData()->GetDocument();
235 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
240 pChanges
->SetModifiedLink(aLink
);
243 SfxViewShell::Deactivate(bMDI
);
245 ScInputHandler
* pHdl
= SC_MOD()->GetInputHdl(this);
249 // during shell deactivation, shells must not be switched, or the loop
250 // through the shell stack (in SfxDispatcher::DoDeactivate_Impl) will not work
251 bool bOldDontSwitch
= bDontSwitch
;
254 DeActivateOlk( GetViewData() );
255 ActivateView( false, false );
257 if ( GetViewFrame()->GetFrame().IsInPlace() ) // inplace
258 GetViewData()->GetDocShell()->UpdateOle(GetViewData(), true);
261 pHdl
->NotifyChange( NULL
, true ); // Timer-verzoegert wg. Dokumentwechsel
263 if (pScActiveViewShell
== this)
264 pScActiveViewShell
= NULL
;
266 bDontSwitch
= bOldDontSwitch
;
270 HideNoteMarker(); // Notiz-Anzeige
273 pHdl
->HideTip(); // Formel-AutoEingabe-Tip abschalten
277 void ScTabViewShell::SetActive()
279 // Die Sfx-View moechte sich gerne selbst aktivieren, weil dabei noch
280 // magische Dinge geschehen (z.B. stuerzt sonst evtl. der Gestalter ab)
284 bool ScTabViewShell::PrepareClose(bool bUI
)
286 // Call EnterHandler even in formula mode here,
287 // so a formula change in an embedded object isn't lost
288 // (ScDocShell::PrepareClose isn't called then).
289 ScInputHandler
* pHdl
= SC_MOD()->GetInputHdl( this );
290 if ( pHdl
&& pHdl
->IsInputMode() )
291 pHdl
->EnterHandler();
293 // draw text edit mode must be closed
294 FuPoor
* pPoor
= GetDrawFuncPtr();
295 if ( pPoor
&& ( IsDrawTextShell() || pPoor
->GetSlotID() == SID_DRAW_NOTEEDIT
) )
297 // "clean" end of text edit, including note handling, subshells and draw func switching,
298 // as in FuDraw and ScTabView::DrawDeselectAll
299 GetViewData()->GetDispatcher().Execute( pPoor
->GetSlotID(), SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
301 ScDrawView
* pDrView
= GetScDrawView();
304 // force end of text edit, to be safe
305 // ScEndTextEdit must always be used, to ensure correct UndoManager
306 pDrView
->ScEndTextEdit();
311 bool nRet
= pFormShell
->PrepareClose(bUI
);
315 return SfxViewShell::PrepareClose(bUI
);
318 // Zoom fuer In-Place berechnen
319 // aus Verhaeltnis von VisArea und Fenstergroesse des GridWin
321 void ScTabViewShell::UpdateOleZoom()
323 ScDocShell
* pDocSh
= GetViewData()->GetDocShell();
324 if ( pDocSh
->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED
)
326 //TODO/LATER: is there a difference between the two GetVisArea methods?
327 Size aObjSize
= ((const SfxObjectShell
*)pDocSh
)->GetVisArea().GetSize();
328 if ( aObjSize
.Width() > 0 && aObjSize
.Height() > 0 )
330 Window
* pWin
= GetActiveWin();
331 Size aWinHMM
= pWin
->PixelToLogic( pWin
->GetOutputSizePixel(), MAP_100TH_MM
);
332 SetZoomFactor( Fraction( aWinHMM
.Width(),aObjSize
.Width() ),
333 Fraction( aWinHMM
.Height(),aObjSize
.Height() ) );
338 void ScTabViewShell::AdjustPosSizePixel( const Point
&rPos
, const Size
&rSize
)
340 OuterResizePixel( rPos
, rSize
);
343 void ScTabViewShell::InnerResizePixel( const Point
&rOfs
, const Size
&rSize
)
345 Size
aNewSize( rSize
);
346 if ( GetViewFrame()->GetFrame().IsInPlace() )
349 GetBorderSize( aBorder
, rSize
);
350 SetBorderPixel( aBorder
);
352 Size aObjSize
= GetObjectShell()->GetVisArea().GetSize();
355 aSize
.Width() -= (aBorder
.Left() + aBorder
.Right());
356 aSize
.Height() -= (aBorder
.Top() + aBorder
.Bottom());
358 if ( aObjSize
.Width() > 0 && aObjSize
.Height() > 0 )
360 Size aLogicSize
= GetWindow()->PixelToLogic( aSize
, MAP_100TH_MM
);
361 SfxViewShell::SetZoomFactor( Fraction( aLogicSize
.Width(),aObjSize
.Width() ),
362 Fraction( aLogicSize
.Height(),aObjSize
.Height() ) );
366 aPos
.X() += aBorder
.Left();
367 aPos
.Y() += aBorder
.Top();
368 GetWindow()->SetPosSizePixel( aPos
, aSize
);
373 GetBorderSize( aBorder
, rSize
);
374 SetBorderPixel( aBorder
);
375 aNewSize
.Width() += aBorder
.Left() + aBorder
.Right();
376 aNewSize
.Height() += aBorder
.Top() + aBorder
.Bottom();
379 DoResize( rOfs
, aNewSize
, true ); // rSize = Groesse von gridwin
381 UpdateOleZoom(); // Zoom fuer In-Place berechnen
383 GetViewData()->GetDocShell()->SetDocumentModified();
386 void ScTabViewShell::OuterResizePixel( const Point
&rOfs
, const Size
&rSize
)
389 GetBorderSize( aBorder
, rSize
);
390 SetBorderPixel( aBorder
);
392 DoResize( rOfs
, rSize
); // Position und Groesse von tabview wie uebergeben
394 // ForceMove als Ersatz fuer den Sfx-Move-Mechanismus
395 // (aWinPos muss aktuell gehalten werden, damit ForceMove beim Ole-Deaktivieren klappt)
400 void ScTabViewShell::SetZoomFactor( const Fraction
&rZoomX
, const Fraction
&rZoomY
)
404 Fraction
aFrac20( 1,5 );
405 Fraction
aFrac400( 4,1 );
407 Fraction
aNewX( rZoomX
);
408 if ( aNewX
< aFrac20
)
410 if ( aNewX
> aFrac400
)
412 Fraction
aNewY( rZoomY
);
413 if ( aNewY
< aFrac20
)
415 if ( aNewY
> aFrac400
)
418 GetViewData()->UpdateScreenZoom( aNewX
, aNewY
);
419 SetZoom( aNewX
, aNewY
, true );
425 SfxViewShell::SetZoomFactor( rZoomX
, rZoomY
);
428 void ScTabViewShell::QueryObjAreaPixel( Rectangle
& rRect
) const
430 // auf ganze Zellen anpassen (in 1/100 mm)
432 Size aPixelSize
= rRect
.GetSize();
433 Window
* pWin
= ((ScTabViewShell
*)this)->GetActiveWin();
434 Size aLogicSize
= pWin
->PixelToLogic( aPixelSize
);
436 const ScViewData
* pViewData
= GetViewData();
437 ScDocument
* pDoc
= pViewData
->GetDocument();
438 ScSplitPos ePos
= pViewData
->GetActivePart();
439 SCCOL nCol
= pViewData
->GetPosX(WhichH(ePos
));
440 SCROW nRow
= pViewData
->GetPosY(WhichV(ePos
));
441 SCTAB nTab
= pViewData
->GetTabNo();
442 bool bNegativePage
= pDoc
->IsNegativePage( nTab
);
444 Rectangle aLogicRect
= pDoc
->GetMMRect( nCol
, nRow
, nCol
, nRow
, nTab
);
447 // use right edge of aLogicRect, and aLogicSize
448 aLogicRect
.Left() = aLogicRect
.Right() - aLogicSize
.Width() + 1; // Right() is set below
450 aLogicRect
.SetSize( aLogicSize
);
452 pViewData
->GetDocShell()->SnapVisArea( aLogicRect
);
454 rRect
.SetSize( pWin
->LogicToPixel( aLogicRect
.GetSize() ) );
457 void ScTabViewShell::Move()
459 Point aNewPos
= GetViewFrame()->GetWindow().OutputToScreenPixel(Point());
461 if (aNewPos
!= aWinPos
)
468 void ScTabViewShell::ShowCursor(bool /* bOn */)
470 /*!!! ShowCursor wird nicht paarweise wie im gridwin gerufen.
471 Der CursorLockCount am Gridwin muss hier direkt auf 0 gesetzt werden
480 void ScTabViewShell::WriteUserData(OUString
& rData
, bool /* bBrowse */)
482 GetViewData()->WriteUserData(rData
);
485 void ScTabViewShell::WriteUserDataSequence (uno::Sequence
< beans::PropertyValue
>& rSettings
, bool /* bBrowse */ )
487 GetViewData()->WriteUserDataSequence (rSettings
);
490 void ScTabViewShell::ReadUserData(const OUString
& rData
, bool /* bBrowse */)
492 if ( !GetViewData()->GetDocShell()->IsPreview() )
493 DoReadUserData( rData
);
496 void ScTabViewShell::ReadUserDataSequence (const uno::Sequence
< beans::PropertyValue
>& rSettings
, bool /* bBrowse */ )
498 if ( !GetViewData()->GetDocShell()->IsPreview() )
499 DoReadUserDataSequence( rSettings
);
502 void ScTabViewShell::DoReadUserDataSequence( const uno::Sequence
< beans::PropertyValue
>& rSettings
)
504 Window
* pOldWin
= GetActiveWin();
505 bool bFocus
= pOldWin
&& pOldWin
->HasFocus();
507 GetViewData()->ReadUserDataSequence(rSettings
);
508 SetTabNo( GetViewData()->GetTabNo(), true );
510 if ( GetViewData()->IsPagebreakMode() )
511 SetCurSubShell( GetCurObjectSelectionType(), true );
513 Window
* pNewWin
= GetActiveWin();
514 if (pNewWin
&& pNewWin
!= pOldWin
)
516 SetWindow( pNewWin
); //! ist diese ViewShell immer aktiv???
518 pNewWin
->GrabFocus();
519 WindowChanged(); // Drawing-Layer (z.B. #56771#)
522 if (GetViewData()->GetHSplitMode() == SC_SPLIT_FIX
||
523 GetViewData()->GetVSplitMode() == SC_SPLIT_FIX
)
532 //! if ViewData has more tables than document, remove tables in ViewData
535 void ScTabViewShell::AddOpenGLChartWindows()
538 ScDocument
* pDoc
= GetViewData()->GetDocument();
539 ScGridWindow
* pParentWindow
= GetActiveWin();
541 std::vector
<std::pair
<uno::Reference
<chart2::XChartDocument
>, Rectangle
> > aCharts
= pDoc
->GetAllCharts();
543 for(std::vector
<std::pair
<uno::Reference
<chart2::XChartDocument
>, Rectangle
> >::iterator itr
= aCharts
.begin(),
544 itrEnd
= aCharts
.end(); itr
!= itrEnd
; ++itr
)
546 OpenGLWindow
* pOpenGLWindow
= new OpenGLWindow(pParentWindow
);
547 pOpenGLWindow
->Show(false);
548 Size aSize
= itr
->second
.GetSize();
550 pOpenGLWindow
->SetSizePixel(aSize
);
551 Point aPos
= itr
->second
.TopLeft();
552 pOpenGLWindow
->SetPosPixel(aPos
);
553 pParentWindow
->AddChildWindow(pOpenGLWindow
);
554 uno::Reference
< chart2::X3DChartWindowProvider
> x3DWindowProvider( itr
->first
, uno::UNO_QUERY_THROW
);
555 sal_uInt64 nWindowPtr
= reinterpret_cast<sal_uInt64
>(pOpenGLWindow
);
556 x3DWindowProvider
->setWindow(nWindowPtr
);
561 // DoReadUserData is also called from ctor when switching from print preview
563 void ScTabViewShell::DoReadUserData( const OUString
& rData
)
565 Window
* pOldWin
= GetActiveWin();
566 bool bFocus
= pOldWin
&& pOldWin
->HasFocus();
568 GetViewData()->ReadUserData(rData
);
569 SetTabNo( GetViewData()->GetTabNo(), true );
571 if ( GetViewData()->IsPagebreakMode() )
572 SetCurSubShell( GetCurObjectSelectionType(), true );
574 Window
* pNewWin
= GetActiveWin();
575 if (pNewWin
&& pNewWin
!= pOldWin
)
577 SetWindow( pNewWin
); //! ist diese ViewShell immer aktiv???
579 pNewWin
->GrabFocus();
580 WindowChanged(); // Drawing-Layer (z.B. #56771#)
583 if (GetViewData()->GetHSplitMode() == SC_SPLIT_FIX
||
584 GetViewData()->GetVSplitMode() == SC_SPLIT_FIX
)
593 //! if ViewData has more tables than document, remove tables in ViewData
596 void ScTabViewShell::UpdateDrawShell()
598 // Called after user interaction that may delete the selected drawing object.
599 // Remove DrawShell if nothing is selected.
601 SdrView
* pDrView
= GetSdrView();
602 if ( pDrView
&& !pDrView
->AreObjectsMarked() && !IsDrawSelMode() )
603 SetDrawShell( false );
606 void ScTabViewShell::SetDrawShellOrSub()
608 bActiveDrawSh
= true;
610 if(bActiveDrawFormSh
)
612 SetCurSubShell(OST_DrawForm
);
614 else if(bActiveGraphicSh
)
616 SetCurSubShell(OST_Graphic
);
618 else if(bActiveMediaSh
)
620 SetCurSubShell(OST_Media
);
622 else if(bActiveChartSh
)
624 SetCurSubShell(OST_Chart
);
626 else if(bActiveOleObjectSh
)
628 SetCurSubShell(OST_OleObject
);
632 SetCurSubShell(OST_Drawing
, true /* force: different toolbars are
633 visible concerning shape type
638 void ScTabViewShell::SetDrawShell( bool bActive
)
642 SetCurSubShell(OST_Drawing
, true /* force: different toolbars are
643 visible concerning shape type
648 if(bActiveDrawFormSh
|| bActiveDrawSh
||
649 bActiveGraphicSh
|| bActiveMediaSh
|| bActiveOleObjectSh
||
650 bActiveChartSh
|| bActiveDrawTextSh
)
652 SetCurSubShell(OST_Cell
);
654 bActiveDrawFormSh
=false;
655 bActiveGraphicSh
=false;
656 bActiveMediaSh
=false;
657 bActiveOleObjectSh
=false;
658 bActiveChartSh
=false;
661 bool bWasDraw
= bActiveDrawSh
|| bActiveDrawTextSh
;
663 bActiveDrawSh
= bActive
;
664 bActiveDrawTextSh
= false;
668 ResetDrawDragMode(); // Mirror / Rotate aus
670 if (bWasDraw
&& (GetViewData()->GetHSplitMode() == SC_SPLIT_FIX
||
671 GetViewData()->GetVSplitMode() == SC_SPLIT_FIX
))
673 // Aktiven Teil an Cursor anpassen, etc.
674 MoveCursorAbs( GetViewData()->GetCurX(), GetViewData()->GetCurY(),
675 SC_FOLLOW_NONE
, false, false, true );
680 void ScTabViewShell::SetDrawTextShell( bool bActive
)
682 bActiveDrawTextSh
= bActive
;
685 bActiveDrawFormSh
=false;
686 bActiveGraphicSh
=false;
687 bActiveMediaSh
=false;
688 bActiveOleObjectSh
=false;
689 bActiveChartSh
=false;
690 bActiveDrawSh
= false;
691 SetCurSubShell(OST_DrawText
);
694 SetCurSubShell(OST_Cell
);
698 void ScTabViewShell::SetPivotShell( bool bActive
)
700 bActivePivotSh
= bActive
;
702 // SetPivotShell is called from CursorPosChanged every time
703 // -> don't change anything except switching between cell and pivot shell
705 if ( eCurOST
== OST_Pivot
|| eCurOST
== OST_Cell
)
709 bActiveDrawTextSh
= bActiveDrawSh
= false;
710 bActiveDrawFormSh
=false;
711 bActiveGraphicSh
=false;
712 bActiveMediaSh
=false;
713 bActiveOleObjectSh
=false;
714 bActiveChartSh
=false;
715 SetCurSubShell(OST_Pivot
);
718 SetCurSubShell(OST_Cell
);
722 void ScTabViewShell::SetAuditShell( bool bActive
)
724 bActiveAuditingSh
= bActive
;
727 bActiveDrawTextSh
= bActiveDrawSh
= false;
728 bActiveDrawFormSh
=false;
729 bActiveGraphicSh
=false;
730 bActiveMediaSh
=false;
731 bActiveOleObjectSh
=false;
732 bActiveChartSh
=false;
733 SetCurSubShell(OST_Auditing
);
736 SetCurSubShell(OST_Cell
);
739 void ScTabViewShell::SetDrawFormShell( bool bActive
)
741 bActiveDrawFormSh
= bActive
;
743 if(bActiveDrawFormSh
)
744 SetCurSubShell(OST_DrawForm
);
746 void ScTabViewShell::SetChartShell( bool bActive
)
748 bActiveChartSh
= bActive
;
751 SetCurSubShell(OST_Chart
);
754 void ScTabViewShell::SetGraphicShell( bool bActive
)
756 bActiveGraphicSh
= bActive
;
759 SetCurSubShell(OST_Graphic
);
762 void ScTabViewShell::SetMediaShell( bool bActive
)
764 bActiveMediaSh
= bActive
;
767 SetCurSubShell(OST_Media
);
770 void ScTabViewShell::SetOleObjectShell( bool bActive
)
772 bActiveOleObjectSh
= bActive
;
774 if(bActiveOleObjectSh
)
775 SetCurSubShell(OST_OleObject
);
777 SetCurSubShell(OST_Cell
);
780 void ScTabViewShell::SetEditShell(EditView
* pView
, bool bActive
)
785 pEditShell
->SetEditView( pView
);
787 pEditShell
= new ScEditShell( pView
, GetViewData() );
789 SetCurSubShell(OST_Editing
);
791 else if(bActiveEditSh
)
793 SetCurSubShell(OST_Cell
);
795 bActiveEditSh
= bActive
;
798 void ScTabViewShell::SetCurSubShell(ObjectSelectionType eOST
, bool bForce
)
800 ScViewData
* pViewData
= GetViewData();
801 ScDocShell
* pDocSh
= pViewData
->GetDocShell();
803 if(bDontSwitch
) return;
805 if(!pCellShell
) //Wird eh immer gebraucht.
807 pCellShell
= new ScCellShell( GetViewData() );
808 pCellShell
->SetRepeatTarget( &aTarget
);
811 bool bPgBrk
=pViewData
->IsPagebreakMode();
813 if(bPgBrk
&& !pPageBreakShell
)
815 pPageBreakShell
= new ScPageBreakShell( this );
816 pPageBreakShell
->SetRepeatTarget( &aTarget
);
820 if ( eOST
!=eCurOST
|| bForce
)
822 bool bCellBrush
= false; // "format paint brush" allowed for cells
823 bool bDrawBrush
= false; // "format paint brush" allowed for drawing objects
825 if(eCurOST
!=OST_NONE
) RemoveSubShell();
827 if (pFormShell
&& !bFormShellAtTop
)
828 AddSubShell(*pFormShell
); // add below own subshells
834 AddSubShell(*pCellShell
);
835 if(bPgBrk
) AddSubShell(*pPageBreakShell
);
841 AddSubShell(*pCellShell
);
842 if(bPgBrk
) AddSubShell(*pPageBreakShell
);
846 AddSubShell(*pEditShell
);
852 if ( !pDrawTextShell
)
854 pDocSh
->MakeDrawLayer();
855 pDrawTextShell
= new ScDrawTextObjectBar( GetViewData() );
857 AddSubShell(*pDrawTextShell
);
862 if (svx::checkForSelectedCustomShapes(
863 GetScDrawView(), true /* bOnlyExtruded */ )) {
864 if (pExtrusionBarShell
== 0)
865 pExtrusionBarShell
= new svx::ExtrusionBar(this);
866 AddSubShell( *pExtrusionBarShell
);
868 sal_uInt32 nCheckStatus
= 0;
869 if (svx::checkForSelectedFontWork(
870 GetScDrawView(), nCheckStatus
)) {
871 if (pFontworkBarShell
== 0)
872 pFontworkBarShell
= new svx::FontworkBar(this);
873 AddSubShell( *pFontworkBarShell
);
878 pDocSh
->MakeDrawLayer();
879 pDrawShell
= new ScDrawShell( GetViewData() );
880 pDrawShell
->SetRepeatTarget( &aTarget
);
882 AddSubShell(*pDrawShell
);
889 if ( !pDrawFormShell
)
891 pDocSh
->MakeDrawLayer();
892 pDrawFormShell
= new ScDrawFormShell( GetViewData() );
893 pDrawFormShell
->SetRepeatTarget( &aTarget
);
895 AddSubShell(*pDrawFormShell
);
904 pDocSh
->MakeDrawLayer();
905 pChartShell
= new ScChartShell( GetViewData() );
906 pChartShell
->SetRepeatTarget( &aTarget
);
908 AddSubShell(*pChartShell
);
915 if ( !pOleObjectShell
)
917 pDocSh
->MakeDrawLayer();
918 pOleObjectShell
= new ScOleObjectShell( GetViewData() );
919 pOleObjectShell
->SetRepeatTarget( &aTarget
);
921 AddSubShell(*pOleObjectShell
);
930 pDocSh
->MakeDrawLayer();
931 pGraphicShell
= new ScGraphicShell( GetViewData() );
932 pGraphicShell
->SetRepeatTarget( &aTarget
);
934 AddSubShell(*pGraphicShell
);
943 pDocSh
->MakeDrawLayer();
944 pMediaShell
= new ScMediaShell( GetViewData() );
945 pMediaShell
->SetRepeatTarget( &aTarget
);
947 AddSubShell(*pMediaShell
);
953 AddSubShell(*pCellShell
);
954 if(bPgBrk
) AddSubShell(*pPageBreakShell
);
958 pPivotShell
= new ScPivotShell( this );
959 pPivotShell
->SetRepeatTarget( &aTarget
);
961 AddSubShell(*pPivotShell
);
967 AddSubShell(*pCellShell
);
968 if(bPgBrk
) AddSubShell(*pPageBreakShell
);
970 if ( !pAuditingShell
)
972 pDocSh
->MakeDrawLayer(); // die Wartezeit lieber jetzt als beim Klick
974 pAuditingShell
= new ScAuditingShell( GetViewData() );
975 pAuditingShell
->SetRepeatTarget( &aTarget
);
977 AddSubShell(*pAuditingShell
);
982 OSL_FAIL("Falsche Shell angefordert");
986 if (pFormShell
&& bFormShellAtTop
)
987 AddSubShell(*pFormShell
); // add on top of own subshells
991 // abort "format paint brush" when switching to an incompatible shell
992 if ( ( GetBrushDocument() && !bCellBrush
) || ( GetDrawBrushSet() && !bDrawBrush
) )
993 ResetBrushDocument();
997 void ScTabViewShell::SetFormShellAtTop( bool bSet
)
999 if ( pFormShell
&& !bSet
)
1000 pFormShell
->ForgetActiveControl(); // let the FormShell know it no longer has the focus
1002 if ( bFormShellAtTop
!= bSet
)
1004 bFormShellAtTop
= bSet
;
1005 SetCurSubShell( GetCurObjectSelectionType(), true );
1009 IMPL_LINK_NOARG(ScTabViewShell
, FormControlActivated
)
1011 // a form control got the focus, so the form shell has to be on top
1012 SetFormShellAtTop( true );
1016 ObjectSelectionType
ScTabViewShell::GetCurObjectSelectionType()
1021 // GetMySubShell / SetMySubShell: altes Verhalten simulieren,
1022 // dass es nur eine SubShell gibt (nur innerhalb der 5 eignenen SubShells)
1024 SfxShell
* ScTabViewShell::GetMySubShell() const
1026 // GetSubShell() war frueher const, und GetSubShell(sal_uInt16) sollte es auch sein...
1028 sal_uInt16 nPos
= 0;
1029 SfxShell
* pSub
= ((ScTabViewShell
*)this)->GetSubShell(nPos
);
1032 if ( pSub
== pDrawShell
|| pSub
== pDrawTextShell
|| pSub
== pEditShell
||
1033 pSub
== pPivotShell
|| pSub
== pAuditingShell
|| pSub
== pDrawFormShell
||
1034 pSub
== pCellShell
|| pSub
== pOleObjectShell
|| pSub
== pChartShell
||
1035 pSub
== pGraphicShell
|| pSub
== pMediaShell
|| pSub
== pPageBreakShell
)
1036 return pSub
; // gefunden
1038 pSub
= ((ScTabViewShell
*)this)->GetSubShell(++nPos
);
1040 return NULL
; // keine von meinen dabei
1044 bool ScTabViewShell::IsDrawTextShell() const
1046 return ( pDrawTextShell
&& ( GetMySubShell() == pDrawTextShell
) );
1049 bool ScTabViewShell::IsAuditShell() const
1051 return ( pAuditingShell
&& ( GetMySubShell() == pAuditingShell
) );
1054 void ScTabViewShell::SetDrawTextUndo( ::svl::IUndoManager
* pNewUndoMgr
)
1056 // Default: Undo-Manager der DocShell
1058 pNewUndoMgr
= GetViewData()->GetDocShell()->GetUndoManager();
1062 pDrawTextShell
->SetUndoManager(pNewUndoMgr
);
1063 ScDocShell
* pDocSh
= GetViewData()->GetDocShell();
1064 if ( pNewUndoMgr
== pDocSh
->GetUndoManager() &&
1065 !pDocSh
->GetDocument()->IsUndoEnabled() )
1067 pNewUndoMgr
->SetMaxUndoActionCount( 0 );
1072 OSL_FAIL("SetDrawTextUndo ohne DrawTextShell");
1076 ScTabViewShell
* ScTabViewShell::GetActiveViewShell()
1078 return PTR_CAST(ScTabViewShell
,Current());
1081 SfxPrinter
* ScTabViewShell::GetPrinter( bool bCreate
)
1083 // Drucker ist immer da (wird fuer die FontListe schon beim Starten angelegt)
1084 return GetViewData()->GetDocShell()->GetPrinter(bCreate
);
1087 sal_uInt16
ScTabViewShell::SetPrinter( SfxPrinter
*pNewPrinter
, sal_uInt16 nDiffFlags
, bool )
1089 return GetViewData()->GetDocShell()->SetPrinter( pNewPrinter
, nDiffFlags
);
1092 bool ScTabViewShell::HasPrintOptionsPage() const
1097 SfxTabPage
* ScTabViewShell::CreatePrintOptionsPage( Window
*pParent
, const SfxItemSet
&rOptions
)
1099 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1100 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
1101 ::CreateTabPage ScTpPrintOptionsCreate
= pFact
->GetTabPageCreatorFunc( RID_SCPAGE_PRINT
);
1102 if ( ScTpPrintOptionsCreate
)
1103 return (*ScTpPrintOptionsCreate
)( pParent
, rOptions
);
1107 void ScTabViewShell::StopEditShell()
1109 if ( pEditShell
!= NULL
&& !bDontSwitch
)
1110 SetEditShell(NULL
, false );
1113 // close handler to ensure function of dialog:
1115 IMPL_LINK_NOARG(ScTabViewShell
, SimpleRefClose
)
1117 SfxInPlaceClient
* pClient
= GetIPClient();
1118 if ( pClient
&& pClient
->IsObjectInPlaceActive() )
1120 // If range selection was started with an active embedded object,
1121 // switch back to original sheet (while the dialog is still open).
1123 SetTabNo( GetViewData()->GetRefTabNo() );
1126 ScSimpleRefDlgWrapper::SetAutoReOpen( true );
1130 // handlers to call UNO listeners:
1132 static ScTabViewObj
* lcl_GetViewObj( ScTabViewShell
& rShell
)
1134 ScTabViewObj
* pRet
= NULL
;
1135 SfxViewFrame
* pViewFrame
= rShell
.GetViewFrame();
1138 SfxFrame
& rFrame
= pViewFrame
->GetFrame();
1139 uno::Reference
<frame::XController
> xController
= rFrame
.GetController();
1140 if (xController
.is())
1141 pRet
= ScTabViewObj::getImplementation( xController
);
1146 IMPL_LINK( ScTabViewShell
, SimpleRefDone
, OUString
*, pResult
)
1148 ScTabViewObj
* pImpObj
= lcl_GetViewObj( *this );
1149 if ( pImpObj
&& pResult
)
1150 pImpObj
->RangeSelDone( *pResult
);
1154 IMPL_LINK( ScTabViewShell
, SimpleRefAborted
, OUString
*, pResult
)
1156 ScTabViewObj
* pImpObj
= lcl_GetViewObj( *this );
1157 if ( pImpObj
&& pResult
)
1158 pImpObj
->RangeSelAborted( *pResult
);
1162 IMPL_LINK( ScTabViewShell
, SimpleRefChange
, OUString
*, pResult
)
1164 ScTabViewObj
* pImpObj
= lcl_GetViewObj( *this );
1165 if ( pImpObj
&& pResult
)
1166 pImpObj
->RangeSelChanged( *pResult
);
1170 void ScTabViewShell::StartSimpleRefDialog(
1171 const OUString
& rTitle
, const OUString
& rInitVal
,
1172 bool bCloseOnButtonUp
, bool bSingleCell
, bool bMultiSelection
)
1174 SfxViewFrame
* pViewFrm
= GetViewFrame();
1176 if ( GetActiveViewShell() != this )
1178 // #i18833# / #i34499# The API method can be called for a view that's not active.
1179 // Then the view has to be activated first, the same way as in Execute for SID_CURRENTDOC.
1180 // Can't use GrabFocus here, because it needs to take effect immediately.
1182 pViewFrm
->GetFrame().Appear();
1185 sal_uInt16 nId
= ScSimpleRefDlgWrapper::GetChildWindowId();
1187 SC_MOD()->SetRefDialog( nId
, true, pViewFrm
);
1189 ScSimpleRefDlgWrapper
* pWnd
= (ScSimpleRefDlgWrapper
*)pViewFrm
->GetChildWindow( nId
);
1192 pWnd
->SetCloseHdl( LINK( this, ScTabViewShell
, SimpleRefClose
) );
1193 pWnd
->SetUnoLinks( LINK( this, ScTabViewShell
, SimpleRefDone
),
1194 LINK( this, ScTabViewShell
, SimpleRefAborted
),
1195 LINK( this, ScTabViewShell
, SimpleRefChange
) );
1196 pWnd
->SetRefString( rInitVal
);
1197 pWnd
->SetFlags( bCloseOnButtonUp
, bSingleCell
, bMultiSelection
);
1198 pWnd
->SetAutoReOpen( false );
1199 Window
* pWin
= pWnd
->GetWindow();
1200 pWin
->SetText( rTitle
);
1201 pWnd
->StartRefInput();
1205 void ScTabViewShell::StopSimpleRefDialog()
1207 SfxViewFrame
* pViewFrm
= GetViewFrame();
1208 sal_uInt16 nId
= ScSimpleRefDlgWrapper::GetChildWindowId();
1210 ScSimpleRefDlgWrapper
* pWnd
= (ScSimpleRefDlgWrapper
*)pViewFrm
->GetChildWindow( nId
);
1213 Window
* pWin
= pWnd
->GetWindow();
1214 if (pWin
&& pWin
->IsSystemWindow())
1215 ((SystemWindow
*)pWin
)->Close(); // calls abort handler
1219 bool ScTabViewShell::TabKeyInput(const KeyEvent
& rKEvt
)
1221 ScModule
* pScMod
= SC_MOD();
1223 SfxViewFrame
* pThisFrame
= GetViewFrame();
1224 if ( pThisFrame
->GetChildWindow( SID_OPENDLG_FUNCTION
) )
1227 KeyCode aCode
= rKEvt
.GetKeyCode();
1228 bool bShift
= aCode
.IsShift();
1229 bool bControl
= aCode
.IsMod1();
1230 bool bAlt
= aCode
.IsMod2();
1231 sal_uInt16 nCode
= aCode
.GetCode();
1233 bool bInPlace
= pScMod
->IsEditMode(); // Editengine bekommt alles
1234 bool bAnyEdit
= pScMod
->IsInputMode(); // nur Zeichen & Backspace
1235 bool bDraw
= IsDrawTextEdit();
1237 HideNoteMarker(); // Notiz-Anzeige
1239 // don't do extra HideCursor/ShowCursor calls if EnterHandler will switch to a different sheet
1240 bool bOnRefSheet
= ( GetViewData()->GetRefTabNo() == GetViewData()->GetTabNo() );
1241 bool bHideCursor
= ( ( nCode
== KEY_RETURN
&& bInPlace
) || nCode
== KEY_TAB
) && bOnRefSheet
;
1246 ScDocument
* pDoc
= GetViewData()->GetDocument();
1248 pDoc
->KeyInput( rKEvt
); // TimerDelays etc.
1252 bUsed
= pScMod
->InputKeyEvent( rKEvt
); // Eingabe
1254 bUsed
= SfxViewShell::KeyInput( rKEvt
); // accelerators
1258 bool bIsType
= false;
1259 sal_uInt16 nModi
= aCode
.GetModifier();
1260 sal_uInt16 nGroup
= aCode
.GetGroup();
1262 if ( nGroup
== KEYGROUP_NUM
|| nGroup
== KEYGROUP_ALPHA
|| nGroup
== 0 )
1263 if ( !bControl
&& !bAlt
)
1266 if ( nGroup
== KEYGROUP_MISC
)
1270 bIsType
= bControl
&& !bAlt
; // Control, Shift-Control-Return
1271 if ( !bIsType
&& nModi
== 0 )
1273 // Will der InputHandler auch ein einfaches Return?
1275 ScInputHandler
* pHdl
= pScMod
->GetInputHdl(this);
1276 bIsType
= pHdl
&& pHdl
->TakesReturn();
1280 bIsType
= !bControl
&& !bAlt
; // ohne Modifier oder Shift-Space
1283 bIsType
= (nModi
== 0); // nur ohne Modifier
1290 bUsed
= pScMod
->InputKeyEvent( rKEvt
); // Eingabe
1293 bUsed
= SfxViewShell::KeyInput( rKEvt
); // accelerators
1295 if ( !bUsed
&& !bIsType
&& nCode
!= KEY_RETURN
) // Eingabe nochmal hinterher
1296 bUsed
= pScMod
->InputKeyEvent( rKEvt
);
1300 // Spezialfall: Copy/Cut bei Mehrfachselektion -> Fehlermeldung
1301 // (Slot ist disabled, SfxViewShell::KeyInput wuerde also kommentarlos verschluckt)
1302 KeyFuncType eFunc
= aCode
.GetFunction();
1303 if ( eFunc
== KEYFUNC_CUT
)
1306 ScMarkType eMarkType
= GetViewData()->GetSimpleArea( aDummy
);
1307 if (eMarkType
!= SC_MARK_SIMPLE
)
1309 ErrorMessage(STR_NOMULTISELECT
);
1314 bUsed
= SfxViewShell::KeyInput( rKEvt
); // accelerators
1316 // during inplace editing, some slots are handled by the
1317 // container app and are executed during Window::KeyInput.
1318 // -> don't pass keys to input handler that would be used there
1319 // but should call slots instead.
1320 bool bParent
= ( GetViewFrame()->GetFrame().IsInPlace() && eFunc
!= KEYFUNC_DONTKNOW
);
1322 if( !bUsed
&& !bDraw
&& nCode
!= KEY_RETURN
&& !bParent
)
1323 bUsed
= pScMod
->InputKeyEvent( rKEvt
, true ); // Eingabe
1326 if (!bInPlace
&& !bUsed
&& !bDraw
)
1332 bool bNormal
= !bControl
&& !bAlt
;
1333 if ( !bAnyEdit
&& bNormal
)
1335 // je nach Optionen mit Enter in den Edit-Modus schalten
1337 const ScInputOptions
& rOpt
= pScMod
->GetInputOptions();
1338 if ( rOpt
.GetEnterEdit() )
1340 pScMod
->SetInputMode( SC_INPUT_TABLE
);
1345 bool bEditReturn
= bControl
&& !bShift
; // An Edit-Engine weiter
1346 if ( !bUsed
&& !bEditReturn
)
1351 sal_uInt8 nMode
= SC_ENTER_NORMAL
;
1352 if ( bShift
&& bControl
)
1353 nMode
= SC_ENTER_MATRIX
;
1355 nMode
= SC_ENTER_BLOCK
;
1356 pScMod
->InputEnterHandler(nMode
);
1358 if (nMode
== SC_ENTER_NORMAL
)
1361 GetViewData()->GetDispatcher().Execute( SID_CURSORENTERUP
,
1362 SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
1364 GetViewData()->GetDispatcher().Execute( SID_CURSORENTERDOWN
,
1365 SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
1368 UpdateInputHandler(true);
1373 // hier kein UpdateInputHandler, weil bei Referenzeingabe auf ein
1374 // anderes Dokument diese ViewShell nicht die ist, auf der eingegeben
1384 // Alt-Cursortasten hart codiert, weil Alt nicht konfigurierbar ist
1386 if ( !bUsed
&& bAlt
&& !bControl
)
1388 sal_uInt16 nSlotId
= 0;
1392 ModifyCellSize( DIR_TOP
, bShift
);
1396 ModifyCellSize( DIR_BOTTOM
, bShift
);
1400 ModifyCellSize( DIR_LEFT
, bShift
);
1404 ModifyCellSize( DIR_RIGHT
, bShift
);
1408 nSlotId
= bShift
? SID_CURSORPAGELEFT_SEL
: SID_CURSORPAGELEFT_
;
1411 nSlotId
= bShift
? SID_CURSORPAGERIGHT_SEL
: SID_CURSORPAGERIGHT_
;
1416 GetViewData()->GetDispatcher().Execute( nSlotId
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
1421 // use Ctrl+Alt+Shift+arrow keys to move the cursor in cells
1422 // while keeping the last selection
1423 if ( !bUsed
&& bAlt
&& bControl
&& bShift
)
1425 sal_uInt16 nSlotId
= 0;
1429 nSlotId
= SID_CURSORUP
;
1432 nSlotId
= SID_CURSORDOWN
;
1435 nSlotId
= SID_CURSORLEFT
;
1438 nSlotId
= SID_CURSORRIGHT
;
1441 nSlotId
= SID_CURSORPAGEUP
;
1444 nSlotId
= SID_CURSORPAGEDOWN
;
1447 nSlotId
= SID_CURSORHOME
;
1450 nSlotId
= SID_CURSOREND
;
1458 sal_uInt16 nMode
= GetLockedModifiers();
1459 LockModifiers(KEY_MOD1
);
1460 GetViewData()->GetDispatcher().Execute( nSlotId
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
1461 LockModifiers(nMode
);
1471 bool ScTabViewShell::SfxKeyInput(const KeyEvent
& rKeyEvent
)
1473 return SfxViewShell::KeyInput( rKeyEvent
);
1476 bool ScTabViewShell::KeyInput( const KeyEvent
&rKeyEvent
)
1478 return TabKeyInput( rKeyEvent
);
1481 #define __INIT_ScTabViewShell \
1482 eCurOST(OST_NONE), \
1484 nCtrlSfxId(USHRT_MAX), \
1485 nFormSfxId(USHRT_MAX), \
1487 pDrawTextShell(NULL), \
1489 pPivotShell(NULL), \
1490 pAuditingShell(NULL), \
1491 pDrawFormShell(NULL), \
1493 pOleObjectShell(NULL), \
1494 pChartShell(NULL), \
1495 pGraphicShell(NULL), \
1496 pMediaShell(NULL), \
1497 pPageBreakShell(NULL), \
1498 pExtrusionBarShell(NULL), \
1499 pFontworkBarShell(NULL), \
1501 pInputHandler(NULL), \
1502 pCurFrameLine(NULL), \
1504 pDialogDPObject(NULL), \
1505 pNavSettings(NULL), \
1506 bActiveDrawSh(false), \
1507 bActiveDrawTextSh(false), \
1508 bActivePivotSh(false), \
1509 bActiveAuditingSh(false), \
1510 bActiveDrawFormSh(false), \
1511 bActiveOleObjectSh(false), \
1512 bActiveChartSh(false), \
1513 bActiveGraphicSh(false), \
1514 bActiveMediaSh(false), \
1515 bActiveEditSh(false), \
1516 bFormShellAtTop(false), \
1517 bDontSwitch(false), \
1518 bInFormatDialog(false), \
1519 bPrintSelected(false), \
1521 pScSbxObject(NULL), \
1522 bChartAreaValid(false), \
1523 bForceFocusOnCurCell(false),\
1525 pAccessibilityBroadcaster(NULL), \
1529 void ScTabViewShell::Construct( sal_uInt8 nForceDesignMode
)
1531 SfxApplication
* pSfxApp
= SFX_APP();
1532 ScDocShell
* pDocSh
= GetViewData()->GetDocShell();
1533 ScDocument
* pDoc
= pDocSh
->GetDocument();
1534 bReadOnly
= pDocSh
->IsReadOnly();
1537 EnableAutoSpell(pDoc
->GetDocOptions().IsAutoSpell());
1539 SetName(OUString("View")); // fuer SBX
1540 Color
aColBlack( COL_BLACK
);
1541 SetPool( &SC_MOD()->GetPool() );
1542 SetWindow( GetActiveWin() );
1544 pCurFrameLine
= new ::editeng::SvxBorderLine(&aColBlack
, 20,
1545 table::BorderLineStyle::SOLID
);
1546 pPivotSource
= new ScArea
;
1547 StartListening(*GetViewData()->GetDocShell(),true);
1548 StartListening(*GetViewFrame(),true);
1549 StartListening(*pSfxApp
,true); // #i62045# #i62046# application is needed for Calc's own hints
1551 SfxViewFrame
* pFirst
= SfxViewFrame::GetFirst(pDocSh
);
1552 bool bFirstView
= !pFirst
1553 || (pFirst
== GetViewFrame() && !SfxViewFrame::GetNext(*pFirst
,pDocSh
));
1555 if ( pDocSh
->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED
)
1557 //TODO/LATER: is there a difference between the two GetVisArea methods?
1558 Rectangle aVisArea
= ((const SfxObjectShell
*)pDocSh
)->GetVisArea();
1560 SCTAB nVisTab
= pDoc
->GetVisibleTab();
1561 if (!pDoc
->HasTable(nVisTab
))
1564 pDoc
->SetVisibleTab(nVisTab
);
1566 SetTabNo( nVisTab
);
1567 bool bNegativePage
= pDoc
->IsNegativePage( nVisTab
);
1568 // show the right cells
1569 GetViewData()->SetScreenPos( bNegativePage
? aVisArea
.TopRight() : aVisArea
.TopLeft() );
1571 if ( GetViewFrame()->GetFrame().IsInPlace() ) // inplace
1573 pDocSh
->SetInplace( true ); // schon so initialisiert
1574 if (pDoc
->IsEmbedded())
1575 pDoc
->ResetEmbedded(); // keine blaue Markierung
1577 else if ( bFirstView
)
1579 pDocSh
->SetInplace( false );
1580 GetViewData()->RefreshZoom(); // recalculate PPT
1581 if (!pDoc
->IsEmbedded())
1582 pDoc
->SetEmbedded( pDoc
->GetVisibleTab(), aVisArea
); // VisArea markieren
1587 // jeder Task hat neuerdings sein eigenes InputWindow,
1588 // darum muesste eigentlich entweder jeder Task seinen InputHandler bekommen,
1589 // oder das InputWindow muesste sich beim App-InputHandler anmelden, wenn der
1590 // Task aktiv wird, oder das InputWindow muesste sich den InputHandler selbst
1591 // anlegen (dann immer ueber das InputWindow suchen, und nur wenn das nicht da
1592 // ist, den InputHandler von der App nehmen).
1593 // Als Sofortloesung bekommt erstmal jede View ihren Inputhandler, das gibt
1594 // nur noch Probleme, wenn zwei Views in einem Task-Fenster sind.
1596 pInputHandler
= new ScInputHandler
;
1599 // if ( !GetViewFrame()->ISA(SfxTopViewFrame) ) // OLE oder Plug-In
1600 // pInputHandler = new ScInputHandler;
1602 // FormShell vor MakeDrawView anlegen, damit die DrawView auf jeden Fall
1603 // an der FormShell angemeldet werden kann
1604 // Gepusht wird die FormShell im ersten Activate
1605 pFormShell
= new FmFormShell(this);
1606 pFormShell
->SetControlActivationHandler( LINK( this, ScTabViewShell
, FormControlActivated
) );
1608 // DrawView darf nicht im TabView - ctor angelegt werden,
1609 // wenn die ViewShell noch nicht kostruiert ist...
1610 if (pDoc
->GetDrawLayer())
1611 MakeDrawView( nForceDesignMode
);
1612 ViewOptionsHasChanged(false); // legt auch evtl. DrawView an
1614 ::svl::IUndoManager
* pMgr
= pDocSh
->GetUndoManager();
1615 SetUndoManager( pMgr
);
1616 pFormShell
->SetUndoManager( pMgr
);
1617 if ( !pDoc
->IsUndoEnabled() )
1619 pMgr
->SetMaxUndoActionCount( 0 );
1621 SetRepeatTarget( &aTarget
);
1622 pFormShell
->SetRepeatTarget( &aTarget
);
1623 SetHelpId( HID_SCSHELL_TABVWSH
);
1625 if ( bFirstView
) // first view?
1627 pDoc
->SetDocVisible( true ); // used when creating new sheets
1628 if ( pDocSh
->IsEmpty() )
1630 // set first sheet's RTL flag (following will already be initialized because of SetDocVisible)
1631 pDoc
->SetLayoutRTL( 0, ScGlobal::IsSystemRTL() );
1633 // append additional sheets (not for OLE object)
1634 if ( pDocSh
->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED
)
1636 // Get the customized initial tab count
1637 const ScDefaultsOptions
& rOpt
= SC_MOD()->GetDefaultsOptions();
1638 SCTAB nInitTabCount
= rOpt
.GetInitTabCount();
1640 for (SCTAB i
=1; i
<nInitTabCount
; i
++)
1641 pDoc
->MakeTable(i
,false);
1644 pDocSh
->SetEmpty( false ); // #i6232# make sure this is done only once
1647 // ReadExtOptions is now in Activate
1649 // Link-Update nicht verschachteln
1650 if ( pDocSh
->GetCreateMode() != SFX_CREATE_MODE_INTERNAL
&&
1651 pDocSh
->IsUpdateEnabled() ) // #105575#; update only in the first creation of the ViewShell
1653 // Check if there are any external data.
1654 bool bLink
= pDoc
->GetExternalRefManager()->hasExternalData();
1657 // #i100042# sheet links can still exist independently from external formula references
1658 SCTAB nTabCount
= pDoc
->GetTableCount();
1659 for (SCTAB i
=0; i
<nTabCount
&& !bLink
; i
++)
1660 if (pDoc
->IsLinked(i
))
1665 const sc::DocumentLinkManager
& rMgr
= pDoc
->GetDocLinkManager();
1666 if (rMgr
.hasDdeLinks() || pDoc
->HasAreaLinks())
1672 pFirst
= GetViewFrame();
1674 if(SC_MOD()->GetCurRefDlgId()==0)
1676 pFirst
->GetDispatcher()->Execute( SID_UPDATETABLINKS
,
1677 SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
1681 bool bReImport
= false; // importierte Daten aktualisieren
1682 ScDBCollection
* pDBColl
= pDoc
->GetDBCollection();
1685 const ScDBCollection::NamedDBs
& rDBs
= pDBColl
->getNamedDBs();
1686 ScDBCollection::NamedDBs::const_iterator itr
= rDBs
.begin(), itrEnd
= rDBs
.end();
1687 for (; itr
!= itrEnd
; ++itr
)
1689 if (itr
->IsStripData() && itr
->HasImportParam() && !itr
->HasImportSelection())
1699 pFirst
= GetViewFrame();
1700 if(SC_MOD()->GetCurRefDlgId()==0)
1702 pFirst
->GetDispatcher()->Execute( SID_REIMPORT_AFTER_LOAD
,
1703 SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
1709 UpdateAutoFillMark();
1711 // ScDispatchProviderInterceptor registers itself in ctor
1712 xDisProvInterceptor
= new ScDispatchProviderInterceptor( this );
1714 bFirstActivate
= true; // NavigatorUpdate aufschieben bis Activate()
1716 // #105575#; update only in the first creation of the ViewShell
1717 pDocSh
->SetUpdateEnabled(false);
1719 if ( GetViewFrame()->GetFrame().IsInPlace() )
1720 UpdateHeaderWidth(); // The implace activation requires headers to be calculated
1723 GetBorderSize( aBorder
, Size() );
1724 SetBorderPixel( aBorder
);
1730 ScTabViewShell::ScTabViewShell( SfxViewFrame
* pViewFrame
,
1731 SfxViewShell
* pOldSh
) :
1732 SfxViewShell( pViewFrame
, SFX_VIEW_CAN_PRINT
| SFX_VIEW_HAS_PRINTOPTIONS
),
1733 ScDBFunc( &pViewFrame
->GetWindow(), (ScDocShell
&)*pViewFrame
->GetObjectShell(), this ),
1734 __INIT_ScTabViewShell
1736 const ScAppOptions
& rAppOpt
= SC_MOD()->GetAppOptions();
1738 // if switching back from print preview,
1739 // restore the view settings that were active when creating the preview
1740 // ReadUserData must not happen from ctor, because the view's edit window
1741 // has to be shown by the sfx. ReadUserData is deferred until the first Activate call.
1742 // old DesignMode state from form layer must be restored, too
1744 sal_uInt8 nForceDesignMode
= SC_FORCEMODE_NONE
;
1745 if ( pOldSh
&& pOldSh
->ISA( ScPreviewShell
) )
1747 ScPreviewShell
* pPreviewShell
= ((ScPreviewShell
*)pOldSh
);
1748 nForceDesignMode
= pPreviewShell
->GetSourceDesignMode();
1749 ScPreview
* p
= pPreviewShell
->GetPreview();
1751 GetViewData()->GetMarkData().SetSelectedTabs(p
->GetSelectedTabs());
1754 Construct( nForceDesignMode
);
1756 if ( GetViewData()->GetDocShell()->IsPreview() )
1758 // preview for template dialog: always show whole page
1759 SetZoomType( SVX_ZOOM_WHOLEPAGE
, true ); // zoom value is recalculated at next Resize
1763 Fraction
aFract( rAppOpt
.GetZoom(), 100 );
1764 SetZoom( aFract
, aFract
, true );
1765 SetZoomType( rAppOpt
.GetZoomType(), true );
1768 // make Controller known to SFX
1769 new ScTabViewObj( this );
1771 SetCurSubShell(OST_Cell
);
1773 GetBorderSize( aBorder
, Size() );
1774 SetBorderPixel( aBorder
);
1780 #undef __INIT_ScTabViewShell
1782 ScTabViewShell::~ScTabViewShell()
1784 ScDocShell
* pDocSh
= GetViewData()->GetDocShell();
1785 EndListening(*pDocSh
);
1786 EndListening(*GetViewFrame());
1787 EndListening(*SFX_APP()); // #i62045# #i62046# needed now - SfxViewShell no longer does it
1789 SC_MOD()->ViewShellGone(this);
1791 RemoveSubShell(); // alle
1794 // alles auf NULL, falls aus dem TabView-dtor noch darauf zugegriffen wird
1795 //! (soll eigentlich nicht !??!?!)
1798 pInputHandler
->SetDocumentDisposing(true);
1800 DELETEZ(pFontworkBarShell
);
1801 DELETEZ(pExtrusionBarShell
);
1802 DELETEZ(pCellShell
);
1803 DELETEZ(pPageBreakShell
);
1804 DELETEZ(pDrawShell
);
1805 DELETEZ(pDrawFormShell
);
1806 DELETEZ(pOleObjectShell
);
1807 DELETEZ(pChartShell
);
1808 DELETEZ(pGraphicShell
);
1809 DELETEZ(pMediaShell
);
1810 DELETEZ(pDrawTextShell
);
1811 DELETEZ(pEditShell
);
1812 DELETEZ(pPivotShell
);
1813 DELETEZ(pAuditingShell
);
1814 DELETEZ(pCurFrameLine
);
1815 DELETEZ(pInputHandler
);
1816 DELETEZ(pPivotSource
);
1817 DELETEZ(pDialogDPObject
);
1818 DELETEZ(pNavSettings
);
1820 DELETEZ(pFormShell
);
1821 DELETEZ(pAccessibilityBroadcaster
);
1824 void ScTabViewShell::SetDialogDPObject( const ScDPObject
* pObj
)
1826 delete pDialogDPObject
;
1828 pDialogDPObject
= new ScDPObject( *pObj
);
1830 pDialogDPObject
= NULL
;
1833 void ScTabViewShell::FillFieldData( ScHeaderFieldData
& rData
)
1835 ScDocShell
* pDocShell
= GetViewData()->GetDocShell();
1836 ScDocument
* pDoc
= pDocShell
->GetDocument();
1837 SCTAB nTab
= GetViewData()->GetTabNo();
1839 pDoc
->GetName(nTab
, aTmp
);
1840 rData
.aTabName
= aTmp
;
1842 if( pDocShell
->getDocProperties()->getTitle().getLength() != 0 )
1843 rData
.aTitle
= pDocShell
->getDocProperties()->getTitle();
1845 rData
.aTitle
= pDocShell
->GetTitle();
1847 const INetURLObject
& rURLObj
= pDocShell
->GetMedium()->GetURLObject();
1848 rData
.aLongDocName
= rURLObj
.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS
);
1849 if ( !rData
.aLongDocName
.isEmpty() )
1850 rData
.aShortDocName
= rURLObj
.GetName( INetURLObject::DECODE_UNAMBIGUOUS
);
1852 rData
.aShortDocName
= rData
.aLongDocName
= rData
.aTitle
;
1854 rData
.nTotalPages
= 99;
1856 // eNumType kennt der Dialog selber
1859 void ScTabViewShell::SetChartArea( const ScRangeListRef
& rSource
, const Rectangle
& rDest
)
1861 bChartAreaValid
= true;
1862 aChartSource
= rSource
;
1864 nChartDestTab
= GetViewData()->GetTabNo();
1867 bool ScTabViewShell::GetChartArea( ScRangeListRef
& rSource
, Rectangle
& rDest
, SCTAB
& rTab
) const
1869 rSource
= aChartSource
;
1871 rTab
= nChartDestTab
;
1872 return bChartAreaValid
;
1875 ScNavigatorSettings
* ScTabViewShell::GetNavigatorSettings()
1878 pNavSettings
= new ScNavigatorSettings
;
1879 return pNavSettings
;
1883 void ScTabViewShell::ExecTbx( SfxRequest
& rReq
)
1885 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
1886 sal_uInt16 nSlot
= rReq
.GetSlot();
1887 const SfxPoolItem
* pItem
= NULL
;
1889 pReqArgs
->GetItemState( nSlot
, true, &pItem
);
1893 case SID_TBXCTL_INSERT
:
1895 nInsertCtrlState
= ((const SfxUInt16Item
*)pItem
)->GetValue();
1897 case SID_TBXCTL_INSCELLS
:
1899 nInsCellsCtrlState
= ((const SfxUInt16Item
*)pItem
)->GetValue();
1901 case SID_TBXCTL_INSOBJ
:
1903 nInsObjCtrlState
= ((const SfxUInt16Item
*)pItem
)->GetValue();
1906 OSL_FAIL("Slot im Wald");
1908 GetViewFrame()->GetBindings().Invalidate( nSlot
);
1911 void ScTabViewShell::GetTbxState( SfxItemSet
& rSet
)
1913 rSet
.Put( SfxUInt16Item( SID_TBXCTL_INSERT
, nInsertCtrlState
) );
1914 rSet
.Put( SfxUInt16Item( SID_TBXCTL_INSCELLS
, nInsCellsCtrlState
) );
1916 // ohne installiertes Chart darf Chart nicht Default sein...
1917 if ( nInsObjCtrlState
== SID_DRAW_CHART
&& !SvtModuleOptions().IsChart() )
1918 nInsObjCtrlState
= SID_INSERT_OBJECT
;
1920 rSet
.Put( SfxUInt16Item( SID_TBXCTL_INSOBJ
, nInsObjCtrlState
) );
1923 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */