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