1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sc.hxx" 30 31 32 33 // INCLUDE --------------------------------------------------------------- 34 35 #include "scitems.hxx" 36 #include <sfx2/viewfrm.hxx> 37 #include <sfx2/bindings.hxx> 38 #include <sfx2/dispatch.hxx> 39 #include <sfx2/request.hxx> 40 #include <svl/stritem.hxx> 41 #include <vcl/msgbox.hxx> 42 #include <sfx2/app.hxx> 43 #include "globstr.hrc" 44 #include "scmod.hxx" 45 #include "appoptio.hxx" 46 #include "tabvwsh.hxx" 47 #include "document.hxx" 48 #include "sc.hrc" 49 #include "docsh.hxx" 50 #include "reffact.hxx" 51 #include "uiitems.hxx" 52 //CHINA001 #include "scendlg.hxx" 53 //CHINA001 #include "mtrindlg.hxx" 54 #include "autoform.hxx" 55 #include "autofmt.hxx" 56 #include "cellsh.hxx" 57 #include "attrdlg.hrc" // TP_ALIGNMENT 58 #include "inputhdl.hxx" 59 #include "editable.hxx" 60 61 #include "scabstdlg.hxx" //CHINA001 62 63 #define IS_EDITMODE() GetViewData()->HasEditView( GetViewData()->GetActivePart() ) 64 65 inline long TwipsToHMM(long nTwips) { return (nTwips * 127 + 36) / 72; } 66 inline long HMMToTwips(long nHMM) { return (nHMM * 72 + 63) / 127; } 67 inline long TwipsToEvenHMM(long nTwips) { return ( (nTwips * 127 + 72) / 144 ) * 2; } 68 69 //------------------------------------------------------------------ 70 71 void ScCellShell::Execute( SfxRequest& rReq ) 72 { 73 ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 74 SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings(); 75 ScModule* pScMod = SC_MOD(); 76 const SfxItemSet* pReqArgs = rReq.GetArgs(); 77 sal_uInt16 nSlot = rReq.GetSlot(); 78 79 if (nSlot != SID_CURRENTCELL) // der kommt beim MouseButtonUp 80 pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox 81 82 if ( IS_EDITMODE() ) 83 { 84 switch ( nSlot ) 85 { 86 // beim Oeffnen eines Referenz-Dialogs darf die SubShell nicht umgeschaltet werden 87 // (beim Schliessen des Dialogs wird StopEditShell gerufen) 88 case SID_OPENDLG_FUNCTION: 89 // #53318# inplace macht die EditShell Aerger... 90 //! kann nicht immer umgeschaltet werden ???? 91 if (!pTabViewShell->GetViewFrame()->GetFrame().IsInPlace()) 92 pTabViewShell->SetDontSwitch(sal_True); // EditShell nicht abschalten 93 // kein break 94 95 case FID_CELL_FORMAT: 96 case SID_ENABLE_HYPHENATION: 97 case SID_DATA_SELECT: 98 case SID_OPENDLG_CONSOLIDATE: 99 case SID_OPENDLG_SOLVE: 100 case SID_OPENDLG_OPTSOLVER: 101 102 pScMod->InputEnterHandler(); 103 pTabViewShell->UpdateInputHandler(); 104 105 pTabViewShell->SetDontSwitch(sal_False); 106 107 break; 108 109 default: 110 break; 111 } 112 } 113 114 switch ( nSlot ) 115 { 116 117 118 119 case SID_ATTR_SIZE://XXX ??? 120 break; 121 122 case SID_STATUS_SELMODE: 123 if ( pReqArgs ) 124 { 125 /* 0: STD Click hebt Sel auf 126 * 1: ER Click erweitert Selektion 127 * 2: ERG Click definiert weitere Selektion 128 */ 129 sal_uInt16 nMode = ((const SfxUInt16Item&)pReqArgs->Get( nSlot )).GetValue(); 130 131 switch ( nMode ) 132 { 133 case 1: nMode = KEY_SHIFT; break; 134 case 2: nMode = KEY_MOD1; break; // Control-Taste 135 case 0: 136 default: 137 nMode = 0; 138 } 139 140 pTabViewShell->LockModifiers( nMode ); 141 } 142 else 143 { 144 // no arguments (also executed by double click on the status bar controller): 145 // advance to next selection mode 146 147 sal_uInt16 nModifiers = pTabViewShell->GetLockedModifiers(); 148 switch ( nModifiers ) 149 { 150 case KEY_SHIFT: nModifiers = KEY_MOD1; break; // EXT -> ADD 151 case KEY_MOD1: nModifiers = 0; break; // ADD -> STD 152 default: nModifiers = KEY_SHIFT; break; // STD -> EXT 153 } 154 pTabViewShell->LockModifiers( nModifiers ); 155 } 156 157 rBindings.Invalidate( SID_STATUS_SELMODE ); 158 rReq.Done(); 159 break; 160 161 // SID_STATUS_SELMODE_NORM wird nicht benutzt ??? 162 163 case SID_STATUS_SELMODE_NORM: 164 pTabViewShell->LockModifiers( 0 ); 165 rBindings.Invalidate( SID_STATUS_SELMODE ); 166 break; 167 168 // SID_STATUS_SELMODE_ERG / SID_STATUS_SELMODE_ERW als Toggles: 169 170 case SID_STATUS_SELMODE_ERG: 171 if ( pTabViewShell->GetLockedModifiers() & KEY_MOD1 ) 172 pTabViewShell->LockModifiers( 0 ); 173 else 174 pTabViewShell->LockModifiers( KEY_MOD1 ); 175 rBindings.Invalidate( SID_STATUS_SELMODE ); 176 break; 177 178 case SID_STATUS_SELMODE_ERW: 179 if ( pTabViewShell->GetLockedModifiers() & KEY_SHIFT ) 180 pTabViewShell->LockModifiers( 0 ); 181 else 182 pTabViewShell->LockModifiers( KEY_SHIFT ); 183 rBindings.Invalidate( SID_STATUS_SELMODE ); 184 break; 185 186 case SID_ENTER_STRING: 187 { 188 if ( pReqArgs ) 189 { 190 String aStr( ((const SfxStringItem&)pReqArgs-> 191 Get( SID_ENTER_STRING )).GetValue() ); 192 193 pTabViewShell->EnterData( GetViewData()->GetCurX(), 194 GetViewData()->GetCurY(), 195 GetViewData()->GetTabNo(), 196 aStr ); 197 198 ScInputHandler* pHdl = SC_MOD()->GetInputHdl( pTabViewShell ); 199 if ( !pHdl || !pHdl->IsInEnterHandler() ) 200 { 201 // #101061# UpdateInputHandler is needed after the cell content 202 // has changed, but if called from EnterHandler, UpdateInputHandler 203 // will be called later when moving the cursor. 204 205 pTabViewShell->UpdateInputHandler(); 206 } 207 208 rReq.Done(); 209 210 // hier kein GrabFocus, weil sonst auf dem Mac die Tabelle vor die 211 // Seitenansicht springt, wenn die Eingabe nicht abgeschlossen war 212 // (GrabFocus passiert in KillEditView) 213 } 214 } 215 break; 216 217 case SID_INSERT_MATRIX: 218 { 219 if ( pReqArgs ) 220 { 221 String aStr = ((const SfxStringItem&)pReqArgs-> 222 Get( SID_INSERT_MATRIX )).GetValue(); 223 pTabViewShell->EnterMatrix( aStr ); 224 rReq.Done(); 225 } 226 } 227 break; 228 229 case FID_INPUTLINE_ENTER: 230 case FID_INPUTLINE_BLOCK: 231 case FID_INPUTLINE_MATRIX: 232 { 233 if( pReqArgs == 0 ) //XXX vorlaufiger HACK um GPF zu vermeiden 234 break; 235 236 const ScInputStatusItem* pStatusItem 237 = (const ScInputStatusItem*)&pReqArgs-> 238 Get( FID_INPUTLINE_STATUS ); 239 240 ScAddress aCursorPos = pStatusItem->GetPos(); 241 String aString = pStatusItem->GetString(); 242 const EditTextObject* pData = pStatusItem->GetEditData(); 243 if (pData) 244 { 245 if (nSlot == FID_INPUTLINE_BLOCK) 246 { 247 pTabViewShell->EnterBlock( aString, pData ); 248 } 249 else if ( aString.Len() > 0 && ( aString.GetChar(0) == '=' || aString.GetChar(0) == '+' || aString.GetChar(0) == '-' ) ) 250 { 251 pTabViewShell->EnterData( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(), aString, sal_True, pData ); 252 } 253 else 254 { 255 pTabViewShell->EnterData( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(), pData ); 256 } 257 } 258 else 259 { 260 if (nSlot == FID_INPUTLINE_ENTER) 261 { 262 if ( 263 aCursorPos.Col() == GetViewData()->GetCurX() && 264 aCursorPos.Row() == GetViewData()->GetCurY() && 265 aCursorPos.Tab() == GetViewData()->GetTabNo() 266 ) 267 { 268 SfxStringItem aItem( SID_ENTER_STRING, aString ); 269 270 // SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings(); 271 const SfxPoolItem* aArgs[2]; 272 aArgs[0] = &aItem; 273 aArgs[1] = NULL; 274 rBindings.Execute( SID_ENTER_STRING, aArgs ); 275 } 276 else 277 { 278 pTabViewShell->EnterData( aCursorPos.Col(), 279 aCursorPos.Row(), 280 aCursorPos.Tab(), 281 aString ); 282 rReq.Done(); 283 } 284 } 285 else if (nSlot == FID_INPUTLINE_BLOCK) 286 { 287 pTabViewShell->EnterBlock( aString, NULL ); 288 rReq.Done(); 289 } 290 else 291 { 292 pTabViewShell->EnterMatrix( aString ); 293 rReq.Done(); 294 } 295 296 } 297 298 // hier kein GrabFocus, weil sonst auf dem Mac die Tabelle vor die 299 // Seitenansicht springt, wenn die Eingabe nicht abgeschlossen war 300 // (GrabFocus passiert in KillEditView) 301 } 302 break; 303 304 case SID_OPENDLG_FUNCTION: 305 { 306 sal_uInt16 nId = SID_OPENDLG_FUNCTION; 307 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); 308 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); 309 310 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True ); 311 rReq.Ignore(); 312 } 313 break; 314 315 case SID_OPENDLG_CONSOLIDATE: 316 { 317 sal_uInt16 nId = ScConsolidateDlgWrapper::GetChildWindowId(); 318 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); 319 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); 320 321 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True ); 322 } 323 break; 324 325 case FID_CELL_FORMAT: 326 { 327 if ( pReqArgs != NULL ) 328 { 329 //---------------------------------- 330 // Zellattribute ohne Dialog setzen: 331 //---------------------------------- 332 SfxItemSet* pEmptySet = 333 new SfxItemSet( *pReqArgs->GetPool(), 334 ATTR_PATTERN_START, 335 ATTR_PATTERN_END ); 336 337 SfxItemSet* pNewSet = 338 new SfxItemSet( *pReqArgs->GetPool(), 339 ATTR_PATTERN_START, 340 ATTR_PATTERN_END ); 341 342 const SfxPoolItem* pAttr = NULL; 343 sal_uInt16 nWhich = 0; 344 345 for ( nWhich=ATTR_PATTERN_START; nWhich<=ATTR_PATTERN_END; nWhich++ ) 346 if ( pReqArgs->GetItemState( nWhich, sal_True, &pAttr ) == SFX_ITEM_SET ) 347 pNewSet->Put( *pAttr ); 348 349 pTabViewShell->ApplyAttributes( pNewSet, pEmptySet ); 350 351 delete pNewSet; 352 delete pEmptySet; 353 354 rReq.Done(); 355 } 356 else if ( pReqArgs == NULL ) 357 { 358 pTabViewShell->ExecuteCellFormatDlg( rReq ); 359 } 360 } 361 break; 362 363 case SID_ENABLE_HYPHENATION: 364 pTabViewShell->ExecuteCellFormatDlg( rReq, TP_ALIGNMENT ); 365 break; 366 367 case SID_OPENDLG_SOLVE: 368 { 369 sal_uInt16 nId = ScSolverDlgWrapper::GetChildWindowId(); 370 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); 371 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); 372 373 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True ); 374 } 375 break; 376 377 case SID_OPENDLG_OPTSOLVER: 378 { 379 sal_uInt16 nId = ScOptSolverDlgWrapper::GetChildWindowId(); 380 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); 381 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); 382 383 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True ); 384 } 385 break; 386 387 case SID_OPENDLG_TABOP: 388 { 389 sal_uInt16 nId = ScTabOpDlgWrapper::GetChildWindowId(); 390 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); 391 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); 392 393 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True ); 394 } 395 break; 396 397 case SID_SCENARIOS: 398 { 399 ScDocument* pDoc = GetViewData()->GetDocument(); 400 ScMarkData& rMark = GetViewData()->GetMarkData(); 401 SCTAB nTab = GetViewData()->GetTabNo(); 402 403 if ( pDoc->IsScenario(nTab) ) 404 { 405 rMark.MarkToMulti(); 406 if ( rMark.IsMultiMarked() ) 407 { 408 if ( rReq.IsAPI() 409 || RET_YES == 410 QueryBox( pTabViewShell->GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES), 411 ScGlobal::GetRscString(STR_UPDATE_SCENARIO) ). 412 Execute() ) 413 { 414 pTabViewShell->ExtendScenario(); 415 rReq.Done(); 416 } 417 } 418 else if( ! rReq.IsAPI() ) 419 { 420 ErrorBox aErrorBox( pTabViewShell->GetDialogParent(), WinBits(WB_OK | WB_DEF_OK), 421 ScGlobal::GetRscString(STR_NOAREASELECTED) ); 422 aErrorBox.Execute(); 423 } 424 } 425 else 426 { 427 rMark.MarkToMulti(); 428 if ( rMark.IsMultiMarked() ) 429 { 430 SCTAB i=1; 431 String aBaseName; 432 String aName; 433 String aComment; 434 Color aColor; 435 sal_uInt16 nFlags; 436 437 pDoc->GetName( nTab, aBaseName ); 438 aBaseName += '_'; 439 aBaseName += ScGlobal::GetRscString(STR_SCENARIO); 440 aBaseName += '_'; 441 442 // vorneweg testen, ob der Prefix als gueltig erkannt wird 443 // wenn nicht, nur doppelte vermeiden 444 sal_Bool bPrefix = pDoc->ValidTabName( aBaseName ); 445 DBG_ASSERT(bPrefix, "ungueltiger Tabellenname"); 446 447 while ( pDoc->IsScenario(nTab+i) ) 448 i++; 449 450 sal_Bool bValid; 451 SCTAB nDummy; 452 do 453 { 454 aName = aBaseName; 455 aName += String::CreateFromInt32( i ); 456 if (bPrefix) 457 bValid = pDoc->ValidNewTabName( aName ); 458 else 459 bValid = !pDoc->GetTable( aName, nDummy ); 460 ++i; 461 } 462 while ( !bValid && i <= 2*MAXTAB ); 463 464 if ( pReqArgs != NULL ) 465 { 466 String aArgName; 467 String aArgComment; 468 const SfxPoolItem* pItem; 469 if ( pReqArgs->GetItemState( SID_SCENARIOS, sal_True, &pItem ) == SFX_ITEM_SET ) 470 aArgName = ((const SfxStringItem*)pItem)->GetValue(); 471 if ( pReqArgs->GetItemState( SID_NEW_TABLENAME, sal_True, &pItem ) == SFX_ITEM_SET ) 472 aArgComment = ((const SfxStringItem*)pItem)->GetValue(); 473 474 aColor = Color( COL_LIGHTGRAY ); // Default 475 nFlags = 0; // nicht-TwoWay 476 477 pTabViewShell->MakeScenario( aArgName, aArgComment, aColor, nFlags ); 478 if( ! rReq.IsAPI() ) 479 rReq.Done(); 480 } 481 else 482 { 483 sal_Bool bSheetProtected = pDoc->IsTabProtected(nTab); 484 //CHINA001 ScNewScenarioDlg* pNewDlg = 485 //CHINA001 new ScNewScenarioDlg( pTabViewShell->GetDialogParent(), aName, sal_False, bSheetProtected ); 486 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 487 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 488 489 AbstractScNewScenarioDlg* pNewDlg = pFact->CreateScNewScenarioDlg( pTabViewShell->GetDialogParent(), aName, RID_SCDLG_NEWSCENARIO, sal_False,bSheetProtected); 490 DBG_ASSERT(pNewDlg, "Dialog create fail!");//CHINA001 491 if ( pNewDlg->Execute() == RET_OK ) 492 { 493 pNewDlg->GetScenarioData( aName, aComment, aColor, nFlags ); 494 pTabViewShell->MakeScenario( aName, aComment, aColor, nFlags ); 495 496 rReq.AppendItem( SfxStringItem( SID_SCENARIOS, aName ) ); 497 rReq.AppendItem( SfxStringItem( SID_NEW_TABLENAME, aComment ) ); 498 rReq.Done(); 499 } 500 delete pNewDlg; 501 } 502 } 503 else if( ! rReq.IsAPI() ) 504 { 505 pTabViewShell->ErrorMessage(STR_ERR_NEWSCENARIO); 506 } 507 } 508 } 509 break; 510 511 512 case SID_SELECTALL: 513 { 514 pTabViewShell->SelectAll(); 515 rReq.Done(); 516 } 517 break; 518 519 //---------------------------------------------------------------- 520 521 case FID_ROW_HEIGHT: 522 { 523 if ( pReqArgs ) 524 { 525 const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_ROW_HEIGHT ); 526 527 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert 528 pTabViewShell->SetMarkedWidthOrHeight( sal_False, SC_SIZE_DIRECT, 529 sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) ); 530 if( ! rReq.IsAPI() ) 531 rReq.Done(); 532 } 533 else 534 { 535 ScViewData* pData = GetViewData(); 536 FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric(); 537 sal_uInt16 nCurHeight = pData->GetDocument()-> 538 GetRowHeight( pData->GetCurY(), 539 pData->GetTabNo() ); 540 //CHINA001 ScMetricInputDlg* pDlg = 541 //CHINA001 new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_MAN, 542 //CHINA001 nCurHeight, 543 //CHINA001 ScGlobal::nStdRowHeight, 544 //CHINA001 eMetric, 545 //CHINA001 2, 546 //CHINA001 MAX_COL_HEIGHT ); 547 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 548 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 549 550 AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_MAN, 551 nCurHeight, 552 ScGlobal::nStdRowHeight, 553 RID_SCDLG_ROW_MAN, 554 eMetric, 555 2, 556 MAX_COL_HEIGHT); 557 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 558 559 if ( pDlg->Execute() == RET_OK ) 560 { 561 long nVal = pDlg->GetInputValue(); 562 pTabViewShell->SetMarkedWidthOrHeight( sal_False, SC_SIZE_DIRECT, (sal_uInt16)nVal ); 563 564 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert 565 rReq.AppendItem( SfxUInt16Item( FID_ROW_HEIGHT, (sal_uInt16)TwipsToEvenHMM(nVal) ) ); 566 rReq.Done(); 567 568 } 569 delete pDlg; 570 } 571 } 572 break; 573 574 case FID_ROW_OPT_HEIGHT: 575 { 576 if ( pReqArgs ) 577 { 578 const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_ROW_OPT_HEIGHT ); 579 580 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert 581 pTabViewShell->SetMarkedWidthOrHeight( sal_False, SC_SIZE_OPTIMAL, 582 sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) ); 583 ScGlobal::nLastRowHeightExtra = rUInt16Item.GetValue(); 584 585 if( ! rReq.IsAPI() ) 586 rReq.Done(); 587 } 588 else 589 { 590 FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric(); 591 592 //CHINA001 ScMetricInputDlg* pDlg = 593 //CHINA001 new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_OPT, 594 //CHINA001 ScGlobal::nLastRowHeightExtra, 595 //CHINA001 0, 596 //CHINA001 eMetric, 597 //CHINA001 1, 598 //CHINA001 MAX_EXTRA_HEIGHT ); 599 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 600 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 601 602 AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_OPT, 603 ScGlobal::nLastRowHeightExtra, 604 0, 605 RID_SCDLG_ROW_OPT, 606 eMetric, 607 1, 608 MAX_EXTRA_HEIGHT); 609 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 610 611 if ( pDlg->Execute() == RET_OK ) 612 { 613 long nVal = pDlg->GetInputValue(); 614 pTabViewShell->SetMarkedWidthOrHeight( sal_False, SC_SIZE_OPTIMAL, (sal_uInt16)nVal ); 615 ScGlobal::nLastRowHeightExtra = nVal; 616 617 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert 618 rReq.AppendItem( SfxUInt16Item( FID_ROW_OPT_HEIGHT, (sal_uInt16)TwipsToEvenHMM(nVal) ) ); 619 rReq.Done(); 620 621 } 622 delete pDlg; 623 } 624 } 625 break; 626 627 case FID_COL_WIDTH: 628 { 629 if ( pReqArgs ) 630 { 631 const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_COL_WIDTH ); 632 633 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert 634 pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_DIRECT, 635 sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) ); 636 if( ! rReq.IsAPI() ) 637 rReq.Done(); 638 } 639 else 640 { 641 FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric(); 642 ScViewData* pData = GetViewData(); 643 sal_uInt16 nCurHeight = pData->GetDocument()-> 644 GetColWidth( pData->GetCurX(), 645 pData->GetTabNo() ); 646 //CHINA001 ScMetricInputDlg* pDlg = 647 //CHINA001 new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_MAN, 648 //CHINA001 nCurHeight, 649 //CHINA001 STD_COL_WIDTH, 650 //CHINA001 eMetric, 651 //CHINA001 2, 652 //CHINA001 MAX_COL_WIDTH ); 653 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 654 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 655 656 AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_MAN, 657 nCurHeight, 658 STD_COL_WIDTH, 659 RID_SCDLG_COL_MAN, 660 eMetric, 661 2, 662 MAX_COL_WIDTH); 663 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 664 665 if ( pDlg->Execute() == RET_OK ) 666 { 667 long nVal = pDlg->GetInputValue(); 668 pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_DIRECT, (sal_uInt16)nVal ); 669 670 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert 671 rReq.AppendItem( SfxUInt16Item( FID_COL_WIDTH, (sal_uInt16)TwipsToEvenHMM(nVal)) ); 672 rReq.Done(); 673 674 } 675 delete pDlg; 676 } 677 } 678 break; 679 680 case FID_COL_OPT_WIDTH: 681 { 682 if ( pReqArgs ) 683 { 684 const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_COL_OPT_WIDTH ); 685 686 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert 687 pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_OPTIMAL, 688 sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) ); 689 ScGlobal::nLastColWidthExtra = rUInt16Item.GetValue(); 690 691 if( ! rReq.IsAPI() ) 692 rReq.Done(); 693 } 694 else 695 { 696 FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric(); 697 698 //CHINA001 ScMetricInputDlg* pDlg = 699 //CHINA001 new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_OPT, 700 //CHINA001 ScGlobal::nLastColWidthExtra, 701 //CHINA001 STD_EXTRA_WIDTH, 702 //CHINA001 eMetric, 703 //CHINA001 1, 704 //CHINA001 MAX_EXTRA_WIDTH ); 705 706 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 707 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 708 709 AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_OPT, 710 ScGlobal::nLastColWidthExtra, 711 STD_EXTRA_WIDTH, 712 RID_SCDLG_COL_OPT, 713 eMetric, 714 1, 715 MAX_EXTRA_WIDTH); 716 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 717 if ( pDlg->Execute() == RET_OK ) 718 { 719 long nVal = pDlg->GetInputValue(); 720 pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_OPTIMAL, (sal_uInt16)nVal ); 721 ScGlobal::nLastColWidthExtra = nVal; 722 723 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert 724 rReq.AppendItem( SfxUInt16Item( FID_COL_OPT_WIDTH, (sal_uInt16)TwipsToEvenHMM(nVal) ) ); 725 rReq.Done(); 726 } 727 delete pDlg; 728 } 729 } 730 break; 731 732 case FID_COL_OPT_DIRECT: 733 pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH ); 734 rReq.Done(); 735 break; 736 737 case FID_ROW_HIDE: 738 pTabViewShell->SetMarkedWidthOrHeight( sal_False, SC_SIZE_DIRECT, 0 ); 739 rReq.Done(); 740 break; 741 case FID_ROW_SHOW: 742 pTabViewShell->SetMarkedWidthOrHeight( sal_False, SC_SIZE_SHOW, 0 ); 743 rReq.Done(); 744 break; 745 case FID_COL_HIDE: 746 pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_DIRECT, 0 ); 747 rReq.Done(); 748 break; 749 case FID_COL_SHOW: 750 pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_SHOW, 0 ); 751 rReq.Done(); 752 break; 753 754 //---------------------------------------------------------------- 755 756 757 case SID_CELL_FORMAT_RESET: 758 { 759 pTabViewShell->DeleteContents( IDF_HARDATTR | IDF_EDITATTR ); 760 rReq.Done(); 761 } 762 break; 763 764 case FID_MERGE_ON: 765 case FID_MERGE_OFF: 766 case FID_MERGE_TOGGLE: 767 { 768 if ( !GetViewData()->GetDocument()->GetChangeTrack() ) 769 { 770 // test whether to merge or to split 771 bool bMerge = false; 772 switch( nSlot ) 773 { 774 case FID_MERGE_ON: 775 bMerge = true; 776 break; 777 case FID_MERGE_OFF: 778 bMerge = false; 779 break; 780 case FID_MERGE_TOGGLE: 781 { 782 SfxPoolItem* pItem = 0; 783 if( rBindings.QueryState( nSlot, pItem ) >= SFX_ITEM_DEFAULT ) 784 bMerge = !static_cast< SfxBoolItem* >( pItem )->GetValue(); 785 } 786 break; 787 } 788 789 if( bMerge ) 790 { 791 // merge - check if to move contents of covered cells 792 sal_Bool bMoveContents = sal_False; 793 sal_Bool bApi = rReq.IsAPI(); 794 const SfxPoolItem* pItem; 795 if ( pReqArgs && 796 pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET ) 797 { 798 DBG_ASSERT(pItem && pItem->ISA(SfxBoolItem), "falsches Item"); 799 bMoveContents = ((const SfxBoolItem*)pItem)->GetValue(); 800 } 801 802 if (pTabViewShell->MergeCells( bApi, bMoveContents )) 803 { 804 if (!bApi && bMoveContents) // "ja" im Dialog geklickt 805 rReq.AppendItem( SfxBoolItem( nSlot, bMoveContents ) ); 806 rBindings.Invalidate( nSlot ); 807 rReq.Done(); 808 } 809 } 810 else 811 { 812 // split cells 813 if (pTabViewShell->RemoveMerge()) 814 { 815 rBindings.Invalidate( nSlot ); 816 rReq.Done(); 817 } 818 } 819 break; 820 } 821 } 822 break; 823 824 case SID_AUTOFORMAT: 825 { 826 Window* pDlgParent = pTabViewShell->GetDialogParent(); 827 SCCOL nStartCol; 828 SCROW nStartRow; 829 SCTAB nStartTab; 830 SCCOL nEndCol; 831 SCROW nEndRow; 832 SCTAB nEndTab; 833 834 const ScMarkData& rMark = GetViewData()->GetMarkData(); 835 if ( !rMark.IsMarked() && !rMark.IsMultiMarked() ) 836 pTabViewShell->MarkDataArea( sal_True ); 837 838 GetViewData()->GetSimpleArea( nStartCol,nStartRow,nStartTab, 839 nEndCol,nEndRow,nEndTab ); 840 841 if ( ( Abs((SCsCOL)nEndCol-(SCsCOL)nStartCol) > 1 ) 842 && ( Abs((SCsROW)nEndRow-(SCsROW)nStartRow) > 1 ) ) 843 { 844 if ( pReqArgs ) 845 { 846 const SfxStringItem& rNameItem = (const SfxStringItem&)pReqArgs->Get( SID_AUTOFORMAT ); 847 ScAutoFormat* pFormat = ScGlobal::GetAutoFormat(); 848 sal_uInt16 nIndex = pFormat->FindIndexPerName( rNameItem.GetValue() ); 849 850 pTabViewShell->AutoFormat( nIndex ); 851 852 if( ! rReq.IsAPI() ) 853 rReq.Done(); 854 } 855 else 856 { 857 ScGlobal::ClearAutoFormat(); 858 ScAutoFormatData* pNewEntry = pTabViewShell->CreateAutoFormatData(); 859 //CHINA001 ScAutoFormatDlg* pDlg = new ScAutoFormatDlg( 860 //CHINA001 pDlgParent, 861 //CHINA001 ScGlobal::GetAutoFormat(), 862 //CHINA001 pNewEntry, 863 //CHINA001 GetViewData()->GetDocument() ); 864 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 865 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 866 867 AbstractScAutoFormatDlg* pDlg = pFact->CreateScAutoFormatDlg( pDlgParent, ScGlobal::GetAutoFormat(), pNewEntry,GetViewData()->GetDocument(), RID_SCDLG_AUTOFORMAT ); 868 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 869 870 if ( pDlg->Execute() == RET_OK ) 871 { 872 ScEditableTester aTester( pTabViewShell ); 873 if ( !aTester.IsEditable() ) 874 { 875 pTabViewShell->ErrorMessage(aTester.GetMessageId()); 876 } 877 else 878 { 879 pTabViewShell->AutoFormat( pDlg->GetIndex() ); 880 881 rReq.AppendItem( SfxStringItem( SID_AUTOFORMAT, pDlg->GetCurrFormatName() ) ); 882 rReq.Done(); 883 } 884 } 885 delete pDlg; 886 delete pNewEntry; 887 } 888 } 889 else 890 ErrorBox( pDlgParent, WinBits( WB_OK | WB_DEF_OK ), 891 ScGlobal::GetRscString(STR_INVALID_AFAREA) ).Execute(); 892 } 893 break; 894 895 case SID_CANCEL: 896 { 897 if (GetViewData()->HasEditView(GetViewData()->GetActivePart())) 898 pScMod->InputCancelHandler(); 899 else if (pTabViewShell->HasPaintBrush()) 900 pTabViewShell->ResetBrushDocument(); // abort format paint brush 901 else if (pTabViewShell->HasHintWindow()) 902 pTabViewShell->RemoveHintWindow(); // Eingabemeldung abschalten 903 else if( ScViewUtil::IsFullScreen( *pTabViewShell ) ) 904 ScViewUtil::SetFullScreen( *pTabViewShell, false ); 905 else 906 { 907 // TODO/LATER: when is this code executed? 908 pTabViewShell->Escape(); 909 //SfxObjectShell* pObjSh = GetViewData()->GetSfxDocShell(); 910 //if (pObjSh->GetInPlaceObject() && 911 // pObjSh->GetInPlaceObject()->GetIPClient()) 912 //{ 913 // GetViewData()->GetDocShell()-> 914 // DoInPlaceActivate(sal_False); // OLE beenden 915 //} 916 } 917 918 // SetSumAssignMode(); //ScInputWindow 919 } 920 break; 921 922 case SID_DATA_SELECT: 923 pTabViewShell->StartDataSelect(); 924 break; 925 926 case SID_DETECTIVE_FILLMODE: 927 { 928 sal_Bool bOldMode = pTabViewShell->IsAuditShell(); 929 pTabViewShell->SetAuditShell( !bOldMode ); 930 pTabViewShell->Invalidate( nSlot ); 931 } 932 break; 933 934 case SID_OPENDLG_CONDFRMT: 935 { 936 sal_uInt16 nId = ScCondFormatDlgWrapper::GetChildWindowId(); 937 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); 938 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); 939 940 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True ); 941 } 942 break; 943 944 // ---------------------------------------------------------------- 945 946 case FID_INPUTLINE_STATUS: 947 DBG_ERROR("Execute von InputLine-Status"); 948 break; 949 950 case SID_STATUS_DOCPOS: 951 // Launch navigator. 952 GetViewData()->GetDispatcher().Execute( 953 SID_NAVIGATOR, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD ); 954 break; 955 956 case SID_MARKAREA: 957 // called from Basic at the hidden view to select a range in the visible view 958 DBG_ERROR("old slot SID_MARKAREA"); 959 break; 960 961 default: 962 DBG_ERROR("Unbekannter Slot bei ScCellShell::Execute"); 963 break; 964 } 965 } 966 967