Bump version to 4.3-4
[LibreOffice.git] / sc / source / ui / view / tabvwsha.cxx
blob8cb4244e8f9a5d128e4725446e16e6944001f081
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 <svl/ilstitem.hxx>
28 #include <svl/int64item.hxx>
29 #include <svx/zoomslideritem.hxx>
30 #include <sfx2/bindings.hxx>
31 #include <sfx2/viewfrm.hxx>
32 #include <sfx2/dispatch.hxx>
33 #include <sfx2/request.hxx>
34 #include <vcl/msgbox.hxx>
36 #include "global.hxx"
37 #include "attrib.hxx"
38 #include "patattr.hxx"
39 #include "document.hxx"
40 #include "formulacell.hxx"
41 #include "globstr.hrc"
42 #include "scmod.hxx"
43 #include "inputhdl.hxx"
44 #include "inputwin.hxx"
45 #include "docsh.hxx"
46 #include "viewdata.hxx"
47 #include "appoptio.hxx"
48 #include "sc.hrc"
49 #include "stlpool.hxx"
50 #include "tabvwsh.hxx"
51 #include "dwfunctr.hxx"
52 #include "scabstdlg.hxx"
53 #include "compiler.hxx"
54 #include "markdata.hxx"
55 #include "cellvalue.hxx"
56 #include "tokenarray.hxx"
58 #include <com/sun/star/table/BorderLineStyle.hpp>
60 #include <boost/scoped_ptr.hpp>
62 using namespace com::sun::star;
64 bool ScTabViewShell::GetFunction( OUString& rFuncStr, sal_uInt16 nErrCode )
66 OUString aStr;
68 ScSubTotalFunc eFunc = (ScSubTotalFunc) SC_MOD()->GetAppOptions().GetStatusFunc();
69 ScViewData* pViewData = GetViewData();
70 ScMarkData& rMark = pViewData->GetMarkData();
71 bool bIgnoreError = (rMark.IsMarked() || rMark.IsMultiMarked());
73 if (bIgnoreError && (eFunc == SUBTOTAL_FUNC_CNT || eFunc == SUBTOTAL_FUNC_CNT2))
74 nErrCode = 0;
76 if (nErrCode)
78 rFuncStr = ScGlobal::GetLongErrorString(nErrCode);
79 return true;
82 sal_uInt16 nGlobStrId = 0;
83 switch (eFunc)
85 case SUBTOTAL_FUNC_AVE: nGlobStrId = STR_FUN_TEXT_AVG; break;
86 case SUBTOTAL_FUNC_CNT: nGlobStrId = STR_FUN_TEXT_COUNT; break;
87 case SUBTOTAL_FUNC_CNT2: nGlobStrId = STR_FUN_TEXT_COUNT2; break;
88 case SUBTOTAL_FUNC_MAX: nGlobStrId = STR_FUN_TEXT_MAX; break;
89 case SUBTOTAL_FUNC_MIN: nGlobStrId = STR_FUN_TEXT_MIN; break;
90 case SUBTOTAL_FUNC_SUM: nGlobStrId = STR_FUN_TEXT_SUM; break;
91 case SUBTOTAL_FUNC_SELECTION_COUNT: nGlobStrId = STR_FUN_TEXT_SELECTION_COUNT; break;
93 default:
95 // added to avoid warnings
98 if (nGlobStrId)
100 ScDocument* pDoc = pViewData->GetDocument();
101 SCCOL nPosX = pViewData->GetCurX();
102 SCROW nPosY = pViewData->GetCurY();
103 SCTAB nTab = pViewData->GetTabNo();
105 aStr = ScGlobal::GetRscString(nGlobStrId);
106 aStr += "=";
108 ScAddress aCursor( nPosX, nPosY, nTab );
109 double nVal;
110 if ( pDoc->GetSelectionFunction( eFunc, aCursor, rMark, nVal ) )
112 if ( nVal == 0.0 )
113 aStr += "0";
114 else
116 // Number in the standard format, the other on the cursor position
117 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
118 sal_uInt32 nNumFmt = 0;
119 if ( eFunc != SUBTOTAL_FUNC_CNT && eFunc != SUBTOTAL_FUNC_CNT2 && eFunc != SUBTOTAL_FUNC_SELECTION_COUNT)
121 // Zahlformat aus Attributen oder Formel
122 pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt );
125 OUString aValStr;
126 Color* pDummy;
127 pFormatter->GetOutputString( nVal, nNumFmt, aValStr, &pDummy );
128 aStr += aValStr;
132 rFuncStr = aStr;
133 return true;
136 return false;
139 // Functions that are disabled, depending on the selection
140 // Default:
141 // SID_DELETE,
142 // SID_DELETE_CONTENTS,
143 // FID_DELETE_CELL
144 // FID_VALIDATION
147 void ScTabViewShell::GetState( SfxItemSet& rSet )
149 ScViewData* pViewData = GetViewData();
150 ScDocument* pDoc = pViewData->GetDocument();
151 ScDocShell* pDocShell = pViewData->GetDocShell();
152 ScMarkData& rMark = pViewData->GetMarkData();
153 SCCOL nPosX = pViewData->GetCurX();
154 SCROW nPosY = pViewData->GetCurY();
155 SCTAB nTab = pViewData->GetTabNo();
156 sal_uInt16 nMyId = 0;
158 SfxViewFrame* pThisFrame = GetViewFrame();
159 bool bOle = GetViewFrame()->GetFrame().IsInPlace();
161 SCTAB nTabSelCount = rMark.GetSelectCount();
163 SfxWhichIter aIter(rSet);
164 sal_uInt16 nWhich = aIter.FirstWhich();
166 while ( nWhich )
168 switch ( nWhich )
170 case FID_CHG_COMMENT:
172 ScDocShell* pDocSh = GetViewData()->GetDocShell();
173 ScAddress aPos( nPosX, nPosY, nTab );
174 if ( pDocSh->IsReadOnly() || !pDocSh->GetChangeAction(aPos) || pDocSh->IsDocShared() )
175 rSet.DisableItem( nWhich );
177 break;
179 case SID_OPENDLG_EDIT_PRINTAREA:
180 case SID_ADD_PRINTAREA:
181 case SID_DEFINE_PRINTAREA:
183 if ( pDocShell && pDocShell->IsDocShared() )
185 rSet.DisableItem( nWhich );
188 break;
190 case SID_DELETE_PRINTAREA:
191 if ( pDocShell && pDocShell->IsDocShared() )
193 rSet.DisableItem( nWhich );
195 else if (pDoc->IsPrintEntireSheet(nTab))
196 rSet.DisableItem(nWhich);
197 break;
199 case SID_STATUS_PAGESTYLE:
200 case SID_HFEDIT:
201 GetViewData()->GetDocShell()->GetStatePageStyle( *this, rSet, nTab );
202 break;
204 case SID_SEARCH_ITEM:
206 SvxSearchItem aItem(ScGlobal::GetSearchItem()); // make a copy.
207 // Search on current selection if a range is marked.
208 aItem.SetSelection(rMark.IsMarked());
209 rSet.Put(aItem);
210 break;
213 case SID_SEARCH_OPTIONS:
215 // Anything goes
216 sal_uInt16 nOptions = 0xffff;
218 // No replacement if ReadOnly
219 if (GetViewData()->GetDocShell()->IsReadOnly())
220 nOptions &= ~( SEARCH_OPTIONS_REPLACE | SEARCH_OPTIONS_REPLACE_ALL );
221 rSet.Put( SfxUInt16Item( nWhich, nOptions ) );
223 break;
225 case SID_CURRENTCELL:
227 ScAddress aScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), 0 );
228 OUString aAddr(aScAddress.Format(SCA_ABS, NULL, pDoc->GetAddressConvention()));
229 SfxStringItem aPosItem( SID_CURRENTCELL, aAddr );
231 rSet.Put( aPosItem );
233 break;
235 case SID_CURRENTTAB:
236 // Table for Basic is 1-based
237 rSet.Put( SfxUInt16Item( nWhich, static_cast<sal_uInt16>(GetViewData()->GetTabNo()) + 1 ) );
238 break;
240 case SID_CURRENTDOC:
241 rSet.Put( SfxStringItem( nWhich, GetViewData()->GetDocShell()->GetTitle() ) );
242 break;
244 case FID_TOGGLEINPUTLINE:
246 sal_uInt16 nId = ScInputWindowWrapper::GetChildWindowId();
248 if ( pThisFrame->KnowsChildWindow( nId ) )
250 SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
251 rSet.Put( SfxBoolItem( nWhich, pWnd ? sal_True : false ) );
253 else
254 rSet.DisableItem( nWhich );
256 break;
258 case FID_DEL_MANUALBREAKS:
259 if (!pDoc->HasManualBreaks(nTab))
260 rSet.DisableItem( nWhich );
261 break;
263 case FID_RESET_PRINTZOOM:
265 // disable if already set to default
267 OUString aStyleName = pDoc->GetPageStyle( nTab );
268 ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
269 SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName,
270 SFX_STYLE_FAMILY_PAGE );
271 OSL_ENSURE( pStyleSheet, "PageStyle not found" );
272 if ( pStyleSheet )
274 SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
275 sal_uInt16 nScale = ((const SfxUInt16Item&)
276 rStyleSet.Get(ATTR_PAGE_SCALE)).GetValue();
277 sal_uInt16 nPages = ((const SfxUInt16Item&)
278 rStyleSet.Get(ATTR_PAGE_SCALETOPAGES)).GetValue();
279 if ( nScale == 100 && nPages == 0 )
280 rSet.DisableItem( nWhich );
283 break;
285 case FID_SCALE:
286 case SID_ATTR_ZOOM:
287 if ( bOle )
288 rSet.DisableItem( nWhich );
289 else
291 const Fraction& rOldY = GetViewData()->GetZoomY();
292 sal_uInt16 nZoom = (sal_uInt16)(( rOldY.GetNumerator() * 100 )
293 / rOldY.GetDenominator());
294 rSet.Put( SvxZoomItem( SVX_ZOOM_PERCENT, nZoom, nWhich ) );
296 break;
298 case SID_ATTR_ZOOMSLIDER:
300 if ( bOle )
301 rSet.DisableItem( nWhich );
302 else
304 const Fraction& rOldY = GetViewData()->GetZoomY();
305 sal_uInt16 nCurrentZoom = (sal_uInt16)(( rOldY.GetNumerator() * 100 ) / rOldY.GetDenominator());
307 if( nCurrentZoom )
309 SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM, SID_ATTR_ZOOMSLIDER );
310 aZoomSliderItem.AddSnappingPoint( 100 );
311 rSet.Put( aZoomSliderItem );
315 break;
317 case FID_TOGGLESYNTAX:
318 rSet.Put(SfxBoolItem(nWhich, GetViewData()->IsSyntaxMode()));
319 break;
321 case FID_TOGGLEHEADERS:
322 rSet.Put(SfxBoolItem(nWhich, GetViewData()->IsHeaderMode()));
323 break;
325 case FID_TOGGLEFORMULA:
327 const ScViewOptions& rOpts = pViewData->GetOptions();
328 bool bFormulaMode = rOpts.GetOption( VOPT_FORMULAS );
329 rSet.Put(SfxBoolItem(nWhich, bFormulaMode ));
331 break;
333 case FID_NORMALVIEWMODE:
334 case FID_PAGEBREAKMODE:
335 // always handle both slots - they exclude each other
336 if ( bOle )
338 rSet.DisableItem( FID_NORMALVIEWMODE );
339 rSet.DisableItem( FID_PAGEBREAKMODE );
341 else
343 rSet.Put(SfxBoolItem(FID_NORMALVIEWMODE, !GetViewData()->IsPagebreakMode()));
344 rSet.Put(SfxBoolItem(FID_PAGEBREAKMODE, GetViewData()->IsPagebreakMode()));
346 break;
348 case FID_FUNCTION_BOX:
349 nMyId = ScFunctionChildWindow::GetChildWindowId();
350 rSet.Put(SfxBoolItem(FID_FUNCTION_BOX, pThisFrame->HasChildWindow(nMyId)));
351 break;
353 case FID_PROTECT_DOC:
355 if ( pDocShell && pDocShell->IsDocShared() )
357 rSet.DisableItem( nWhich );
359 else
361 rSet.Put( SfxBoolItem( nWhich, pDoc->IsDocProtected() ) );
364 break;
366 case FID_PROTECT_TABLE:
368 if ( pDocShell && pDocShell->IsDocShared() )
370 rSet.DisableItem( nWhich );
372 else
374 rSet.Put( SfxBoolItem( nWhich, pDoc->IsTabProtected( nTab ) ) );
377 break;
379 case SID_AUTO_OUTLINE:
381 if (pDoc->GetChangeTrack()!=NULL || GetViewData()->IsMultiMarked())
383 rSet.DisableItem( nWhich );
386 break;
388 case SID_OUTLINE_DELETEALL:
390 SCTAB nOlTab = GetViewData()->GetTabNo();
391 ScOutlineTable* pOlTable = pDoc->GetOutlineTable( nOlTab );
392 if (pOlTable == NULL)
393 rSet.DisableItem( nWhich );
395 break;
397 case SID_WINDOW_SPLIT:
398 rSet.Put(SfxBoolItem(nWhich,
399 pViewData->GetHSplitMode() == SC_SPLIT_NORMAL ||
400 pViewData->GetVSplitMode() == SC_SPLIT_NORMAL ));
401 break;
403 case SID_WINDOW_FIX:
404 rSet.Put(SfxBoolItem(nWhich,
405 pViewData->GetHSplitMode() == SC_SPLIT_FIX ||
406 pViewData->GetVSplitMode() == SC_SPLIT_FIX ));
407 break;
409 case FID_CHG_SHOW:
411 if ( pDoc->GetChangeTrack() == NULL || ( pDocShell && pDocShell->IsDocShared() ) )
412 rSet.DisableItem( nWhich );
414 break;
415 case FID_CHG_ACCEPT:
417 rSet.Put(SfxBoolItem(FID_CHG_ACCEPT,
418 pThisFrame->HasChildWindow(FID_CHG_ACCEPT)));
419 if(pDoc->GetChangeTrack()==NULL)
421 if ( !pThisFrame->HasChildWindow(FID_CHG_ACCEPT) )
423 rSet.DisableItem( nWhich);
426 if ( pDocShell && pDocShell->IsDocShared() )
428 rSet.DisableItem( nWhich );
431 break;
433 case SID_FORMATPAGE:
434 // in protected tables
435 if ( pDocShell && ( pDocShell->IsReadOnly() || pDocShell->IsDocShared() ) )
436 rSet.DisableItem( nWhich );
437 break;
439 case SID_PRINTPREVIEW:
440 // Toggle slot needs a State
441 rSet.Put( SfxBoolItem( nWhich, false ) );
442 break;
444 case SID_READONLY_MODE:
445 rSet.Put( SfxBoolItem( nWhich, GetViewData()->GetDocShell()->IsReadOnly() ) );
446 break;
448 case FID_TAB_DESELECTALL:
449 if ( nTabSelCount == 1 )
450 rSet.DisableItem( nWhich ); // enabled only if several sheets are selected
451 break;
453 } // switch ( nWitch )
454 nWhich = aIter.NextWhich();
455 } // while ( nWitch )
459 void ScTabViewShell::ExecuteCellFormatDlg(SfxRequest& rReq, const OString &rName)
461 ScDocument* pDoc = GetViewData()->GetDocument();
463 SvxBoxItem aLineOuter( ATTR_BORDER );
464 SvxBoxInfoItem aLineInner( ATTR_BORDER_INNER );
466 const ScPatternAttr* pOldAttrs = GetSelectionPattern();
468 boost::scoped_ptr<SfxAbstractTabDialog> pDlg;
469 boost::scoped_ptr<SfxItemSet> pOldSet(new SfxItemSet(pOldAttrs->GetItemSet()));
470 boost::scoped_ptr<SvxNumberInfoItem> pNumberInfoItem;
472 pOldSet->MergeRange(SID_ATTR_BORDER_STYLES, SID_ATTR_BORDER_DEFAULT_WIDTH);
474 // We only allow these border line types.
475 std::vector<sal_Int32> aBorderStyles;
476 aBorderStyles.reserve(5);
477 aBorderStyles.push_back(table::BorderLineStyle::SOLID);
478 aBorderStyles.push_back(table::BorderLineStyle::DOTTED);
479 aBorderStyles.push_back(table::BorderLineStyle::DASHED);
480 aBorderStyles.push_back(table::BorderLineStyle::FINE_DASHED);
481 aBorderStyles.push_back(table::BorderLineStyle::DASH_DOT);
482 aBorderStyles.push_back(table::BorderLineStyle::DASH_DOT_DOT);
483 aBorderStyles.push_back(table::BorderLineStyle::DOUBLE_THIN);
485 SfxIntegerListItem aBorderStylesItem(SID_ATTR_BORDER_STYLES, aBorderStyles);
486 pOldSet->Put(aBorderStylesItem);
488 // Set the default border width to 0.75 points.
489 SfxInt64Item aBorderWidthItem(SID_ATTR_BORDER_DEFAULT_WIDTH, 75);
490 pOldSet->Put(aBorderWidthItem);
492 // Get border items and put them in the set:
493 GetSelectionFrame( aLineOuter, aLineInner );
494 //Fix border incorrect for RTL fdo#62399
495 if( pDoc->IsLayoutRTL( GetViewData()->GetTabNo() ) )
497 SvxBoxItem aNewFrame( aLineOuter );
498 SvxBoxInfoItem aTempInfo( aLineInner );
500 if ( aLineInner.IsValid(VALID_LEFT) )
501 aNewFrame.SetLine( aLineOuter.GetLeft(), BOX_LINE_RIGHT );
502 if ( aLineInner.IsValid(VALID_RIGHT) )
503 aNewFrame.SetLine( aLineOuter.GetRight(), BOX_LINE_LEFT );
505 aLineInner.SetValid( VALID_LEFT, aTempInfo.IsValid(VALID_RIGHT));
506 aLineInner.SetValid( VALID_RIGHT, aTempInfo.IsValid(VALID_LEFT));
508 pOldSet->Put( aNewFrame );
510 else
511 pOldSet->Put( aLineOuter );
513 pOldSet->Put( aLineInner );
515 // Generate NumberFormat Value from Value and Language and box it.
516 pOldSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT,
517 pOldAttrs->GetNumberFormat( pDoc->GetFormatTable() ) ) );
519 pNumberInfoItem.reset(MakeNumberInfoItem(pDoc, GetViewData()));
521 pOldSet->MergeRange( SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO );
522 pOldSet->Put(*pNumberInfoItem );
524 bInFormatDialog = true;
525 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
526 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
528 pDlg.reset(pFact->CreateScAttrDlg(GetViewFrame(), GetDialogParent(), pOldSet.get()));
530 if (!rName.isEmpty())
531 pDlg->SetCurPageId(rName);
532 short nResult = pDlg->Execute();
533 bInFormatDialog = false;
535 if ( nResult == RET_OK )
537 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
539 const SfxPoolItem* pItem=NULL;
540 if(pOutSet->GetItemState(SID_ATTR_NUMBERFORMAT_INFO,true,&pItem)==SFX_ITEM_SET)
543 UpdateNumberFormatter((const SvxNumberInfoItem&)*pItem);
546 ApplyAttributes(pOutSet, pOldSet.get());
548 rReq.Done( *pOutSet );
552 bool ScTabViewShell::IsRefInputMode() const
554 ScModule* pScMod = SC_MOD();
555 if ( pScMod )
557 if( pScMod->IsRefDialogOpen() )
558 return pScMod->IsFormulaMode();
559 if( pScMod->IsFormulaMode() )
561 ScInputHandler* pHdl = pScMod->GetInputHdl();
562 if ( pHdl )
564 OUString aString = pHdl->GetEditString();
565 if ( !pHdl->GetSelIsRef() && aString.getLength() > 1 &&
566 ( aString[0] == '+' || aString[0] == '-' ) )
568 const ScViewData* pViewData = GetViewData();
569 if ( pViewData )
571 ScDocument* pDoc = pViewData->GetDocument();
572 if ( pDoc )
574 const ScAddress aPos( pViewData->GetCurPos() );
575 ScCompiler aComp( pDoc, aPos );
576 aComp.SetGrammar(pDoc->GetGrammar());
577 aComp.SetCloseBrackets( false );
578 boost::scoped_ptr<ScTokenArray> pArr(aComp.CompileString(aString));
579 if ( pArr && pArr->MayReferenceFollow() )
581 return true;
586 else
588 return true;
594 return false;
597 void ScTabViewShell::ExecuteInputDirect()
599 if ( !IsRefInputMode() )
601 ScModule* pScMod = SC_MOD();
602 if ( pScMod )
604 pScMod->InputEnterHandler();
609 void ScTabViewShell::UpdateInputHandler( bool bForce /* = sal_False */, bool bStopEditing /* = sal_True */ )
611 ScInputHandler* pHdl = pInputHandler ? pInputHandler : SC_MOD()->GetInputHdl();
613 if ( pHdl )
615 OUString aString;
616 const EditTextObject* pObject = NULL;
617 ScViewData* pViewData = GetViewData();
618 ScDocument* pDoc = pViewData->GetDocument();
619 CellType eType;
620 SCCOL nPosX = pViewData->GetCurX();
621 SCROW nPosY = pViewData->GetCurY();
622 SCTAB nTab = pViewData->GetTabNo();
623 SCTAB nStartTab = 0;
624 SCTAB nEndTab = 0;
625 SCCOL nStartCol = 0;
626 SCROW nStartRow = 0;
627 SCCOL nEndCol = 0;
628 SCROW nEndRow = 0;
629 ScAddress aPos = pViewData->GetCurPos();
631 pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
632 nEndCol, nEndRow, nEndTab );
634 PutInOrder( nStartCol, nEndCol );
635 PutInOrder( nStartRow, nEndRow );
636 PutInOrder( nStartTab, nEndTab );
638 bool bHideFormula = false;
639 bool bHideAll = false;
641 if (pDoc->IsTabProtected(nTab))
643 const ScProtectionAttr* pProt = (const ScProtectionAttr*)
644 pDoc->GetAttr( nPosX,nPosY,nTab,
645 ATTR_PROTECTION);
646 bHideFormula = pProt->GetHideFormula();
647 bHideAll = pProt->GetHideCell();
650 if (!bHideAll)
652 eType = pDoc->GetCellType(aPos);
653 if (eType == CELLTYPE_FORMULA)
655 if (!bHideFormula)
656 pDoc->GetFormula( nPosX, nPosY, nTab, aString );
658 else if (eType == CELLTYPE_EDIT)
660 pObject = pDoc->GetEditText(aPos);
662 else
664 pDoc->GetInputString( nPosX, nPosY, nTab, aString );
665 if (eType == CELLTYPE_STRING)
667 // Bei Bedarf ein ' vorneweg, damit der String nicht ungewollt
668 // als Zahl interpretiert wird, und um dem Benutzer zu zeigen,
669 // dass es ein String ist (#35060#).
670 //! Auch bei Zahlformat "Text"? -> dann beim Editieren wegnehmen
672 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
673 sal_uInt32 nNumFmt;
674 pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt );
675 double fDummy;
676 if ( pFormatter->IsNumberFormat(aString, nNumFmt, fDummy) )
677 aString = "'" + aString;
682 ScInputHdlState aState( ScAddress( nPosX, nPosY, nTab ),
683 ScAddress( nStartCol, nStartRow, nTab ),
684 ScAddress( nEndCol, nEndRow, nTab ),
685 aString,
686 pObject );
688 // if using the view's local input handler, this view can always be set
689 // as current view inside NotifyChange.
690 ScTabViewShell* pSourceSh = pInputHandler ? this : NULL;
692 pHdl->NotifyChange( &aState, bForce, pSourceSh, bStopEditing );
695 SfxBindings& rBindings = GetViewFrame()->GetBindings();
696 rBindings.Invalidate( SID_STATUS_SUM ); // immer zusammen mit Eingabezeile
697 rBindings.Invalidate( SID_ATTR_SIZE );
698 rBindings.Invalidate( SID_TABLE_CELL );
701 void ScTabViewShell::UpdateInputHandlerCellAdjust( SvxCellHorJustify eJust )
703 if( ScInputHandler* pHdl = pInputHandler ? pInputHandler : SC_MOD()->GetInputHdl() )
704 pHdl->UpdateCellAdjust( eJust );
707 void ScTabViewShell::ExecuteSave( SfxRequest& rReq )
709 // only SID_SAVEDOC / SID_SAVEASDOC
711 // Finish entering in any case, even if a formula is being processed
712 SC_MOD()->InputEnterHandler();
714 if ( GetViewData()->GetDocShell()->IsDocShared() )
716 GetViewData()->GetDocShell()->SetDocumentModified();
719 // otherwise as normal
720 GetViewData()->GetDocShell()->ExecuteSlot( rReq );
723 void ScTabViewShell::GetSaveState( SfxItemSet& rSet )
725 SfxShell* pDocSh = GetViewData()->GetDocShell();
727 SfxWhichIter aIter(rSet);
728 sal_uInt16 nWhich = aIter.FirstWhich();
729 while( nWhich )
731 if ( nWhich != SID_SAVEDOC || !GetViewData()->GetDocShell()->IsDocShared() )
733 // get state from DocShell
734 pDocSh->GetSlotState( nWhich, NULL, &rSet );
736 nWhich = aIter.NextWhich();
740 void ScTabViewShell::ExecDrawOpt( SfxRequest& rReq )
742 ScViewOptions aViewOptions = GetViewData()->GetOptions();
743 ScGridOptions aGridOptions = aViewOptions.GetGridOptions();
745 SfxBindings& rBindings = GetViewFrame()->GetBindings();
746 const SfxItemSet* pArgs = rReq.GetArgs();
747 const SfxPoolItem* pItem;
748 sal_uInt16 nSlotId = rReq.GetSlot();
749 switch (nSlotId)
751 case SID_GRID_VISIBLE:
752 if ( pArgs && pArgs->GetItemState(nSlotId,true,&pItem) == SFX_ITEM_SET )
754 aGridOptions.SetGridVisible( ((const SfxBoolItem*)pItem)->GetValue() );
755 aViewOptions.SetGridOptions(aGridOptions);
756 rBindings.Invalidate(SID_GRID_VISIBLE);
758 break;
760 case SID_GRID_USE:
761 if ( pArgs && pArgs->GetItemState(nSlotId,true,&pItem) == SFX_ITEM_SET )
763 aGridOptions.SetUseGridSnap( ((const SfxBoolItem*)pItem)->GetValue() );
764 aViewOptions.SetGridOptions(aGridOptions);
765 rBindings.Invalidate(SID_GRID_USE);
767 break;
769 case SID_HELPLINES_MOVE:
770 if ( pArgs && pArgs->GetItemState(nSlotId,true,&pItem) == SFX_ITEM_SET )
772 aViewOptions.SetOption( VOPT_HELPLINES, ((const SfxBoolItem*)pItem)->GetValue() );
773 rBindings.Invalidate(SID_HELPLINES_MOVE);
775 break;
778 GetViewData()->SetOptions(aViewOptions);
781 void ScTabViewShell::GetDrawOptState( SfxItemSet& rSet )
783 SfxBoolItem aBool;
785 const ScViewOptions& rViewOptions = GetViewData()->GetOptions();
786 const ScGridOptions& rGridOptions = rViewOptions.GetGridOptions();
788 aBool.SetValue(rGridOptions.GetGridVisible());
789 aBool.SetWhich( SID_GRID_VISIBLE );
790 rSet.Put( aBool );
792 aBool.SetValue(rGridOptions.GetUseGridSnap());
793 aBool.SetWhich( SID_GRID_USE );
794 rSet.Put( aBool );
796 aBool.SetValue(rViewOptions.GetOption( VOPT_HELPLINES ));
797 aBool.SetWhich( SID_HELPLINES_MOVE );
798 rSet.Put( aBool );
802 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */