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