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