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 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> 27 #include <comphelper/processfactory.hxx> 28 29 30 31 32 33 // INCLUDE --------------------------------------------------------------- 34 35 #include "scitems.hxx" 36 #include <sfx2/app.hxx> 37 #include <editeng/eeitem.hxx> 38 39 #include <editeng/flditem.hxx> 40 #include <editeng/outliner.hxx> 41 #include <basic/sbstar.hxx> 42 43 #include <sfx2/sfxdlg.hxx> 44 #include <sfx2/viewfrm.hxx> 45 #include <sfx2/objface.hxx> 46 47 #include <svx/hyprlink.hxx> 48 #include "IAnyRefDialog.hxx" 49 50 #include <svtools/ehdl.hxx> 51 #include <svtools/accessibilityoptions.hxx> 52 #include <svl/ctloptions.hxx> 53 #include <unotools/useroptions.hxx> 54 #include <vcl/status.hxx> 55 #include <sfx2/bindings.hxx> 56 #include <sfx2/request.hxx> 57 #include <sfx2/printer.hxx> 58 #include <editeng/langitem.hxx> 59 #include <svtools/colorcfg.hxx> 60 61 #include <svl/whiter.hxx> 62 #include <svx/selctrl.hxx> 63 #include <svx/insctrl.hxx> 64 #include <svx/zoomctrl.hxx> 65 #include <svx/modctrl.hxx> 66 #include <svx/pszctrl.hxx> 67 #include <svx/zoomsliderctrl.hxx> 68 #include <vcl/msgbox.hxx> 69 #include <svl/inethist.hxx> 70 #include <vcl/waitobj.hxx> 71 #include <svx/svxerr.hxx> 72 73 74 75 #include "scmod.hxx" 76 #include "global.hxx" 77 #include "viewopti.hxx" 78 #include "docoptio.hxx" 79 #include "appoptio.hxx" 80 #include "inputopt.hxx" 81 #include "printopt.hxx" 82 #include "navicfg.hxx" 83 #include "addincfg.hxx" 84 #include "tabvwsh.hxx" 85 #include "prevwsh.hxx" 86 #include "docsh.hxx" 87 #include "drwlayer.hxx" 88 #include "uiitems.hxx" 89 #include "sc.hrc" 90 #include "cfgids.hxx" 91 #include "inputhdl.hxx" 92 #include "inputwin.hxx" 93 #include "msgpool.hxx" 94 #include "scresid.hxx" 95 #include "anyrefdg.hxx" 96 #include "dwfunctr.hxx" 97 #include "formdata.hxx" 98 //CHINA001 #include "tpview.hxx" 99 //CHINA001 #include "tpusrlst.hxx" 100 //CHINA001 #include "tpcalc.hxx" 101 #include "tpprint.hxx" 102 //CHINA001 #include "opredlin.hxx" 103 #include "transobj.hxx" 104 #include "detfunc.hxx" 105 #include "preview.hxx" 106 107 #include <svx/xmlsecctrl.hxx> 108 109 110 #define ScModule 111 #include "scslots.hxx" 112 113 #include "scabstdlg.hxx" //CHINA001 114 115 #define SC_IDLE_MIN 150 116 #define SC_IDLE_MAX 3000 117 #define SC_IDLE_STEP 75 118 #define SC_IDLE_COUNT 50 119 120 static sal_uInt16 nIdleCount = 0; 121 122 //------------------------------------------------------------------ 123 124 SFX_IMPL_INTERFACE( ScModule, SfxShell, ScResId(RID_APPTITLE) ) 125 { 126 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_APPLICATION | SFX_VISIBILITY_DESKTOP | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_CLIENT | SFX_VISIBILITY_VIEWER, 127 ScResId(RID_OBJECTBAR_APP) ); 128 SFX_STATUSBAR_REGISTRATION( ScResId(SCCFG_STATUSBAR) ); // nur ID wichtig 129 SFX_CHILDWINDOW_REGISTRATION( SvxHyperlinkDlgWrapper::GetChildWindowId() ); 130 } 131 132 //------------------------------------------------------------------ 133 134 ScModule::ScModule( SfxObjectFactory* pFact ) : 135 SfxModule( SfxApplication::CreateResManager( "sc" ), sal_False, pFact, NULL ), 136 pSelTransfer( NULL ), 137 pMessagePool( NULL ), 138 pRefInputHandler( NULL ), 139 pViewCfg( NULL ), 140 pDocCfg( NULL ), 141 pAppCfg( NULL ), 142 pInputCfg( NULL ), 143 pPrintCfg( NULL ), 144 pNavipiCfg( NULL ), 145 pAddInCfg( NULL ), 146 pColorConfig( NULL ), 147 pAccessOptions( NULL ), 148 pCTLOptions( NULL ), 149 pUserOptions( NULL ), 150 pErrorHdl( NULL ), 151 pSvxErrorHdl( NULL ), 152 pFormEditData( NULL ), 153 nCurRefDlgId( 0 ), 154 bIsWaterCan( sal_False ), 155 bIsInEditCommand( sal_False ), 156 bIsInExecuteDrop( sal_False ), 157 mbIsInSharedDocLoading( false ), 158 mbIsInSharedDocSaving( false ) 159 { 160 // im ctor ist der ResManager (DLL-Daten) noch nicht initialisiert! 161 162 SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("StarCalc"))); // fuer Basic 163 164 ResetDragObject(); 165 SetClipObject( NULL, NULL ); 166 167 // InputHandler braucht nicht mehr angelegt zu werden 168 169 // ErrorHandler anlegen - war in Init() 170 // zwischen OfficeApplication::Init und ScGlobal::Init 171 SvxErrorHandler::Get(); 172 pErrorHdl = new SfxErrorHandler( RID_ERRHDLSC, 173 ERRCODE_AREA_SC, 174 ERRCODE_AREA_APP2-1, 175 GetResMgr() ); 176 177 aSpellTimer.SetTimeout(10); 178 aSpellTimer.SetTimeoutHdl( LINK( this, ScModule, SpellTimerHdl ) ); 179 aIdleTimer.SetTimeout(SC_IDLE_MIN); 180 aIdleTimer.SetTimeoutHdl( LINK( this, ScModule, IdleHandler ) ); 181 aIdleTimer.Start(); 182 183 pMessagePool = new ScMessagePool; 184 pMessagePool->FreezeIdRanges(); 185 SetPool( pMessagePool ); 186 ScGlobal::InitTextHeight( pMessagePool ); 187 188 StartListening( *SFX_APP() ); // for SFX_HINT_DEINITIALIZING 189 } 190 191 ScModule::~ScModule() 192 { 193 DBG_ASSERT( !pSelTransfer, "Selection Transfer object not deleted" ); 194 195 // InputHandler braucht nicht mehr geloescht zu werden (gibt keinen an der App mehr) 196 197 SfxItemPool::Free(pMessagePool); 198 199 DELETEZ( pFormEditData ); 200 201 delete pErrorHdl; 202 // delete pSvxErrorHdl; 203 204 ScGlobal::Clear(); // ruft auch ScDocumentPool::DeleteVersionMaps(); 205 206 DeleteCfg(); // wurde mal aus Exit() gerufen 207 } 208 209 //------------------------------------------------------------------ 210 void ScModule::ConfigurationChanged( utl::ConfigurationBroadcaster* p, sal_uInt32 ) 211 { 212 if ( p == pColorConfig || p == pAccessOptions ) 213 { 214 // Test if detective objects have to be updated with new colors 215 // (if the detective colors haven't been used yet, there's nothing to update) 216 if ( ScDetectiveFunc::IsColorsInitialized() ) 217 { 218 const svtools::ColorConfig& rColors = GetColorConfig(); 219 sal_Bool bArrows = 220 ( ScDetectiveFunc::GetArrowColor() != (ColorData)rColors.GetColorValue(svtools::CALCDETECTIVE).nColor || 221 ScDetectiveFunc::GetErrorColor() != (ColorData)rColors.GetColorValue(svtools::CALCDETECTIVEERROR).nColor ); 222 sal_Bool bComments = 223 ( ScDetectiveFunc::GetCommentColor() != (ColorData)rColors.GetColorValue(svtools::CALCNOTESBACKGROUND).nColor ); 224 if ( bArrows || bComments ) 225 { 226 ScDetectiveFunc::InitializeColors(); // get the new colors 227 228 // update detective objects in all open documents 229 SfxObjectShell* pObjSh = SfxObjectShell::GetFirst(); 230 while ( pObjSh ) 231 { 232 if ( pObjSh->Type() == TYPE(ScDocShell) ) 233 { 234 ScDocShell* pDocSh = ((ScDocShell*)pObjSh); 235 if ( bArrows ) 236 ScDetectiveFunc( pDocSh->GetDocument(), 0 ).UpdateAllArrowColors(); 237 if ( bComments ) 238 ScDetectiveFunc::UpdateAllComments( *pDocSh->GetDocument() ); 239 } 240 pObjSh = SfxObjectShell::GetNext( *pObjSh ); 241 } 242 } 243 } 244 245 // force all views to repaint, using the new options 246 247 SfxViewShell* pViewShell = SfxViewShell::GetFirst(); 248 while(pViewShell) 249 { 250 if ( pViewShell->ISA(ScTabViewShell) ) 251 { 252 ScTabViewShell* pViewSh = (ScTabViewShell*)pViewShell; 253 pViewSh->PaintGrid(); 254 pViewSh->PaintTop(); 255 pViewSh->PaintLeft(); 256 pViewSh->PaintExtras(); 257 258 ScInputHandler* pHdl = pViewSh->GetInputHandler(); 259 if ( pHdl ) 260 pHdl->ForgetLastPattern(); // EditEngine BackgroundColor may change 261 } 262 else if ( pViewShell->ISA(ScPreviewShell) ) 263 { 264 Window* pWin = pViewShell->GetWindow(); 265 if (pWin) 266 pWin->Invalidate(); 267 } 268 pViewShell = SfxViewShell::GetNext( *pViewShell ); 269 } 270 } 271 else if ( p == pCTLOptions ) 272 { 273 // for all documents: set digit language for printer, recalc output factor, update row heights 274 SfxObjectShell* pObjSh = SfxObjectShell::GetFirst(); 275 while ( pObjSh ) 276 { 277 if ( pObjSh->Type() == TYPE(ScDocShell) ) 278 { 279 ScDocShell* pDocSh = ((ScDocShell*)pObjSh); 280 OutputDevice* pPrinter = pDocSh->GetPrinter(); 281 if ( pPrinter ) 282 pPrinter->SetDigitLanguage( GetOptDigitLanguage() ); 283 284 pDocSh->CalcOutputFactor(); 285 286 SCTAB nTabCount = pDocSh->GetDocument()->GetTableCount(); 287 for (SCTAB nTab=0; nTab<nTabCount; nTab++) 288 pDocSh->AdjustRowHeight( 0, MAXROW, nTab ); 289 } 290 pObjSh = SfxObjectShell::GetNext( *pObjSh ); 291 } 292 293 // for all views (table and preview): update digit language 294 SfxViewShell* pSh = SfxViewShell::GetFirst(); 295 while ( pSh ) 296 { 297 if ( pSh->ISA( ScTabViewShell ) ) 298 { 299 ScTabViewShell* pViewSh = (ScTabViewShell*)pSh; 300 301 // set ref-device for EditEngine (re-evaluates digit settings) 302 ScInputHandler* pHdl = GetInputHdl(pViewSh); 303 if (pHdl) 304 pHdl->UpdateRefDevice(); 305 306 pViewSh->DigitLanguageChanged(); 307 pViewSh->PaintGrid(); 308 } 309 else if ( pSh->ISA( ScPreviewShell ) ) 310 { 311 ScPreviewShell* pPreviewSh = (ScPreviewShell*)pSh; 312 ScPreview* pPreview = pPreviewSh->GetPreview(); 313 314 pPreview->SetDigitLanguage( GetOptDigitLanguage() ); 315 pPreview->Invalidate(); 316 } 317 318 pSh = SfxViewShell::GetNext( *pSh ); 319 } 320 } 321 } 322 323 void ScModule::Notify( SfxBroadcaster&, const SfxHint& rHint ) 324 { 325 if ( rHint.ISA(SfxSimpleHint) ) 326 { 327 sal_uLong nHintId = ((SfxSimpleHint&)rHint).GetId(); 328 if ( nHintId == SFX_HINT_DEINITIALIZING ) 329 { 330 // ConfigItems must be removed before ConfigManager 331 DeleteCfg(); 332 } 333 } 334 } 335 336 //------------------------------------------------------------------ 337 338 void ScModule::DeleteCfg() 339 { 340 DELETEZ( pViewCfg ); // Speichern passiert vor Exit() automatisch 341 DELETEZ( pDocCfg ); 342 DELETEZ( pAppCfg ); 343 DELETEZ( pInputCfg ); 344 DELETEZ( pPrintCfg ); 345 DELETEZ( pNavipiCfg ); 346 DELETEZ( pAddInCfg ); 347 348 if ( pColorConfig ) 349 { 350 pColorConfig->RemoveListener(this); 351 DELETEZ( pColorConfig ); 352 } 353 if ( pAccessOptions ) 354 { 355 pAccessOptions->RemoveListener(this); 356 DELETEZ( pAccessOptions ); 357 } 358 if ( pCTLOptions ) 359 { 360 pCTLOptions->RemoveListener(this); 361 DELETEZ( pCTLOptions ); 362 } 363 if( pUserOptions ) 364 { 365 DELETEZ( pUserOptions ); 366 } 367 } 368 369 //------------------------------------------------------------------ 370 // 371 // von der Applikation verschoben: 372 // 373 //------------------------------------------------------------------ 374 375 void ScModule::Execute( SfxRequest& rReq ) 376 { 377 SfxViewFrame* pViewFrm = SfxViewFrame::Current(); 378 SfxBindings* pBindings = pViewFrm ? &pViewFrm->GetBindings() : NULL; 379 380 const SfxItemSet* pReqArgs = rReq.GetArgs(); 381 sal_uInt16 nSlot = rReq.GetSlot(); 382 383 switch ( nSlot ) 384 { 385 case SID_CHOOSE_DESIGN: 386 { 387 String aMacroName = 388 String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Template.Samples.ShowStyles")); 389 SfxApplication::CallAppBasic( aMacroName ); 390 } 391 break; 392 case SID_EURO_CONVERTER: 393 { 394 String aMacroName = 395 String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Euro.ConvertRun.Main")); 396 SfxApplication::CallAppBasic( aMacroName ); 397 } 398 break; 399 case SID_AUTOSPELL_CHECK: 400 { 401 sal_Bool bSet; 402 const SfxPoolItem* pItem; 403 if ( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( nSlot, sal_True, &pItem ) ) 404 bSet = ((const SfxBoolItem*)pItem)->GetValue(); 405 else 406 { // Toggle 407 ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current()); 408 if ( pDocSh ) 409 bSet = !pDocSh->GetDocument()->GetDocOptions().IsAutoSpell(); 410 else 411 bSet = !GetDocOptions().IsAutoSpell(); 412 } 413 414 SfxItemSet aSet( GetPool(), SID_AUTOSPELL_CHECK, SID_AUTOSPELL_CHECK ); 415 aSet.Put( SfxBoolItem( SID_AUTOSPELL_CHECK, bSet ) ); 416 ModifyOptions( aSet ); 417 rReq.Done(); 418 } 419 break; 420 421 case SID_ATTR_METRIC: 422 { 423 const SfxPoolItem* pItem; 424 if ( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( nSlot, sal_True, &pItem ) ) 425 { 426 FieldUnit eUnit = (FieldUnit)((const SfxUInt16Item*)pItem)->GetValue(); 427 switch( eUnit ) 428 { 429 case FUNIT_MM: // nur die Einheiten, die auch im Dialog stehen 430 case FUNIT_CM: 431 case FUNIT_INCH: 432 case FUNIT_PICA: 433 case FUNIT_POINT: 434 { 435 PutItem( *pItem ); 436 ScAppOptions aNewOpts( GetAppOptions() ); 437 aNewOpts.SetAppMetric( eUnit ); 438 SetAppOptions( aNewOpts ); 439 rReq.Done(); 440 } 441 break; 442 default: 443 { 444 // added to avoid warnings 445 } 446 } 447 } 448 } 449 break; 450 451 case FID_AUTOCOMPLETE: 452 { 453 ScAppOptions aNewOpts( GetAppOptions() ); 454 sal_Bool bNew = !aNewOpts.GetAutoComplete(); 455 aNewOpts.SetAutoComplete( bNew ); 456 SetAppOptions( aNewOpts ); 457 ScInputHandler::SetAutoComplete( bNew ); 458 if (pBindings) 459 pBindings->Invalidate( FID_AUTOCOMPLETE ); 460 rReq.Done(); 461 } 462 break; 463 464 case SID_DETECTIVE_AUTO: 465 { 466 ScAppOptions aNewOpts( GetAppOptions() ); 467 sal_Bool bNew = !aNewOpts.GetDetectiveAuto(); 468 SFX_REQUEST_ARG( rReq, pAuto, SfxBoolItem, SID_DETECTIVE_AUTO, sal_False ); 469 if ( pAuto ) 470 bNew = pAuto->GetValue(); 471 472 aNewOpts.SetDetectiveAuto( bNew ); 473 SetAppOptions( aNewOpts ); 474 if (pBindings) 475 pBindings->Invalidate( SID_DETECTIVE_AUTO ); 476 rReq.AppendItem( SfxBoolItem( SID_DETECTIVE_AUTO, bNew ) ); 477 rReq.Done(); 478 } 479 break; 480 481 case SID_PSZ_FUNCTION: 482 if (pReqArgs) 483 { 484 const SfxUInt16Item& rItem = (const SfxUInt16Item&)pReqArgs->Get(SID_PSZ_FUNCTION); 485 DBG_ASSERT(rItem.ISA(SfxUInt16Item),"falscher Parameter"); 486 487 ScAppOptions aNewOpts( GetAppOptions() ); 488 aNewOpts.SetStatusFunc( rItem.GetValue() ); 489 SetAppOptions( aNewOpts ); 490 491 if (pBindings) 492 { 493 pBindings->Invalidate( SID_TABLE_CELL ); 494 pBindings->Update( SID_TABLE_CELL ); // sofort 495 496 pBindings->Invalidate( SID_PSZ_FUNCTION ); 497 pBindings->Update( SID_PSZ_FUNCTION ); 498 // falls Menue gleich wieder aufgeklappt wird 499 } 500 } 501 break; 502 503 case SID_ATTR_LANGUAGE: 504 case SID_ATTR_CHAR_CJK_LANGUAGE: 505 case SID_ATTR_CHAR_CTL_LANGUAGE: 506 { 507 const SfxPoolItem* pItem; 508 if ( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( GetPool().GetWhich(nSlot), sal_True, &pItem ) ) 509 { 510 ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current()); 511 ScDocument* pDoc = pDocSh ? pDocSh->GetDocument() : NULL; 512 if ( pDoc ) 513 { 514 LanguageType eNewLang = ((SvxLanguageItem*)pItem)->GetLanguage(); 515 LanguageType eLatin, eCjk, eCtl; 516 pDoc->GetLanguage( eLatin, eCjk, eCtl ); 517 LanguageType eOld = ( nSlot == SID_ATTR_CHAR_CJK_LANGUAGE ) ? eCjk : 518 ( ( nSlot == SID_ATTR_CHAR_CTL_LANGUAGE ) ? eCtl : eLatin ); 519 if ( eNewLang != eOld ) 520 { 521 if ( nSlot == SID_ATTR_CHAR_CJK_LANGUAGE ) 522 eCjk = eNewLang; 523 else if ( nSlot == SID_ATTR_CHAR_CTL_LANGUAGE ) 524 eCtl = eNewLang; 525 else 526 eLatin = eNewLang; 527 528 pDoc->SetLanguage( eLatin, eCjk, eCtl ); 529 530 ScInputHandler* pInputHandler = GetInputHdl(); 531 if ( pInputHandler ) 532 pInputHandler->UpdateSpellSettings(); // EditEngine-Flags 533 ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell, SfxViewShell::Current()); 534 if ( pViewSh ) 535 pViewSh->UpdateDrawTextOutliner(); // EditEngine-Flags 536 537 pDocSh->SetDocumentModified(); 538 } 539 } 540 } 541 } 542 break; 543 544 case FID_FOCUS_POSWND: 545 { 546 ScInputHandler* pHdl = GetInputHdl(); 547 if (pHdl) 548 { 549 ScInputWindow* pWin = pHdl->GetInputWindow(); 550 if (pWin) 551 pWin->PosGrabFocus(); 552 } 553 rReq.Done(); 554 } 555 break; 556 557 case SID_OPEN_XML_FILTERSETTINGS: 558 { 559 try 560 { 561 com::sun::star::uno::Reference < ::com::sun::star::ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), com::sun::star::uno::UNO_QUERY); 562 if( xDialog.is() ) 563 { 564 xDialog->execute(); 565 } 566 } 567 catch( ::com::sun::star::uno::RuntimeException& ) 568 { 569 } 570 } 571 break; 572 573 default: 574 DBG_ERROR( "ScApplication: Unknown Message." ); 575 break; 576 } 577 } 578 579 void ScModule::GetState( SfxItemSet& rSet ) 580 { 581 SfxWhichIter aIter(rSet); 582 sal_uInt16 nWhich = aIter.FirstWhich(); 583 while ( nWhich ) 584 { 585 switch ( nWhich ) 586 { 587 case FID_AUTOCOMPLETE: 588 rSet.Put( SfxBoolItem( nWhich, GetAppOptions().GetAutoComplete() ) ); 589 break; 590 case SID_DETECTIVE_AUTO: 591 rSet.Put( SfxBoolItem( nWhich, GetAppOptions().GetDetectiveAuto() ) ); 592 break; 593 case SID_PSZ_FUNCTION: 594 rSet.Put( SfxUInt16Item( nWhich, GetAppOptions().GetStatusFunc() ) ); 595 break; 596 case SID_ATTR_METRIC: 597 rSet.Put( SfxUInt16Item( nWhich, sal::static_int_cast<sal_uInt16>(GetAppOptions().GetAppMetric()) ) ); 598 break; 599 case SID_AUTOSPELL_CHECK: 600 { 601 sal_Bool bAuto; 602 ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current()); 603 if ( pDocSh ) 604 bAuto = pDocSh->GetDocument()->GetDocOptions().IsAutoSpell(); 605 else 606 { 607 sal_uInt16 nDummyLang, nDummyCjk, nDummyCtl; 608 GetSpellSettings( nDummyLang, nDummyCjk, nDummyCtl, bAuto ); 609 } 610 rSet.Put( SfxBoolItem( nWhich, bAuto ) ); 611 } 612 break; 613 case SID_ATTR_LANGUAGE: 614 case ATTR_CJK_FONT_LANGUAGE: // WID for SID_ATTR_CHAR_CJK_LANGUAGE 615 case ATTR_CTL_FONT_LANGUAGE: // WID for SID_ATTR_CHAR_CTL_LANGUAGE 616 { 617 ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current()); 618 ScDocument* pDoc = pDocSh ? pDocSh->GetDocument() : NULL; 619 if ( pDoc ) 620 { 621 LanguageType eLatin, eCjk, eCtl; 622 pDoc->GetLanguage( eLatin, eCjk, eCtl ); 623 LanguageType eLang = ( nWhich == ATTR_CJK_FONT_LANGUAGE ) ? eCjk : 624 ( ( nWhich == ATTR_CTL_FONT_LANGUAGE ) ? eCtl : eLatin ); 625 rSet.Put( SvxLanguageItem( eLang, nWhich ) ); 626 } 627 } 628 break; 629 630 } 631 nWhich = aIter.NextWhich(); 632 } 633 } 634 635 636 void ScModule::HideDisabledSlots( SfxItemSet& rSet ) 637 { 638 if( SfxViewFrame* pViewFrm = SfxViewFrame::Current() ) 639 { 640 SfxBindings& rBindings = pViewFrm->GetBindings(); 641 SfxWhichIter aIter( rSet ); 642 for( sal_uInt16 nWhich = aIter.FirstWhich(); nWhich != 0; nWhich = aIter.NextWhich() ) 643 { 644 ScViewUtil::HideDisabledSlot( rSet, rBindings, nWhich ); 645 // always disable the slots 646 rSet.DisableItem( nWhich ); 647 } 648 } 649 } 650 651 652 //------------------------------------------------------------------ 653 654 void ScModule::ResetDragObject() 655 { 656 aDragData.pCellTransfer = NULL; 657 aDragData.pDrawTransfer = NULL; 658 659 aDragData.aLinkDoc.Erase(); 660 aDragData.aLinkTable.Erase(); 661 aDragData.aLinkArea.Erase(); 662 aDragData.pJumpLocalDoc = NULL; 663 aDragData.aJumpTarget.Erase(); 664 aDragData.aJumpText.Erase(); 665 } 666 667 void ScModule::SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj ) 668 { 669 ResetDragObject(); 670 aDragData.pCellTransfer = pCellObj; 671 aDragData.pDrawTransfer = pDrawObj; 672 } 673 674 void ScModule::SetDragLink( const String& rDoc, const String& rTab, const String& rArea ) 675 { 676 ResetDragObject(); 677 678 aDragData.aLinkDoc = rDoc; 679 aDragData.aLinkTable = rTab; 680 aDragData.aLinkArea = rArea; 681 } 682 683 void ScModule::SetDragJump( ScDocument* pLocalDoc, const String& rTarget, const String& rText ) 684 { 685 ResetDragObject(); 686 687 aDragData.pJumpLocalDoc = pLocalDoc; 688 aDragData.aJumpTarget = rTarget; 689 aDragData.aJumpText = rText; 690 } 691 692 //------------------------------------------------------------------ 693 694 void ScModule::SetClipObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj ) 695 { 696 DBG_ASSERT( !pCellObj || !pDrawObj, "SetClipObject: not allowed to set both objects" ); 697 698 aClipData.pCellClipboard = pCellObj; 699 aClipData.pDrawClipboard = pDrawObj; 700 } 701 702 ScDocument* ScModule::GetClipDoc() 703 { 704 // called from document 705 706 ScTransferObj* pObj = ScTransferObj::GetOwnClipboard( NULL ); 707 if (pObj) 708 return pObj->GetDocument(); 709 710 return NULL; 711 } 712 713 //------------------------------------------------------------------ 714 715 void ScModule::SetSelectionTransfer( ScSelectionTransferObj* pNew ) 716 { 717 pSelTransfer = pNew; 718 } 719 720 //------------------------------------------------------------------ 721 722 void ScModule::InitFormEditData() 723 { 724 pFormEditData = new ScFormEditData; 725 } 726 727 void ScModule::ClearFormEditData() 728 { 729 DELETEZ( pFormEditData ); 730 } 731 732 //------------------------------------------------------------------ 733 734 void ScModule::SetViewOptions( const ScViewOptions& rOpt ) 735 { 736 if ( !pViewCfg ) 737 pViewCfg = new ScViewCfg; 738 739 pViewCfg->SetOptions( rOpt ); 740 } 741 742 const ScViewOptions& ScModule::GetViewOptions() 743 { 744 if ( !pViewCfg ) 745 pViewCfg = new ScViewCfg; 746 747 return *pViewCfg; 748 } 749 750 void ScModule::SetDocOptions( const ScDocOptions& rOpt ) 751 { 752 if ( !pDocCfg ) 753 pDocCfg = new ScDocCfg; 754 755 pDocCfg->SetOptions( rOpt ); 756 } 757 758 const ScDocOptions& ScModule::GetDocOptions() 759 { 760 if ( !pDocCfg ) 761 pDocCfg = new ScDocCfg; 762 763 return *pDocCfg; 764 } 765 766 #ifndef LRU_MAX 767 #define LRU_MAX 10 768 #endif 769 770 void ScModule::InsertEntryToLRUList(sal_uInt16 nFIndex) 771 { 772 if(nFIndex != 0) 773 { 774 const ScAppOptions& rAppOpt = GetAppOptions(); 775 sal_uInt16 nLRUFuncCount = Min( rAppOpt.GetLRUFuncListCount(), (sal_uInt16)LRU_MAX ); 776 sal_uInt16* pLRUListIds = rAppOpt.GetLRUFuncList(); 777 778 sal_uInt16 aIdxList[LRU_MAX]; 779 sal_uInt16 n = 0; 780 sal_Bool bFound = sal_False; 781 782 while ((n < LRU_MAX) && n<nLRUFuncCount) // alte Liste abklappern 783 { 784 if (!bFound && (pLRUListIds[n]== nFIndex)) 785 bFound = sal_True; // erster! Treffer 786 else if (bFound) 787 aIdxList[n ] = pLRUListIds[n]; // hinter Treffer kopieren 788 else if ((n+1) < LRU_MAX) 789 aIdxList[n+1] = pLRUListIds[n]; // vor Treffer verschieben 790 n++; 791 } 792 if (!bFound && (n < LRU_MAX)) // Eintrag nicht gefunden? 793 n++; // einen mehr 794 aIdxList[0] = nFIndex; // Current on Top 795 796 ScAppOptions aNewOpts(rAppOpt); // an App melden 797 aNewOpts.SetLRUFuncList(aIdxList, n); 798 SetAppOptions(aNewOpts); 799 800 RecentFunctionsChanged(); 801 } 802 } 803 804 void ScModule::RecentFunctionsChanged() 805 { 806 // update function list window 807 sal_uInt16 nFuncListID = ScFunctionChildWindow::GetChildWindowId(); 808 809 //! notify all views 810 SfxViewFrame* pViewFrm = SfxViewFrame::Current(); 811 if ( pViewFrm && pViewFrm->HasChildWindow(nFuncListID) ) 812 { 813 ScFunctionChildWindow* pWnd =(ScFunctionChildWindow*)pViewFrm->GetChildWindow( nFuncListID ); 814 815 ScFunctionDockWin* pFuncList=(ScFunctionDockWin*)pWnd->GetWindow(); 816 817 pFuncList->InitLRUList(); 818 } 819 } 820 821 void ScModule::SetAppOptions( const ScAppOptions& rOpt ) 822 { 823 if ( !pAppCfg ) 824 pAppCfg = new ScAppCfg; 825 826 pAppCfg->SetOptions( rOpt ); 827 } 828 829 void global_InitAppOptions() 830 { 831 SC_MOD()->GetAppOptions(); 832 } 833 834 const ScAppOptions& ScModule::GetAppOptions() 835 { 836 if ( !pAppCfg ) 837 pAppCfg = new ScAppCfg; 838 839 return *pAppCfg; 840 } 841 842 void ScModule::SetInputOptions( const ScInputOptions& rOpt ) 843 { 844 if ( !pInputCfg ) 845 pInputCfg = new ScInputCfg; 846 847 pInputCfg->SetOptions( rOpt ); 848 } 849 850 const ScInputOptions& ScModule::GetInputOptions() 851 { 852 if ( !pInputCfg ) 853 pInputCfg = new ScInputCfg; 854 855 return *pInputCfg; 856 } 857 858 void ScModule::SetPrintOptions( const ScPrintOptions& rOpt ) 859 { 860 if ( !pPrintCfg ) 861 pPrintCfg = new ScPrintCfg; 862 863 pPrintCfg->SetOptions( rOpt ); 864 } 865 866 const ScPrintOptions& ScModule::GetPrintOptions() 867 { 868 if ( !pPrintCfg ) 869 pPrintCfg = new ScPrintCfg; 870 871 return *pPrintCfg; 872 } 873 874 ScNavipiCfg& ScModule::GetNavipiCfg() 875 { 876 if ( !pNavipiCfg ) 877 pNavipiCfg = new ScNavipiCfg; 878 879 return *pNavipiCfg; 880 } 881 882 ScAddInCfg& ScModule::GetAddInCfg() 883 { 884 if ( !pAddInCfg ) 885 pAddInCfg = new ScAddInCfg; 886 887 return *pAddInCfg; 888 } 889 890 svtools::ColorConfig& ScModule::GetColorConfig() 891 { 892 if ( !pColorConfig ) 893 { 894 pColorConfig = new svtools::ColorConfig; 895 pColorConfig->AddListener(this); 896 } 897 898 return *pColorConfig; 899 } 900 901 SvtAccessibilityOptions& ScModule::GetAccessOptions() 902 { 903 if ( !pAccessOptions ) 904 { 905 pAccessOptions = new SvtAccessibilityOptions; 906 pAccessOptions->AddListener(this); 907 } 908 909 return *pAccessOptions; 910 } 911 912 SvtCTLOptions& ScModule::GetCTLOptions() 913 { 914 if ( !pCTLOptions ) 915 { 916 pCTLOptions = new SvtCTLOptions; 917 pCTLOptions->AddListener(this); 918 } 919 920 return *pCTLOptions; 921 } 922 923 SvtUserOptions& ScModule::GetUserOptions() 924 { 925 if( !pUserOptions ) 926 { 927 pUserOptions = new SvtUserOptions; 928 } 929 return *pUserOptions; 930 } 931 932 sal_uInt16 ScModule::GetOptDigitLanguage() 933 { 934 SvtCTLOptions::TextNumerals eNumerals = GetCTLOptions().GetCTLTextNumerals(); 935 return ( eNumerals == SvtCTLOptions::NUMERALS_ARABIC ) ? LANGUAGE_ENGLISH_US : 936 ( eNumerals == SvtCTLOptions::NUMERALS_HINDI) ? LANGUAGE_ARABIC_SAUDI_ARABIA : 937 LANGUAGE_SYSTEM; 938 } 939 940 //------------------------------------------------------------------ 941 // 942 // Optionen 943 // 944 //------------------------------------------------------------------ 945 946 // 947 // ModifyOptions - Items aus Calc-Options-Dialog 948 // und SID_AUTOSPELL_CHECK 949 // 950 951 #define IS_AVAILABLE(w,item) (SFX_ITEM_SET==rOptSet.GetItemState((w),sal_True,&item)) 952 953 void ScModule::ModifyOptions( const SfxItemSet& rOptSet ) 954 { 955 sal_uInt16 nOldSpellLang, nOldCjkLang, nOldCtlLang; 956 sal_Bool bOldAutoSpell; 957 GetSpellSettings( nOldSpellLang, nOldCjkLang, nOldCtlLang, bOldAutoSpell ); 958 959 if (!pAppCfg) 960 GetAppOptions(); 961 DBG_ASSERT( pAppCfg, "AppOptions not initialised :-(" ); 962 963 if (!pInputCfg) 964 GetInputOptions(); 965 DBG_ASSERT( pInputCfg, "InputOptions not initialised :-(" ); 966 967 //-------------------------------------------------------------- 968 969 SfxViewFrame* pViewFrm = SfxViewFrame::Current(); 970 SfxBindings* pBindings = pViewFrm ? &pViewFrm->GetBindings() : NULL; 971 972 ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell, SfxViewShell::Current()); 973 ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current()); 974 ScDocument* pDoc = pDocSh ? pDocSh->GetDocument() : NULL; 975 const SfxPoolItem* pItem = NULL; 976 sal_Bool bRepaint = sal_False; 977 sal_Bool bUpdateMarks = sal_False; 978 sal_Bool bUpdateRefDev = sal_False; 979 sal_Bool bCalcAll = sal_False; 980 sal_Bool bSaveSpellCheck = sal_False; 981 sal_Bool bSaveAppOptions = sal_False; 982 sal_Bool bSaveInputOptions = sal_False; 983 984 //-------------------------------------------------------------------------- 985 986 // SFX_APP()->SetOptions( rOptSet ); 987 988 // Linguistik nicht mehr 989 990 if ( IS_AVAILABLE(SID_ATTR_METRIC,pItem) ) 991 { 992 PutItem( *pItem ); 993 pAppCfg->SetAppMetric( (FieldUnit)((const SfxUInt16Item*)pItem)->GetValue() ); 994 bSaveAppOptions = sal_True; 995 } 996 997 if ( IS_AVAILABLE(SCITEM_USERLIST,pItem) ) 998 { 999 ScGlobal::SetUserList( ((const ScUserListItem*)pItem)->GetUserList() ); 1000 bSaveAppOptions = sal_True; 1001 } 1002 1003 if ( IS_AVAILABLE(SID_SC_OPT_SYNCZOOM,pItem) ) 1004 { 1005 pAppCfg->SetSynchronizeZoom( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); 1006 bSaveAppOptions = sal_True; 1007 } 1008 1009 //============================================ 1010 // ViewOptions 1011 //============================================ 1012 1013 if ( IS_AVAILABLE(SID_SCVIEWOPTIONS,pItem) ) 1014 { 1015 const ScViewOptions& rNewOpt = ((const ScTpViewItem*)pItem)->GetViewOptions(); 1016 1017 if ( pViewSh ) 1018 { 1019 ScViewData* pViewData = pViewSh->GetViewData(); 1020 const ScViewOptions& rOldOpt = pViewData->GetOptions(); 1021 1022 sal_Bool bAnchorList = ( rOldOpt.GetOption( VOPT_ANCHOR ) != 1023 rNewOpt.GetOption( VOPT_ANCHOR ) ); 1024 1025 if ( rOldOpt != rNewOpt ) 1026 { 1027 pViewData->SetOptions( rNewOpt ); // veraendert rOldOpt 1028 pViewData->GetDocument()->SetViewOptions( rNewOpt ); 1029 pDocSh->SetDocumentModified(); 1030 bRepaint = sal_True; 1031 } 1032 if ( bAnchorList ) 1033 pViewSh->UpdateAnchorHandles(); 1034 } 1035 SetViewOptions( rNewOpt ); 1036 if (pBindings) 1037 pBindings->Invalidate(SID_HELPLINES_MOVE); 1038 } 1039 1040 //============================================ 1041 // GridOptions, Auswertung nach ViewOptions, 1042 // da GridOptions Member der ViewOptions ist! 1043 //============================================ 1044 1045 if ( IS_AVAILABLE(SID_ATTR_GRID_OPTIONS,pItem) ) 1046 { 1047 ScGridOptions aNewGridOpt( (const SvxOptionsGrid&)((const SvxGridItem&)*pItem) ); 1048 1049 if ( pViewSh ) 1050 { 1051 ScViewData* pViewData = pViewSh->GetViewData(); 1052 ScViewOptions aNewViewOpt( pViewData->GetOptions() ); 1053 const ScGridOptions& rOldGridOpt = aNewViewOpt.GetGridOptions(); 1054 1055 if ( rOldGridOpt != aNewGridOpt ) 1056 { 1057 aNewViewOpt.SetGridOptions( aNewGridOpt ); 1058 pViewData->SetOptions( aNewViewOpt ); 1059 pViewData->GetDocument()->SetViewOptions( aNewViewOpt ); 1060 pDocSh->SetDocumentModified(); 1061 bRepaint = sal_True; 1062 } 1063 } 1064 ScViewOptions aNewViewOpt ( GetViewOptions() ); 1065 aNewViewOpt.SetGridOptions( aNewGridOpt ); 1066 SetViewOptions( aNewViewOpt ); 1067 if (pBindings) 1068 { 1069 pBindings->Invalidate(SID_GRID_VISIBLE); 1070 pBindings->Invalidate(SID_GRID_USE); 1071 } 1072 } 1073 1074 1075 //============================================ 1076 // DocOptions 1077 //============================================ 1078 1079 if ( IS_AVAILABLE(SID_SCDOCOPTIONS,pItem) ) 1080 { 1081 const ScDocOptions& rNewOpt = ((const ScTpCalcItem*)pItem)->GetDocOptions(); 1082 1083 if ( pDoc ) 1084 { 1085 const ScDocOptions& rOldOpt = pDoc->GetDocOptions(); 1086 1087 bRepaint = ( bRepaint || ( rOldOpt != rNewOpt ) ); 1088 bCalcAll = bRepaint && 1089 ( rOldOpt.IsIter() != rNewOpt.IsIter() 1090 || rOldOpt.GetIterCount() != rNewOpt.GetIterCount() 1091 || rOldOpt.GetIterEps() != rNewOpt.GetIterEps() 1092 || rOldOpt.IsIgnoreCase() != rNewOpt.IsIgnoreCase() 1093 || rOldOpt.IsCalcAsShown() != rNewOpt.IsCalcAsShown() 1094 || (rNewOpt.IsCalcAsShown() && 1095 rOldOpt.GetStdPrecision() != rNewOpt.GetStdPrecision()) 1096 || rOldOpt.IsMatchWholeCell() != rNewOpt.IsMatchWholeCell() 1097 || rOldOpt.GetYear2000() != rNewOpt.GetYear2000() 1098 || rOldOpt.IsFormulaRegexEnabled() != rNewOpt.IsFormulaRegexEnabled() 1099 ); 1100 pDoc->SetDocOptions( rNewOpt ); 1101 pDocSh->SetDocumentModified(); 1102 } 1103 SetDocOptions( rNewOpt ); 1104 } 1105 1106 // nach den eigentlichen DocOptions auch noch die TabDistance setzen 1107 if ( IS_AVAILABLE(SID_ATTR_DEFTABSTOP,pItem) ) 1108 { 1109 sal_uInt16 nTabDist = ((SfxUInt16Item*)pItem)->GetValue(); 1110 ScDocOptions aOpt(GetDocOptions()); 1111 aOpt.SetTabDistance(nTabDist); 1112 SetDocOptions( aOpt ); 1113 1114 if ( pDoc ) 1115 { 1116 ScDocOptions aDocOpt(pDoc->GetDocOptions()); 1117 aDocOpt.SetTabDistance(nTabDist); 1118 pDoc->SetDocOptions( aDocOpt ); 1119 pDocSh->SetDocumentModified(); 1120 if(pDoc->GetDrawLayer()) 1121 pDoc->GetDrawLayer()->SetDefaultTabulator(nTabDist); 1122 } 1123 } 1124 1125 // AutoSpell nach den Doc-Options (weil Member) 1126 1127 if ( IS_AVAILABLE(SID_AUTOSPELL_CHECK,pItem) ) // an Doc-Options 1128 { 1129 sal_Bool bDoAutoSpell = ((const SfxBoolItem*)pItem)->GetValue(); 1130 1131 if (pDoc) 1132 { 1133 ScDocOptions aNewOpt = pDoc->GetDocOptions(); 1134 if ( aNewOpt.IsAutoSpell() != bDoAutoSpell ) 1135 { 1136 aNewOpt.SetAutoSpell( bDoAutoSpell ); 1137 pDoc->SetDocOptions( aNewOpt ); 1138 1139 if (bDoAutoSpell) 1140 pDoc->SetOnlineSpellPos( ScAddress(0,0,0) ); // vorne anfangen 1141 else 1142 { 1143 WaitObject aWait( pDocSh->GetActiveDialogParent() ); 1144 pDoc->RemoveAutoSpellObj(); // Edit-Text-Objekte wieder zurueckwandeln 1145 } 1146 1147 //#92038#; don't set document modified, because this flag is no longer saved 1148 // pDocSh->SetDocumentModified(); 1149 1150 bRepaint = sal_True; // weil HideAutoSpell evtl. ungueltig 1151 //! alle Views painten ??? 1152 } 1153 } 1154 1155 if ( bOldAutoSpell != bDoAutoSpell ) 1156 { 1157 SetAutoSpellProperty( bDoAutoSpell ); 1158 bSaveSpellCheck = sal_True; 1159 } 1160 if ( pDocSh ) 1161 pDocSh->PostPaintGridAll(); // wegen Markierungen 1162 ScInputHandler* pInputHandler = GetInputHdl(); 1163 if ( pInputHandler ) 1164 pInputHandler->UpdateSpellSettings(); // EditEngine-Flags 1165 if ( pViewSh ) 1166 pViewSh->UpdateDrawTextOutliner(); // EditEngine-Flags 1167 1168 if (pBindings) 1169 pBindings->Invalidate( SID_AUTOSPELL_CHECK ); 1170 } 1171 1172 //============================================ 1173 // InputOptions 1174 //============================================ 1175 1176 if ( IS_AVAILABLE(SID_SC_INPUT_SELECTIONPOS,pItem) ) 1177 { 1178 pInputCfg->SetMoveDir( ((const SfxUInt16Item*)pItem)->GetValue() ); 1179 bSaveInputOptions = sal_True; 1180 } 1181 if ( IS_AVAILABLE(SID_SC_INPUT_SELECTION,pItem) ) 1182 { 1183 pInputCfg->SetMoveSelection( ((const SfxBoolItem*)pItem)->GetValue() ); 1184 bSaveInputOptions = sal_True; 1185 } 1186 if ( IS_AVAILABLE(SID_SC_INPUT_EDITMODE,pItem) ) 1187 { 1188 pInputCfg->SetEnterEdit( ((const SfxBoolItem*)pItem)->GetValue() ); 1189 bSaveInputOptions = sal_True; 1190 } 1191 if ( IS_AVAILABLE(SID_SC_INPUT_FMT_EXPAND,pItem) ) 1192 { 1193 pInputCfg->SetExtendFormat( ((const SfxBoolItem*)pItem)->GetValue() ); 1194 bSaveInputOptions = sal_True; 1195 } 1196 if ( IS_AVAILABLE(SID_SC_INPUT_RANGEFINDER,pItem) ) 1197 { 1198 pInputCfg->SetRangeFinder( ((const SfxBoolItem*)pItem)->GetValue() ); 1199 bSaveInputOptions = sal_True; 1200 } 1201 if ( IS_AVAILABLE(SID_SC_INPUT_REF_EXPAND,pItem) ) 1202 { 1203 pInputCfg->SetExpandRefs( ((const SfxBoolItem*)pItem)->GetValue() ); 1204 bSaveInputOptions = sal_True; 1205 } 1206 if ( IS_AVAILABLE(SID_SC_INPUT_MARK_HEADER,pItem) ) 1207 { 1208 pInputCfg->SetMarkHeader( ((const SfxBoolItem*)pItem)->GetValue() ); 1209 bSaveInputOptions = sal_True; 1210 bUpdateMarks = sal_True; 1211 } 1212 if ( IS_AVAILABLE(SID_SC_INPUT_TEXTWYSIWYG,pItem) ) 1213 { 1214 sal_Bool bNew = ((const SfxBoolItem*)pItem)->GetValue(); 1215 if ( bNew != pInputCfg->GetTextWysiwyg() ) 1216 { 1217 pInputCfg->SetTextWysiwyg( bNew ); 1218 bSaveInputOptions = sal_True; 1219 bUpdateRefDev = sal_True; 1220 } 1221 } 1222 if( IS_AVAILABLE( SID_SC_INPUT_REPLCELLSWARN, pItem ) ) 1223 { 1224 pInputCfg->SetReplaceCellsWarn( ((const SfxBoolItem*)pItem)->GetValue() ); 1225 bSaveInputOptions = sal_True; 1226 } 1227 1228 //============================================ 1229 // PrintOptions 1230 //============================================ 1231 1232 if ( IS_AVAILABLE(SID_SCPRINTOPTIONS,pItem) ) 1233 { 1234 const ScPrintOptions& rNewOpt = ((const ScTpPrintItem*)pItem)->GetPrintOptions(); 1235 SetPrintOptions( rNewOpt ); 1236 1237 // broadcast causes all previews to recalc page numbers 1238 SFX_APP()->Broadcast( SfxSimpleHint( SID_SCPRINTOPTIONS ) ); 1239 } 1240 1241 //---------------------------------------------------------- 1242 1243 // if ( bSaveSpellCheck ) 1244 // { 1245 // currently LinguProperties are saved only at program exit. 1246 // if a save method becomes available, it should be called here. 1247 // } 1248 1249 if ( bSaveAppOptions ) 1250 pAppCfg->OptionsChanged(); 1251 1252 if ( bSaveInputOptions ) 1253 pInputCfg->OptionsChanged(); 1254 1255 // Neuberechnung anstossen? 1256 1257 if ( pDoc && bCalcAll ) 1258 { 1259 WaitObject aWait( pDocSh->GetActiveDialogParent() ); 1260 pDoc->CalcAll(); 1261 if ( pViewSh ) 1262 pViewSh->UpdateCharts( sal_True ); 1263 else 1264 ScDBFunc::DoUpdateCharts( ScAddress(), pDoc, sal_True ); 1265 if (pBindings) 1266 pBindings->Invalidate( SID_ATTR_SIZE ); //SvxPosSize-StatusControl-Update 1267 } 1268 1269 if ( pViewSh && bUpdateMarks ) 1270 pViewSh->UpdateAutoFillMark(); 1271 1272 // View neuzeichnen? 1273 1274 if ( pViewSh && bRepaint ) 1275 { 1276 pViewSh->UpdateFixPos(); 1277 pViewSh->PaintGrid(); 1278 pViewSh->PaintTop(); 1279 pViewSh->PaintLeft(); 1280 pViewSh->PaintExtras(); 1281 pViewSh->InvalidateBorder(); 1282 if (pBindings) 1283 { 1284 pBindings->Invalidate( FID_TOGGLEHEADERS ); // -> Checks im Menue 1285 pBindings->Invalidate( FID_TOGGLESYNTAX ); 1286 } 1287 } 1288 1289 // update ref device (for all documents) 1290 1291 if ( bUpdateRefDev ) 1292 { 1293 // for all documents: recalc output factor, update row heights 1294 SfxObjectShell* pObjSh = SfxObjectShell::GetFirst(); 1295 while ( pObjSh ) 1296 { 1297 if ( pObjSh->Type() == TYPE(ScDocShell) ) 1298 { 1299 ScDocShell* pOneDocSh = ((ScDocShell*)pObjSh); 1300 pOneDocSh->CalcOutputFactor(); 1301 SCTAB nTabCount = pOneDocSh->GetDocument()->GetTableCount(); 1302 for (SCTAB nTab=0; nTab<nTabCount; nTab++) 1303 pOneDocSh->AdjustRowHeight( 0, MAXROW, nTab ); 1304 } 1305 pObjSh = SfxObjectShell::GetNext( *pObjSh ); 1306 } 1307 1308 // for all (tab-) views: 1309 TypeId aScType = TYPE(ScTabViewShell); 1310 SfxViewShell* pSh = SfxViewShell::GetFirst( &aScType ); 1311 while ( pSh ) 1312 { 1313 ScTabViewShell* pOneViewSh = (ScTabViewShell*)pSh; 1314 1315 // set ref-device for EditEngine 1316 ScInputHandler* pHdl = GetInputHdl(pOneViewSh); 1317 if (pHdl) 1318 pHdl->UpdateRefDevice(); 1319 1320 // update view scale 1321 ScViewData* pViewData = pOneViewSh->GetViewData(); 1322 pOneViewSh->SetZoom( pViewData->GetZoomX(), pViewData->GetZoomY(), sal_False ); 1323 1324 // repaint 1325 pOneViewSh->PaintGrid(); 1326 pOneViewSh->PaintTop(); 1327 pOneViewSh->PaintLeft(); 1328 1329 pSh = SfxViewShell::GetNext( *pSh, &aScType ); 1330 } 1331 } 1332 } 1333 1334 #undef IS_AVAILABLE 1335 1336 //------------------------------------------------------------------ 1337 // 1338 // Input-Handler 1339 // 1340 //------------------------------------------------------------------ 1341 1342 ScInputHandler* ScModule::GetInputHdl( ScTabViewShell* pViewSh, sal_Bool bUseRef ) 1343 { 1344 if ( pRefInputHandler && bUseRef ) 1345 return pRefInputHandler; 1346 1347 ScInputHandler* pHdl = NULL; 1348 if ( !pViewSh ) 1349 { 1350 // in case a UIActive embedded object has no ViewShell ( UNO component ) 1351 // the own calc view shell will be set as current, but no handling should happen 1352 1353 ScTabViewShell* pCurViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); 1354 if ( pCurViewSh && !pCurViewSh->GetUIActiveClient() ) 1355 pViewSh = pCurViewSh; 1356 } 1357 1358 if ( pViewSh ) 1359 pHdl = pViewSh->GetInputHandler(); // Viewshell hat jetzt immer einen 1360 1361 // #57989# wenn keine ViewShell uebergeben oder aktiv, kann NULL herauskommen 1362 DBG_ASSERT( pHdl || !pViewSh, "GetInputHdl: kein InputHandler gefunden" ); 1363 return pHdl; 1364 } 1365 1366 void ScModule::ViewShellChanged() 1367 { 1368 ScInputHandler* pHdl = GetInputHdl(); 1369 ScTabViewShell* pShell = ScTabViewShell::GetActiveViewShell(); 1370 if ( pShell && pHdl ) 1371 pShell->UpdateInputHandler(); 1372 } 1373 1374 void ScModule::SetInputMode( ScInputMode eMode ) 1375 { 1376 ScInputHandler* pHdl = GetInputHdl(); 1377 if (pHdl) 1378 pHdl->SetMode( eMode ); 1379 } 1380 1381 sal_Bool ScModule::IsEditMode() 1382 { 1383 ScInputHandler* pHdl = GetInputHdl(); 1384 return pHdl && pHdl->IsEditMode(); 1385 } 1386 1387 sal_Bool ScModule::IsInputMode() 1388 { 1389 ScInputHandler* pHdl = GetInputHdl(); 1390 return pHdl && pHdl->IsInputMode(); 1391 } 1392 1393 sal_Bool ScModule::InputKeyEvent( const KeyEvent& rKEvt, sal_Bool bStartEdit ) 1394 { 1395 ScInputHandler* pHdl = GetInputHdl(); 1396 return ( pHdl ? pHdl->KeyInput( rKEvt, bStartEdit ) : sal_False ); 1397 } 1398 1399 void ScModule::InputEnterHandler( sal_uInt8 nBlockMode ) 1400 { 1401 if ( !SFX_APP()->IsDowning() ) // nicht beim Programmende 1402 { 1403 ScInputHandler* pHdl = GetInputHdl(); 1404 if (pHdl) 1405 pHdl->EnterHandler( nBlockMode ); 1406 } 1407 } 1408 1409 void ScModule::InputCancelHandler() 1410 { 1411 ScInputHandler* pHdl = GetInputHdl(); 1412 if (pHdl) 1413 pHdl->CancelHandler(); 1414 } 1415 1416 void ScModule::InputSelection( EditView* pView ) 1417 { 1418 ScInputHandler* pHdl = GetInputHdl(); 1419 if (pHdl) 1420 pHdl->InputSelection( pView ); 1421 } 1422 1423 void ScModule::InputChanged( EditView* pView ) 1424 { 1425 ScInputHandler* pHdl = GetInputHdl(); 1426 if (pHdl) 1427 pHdl->InputChanged( pView ); 1428 } 1429 1430 void ScModule::ViewShellGone( ScTabViewShell* pViewSh ) 1431 { 1432 ScInputHandler* pHdl = GetInputHdl(); 1433 if (pHdl) 1434 pHdl->ViewShellGone( pViewSh ); 1435 } 1436 1437 void ScModule::SetRefInputHdl( ScInputHandler* pNew ) 1438 { 1439 pRefInputHandler = pNew; 1440 } 1441 1442 ScInputHandler* ScModule::GetRefInputHdl() 1443 { 1444 return pRefInputHandler; 1445 } 1446 1447 //------------------------------------------------------------------------ 1448 // Olk's Krempel: 1449 1450 void ScModule::InputGetSelection( xub_StrLen& rStart, xub_StrLen& rEnd ) 1451 { 1452 ScInputHandler* pHdl = GetInputHdl(); 1453 if (pHdl) 1454 pHdl->InputGetSelection( rStart, rEnd ); 1455 } 1456 1457 void ScModule::InputSetSelection( xub_StrLen nStart, xub_StrLen nEnd ) 1458 { 1459 ScInputHandler* pHdl = GetInputHdl(); 1460 if (pHdl) 1461 pHdl->InputSetSelection( nStart, nEnd ); 1462 } 1463 1464 void ScModule::InputReplaceSelection( const String& rStr ) 1465 { 1466 ScInputHandler* pHdl = GetInputHdl(); 1467 if (pHdl) 1468 pHdl->InputReplaceSelection( rStr ); 1469 } 1470 1471 String ScModule::InputGetFormulaStr() 1472 { 1473 ScInputHandler* pHdl = GetInputHdl(); 1474 String aStr; 1475 if ( pHdl ) 1476 aStr = pHdl->InputGetFormulaStr(); 1477 return aStr; 1478 } 1479 1480 void ScModule::ActivateInputWindow( const String* pStrFormula, sal_Bool bMatrix ) 1481 { 1482 ScInputHandler* pHdl = GetInputHdl(); 1483 if ( pHdl ) 1484 { 1485 ScInputWindow* pWin = pHdl->GetInputWindow(); 1486 if ( pStrFormula ) 1487 { 1488 // Formel uebernehmen 1489 if ( pWin ) 1490 { 1491 pWin->SetFuncString( *pStrFormula, sal_False ); 1492 // SetSumAssignMode wegen sal_False nicht noetig 1493 } 1494 sal_uInt8 nMode = bMatrix ? SC_ENTER_MATRIX : SC_ENTER_NORMAL; 1495 pHdl->EnterHandler( nMode ); 1496 1497 // ohne Invalidate bleibt die Selektion stehen, wenn die Formel unveraendert ist 1498 if (pWin) 1499 pWin->TextInvalidate(); 1500 } 1501 else 1502 { 1503 // Abbrechen 1504 if ( pWin ) 1505 { 1506 pWin->SetFuncString( EMPTY_STRING, sal_False ); 1507 // SetSumAssignMode wegen sal_False nicht noetig 1508 } 1509 pHdl->CancelHandler(); 1510 } 1511 } 1512 } 1513 1514 //------------------------------------------------------------------ 1515 // 1516 // Referenz - Dialoge 1517 // 1518 //------------------------------------------------------------------ 1519 1520 void ScModule::SetRefDialog( sal_uInt16 nId, sal_Bool bVis, SfxViewFrame* pViewFrm ) 1521 { 1522 //! move reference dialog handling to view 1523 //! (only keep function autopilot here for references to other documents) 1524 1525 if(nCurRefDlgId==0 || (nId==nCurRefDlgId && !bVis)) 1526 { 1527 if ( !pViewFrm ) 1528 pViewFrm = SfxViewFrame::Current(); 1529 1530 // #79379# bindings update causes problems with update of stylist if 1531 // current style family has changed 1532 //if ( pViewFrm ) 1533 // pViewFrm->GetBindings().Update(); // to avoid trouble in LockDispatcher 1534 1535 nCurRefDlgId = bVis ? nId : 0 ; // before SetChildWindow 1536 1537 if ( pViewFrm ) 1538 { 1539 // store the dialog id also in the view shell 1540 SfxViewShell* pViewSh = pViewFrm->GetViewShell(); 1541 if ( pViewSh && pViewSh->ISA( ScTabViewShell ) ) 1542 ((ScTabViewShell*)pViewSh)->SetCurRefDlgId( nCurRefDlgId ); 1543 else 1544 { 1545 // no ScTabViewShell - possible for example from a Basic macro 1546 bVis = sal_False; 1547 nCurRefDlgId = 0; // don't set nCurRefDlgId if no dialog is created 1548 } 1549 1550 pViewFrm->SetChildWindow( nId, bVis ); 1551 } 1552 1553 SfxApplication* pSfxApp = SFX_APP(); 1554 pSfxApp->Broadcast( SfxSimpleHint( FID_REFMODECHANGED ) ); 1555 } 1556 } 1557 1558 SfxChildWindow* lcl_GetChildWinFromAnyView( sal_uInt16 nId ) 1559 { 1560 // first try the current view 1561 1562 SfxViewFrame* pViewFrm = SfxViewFrame::Current(); 1563 // #i46999# current view frame can be null (for example, when closing help) 1564 SfxChildWindow* pChildWnd = pViewFrm ? pViewFrm->GetChildWindow( nId ) : NULL; 1565 if ( pChildWnd ) 1566 return pChildWnd; // found in the current view 1567 1568 // if not found there, get the child window from any open view 1569 // it can be open only in one view because nCurRefDlgId is global 1570 1571 pViewFrm = SfxViewFrame::GetFirst(); 1572 while ( pViewFrm ) 1573 { 1574 pChildWnd = pViewFrm->GetChildWindow( nId ); 1575 if ( pChildWnd ) 1576 return pChildWnd; // found in any view 1577 1578 pViewFrm = SfxViewFrame::GetNext( *pViewFrm ); 1579 } 1580 1581 return NULL; // none found 1582 } 1583 1584 sal_Bool ScModule::IsModalMode(SfxObjectShell* pDocSh) 1585 { 1586 //! move reference dialog handling to view 1587 //! (only keep function autopilot here for references to other documents) 1588 1589 sal_Bool bIsModal = sal_False; 1590 1591 if ( nCurRefDlgId ) 1592 { 1593 SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId ); 1594 if ( pChildWnd ) 1595 { 1596 IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow()); 1597 bIsModal = pChildWnd->IsVisible() && 1598 !( pRefDlg->IsRefInputMode() && pRefDlg->IsDocAllowed(pDocSh) ); 1599 } 1600 else 1601 { 1602 // in 592 and above, the dialog isn't visible in other views 1603 // if the dialog is open but can't be accessed, disable input 1604 1605 bIsModal = sal_True; 1606 } 1607 1608 // pChildWnd kann 0 sein, wenn der Dialog nach dem Umschalten 1609 // von einer anderen Shell noch nicht erzeugt wurde (z.B. in GetFocus) 1610 } 1611 else if (pDocSh) 1612 { 1613 ScInputHandler* pHdl = GetInputHdl(); 1614 if ( pHdl ) 1615 bIsModal = pHdl->IsModalMode(pDocSh); 1616 } 1617 1618 return bIsModal; 1619 } 1620 1621 sal_Bool ScModule::IsTableLocked() 1622 { 1623 //! move reference dialog handling to view 1624 //! (only keep function autopilot here for references to other documents) 1625 1626 sal_Bool bLocked = sal_False; 1627 1628 // bisher nur bei ScAnyRefDlg 1629 1630 if ( nCurRefDlgId ) 1631 { 1632 SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId ); 1633 if ( pChildWnd ) 1634 bLocked = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow())->IsTableLocked(); 1635 else 1636 bLocked = sal_True; // for other views, see IsModalMode 1637 } 1638 1639 return bLocked; 1640 } 1641 1642 sal_Bool ScModule::IsRefDialogOpen() 1643 { 1644 //! move reference dialog handling to view 1645 //! (only keep function autopilot here for references to other documents) 1646 1647 sal_Bool bIsOpen = sal_False; 1648 1649 if ( nCurRefDlgId ) 1650 { 1651 SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId ); 1652 if ( pChildWnd ) 1653 bIsOpen = pChildWnd->IsVisible(); 1654 else 1655 bIsOpen = sal_True; // for other views, see IsModalMode 1656 } 1657 1658 return bIsOpen; 1659 } 1660 1661 sal_Bool ScModule::IsFormulaMode() 1662 { 1663 //! move reference dialog handling to view 1664 //! (only keep function autopilot here for references to other documents) 1665 1666 sal_Bool bIsFormula = sal_False; 1667 1668 if ( nCurRefDlgId ) 1669 { 1670 SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId ); 1671 if ( pChildWnd ) 1672 { 1673 IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow()); 1674 bIsFormula = pChildWnd->IsVisible() && pRefDlg->IsRefInputMode(); 1675 } 1676 } 1677 else 1678 { 1679 ScInputHandler* pHdl = GetInputHdl(); 1680 if ( pHdl ) 1681 bIsFormula = pHdl->IsFormulaMode(); 1682 } 1683 1684 if (bIsInEditCommand) 1685 bIsFormula = sal_True; 1686 1687 return bIsFormula; 1688 } 1689 1690 void lcl_MarkedTabs( const ScMarkData& rMark, SCTAB& rStartTab, SCTAB& rEndTab ) 1691 { 1692 if (rMark.GetSelectCount() > 1) 1693 { 1694 sal_Bool bFirst = sal_True; 1695 for (SCTAB i=0; i<=MAXTAB; i++) 1696 if (rMark.GetTableSelect(i)) 1697 { 1698 if (bFirst) 1699 rStartTab = i; 1700 rEndTab = i; 1701 bFirst = sal_False; 1702 } 1703 } 1704 } 1705 1706 void ScModule::SetReference( const ScRange& rRef, ScDocument* pDoc, 1707 const ScMarkData* pMarkData ) 1708 { 1709 //! move reference dialog handling to view 1710 //! (only keep function autopilot here for references to other documents) 1711 1712 // in Ref-Dialogen wird hiermit auch das Zoom-In ausgeloest, 1713 // wenn Start und Ende der Ref unterschiedlich sind 1714 1715 ScRange aNew = rRef; 1716 aNew.Justify(); // immer "richtig herum" 1717 1718 if( nCurRefDlgId ) 1719 { 1720 SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId ); 1721 DBG_ASSERT( pChildWnd, "NoChildWin" ); 1722 if ( pChildWnd ) 1723 { 1724 if ( nCurRefDlgId == SID_OPENDLG_CONSOLIDATE && pMarkData ) 1725 { 1726 SCTAB nStartTab = aNew.aStart.Tab(); 1727 SCTAB nEndTab = aNew.aEnd.Tab(); 1728 lcl_MarkedTabs( *pMarkData, nStartTab, nEndTab ); 1729 aNew.aStart.SetTab(nStartTab); 1730 aNew.aEnd.SetTab(nEndTab); 1731 } 1732 1733 IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow()); 1734 1735 // hide the (color) selection now instead of later from LoseFocus, 1736 // don't abort the ref input that causes this call (bDoneRefMode = sal_False) 1737 pRefDlg->HideReference( sal_False ); 1738 pRefDlg->SetReference( aNew, pDoc ); 1739 } 1740 } 1741 else 1742 { 1743 ScInputHandler* pHdl = GetInputHdl(); 1744 if (pHdl) 1745 pHdl->SetReference( aNew, pDoc ); 1746 else 1747 { 1748 DBG_ERROR("SetReference ohne Empfaenger"); 1749 } 1750 } 1751 } 1752 1753 void ScModule::AddRefEntry() // "Mehrfachselektion" 1754 { 1755 //! move reference dialog handling to view 1756 //! (only keep function autopilot here for references to other documents) 1757 1758 if ( nCurRefDlgId ) 1759 { 1760 SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId ); 1761 DBG_ASSERT( pChildWnd, "NoChildWin" ); 1762 if ( pChildWnd ) 1763 { 1764 IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow()); 1765 pRefDlg->AddRefEntry(); 1766 } 1767 } 1768 else 1769 { 1770 ScInputHandler* pHdl = GetInputHdl(); 1771 if (pHdl) 1772 pHdl->AddRefEntry(); 1773 } 1774 } 1775 1776 void ScModule::EndReference() 1777 { 1778 //! move reference dialog handling to view 1779 //! (only keep function autopilot here for references to other documents) 1780 1781 // in Ref-Dialogen wird hiermit auch das Zoom-In wieder aufgehoben 1782 1783 //! ShowRefFrame am InputHdl, wenn der Funktions-AP offen ist ??? 1784 1785 if ( nCurRefDlgId ) 1786 { 1787 SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId ); 1788 DBG_ASSERT( pChildWnd, "NoChildWin" ); 1789 if ( pChildWnd ) 1790 { 1791 IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow()); 1792 pRefDlg->SetActive(); 1793 } 1794 } 1795 } 1796 1797 //------------------------------------------------------------------ 1798 // 1799 // Idle / Online-Spelling 1800 // 1801 //------------------------------------------------------------------ 1802 1803 void ScModule::AnythingChanged() 1804 { 1805 sal_uLong nOldTime = aIdleTimer.GetTimeout(); 1806 if ( nOldTime != SC_IDLE_MIN ) 1807 aIdleTimer.SetTimeout( SC_IDLE_MIN ); 1808 1809 nIdleCount = 0; 1810 } 1811 1812 void lcl_CheckNeedsRepaint( ScDocShell* pDocShell ) 1813 { 1814 SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell ); 1815 while ( pFrame ) 1816 { 1817 SfxViewShell* p = pFrame->GetViewShell(); 1818 ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p); 1819 if ( pViewSh ) 1820 pViewSh->CheckNeedsRepaint(); 1821 pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell ); 1822 } 1823 } 1824 1825 IMPL_LINK( ScModule, IdleHandler, Timer*, EMPTYARG ) 1826 { 1827 if ( Application::AnyInput( INPUT_MOUSEANDKEYBOARD ) ) 1828 { 1829 aIdleTimer.Start(); // Timeout unveraendert 1830 return 0; 1831 } 1832 1833 sal_Bool bMore = sal_False; 1834 ScDocShell* pDocSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() ); 1835 if ( pDocSh ) 1836 { 1837 ScDocument* pDoc = pDocSh->GetDocument(); 1838 1839 sal_Bool bLinks = pDoc->IdleCheckLinks(); 1840 sal_Bool bWidth = pDoc->IdleCalcTextWidth(); 1841 sal_Bool bSpell = pDoc->ContinueOnlineSpelling(); 1842 if ( bSpell ) 1843 aSpellTimer.Start(); // da ist noch was 1844 1845 bMore = bLinks || bWidth || bSpell; // ueberhaupt noch was? 1846 1847 // While calculating a Basic formula, a paint event may have occured, 1848 // so check the bNeedsRepaint flags for this document's views 1849 if (bWidth) 1850 lcl_CheckNeedsRepaint( pDocSh ); 1851 } 1852 1853 sal_uLong nOldTime = aIdleTimer.GetTimeout(); 1854 sal_uLong nNewTime = nOldTime; 1855 if ( bMore ) 1856 { 1857 nNewTime = SC_IDLE_MIN; 1858 nIdleCount = 0; 1859 } 1860 else 1861 { 1862 // SC_IDLE_COUNT mal mit initialem Timeout, dann hochzaehlen 1863 1864 if ( nIdleCount < SC_IDLE_COUNT ) 1865 ++nIdleCount; 1866 else 1867 { 1868 nNewTime += SC_IDLE_STEP; 1869 if ( nNewTime > SC_IDLE_MAX ) 1870 nNewTime = SC_IDLE_MAX; 1871 } 1872 } 1873 if ( nNewTime != nOldTime ) 1874 aIdleTimer.SetTimeout( nNewTime ); 1875 1876 aIdleTimer.Start(); 1877 return 0; 1878 } 1879 1880 IMPL_LINK( ScModule, SpellTimerHdl, Timer*, EMPTYARG ) 1881 { 1882 if ( Application::AnyInput( INPUT_KEYBOARD ) ) 1883 { 1884 aSpellTimer.Start(); 1885 return 0; // dann spaeter wieder... 1886 } 1887 1888 ScDocShell* pDocSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() ); 1889 if ( pDocSh ) 1890 { 1891 ScDocument* pDoc = pDocSh->GetDocument(); 1892 if ( pDoc->ContinueOnlineSpelling() ) 1893 aSpellTimer.Start(); 1894 } 1895 return 0; 1896 } 1897 1898 //virtuelle Methoden fuer den Optionendialog 1899 SfxItemSet* ScModule::CreateItemSet( sal_uInt16 nId ) 1900 { 1901 SfxItemSet* pRet = 0; 1902 if(SID_SC_EDITOPTIONS == nId) 1903 { 1904 pRet = new SfxItemSet( GetPool(), 1905 // TP_CALC: 1906 SID_SCDOCOPTIONS, SID_SCDOCOPTIONS, 1907 // TP_VIEW: 1908 SID_SCVIEWOPTIONS, SID_SCVIEWOPTIONS, 1909 SID_SC_OPT_SYNCZOOM, SID_SC_OPT_SYNCZOOM, 1910 // TP_INPUT: 1911 SID_SC_INPUT_SELECTION,SID_SC_INPUT_MARK_HEADER, 1912 SID_SC_INPUT_TEXTWYSIWYG,SID_SC_INPUT_TEXTWYSIWYG, 1913 SID_SC_INPUT_REPLCELLSWARN,SID_SC_INPUT_REPLCELLSWARN, 1914 // TP_USERLISTS: 1915 SCITEM_USERLIST, SCITEM_USERLIST, 1916 // TP_PRINT: 1917 SID_SCPRINTOPTIONS, SID_SCPRINTOPTIONS, 1918 // TP_GRID: 1919 SID_ATTR_GRID_OPTIONS, SID_ATTR_GRID_OPTIONS, 1920 // 1921 SID_ATTR_METRIC, SID_ATTR_METRIC, 1922 SID_ATTR_DEFTABSTOP, SID_ATTR_DEFTABSTOP, 1923 0 ); 1924 1925 ScDocShell* pDocSh = PTR_CAST(ScDocShell, 1926 SfxObjectShell::Current()); 1927 ScDocOptions aCalcOpt = pDocSh 1928 ? pDocSh->GetDocument()->GetDocOptions() 1929 : GetDocOptions(); 1930 1931 ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell, 1932 SfxViewShell::Current()); 1933 ScViewOptions aViewOpt = pViewSh 1934 ? pViewSh->GetViewData()->GetOptions() 1935 : GetViewOptions(); 1936 1937 ScUserListItem aULItem( SCITEM_USERLIST ); 1938 ScUserList* pUL = ScGlobal::GetUserList(); 1939 1940 // SFX_APP()->GetOptions( aSet ); 1941 1942 pRet->Put( SfxUInt16Item( SID_ATTR_METRIC, 1943 sal::static_int_cast<sal_uInt16>(GetAppOptions().GetAppMetric()) ) ); 1944 1945 // TP_CALC 1946 pRet->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP, 1947 aCalcOpt.GetTabDistance())); 1948 pRet->Put( ScTpCalcItem( SID_SCDOCOPTIONS, aCalcOpt ) ); 1949 1950 // TP_VIEW 1951 pRet->Put( ScTpViewItem( SID_SCVIEWOPTIONS, aViewOpt ) ); 1952 pRet->Put( SfxBoolItem( SID_SC_OPT_SYNCZOOM, GetAppOptions().GetSynchronizeZoom() ) ); 1953 1954 // TP_INPUT 1955 const ScInputOptions& rInpOpt = GetInputOptions(); 1956 pRet->Put( SfxUInt16Item( SID_SC_INPUT_SELECTIONPOS, 1957 rInpOpt.GetMoveDir() ) ); 1958 pRet->Put( SfxBoolItem( SID_SC_INPUT_SELECTION, 1959 rInpOpt.GetMoveSelection() ) ); 1960 pRet->Put( SfxBoolItem( SID_SC_INPUT_EDITMODE, 1961 rInpOpt.GetEnterEdit() ) ); 1962 pRet->Put( SfxBoolItem( SID_SC_INPUT_FMT_EXPAND, 1963 rInpOpt.GetExtendFormat() ) ); 1964 pRet->Put( SfxBoolItem( SID_SC_INPUT_RANGEFINDER, 1965 rInpOpt.GetRangeFinder() ) ); 1966 pRet->Put( SfxBoolItem( SID_SC_INPUT_REF_EXPAND, 1967 rInpOpt.GetExpandRefs() ) ); 1968 pRet->Put( SfxBoolItem( SID_SC_INPUT_MARK_HEADER, 1969 rInpOpt.GetMarkHeader() ) ); 1970 pRet->Put( SfxBoolItem( SID_SC_INPUT_TEXTWYSIWYG, 1971 rInpOpt.GetTextWysiwyg() ) ); 1972 pRet->Put( SfxBoolItem( SID_SC_INPUT_REPLCELLSWARN, 1973 rInpOpt.GetReplaceCellsWarn() ) ); 1974 1975 // RID_SC_TP_PRINT 1976 pRet->Put( ScTpPrintItem( SID_SCPRINTOPTIONS, GetPrintOptions() ) ); 1977 1978 // TP_GRID 1979 SvxGridItem* pSvxGridItem = aViewOpt.CreateGridItem(); 1980 pRet->Put( *pSvxGridItem ); 1981 delete pSvxGridItem; 1982 1983 // TP_USERLISTS 1984 if ( pUL ) 1985 aULItem.SetUserList( *pUL ); 1986 pRet->Put( aULItem ); 1987 1988 } 1989 return pRet; 1990 } 1991 1992 void ScModule::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) 1993 { 1994 if(SID_SC_EDITOPTIONS == nId) 1995 { 1996 ModifyOptions( rSet ); 1997 } 1998 } 1999 2000 SfxTabPage* ScModule::CreateTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet ) 2001 { 2002 SfxTabPage* pRet = NULL; 2003 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 2004 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 2005 switch(nId) 2006 { 2007 case SID_SC_TP_LAYOUT: 2008 { 2009 //CHINA001 pRet = ScTpLayoutOptions::Create(pParent, rSet); 2010 ::CreateTabPage ScTpLayoutOptionsCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_LAYOUT ); 2011 if ( ScTpLayoutOptionsCreate ) 2012 pRet = (*ScTpLayoutOptionsCreate) (pParent, rSet); 2013 } 2014 break; 2015 case SID_SC_TP_CONTENT: 2016 { 2017 //CHINA001 pRet = ScTpContentOptions::Create(pParent, rSet); 2018 ::CreateTabPage ScTpContentOptionsCreate = pFact->GetTabPageCreatorFunc(RID_SCPAGE_CONTENT); 2019 if ( ScTpContentOptionsCreate ) 2020 pRet = (*ScTpContentOptionsCreate)(pParent, rSet); 2021 } 2022 break; 2023 case SID_SC_TP_GRID: pRet = SvxGridTabPage::Create(pParent, rSet); break; 2024 case SID_SC_TP_USERLISTS: 2025 { 2026 //CHINA001 pRet = ScTpUserLists::Create(pParent, rSet); 2027 ::CreateTabPage ScTpUserListsCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_USERLISTS ); 2028 if ( ScTpUserListsCreate ) 2029 pRet = (*ScTpUserListsCreate)( pParent, rSet); 2030 } 2031 break; 2032 case SID_SC_TP_CALC: 2033 { //CHINA001 pRet = ScTpCalcOptions::Create(pParent, rSet); 2034 ::CreateTabPage ScTpCalcOptionsCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_CALC ); 2035 if ( ScTpCalcOptionsCreate ) 2036 pRet = (*ScTpCalcOptionsCreate)(pParent, rSet); 2037 } 2038 break; 2039 case SID_SC_TP_CHANGES: 2040 { //CHINA001 pRet = ScRedlineOptionsTabPage::Create(pParent, rSet); 2041 ::CreateTabPage ScRedlineOptionsTabPageCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_OPREDLINE ); 2042 if ( ScRedlineOptionsTabPageCreate ) 2043 pRet =(*ScRedlineOptionsTabPageCreate)(pParent, rSet); 2044 } 2045 break; 2046 case RID_SC_TP_PRINT: 2047 {//CHINA001 pRet = ScTpPrintOptions::Create(pParent, rSet); 2048 ::CreateTabPage ScTpPrintOptionsCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_PRINT ); 2049 if ( ScTpPrintOptionsCreate ) 2050 pRet = (*ScTpPrintOptionsCreate)( pParent, rSet); 2051 } 2052 break; 2053 case RID_OFA_TP_INTERNATIONAL: 2054 { 2055 SfxAbstractDialogFactory* pSfxFact = SfxAbstractDialogFactory::Create(); 2056 if ( pSfxFact ) 2057 { 2058 ::CreateTabPage fnCreatePage = pSfxFact->GetTabPageCreatorFunc( nId ); 2059 if ( fnCreatePage ) 2060 pRet = (*fnCreatePage)( pParent, rSet ); 2061 } 2062 } 2063 } 2064 2065 DBG_ASSERT( pRet, "ScModule::CreateTabPage(): no valid ID for TabPage!" ); 2066 2067 return pRet; 2068 } 2069 2070 //------------------------------------------------------------------ 2071 2072 IMPL_LINK( ScModule, CalcFieldValueHdl, EditFieldInfo*, pInfo ) 2073 { 2074 //! mit ScFieldEditEngine zusammenfassen !!! 2075 2076 if (pInfo) 2077 { 2078 const SvxFieldItem& rField = pInfo->GetField(); 2079 const SvxFieldData* pField = rField.GetField(); 2080 2081 if (pField && pField->ISA(SvxURLField)) 2082 { 2083 /****************************************************************** 2084 * URL-Field 2085 ******************************************************************/ 2086 2087 const SvxURLField* pURLField = (const SvxURLField*) pField; 2088 String aURL = pURLField->GetURL(); 2089 2090 switch ( pURLField->GetFormat() ) 2091 { 2092 case SVXURLFORMAT_APPDEFAULT: //!!! einstellbar an App??? 2093 case SVXURLFORMAT_REPR: 2094 { 2095 pInfo->SetRepresentation( pURLField->GetRepresentation() ); 2096 } 2097 break; 2098 2099 case SVXURLFORMAT_URL: 2100 { 2101 pInfo->SetRepresentation( aURL ); 2102 } 2103 break; 2104 } 2105 2106 svtools::ColorConfigEntry eEntry = 2107 INetURLHistory::GetOrCreate()->QueryUrl( aURL ) ? svtools::LINKSVISITED : svtools::LINKS; 2108 pInfo->SetTxtColor( GetColorConfig().GetColorValue(eEntry).nColor ); 2109 } 2110 else 2111 { 2112 DBG_ERROR("unbekannter Feldbefehl"); 2113 pInfo->SetRepresentation(String('?')); 2114 } 2115 } 2116 2117 return 0; 2118 } 2119 2120 sal_Bool ScModule::RegisterRefWindow( sal_uInt16 nSlotId, Window *pWnd ) 2121 { 2122 std::list<Window*> & rlRefWindow = m_mapRefWindow[nSlotId]; 2123 2124 if( std::find( rlRefWindow.begin(), rlRefWindow.end(), pWnd ) == rlRefWindow.end() ) 2125 { 2126 rlRefWindow.push_back( pWnd ); 2127 return sal_True; 2128 } 2129 2130 return sal_False; 2131 } 2132 2133 sal_Bool ScModule::UnregisterRefWindow( sal_uInt16 nSlotId, Window *pWnd ) 2134 { 2135 std::map<sal_uInt16, std::list<Window*> >::iterator iSlot = m_mapRefWindow.find( nSlotId ); 2136 2137 if( iSlot == m_mapRefWindow.end() ) 2138 return sal_False; 2139 2140 std::list<Window*> & rlRefWindow = iSlot->second; 2141 2142 std::list<Window*>::iterator i = std::find( rlRefWindow.begin(), rlRefWindow.end(), pWnd ); 2143 2144 if( i == rlRefWindow.end() ) 2145 return sal_False; 2146 2147 rlRefWindow.erase( i ); 2148 2149 if( !rlRefWindow.size() ) 2150 m_mapRefWindow.erase( nSlotId ); 2151 2152 return sal_True; 2153 } 2154 2155 sal_Bool ScModule::IsAliveRefDlg( sal_uInt16 nSlotId, Window *pWnd ) 2156 { 2157 std::map<sal_uInt16, std::list<Window*> >::iterator iSlot = m_mapRefWindow.find( nSlotId ); 2158 2159 if( iSlot == m_mapRefWindow.end() ) 2160 return sal_False; 2161 2162 std::list<Window*> & rlRefWindow = iSlot->second; 2163 2164 return rlRefWindow.end() != std::find( rlRefWindow.begin(), rlRefWindow.end(), pWnd ); 2165 } 2166 2167 Window * ScModule::Find1RefWindow( sal_uInt16 nSlotId, Window *pWndAncestor ) 2168 { 2169 if (!pWndAncestor) 2170 return NULL; 2171 2172 std::map<sal_uInt16, std::list<Window*> >::iterator iSlot = m_mapRefWindow.find( nSlotId ); 2173 2174 if( iSlot == m_mapRefWindow.end() ) 2175 return NULL; 2176 2177 std::list<Window*> & rlRefWindow = iSlot->second; 2178 2179 while( Window *pParent = pWndAncestor->GetParent() ) pWndAncestor = pParent; 2180 2181 for( std::list<Window*>::iterator i = rlRefWindow.begin(); i!=rlRefWindow.end(); i++ ) 2182 if ( pWndAncestor->IsWindowOrChild( *i, (*i)->IsSystemWindow() ) ) 2183 return *i; 2184 2185 return NULL; 2186 } 2187 2188 Window * ScModule::Find1RefWindow( Window *pWndAncestor ) 2189 { 2190 if (!pWndAncestor) 2191 return NULL; 2192 2193 while( Window *pParent = pWndAncestor->GetParent() ) pWndAncestor = pParent; 2194 2195 for( std::map<sal_uInt16, std::list<Window*> >::iterator i = m_mapRefWindow.begin(); 2196 i!=m_mapRefWindow.end(); i++ ) 2197 for( std::list<Window*>::iterator j = i->second.begin(); j!=i->second.end(); j++ ) 2198 if ( pWndAncestor->IsWindowOrChild( *j, (*j)->IsSystemWindow() ) ) 2199 return *j; 2200 2201 return NULL; 2202 } 2203 2204