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 34 //svdraw.hxx 35 #define _SDR_NOITEMS 36 #define _SDR_NOTOUCH 37 #define _SDR_NOTRANSFORM 38 #define _SI_NOSBXCONTROLS 39 #define _VCONT_HXX 40 #define _SI_NOOTHERFORMS 41 #define _VCTRLS_HXX 42 #define _SI_NOCONTROL 43 #define _SETBRW_HXX 44 #define _VCBRW_HXX 45 #define _SI_NOSBXCONTROLS 46 47 //------------------------------------------------------------------ 48 #include <com/sun/star/i18n/TextConversionOption.hpp> 49 #include <com/sun/star/sheet/DataPilotFieldFilter.hpp> 50 51 #include "scitems.hxx" 52 #include <sfx2/viewfrm.hxx> 53 54 #define _ZFORLIST_DECLARE_TABLE 55 #include <svl/stritem.hxx> 56 #include <svl/whiter.hxx> 57 #include <svl/zforlist.hxx> 58 #include <svl/zformat.hxx> 59 #include <sfx2/dispatch.hxx> 60 #include <sfx2/request.hxx> 61 #include <vcl/msgbox.hxx> 62 #include <svx/svxdlg.hxx> 63 #include <sot/formats.hxx> 64 #include <svx/postattr.hxx> 65 #include <editeng/fontitem.hxx> 66 #include <svx/clipfmtitem.hxx> 67 #include <sfx2/passwd.hxx> 68 #include <svx/hlnkitem.hxx> 69 #include <basic/sbxcore.hxx> 70 #include <unotools/useroptions.hxx> 71 #include <vcl/waitobj.hxx> 72 #include <unotools/localedatawrapper.hxx> 73 74 #include "cellsh.hxx" 75 #include "sc.hrc" 76 #include "document.hxx" 77 #include "patattr.hxx" 78 #include "scmod.hxx" 79 #include "scresid.hxx" 80 #include "tabvwsh.hxx" 81 //CHINA001 #include "inscldlg.hxx" 82 //CHINA001 #include "inscodlg.hxx" 83 //CHINA001 #include "delcldlg.hxx" 84 //CHINA001 #include "delcodlg.hxx" 85 //CHINA001 #include "filldlg.hxx" 86 //CHINA001 #include "groupdlg.hxx" 87 #include "impex.hxx" 88 #include "reffind.hxx" 89 //CHINA001 #include "namecrea.hxx" 90 #include "uiitems.hxx" 91 #include "reffact.hxx" 92 //CHINA001 #include "namepast.hxx" 93 #include "inputhdl.hxx" 94 #include "transobj.hxx" 95 #include "drwtrans.hxx" 96 //CHINA001 #include "linkarea.hxx" 97 #include "docfunc.hxx" 98 #include "editable.hxx" 99 #include "dpobject.hxx" 100 #include "dpsave.hxx" 101 #include "dpgroup.hxx" // for ScDPNumGroupInfo 102 #include "spellparam.hxx" 103 #include "postit.hxx" 104 #include "clipparam.hxx" 105 106 #include "globstr.hrc" 107 #include "scui_def.hxx" //CHINA001 108 #include <svx/svxdlg.hxx> //CHINA001 109 #include <svx/dialogs.hrc> //CHINA001 110 #include "scabstdlg.hxx" //CHINA001 111 #define IS_AVAILABLE(WhichId,ppItem) \ 112 (pReqArgs->GetItemState((WhichId), sal_True, ppItem ) == SFX_ITEM_SET) 113 114 #define C2U(cChar) rtl::OUString::createFromAscii(cChar) 115 116 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> 117 #include <com/sun/star/lang/XInitialization.hpp> 118 #include <com/sun/star/beans/PropertyValue.hpp> 119 #include <com/sun/star/beans/XPropertySet.hpp> 120 #include <cppuhelper/bootstrap.hxx> 121 122 using namespace ::com::sun::star; 123 using namespace ::com::sun::star::beans; 124 using namespace ::com::sun::star::uno; 125 126 //------------------------------------------------------------------ 127 void ScCellShell::ExecuteEdit( SfxRequest& rReq ) 128 { 129 ScModule* pScMod = SC_MOD(); 130 ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 131 SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings(); 132 const SfxItemSet* pReqArgs = rReq.GetArgs(); 133 sal_uInt16 nSlot = rReq.GetSlot(); 134 135 pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox 136 137 // Eingabe beenden 138 if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) ) 139 { 140 switch ( nSlot ) 141 { 142 case FID_DEFINE_NAME: 143 case FID_USE_NAME: 144 case FID_INSERT_NAME: 145 case SID_SPELL_DIALOG: 146 case SID_HANGUL_HANJA_CONVERSION: 147 148 pScMod->InputEnterHandler(); 149 pTabViewShell->UpdateInputHandler(); 150 break; 151 152 default: 153 break; 154 } 155 } 156 157 switch ( nSlot ) 158 { 159 // 160 // Einfuegen / Loeschen von Zellen / Zeilen / Spalten 161 // 162 163 case FID_INS_ROW: 164 pTabViewShell->InsertCells(INS_INSROWS); 165 rReq.Done(); 166 break; 167 168 case FID_INS_COLUMN: 169 pTabViewShell->InsertCells(INS_INSCOLS); 170 rReq.Done(); 171 break; 172 173 case FID_INS_CELLSDOWN: 174 pTabViewShell->InsertCells(INS_CELLSDOWN); 175 rReq.Done(); 176 break; 177 178 case FID_INS_CELLSRIGHT: 179 pTabViewShell->InsertCells(INS_CELLSRIGHT); 180 rReq.Done(); 181 break; 182 183 case SID_DEL_ROWS: 184 pTabViewShell->DeleteCells( DEL_DELROWS ); 185 rReq.Done(); 186 break; 187 188 case SID_DEL_COLS: 189 pTabViewShell->DeleteCells( DEL_DELCOLS ); 190 rReq.Done(); 191 break; 192 193 case FID_INS_CELL: 194 { 195 InsCellCmd eCmd=INS_NONE; 196 197 if ( pReqArgs ) 198 { 199 const SfxPoolItem* pItem; 200 String aFlags; 201 202 if( IS_AVAILABLE( FID_INS_CELL, &pItem ) ) 203 aFlags = ((const SfxStringItem*)pItem)->GetValue(); 204 if( aFlags.Len() ) 205 { 206 switch( aFlags.GetChar(0) ) 207 { 208 case 'V': eCmd = INS_CELLSDOWN ;break; 209 case '>': eCmd = INS_CELLSRIGHT ;break; 210 case 'R': eCmd = INS_INSROWS ;break; 211 case 'C': eCmd = INS_INSCOLS ;break; 212 } 213 } 214 } 215 else 216 { 217 if ( GetViewData()->SimpleColMarked() ) 218 eCmd = INS_INSCOLS; 219 else if ( GetViewData()->SimpleRowMarked() ) 220 eCmd = INS_INSROWS; 221 else 222 { 223 ScDocument* pDoc = GetViewData()->GetDocument(); 224 sal_Bool bTheFlag=(pDoc->GetChangeTrack()!=NULL); 225 226 //CHINA001 ScInsertCellDlg* pDlg = new ScInsertCellDlg( pTabViewShell->GetDialogParent(), 227 //CHINA001 bTheFlag); 228 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 229 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 230 231 AbstractScInsertCellDlg* pDlg = pFact->CreateScInsertCellDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_INSCELL, bTheFlag); 232 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 233 if (pDlg->Execute() == RET_OK) 234 eCmd = pDlg->GetInsCellCmd(); 235 delete pDlg; 236 } 237 } 238 239 if (eCmd!=INS_NONE) 240 { 241 pTabViewShell->InsertCells( eCmd ); 242 243 if( ! rReq.IsAPI() ) 244 { 245 String aParam; 246 247 switch( eCmd ) 248 { 249 case INS_CELLSDOWN: aParam='V'; break; 250 case INS_CELLSRIGHT: aParam='>'; break; 251 case INS_INSROWS: aParam='R'; break; 252 case INS_INSCOLS: aParam='C'; break; 253 default: 254 { 255 // added to avoid warnings 256 } 257 } 258 rReq.AppendItem( SfxStringItem( FID_INS_CELL, aParam ) ); 259 rReq.Done(); 260 } 261 } 262 } 263 break; 264 265 case FID_DELETE_CELL: 266 { 267 DelCellCmd eCmd = DEL_NONE; 268 269 if ( pReqArgs ) 270 { 271 const SfxPoolItem* pItem; 272 String aFlags; 273 274 if( IS_AVAILABLE( FID_DELETE_CELL, &pItem ) ) 275 aFlags = ((const SfxStringItem*)pItem)->GetValue(); 276 if( aFlags.Len() ) 277 { 278 switch( aFlags.GetChar(0) ) 279 { 280 case 'U': eCmd = DEL_CELLSUP ;break; 281 case 'L': eCmd = DEL_CELLSLEFT ;break; 282 case 'R': eCmd = DEL_DELROWS ;break; 283 case 'C': eCmd = DEL_DELCOLS ;break; 284 } 285 } 286 } 287 else 288 { 289 if ( GetViewData()->SimpleColMarked() ) 290 eCmd = DEL_DELCOLS; 291 else if ( GetViewData()->SimpleRowMarked() ) 292 eCmd = DEL_DELROWS; 293 else 294 { 295 ScRange aRange; 296 ScDocument* pDoc = GetViewData()->GetDocument(); 297 sal_Bool bTheFlag=GetViewData()->IsMultiMarked() || 298 (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE_FILTERED) || 299 (pDoc->GetChangeTrack() != NULL); 300 301 //CHINA001 ScDeleteCellDlg* pDlg = new ScDeleteCellDlg( 302 //CHINA001 pTabViewShell->GetDialogParent(),bTheFlag); 303 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 304 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 305 306 AbstractScDeleteCellDlg* pDlg = pFact->CreateScDeleteCellDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_DELCELL, bTheFlag ); 307 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 308 309 if (pDlg->Execute() == RET_OK) 310 eCmd = pDlg->GetDelCellCmd(); 311 delete pDlg; 312 } 313 } 314 315 if (eCmd != DEL_NONE ) 316 { 317 pTabViewShell->DeleteCells( eCmd ); 318 319 if( ! rReq.IsAPI() ) 320 { 321 String aParam; 322 323 switch( eCmd ) 324 { 325 case DEL_CELLSUP: aParam='U'; break; 326 case DEL_CELLSLEFT: aParam='L'; break; 327 case DEL_DELROWS: aParam='R'; break; 328 case DEL_DELCOLS: aParam='C'; break; 329 default: 330 { 331 // added to avoid warnings 332 } 333 } 334 rReq.AppendItem( SfxStringItem( FID_DELETE_CELL, aParam ) ); 335 rReq.Done(); 336 } 337 } 338 } 339 break; 340 341 // 342 // Inhalte von Zellen loeschen 343 // 344 345 case SID_DELETE_CONTENTS: 346 pTabViewShell->DeleteContents( IDF_CONTENTS ); 347 rReq.Done(); 348 break; 349 350 case SID_DELETE: 351 { 352 sal_uInt16 nFlags = IDF_NONE; 353 354 if ( pReqArgs!=NULL && pTabViewShell->SelectionEditable() ) 355 { 356 const SfxPoolItem* pItem; 357 String aFlags = 'A'; 358 359 if( IS_AVAILABLE( SID_DELETE, &pItem ) ) 360 aFlags = ((const SfxStringItem*)pItem)->GetValue(); 361 362 aFlags.ToUpperAscii(); 363 sal_Bool bCont = sal_True; 364 365 for( xub_StrLen i=0 ; bCont && i<aFlags.Len() ; i++ ) 366 { 367 switch( aFlags.GetChar(i) ) 368 { 369 case 'A': // Alle 370 nFlags |= IDF_ALL; 371 bCont = sal_False; // nicht mehr weitermachen! 372 break; 373 case 'S': nFlags |= IDF_STRING; break; 374 case 'V': nFlags |= IDF_VALUE; break; 375 case 'D': nFlags |= IDF_DATETIME; break; 376 case 'F': nFlags |= IDF_FORMULA; break; 377 case 'N': nFlags |= IDF_NOTE; break; 378 case 'T': nFlags |= IDF_ATTRIB; break; 379 case 'O': nFlags |= IDF_OBJECTS; break; 380 } 381 } 382 } 383 else 384 { 385 ScEditableTester aTester( pTabViewShell ); 386 if (aTester.IsEditable()) 387 { 388 //CHINA001 ScDeleteContentsDlg* pDlg = new ScDeleteContentsDlg( pTabViewShell->GetDialogParent() ); 389 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 390 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 391 392 AbstractScDeleteContentsDlg* pDlg = pFact->CreateScDeleteContentsDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_DELCONT ); 393 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 394 ScDocument* pDoc = GetViewData()->GetDocument(); 395 SCTAB nTab = GetViewData()->GetTabNo(); 396 if ( pDoc->IsTabProtected(nTab) ) 397 pDlg->DisableObjects(); 398 if (pDlg->Execute() == RET_OK) 399 { 400 nFlags = pDlg->GetDelContentsCmdBits(); 401 } 402 delete pDlg; 403 } 404 else 405 pTabViewShell->ErrorMessage(aTester.GetMessageId()); 406 } 407 408 if( nFlags != IDF_NONE ) 409 { 410 pTabViewShell->DeleteContents( nFlags ); 411 412 if( ! rReq.IsAPI() ) 413 { 414 String aFlags; 415 416 if( nFlags == IDF_ALL ) 417 { 418 aFlags += 'A'; 419 } 420 else 421 { 422 if( nFlags & IDF_STRING ) aFlags += 'S'; 423 if( nFlags & IDF_VALUE ) aFlags += 'V'; 424 if( nFlags & IDF_DATETIME ) aFlags += 'D'; 425 if( nFlags & IDF_FORMULA ) aFlags += 'F'; 426 if( nFlags & IDF_NOTE ) aFlags += 'N'; 427 if( nFlags & IDF_ATTRIB ) aFlags += 'T'; 428 if( nFlags & IDF_OBJECTS ) aFlags += 'O'; 429 } 430 431 rReq.AppendItem( SfxStringItem( SID_DELETE, aFlags ) ); 432 rReq.Done(); 433 } 434 } 435 } 436 break; 437 438 // 439 // Ausfuellen... 440 // 441 442 case FID_FILL_TO_BOTTOM: 443 pTabViewShell->FillSimple( FILL_TO_BOTTOM ); 444 rReq.Done(); 445 break; 446 447 case FID_FILL_TO_RIGHT: 448 pTabViewShell->FillSimple( FILL_TO_RIGHT ); 449 rReq.Done(); 450 break; 451 452 case FID_FILL_TO_TOP: 453 pTabViewShell->FillSimple( FILL_TO_TOP ); 454 rReq.Done(); 455 break; 456 457 case FID_FILL_TO_LEFT: 458 pTabViewShell->FillSimple( FILL_TO_LEFT ); 459 rReq.Done(); 460 break; 461 462 case FID_FILL_TAB: 463 { 464 sal_uInt16 nFlags = IDF_NONE; 465 sal_uInt16 nFunction = PASTE_NOFUNC; 466 sal_Bool bSkipEmpty = sal_False; 467 sal_Bool bAsLink = sal_False; 468 469 if ( pReqArgs!=NULL && pTabViewShell->SelectionEditable() ) 470 { 471 const SfxPoolItem* pItem; 472 String aFlags = 'A'; 473 474 if( IS_AVAILABLE( FID_FILL_TAB, &pItem ) ) 475 aFlags = ((const SfxStringItem*)pItem)->GetValue(); 476 477 aFlags.ToUpperAscii(); 478 sal_Bool bCont = sal_True; 479 480 for( xub_StrLen i=0 ; bCont && i<aFlags.Len() ; i++ ) 481 { 482 switch( aFlags.GetChar(i) ) 483 { 484 case 'A': // Alle 485 nFlags |= IDF_ALL; 486 bCont = sal_False; // nicht mehr weitermachen! 487 break; 488 case 'S': nFlags |= IDF_STRING; break; 489 case 'V': nFlags |= IDF_VALUE; break; 490 case 'D': nFlags |= IDF_DATETIME; break; 491 case 'F': nFlags |= IDF_FORMULA; break; 492 case 'N': nFlags |= IDF_NOTE; break; 493 case 'T': nFlags |= IDF_ATTRIB; break; 494 } 495 } 496 } 497 else 498 { 499 //CHINA001 ScInsertContentsDlg* pDlg = 500 //CHINA001 new ScInsertContentsDlg(pTabViewShell->GetDialogParent(), 501 //CHINA001 0, /* nCheckDefaults */ 502 //CHINA001 &ScGlobal::GetRscString(STR_FILL_TAB) ); 503 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 504 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 505 506 AbstractScInsertContentsDlg* pDlg = pFact->CreateScInsertContentsDlg( pTabViewShell->GetDialogParent(), 507 RID_SCDLG_INSCONT, 0, /* nCheckDefaults */ 508 &ScGlobal::GetRscString(STR_FILL_TAB)); 509 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 510 pDlg->SetFillMode(sal_True); 511 512 if (pDlg->Execute() == RET_OK) 513 { 514 nFlags = pDlg->GetInsContentsCmdBits(); 515 nFunction = pDlg->GetFormulaCmdBits(); 516 bSkipEmpty = pDlg->IsSkipEmptyCells(); 517 bAsLink = pDlg->IsLink(); 518 // MoveMode gibt's bei Tabelle fuellen nicht 519 } 520 delete pDlg; 521 } 522 523 if( nFlags != IDF_NONE ) 524 { 525 pTabViewShell->FillTab( nFlags, nFunction, bSkipEmpty, bAsLink ); 526 527 if( ! rReq.IsAPI() ) 528 { 529 String aFlags; 530 531 if( nFlags == IDF_ALL ) 532 { 533 aFlags += 'A'; 534 } 535 else 536 { 537 if( nFlags & IDF_STRING ) aFlags += 'S'; 538 if( nFlags & IDF_VALUE ) aFlags += 'V'; 539 if( nFlags & IDF_DATETIME ) aFlags += 'D'; 540 if( nFlags & IDF_FORMULA ) aFlags += 'F'; 541 if( nFlags & IDF_NOTE ) aFlags += 'N'; 542 if( nFlags & IDF_ATTRIB ) aFlags += 'T'; 543 } 544 545 rReq.AppendItem( SfxStringItem( FID_FILL_TAB, aFlags ) ); 546 rReq.Done(); 547 } 548 } 549 } 550 break; 551 552 case FID_FILL_SERIES: 553 { 554 SCCOL nStartCol; 555 SCROW nStartRow; 556 SCTAB nStartTab; 557 SCCOL nEndCol; 558 SCROW nEndRow; 559 SCTAB nEndTab; 560 sal_uInt16 nPossDir = FDS_OPT_NONE; 561 FillDir eFillDir = FILL_TO_BOTTOM; 562 FillCmd eFillCmd = FILL_LINEAR; 563 FillDateCmd eFillDateCmd = FILL_DAY; 564 double fStartVal = MAXDOUBLE; 565 double fIncVal = 1; 566 double fMaxVal = MAXDOUBLE; 567 sal_Bool bDoIt = sal_False; 568 569 GetViewData()->GetSimpleArea( nStartCol, nStartRow, nStartTab, 570 nEndCol, nEndRow, nEndTab ); 571 572 if( nStartCol!=nEndCol ) 573 { 574 nPossDir |= FDS_OPT_HORZ; 575 eFillDir=FILL_TO_RIGHT; 576 } 577 578 if( nStartRow!=nEndRow ) 579 { 580 nPossDir |= FDS_OPT_VERT; 581 eFillDir=FILL_TO_BOTTOM; 582 } 583 584 ScDocument* pDoc = GetViewData()->GetDocument(); 585 SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); 586 587 if( pReqArgs ) 588 { 589 const SfxPoolItem* pItem; 590 String aFillDir, aFillCmd, aFillDateCmd; 591 String aFillStep, aFillStart, aFillMax; 592 sal_uInt32 nKey; 593 double fTmpVal; 594 595 bDoIt=sal_False; 596 597 if( IS_AVAILABLE( FID_FILL_SERIES, &pItem ) ) 598 aFillDir = ((const SfxStringItem*)pItem)->GetValue(); 599 if( IS_AVAILABLE( FN_PARAM_1, &pItem ) ) 600 aFillCmd = ((const SfxStringItem*)pItem)->GetValue(); 601 if( IS_AVAILABLE( FN_PARAM_2, &pItem ) ) 602 aFillDateCmd = ((const SfxStringItem*)pItem)->GetValue(); 603 if( IS_AVAILABLE( FN_PARAM_3, &pItem ) ) 604 aFillStep = ((const SfxStringItem*)pItem)->GetValue(); 605 if( IS_AVAILABLE( FN_PARAM_4, &pItem ) ) 606 aFillStart = ((const SfxStringItem*)pItem)->GetValue(); 607 if( IS_AVAILABLE( FN_PARAM_5, &pItem ) ) 608 aFillMax = ((const SfxStringItem*)pItem)->GetValue(); 609 610 if( aFillDir.Len() ) 611 switch( aFillDir.GetChar(0) ) 612 { 613 case 'B': case 'b': eFillDir=FILL_TO_BOTTOM; break; 614 case 'R': case 'r': eFillDir=FILL_TO_RIGHT; break; 615 case 'T': case 't': eFillDir=FILL_TO_TOP; break; 616 case 'L': case 'l': eFillDir=FILL_TO_LEFT; break; 617 } 618 619 if( aFillCmd.Len() ) 620 switch( aFillCmd.GetChar(0) ) 621 { 622 case 'S': case 's': eFillCmd=FILL_SIMPLE; break; 623 case 'L': case 'l': eFillCmd=FILL_LINEAR; break; 624 case 'G': case 'g': eFillCmd=FILL_GROWTH; break; 625 case 'D': case 'd': eFillCmd=FILL_DATE; break; 626 case 'A': case 'a': eFillCmd=FILL_AUTO; break; 627 } 628 629 if( aFillDateCmd.Len() ) 630 switch( aFillDateCmd.GetChar(0) ) 631 { 632 case 'D': case 'd': eFillDateCmd=FILL_DAY; break; 633 case 'W': case 'w': eFillDateCmd=FILL_WEEKDAY; break; 634 case 'M': case 'm': eFillDateCmd=FILL_MONTH; break; 635 case 'Y': case 'y': eFillDateCmd=FILL_YEAR; break; 636 } 637 638 nKey = 0; 639 if( pFormatter->IsNumberFormat( aFillStart, nKey, fTmpVal )) 640 fStartVal = fTmpVal; 641 642 nKey = 0; 643 if( pFormatter->IsNumberFormat( aFillStep, nKey, fTmpVal )) 644 fIncVal = fTmpVal; 645 646 nKey = 0; 647 if( pFormatter->IsNumberFormat( aFillMax, nKey, fTmpVal )) 648 fMaxVal = fTmpVal; 649 650 bDoIt = sal_True; 651 652 } 653 else // (pReqArgs == NULL) => Dialog hochziehen 654 { 655 // 656 sal_uInt32 nPrivFormat; 657 CellType eCellType; 658 pDoc->GetNumberFormat( nStartCol, nStartRow, nStartTab, nPrivFormat ); 659 pDoc->GetCellType( nStartCol, nStartRow, nStartTab,eCellType ); 660 const SvNumberformat* pPrivEntry = pFormatter->GetEntry( nPrivFormat ); 661 if (!pPrivEntry) 662 { 663 DBG_ERROR("Zahlformat nicht gefunden !!!"); 664 } 665 else 666 { 667 short nPrivType = pPrivEntry->GetType(); 668 if ( ( nPrivType & NUMBERFORMAT_DATE)>0) 669 { 670 eFillCmd=FILL_DATE; 671 } 672 else if(eCellType==CELLTYPE_STRING) 673 { 674 eFillCmd=FILL_AUTO; 675 } 676 } 677 678 // 679 String aStartStr; 680 681 // Startwert nur vorbelegen, wenn nur 1 Zeile oder Spalte: 682 if ( nStartCol == nEndCol || nStartRow == nEndRow ) 683 { 684 double fInputEndVal = 0.0; 685 String aEndStr; 686 687 pDoc->GetInputString( nStartCol, nStartRow, nStartTab, aStartStr); 688 pDoc->GetValue( nStartCol, nStartRow, nStartTab, fStartVal ); 689 690 691 if(eFillDir==FILL_TO_BOTTOM && nStartRow < nEndRow ) 692 { 693 pDoc->GetInputString( nStartCol, nStartRow+1, nStartTab, aEndStr); 694 if(aEndStr.Len()>0) 695 { 696 pDoc->GetValue( nStartCol, nStartRow+1, nStartTab, fInputEndVal); 697 fIncVal=fInputEndVal-fStartVal; 698 } 699 } 700 else 701 { 702 if(nStartCol < nEndCol) 703 { 704 pDoc->GetInputString( nStartCol+1, nStartRow, nStartTab, aEndStr); 705 if(aEndStr.Len()>0) 706 { 707 pDoc->GetValue( nStartCol+1, nStartRow, nStartTab, fInputEndVal); 708 fIncVal=fInputEndVal-fStartVal; 709 } 710 } 711 } 712 if(eFillCmd==FILL_DATE) 713 { 714 Date aNullDate = *pDoc->GetFormatTable()->GetNullDate(); 715 Date aStartDate = aNullDate; 716 aStartDate+= (long)fStartVal; 717 Date aEndDate = aNullDate; 718 aEndDate+= (long)fInputEndVal; 719 double fTempDate=0; 720 721 if(aStartDate.GetYear()!=aEndDate.GetYear()) 722 { 723 eFillDateCmd = FILL_YEAR; 724 fTempDate=aEndDate.GetYear()-aStartDate.GetYear(); 725 } 726 if(aStartDate.GetMonth()!=aEndDate.GetMonth()) 727 { 728 eFillDateCmd = FILL_MONTH; 729 fTempDate=fTempDate*12+aEndDate.GetMonth()-aStartDate.GetMonth(); 730 } 731 if(aStartDate.GetDay()==aEndDate.GetDay()) 732 { 733 fIncVal=fTempDate; 734 } 735 } 736 } 737 //CHINA001 ScFillSeriesDlg* pDlg = new ScFillSeriesDlg( 738 //CHINA001 pTabViewShell->GetDialogParent(), *pDoc, 739 //CHINA001 eFillDir, eFillCmd, eFillDateCmd, 740 //CHINA001 aStartStr, fIncVal, fMaxVal, 741 //CHINA001 nPossDir); 742 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 743 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 744 745 AbstractScFillSeriesDlg* pDlg = pFact->CreateScFillSeriesDlg( pTabViewShell->GetDialogParent(), 746 *pDoc, 747 eFillDir, eFillCmd, eFillDateCmd, 748 aStartStr, fIncVal, fMaxVal, 749 nPossDir, 750 RID_SCDLG_FILLSERIES); 751 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 752 753 if ( nStartCol != nEndCol && nStartRow != nEndRow ) 754 { 755 pDlg->SetEdStartValEnabled(sal_False); 756 } 757 758 if ( pDlg->Execute() == RET_OK ) 759 { 760 eFillDir = pDlg->GetFillDir(); 761 eFillCmd = pDlg->GetFillCmd(); 762 eFillDateCmd = pDlg->GetFillDateCmd(); 763 764 if(eFillCmd==FILL_AUTO) 765 { 766 String aStr=pDlg->GetStartStr(); 767 if(aStr.Len()>0) 768 pTabViewShell->EnterData( nStartCol, nStartRow, nStartTab, aStr ); 769 } 770 fStartVal = pDlg->GetStart(); 771 fIncVal = pDlg->GetStep(); 772 fMaxVal = pDlg->GetMax(); 773 bDoIt = sal_True; 774 } 775 delete pDlg; 776 } 777 778 if( bDoIt ) 779 { 780 //nScFillModeMouseModifier = 0; // kein Ctrl/Copy 781 pTabViewShell->FillSeries( eFillDir, eFillCmd, eFillDateCmd, fStartVal, fIncVal, fMaxVal ); 782 783 if( ! rReq.IsAPI() ) 784 { 785 String aPara; 786 Color* pColor=0; 787 788 switch( eFillDir ) 789 { 790 case FILL_TO_BOTTOM: aPara = 'B'; break; 791 case FILL_TO_RIGHT: aPara = 'R'; break; 792 case FILL_TO_TOP: aPara = 'T'; break; 793 case FILL_TO_LEFT: aPara = 'L'; break; 794 default: aPara.Erase(); break; 795 } 796 rReq.AppendItem( SfxStringItem( FID_FILL_SERIES, aPara ) ); 797 798 switch( eFillCmd ) 799 { 800 case FILL_SIMPLE: aPara = 'S'; break; 801 case FILL_LINEAR: aPara = 'L'; break; 802 case FILL_GROWTH: aPara = 'G'; break; 803 case FILL_DATE: aPara = 'D'; break; 804 case FILL_AUTO: aPara = 'A'; break; 805 default: aPara.Erase(); break; 806 } 807 rReq.AppendItem( SfxStringItem( FN_PARAM_1, aPara ) ); 808 809 switch( eFillDateCmd ) 810 { 811 case FILL_DAY: aPara = 'D'; break; 812 case FILL_WEEKDAY: aPara = 'W'; break; 813 case FILL_MONTH: aPara = 'M'; break; 814 case FILL_YEAR: aPara = 'Y'; break; 815 default: aPara.Erase(); break; 816 } 817 rReq.AppendItem( SfxStringItem( FN_PARAM_2, aPara ) ); 818 819 sal_uLong nFormatKey = pFormatter->GetStandardFormat(NUMBERFORMAT_NUMBER, 820 ScGlobal::eLnge ); 821 822 pFormatter->GetOutputString( fIncVal, nFormatKey, aPara, &pColor ); 823 rReq.AppendItem( SfxStringItem( FN_PARAM_3, aPara ) ); 824 825 pFormatter->GetOutputString( fStartVal, nFormatKey, aPara, &pColor ); 826 rReq.AppendItem( SfxStringItem( FN_PARAM_4, aPara ) ); 827 828 pFormatter->GetOutputString( fMaxVal, nFormatKey, aPara, &pColor ); 829 rReq.AppendItem( SfxStringItem( FN_PARAM_5, aPara ) ); 830 831 rReq.Done(); 832 } 833 } 834 } 835 break; 836 837 case FID_FILL_AUTO: 838 { 839 SCCOL nStartCol; 840 SCROW nStartRow; 841 SCCOL nEndCol; 842 SCROW nEndRow; 843 SCTAB nStartTab, nEndTab; 844 845 GetViewData()->GetFillData( nStartCol, nStartRow, nEndCol, nEndRow ); 846 SCCOL nFillCol = GetViewData()->GetRefEndX(); 847 SCROW nFillRow = GetViewData()->GetRefEndY(); 848 ScDocument* pDoc = GetViewData()->GetDocument(); 849 850 if( pReqArgs != NULL ) 851 { 852 const SfxPoolItem* pItem; 853 854 if( IS_AVAILABLE( FID_FILL_AUTO, &pItem ) ) 855 { 856 ScAddress aScAddress; 857 String aArg = ((const SfxStringItem*)pItem)->GetValue(); 858 859 if( aScAddress.Parse( aArg, pDoc, pDoc->GetAddressConvention() ) & SCA_VALID ) 860 { 861 nFillRow = aScAddress.Row(); 862 nFillCol = aScAddress.Col(); 863 } 864 } 865 866 GetViewData()->GetSimpleArea( nStartCol,nStartRow,nStartTab, 867 nEndCol,nEndRow,nEndTab ); 868 } 869 else // Aufruf per Maus 870 { 871 // #55284# nicht innerhalb einer zusammengefassten Zelle 872 873 if ( nStartCol == nEndCol && nStartRow == nEndRow ) 874 { 875 SCCOL nMergeCol = nStartCol; 876 SCROW nMergeRow = nStartRow; 877 if ( GetViewData()->GetDocument()->ExtendMerge( 878 nStartCol, nStartRow, nMergeCol, nMergeRow, 879 GetViewData()->GetTabNo() ) ) 880 { 881 if ( nFillCol >= nStartCol && nFillCol <= nMergeCol && nFillRow == nStartRow ) 882 nFillCol = nStartCol; 883 if ( nFillRow >= nStartRow && nFillRow <= nMergeRow && nFillCol == nStartCol ) 884 nFillRow = nStartRow; 885 } 886 } 887 } 888 889 if ( nFillCol != nEndCol || nFillRow != nEndRow ) 890 { 891 if ( nFillCol==nEndCol || nFillRow==nEndRow ) 892 { 893 FillDir eDir = FILL_TO_BOTTOM; 894 SCCOLROW nCount = 0; 895 896 if ( nFillCol==nEndCol ) 897 { 898 if ( nFillRow > nEndRow ) 899 { 900 eDir = FILL_TO_BOTTOM; 901 nCount = nFillRow - nEndRow; 902 } 903 else if ( nFillRow < nStartRow ) 904 { 905 eDir = FILL_TO_TOP; 906 nCount = nStartRow - nFillRow; 907 } 908 } 909 else 910 { 911 if ( nFillCol > nEndCol ) 912 { 913 eDir = FILL_TO_RIGHT; 914 nCount = nFillCol - nEndCol; 915 } 916 else if ( nFillCol < nStartCol ) 917 { 918 eDir = FILL_TO_LEFT; 919 nCount = nStartCol - nFillCol; 920 } 921 } 922 923 if ( nCount != 0) 924 { 925 pTabViewShell->FillAuto( eDir, nStartCol, nStartRow, nEndCol, nEndRow, nCount ); 926 927 if( ! rReq.IsAPI() ) 928 { 929 String aAdrStr; 930 ScAddress aAdr( nFillCol, nFillRow, 0 ); 931 aAdr.Format( aAdrStr, SCR_ABS, pDoc, pDoc->GetAddressConvention() ); 932 933 rReq.AppendItem( SfxStringItem( FID_FILL_AUTO, aAdrStr ) ); 934 rReq.Done(); 935 } 936 } 937 938 } 939 else 940 { 941 DBG_ERROR( "Richtung nicht eindeutig fuer AutoFill" ); 942 } 943 } 944 } 945 break; 946 947 // 948 // Gliederung (Outlines) 949 // SID_AUTO_OUTLINE, SID_OUTLINE_DELETEALL in Execute (in docsh.idl) 950 // 951 952 case SID_OUTLINE_HIDE: 953 if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(), 954 GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) ) 955 pTabViewShell->SetDataPilotDetails( sal_False ); 956 else 957 pTabViewShell->HideMarkedOutlines(); 958 rReq.Done(); 959 break; 960 961 case SID_OUTLINE_SHOW: 962 { 963 ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(), 964 GetViewData()->GetCurY(), GetViewData()->GetTabNo() ); 965 if ( pDPObj ) 966 { 967 Sequence<sheet::DataPilotFieldFilter> aFilters; 968 sal_uInt16 nOrientation; 969 if ( pTabViewShell->HasSelectionForDrillDown( nOrientation ) ) 970 { 971 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 972 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 973 974 AbstractScDPShowDetailDlg* pDlg = pFact->CreateScDPShowDetailDlg( 975 pTabViewShell->GetDialogParent(), RID_SCDLG_DPSHOWDETAIL, *pDPObj, nOrientation ); 976 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 977 if ( pDlg->Execute() == RET_OK ) 978 { 979 String aNewDimName( pDlg->GetDimensionName() ); 980 pTabViewShell->SetDataPilotDetails( sal_True, &aNewDimName ); 981 } 982 } 983 else if ( !pDPObj->IsServiceData() && 984 pDPObj->GetDataFieldPositionData( 985 ScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ), 986 aFilters ) ) 987 pTabViewShell->ShowDataPilotSourceData( *pDPObj, aFilters ); 988 else 989 pTabViewShell->SetDataPilotDetails( sal_True ); 990 } 991 else 992 pTabViewShell->ShowMarkedOutlines(); 993 rReq.Done(); 994 } 995 break; 996 997 case SID_OUTLINE_MAKE: 998 { 999 sal_Bool bColumns = sal_False; 1000 sal_Bool bOk = sal_True; 1001 1002 if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(), 1003 GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) ) 1004 { 1005 ScDPNumGroupInfo aNumInfo; 1006 aNumInfo.Enable = sal_True; 1007 aNumInfo.AutoStart = sal_True; 1008 aNumInfo.AutoEnd = sal_True; 1009 sal_Int32 nParts = 0; 1010 if ( pTabViewShell->HasSelectionForDateGroup( aNumInfo, nParts ) ) 1011 { 1012 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 1013 DBG_ASSERT( pFact, "ScAbstractFactory create fail!" ); 1014 Date aNullDate( *GetViewData()->GetDocument()->GetFormatTable()->GetNullDate() ); 1015 AbstractScDPDateGroupDlg* pDlg = pFact->CreateScDPDateGroupDlg( 1016 pTabViewShell->GetDialogParent(), RID_SCDLG_DPDATEGROUP, 1017 aNumInfo, nParts, aNullDate ); 1018 DBG_ASSERT( pDlg, "Dialog create fail!" ); 1019 if( pDlg->Execute() == RET_OK ) 1020 { 1021 aNumInfo = pDlg->GetGroupInfo(); 1022 pTabViewShell->DateGroupDataPilot( aNumInfo, pDlg->GetDatePart() ); 1023 } 1024 } 1025 else if ( pTabViewShell->HasSelectionForNumGroup( aNumInfo ) ) 1026 { 1027 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 1028 DBG_ASSERT( pFact, "ScAbstractFactory create fail!" ); 1029 AbstractScDPNumGroupDlg* pDlg = pFact->CreateScDPNumGroupDlg( 1030 pTabViewShell->GetDialogParent(), RID_SCDLG_DPNUMGROUP, aNumInfo ); 1031 DBG_ASSERT( pDlg, "Dialog create fail!" ); 1032 if( pDlg->Execute() == RET_OK ) 1033 pTabViewShell->NumGroupDataPilot( pDlg->GetGroupInfo() ); 1034 } 1035 else 1036 pTabViewShell->GroupDataPilot(); 1037 1038 bOk = sal_False; 1039 } 1040 else if( pReqArgs != NULL ) 1041 { 1042 const SfxPoolItem* pItem; 1043 bOk = sal_False; 1044 1045 if( IS_AVAILABLE( SID_OUTLINE_MAKE, &pItem ) ) 1046 { 1047 String aCol = ((const SfxStringItem*)pItem)->GetValue(); 1048 aCol.ToUpperAscii(); 1049 1050 switch( aCol.GetChar(0) ) 1051 { 1052 case 'R': bColumns=sal_False; bOk = sal_True;break; 1053 case 'C': bColumns=sal_True; bOk = sal_True;break; 1054 } 1055 } 1056 } 1057 else // Dialog, wenn nicht ganze Zeilen/Spalten markiert 1058 { 1059 if ( GetViewData()->SimpleColMarked() && !GetViewData()->SimpleRowMarked() ) 1060 bColumns = sal_True; 1061 else if ( !GetViewData()->SimpleColMarked() && GetViewData()->SimpleRowMarked() ) 1062 bColumns = sal_False; 1063 else 1064 { 1065 //CHINA001 ScGroupDlg* pDlg = new ScGroupDlg(pTabViewShell->GetDialogParent(), 1066 //CHINA001 RID_SCDLG_GRP_MAKE, sal_False ); 1067 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 1068 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 1069 1070 AbstractScGroupDlg* pDlg = pFact->CreateAbstractScGroupDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_GRP_MAKE, RID_SCDLG_GRP_MAKE,sal_False); 1071 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 1072 if ( pDlg->Execute() == RET_OK ) 1073 bColumns = pDlg->GetColsChecked(); 1074 else 1075 bOk = sal_False; 1076 delete pDlg; 1077 } 1078 } 1079 if (bOk) 1080 { 1081 pTabViewShell->MakeOutline( bColumns ); 1082 1083 if( ! rReq.IsAPI() ) 1084 { 1085 String aCol = bColumns ? 'C' : 'R'; 1086 rReq.AppendItem( SfxStringItem( SID_OUTLINE_MAKE, aCol ) ); 1087 rReq.Done(); 1088 } 1089 } 1090 } 1091 break; 1092 1093 case SID_OUTLINE_REMOVE: 1094 { 1095 sal_Bool bColumns = sal_False; 1096 sal_Bool bOk = sal_True; 1097 1098 if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(), 1099 GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) ) 1100 { 1101 pTabViewShell->UngroupDataPilot(); 1102 bOk = sal_False; 1103 } 1104 else if( pReqArgs != NULL ) 1105 { 1106 const SfxPoolItem* pItem; 1107 bOk = sal_False; 1108 1109 if( IS_AVAILABLE( SID_OUTLINE_REMOVE, &pItem ) ) 1110 { 1111 String aCol = ((const SfxStringItem*)pItem)->GetValue(); 1112 aCol.ToUpperAscii(); 1113 1114 switch( aCol.GetChar(0) ) 1115 { 1116 case 'R': bColumns=sal_False; bOk = sal_True;break; 1117 case 'C': bColumns=sal_True; bOk = sal_True;break; 1118 } 1119 } 1120 } 1121 else // Dialog nur, wenn Aufheben fuer Zeilen und Spalten moeglich 1122 { 1123 sal_Bool bColPoss, bRowPoss; 1124 pTabViewShell->TestRemoveOutline( bColPoss, bRowPoss ); 1125 if ( bColPoss && bRowPoss ) 1126 { 1127 //CHINA001 ScGroupDlg* pDlg = new ScGroupDlg( pTabViewShell->GetDialogParent(), 1128 //CHINA001 RID_SCDLG_GRP_KILL, sal_True ); 1129 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 1130 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 1131 1132 AbstractScGroupDlg* pDlg = pFact->CreateAbstractScGroupDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_GRP_KILL, RID_SCDLG_GRP_KILL,sal_True); 1133 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 1134 if ( pDlg->Execute() == RET_OK ) 1135 bColumns = pDlg->GetColsChecked(); 1136 else 1137 bOk = sal_False; 1138 delete pDlg; 1139 } 1140 else if ( bColPoss ) 1141 bColumns = sal_True; 1142 else if ( bRowPoss ) 1143 bColumns = sal_False; 1144 else 1145 bOk = sal_False; 1146 } 1147 if (bOk) 1148 { 1149 pTabViewShell->RemoveOutline( bColumns ); 1150 1151 if( ! rReq.IsAPI() ) 1152 { 1153 String aCol = bColumns ? 'C' : 'R'; 1154 rReq.AppendItem( SfxStringItem( SID_OUTLINE_REMOVE, aCol ) ); 1155 rReq.Done(); 1156 } 1157 } 1158 } 1159 break; 1160 1161 // 1162 // Clipboard 1163 // 1164 1165 case SID_COPY: // fuer Grafiken in DrawShell 1166 { 1167 WaitObject aWait( GetViewData()->GetDialogParent() ); 1168 pTabViewShell->CopyToClip( NULL, sal_False, sal_False, sal_True ); 1169 rReq.Done(); 1170 } 1171 break; 1172 1173 case SID_CUT: // fuer Grafiken in DrawShell 1174 { 1175 WaitObject aWait( GetViewData()->GetDialogParent() ); 1176 pTabViewShell->CutToClip( NULL, sal_True ); 1177 rReq.Done(); 1178 } 1179 break; 1180 1181 case SID_PASTE: 1182 { 1183 PasteFromClipboard ( GetViewData(), pTabViewShell, true ); 1184 rReq.Done(); 1185 } 1186 break; 1187 1188 case SID_CLIPBOARD_FORMAT_ITEMS: 1189 { 1190 WaitObject aWait( GetViewData()->GetDialogParent() ); 1191 1192 sal_uLong nFormat = 0; 1193 const SfxPoolItem* pItem; 1194 if ( pReqArgs && 1195 pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET && 1196 pItem->ISA(SfxUInt32Item) ) 1197 { 1198 nFormat = ((const SfxUInt32Item*)pItem)->GetValue(); 1199 } 1200 1201 if ( nFormat ) 1202 { 1203 Window* pWin = GetViewData()->GetActiveWin(); 1204 sal_Bool bCells = ( ScTransferObj::GetOwnClipboard( pWin ) != NULL ); 1205 sal_Bool bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL ); 1206 sal_Bool bOle = ( nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE ); 1207 1208 if ( bCells && bOle ) 1209 pTabViewShell->PasteFromSystem(); 1210 else if ( bDraw && bOle ) 1211 pTabViewShell->PasteDraw(); 1212 else 1213 pTabViewShell->PasteFromSystem(nFormat); 1214 } 1215 //?else 1216 //? pTabViewShell->PasteFromSystem(); 1217 1218 rReq.Done(); 1219 } 1220 pTabViewShell->CellContentChanged(); 1221 break; 1222 1223 case FID_INS_CELL_CONTENTS: 1224 { 1225 sal_uInt16 nFlags = IDF_NONE; 1226 sal_uInt16 nFunction = PASTE_NOFUNC; 1227 sal_Bool bSkipEmpty = sal_False; 1228 sal_Bool bTranspose = sal_False; 1229 sal_Bool bAsLink = sal_False; 1230 InsCellCmd eMoveMode = INS_NONE; 1231 1232 Window* pWin = GetViewData()->GetActiveWin(); 1233 ScDocument* pDoc = GetViewData()->GetDocument(); 1234 sal_Bool bOtherDoc = !pDoc->IsClipboardSource(); 1235 ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin ); 1236 if ( pOwnClip ) 1237 { 1238 // #129384# keep a reference in case the clipboard is changed during dialog or PasteFromClip 1239 uno::Reference<datatransfer::XTransferable> aOwnClipRef( pOwnClip ); 1240 if ( pReqArgs!=NULL && pTabViewShell->SelectionEditable() ) 1241 { 1242 const SfxPoolItem* pItem; 1243 String aFlags = 'A'; 1244 1245 if( IS_AVAILABLE( FID_INS_CELL_CONTENTS, &pItem ) ) 1246 aFlags = ((const SfxStringItem*)pItem)->GetValue(); 1247 1248 aFlags.ToUpperAscii(); 1249 sal_Bool bCont = sal_True; 1250 1251 for( xub_StrLen i=0 ; bCont && i<aFlags.Len() ; i++ ) 1252 { 1253 switch( aFlags.GetChar(i) ) 1254 { 1255 case 'A': // Alle 1256 nFlags |= IDF_ALL; 1257 bCont = sal_False; // nicht mehr weitermachen! 1258 break; 1259 case 'S': nFlags |= IDF_STRING; break; 1260 case 'V': nFlags |= IDF_VALUE; break; 1261 case 'D': nFlags |= IDF_DATETIME; break; 1262 case 'F': nFlags |= IDF_FORMULA; break; 1263 case 'N': nFlags |= IDF_NOTE; break; 1264 case 'T': nFlags |= IDF_ATTRIB; break; 1265 } 1266 } 1267 1268 SFX_REQUEST_ARG( rReq, pFuncItem, SfxUInt16Item, FN_PARAM_1, sal_False ); 1269 SFX_REQUEST_ARG( rReq, pSkipItem, SfxBoolItem, FN_PARAM_2, sal_False ); 1270 SFX_REQUEST_ARG( rReq, pTransposeItem, SfxBoolItem, FN_PARAM_3, sal_False ); 1271 SFX_REQUEST_ARG( rReq, pLinkItem, SfxBoolItem, FN_PARAM_4, sal_False ); 1272 SFX_REQUEST_ARG( rReq, pMoveItem, SfxInt16Item, FN_PARAM_5, sal_False ); 1273 if ( pFuncItem ) 1274 nFunction = pFuncItem->GetValue(); 1275 if ( pSkipItem ) 1276 bSkipEmpty = pSkipItem->GetValue(); 1277 if ( pTransposeItem ) 1278 bTranspose = pTransposeItem->GetValue(); 1279 if ( pLinkItem ) 1280 bAsLink = pLinkItem->GetValue(); 1281 if ( pMoveItem ) 1282 eMoveMode = (InsCellCmd) pMoveItem->GetValue(); 1283 } 1284 else 1285 { 1286 ScEditableTester aTester( pTabViewShell ); 1287 if (aTester.IsEditable()) 1288 { 1289 //CHINA001 ScInsertContentsDlg* pDlg = new ScInsertContentsDlg( pTabViewShell->GetDialogParent() ); 1290 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 1291 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 1292 1293 AbstractScInsertContentsDlg* pDlg = pFact->CreateScInsertContentsDlg( pTabViewShell->GetDialogParent(), 1294 RID_SCDLG_INSCONT); 1295 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 1296 pDlg->SetOtherDoc( bOtherDoc ); 1297 // #53661# bei ChangeTrack MoveMode disablen 1298 pDlg->SetChangeTrack( pDoc->GetChangeTrack() != NULL ); 1299 // #72930# cut/move references may disable shift 1300 // directions if source and destination ranges intersect 1301 if ( !bOtherDoc ) 1302 { 1303 if ( pOwnClip && pOwnClip->GetDocument()->IsCutMode() ) 1304 { 1305 ScViewData* pData = GetViewData(); 1306 if ( pData->GetMarkData().GetTableSelect( 1307 pData->GetTabNo() ) ) 1308 { 1309 SCCOL nPosX = pData->GetCurX(); 1310 SCROW nPosY = pData->GetCurY(); 1311 SCCOL nClipStartX, nClipSizeX; 1312 SCROW nClipStartY, nClipSizeY; 1313 pOwnClip->GetDocument()->GetClipStart( nClipStartX, nClipStartY ); 1314 // for CutMode, filtered rows can always be included 1315 pOwnClip->GetDocument()->GetClipArea( nClipSizeX, nClipSizeY, sal_True ); 1316 int nDisableShift = 0; 1317 if ( nClipStartX <= nPosX + nClipSizeX && 1318 nPosX <= nClipStartX + nClipSizeX ) 1319 nDisableShift |= SC_CELL_SHIFT_DISABLE_DOWN; 1320 if ( nClipStartY <= nPosY + nClipSizeY && 1321 nPosY <= nClipStartY + nClipSizeY ) 1322 nDisableShift |= SC_CELL_SHIFT_DISABLE_RIGHT; 1323 if ( nDisableShift ) 1324 pDlg->SetCellShiftDisabled( nDisableShift ); 1325 } 1326 } 1327 } 1328 if (pDlg->Execute() == RET_OK) 1329 { 1330 nFlags = pDlg->GetInsContentsCmdBits(); 1331 nFunction = pDlg->GetFormulaCmdBits(); 1332 bSkipEmpty = pDlg->IsSkipEmptyCells(); 1333 bTranspose = pDlg->IsTranspose(); 1334 bAsLink = pDlg->IsLink(); 1335 eMoveMode = pDlg->GetMoveMode(); 1336 } 1337 delete pDlg; 1338 } 1339 else 1340 pTabViewShell->ErrorMessage(aTester.GetMessageId()); 1341 } 1342 1343 if( nFlags != IDF_NONE ) 1344 { 1345 { 1346 WaitObject aWait( GetViewData()->GetDialogParent() ); 1347 if ( bAsLink && bOtherDoc ) 1348 pTabViewShell->PasteFromSystem(SOT_FORMATSTR_ID_LINK); // DDE einfuegen 1349 else 1350 pTabViewShell->PasteFromClip( nFlags, pOwnClip->GetDocument(), 1351 nFunction, bSkipEmpty, bTranspose, bAsLink, 1352 eMoveMode, IDF_NONE, sal_True ); // allow warning dialog 1353 } 1354 1355 if( !pReqArgs ) 1356 { 1357 String aFlags; 1358 1359 if( nFlags == IDF_ALL ) 1360 { 1361 aFlags += 'A'; 1362 } 1363 else 1364 { 1365 if( nFlags & IDF_STRING ) aFlags += 'S'; 1366 if( nFlags & IDF_VALUE ) aFlags += 'V'; 1367 if( nFlags & IDF_DATETIME ) aFlags += 'D'; 1368 if( nFlags & IDF_FORMULA ) aFlags += 'F'; 1369 if( nFlags & IDF_NOTE ) aFlags += 'N'; 1370 if( nFlags & IDF_ATTRIB ) aFlags += 'T'; 1371 } 1372 1373 rReq.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS, aFlags ) ); 1374 rReq.AppendItem( SfxBoolItem( FN_PARAM_2, bSkipEmpty ) ); 1375 rReq.AppendItem( SfxBoolItem( FN_PARAM_3, bTranspose ) ); 1376 rReq.AppendItem( SfxBoolItem( FN_PARAM_4, bAsLink ) ); 1377 rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, nFunction ) ); 1378 rReq.AppendItem( SfxInt16Item( FN_PARAM_5, (sal_Int16) eMoveMode ) ); 1379 rReq.Done(); 1380 } 1381 } 1382 } 1383 } 1384 pTabViewShell->CellContentChanged(); // => PasteFromXXX ??? 1385 break; 1386 1387 case SID_PASTE_SPECIAL: 1388 // Unterscheidung, ob eigene oder fremde Daten, 1389 // dadurch FID_INS_CELL_CONTENTS ueberfluessig 1390 { 1391 Window* pWin = GetViewData()->GetActiveWin(); 1392 1393 // Clipboard-ID als Parameter angegeben? Basic "PasteSpecial(Format)" 1394 const SfxPoolItem* pItem=NULL; 1395 if ( pReqArgs && 1396 pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET && 1397 pItem->ISA(SfxUInt32Item) ) 1398 { 1399 sal_uLong nFormat = ((const SfxUInt32Item*)pItem)->GetValue(); 1400 sal_Bool bRet=sal_True; 1401 { 1402 WaitObject aWait( GetViewData()->GetDialogParent() ); 1403 sal_Bool bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL ); 1404 if ( bDraw && nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE ) 1405 pTabViewShell->PasteDraw(); 1406 else 1407 bRet = pTabViewShell->PasteFromSystem(nFormat, sal_True); // TRUE: keine Fehlermeldungen 1408 } 1409 1410 if ( bRet ) 1411 { 1412 rReq.SetReturnValue(SfxInt16Item(nSlot, bRet)); // 1 = Erfolg, 0 = Fehler 1413 rReq.Done(); 1414 } 1415 else 1416 // if format is not available -> fallback to request without parameters 1417 pItem = NULL; 1418 } 1419 1420 if ( !pItem ) 1421 { 1422 if ( ScTransferObj::GetOwnClipboard( pWin ) ) // own cell data 1423 { 1424 rReq.SetSlot( FID_INS_CELL_CONTENTS ); 1425 ExecuteSlot( rReq, GetInterface() ); 1426 rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = Erfolg 1427 } 1428 else // Zeichenobjekte oder fremde Daten 1429 { 1430 sal_Bool bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL ); 1431 1432 SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS ); 1433 GetPossibleClipboardFormats( aFormats ); 1434 1435 sal_uInt16 nFormatCount = aFormats.Count(); 1436 if ( nFormatCount ) 1437 { 1438 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 1439 SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( pTabViewShell->GetDialogParent() ); 1440 if ( pDlg ) 1441 { 1442 for (sal_uInt16 i=0; i<nFormatCount; i++) 1443 { 1444 sal_uLong nFormatId = aFormats.GetClipbrdFormatId( i ); 1445 String aName = aFormats.GetClipbrdFormatName( i ); 1446 // special case for paste dialog: '*' is replaced by object type 1447 if ( nFormatId == SOT_FORMATSTR_ID_EMBED_SOURCE ) 1448 aName.Assign((sal_Unicode)'*'); 1449 pDlg->Insert( nFormatId, aName ); 1450 } 1451 1452 TransferableDataHelper aDataHelper( 1453 TransferableDataHelper::CreateFromSystemClipboard( pWin ) ); 1454 sal_uLong nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() ); 1455 if (nFormat > 0) 1456 { 1457 { 1458 WaitObject aWait( GetViewData()->GetDialogParent() ); 1459 if ( bDraw && nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE ) 1460 pTabViewShell->PasteDraw(); 1461 else 1462 pTabViewShell->PasteFromSystem(nFormat); 1463 } 1464 rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = Erfolg 1465 rReq.AppendItem( SfxUInt32Item( nSlot, nFormat ) ); 1466 rReq.Done(); 1467 } 1468 else 1469 { 1470 rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = Fehler 1471 rReq.Ignore(); 1472 } 1473 1474 delete pDlg; 1475 } 1476 } 1477 else 1478 rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = Fehler 1479 } 1480 } 1481 } 1482 pTabViewShell->CellContentChanged(); // => PasteFromSystem() ??? 1483 break; 1484 1485 // 1486 // sonstiges 1487 // 1488 1489 case FID_INS_ROWBRK: 1490 pTabViewShell->InsertPageBreak( sal_False ); 1491 rReq.Done(); 1492 break; 1493 1494 case FID_INS_COLBRK: 1495 pTabViewShell->InsertPageBreak( sal_True ); 1496 rReq.Done(); 1497 break; 1498 1499 case FID_DEL_ROWBRK: 1500 pTabViewShell->DeletePageBreak( sal_False ); 1501 rReq.Done(); 1502 break; 1503 1504 case FID_DEL_COLBRK: 1505 pTabViewShell->DeletePageBreak( sal_True ); 1506 rReq.Done(); 1507 break; 1508 1509 case SID_DETECTIVE_ADD_PRED: 1510 pTabViewShell->DetectiveAddPred(); 1511 rReq.Done(); 1512 break; 1513 1514 case SID_DETECTIVE_DEL_PRED: 1515 pTabViewShell->DetectiveDelPred(); 1516 rReq.Done(); 1517 break; 1518 1519 case SID_DETECTIVE_ADD_SUCC: 1520 pTabViewShell->DetectiveAddSucc(); 1521 rReq.Done(); 1522 break; 1523 1524 case SID_DETECTIVE_DEL_SUCC: 1525 pTabViewShell->DetectiveDelSucc(); 1526 rReq.Done(); 1527 break; 1528 1529 case SID_DETECTIVE_ADD_ERR: 1530 pTabViewShell->DetectiveAddError(); 1531 rReq.Done(); 1532 break; 1533 1534 case SID_DETECTIVE_INVALID: 1535 pTabViewShell->DetectiveMarkInvalid(); 1536 rReq.Done(); 1537 break; 1538 1539 case SID_DETECTIVE_REFRESH: 1540 pTabViewShell->DetectiveRefresh(); 1541 rReq.Done(); 1542 break; 1543 1544 case SID_SPELL_DIALOG: 1545 // pTabViewShell->DoSpellingChecker(); 1546 { 1547 SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame(); 1548 if( rReq.GetArgs() ) 1549 pViewFrame->SetChildWindow( SID_SPELL_DIALOG, 1550 static_cast< const SfxBoolItem& >( rReq.GetArgs()-> 1551 Get( SID_SPELL_DIALOG ) ).GetValue() ); 1552 else 1553 pViewFrame->ToggleChildWindow( SID_SPELL_DIALOG ); 1554 1555 pViewFrame->GetBindings().Invalidate( SID_SPELL_DIALOG ); 1556 rReq.Ignore(); 1557 } 1558 break; 1559 1560 case SID_HANGUL_HANJA_CONVERSION: 1561 pTabViewShell->DoHangulHanjaConversion(); 1562 break; 1563 1564 case SID_CHINESE_CONVERSION: 1565 { 1566 //open ChineseTranslationDialog 1567 Reference< XComponentContext > xContext( 1568 ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one 1569 if(xContext.is()) 1570 { 1571 Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() ); 1572 if(xMCF.is()) 1573 { 1574 Reference< ui::dialogs::XExecutableDialog > xDialog( 1575 xMCF->createInstanceWithContext( 1576 rtl::OUString::createFromAscii("com.sun.star.linguistic2.ChineseTranslationDialog") 1577 , xContext), UNO_QUERY); 1578 Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY ); 1579 if( xInit.is() ) 1580 { 1581 // initialize dialog 1582 Reference< awt::XWindow > xDialogParentWindow(0); 1583 Sequence<Any> aSeq(1); 1584 Any* pArray = aSeq.getArray(); 1585 PropertyValue aParam; 1586 aParam.Name = rtl::OUString::createFromAscii("ParentWindow"); 1587 aParam.Value <<= makeAny(xDialogParentWindow); 1588 pArray[0] <<= makeAny(aParam); 1589 xInit->initialize( aSeq ); 1590 1591 //execute dialog 1592 sal_Int16 nDialogRet = xDialog->execute(); 1593 if( RET_OK == nDialogRet ) 1594 { 1595 //get some parameters from the dialog 1596 sal_Bool bToSimplified = sal_True; 1597 sal_Bool bUseVariants = sal_True; 1598 sal_Bool bCommonTerms = sal_True; 1599 Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY ); 1600 if( xProp.is() ) 1601 { 1602 try 1603 { 1604 xProp->getPropertyValue( C2U("IsDirectionToSimplified") ) >>= bToSimplified; 1605 xProp->getPropertyValue( C2U("IsUseCharacterVariants") ) >>= bUseVariants; 1606 xProp->getPropertyValue( C2U("IsTranslateCommonTerms") ) >>= bCommonTerms; 1607 } 1608 catch( Exception& ) 1609 { 1610 } 1611 } 1612 1613 //execute translation 1614 LanguageType eSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED; 1615 LanguageType eTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL; 1616 sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0; 1617 if( !bCommonTerms ) 1618 nOptions |= i18n::TextConversionOption::CHARACTER_BY_CHARACTER; 1619 1620 Font aTargetFont = GetViewData()->GetActiveWin()->GetDefaultFont( 1621 DEFAULTFONT_CJK_SPREADSHEET, 1622 eTargetLang, DEFAULTFONT_FLAGS_ONLYONE ); 1623 ScConversionParam aConvParam( SC_CONVERSION_CHINESE_TRANSL, 1624 eSourceLang, eTargetLang, aTargetFont, nOptions, false ); 1625 pTabViewShell->DoSheetConversion( aConvParam ); 1626 } 1627 } 1628 Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY ); 1629 if( xComponent.is() ) 1630 xComponent->dispose(); 1631 } 1632 } 1633 } 1634 break; 1635 1636 case SID_THESAURUS: 1637 pTabViewShell->DoThesaurus(); 1638 break; 1639 1640 case SID_TOGGLE_REL: 1641 pTabViewShell->DoRefConversion(); 1642 break; 1643 1644 case SID_DEC_INDENT: 1645 pTabViewShell->ChangeIndent( sal_False ); 1646 break; 1647 case SID_INC_INDENT: 1648 pTabViewShell->ChangeIndent( sal_True ); 1649 break; 1650 1651 case FID_USE_NAME: 1652 { 1653 sal_uInt16 nFlags = pTabViewShell->GetCreateNameFlags(); 1654 1655 //CHINA001 ScNameCreateDlg* pDlg = new ScNameCreateDlg( pTabViewShell->GetDialogParent(), nFlags ); 1656 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 1657 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 1658 1659 AbstractScNameCreateDlg* pDlg = pFact->CreateScNameCreateDlg(pTabViewShell->GetDialogParent(), nFlags, RID_SCDLG_NAMES_CREATE ); 1660 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 1661 1662 if( pDlg->Execute() ) 1663 { 1664 nFlags = pDlg->GetFlags(); 1665 pTabViewShell->CreateNames(nFlags); 1666 rReq.Done(); 1667 } 1668 delete pDlg; 1669 } 1670 break; 1671 1672 case SID_CONSOLIDATE: 1673 { 1674 const SfxPoolItem* pItem; 1675 if ( pReqArgs && SFX_ITEM_SET == 1676 pReqArgs->GetItemState( SCITEM_CONSOLIDATEDATA, sal_True, &pItem ) ) 1677 { 1678 const ScConsolidateParam& rParam = 1679 ((const ScConsolidateItem*)pItem)->GetData(); 1680 1681 pTabViewShell->Consolidate( rParam ); 1682 GetViewData()->GetDocument()->SetConsolidateDlgData( &rParam ); 1683 1684 rReq.Done(); 1685 } 1686 else if (rReq.IsAPI()) 1687 SbxBase::SetError(SbxERR_BAD_PARAMETER); 1688 } 1689 break; 1690 1691 case SID_INS_FUNCTION: 1692 { 1693 const SfxBoolItem* pOkItem = (const SfxBoolItem*)&pReqArgs->Get( SID_DLG_RETOK ); 1694 1695 // pScMod->SetFunctionDlg( NULL ); 1696 1697 if ( pOkItem->GetValue() ) // OK 1698 { 1699 String aFormula; 1700 const SfxStringItem* pSItem = (const SfxStringItem*)&pReqArgs->Get( SCITEM_STRING ); 1701 const SfxBoolItem* pMatrixItem = (const SfxBoolItem*) &pReqArgs->Get( SID_DLG_MATRIX ); 1702 1703 aFormula += pSItem->GetValue(); 1704 pScMod->ActivateInputWindow( &aFormula, pMatrixItem->GetValue() ); 1705 } 1706 else // CANCEL 1707 { 1708 pScMod->ActivateInputWindow( NULL ); 1709 } 1710 rReq.Ignore(); // only SID_ENTER_STRING is recorded 1711 } 1712 break; 1713 1714 case FID_DEFINE_NAME: 1715 if ( pReqArgs ) 1716 { 1717 const SfxPoolItem* pItem; 1718 String aName, aSymbol, aAttrib; 1719 1720 if( IS_AVAILABLE( FID_DEFINE_NAME, &pItem ) ) 1721 aName = ((const SfxStringItem*)pItem)->GetValue(); 1722 1723 if( IS_AVAILABLE( FN_PARAM_1, &pItem ) ) 1724 aSymbol = ((const SfxStringItem*)pItem)->GetValue(); 1725 1726 if( IS_AVAILABLE( FN_PARAM_2, &pItem ) ) 1727 aAttrib = ((const SfxStringItem*)pItem)->GetValue(); 1728 1729 if ( aName.Len() && aSymbol.Len() ) 1730 { 1731 if (pTabViewShell->InsertName( aName, aSymbol, aAttrib )) 1732 rReq.Done(); 1733 else 1734 SbxBase::SetError( SbxERR_BAD_PARAMETER ); // Basic-Fehler 1735 } 1736 } 1737 else 1738 { 1739 sal_uInt16 nId = ScNameDlgWrapper::GetChildWindowId(); 1740 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); 1741 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); 1742 1743 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True ); 1744 } 1745 break; 1746 1747 case SID_DEFINE_COLROWNAMERANGES: 1748 { 1749 1750 sal_uInt16 nId = ScColRowNameRangesDlgWrapper::GetChildWindowId(); 1751 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); 1752 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); 1753 1754 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True ); 1755 1756 } 1757 break; 1758 1759 case SID_UPDATECHART: 1760 { 1761 sal_Bool bAll = sal_False; 1762 1763 if( pReqArgs ) 1764 { 1765 const SfxPoolItem* pItem; 1766 1767 if( IS_AVAILABLE( SID_UPDATECHART, &pItem ) ) 1768 bAll = ((const SfxBoolItem*)pItem)->GetValue(); 1769 } 1770 1771 pTabViewShell->UpdateCharts( bAll ); 1772 1773 if( ! rReq.IsAPI() ) 1774 { 1775 rReq.AppendItem( SfxBoolItem( SID_UPDATECHART, bAll ) ); 1776 rReq.Done(); 1777 } 1778 } 1779 break; 1780 1781 1782 case SID_TABOP: 1783 if (pReqArgs) 1784 { 1785 const ScTabOpItem& rItem = 1786 (const ScTabOpItem&) 1787 pReqArgs->Get( SID_TABOP ); 1788 1789 pTabViewShell->TabOp( rItem.GetData() ); 1790 1791 rReq.Done( *pReqArgs ); 1792 } 1793 break; 1794 1795 case SID_SOLVE: 1796 if (pReqArgs) 1797 { 1798 const ScSolveItem& rItem = 1799 (const ScSolveItem&) 1800 pReqArgs->Get( SCITEM_SOLVEDATA ); 1801 1802 pTabViewShell->Solve( rItem.GetData() ); 1803 1804 rReq.Done( *pReqArgs ); 1805 } 1806 break; 1807 1808 case FID_INSERT_NAME: 1809 { 1810 ScDocument* pDoc = GetViewData()->GetDocument(); 1811 //CHINA001 ScNamePasteDlg* pDlg = new ScNamePasteDlg( pTabViewShell->GetDialogParent(), pDoc->GetRangeName() ); 1812 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 1813 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 1814 1815 AbstractScNamePasteDlg* pDlg = pFact->CreateScNamePasteDlg( pTabViewShell->GetDialogParent(), pDoc->GetRangeName(), RID_SCDLG_NAMES_PASTE ); 1816 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 1817 switch( pDlg->Execute() ) 1818 { 1819 case BTN_PASTE_LIST: 1820 pTabViewShell->InsertNameList(); 1821 break; 1822 case BTN_PASTE_NAME: 1823 { 1824 ScInputHandler* pHdl = pScMod->GetInputHdl( pTabViewShell ); 1825 if (pHdl) 1826 { 1827 // das "=" per Key-Event, schaltet in den Eingabe-Modus 1828 pScMod->InputKeyEvent( KeyEvent('=',KeyCode()) ); 1829 1830 String aName = pDlg->GetSelectedName(); 1831 pHdl->InsertFunction( aName, sal_False ); // ohne "()" 1832 } 1833 } 1834 break; 1835 } 1836 delete pDlg; 1837 } 1838 break; 1839 1840 case SID_RANGE_NOTETEXT: 1841 if (pReqArgs) 1842 { 1843 const SfxStringItem& rTextItem = (const SfxStringItem&)pReqArgs->Get( SID_RANGE_NOTETEXT ); 1844 1845 // #43343# immer Cursorposition 1846 ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ); 1847 pTabViewShell->SetNoteText( aPos, rTextItem.GetValue() ); 1848 rReq.Done(); 1849 } 1850 break; 1851 1852 case SID_INSERT_POSTIT: 1853 if ( pReqArgs ) 1854 { 1855 const SvxPostItAuthorItem& rAuthorItem = (const SvxPostItAuthorItem&)pReqArgs->Get( SID_ATTR_POSTIT_AUTHOR ); 1856 const SvxPostItDateItem& rDateItem = (const SvxPostItDateItem&) pReqArgs->Get( SID_ATTR_POSTIT_DATE ); 1857 const SvxPostItTextItem& rTextItem = (const SvxPostItTextItem&) pReqArgs->Get( SID_ATTR_POSTIT_TEXT ); 1858 1859 ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ); 1860 pTabViewShell->ReplaceNote( aPos, rTextItem.GetValue(), &rAuthorItem.GetValue(), &rDateItem.GetValue() ); 1861 rReq.Done(); 1862 } 1863 else 1864 { 1865 pTabViewShell->EditNote(); // Zeichenobjekt zum Editieren 1866 } 1867 break; 1868 1869 case FID_NOTE_VISIBLE: 1870 { 1871 ScDocument* pDoc = GetViewData()->GetDocument(); 1872 ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ); 1873 if( ScPostIt* pNote = pDoc->GetNote( aPos ) ) 1874 { 1875 bool bShow; 1876 const SfxPoolItem* pItem; 1877 if ( pReqArgs && (pReqArgs->GetItemState( FID_NOTE_VISIBLE, sal_True, &pItem ) == SFX_ITEM_SET) ) 1878 bShow = ((const SfxBoolItem*) pItem)->GetValue(); 1879 else 1880 bShow = !pNote->IsCaptionShown(); 1881 1882 pTabViewShell->ShowNote( bShow ); 1883 1884 if (!pReqArgs) 1885 rReq.AppendItem( SfxBoolItem( FID_NOTE_VISIBLE, bShow ) ); 1886 1887 rReq.Done(); 1888 rBindings.Invalidate( FID_NOTE_VISIBLE ); 1889 } 1890 else 1891 rReq.Ignore(); 1892 } 1893 break; 1894 1895 case SID_DELETE_NOTE: 1896 pTabViewShell->DeleteContents( IDF_NOTE ); // delete all notes in selection 1897 rReq.Done(); 1898 break; 1899 1900 case SID_CHARMAP: 1901 if( pReqArgs != NULL ) 1902 { 1903 String aChars, aFontName; 1904 const SfxItemSet *pArgs = rReq.GetArgs(); 1905 const SfxPoolItem* pItem = 0; 1906 if ( pArgs ) 1907 pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), sal_False, &pItem); 1908 if ( pItem ) 1909 { 1910 const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, pItem ); 1911 if ( pStringItem ) 1912 aChars = pStringItem->GetValue(); 1913 const SfxPoolItem* pFtItem = NULL; 1914 pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), sal_False, &pFtItem); 1915 const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem ); 1916 if ( pFontItem ) 1917 aFontName = pFontItem->GetValue(); 1918 } 1919 1920 if ( aChars.Len() ) 1921 { 1922 Font aFont; 1923 pTabViewShell->GetSelectionPattern()->GetFont( aFont, SC_AUTOCOL_BLACK, NULL, NULL, NULL, 1924 pTabViewShell->GetSelectionScriptType() ); 1925 if ( aFontName.Len() ) 1926 aFont = Font( aFontName, Size(1,1) ); 1927 pTabViewShell->InsertSpecialChar( aChars, aFont ); 1928 if( ! rReq.IsAPI() ) 1929 rReq.Done(); 1930 } 1931 } 1932 else 1933 { 1934 //CHINA001 SvxCharacterMap* pDlg = new SvxCharacterMap( pTabViewShell->GetDialogParent(), sal_False ); 1935 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 1936 1937 // font color doesn't matter here 1938 Font aCurFont; 1939 pTabViewShell->GetSelectionPattern()->GetFont( aCurFont, SC_AUTOCOL_BLACK, NULL, NULL, NULL, 1940 pTabViewShell->GetSelectionScriptType() ); 1941 1942 SfxAllItemSet aSet( GetPool() ); 1943 aSet.Put( SfxBoolItem( FN_PARAM_1, sal_False ) ); 1944 aSet.Put( SvxFontItem( aCurFont.GetFamily(), aCurFont.GetName(), aCurFont.GetStyleName(), aCurFont.GetPitch(), aCurFont.GetCharSet(), GetPool().GetWhich(SID_ATTR_CHAR_FONT) ) ); 1945 1946 SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( pTabViewShell->GetDialogParent(), aSet, 1947 pTabViewShell->GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP ); 1948 1949 if ( pDlg->Execute() == RET_OK ) 1950 { 1951 SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pItem, SfxStringItem, SID_CHARMAP, sal_False ); 1952 SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, sal_False ); 1953 1954 if ( pItem && pFontItem ) 1955 { 1956 Font aNewFont( pFontItem->GetFamilyName(), pFontItem->GetStyleName(), Size(1,1) ); 1957 aNewFont.SetCharSet( pFontItem->GetCharSet() ); 1958 aNewFont.SetPitch( pFontItem->GetPitch() ); 1959 pTabViewShell->InsertSpecialChar( pItem->GetValue(), aNewFont ); 1960 rReq.AppendItem( *pFontItem ); 1961 rReq.AppendItem( *pItem ); 1962 rReq.Done(); 1963 } 1964 } 1965 delete pDlg; 1966 } 1967 break; 1968 1969 case SID_SELECT_SCENARIO: 1970 { 1971 // Testing 1972 1973 if ( pReqArgs ) 1974 { 1975 const SfxStringItem* pItem = 1976 (const SfxStringItem*)&pReqArgs->Get( SID_SELECT_SCENARIO ); 1977 1978 if( pItem ) 1979 { 1980 pTabViewShell->UseScenario( pItem->GetValue() ); 1981 //! wofuer soll der Return-Wert gut sein?!?! 1982 rReq.SetReturnValue( SfxStringItem( SID_SELECT_SCENARIO, pItem->GetValue() ) ); 1983 rReq.Done(); 1984 } 1985 else 1986 { 1987 DBG_ERROR("NULL"); 1988 } 1989 } 1990 } 1991 break; 1992 1993 case SID_HYPERLINK_SETLINK: 1994 if( pReqArgs ) 1995 { 1996 const SfxPoolItem* pItem; 1997 if( IS_AVAILABLE( SID_HYPERLINK_SETLINK, &pItem ) ) 1998 { 1999 const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem; 2000 const String& rName = pHyper->GetName(); 2001 const String& rURL = pHyper->GetURL(); 2002 const String& rTarget = pHyper->GetTargetFrame(); 2003 sal_uInt16 nType = (sal_uInt16) pHyper->GetInsertMode(); 2004 2005 pTabViewShell->InsertURL( rName, rURL, rTarget, nType ); 2006 rReq.Done(); 2007 } 2008 else 2009 rReq.Ignore(); 2010 } 2011 break; 2012 2013 case FID_CONDITIONAL_FORMAT: 2014 if( pReqArgs ) 2015 { 2016 const SfxPoolItem* pItem; 2017 if( IS_AVAILABLE( FID_CONDITIONAL_FORMAT, &pItem ) ) 2018 { 2019 // Wenn RefInput auf andere Tabelle als Datentabelle umgeschaltet 2020 // hat wieder zurueckschalten: 2021 if ( GetViewData()->GetTabNo() != GetViewData()->GetRefTabNo() ) 2022 { 2023 pTabViewShell->SetTabNo( GetViewData()->GetRefTabNo() ); 2024 pTabViewShell->PaintExtras(); 2025 } 2026 2027 const ScCondFrmtItem* pCndFmtItem = (const ScCondFrmtItem*) pItem; 2028 pTabViewShell->SetConditionalFormat( pCndFmtItem->GetData() ); 2029 rReq.Done(); 2030 } 2031 } 2032 break; 2033 2034 case SID_EXTERNAL_SOURCE: 2035 { 2036 String aFile; 2037 String aFilter; 2038 String aOptions; 2039 String aSource; 2040 sal_uLong nRefresh=0; 2041 2042 SFX_REQUEST_ARG( rReq, pFile, SfxStringItem, SID_FILE_NAME, sal_False ); 2043 SFX_REQUEST_ARG( rReq, pSource, SfxStringItem, FN_PARAM_1, sal_False ); 2044 if ( pFile && pSource ) 2045 { 2046 aFile = pFile->GetValue(); 2047 aSource = pSource->GetValue(); 2048 SFX_REQUEST_ARG( rReq, pFilter, SfxStringItem, SID_FILTER_NAME, sal_False ); 2049 if ( pFilter ) 2050 aFilter = pFilter->GetValue(); 2051 SFX_REQUEST_ARG( rReq, pOptions, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False ); 2052 if ( pOptions ) 2053 aOptions = pOptions->GetValue(); 2054 SFX_REQUEST_ARG( rReq, pRefresh, SfxUInt32Item, FN_PARAM_2, sal_False ); 2055 if ( pRefresh ) 2056 nRefresh = pRefresh->GetValue(); 2057 } 2058 else 2059 { 2060 //CHINA001 ScLinkedAreaDlg* pDlg = new ScLinkedAreaDlg( pTabViewShell->GetDialogParent() ); 2061 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 2062 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 2063 2064 delete pImpl->m_pLinkedDlg; 2065 pImpl->m_pLinkedDlg = 2066 pFact->CreateScLinkedAreaDlg( pTabViewShell->GetDialogParent(), 2067 RID_SCDLG_LINKAREA); 2068 DBG_ASSERT(pImpl->m_pLinkedDlg, "Dialog create fail!");//CHINA001 2069 delete pImpl->m_pRequest; 2070 pImpl->m_pRequest = new SfxRequest( rReq ); 2071 pImpl->m_pLinkedDlg->StartExecuteModal( LINK( this, ScCellShell, DialogClosed ) ); 2072 return; 2073 } 2074 2075 ExecuteExternalSource( aFile, aFilter, aOptions, aSource, nRefresh, rReq ); 2076 } 2077 break; 2078 2079 // 2080 // 2081 // 2082 2083 default: 2084 DBG_ERROR("falscher Slot bei ExecuteEdit"); 2085 break; 2086 } 2087 } 2088 2089 void ScCellShell::ExecuteTrans( SfxRequest& rReq ) 2090 { 2091 sal_Int32 nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() ); 2092 if ( nType ) 2093 { 2094 GetViewData()->GetView()->TransliterateText( nType ); 2095 rReq.Done(); 2096 } 2097 } 2098 2099 void ScCellShell::ExecuteExternalSource( 2100 const String& _rFile, const String& _rFilter, const String& _rOptions, 2101 const String& _rSource, sal_uLong _nRefresh, SfxRequest& _rRequest ) 2102 { 2103 if ( _rFile.Len() && _rSource.Len() ) // filter may be empty 2104 { 2105 ScRange aLinkRange; 2106 sal_Bool bMove = sal_False; 2107 2108 ScViewData* pData = GetViewData(); 2109 ScMarkData& rMark = pData->GetMarkData(); 2110 rMark.MarkToSimple(); 2111 if ( rMark.IsMarked() ) 2112 { 2113 rMark.GetMarkArea( aLinkRange ); 2114 bMove = sal_True; // insert/delete cells to fit range 2115 } 2116 else 2117 aLinkRange = ScRange( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() ); 2118 2119 ScDocFunc aFunc(*pData->GetDocShell()); 2120 aFunc.InsertAreaLink( _rFile, _rFilter, _rOptions, _rSource, 2121 aLinkRange, _nRefresh, bMove, sal_False ); 2122 _rRequest.Done(); 2123 } 2124 else 2125 _rRequest.Ignore(); 2126 } 2127 2128 IMPL_LINK( ScCellShell, DialogClosed, AbstractScLinkedAreaDlg*, EMPTYARG ) 2129 { 2130 DBG_ASSERT( pImpl->m_pLinkedDlg, "ScCellShell::DialogClosed(): invalid request" ); 2131 DBG_ASSERT( pImpl->m_pRequest, "ScCellShell::DialogClosed(): invalid request" ); 2132 String sFile, sFilter, sOptions, sSource; 2133 sal_uLong nRefresh = 0; 2134 2135 if ( pImpl->m_pLinkedDlg->GetResult() == RET_OK ) 2136 { 2137 sFile = pImpl->m_pLinkedDlg->GetURL(); 2138 sFilter = pImpl->m_pLinkedDlg->GetFilter(); 2139 sOptions = pImpl->m_pLinkedDlg->GetOptions(); 2140 sSource = pImpl->m_pLinkedDlg->GetSource(); 2141 nRefresh = pImpl->m_pLinkedDlg->GetRefresh(); 2142 if ( sFile.Len() ) 2143 pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_NAME, sFile ) ); 2144 if ( sFilter.Len() ) 2145 pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILTER_NAME, sFilter ) ); 2146 if ( sOptions.Len() ) 2147 pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_FILTEROPTIONS, sOptions ) ); 2148 if ( sSource.Len() ) 2149 pImpl->m_pRequest->AppendItem( SfxStringItem( FN_PARAM_1, sSource ) ); 2150 if ( nRefresh ) 2151 pImpl->m_pRequest->AppendItem( SfxUInt32Item( FN_PARAM_2, nRefresh ) ); 2152 } 2153 2154 ExecuteExternalSource( sFile, sFilter, sOptions, sSource, nRefresh, *(pImpl->m_pRequest) ); 2155 return 0; 2156 } 2157 2158 void ScCellShell::PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTabViewShell, bool bShowDialog ) 2159 { 2160 Window* pWin = pViewData->GetActiveWin(); 2161 ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin ); 2162 ScDocument* pThisDoc = pViewData->GetDocument(); 2163 ScDPObject* pDPObj = pThisDoc->GetDPAtCursor( pViewData->GetCurX(), 2164 pViewData->GetCurY(), pViewData->GetTabNo() ); 2165 if ( pOwnClip && pDPObj ) 2166 { 2167 // paste from Calc into DataPilot table: sort (similar to drag & drop) 2168 2169 ScDocument* pClipDoc = pOwnClip->GetDocument(); 2170 SCTAB nSourceTab = pOwnClip->GetVisibleTab(); 2171 2172 SCCOL nClipStartX; 2173 SCROW nClipStartY; 2174 SCCOL nClipEndX; 2175 SCROW nClipEndY; 2176 pClipDoc->GetClipStart( nClipStartX, nClipStartY ); 2177 pClipDoc->GetClipArea( nClipEndX, nClipEndY, sal_True ); 2178 nClipEndX = nClipEndX + nClipStartX; 2179 nClipEndY = nClipEndY + nClipStartY; // GetClipArea returns the difference 2180 2181 ScRange aSource( nClipStartX, nClipStartY, nSourceTab, nClipEndX, nClipEndY, nSourceTab ); 2182 sal_Bool bDone = pTabViewShell->DataPilotMove( aSource, pViewData->GetCurPos() ); 2183 if ( !bDone ) 2184 pTabViewShell->ErrorMessage( STR_ERR_DATAPILOT_INPUT ); 2185 } 2186 else 2187 { 2188 // normal paste 2189 WaitObject aWait( pViewData->GetDialogParent() ); 2190 if (!pOwnClip) 2191 pTabViewShell->PasteFromSystem(); 2192 else 2193 { 2194 ScDocument* pClipDoc = pOwnClip->GetDocument(); 2195 sal_uInt16 nFlags = IDF_ALL; 2196 if (pClipDoc->GetClipParam().isMultiRange()) 2197 // For multi-range paste, we paste values by default. 2198 nFlags &= ~IDF_FORMULA; 2199 2200 pTabViewShell->PasteFromClip( nFlags, pClipDoc, 2201 PASTE_NOFUNC, sal_False, sal_False, sal_False, INS_NONE, IDF_NONE, 2202 bShowDialog ); // allow warning dialog 2203 } 2204 } 2205 pTabViewShell->CellContentChanged(); // => PasteFromSystem() ??? 2206 } 2207