bump product version to 4.1.6.2
[LibreOffice.git] / sc / source / ui / view / tabvwsha.cxx
blob4e2d64517473a0f6e8c415b20b69c0397e3cc7b0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "scitems.hxx"
21 #include <svl/stritem.hxx>
22 #include <svl/whiter.hxx>
23 #include <svl/zformat.hxx>
24 #include <editeng/boxitem.hxx>
25 #include <svx/numinf.hxx>
26 #include <svl/srchitem.hxx>
27 #include <svx/zoomslideritem.hxx>
28 #include <sfx2/bindings.hxx>
29 #include <sfx2/viewfrm.hxx>
30 #include <sfx2/dispatch.hxx>
31 #include <sfx2/request.hxx>
32 #include <vcl/msgbox.hxx>
34 #include "global.hxx"
35 #include "attrib.hxx"
36 #include "patattr.hxx"
37 #include "document.hxx"
38 #include "formulacell.hxx" // Input Status Edit-Zellen
39 #include "globstr.hrc"
40 #include "scmod.hxx"
41 #include "inputhdl.hxx"
42 #include "inputwin.hxx"
43 #include "docsh.hxx"
44 #include "viewdata.hxx"
45 #include "appoptio.hxx"
46 #include "sc.hrc"
47 #include "stlpool.hxx"
48 #include "tabvwsh.hxx"
49 #include "dwfunctr.hxx"
50 #include "scabstdlg.hxx"
51 #include "compiler.hxx"
52 #include "markdata.hxx"
53 #include "cellvalue.hxx"
54 #include "tokenarray.hxx"
56 sal_Bool ScTabViewShell::GetFunction( String& rFuncStr, sal_uInt16 nErrCode )
58 String aStr;
60 ScSubTotalFunc eFunc = (ScSubTotalFunc) SC_MOD()->GetAppOptions().GetStatusFunc();
61 ScViewData* pViewData = GetViewData();
62 ScMarkData& rMark = pViewData->GetMarkData();
63 bool bIgnoreError = (rMark.IsMarked() || rMark.IsMultiMarked());
65 if (bIgnoreError && (eFunc == SUBTOTAL_FUNC_CNT || eFunc == SUBTOTAL_FUNC_CNT2))
66 nErrCode = 0;
68 if (nErrCode)
70 rFuncStr = ScGlobal::GetLongErrorString(nErrCode);
71 return true;
74 sal_uInt16 nGlobStrId = 0;
75 switch (eFunc)
77 case SUBTOTAL_FUNC_AVE: nGlobStrId = STR_FUN_TEXT_AVG; break;
78 case SUBTOTAL_FUNC_CNT: nGlobStrId = STR_FUN_TEXT_COUNT; break;
79 case SUBTOTAL_FUNC_CNT2: nGlobStrId = STR_FUN_TEXT_COUNT2; break;
80 case SUBTOTAL_FUNC_MAX: nGlobStrId = STR_FUN_TEXT_MAX; break;
81 case SUBTOTAL_FUNC_MIN: nGlobStrId = STR_FUN_TEXT_MIN; break;
82 case SUBTOTAL_FUNC_SUM: nGlobStrId = STR_FUN_TEXT_SUM; break;
83 case SUBTOTAL_FUNC_SELECTION_COUNT: nGlobStrId = STR_FUN_TEXT_SELECTION_COUNT; break;
85 default:
87 // added to avoid warnings
90 if (nGlobStrId)
92 ScDocument* pDoc = pViewData->GetDocument();
93 SCCOL nPosX = pViewData->GetCurX();
94 SCROW nPosY = pViewData->GetCurY();
95 SCTAB nTab = pViewData->GetTabNo();
97 aStr = ScGlobal::GetRscString(nGlobStrId);
98 aStr += '=';
100 ScAddress aCursor( nPosX, nPosY, nTab );
101 double nVal;
102 if ( pDoc->GetSelectionFunction( eFunc, aCursor, rMark, nVal ) )
104 if ( nVal == 0.0 )
105 aStr += '0';
106 else
108 // Number in the standard format, the other on the cursor position
109 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
110 sal_uInt32 nNumFmt = 0;
111 if ( eFunc != SUBTOTAL_FUNC_CNT && eFunc != SUBTOTAL_FUNC_CNT2 && eFunc != SUBTOTAL_FUNC_SELECTION_COUNT)
113 // Zahlformat aus Attributen oder Formel
114 pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt );
117 String aValStr;
118 Color* pDummy;
119 pFormatter->GetOutputString( nVal, nNumFmt, aValStr, &pDummy );
120 aStr += aValStr;
124 rFuncStr = aStr;
125 return sal_True;
128 return false;
133 // Functions that are disabled, depending on the selection
134 // Default:
135 // SID_DELETE,
136 // SID_DELETE_CONTENTS,
137 // FID_DELETE_CELL
138 // FID_VALIDATION
141 void ScTabViewShell::GetState( SfxItemSet& rSet )
143 ScViewData* pViewData = GetViewData();
144 ScDocument* pDoc = pViewData->GetDocument();
145 ScDocShell* pDocShell = pViewData->GetDocShell();
146 ScMarkData& rMark = pViewData->GetMarkData();
147 SCCOL nPosX = pViewData->GetCurX();
148 SCROW nPosY = pViewData->GetCurY();
149 SCTAB nTab = pViewData->GetTabNo();
150 sal_uInt16 nMyId = 0;
152 SfxViewFrame* pThisFrame = GetViewFrame();
153 sal_Bool bOle = GetViewFrame()->GetFrame().IsInPlace();
155 SCTAB nTabCount = pDoc->GetTableCount();
156 SCTAB nTabSelCount = rMark.GetSelectCount();
158 SfxWhichIter aIter(rSet);
159 sal_uInt16 nWhich = aIter.FirstWhich();
161 while ( nWhich )
163 switch ( nWhich )
165 case FID_CHG_COMMENT:
167 ScDocShell* pDocSh = GetViewData()->GetDocShell();
168 ScAddress aPos( nPosX, nPosY, nTab );
169 if ( pDocSh->IsReadOnly() || !pDocSh->GetChangeAction(aPos) || pDocSh->IsDocShared() )
170 rSet.DisableItem( nWhich );
172 break;
174 case SID_OPENDLG_EDIT_PRINTAREA:
175 case SID_ADD_PRINTAREA:
176 case SID_DEFINE_PRINTAREA:
178 if ( pDocShell && pDocShell->IsDocShared() )
180 rSet.DisableItem( nWhich );
183 break;
185 case SID_DELETE_PRINTAREA:
186 if ( nTabSelCount > 1 )
188 // #i22589# also take "Print Entire Sheet" into account here
189 sal_Bool bHas = false;
190 for (SCTAB i=0; !bHas && i<nTabCount; i++)
191 bHas = rMark.GetTableSelect(i) && (pDoc->GetPrintRangeCount(i) || pDoc->IsPrintEntireSheet(i));
192 if (!bHas)
193 rSet.DisableItem( nWhich );
195 else if ( !pDoc->GetPrintRangeCount( nTab ) && !pDoc->IsPrintEntireSheet( nTab ) )
196 rSet.DisableItem( nWhich );
197 if ( pDocShell && pDocShell->IsDocShared() )
199 rSet.DisableItem( nWhich );
201 break;
203 case SID_STATUS_PAGESTYLE:
204 case SID_HFEDIT:
205 GetViewData()->GetDocShell()->GetStatePageStyle( *this, rSet, nTab );
206 break;
208 case SID_SEARCH_ITEM:
210 SvxSearchItem aItem(ScGlobal::GetSearchItem()); // make a copy.
211 // Search on current selection if a range is marked.
212 aItem.SetSelection(rMark.IsMarked());
213 rSet.Put(aItem);
214 break;
217 case SID_SEARCH_OPTIONS:
219 // Anything goes
220 sal_uInt16 nOptions = 0xffff;
222 // No replacement if ReadOnly
223 if (GetViewData()->GetDocShell()->IsReadOnly())
224 nOptions &= ~( SEARCH_OPTIONS_REPLACE | SEARCH_OPTIONS_REPLACE_ALL );
225 rSet.Put( SfxUInt16Item( nWhich, nOptions ) );
227 break;
229 case SID_CURRENTCELL:
231 ScAddress aScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), 0 );
232 String aAddr;
233 aScAddress.Format( aAddr, SCA_ABS, NULL, pDoc->GetAddressConvention() );
234 SfxStringItem aPosItem( SID_CURRENTCELL, aAddr );
236 rSet.Put( aPosItem );
238 break;
240 case SID_CURRENTTAB:
241 // Table for Basic is 1-based
242 rSet.Put( SfxUInt16Item( nWhich, static_cast<sal_uInt16>(GetViewData()->GetTabNo()) + 1 ) );
243 break;
245 case SID_CURRENTDOC:
246 rSet.Put( SfxStringItem( nWhich, GetViewData()->GetDocShell()->GetTitle() ) );
247 break;
249 case FID_TOGGLEINPUTLINE:
251 sal_uInt16 nId = ScInputWindowWrapper::GetChildWindowId();
253 if ( pThisFrame->KnowsChildWindow( nId ) )
255 SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
256 rSet.Put( SfxBoolItem( nWhich, pWnd ? sal_True : false ) );
258 else
259 rSet.DisableItem( nWhich );
261 break;
263 case FID_DEL_MANUALBREAKS:
264 if (!pDoc->HasManualBreaks(nTab))
265 rSet.DisableItem( nWhich );
266 break;
268 case FID_RESET_PRINTZOOM:
270 // disable if already set to default
272 String aStyleName = pDoc->GetPageStyle( nTab );
273 ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
274 SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName,
275 SFX_STYLE_FAMILY_PAGE );
276 OSL_ENSURE( pStyleSheet, "PageStyle not found" );
277 if ( pStyleSheet )
279 SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
280 sal_uInt16 nScale = ((const SfxUInt16Item&)
281 rStyleSet.Get(ATTR_PAGE_SCALE)).GetValue();
282 sal_uInt16 nPages = ((const SfxUInt16Item&)
283 rStyleSet.Get(ATTR_PAGE_SCALETOPAGES)).GetValue();
284 if ( nScale == 100 && nPages == 0 )
285 rSet.DisableItem( nWhich );
288 break;
290 case FID_SCALE:
291 case SID_ATTR_ZOOM:
292 if ( bOle )
293 rSet.DisableItem( nWhich );
294 else
296 const Fraction& rOldY = GetViewData()->GetZoomY();
297 sal_uInt16 nZoom = (sal_uInt16)(( rOldY.GetNumerator() * 100 )
298 / rOldY.GetDenominator());
299 rSet.Put( SvxZoomItem( SVX_ZOOM_PERCENT, nZoom, nWhich ) );
301 break;
303 case SID_ATTR_ZOOMSLIDER:
305 if ( bOle )
306 rSet.DisableItem( nWhich );
307 else
309 const Fraction& rOldY = GetViewData()->GetZoomY();
310 sal_uInt16 nCurrentZoom = (sal_uInt16)(( rOldY.GetNumerator() * 100 ) / rOldY.GetDenominator());
312 if( nCurrentZoom )
314 SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM, SID_ATTR_ZOOMSLIDER );
315 aZoomSliderItem.AddSnappingPoint( 100 );
316 rSet.Put( aZoomSliderItem );
320 break;
322 case FID_TOGGLESYNTAX:
323 rSet.Put(SfxBoolItem(nWhich, GetViewData()->IsSyntaxMode()));
324 break;
326 case FID_TOGGLEHEADERS:
327 rSet.Put(SfxBoolItem(nWhich, GetViewData()->IsHeaderMode()));
328 break;
330 case FID_TOGGLEFORMULA:
332 const ScViewOptions& rOpts = pViewData->GetOptions();
333 sal_Bool bFormulaMode = rOpts.GetOption( VOPT_FORMULAS );
334 rSet.Put(SfxBoolItem(nWhich, bFormulaMode ));
336 break;
338 case FID_NORMALVIEWMODE:
339 case FID_PAGEBREAKMODE:
340 // always handle both slots - they exclude each other
341 if ( bOle )
343 rSet.DisableItem( FID_NORMALVIEWMODE );
344 rSet.DisableItem( FID_PAGEBREAKMODE );
346 else
348 rSet.Put(SfxBoolItem(FID_NORMALVIEWMODE, !GetViewData()->IsPagebreakMode()));
349 rSet.Put(SfxBoolItem(FID_PAGEBREAKMODE, GetViewData()->IsPagebreakMode()));
351 break;
353 case FID_FUNCTION_BOX:
354 nMyId = ScFunctionChildWindow::GetChildWindowId();
355 rSet.Put(SfxBoolItem(FID_FUNCTION_BOX, pThisFrame->HasChildWindow(nMyId)));
356 break;
358 case FID_PROTECT_DOC:
360 if ( pDocShell && pDocShell->IsDocShared() )
362 rSet.DisableItem( nWhich );
364 else
366 rSet.Put( SfxBoolItem( nWhich, pDoc->IsDocProtected() ) );
369 break;
371 case FID_PROTECT_TABLE:
373 if ( pDocShell && pDocShell->IsDocShared() )
375 rSet.DisableItem( nWhich );
377 else
379 rSet.Put( SfxBoolItem( nWhich, pDoc->IsTabProtected( nTab ) ) );
382 break;
384 case SID_AUTO_OUTLINE:
386 if (pDoc->GetChangeTrack()!=NULL || GetViewData()->IsMultiMarked())
388 rSet.DisableItem( nWhich );
391 break;
393 case SID_OUTLINE_DELETEALL:
395 SCTAB nOlTab = GetViewData()->GetTabNo();
396 ScOutlineTable* pOlTable = pDoc->GetOutlineTable( nOlTab );
397 if (pOlTable == NULL)
398 rSet.DisableItem( nWhich );
400 break;
402 case SID_WINDOW_SPLIT:
403 rSet.Put(SfxBoolItem(nWhich,
404 pViewData->GetHSplitMode() == SC_SPLIT_NORMAL ||
405 pViewData->GetVSplitMode() == SC_SPLIT_NORMAL ));
406 break;
408 case SID_WINDOW_FIX:
409 rSet.Put(SfxBoolItem(nWhich,
410 pViewData->GetHSplitMode() == SC_SPLIT_FIX ||
411 pViewData->GetVSplitMode() == SC_SPLIT_FIX ));
412 break;
414 case FID_CHG_SHOW:
416 if ( pDoc->GetChangeTrack() == NULL || ( pDocShell && pDocShell->IsDocShared() ) )
417 rSet.DisableItem( nWhich );
419 break;
420 case FID_CHG_ACCEPT:
422 rSet.Put(SfxBoolItem(FID_CHG_ACCEPT,
423 pThisFrame->HasChildWindow(FID_CHG_ACCEPT)));
424 if(pDoc->GetChangeTrack()==NULL)
426 if ( !pThisFrame->HasChildWindow(FID_CHG_ACCEPT) )
428 rSet.DisableItem( nWhich);
431 if ( pDocShell && pDocShell->IsDocShared() )
433 rSet.DisableItem( nWhich );
436 break;
438 case SID_FORMATPAGE:
439 // in protected tables
440 if ( pDocShell && ( pDocShell->IsReadOnly() || pDocShell->IsDocShared() ) )
441 rSet.DisableItem( nWhich );
442 break;
444 case SID_PRINTPREVIEW:
445 // Toggle slot needs a State
446 rSet.Put( SfxBoolItem( nWhich, false ) );
447 break;
449 case SID_READONLY_MODE:
450 rSet.Put( SfxBoolItem( nWhich, GetViewData()->GetDocShell()->IsReadOnly() ) );
451 break;
453 case FID_TAB_DESELECTALL:
454 if ( nTabSelCount == 1 )
455 rSet.DisableItem( nWhich ); // enabled only if several sheets are selected
456 break;
458 } // switch ( nWitch )
459 nWhich = aIter.NextWhich();
460 } // while ( nWitch )
463 //------------------------------------------------------------------
464 void ScTabViewShell::ExecuteCellFormatDlg(SfxRequest& rReq, const OString &rName)
466 SfxAbstractTabDialog * pDlg = NULL;
467 ScDocument* pDoc = GetViewData()->GetDocument();
469 SvxBoxItem aLineOuter( ATTR_BORDER );
470 SvxBoxInfoItem aLineInner( ATTR_BORDER_INNER );
472 SvxNumberInfoItem* pNumberInfoItem = NULL;
473 const ScPatternAttr* pOldAttrs = GetSelectionPattern();
474 SfxItemSet* pOldSet = new SfxItemSet(
475 pOldAttrs->GetItemSet() );
478 // Get border items and put them in the set:
479 GetSelectionFrame( aLineOuter, aLineInner );
480 //Fix border incorrect for RTL fdo#62399
481 if( pDoc->IsLayoutRTL( GetViewData()->GetTabNo() ) )
483 SvxBoxItem aNewFrame( aLineOuter );
484 SvxBoxInfoItem aTempInfo( aLineInner );
486 if ( aLineInner.IsValid(VALID_LEFT) )
487 aNewFrame.SetLine( aLineOuter.GetLeft(), BOX_LINE_RIGHT );
488 if ( aLineInner.IsValid(VALID_RIGHT) )
489 aNewFrame.SetLine( aLineOuter.GetRight(), BOX_LINE_LEFT );
491 aLineInner.SetValid( VALID_LEFT, aTempInfo.IsValid(VALID_RIGHT));
492 aLineInner.SetValid( VALID_RIGHT, aTempInfo.IsValid(VALID_LEFT));
494 pOldSet->Put( aNewFrame );
496 else
497 pOldSet->Put( aLineOuter );
499 pOldSet->Put( aLineInner );
501 // Generate NumberFormat Value from Value and Language and box it.
502 pOldSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT,
503 pOldAttrs->GetNumberFormat( pDoc->GetFormatTable() ) ) );
505 MakeNumberInfoItem( pDoc, GetViewData(), &pNumberInfoItem );
507 pOldSet->MergeRange( SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO );
508 pOldSet->Put(*pNumberInfoItem );
510 bInFormatDialog = true;
511 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
512 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
514 pDlg = pFact->CreateScAttrDlg(GetViewFrame(), GetDialogParent(), pOldSet);
515 OSL_ENSURE(pDlg, "Dialog create fail!");
516 if (!rName.isEmpty())
517 pDlg->SetCurPageId(rName);
518 short nResult = pDlg->Execute();
519 bInFormatDialog = false;
521 if ( nResult == RET_OK )
523 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
525 const SfxPoolItem* pItem=NULL;
526 if(pOutSet->GetItemState(SID_ATTR_NUMBERFORMAT_INFO,sal_True,&pItem)==SFX_ITEM_SET)
529 UpdateNumberFormatter((const SvxNumberInfoItem&)*pItem);
532 ApplyAttributes( pOutSet, pOldSet );
534 rReq.Done( *pOutSet );
536 delete pOldSet;
537 delete pNumberInfoItem;
538 delete pDlg;
541 //------------------------------------------------------------------
543 bool ScTabViewShell::IsRefInputMode() const
545 ScModule* pScMod = SC_MOD();
546 if ( pScMod )
548 if( pScMod->IsRefDialogOpen() )
549 return pScMod->IsFormulaMode();
550 if( pScMod->IsFormulaMode() )
552 ScInputHandler* pHdl = pScMod->GetInputHdl();
553 if ( pHdl )
555 String aString = pHdl->GetEditString();
556 if ( !pHdl->GetSelIsRef() && aString.Len() > 1 &&
557 ( aString.GetChar(0) == '+' || aString.GetChar(0) == '-' ) )
559 const ScViewData* pViewData = GetViewData();
560 if ( pViewData )
562 ScDocument* pDoc = pViewData->GetDocument();
563 if ( pDoc )
565 const ScAddress aPos( pViewData->GetCurPos() );
566 ScCompiler aComp( pDoc, aPos );
567 aComp.SetGrammar(pDoc->GetGrammar());
568 aComp.SetCloseBrackets( false );
569 ScTokenArray* pArr = aComp.CompileString( aString );
570 if ( pArr && pArr->MayReferenceFollow() )
572 return true;
577 else
579 return true;
585 return false;
588 //------------------------------------------------------------------
590 void ScTabViewShell::ExecuteInputDirect()
592 if ( !IsRefInputMode() )
594 ScModule* pScMod = SC_MOD();
595 if ( pScMod )
597 pScMod->InputEnterHandler();
602 //------------------------------------------------------------------
604 void ScTabViewShell::UpdateInputHandler( sal_Bool bForce /* = sal_False */, sal_Bool bStopEditing /* = sal_True */ )
606 ScInputHandler* pHdl = pInputHandler ? pInputHandler : SC_MOD()->GetInputHdl();
608 if ( pHdl )
610 String aString;
611 const EditTextObject* pObject = NULL;
612 ScViewData* pViewData = GetViewData();
613 ScDocument* pDoc = pViewData->GetDocument();
614 CellType eType;
615 SCCOL nPosX = pViewData->GetCurX();
616 SCROW nPosY = pViewData->GetCurY();
617 SCTAB nTab = pViewData->GetTabNo();
618 SCTAB nStartTab = 0;
619 SCTAB nEndTab = 0;
620 SCCOL nStartCol = 0;
621 SCROW nStartRow = 0;
622 SCCOL nEndCol = 0;
623 SCROW nEndRow = 0;
624 ScAddress aPos = pViewData->GetCurPos();
626 pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
627 nEndCol, nEndRow, nEndTab );
629 PutInOrder( nStartCol, nEndCol );
630 PutInOrder( nStartRow, nEndRow );
631 PutInOrder( nStartTab, nEndTab );
633 bool bHideFormula = false;
634 bool bHideAll = false;
636 if (pDoc->IsTabProtected(nTab))
638 const ScProtectionAttr* pProt = (const ScProtectionAttr*)
639 pDoc->GetAttr( nPosX,nPosY,nTab,
640 ATTR_PROTECTION);
641 bHideFormula = pProt->GetHideFormula();
642 bHideAll = pProt->GetHideCell();
645 if (!bHideAll)
647 eType = pDoc->GetCellType(aPos);
648 if (eType == CELLTYPE_FORMULA)
650 if (!bHideFormula)
651 pDoc->GetFormula( nPosX, nPosY, nTab, aString );
653 else if (eType == CELLTYPE_EDIT)
655 pObject = pDoc->GetEditText(aPos);
657 else
659 pDoc->GetInputString( nPosX, nPosY, nTab, aString );
660 if (eType == CELLTYPE_STRING)
662 // Bei Bedarf ein ' vorneweg, damit der String nicht ungewollt
663 // als Zahl interpretiert wird, und um dem Benutzer zu zeigen,
664 // dass es ein String ist (#35060#).
665 //! Auch bei Zahlformat "Text"? -> dann beim Editieren wegnehmen
667 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
668 sal_uInt32 nNumFmt;
669 pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt );
670 double fDummy;
671 if ( pFormatter->IsNumberFormat(aString, nNumFmt, fDummy) )
672 aString.Insert('\'',0);
677 ScInputHdlState aState( ScAddress( nPosX, nPosY, nTab ),
678 ScAddress( nStartCol, nStartRow, nTab ),
679 ScAddress( nEndCol, nEndRow, nTab ),
680 aString,
681 pObject );
683 // if using the view's local input handler, this view can always be set
684 // as current view inside NotifyChange.
685 ScTabViewShell* pSourceSh = pInputHandler ? this : NULL;
687 pHdl->NotifyChange( &aState, bForce, pSourceSh, bStopEditing );
690 SfxBindings& rBindings = GetViewFrame()->GetBindings();
691 rBindings.Invalidate( SID_STATUS_SUM ); // immer zusammen mit Eingabezeile
692 rBindings.Invalidate( SID_ATTR_SIZE );
693 rBindings.Invalidate( SID_TABLE_CELL );
696 void ScTabViewShell::UpdateInputHandlerCellAdjust( SvxCellHorJustify eJust )
698 if( ScInputHandler* pHdl = pInputHandler ? pInputHandler : SC_MOD()->GetInputHdl() )
699 pHdl->UpdateCellAdjust( eJust );
702 //------------------------------------------------------------------
704 void ScTabViewShell::ExecuteSave( SfxRequest& rReq )
706 // only SID_SAVEDOC / SID_SAVEASDOC
708 // Finish entering in any case, even if a formula is being processed
709 SC_MOD()->InputEnterHandler();
711 if ( GetViewData()->GetDocShell()->IsDocShared() )
713 GetViewData()->GetDocShell()->SetDocumentModified();
716 // otherwise as normal
717 GetViewData()->GetDocShell()->ExecuteSlot( rReq );
720 void ScTabViewShell::GetSaveState( SfxItemSet& rSet )
722 SfxShell* pDocSh = GetViewData()->GetDocShell();
724 SfxWhichIter aIter(rSet);
725 sal_uInt16 nWhich = aIter.FirstWhich();
726 while( nWhich )
728 if ( nWhich != SID_SAVEDOC || !GetViewData()->GetDocShell()->IsDocShared() )
730 // get state from DocShell
731 pDocSh->GetSlotState( nWhich, NULL, &rSet );
733 nWhich = aIter.NextWhich();
737 void ScTabViewShell::ExecDrawOpt( SfxRequest& rReq )
739 ScViewOptions aViewOptions = GetViewData()->GetOptions();
740 ScGridOptions aGridOptions = aViewOptions.GetGridOptions();
742 SfxBindings& rBindings = GetViewFrame()->GetBindings();
743 const SfxItemSet* pArgs = rReq.GetArgs();
744 const SfxPoolItem* pItem;
745 sal_uInt16 nSlotId = rReq.GetSlot();
746 switch (nSlotId)
748 case SID_GRID_VISIBLE:
749 if ( pArgs && pArgs->GetItemState(nSlotId,sal_True,&pItem) == SFX_ITEM_SET )
751 aGridOptions.SetGridVisible( ((const SfxBoolItem*)pItem)->GetValue() );
752 aViewOptions.SetGridOptions(aGridOptions);
753 rBindings.Invalidate(SID_GRID_VISIBLE);
755 break;
757 case SID_GRID_USE:
758 if ( pArgs && pArgs->GetItemState(nSlotId,sal_True,&pItem) == SFX_ITEM_SET )
760 aGridOptions.SetUseGridSnap( ((const SfxBoolItem*)pItem)->GetValue() );
761 aViewOptions.SetGridOptions(aGridOptions);
762 rBindings.Invalidate(SID_GRID_USE);
764 break;
766 case SID_HELPLINES_MOVE:
767 if ( pArgs && pArgs->GetItemState(nSlotId,sal_True,&pItem) == SFX_ITEM_SET )
769 aViewOptions.SetOption( VOPT_HELPLINES, ((const SfxBoolItem*)pItem)->GetValue() );
770 rBindings.Invalidate(SID_HELPLINES_MOVE);
772 break;
775 GetViewData()->SetOptions(aViewOptions);
778 void ScTabViewShell::GetDrawOptState( SfxItemSet& rSet )
780 SfxBoolItem aBool;
782 const ScViewOptions& rViewOptions = GetViewData()->GetOptions();
783 const ScGridOptions& rGridOptions = rViewOptions.GetGridOptions();
785 aBool.SetValue(rGridOptions.GetGridVisible());
786 aBool.SetWhich( SID_GRID_VISIBLE );
787 rSet.Put( aBool );
789 aBool.SetValue(rGridOptions.GetUseGridSnap());
790 aBool.SetWhich( SID_GRID_USE );
791 rSet.Put( aBool );
793 aBool.SetValue(rViewOptions.GetOption( VOPT_HELPLINES ));
794 aBool.SetWhich( SID_HELPLINES_MOVE );
795 rSet.Put( aBool );
801 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */