fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / view / tabvwsha.cxx
blobfe2dbadffb51e55d7df18300ef019c451788de97
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& rViewData = GetViewData();
70 ScMarkData& rMark = rViewData.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 = rViewData.GetDocument();
101 SCCOL nPosX = rViewData.GetCurX();
102 SCROW nPosY = rViewData.GetCurY();
103 SCTAB nTab = rViewData.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
146 void ScTabViewShell::GetState( SfxItemSet& rSet )
148 ScViewData& rViewData = GetViewData();
149 ScDocument* pDoc = rViewData.GetDocument();
150 ScDocShell* pDocShell = rViewData.GetDocShell();
151 ScMarkData& rMark = rViewData.GetMarkData();
152 SCCOL nPosX = rViewData.GetCurX();
153 SCROW nPosY = rViewData.GetCurY();
154 SCTAB nTab = rViewData.GetTabNo();
156 SfxViewFrame* pThisFrame = GetViewFrame();
157 bool bOle = GetViewFrame()->GetFrame().IsInPlace();
159 SCTAB nTabSelCount = rMark.GetSelectCount();
161 SfxWhichIter aIter(rSet);
162 sal_uInt16 nWhich = aIter.FirstWhich();
164 while ( nWhich )
166 switch ( nWhich )
168 case FID_CHG_COMMENT:
170 ScDocShell* pDocSh = GetViewData().GetDocShell();
171 ScAddress aPos( nPosX, nPosY, nTab );
172 if ( pDocSh->IsReadOnly() || !pDocSh->GetChangeAction(aPos) || pDocSh->IsDocShared() )
173 rSet.DisableItem( nWhich );
175 break;
177 case SID_OPENDLG_EDIT_PRINTAREA:
178 case SID_ADD_PRINTAREA:
179 case SID_DEFINE_PRINTAREA:
181 if ( pDocShell && pDocShell->IsDocShared() )
183 rSet.DisableItem( nWhich );
186 break;
188 case SID_DELETE_PRINTAREA:
189 if ( pDocShell && pDocShell->IsDocShared() )
191 rSet.DisableItem( nWhich );
193 else if (pDoc->IsPrintEntireSheet(nTab))
194 rSet.DisableItem(nWhich);
195 break;
197 case SID_STATUS_PAGESTYLE:
198 case SID_HFEDIT:
199 GetViewData().GetDocShell()->GetStatePageStyle( *this, rSet, nTab );
200 break;
202 case SID_SEARCH_ITEM:
204 SvxSearchItem aItem(ScGlobal::GetSearchItem()); // make a copy.
205 // Search on current selection if a range is marked.
206 aItem.SetSelection(rMark.IsMarked());
207 rSet.Put(aItem);
208 break;
211 case SID_SEARCH_OPTIONS:
213 // Anything goes
214 SearchOptionFlags nOptions = SearchOptionFlags::ALL;
216 // No replacement if ReadOnly
217 if (GetViewData().GetDocShell()->IsReadOnly())
218 nOptions &= ~SearchOptionFlags( SearchOptionFlags::REPLACE | SearchOptionFlags::REPLACE_ALL );
219 rSet.Put( SfxUInt16Item( nWhich, static_cast<sal_uInt16>(nOptions) ) );
221 break;
223 case SID_CURRENTCELL:
225 ScAddress aScAddress( GetViewData().GetCurX(), GetViewData().GetCurY(), 0 );
226 OUString aAddr(aScAddress.Format(SCA_ABS, NULL, pDoc->GetAddressConvention()));
227 SfxStringItem aPosItem( SID_CURRENTCELL, aAddr );
229 rSet.Put( aPosItem );
231 break;
233 case SID_CURRENTTAB:
234 // Table for Basic is 1-based
235 rSet.Put( SfxUInt16Item( nWhich, static_cast<sal_uInt16>(GetViewData().GetTabNo()) + 1 ) );
236 break;
238 case SID_CURRENTDOC:
239 rSet.Put( SfxStringItem( nWhich, GetViewData().GetDocShell()->GetTitle() ) );
240 break;
242 case FID_TOGGLEINPUTLINE:
244 sal_uInt16 nId = ScInputWindowWrapper::GetChildWindowId();
246 if ( pThisFrame->KnowsChildWindow( nId ) )
248 SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
249 rSet.Put( SfxBoolItem( nWhich, pWnd != nullptr ) );
251 else
252 rSet.DisableItem( nWhich );
254 break;
256 case FID_DEL_MANUALBREAKS:
257 if (!pDoc->HasManualBreaks(nTab))
258 rSet.DisableItem( nWhich );
259 break;
261 case FID_RESET_PRINTZOOM:
263 // disable if already set to default
265 OUString aStyleName = pDoc->GetPageStyle( nTab );
266 ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
267 SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName,
268 SFX_STYLE_FAMILY_PAGE );
269 OSL_ENSURE( pStyleSheet, "PageStyle not found" );
270 if ( pStyleSheet )
272 SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
273 sal_uInt16 nScale = static_cast<const SfxUInt16Item&>(
274 rStyleSet.Get(ATTR_PAGE_SCALE)).GetValue();
275 sal_uInt16 nPages = static_cast<const SfxUInt16Item&>(
276 rStyleSet.Get(ATTR_PAGE_SCALETOPAGES)).GetValue();
277 if ( nScale == 100 && nPages == 0 )
278 rSet.DisableItem( nWhich );
281 break;
283 case FID_SCALE:
284 case SID_ATTR_ZOOM:
285 if ( bOle )
286 rSet.DisableItem( nWhich );
287 else
289 const Fraction& rOldY = GetViewData().GetZoomY();
290 sal_uInt16 nZoom = (sal_uInt16)(( rOldY.GetNumerator() * 100 )
291 / rOldY.GetDenominator());
292 rSet.Put( SvxZoomItem( SvxZoomType::PERCENT, nZoom, nWhich ) );
294 break;
296 case SID_ATTR_ZOOMSLIDER:
298 if ( bOle )
299 rSet.DisableItem( nWhich );
300 else
302 const Fraction& rOldY = GetViewData().GetZoomY();
303 sal_uInt16 nCurrentZoom = (sal_uInt16)(( rOldY.GetNumerator() * 100 ) / rOldY.GetDenominator());
305 if( nCurrentZoom )
307 SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM, SID_ATTR_ZOOMSLIDER );
308 aZoomSliderItem.AddSnappingPoint( 100 );
309 rSet.Put( aZoomSliderItem );
313 break;
315 case FID_TOGGLESYNTAX:
316 rSet.Put(SfxBoolItem(nWhich, GetViewData().IsSyntaxMode()));
317 break;
319 case FID_TOGGLEHEADERS:
320 rSet.Put(SfxBoolItem(nWhich, GetViewData().IsHeaderMode()));
321 break;
323 case FID_TOGGLEFORMULA:
325 const ScViewOptions& rOpts = rViewData.GetOptions();
326 bool bFormulaMode = rOpts.GetOption( VOPT_FORMULAS );
327 rSet.Put(SfxBoolItem(nWhich, bFormulaMode ));
329 break;
331 case FID_NORMALVIEWMODE:
332 case FID_PAGEBREAKMODE:
333 // always handle both slots - they exclude each other
334 if ( bOle )
336 rSet.DisableItem( FID_NORMALVIEWMODE );
337 rSet.DisableItem( FID_PAGEBREAKMODE );
339 else
341 rSet.Put(SfxBoolItem(FID_NORMALVIEWMODE, !GetViewData().IsPagebreakMode()));
342 rSet.Put(SfxBoolItem(FID_PAGEBREAKMODE, GetViewData().IsPagebreakMode()));
344 break;
346 case FID_PROTECT_DOC:
348 if ( pDocShell && pDocShell->IsDocShared() )
350 rSet.DisableItem( nWhich );
352 else
354 rSet.Put( SfxBoolItem( nWhich, pDoc->IsDocProtected() ) );
357 break;
359 case FID_PROTECT_TABLE:
361 if ( pDocShell && pDocShell->IsDocShared() )
363 rSet.DisableItem( nWhich );
365 else
367 rSet.Put( SfxBoolItem( nWhich, pDoc->IsTabProtected( nTab ) ) );
370 break;
372 case SID_AUTO_OUTLINE:
374 if (pDoc->GetChangeTrack()!=NULL || GetViewData().IsMultiMarked())
376 rSet.DisableItem( nWhich );
379 break;
381 case SID_OUTLINE_DELETEALL:
383 SCTAB nOlTab = GetViewData().GetTabNo();
384 ScOutlineTable* pOlTable = pDoc->GetOutlineTable( nOlTab );
385 if (pOlTable == NULL)
386 rSet.DisableItem( nWhich );
388 break;
390 case SID_WINDOW_SPLIT:
391 rSet.Put(SfxBoolItem(nWhich,
392 rViewData.GetHSplitMode() == SC_SPLIT_NORMAL ||
393 rViewData.GetVSplitMode() == SC_SPLIT_NORMAL ));
394 break;
396 case SID_WINDOW_FIX:
397 rSet.Put(SfxBoolItem(nWhich,
398 rViewData.GetHSplitMode() == SC_SPLIT_FIX ||
399 rViewData.GetVSplitMode() == SC_SPLIT_FIX ));
400 break;
402 case FID_CHG_SHOW:
404 if ( pDoc->GetChangeTrack() == NULL || ( pDocShell && pDocShell->IsDocShared() ) )
405 rSet.DisableItem( nWhich );
407 break;
408 case FID_CHG_ACCEPT:
410 rSet.Put(SfxBoolItem(FID_CHG_ACCEPT,
411 pThisFrame->HasChildWindow(FID_CHG_ACCEPT)));
412 if(pDoc->GetChangeTrack()==NULL)
414 if ( !pThisFrame->HasChildWindow(FID_CHG_ACCEPT) )
416 rSet.DisableItem( nWhich);
419 if ( pDocShell && pDocShell->IsDocShared() )
421 rSet.DisableItem( nWhich );
424 break;
426 case SID_FORMATPAGE:
427 // in protected tables
428 if ( pDocShell && ( pDocShell->IsReadOnly() || pDocShell->IsDocShared() ) )
429 rSet.DisableItem( nWhich );
430 break;
432 case SID_PRINTPREVIEW:
433 // Toggle slot needs a State
434 rSet.Put( SfxBoolItem( nWhich, false ) );
435 break;
437 case SID_READONLY_MODE:
438 rSet.Put( SfxBoolItem( nWhich, GetViewData().GetDocShell()->IsReadOnly() ) );
439 break;
441 case FID_TAB_DESELECTALL:
442 if ( nTabSelCount == 1 )
443 rSet.DisableItem( nWhich ); // enabled only if several sheets are selected
444 break;
446 } // switch ( nWitch )
447 nWhich = aIter.NextWhich();
448 } // while ( nWitch )
451 void ScTabViewShell::ExecuteCellFormatDlg(SfxRequest& rReq, const OString &rName)
453 ScDocument* pDoc = GetViewData().GetDocument();
455 SvxBoxItem aLineOuter( ATTR_BORDER );
456 SvxBoxInfoItem aLineInner( ATTR_BORDER_INNER );
458 const ScPatternAttr* pOldAttrs = GetSelectionPattern();
460 boost::scoped_ptr<SfxAbstractTabDialog> pDlg;
461 boost::scoped_ptr<SfxItemSet> pOldSet(new SfxItemSet(pOldAttrs->GetItemSet()));
462 boost::scoped_ptr<SvxNumberInfoItem> pNumberInfoItem;
464 pOldSet->MergeRange(SID_ATTR_BORDER_STYLES, SID_ATTR_BORDER_DEFAULT_WIDTH);
466 // We only allow these border line types.
467 std::vector<sal_Int32> aBorderStyles;
468 aBorderStyles.reserve(5);
469 aBorderStyles.push_back(table::BorderLineStyle::SOLID);
470 aBorderStyles.push_back(table::BorderLineStyle::DOTTED);
471 aBorderStyles.push_back(table::BorderLineStyle::DASHED);
472 aBorderStyles.push_back(table::BorderLineStyle::FINE_DASHED);
473 aBorderStyles.push_back(table::BorderLineStyle::DASH_DOT);
474 aBorderStyles.push_back(table::BorderLineStyle::DASH_DOT_DOT);
475 aBorderStyles.push_back(table::BorderLineStyle::DOUBLE_THIN);
477 SfxIntegerListItem aBorderStylesItem(SID_ATTR_BORDER_STYLES, aBorderStyles);
478 pOldSet->Put(aBorderStylesItem);
480 // Set the default border width to 0.75 points.
481 SfxInt64Item aBorderWidthItem(SID_ATTR_BORDER_DEFAULT_WIDTH, 75);
482 pOldSet->Put(aBorderWidthItem);
484 // Get border items and put them in the set:
485 GetSelectionFrame( aLineOuter, aLineInner );
486 //Fix border incorrect for RTL fdo#62399
487 if( pDoc->IsLayoutRTL( GetViewData().GetTabNo() ) )
489 SvxBoxItem aNewFrame( aLineOuter );
490 SvxBoxInfoItem aTempInfo( aLineInner );
492 if ( aLineInner.IsValid(SvxBoxInfoItemValidFlags::LEFT) )
493 aNewFrame.SetLine( aLineOuter.GetLeft(), SvxBoxItemLine::RIGHT );
494 if ( aLineInner.IsValid(SvxBoxInfoItemValidFlags::RIGHT) )
495 aNewFrame.SetLine( aLineOuter.GetRight(), SvxBoxItemLine::LEFT );
497 aLineInner.SetValid( SvxBoxInfoItemValidFlags::LEFT, aTempInfo.IsValid(SvxBoxInfoItemValidFlags::RIGHT));
498 aLineInner.SetValid( SvxBoxInfoItemValidFlags::RIGHT, aTempInfo.IsValid(SvxBoxInfoItemValidFlags::LEFT));
500 pOldSet->Put( aNewFrame );
502 else
503 pOldSet->Put( aLineOuter );
505 pOldSet->Put( aLineInner );
507 // Generate NumberFormat Value from Value and Language and box it.
508 pOldSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT,
509 pOldAttrs->GetNumberFormat( pDoc->GetFormatTable() ) ) );
511 pNumberInfoItem.reset(MakeNumberInfoItem(pDoc, &GetViewData()));
513 pOldSet->MergeRange( SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO );
514 pOldSet->Put(*pNumberInfoItem );
516 bInFormatDialog = true;
517 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
518 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
520 pDlg.reset(pFact->CreateScAttrDlg(GetViewFrame(), GetDialogParent(), pOldSet.get()));
522 if (!rName.isEmpty())
523 pDlg->SetCurPageId(rName);
524 short nResult = pDlg->Execute();
525 bInFormatDialog = false;
527 if ( nResult == RET_OK )
529 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
531 const SfxPoolItem* pItem=NULL;
532 if(pOutSet->GetItemState(SID_ATTR_NUMBERFORMAT_INFO,true,&pItem)==SfxItemState::SET)
535 UpdateNumberFormatter(static_cast<const SvxNumberInfoItem&>(*pItem));
538 ApplyAttributes(pOutSet, pOldSet.get());
540 rReq.Done( *pOutSet );
544 bool ScTabViewShell::IsRefInputMode() const
546 ScModule* pScMod = SC_MOD();
547 if ( pScMod )
549 if( pScMod->IsRefDialogOpen() )
550 return pScMod->IsFormulaMode();
551 if( pScMod->IsFormulaMode() )
553 ScInputHandler* pHdl = pScMod->GetInputHdl();
554 if ( pHdl )
556 OUString aString = pHdl->GetEditString();
557 if ( !pHdl->GetSelIsRef() && aString.getLength() > 1 &&
558 ( aString[0] == '+' || aString[0] == '-' ) )
560 const ScViewData& rViewData = GetViewData();
561 ScDocument* pDoc = rViewData.GetDocument();
562 if ( pDoc )
564 const ScAddress aPos( rViewData.GetCurPos() );
565 ScCompiler aComp( pDoc, aPos );
566 aComp.SetGrammar(pDoc->GetGrammar());
567 aComp.SetCloseBrackets( false );
568 boost::scoped_ptr<ScTokenArray> pArr(aComp.CompileString(aString));
569 if ( pArr && pArr->MayReferenceFollow() )
571 return true;
575 else
577 return true;
583 return false;
586 void ScTabViewShell::ExecuteInputDirect()
588 if ( !IsRefInputMode() )
590 ScModule* pScMod = SC_MOD();
591 if ( pScMod )
593 pScMod->InputEnterHandler();
598 void ScTabViewShell::UpdateInputHandler( bool bForce /* = sal_False */, bool bStopEditing /* = sal_True */ )
600 ScInputHandler* pHdl = pInputHandler ? pInputHandler : SC_MOD()->GetInputHdl();
602 if ( pHdl )
604 OUString aString;
605 const EditTextObject* pObject = NULL;
606 ScViewData& rViewData = GetViewData();
607 ScDocument* pDoc = rViewData.GetDocument();
608 CellType eType;
609 SCCOL nPosX = rViewData.GetCurX();
610 SCROW nPosY = rViewData.GetCurY();
611 SCTAB nTab = rViewData.GetTabNo();
612 SCTAB nStartTab = 0;
613 SCTAB nEndTab = 0;
614 SCCOL nStartCol = 0;
615 SCROW nStartRow = 0;
616 SCCOL nEndCol = 0;
617 SCROW nEndRow = 0;
618 ScAddress aPos = rViewData.GetCurPos();
620 rViewData.GetSimpleArea( nStartCol, nStartRow, nStartTab,
621 nEndCol, nEndRow, nEndTab );
623 PutInOrder( nStartCol, nEndCol );
624 PutInOrder( nStartRow, nEndRow );
625 PutInOrder( nStartTab, nEndTab );
627 bool bHideFormula = false;
628 bool bHideAll = false;
630 if (pDoc->IsTabProtected(nTab))
632 const ScProtectionAttr* pProt = static_cast<const ScProtectionAttr*>(
633 pDoc->GetAttr( nPosX,nPosY,nTab,
634 ATTR_PROTECTION));
635 bHideFormula = pProt->GetHideFormula();
636 bHideAll = pProt->GetHideCell();
639 if (!bHideAll)
641 eType = pDoc->GetCellType(aPos);
642 if (eType == CELLTYPE_FORMULA)
644 if (!bHideFormula)
645 pDoc->GetFormula( nPosX, nPosY, nTab, aString );
647 else if (eType == CELLTYPE_EDIT)
649 pObject = pDoc->GetEditText(aPos);
651 else
653 pDoc->GetInputString( nPosX, nPosY, nTab, aString );
654 if (eType == CELLTYPE_STRING)
656 // Bei Bedarf ein ' vorneweg, damit der String nicht ungewollt
657 // als Zahl interpretiert wird, und um dem Benutzer zu zeigen,
658 // dass es ein String ist (#35060#).
659 //! Auch bei Zahlformat "Text"? -> dann beim Editieren wegnehmen
661 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
662 sal_uInt32 nNumFmt;
663 pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt );
664 double fDummy;
665 if ( pFormatter->IsNumberFormat(aString, nNumFmt, fDummy) )
666 aString = "'" + aString;
671 ScInputHdlState aState( ScAddress( nPosX, nPosY, nTab ),
672 ScAddress( nStartCol, nStartRow, nTab ),
673 ScAddress( nEndCol, nEndRow, nTab ),
674 aString,
675 pObject );
677 // if using the view's local input handler, this view can always be set
678 // as current view inside NotifyChange.
679 ScTabViewShell* pSourceSh = pInputHandler ? this : NULL;
681 pHdl->NotifyChange( &aState, bForce, pSourceSh, bStopEditing );
684 SfxBindings& rBindings = GetViewFrame()->GetBindings();
685 rBindings.Invalidate( SID_STATUS_SUM ); // immer zusammen mit Eingabezeile
686 rBindings.Invalidate( SID_ATTR_SIZE );
687 rBindings.Invalidate( SID_TABLE_CELL );
690 void ScTabViewShell::UpdateInputHandlerCellAdjust( SvxCellHorJustify eJust )
692 if( ScInputHandler* pHdl = pInputHandler ? pInputHandler : SC_MOD()->GetInputHdl() )
693 pHdl->UpdateCellAdjust( eJust );
696 void ScTabViewShell::ExecuteSave( SfxRequest& rReq )
698 // only SID_SAVEDOC / SID_SAVEASDOC
700 // Finish entering in any case, even if a formula is being processed
701 SC_MOD()->InputEnterHandler();
703 if ( GetViewData().GetDocShell()->IsDocShared() )
705 GetViewData().GetDocShell()->SetDocumentModified();
708 // otherwise as normal
709 GetViewData().GetDocShell()->ExecuteSlot( rReq );
712 void ScTabViewShell::GetSaveState( SfxItemSet& rSet )
714 SfxShell* pDocSh = GetViewData().GetDocShell();
716 SfxWhichIter aIter(rSet);
717 sal_uInt16 nWhich = aIter.FirstWhich();
718 while( nWhich )
720 if ( nWhich != SID_SAVEDOC || !GetViewData().GetDocShell()->IsDocShared() )
722 // get state from DocShell
723 pDocSh->GetSlotState( nWhich, NULL, &rSet );
725 nWhich = aIter.NextWhich();
729 void ScTabViewShell::ExecDrawOpt( SfxRequest& rReq )
731 ScViewOptions aViewOptions = GetViewData().GetOptions();
732 ScGridOptions aGridOptions = aViewOptions.GetGridOptions();
734 SfxBindings& rBindings = GetViewFrame()->GetBindings();
735 const SfxItemSet* pArgs = rReq.GetArgs();
736 const SfxPoolItem* pItem;
737 sal_uInt16 nSlotId = rReq.GetSlot();
738 switch (nSlotId)
740 case SID_GRID_VISIBLE:
741 if ( pArgs && pArgs->GetItemState(nSlotId,true,&pItem) == SfxItemState::SET )
743 aGridOptions.SetGridVisible( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
744 aViewOptions.SetGridOptions(aGridOptions);
745 rBindings.Invalidate(SID_GRID_VISIBLE);
747 break;
749 case SID_GRID_USE:
750 if ( pArgs && pArgs->GetItemState(nSlotId,true,&pItem) == SfxItemState::SET )
752 aGridOptions.SetUseGridSnap( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
753 aViewOptions.SetGridOptions(aGridOptions);
754 rBindings.Invalidate(SID_GRID_USE);
756 break;
758 case SID_HELPLINES_MOVE:
759 if ( pArgs && pArgs->GetItemState(nSlotId,true,&pItem) == SfxItemState::SET )
761 aViewOptions.SetOption( VOPT_HELPLINES, static_cast<const SfxBoolItem*>(pItem)->GetValue() );
762 rBindings.Invalidate(SID_HELPLINES_MOVE);
764 break;
767 GetViewData().SetOptions(aViewOptions);
770 void ScTabViewShell::GetDrawOptState( SfxItemSet& rSet )
772 SfxBoolItem aBool;
774 const ScViewOptions& rViewOptions = GetViewData().GetOptions();
775 const ScGridOptions& rGridOptions = rViewOptions.GetGridOptions();
777 aBool.SetValue(rGridOptions.GetGridVisible());
778 aBool.SetWhich( SID_GRID_VISIBLE );
779 rSet.Put( aBool );
781 aBool.SetValue(rGridOptions.GetUseGridSnap());
782 aBool.SetWhich( SID_GRID_USE );
783 rSet.Put( aBool );
785 aBool.SetValue(rViewOptions.GetOption( VOPT_HELPLINES ));
786 aBool.SetWhich( SID_HELPLINES_MOVE );
787 rSet.Put( aBool );
790 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */