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 #define _ZFORLIST_DECLARE_TABLE 32 #include "scitems.hxx" 33 #include <svl/stritem.hxx> 34 #include <svl/whiter.hxx> 35 #include <svl/zformat.hxx> 36 #include <editeng/boxitem.hxx> 37 #include <svx/numinf.hxx> 38 #include <svl/srchitem.hxx> 39 #include <svx/zoomslideritem.hxx> 40 #include <sfx2/bindings.hxx> 41 #include <sfx2/viewfrm.hxx> 42 #include <sfx2/dispatch.hxx> 43 #include <sfx2/request.hxx> 44 #include <vcl/msgbox.hxx> 45 46 #include "global.hxx" 47 #include "attrib.hxx" 48 #include "patattr.hxx" 49 #include "document.hxx" 50 #include "cell.hxx" // Input Status Edit-Zellen 51 #include "globstr.hrc" 52 #include "scmod.hxx" 53 #include "inputhdl.hxx" 54 #include "inputwin.hxx" 55 #include "docsh.hxx" 56 #include "viewdata.hxx" 57 //CHINA001 #include "attrdlg.hxx" 58 #include "appoptio.hxx" 59 #include "sc.hrc" 60 #include "stlpool.hxx" 61 #include "tabvwsh.hxx" 62 #include "dwfunctr.hxx" 63 #include "scabstdlg.hxx" //CHINA001 64 #include "compiler.hxx" 65 66 67 sal_Bool ScTabViewShell::GetFunction( String& rFuncStr, sal_uInt16 nErrCode ) 68 { 69 String aStr; 70 71 ScSubTotalFunc eFunc = (ScSubTotalFunc) SC_MOD()->GetAppOptions().GetStatusFunc(); 72 ScViewData* pViewData = GetViewData(); 73 ScMarkData& rMark = pViewData->GetMarkData(); 74 bool bIgnoreError = (rMark.IsMarked() || rMark.IsMultiMarked()); 75 76 if (bIgnoreError && (eFunc == SUBTOTAL_FUNC_CNT || eFunc == SUBTOTAL_FUNC_CNT2)) 77 nErrCode = 0; 78 79 if (nErrCode) 80 { 81 rFuncStr = ScGlobal::GetLongErrorString(nErrCode); 82 return true; 83 } 84 85 sal_uInt16 nGlobStrId = 0; 86 switch (eFunc) 87 { 88 case SUBTOTAL_FUNC_AVE: nGlobStrId = STR_FUN_TEXT_AVG; break; 89 case SUBTOTAL_FUNC_CNT: nGlobStrId = STR_FUN_TEXT_COUNT; break; 90 case SUBTOTAL_FUNC_CNT2: nGlobStrId = STR_FUN_TEXT_COUNT2; break; 91 case SUBTOTAL_FUNC_MAX: nGlobStrId = STR_FUN_TEXT_MAX; break; 92 case SUBTOTAL_FUNC_MIN: nGlobStrId = STR_FUN_TEXT_MIN; break; 93 case SUBTOTAL_FUNC_SUM: nGlobStrId = STR_FUN_TEXT_SUM; break; 94 default: 95 { 96 // added to avoid warnings 97 } 98 } 99 if (nGlobStrId) 100 { 101 ScDocument* pDoc = pViewData->GetDocument(); 102 SCCOL nPosX = pViewData->GetCurX(); 103 SCROW nPosY = pViewData->GetCurY(); 104 SCTAB nTab = pViewData->GetTabNo(); 105 106 aStr = ScGlobal::GetRscString(nGlobStrId); 107 aStr += '='; 108 109 ScAddress aCursor( nPosX, nPosY, nTab ); 110 double nVal; 111 if ( pDoc->GetSelectionFunction( eFunc, aCursor, rMark, nVal ) ) 112 { 113 if ( nVal == 0.0 ) 114 aStr += '0'; 115 else 116 { 117 // Anzahl im Standardformat, die anderen nach Cursorposition 118 SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); 119 sal_uInt32 nNumFmt = 0; 120 if ( eFunc != SUBTOTAL_FUNC_CNT && eFunc != SUBTOTAL_FUNC_CNT2 ) 121 { 122 // Zahlformat aus Attributen oder Formel 123 pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt ); 124 if ( (nNumFmt % SV_COUNTRY_LANGUAGE_OFFSET) == 0 ) 125 { 126 ScBaseCell* pCell; 127 pDoc->GetCell( nPosX, nPosY, nTab, pCell ); 128 if (pCell && pCell->GetCellType() == CELLTYPE_FORMULA) 129 { 130 131 nNumFmt = ((ScFormulaCell*)pCell)->GetStandardFormat(*pFormatter, nNumFmt ); 132 } 133 } 134 } 135 136 String aValStr; 137 Color* pDummy; 138 pFormatter->GetOutputString( nVal, nNumFmt, aValStr, &pDummy ); 139 aStr += aValStr; 140 } 141 } 142 143 rFuncStr = aStr; 144 return sal_True; 145 } 146 147 return sal_False; 148 } 149 150 151 152 // Funktionen, die je nach Selektion disabled sind 153 // Default: 154 // SID_DELETE, 155 // SID_DELETE_CONTENTS, 156 // FID_DELETE_CELL 157 // FID_VALIDATION 158 159 160 void __EXPORT ScTabViewShell::GetState( SfxItemSet& rSet ) 161 { 162 ScViewData* pViewData = GetViewData(); 163 ScDocument* pDoc = pViewData->GetDocument(); 164 ScDocShell* pDocShell = pViewData->GetDocShell(); 165 ScMarkData& rMark = pViewData->GetMarkData(); 166 SCCOL nPosX = pViewData->GetCurX(); 167 SCROW nPosY = pViewData->GetCurY(); 168 SCTAB nTab = pViewData->GetTabNo(); 169 sal_uInt16 nMyId = 0; 170 171 SfxViewFrame* pThisFrame = GetViewFrame(); 172 sal_Bool bOle = GetViewFrame()->GetFrame().IsInPlace(); 173 174 SCTAB nTabCount = pDoc->GetTableCount(); 175 SCTAB nTabSelCount = rMark.GetSelectCount(); 176 177 SfxWhichIter aIter(rSet); 178 sal_uInt16 nWhich = aIter.FirstWhich(); 179 180 while ( nWhich ) 181 { 182 switch ( nWhich ) 183 { 184 case FID_CHG_COMMENT: 185 { 186 ScDocShell* pDocSh = GetViewData()->GetDocShell(); 187 ScAddress aPos( nPosX, nPosY, nTab ); 188 if ( pDocSh->IsReadOnly() || !pDocSh->GetChangeAction(aPos) || pDocSh->IsDocShared() ) 189 rSet.DisableItem( nWhich ); 190 } 191 break; 192 193 case SID_OPENDLG_EDIT_PRINTAREA: 194 case SID_ADD_PRINTAREA: 195 case SID_DEFINE_PRINTAREA: 196 { 197 if ( pDocShell && pDocShell->IsDocShared() ) 198 { 199 rSet.DisableItem( nWhich ); 200 } 201 } 202 break; 203 204 case SID_DELETE_PRINTAREA: 205 if ( nTabSelCount > 1 ) 206 { 207 // #i22589# also take "Print Entire Sheet" into account here 208 sal_Bool bHas = sal_False; 209 for (SCTAB i=0; !bHas && i<nTabCount; i++) 210 bHas = rMark.GetTableSelect(i) && (pDoc->GetPrintRangeCount(i) || pDoc->IsPrintEntireSheet(i)); 211 if (!bHas) 212 rSet.DisableItem( nWhich ); 213 } 214 else if ( !pDoc->GetPrintRangeCount( nTab ) && !pDoc->IsPrintEntireSheet( nTab ) ) 215 rSet.DisableItem( nWhich ); 216 if ( pDocShell && pDocShell->IsDocShared() ) 217 { 218 rSet.DisableItem( nWhich ); 219 } 220 break; 221 222 case SID_STATUS_PAGESTYLE: 223 case SID_HFEDIT: 224 GetViewData()->GetDocShell()->GetStatePageStyle( *this, rSet, nTab ); 225 break; 226 227 case SID_SEARCH_ITEM: 228 { 229 SvxSearchItem searchItem = ScGlobal::GetSearchItem(); 230 // i35093: 231 if (bSearchJustOpened) 232 { 233 ScMarkData& rMarkData = pViewData->GetMarkData(); 234 if (rMarkData.IsMarked()) 235 searchItem.SetSelection( sal_True ); 236 } 237 bSearchJustOpened = sal_False; 238 rSet.Put(searchItem); 239 } 240 break; 241 242 case SID_SEARCH_OPTIONS: 243 { 244 sal_uInt16 nOptions = 0xffff; // alles erlaubt 245 // wenn ReadOnly, kein Ersetzen: 246 if (GetViewData()->GetDocShell()->IsReadOnly()) 247 nOptions &= ~( SEARCH_OPTIONS_REPLACE | SEARCH_OPTIONS_REPLACE_ALL ); 248 rSet.Put( SfxUInt16Item( nWhich, nOptions ) ); 249 } 250 break; 251 252 case SID_CURRENTCELL: 253 { 254 ScAddress aScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), 0 ); 255 String aAddr; 256 aScAddress.Format( aAddr, SCA_ABS, NULL, pDoc->GetAddressConvention() ); 257 SfxStringItem aPosItem( SID_CURRENTCELL, aAddr ); 258 259 rSet.Put( aPosItem ); 260 } 261 break; 262 263 case SID_CURRENTTAB: 264 // Tabelle fuer Basic ist 1-basiert 265 rSet.Put( SfxUInt16Item( nWhich, static_cast<sal_uInt16>(GetViewData()->GetTabNo()) + 1 ) ); 266 break; 267 268 case SID_CURRENTDOC: 269 rSet.Put( SfxStringItem( nWhich, GetViewData()->GetDocShell()->GetTitle() ) ); 270 break; 271 272 case FID_TOGGLEINPUTLINE: 273 { 274 sal_uInt16 nId = ScInputWindowWrapper::GetChildWindowId(); 275 276 if ( pThisFrame->KnowsChildWindow( nId ) ) 277 { 278 SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId ); 279 rSet.Put( SfxBoolItem( nWhich, pWnd ? sal_True : sal_False ) ); 280 } 281 else 282 rSet.DisableItem( nWhich ); 283 } 284 break; 285 286 case FID_DEL_MANUALBREAKS: 287 if (!pDoc->HasManualBreaks(nTab)) 288 rSet.DisableItem( nWhich ); 289 break; 290 291 case FID_RESET_PRINTZOOM: 292 { 293 // disablen, wenn schon Default eingestellt 294 295 String aStyleName = pDoc->GetPageStyle( nTab ); 296 ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool(); 297 SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName, 298 SFX_STYLE_FAMILY_PAGE ); 299 DBG_ASSERT( pStyleSheet, "PageStyle not found" ); 300 if ( pStyleSheet ) 301 { 302 SfxItemSet& rStyleSet = pStyleSheet->GetItemSet(); 303 sal_uInt16 nScale = ((const SfxUInt16Item&) 304 rStyleSet.Get(ATTR_PAGE_SCALE)).GetValue(); 305 sal_uInt16 nPages = ((const SfxUInt16Item&) 306 rStyleSet.Get(ATTR_PAGE_SCALETOPAGES)).GetValue(); 307 if ( nScale == 100 && nPages == 0 ) 308 rSet.DisableItem( nWhich ); 309 } 310 } 311 break; 312 313 case FID_SCALE: 314 case SID_ATTR_ZOOM: 315 if ( bOle ) 316 rSet.DisableItem( nWhich ); 317 else 318 { 319 const Fraction& rOldY = GetViewData()->GetZoomY(); 320 sal_uInt16 nZoom = (sal_uInt16)(( rOldY.GetNumerator() * 100 ) 321 / rOldY.GetDenominator()); 322 rSet.Put( SvxZoomItem( SVX_ZOOM_PERCENT, nZoom, nWhich ) ); 323 } 324 break; 325 326 case SID_ATTR_ZOOMSLIDER: 327 { 328 if ( bOle ) 329 rSet.DisableItem( nWhich ); 330 else 331 { 332 const Fraction& rOldY = GetViewData()->GetZoomY(); 333 sal_uInt16 nCurrentZoom = (sal_uInt16)(( rOldY.GetNumerator() * 100 ) / rOldY.GetDenominator()); 334 335 if( nCurrentZoom ) 336 { 337 SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM, SID_ATTR_ZOOMSLIDER ); 338 aZoomSliderItem.AddSnappingPoint( 100 ); 339 rSet.Put( aZoomSliderItem ); 340 } 341 } 342 } 343 break; 344 345 case FID_TOGGLESYNTAX: 346 rSet.Put(SfxBoolItem(nWhich, GetViewData()->IsSyntaxMode())); 347 break; 348 349 case FID_TOGGLEHEADERS: 350 rSet.Put(SfxBoolItem(nWhich, GetViewData()->IsHeaderMode())); 351 break; 352 353 case FID_TOGGLEFORMULA: 354 { 355 const ScViewOptions& rOpts = pViewData->GetOptions(); 356 sal_Bool bFormulaMode = rOpts.GetOption( VOPT_FORMULAS ); 357 rSet.Put(SfxBoolItem(nWhich, bFormulaMode )); 358 } 359 break; 360 361 case FID_NORMALVIEWMODE: 362 case FID_PAGEBREAKMODE: 363 // always handle both slots - they exclude each other 364 if ( bOle ) 365 { 366 rSet.DisableItem( FID_NORMALVIEWMODE ); 367 rSet.DisableItem( FID_PAGEBREAKMODE ); 368 } 369 else 370 { 371 rSet.Put(SfxBoolItem(FID_NORMALVIEWMODE, !GetViewData()->IsPagebreakMode())); 372 rSet.Put(SfxBoolItem(FID_PAGEBREAKMODE, GetViewData()->IsPagebreakMode())); 373 } 374 break; 375 376 case FID_FUNCTION_BOX: 377 nMyId = ScFunctionChildWindow::GetChildWindowId(); 378 rSet.Put(SfxBoolItem(FID_FUNCTION_BOX, pThisFrame->HasChildWindow(nMyId))); 379 break; 380 381 case FID_PROTECT_DOC: 382 { 383 if ( pDocShell && pDocShell->IsDocShared() ) 384 { 385 rSet.DisableItem( nWhich ); 386 } 387 else 388 { 389 rSet.Put( SfxBoolItem( nWhich, pDoc->IsDocProtected() ) ); 390 } 391 } 392 break; 393 394 case FID_PROTECT_TABLE: 395 { 396 if ( pDocShell && pDocShell->IsDocShared() ) 397 { 398 rSet.DisableItem( nWhich ); 399 } 400 else 401 { 402 rSet.Put( SfxBoolItem( nWhich, pDoc->IsTabProtected( nTab ) ) ); 403 } 404 } 405 break; 406 407 case SID_AUTO_OUTLINE: 408 { 409 if (pDoc->GetChangeTrack()!=NULL || GetViewData()->IsMultiMarked()) 410 { 411 rSet.DisableItem( nWhich ); 412 } 413 } 414 break; 415 416 case SID_OUTLINE_DELETEALL: 417 { 418 SCTAB nOlTab = GetViewData()->GetTabNo(); 419 ScOutlineTable* pOlTable = pDoc->GetOutlineTable( nOlTab ); 420 if (pOlTable == NULL) 421 rSet.DisableItem( nWhich ); 422 } 423 break; 424 425 case SID_WINDOW_SPLIT: 426 rSet.Put(SfxBoolItem(nWhich, 427 pViewData->GetHSplitMode() == SC_SPLIT_NORMAL || 428 pViewData->GetVSplitMode() == SC_SPLIT_NORMAL )); 429 break; 430 431 case SID_WINDOW_FIX: 432 rSet.Put(SfxBoolItem(nWhich, 433 pViewData->GetHSplitMode() == SC_SPLIT_FIX || 434 pViewData->GetVSplitMode() == SC_SPLIT_FIX )); 435 break; 436 437 case FID_CHG_SHOW: 438 { 439 if ( pDoc->GetChangeTrack() == NULL || ( pDocShell && pDocShell->IsDocShared() ) ) 440 rSet.DisableItem( nWhich ); 441 } 442 break; 443 case FID_CHG_ACCEPT: 444 { 445 rSet.Put(SfxBoolItem(FID_CHG_ACCEPT, 446 pThisFrame->HasChildWindow(FID_CHG_ACCEPT))); 447 if(pDoc->GetChangeTrack()==NULL) 448 { 449 if ( !pThisFrame->HasChildWindow(FID_CHG_ACCEPT) ) 450 { 451 rSet.DisableItem( nWhich); 452 } 453 } 454 if ( pDocShell && pDocShell->IsDocShared() ) 455 { 456 rSet.DisableItem( nWhich ); 457 } 458 } 459 break; 460 461 case SID_FORMATPAGE: 462 //! bei geschuetzten Tabellen ??? 463 if ( pDocShell && ( pDocShell->IsReadOnly() || pDocShell->IsDocShared() ) ) 464 rSet.DisableItem( nWhich ); 465 break; 466 467 case SID_PRINTPREVIEW: 468 // #58924# Toggle-Slot braucht einen State 469 rSet.Put( SfxBoolItem( nWhich, sal_False ) ); 470 break; 471 472 case SID_READONLY_MODE: 473 rSet.Put( SfxBoolItem( nWhich, GetViewData()->GetDocShell()->IsReadOnly() ) ); 474 break; 475 476 case FID_TAB_DESELECTALL: 477 if ( nTabSelCount == 1 ) 478 rSet.DisableItem( nWhich ); // enabled only if several sheets are selected 479 break; 480 481 } // switch ( nWitch ) 482 nWhich = aIter.NextWhich(); 483 } // while ( nWitch ) 484 } 485 486 //------------------------------------------------------------------ 487 void ScTabViewShell::ExecuteCellFormatDlg( SfxRequest& rReq, sal_uInt16 nTabPage ) 488 { 489 //CHINA001 ScAttrDlg* pDlg = NULL; 490 SfxAbstractTabDialog * pDlg = NULL; //CHINA001 491 ScDocument* pDoc = GetViewData()->GetDocument(); 492 493 SvxBoxItem aLineOuter( ATTR_BORDER ); 494 SvxBoxInfoItem aLineInner( ATTR_BORDER_INNER ); 495 496 SvxNumberInfoItem* pNumberInfoItem = NULL; 497 const ScPatternAttr* pOldAttrs = GetSelectionPattern(); 498 SfxItemSet* pOldSet = new SfxItemSet( 499 pOldAttrs->GetItemSet() ); 500 501 502 // Umrandungs-Items holen und in den Set packen: 503 GetSelectionFrame( aLineOuter, aLineInner ); 504 pOldSet->Put( aLineOuter ); 505 pOldSet->Put( aLineInner ); 506 507 // NumberFormat Value aus Value und Language erzeugen und eintueten 508 pOldSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT, 509 pOldAttrs->GetNumberFormat( pDoc->GetFormatTable() ) ) ); 510 511 MakeNumberInfoItem( pDoc, GetViewData(), &pNumberInfoItem ); 512 513 pOldSet->MergeRange( SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO ); 514 pOldSet->Put(*pNumberInfoItem ); 515 516 bInFormatDialog = sal_True; 517 //CHINA001 pDlg = new ScAttrDlg( GetViewFrame(), GetDialogParent(), pOldSet ); 518 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 519 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 520 521 pDlg = pFact->CreateScAttrDlg( GetViewFrame(), GetDialogParent(), pOldSet, RID_SCDLG_ATTR); 522 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 523 if ( nTabPage != 0xffff ) 524 pDlg->SetCurPageId( nTabPage ); 525 short nResult = pDlg->Execute(); 526 bInFormatDialog = sal_False; 527 528 if ( nResult == RET_OK ) 529 { 530 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); 531 532 const SfxPoolItem* pItem=NULL; 533 if(pOutSet->GetItemState(SID_ATTR_NUMBERFORMAT_INFO,sal_True,&pItem)==SFX_ITEM_SET) 534 { 535 536 UpdateNumberFormatter( pDoc,(const SvxNumberInfoItem&)*pItem); 537 } 538 539 ApplyAttributes( pOutSet, pOldSet ); 540 541 rReq.Done( *pOutSet ); 542 } 543 delete pOldSet; 544 delete pNumberInfoItem; 545 delete pDlg; 546 } 547 548 //------------------------------------------------------------------ 549 550 bool ScTabViewShell::IsRefInputMode() const 551 { 552 ScModule* pScMod = SC_MOD(); 553 if ( pScMod ) 554 { 555 if( pScMod->IsRefDialogOpen() ) 556 return pScMod->IsFormulaMode(); 557 if( pScMod->IsFormulaMode() ) 558 { 559 ScInputHandler* pHdl = pScMod->GetInputHdl(); 560 if ( pHdl ) 561 { 562 String aString = pHdl->GetEditString(); 563 if ( !pHdl->GetSelIsRef() && aString.Len() > 1 && 564 ( aString.GetChar(0) == '+' || aString.GetChar(0) == '-' ) ) 565 { 566 const ScViewData* pViewData = GetViewData(); 567 if ( pViewData ) 568 { 569 ScDocument* pDoc = pViewData->GetDocument(); 570 if ( pDoc ) 571 { 572 const ScAddress aPos( pViewData->GetCurPos() ); 573 ScCompiler aComp( pDoc, aPos ); 574 aComp.SetGrammar(pDoc->GetGrammar()); 575 aComp.SetCloseBrackets( false ); 576 ScTokenArray* pArr = aComp.CompileString( aString ); 577 if ( pArr && pArr->MayReferenceFollow() ) 578 { 579 return true; 580 } 581 } 582 } 583 } 584 else 585 { 586 return true; 587 } 588 } 589 } 590 } 591 592 return false; 593 } 594 595 //------------------------------------------------------------------ 596 597 void ScTabViewShell::ExecuteInputDirect() 598 { 599 if ( !IsRefInputMode() ) 600 { 601 ScModule* pScMod = SC_MOD(); 602 if ( pScMod ) 603 { 604 pScMod->InputEnterHandler(); 605 } 606 } 607 } 608 609 //------------------------------------------------------------------ 610 611 void ScTabViewShell::UpdateInputHandler( sal_Bool bForce /* = sal_False */, sal_Bool bStopEditing /* = sal_True */ ) 612 { 613 ScInputHandler* pHdl = pInputHandler ? pInputHandler : SC_MOD()->GetInputHdl(); 614 615 if ( pHdl ) 616 { 617 String aString; 618 const EditTextObject* pObject = NULL; 619 ScViewData* pViewData = GetViewData(); 620 ScDocument* pDoc = pViewData->GetDocument(); 621 CellType eType; 622 SCCOL nPosX = pViewData->GetCurX(); 623 SCROW nPosY = pViewData->GetCurY(); 624 SCTAB nTab = pViewData->GetTabNo(); 625 SCTAB nStartTab = 0; 626 SCTAB nEndTab = 0; 627 SCCOL nStartCol = 0; 628 SCROW nStartRow = 0; 629 SCCOL nEndCol = 0; 630 SCROW nEndRow = 0; 631 632 pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab, 633 nEndCol, nEndRow, nEndTab ); 634 635 PutInOrder( nStartCol, nEndCol ); 636 PutInOrder( nStartRow, nEndRow ); 637 PutInOrder( nStartTab, nEndTab ); 638 639 sal_Bool bHideFormula = sal_False; 640 sal_Bool bHideAll = sal_False; 641 642 if (pDoc->IsTabProtected(nTab)) 643 { 644 const ScProtectionAttr* pProt = (const ScProtectionAttr*) 645 pDoc->GetAttr( nPosX,nPosY,nTab, 646 ATTR_PROTECTION); 647 bHideFormula = pProt->GetHideFormula(); 648 bHideAll = pProt->GetHideCell(); 649 } 650 651 if (!bHideAll) 652 { 653 pDoc->GetCellType( nPosX, nPosY, nTab, eType ); 654 if (eType == CELLTYPE_FORMULA) 655 { 656 if (!bHideFormula) 657 pDoc->GetFormula( nPosX, nPosY, nTab, aString ); 658 } 659 else if (eType == CELLTYPE_EDIT) 660 { 661 ScBaseCell* pCell; 662 pDoc->GetCell( nPosX, nPosY, nTab, pCell ); 663 ((ScEditCell*)pCell)->GetData( pObject ); 664 } 665 else 666 { 667 pDoc->GetInputString( nPosX, nPosY, nTab, aString ); 668 if (eType == CELLTYPE_STRING) 669 { 670 // Bei Bedarf ein ' vorneweg, damit der String nicht ungewollt 671 // als Zahl interpretiert wird, und um dem Benutzer zu zeigen, 672 // dass es ein String ist (#35060#). 673 //! Auch bei Zahlformat "Text"? -> dann beim Editieren wegnehmen 674 675 SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); 676 sal_uInt32 nNumFmt; 677 pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt ); 678 double fDummy; 679 if ( pFormatter->IsNumberFormat(aString, nNumFmt, fDummy) ) 680 aString.Insert('\'',0); 681 } 682 } 683 } 684 685 ScInputHdlState aState( ScAddress( nPosX, nPosY, nTab ), 686 ScAddress( nStartCol, nStartRow, nTab ), 687 ScAddress( nEndCol, nEndRow, nTab ), 688 aString, 689 pObject ); 690 691 // if using the view's local input handler, this view can always be set 692 // as current view inside NotifyChange. 693 ScTabViewShell* pSourceSh = pInputHandler ? this : NULL; 694 695 pHdl->NotifyChange( &aState, bForce, pSourceSh, bStopEditing ); 696 } 697 698 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 699 rBindings.Invalidate( SID_STATUS_SUM ); // immer zusammen mit Eingabezeile 700 rBindings.Invalidate( SID_ATTR_SIZE ); 701 rBindings.Invalidate( SID_TABLE_CELL ); 702 } 703 704 void ScTabViewShell::UpdateInputHandlerCellAdjust( SvxCellHorJustify eJust ) 705 { 706 if( ScInputHandler* pHdl = pInputHandler ? pInputHandler : SC_MOD()->GetInputHdl() ) 707 pHdl->UpdateCellAdjust( eJust ); 708 } 709 710 //------------------------------------------------------------------ 711 712 void __EXPORT ScTabViewShell::ExecuteSave( SfxRequest& rReq ) 713 { 714 // nur SID_SAVEDOC / SID_SAVEASDOC 715 716 // Eingabe auf jeden Fall abschliessen, auch wenn eine Formel bearbeitet wird 717 SC_MOD()->InputEnterHandler(); 718 719 if ( GetViewData()->GetDocShell()->IsDocShared() ) 720 { 721 GetViewData()->GetDocShell()->SetDocumentModified(); 722 } 723 724 // ansonsten normal weiter 725 GetViewData()->GetDocShell()->ExecuteSlot( rReq ); 726 } 727 728 void __EXPORT ScTabViewShell::GetSaveState( SfxItemSet& rSet ) 729 { 730 SfxShell* pDocSh = GetViewData()->GetDocShell(); 731 732 SfxWhichIter aIter(rSet); 733 sal_uInt16 nWhich = aIter.FirstWhich(); 734 while( nWhich ) 735 { 736 if ( nWhich != SID_SAVEDOC || !GetViewData()->GetDocShell()->IsDocShared() ) 737 { 738 // get state from DocShell 739 pDocSh->GetSlotState( nWhich, NULL, &rSet ); 740 } 741 nWhich = aIter.NextWhich(); 742 } 743 } 744 745 //------------------------------------------------------------------ 746 747 void ScTabViewShell::ExecDrawOpt( SfxRequest& rReq ) 748 { 749 ScViewOptions aViewOptions = GetViewData()->GetOptions(); 750 ScGridOptions aGridOptions = aViewOptions.GetGridOptions(); 751 752 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 753 const SfxItemSet* pArgs = rReq.GetArgs(); 754 const SfxPoolItem* pItem; 755 sal_uInt16 nSlotId = rReq.GetSlot(); 756 switch (nSlotId) 757 { 758 case SID_GRID_VISIBLE: 759 if ( pArgs && pArgs->GetItemState(nSlotId,sal_True,&pItem) == SFX_ITEM_SET ) 760 { 761 aGridOptions.SetGridVisible( ((const SfxBoolItem*)pItem)->GetValue() ); 762 aViewOptions.SetGridOptions(aGridOptions); 763 rBindings.Invalidate(SID_GRID_VISIBLE); 764 } 765 break; 766 767 case SID_GRID_USE: 768 if ( pArgs && pArgs->GetItemState(nSlotId,sal_True,&pItem) == SFX_ITEM_SET ) 769 { 770 aGridOptions.SetUseGridSnap( ((const SfxBoolItem*)pItem)->GetValue() ); 771 aViewOptions.SetGridOptions(aGridOptions); 772 rBindings.Invalidate(SID_GRID_USE); 773 } 774 break; 775 776 case SID_HELPLINES_MOVE: 777 if ( pArgs && pArgs->GetItemState(nSlotId,sal_True,&pItem) == SFX_ITEM_SET ) 778 { 779 aViewOptions.SetOption( VOPT_HELPLINES, ((const SfxBoolItem*)pItem)->GetValue() ); 780 rBindings.Invalidate(SID_HELPLINES_MOVE); 781 } 782 break; 783 } 784 785 GetViewData()->SetOptions(aViewOptions); 786 } 787 788 void ScTabViewShell::GetDrawOptState( SfxItemSet& rSet ) 789 { 790 SfxBoolItem aBool; 791 792 const ScViewOptions& rViewOptions = GetViewData()->GetOptions(); 793 const ScGridOptions& rGridOptions = rViewOptions.GetGridOptions(); 794 795 aBool.SetValue(rGridOptions.GetGridVisible()); 796 aBool.SetWhich( SID_GRID_VISIBLE ); 797 rSet.Put( aBool ); 798 799 aBool.SetValue(rGridOptions.GetUseGridSnap()); 800 aBool.SetWhich( SID_GRID_USE ); 801 rSet.Put( aBool ); 802 803 aBool.SetValue(rViewOptions.GetOption( VOPT_HELPLINES )); 804 aBool.SetWhich( SID_HELPLINES_MOVE ); 805 rSet.Put( aBool ); 806 } 807 808 809 810 811