Version 4.0.2.1, tag libreoffice-4.0.2.1
[LibreOffice.git] / sc / source / ui / view / tabvwsha.cxx
blob45e9f026cbacaeae58260ebcbd7921d62e070804
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 "cell.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"
55 sal_Bool ScTabViewShell::GetFunction( String& rFuncStr, sal_uInt16 nErrCode )
57 String aStr;
59 ScSubTotalFunc eFunc = (ScSubTotalFunc) SC_MOD()->GetAppOptions().GetStatusFunc();
60 ScViewData* pViewData = GetViewData();
61 ScMarkData& rMark = pViewData->GetMarkData();
62 bool bIgnoreError = (rMark.IsMarked() || rMark.IsMultiMarked());
64 if (bIgnoreError && (eFunc == SUBTOTAL_FUNC_CNT || eFunc == SUBTOTAL_FUNC_CNT2))
65 nErrCode = 0;
67 if (nErrCode)
69 rFuncStr = ScGlobal::GetLongErrorString(nErrCode);
70 return true;
73 sal_uInt16 nGlobStrId = 0;
74 switch (eFunc)
76 case SUBTOTAL_FUNC_AVE: nGlobStrId = STR_FUN_TEXT_AVG; break;
77 case SUBTOTAL_FUNC_CNT: nGlobStrId = STR_FUN_TEXT_COUNT; break;
78 case SUBTOTAL_FUNC_CNT2: nGlobStrId = STR_FUN_TEXT_COUNT2; break;
79 case SUBTOTAL_FUNC_MAX: nGlobStrId = STR_FUN_TEXT_MAX; break;
80 case SUBTOTAL_FUNC_MIN: nGlobStrId = STR_FUN_TEXT_MIN; break;
81 case SUBTOTAL_FUNC_SUM: nGlobStrId = STR_FUN_TEXT_SUM; break;
82 default:
84 // added to avoid warnings
87 if (nGlobStrId)
89 ScDocument* pDoc = pViewData->GetDocument();
90 SCCOL nPosX = pViewData->GetCurX();
91 SCROW nPosY = pViewData->GetCurY();
92 SCTAB nTab = pViewData->GetTabNo();
94 aStr = ScGlobal::GetRscString(nGlobStrId);
95 aStr += '=';
97 ScAddress aCursor( nPosX, nPosY, nTab );
98 double nVal;
99 if ( pDoc->GetSelectionFunction( eFunc, aCursor, rMark, nVal ) )
101 if ( nVal == 0.0 )
102 aStr += '0';
103 else
105 // Anzahl im Standardformat, die anderen nach Cursorposition
106 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
107 sal_uInt32 nNumFmt = 0;
108 if ( eFunc != SUBTOTAL_FUNC_CNT && eFunc != SUBTOTAL_FUNC_CNT2 )
110 // Zahlformat aus Attributen oder Formel
111 pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt );
112 if ( (nNumFmt % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
114 ScBaseCell* pCell;
115 pDoc->GetCell( nPosX, nPosY, nTab, pCell );
116 if (pCell && pCell->GetCellType() == CELLTYPE_FORMULA)
119 nNumFmt = ((ScFormulaCell*)pCell)->GetStandardFormat(*pFormatter, nNumFmt );
124 String aValStr;
125 Color* pDummy;
126 pFormatter->GetOutputString( nVal, nNumFmt, aValStr, &pDummy );
127 aStr += aValStr;
131 rFuncStr = aStr;
132 return sal_True;
135 return false;
140 // Funktionen, die je nach Selektion disabled sind
141 // Default:
142 // SID_DELETE,
143 // SID_DELETE_CONTENTS,
144 // FID_DELETE_CELL
145 // FID_VALIDATION
148 void ScTabViewShell::GetState( SfxItemSet& rSet )
150 ScViewData* pViewData = GetViewData();
151 ScDocument* pDoc = pViewData->GetDocument();
152 ScDocShell* pDocShell = pViewData->GetDocShell();
153 ScMarkData& rMark = pViewData->GetMarkData();
154 SCCOL nPosX = pViewData->GetCurX();
155 SCROW nPosY = pViewData->GetCurY();
156 SCTAB nTab = pViewData->GetTabNo();
157 sal_uInt16 nMyId = 0;
159 SfxViewFrame* pThisFrame = GetViewFrame();
160 sal_Bool bOle = GetViewFrame()->GetFrame().IsInPlace();
162 SCTAB nTabCount = pDoc->GetTableCount();
163 SCTAB nTabSelCount = rMark.GetSelectCount();
165 SfxWhichIter aIter(rSet);
166 sal_uInt16 nWhich = aIter.FirstWhich();
168 while ( nWhich )
170 switch ( nWhich )
172 case FID_CHG_COMMENT:
174 ScDocShell* pDocSh = GetViewData()->GetDocShell();
175 ScAddress aPos( nPosX, nPosY, nTab );
176 if ( pDocSh->IsReadOnly() || !pDocSh->GetChangeAction(aPos) || pDocSh->IsDocShared() )
177 rSet.DisableItem( nWhich );
179 break;
181 case SID_OPENDLG_EDIT_PRINTAREA:
182 case SID_ADD_PRINTAREA:
183 case SID_DEFINE_PRINTAREA:
185 if ( pDocShell && pDocShell->IsDocShared() )
187 rSet.DisableItem( nWhich );
190 break;
192 case SID_DELETE_PRINTAREA:
193 if ( nTabSelCount > 1 )
195 // #i22589# also take "Print Entire Sheet" into account here
196 sal_Bool bHas = false;
197 for (SCTAB i=0; !bHas && i<nTabCount; i++)
198 bHas = rMark.GetTableSelect(i) && (pDoc->GetPrintRangeCount(i) || pDoc->IsPrintEntireSheet(i));
199 if (!bHas)
200 rSet.DisableItem( nWhich );
202 else if ( !pDoc->GetPrintRangeCount( nTab ) && !pDoc->IsPrintEntireSheet( nTab ) )
203 rSet.DisableItem( nWhich );
204 if ( pDocShell && pDocShell->IsDocShared() )
206 rSet.DisableItem( nWhich );
208 break;
210 case SID_STATUS_PAGESTYLE:
211 case SID_HFEDIT:
212 GetViewData()->GetDocShell()->GetStatePageStyle( *this, rSet, nTab );
213 break;
215 case SID_SEARCH_ITEM:
217 SvxSearchItem aItem(ScGlobal::GetSearchItem()); // make a copy.
218 // Search on current selection if a range is marked.
219 aItem.SetSelection(rMark.IsMarked());
220 rSet.Put(aItem);
221 break;
224 case SID_SEARCH_OPTIONS:
226 sal_uInt16 nOptions = 0xffff; // alles erlaubt
227 // wenn ReadOnly, kein Ersetzen:
228 if (GetViewData()->GetDocShell()->IsReadOnly())
229 nOptions &= ~( SEARCH_OPTIONS_REPLACE | SEARCH_OPTIONS_REPLACE_ALL );
230 rSet.Put( SfxUInt16Item( nWhich, nOptions ) );
232 break;
234 case SID_CURRENTCELL:
236 ScAddress aScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), 0 );
237 String aAddr;
238 aScAddress.Format( aAddr, SCA_ABS, NULL, pDoc->GetAddressConvention() );
239 SfxStringItem aPosItem( SID_CURRENTCELL, aAddr );
241 rSet.Put( aPosItem );
243 break;
245 case SID_CURRENTTAB:
246 // Tabelle fuer Basic ist 1-basiert
247 rSet.Put( SfxUInt16Item( nWhich, static_cast<sal_uInt16>(GetViewData()->GetTabNo()) + 1 ) );
248 break;
250 case SID_CURRENTDOC:
251 rSet.Put( SfxStringItem( nWhich, GetViewData()->GetDocShell()->GetTitle() ) );
252 break;
254 case FID_TOGGLEINPUTLINE:
256 sal_uInt16 nId = ScInputWindowWrapper::GetChildWindowId();
258 if ( pThisFrame->KnowsChildWindow( nId ) )
260 SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
261 rSet.Put( SfxBoolItem( nWhich, pWnd ? sal_True : false ) );
263 else
264 rSet.DisableItem( nWhich );
266 break;
268 case FID_DEL_MANUALBREAKS:
269 if (!pDoc->HasManualBreaks(nTab))
270 rSet.DisableItem( nWhich );
271 break;
273 case FID_RESET_PRINTZOOM:
275 // disablen, wenn schon Default eingestellt
277 String aStyleName = pDoc->GetPageStyle( nTab );
278 ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
279 SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName,
280 SFX_STYLE_FAMILY_PAGE );
281 OSL_ENSURE( pStyleSheet, "PageStyle not found" );
282 if ( pStyleSheet )
284 SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
285 sal_uInt16 nScale = ((const SfxUInt16Item&)
286 rStyleSet.Get(ATTR_PAGE_SCALE)).GetValue();
287 sal_uInt16 nPages = ((const SfxUInt16Item&)
288 rStyleSet.Get(ATTR_PAGE_SCALETOPAGES)).GetValue();
289 if ( nScale == 100 && nPages == 0 )
290 rSet.DisableItem( nWhich );
293 break;
295 case FID_SCALE:
296 case SID_ATTR_ZOOM:
297 if ( bOle )
298 rSet.DisableItem( nWhich );
299 else
301 const Fraction& rOldY = GetViewData()->GetZoomY();
302 sal_uInt16 nZoom = (sal_uInt16)(( rOldY.GetNumerator() * 100 )
303 / rOldY.GetDenominator());
304 rSet.Put( SvxZoomItem( SVX_ZOOM_PERCENT, nZoom, nWhich ) );
306 break;
308 case SID_ATTR_ZOOMSLIDER:
310 if ( bOle )
311 rSet.DisableItem( nWhich );
312 else
314 const Fraction& rOldY = GetViewData()->GetZoomY();
315 sal_uInt16 nCurrentZoom = (sal_uInt16)(( rOldY.GetNumerator() * 100 ) / rOldY.GetDenominator());
317 if( nCurrentZoom )
319 SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM, SID_ATTR_ZOOMSLIDER );
320 aZoomSliderItem.AddSnappingPoint( 100 );
321 rSet.Put( aZoomSliderItem );
325 break;
327 case FID_TOGGLESYNTAX:
328 rSet.Put(SfxBoolItem(nWhich, GetViewData()->IsSyntaxMode()));
329 break;
331 case FID_TOGGLEHEADERS:
332 rSet.Put(SfxBoolItem(nWhich, GetViewData()->IsHeaderMode()));
333 break;
335 case FID_TOGGLEFORMULA:
337 const ScViewOptions& rOpts = pViewData->GetOptions();
338 sal_Bool bFormulaMode = rOpts.GetOption( VOPT_FORMULAS );
339 rSet.Put(SfxBoolItem(nWhich, bFormulaMode ));
341 break;
343 case FID_NORMALVIEWMODE:
344 case FID_PAGEBREAKMODE:
345 // always handle both slots - they exclude each other
346 if ( bOle )
348 rSet.DisableItem( FID_NORMALVIEWMODE );
349 rSet.DisableItem( FID_PAGEBREAKMODE );
351 else
353 rSet.Put(SfxBoolItem(FID_NORMALVIEWMODE, !GetViewData()->IsPagebreakMode()));
354 rSet.Put(SfxBoolItem(FID_PAGEBREAKMODE, GetViewData()->IsPagebreakMode()));
356 break;
358 case FID_FUNCTION_BOX:
359 nMyId = ScFunctionChildWindow::GetChildWindowId();
360 rSet.Put(SfxBoolItem(FID_FUNCTION_BOX, pThisFrame->HasChildWindow(nMyId)));
361 break;
363 case FID_PROTECT_DOC:
365 if ( pDocShell && pDocShell->IsDocShared() )
367 rSet.DisableItem( nWhich );
369 else
371 rSet.Put( SfxBoolItem( nWhich, pDoc->IsDocProtected() ) );
374 break;
376 case FID_PROTECT_TABLE:
378 if ( pDocShell && pDocShell->IsDocShared() )
380 rSet.DisableItem( nWhich );
382 else
384 rSet.Put( SfxBoolItem( nWhich, pDoc->IsTabProtected( nTab ) ) );
387 break;
389 case SID_AUTO_OUTLINE:
391 if (pDoc->GetChangeTrack()!=NULL || GetViewData()->IsMultiMarked())
393 rSet.DisableItem( nWhich );
396 break;
398 case SID_OUTLINE_DELETEALL:
400 SCTAB nOlTab = GetViewData()->GetTabNo();
401 ScOutlineTable* pOlTable = pDoc->GetOutlineTable( nOlTab );
402 if (pOlTable == NULL)
403 rSet.DisableItem( nWhich );
405 break;
407 case SID_WINDOW_SPLIT:
408 rSet.Put(SfxBoolItem(nWhich,
409 pViewData->GetHSplitMode() == SC_SPLIT_NORMAL ||
410 pViewData->GetVSplitMode() == SC_SPLIT_NORMAL ));
411 break;
413 case SID_WINDOW_FIX:
414 rSet.Put(SfxBoolItem(nWhich,
415 pViewData->GetHSplitMode() == SC_SPLIT_FIX ||
416 pViewData->GetVSplitMode() == SC_SPLIT_FIX ));
417 break;
419 case FID_CHG_SHOW:
421 if ( pDoc->GetChangeTrack() == NULL || ( pDocShell && pDocShell->IsDocShared() ) )
422 rSet.DisableItem( nWhich );
424 break;
425 case FID_CHG_ACCEPT:
427 rSet.Put(SfxBoolItem(FID_CHG_ACCEPT,
428 pThisFrame->HasChildWindow(FID_CHG_ACCEPT)));
429 if(pDoc->GetChangeTrack()==NULL)
431 if ( !pThisFrame->HasChildWindow(FID_CHG_ACCEPT) )
433 rSet.DisableItem( nWhich);
436 if ( pDocShell && pDocShell->IsDocShared() )
438 rSet.DisableItem( nWhich );
441 break;
443 case SID_FORMATPAGE:
444 //! bei geschuetzten Tabellen ???
445 if ( pDocShell && ( pDocShell->IsReadOnly() || pDocShell->IsDocShared() ) )
446 rSet.DisableItem( nWhich );
447 break;
449 case SID_PRINTPREVIEW:
450 // Toggle-Slot braucht einen State
451 rSet.Put( SfxBoolItem( nWhich, false ) );
452 break;
454 case SID_READONLY_MODE:
455 rSet.Put( SfxBoolItem( nWhich, GetViewData()->GetDocShell()->IsReadOnly() ) );
456 break;
458 case FID_TAB_DESELECTALL:
459 if ( nTabSelCount == 1 )
460 rSet.DisableItem( nWhich ); // enabled only if several sheets are selected
461 break;
463 } // switch ( nWitch )
464 nWhich = aIter.NextWhich();
465 } // while ( nWitch )
468 //------------------------------------------------------------------
469 void ScTabViewShell::ExecuteCellFormatDlg( SfxRequest& rReq, sal_uInt16 nTabPage )
471 SfxAbstractTabDialog * pDlg = NULL;
472 ScDocument* pDoc = GetViewData()->GetDocument();
474 SvxBoxItem aLineOuter( ATTR_BORDER );
475 SvxBoxInfoItem aLineInner( ATTR_BORDER_INNER );
477 SvxNumberInfoItem* pNumberInfoItem = NULL;
478 const ScPatternAttr* pOldAttrs = GetSelectionPattern();
479 SfxItemSet* pOldSet = new SfxItemSet(
480 pOldAttrs->GetItemSet() );
483 // Umrandungs-Items holen und in den Set packen:
484 GetSelectionFrame( aLineOuter, aLineInner );
485 pOldSet->Put( aLineOuter );
486 pOldSet->Put( aLineInner );
488 // NumberFormat Value aus Value und Language erzeugen und eintueten
489 pOldSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT,
490 pOldAttrs->GetNumberFormat( pDoc->GetFormatTable() ) ) );
492 MakeNumberInfoItem( pDoc, GetViewData(), &pNumberInfoItem );
494 pOldSet->MergeRange( SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO );
495 pOldSet->Put(*pNumberInfoItem );
497 bInFormatDialog = true;
498 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
499 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
501 pDlg = pFact->CreateScAttrDlg( GetViewFrame(), GetDialogParent(), pOldSet, RID_SCDLG_ATTR);
502 OSL_ENSURE(pDlg, "Dialog create fail!");
503 if ( nTabPage != 0xffff )
504 pDlg->SetCurPageId( nTabPage );
505 short nResult = pDlg->Execute();
506 bInFormatDialog = false;
508 if ( nResult == RET_OK )
510 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
512 const SfxPoolItem* pItem=NULL;
513 if(pOutSet->GetItemState(SID_ATTR_NUMBERFORMAT_INFO,sal_True,&pItem)==SFX_ITEM_SET)
516 UpdateNumberFormatter((const SvxNumberInfoItem&)*pItem);
519 ApplyAttributes( pOutSet, pOldSet );
521 rReq.Done( *pOutSet );
523 delete pOldSet;
524 delete pNumberInfoItem;
525 delete pDlg;
528 //------------------------------------------------------------------
530 bool ScTabViewShell::IsRefInputMode() const
532 ScModule* pScMod = SC_MOD();
533 if ( pScMod )
535 if( pScMod->IsRefDialogOpen() )
536 return pScMod->IsFormulaMode();
537 if( pScMod->IsFormulaMode() )
539 ScInputHandler* pHdl = pScMod->GetInputHdl();
540 if ( pHdl )
542 String aString = pHdl->GetEditString();
543 if ( !pHdl->GetSelIsRef() && aString.Len() > 1 &&
544 ( aString.GetChar(0) == '+' || aString.GetChar(0) == '-' ) )
546 const ScViewData* pViewData = GetViewData();
547 if ( pViewData )
549 ScDocument* pDoc = pViewData->GetDocument();
550 if ( pDoc )
552 const ScAddress aPos( pViewData->GetCurPos() );
553 ScCompiler aComp( pDoc, aPos );
554 aComp.SetGrammar(pDoc->GetGrammar());
555 aComp.SetCloseBrackets( false );
556 ScTokenArray* pArr = aComp.CompileString( aString );
557 if ( pArr && pArr->MayReferenceFollow() )
559 return true;
564 else
566 return true;
572 return false;
575 //------------------------------------------------------------------
577 void ScTabViewShell::ExecuteInputDirect()
579 if ( !IsRefInputMode() )
581 ScModule* pScMod = SC_MOD();
582 if ( pScMod )
584 pScMod->InputEnterHandler();
589 //------------------------------------------------------------------
591 void ScTabViewShell::UpdateInputHandler( sal_Bool bForce /* = sal_False */, sal_Bool bStopEditing /* = sal_True */ )
593 ScInputHandler* pHdl = pInputHandler ? pInputHandler : SC_MOD()->GetInputHdl();
595 if ( pHdl )
597 String aString;
598 const EditTextObject* pObject = NULL;
599 ScViewData* pViewData = GetViewData();
600 ScDocument* pDoc = pViewData->GetDocument();
601 CellType eType;
602 SCCOL nPosX = pViewData->GetCurX();
603 SCROW nPosY = pViewData->GetCurY();
604 SCTAB nTab = pViewData->GetTabNo();
605 SCTAB nStartTab = 0;
606 SCTAB nEndTab = 0;
607 SCCOL nStartCol = 0;
608 SCROW nStartRow = 0;
609 SCCOL nEndCol = 0;
610 SCROW nEndRow = 0;
612 pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
613 nEndCol, nEndRow, nEndTab );
615 PutInOrder( nStartCol, nEndCol );
616 PutInOrder( nStartRow, nEndRow );
617 PutInOrder( nStartTab, nEndTab );
619 sal_Bool bHideFormula = false;
620 sal_Bool bHideAll = false;
622 if (pDoc->IsTabProtected(nTab))
624 const ScProtectionAttr* pProt = (const ScProtectionAttr*)
625 pDoc->GetAttr( nPosX,nPosY,nTab,
626 ATTR_PROTECTION);
627 bHideFormula = pProt->GetHideFormula();
628 bHideAll = pProt->GetHideCell();
631 if (!bHideAll)
633 pDoc->GetCellType( nPosX, nPosY, nTab, eType );
634 if (eType == CELLTYPE_FORMULA)
636 if (!bHideFormula)
637 pDoc->GetFormula( nPosX, nPosY, nTab, aString );
639 else if (eType == CELLTYPE_EDIT)
641 ScBaseCell* pCell;
642 pDoc->GetCell( nPosX, nPosY, nTab, pCell );
643 ((ScEditCell*)pCell)->GetData( pObject );
645 else
647 pDoc->GetInputString( nPosX, nPosY, nTab, aString );
648 if (eType == CELLTYPE_STRING)
650 // Bei Bedarf ein ' vorneweg, damit der String nicht ungewollt
651 // als Zahl interpretiert wird, und um dem Benutzer zu zeigen,
652 // dass es ein String ist (#35060#).
653 //! Auch bei Zahlformat "Text"? -> dann beim Editieren wegnehmen
655 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
656 sal_uInt32 nNumFmt;
657 pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt );
658 double fDummy;
659 if ( pFormatter->IsNumberFormat(aString, nNumFmt, fDummy) )
660 aString.Insert('\'',0);
665 ScInputHdlState aState( ScAddress( nPosX, nPosY, nTab ),
666 ScAddress( nStartCol, nStartRow, nTab ),
667 ScAddress( nEndCol, nEndRow, nTab ),
668 aString,
669 pObject );
671 // if using the view's local input handler, this view can always be set
672 // as current view inside NotifyChange.
673 ScTabViewShell* pSourceSh = pInputHandler ? this : NULL;
675 pHdl->NotifyChange( &aState, bForce, pSourceSh, bStopEditing );
678 SfxBindings& rBindings = GetViewFrame()->GetBindings();
679 rBindings.Invalidate( SID_STATUS_SUM ); // immer zusammen mit Eingabezeile
680 rBindings.Invalidate( SID_ATTR_SIZE );
681 rBindings.Invalidate( SID_TABLE_CELL );
684 void ScTabViewShell::UpdateInputHandlerCellAdjust( SvxCellHorJustify eJust )
686 if( ScInputHandler* pHdl = pInputHandler ? pInputHandler : SC_MOD()->GetInputHdl() )
687 pHdl->UpdateCellAdjust( eJust );
690 //------------------------------------------------------------------
692 void ScTabViewShell::ExecuteSave( SfxRequest& rReq )
694 // nur SID_SAVEDOC / SID_SAVEASDOC
696 // Eingabe auf jeden Fall abschliessen, auch wenn eine Formel bearbeitet wird
697 SC_MOD()->InputEnterHandler();
699 if ( GetViewData()->GetDocShell()->IsDocShared() )
701 GetViewData()->GetDocShell()->SetDocumentModified();
704 // ansonsten normal weiter
705 GetViewData()->GetDocShell()->ExecuteSlot( rReq );
708 void ScTabViewShell::GetSaveState( SfxItemSet& rSet )
710 SfxShell* pDocSh = GetViewData()->GetDocShell();
712 SfxWhichIter aIter(rSet);
713 sal_uInt16 nWhich = aIter.FirstWhich();
714 while( nWhich )
716 if ( nWhich != SID_SAVEDOC || !GetViewData()->GetDocShell()->IsDocShared() )
718 // get state from DocShell
719 pDocSh->GetSlotState( nWhich, NULL, &rSet );
721 nWhich = aIter.NextWhich();
725 void ScTabViewShell::ExecDrawOpt( SfxRequest& rReq )
727 ScViewOptions aViewOptions = GetViewData()->GetOptions();
728 ScGridOptions aGridOptions = aViewOptions.GetGridOptions();
730 SfxBindings& rBindings = GetViewFrame()->GetBindings();
731 const SfxItemSet* pArgs = rReq.GetArgs();
732 const SfxPoolItem* pItem;
733 sal_uInt16 nSlotId = rReq.GetSlot();
734 switch (nSlotId)
736 case SID_GRID_VISIBLE:
737 if ( pArgs && pArgs->GetItemState(nSlotId,sal_True,&pItem) == SFX_ITEM_SET )
739 aGridOptions.SetGridVisible( ((const SfxBoolItem*)pItem)->GetValue() );
740 aViewOptions.SetGridOptions(aGridOptions);
741 rBindings.Invalidate(SID_GRID_VISIBLE);
743 break;
745 case SID_GRID_USE:
746 if ( pArgs && pArgs->GetItemState(nSlotId,sal_True,&pItem) == SFX_ITEM_SET )
748 aGridOptions.SetUseGridSnap( ((const SfxBoolItem*)pItem)->GetValue() );
749 aViewOptions.SetGridOptions(aGridOptions);
750 rBindings.Invalidate(SID_GRID_USE);
752 break;
754 case SID_HELPLINES_MOVE:
755 if ( pArgs && pArgs->GetItemState(nSlotId,sal_True,&pItem) == SFX_ITEM_SET )
757 aViewOptions.SetOption( VOPT_HELPLINES, ((const SfxBoolItem*)pItem)->GetValue() );
758 rBindings.Invalidate(SID_HELPLINES_MOVE);
760 break;
763 GetViewData()->SetOptions(aViewOptions);
766 void ScTabViewShell::GetDrawOptState( SfxItemSet& rSet )
768 SfxBoolItem aBool;
770 const ScViewOptions& rViewOptions = GetViewData()->GetOptions();
771 const ScGridOptions& rGridOptions = rViewOptions.GetGridOptions();
773 aBool.SetValue(rGridOptions.GetGridVisible());
774 aBool.SetWhich( SID_GRID_VISIBLE );
775 rSet.Put( aBool );
777 aBool.SetValue(rGridOptions.GetUseGridSnap());
778 aBool.SetWhich( SID_GRID_USE );
779 rSet.Put( aBool );
781 aBool.SetValue(rViewOptions.GetOption( VOPT_HELPLINES ));
782 aBool.SetWhich( SID_HELPLINES_MOVE );
783 rSet.Put( aBool );
789 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */