1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
38 #include "patattr.hxx"
39 #include "document.hxx"
40 #include "formulacell.hxx"
41 #include "globstr.hrc"
43 #include "inputhdl.hxx"
44 #include "inputwin.hxx"
46 #include "viewdata.hxx"
47 #include "appoptio.hxx"
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
)
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
))
78 rFuncStr
= ScGlobal::GetLongErrorString(nErrCode
);
82 sal_uInt16 nGlobStrId
= 0;
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;
95 // added to avoid warnings
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
);
108 ScAddress
aCursor( nPosX
, nPosY
, nTab
);
110 if ( pDoc
->GetSelectionFunction( eFunc
, aCursor
, rMark
, nVal
) )
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
);
127 pFormatter
->GetOutputString( nVal
, nNumFmt
, aValStr
, &pDummy
);
139 // Functions that are disabled, depending on the selection
142 // SID_DELETE_CONTENTS,
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();
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
);
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
);
188 case SID_DELETE_PRINTAREA
:
189 if ( pDocShell
&& pDocShell
->IsDocShared() )
191 rSet
.DisableItem( nWhich
);
193 else if (pDoc
->IsPrintEntireSheet(nTab
))
194 rSet
.DisableItem(nWhich
);
197 case SID_STATUS_PAGESTYLE
:
199 GetViewData().GetDocShell()->GetStatePageStyle( *this, rSet
, nTab
);
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());
211 case SID_SEARCH_OPTIONS
:
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
) ) );
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
);
234 // Table for Basic is 1-based
235 rSet
.Put( SfxUInt16Item( nWhich
, static_cast<sal_uInt16
>(GetViewData().GetTabNo()) + 1 ) );
239 rSet
.Put( SfxStringItem( nWhich
, GetViewData().GetDocShell()->GetTitle() ) );
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 ) );
252 rSet
.DisableItem( nWhich
);
256 case FID_DEL_MANUALBREAKS
:
257 if (!pDoc
->HasManualBreaks(nTab
))
258 rSet
.DisableItem( nWhich
);
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" );
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
);
286 rSet
.DisableItem( nWhich
);
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
) );
296 case SID_ATTR_ZOOMSLIDER
:
299 rSet
.DisableItem( nWhich
);
302 const Fraction
& rOldY
= GetViewData().GetZoomY();
303 sal_uInt16 nCurrentZoom
= (sal_uInt16
)(( rOldY
.GetNumerator() * 100 ) / rOldY
.GetDenominator());
307 SvxZoomSliderItem
aZoomSliderItem( nCurrentZoom
, MINZOOM
, MAXZOOM
, SID_ATTR_ZOOMSLIDER
);
308 aZoomSliderItem
.AddSnappingPoint( 100 );
309 rSet
.Put( aZoomSliderItem
);
315 case FID_TOGGLESYNTAX
:
316 rSet
.Put(SfxBoolItem(nWhich
, GetViewData().IsSyntaxMode()));
319 case FID_TOGGLEHEADERS
:
320 rSet
.Put(SfxBoolItem(nWhich
, GetViewData().IsHeaderMode()));
323 case FID_TOGGLEFORMULA
:
325 const ScViewOptions
& rOpts
= rViewData
.GetOptions();
326 bool bFormulaMode
= rOpts
.GetOption( VOPT_FORMULAS
);
327 rSet
.Put(SfxBoolItem(nWhich
, bFormulaMode
));
331 case FID_NORMALVIEWMODE
:
332 case FID_PAGEBREAKMODE
:
333 // always handle both slots - they exclude each other
336 rSet
.DisableItem( FID_NORMALVIEWMODE
);
337 rSet
.DisableItem( FID_PAGEBREAKMODE
);
341 rSet
.Put(SfxBoolItem(FID_NORMALVIEWMODE
, !GetViewData().IsPagebreakMode()));
342 rSet
.Put(SfxBoolItem(FID_PAGEBREAKMODE
, GetViewData().IsPagebreakMode()));
346 case FID_PROTECT_DOC
:
348 if ( pDocShell
&& pDocShell
->IsDocShared() )
350 rSet
.DisableItem( nWhich
);
354 rSet
.Put( SfxBoolItem( nWhich
, pDoc
->IsDocProtected() ) );
359 case FID_PROTECT_TABLE
:
361 if ( pDocShell
&& pDocShell
->IsDocShared() )
363 rSet
.DisableItem( nWhich
);
367 rSet
.Put( SfxBoolItem( nWhich
, pDoc
->IsTabProtected( nTab
) ) );
372 case SID_AUTO_OUTLINE
:
374 if (pDoc
->GetChangeTrack()!=NULL
|| GetViewData().IsMultiMarked())
376 rSet
.DisableItem( nWhich
);
381 case SID_OUTLINE_DELETEALL
:
383 SCTAB nOlTab
= GetViewData().GetTabNo();
384 ScOutlineTable
* pOlTable
= pDoc
->GetOutlineTable( nOlTab
);
385 if (pOlTable
== NULL
)
386 rSet
.DisableItem( nWhich
);
390 case SID_WINDOW_SPLIT
:
391 rSet
.Put(SfxBoolItem(nWhich
,
392 rViewData
.GetHSplitMode() == SC_SPLIT_NORMAL
||
393 rViewData
.GetVSplitMode() == SC_SPLIT_NORMAL
));
397 rSet
.Put(SfxBoolItem(nWhich
,
398 rViewData
.GetHSplitMode() == SC_SPLIT_FIX
||
399 rViewData
.GetVSplitMode() == SC_SPLIT_FIX
));
404 if ( pDoc
->GetChangeTrack() == NULL
|| ( pDocShell
&& pDocShell
->IsDocShared() ) )
405 rSet
.DisableItem( nWhich
);
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
);
427 // in protected tables
428 if ( pDocShell
&& ( pDocShell
->IsReadOnly() || pDocShell
->IsDocShared() ) )
429 rSet
.DisableItem( nWhich
);
432 case SID_PRINTPREVIEW
:
433 // Toggle slot needs a State
434 rSet
.Put( SfxBoolItem( nWhich
, false ) );
437 case SID_READONLY_MODE
:
438 rSet
.Put( SfxBoolItem( nWhich
, GetViewData().GetDocShell()->IsReadOnly() ) );
441 case FID_TAB_DESELECTALL
:
442 if ( nTabSelCount
== 1 )
443 rSet
.DisableItem( nWhich
); // enabled only if several sheets are selected
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
);
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();
549 if( pScMod
->IsRefDialogOpen() )
550 return pScMod
->IsFormulaMode();
551 if( pScMod
->IsFormulaMode() )
553 ScInputHandler
* pHdl
= pScMod
->GetInputHdl();
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();
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() )
586 void ScTabViewShell::ExecuteInputDirect()
588 if ( !IsRefInputMode() )
590 ScModule
* pScMod
= SC_MOD();
593 pScMod
->InputEnterHandler();
598 void ScTabViewShell::UpdateInputHandler( bool bForce
/* = sal_False */, bool bStopEditing
/* = sal_True */ )
600 ScInputHandler
* pHdl
= pInputHandler
? pInputHandler
: SC_MOD()->GetInputHdl();
605 const EditTextObject
* pObject
= NULL
;
606 ScViewData
& rViewData
= GetViewData();
607 ScDocument
* pDoc
= rViewData
.GetDocument();
609 SCCOL nPosX
= rViewData
.GetCurX();
610 SCROW nPosY
= rViewData
.GetCurY();
611 SCTAB nTab
= rViewData
.GetTabNo();
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
,
635 bHideFormula
= pProt
->GetHideFormula();
636 bHideAll
= pProt
->GetHideCell();
641 eType
= pDoc
->GetCellType(aPos
);
642 if (eType
== CELLTYPE_FORMULA
)
645 pDoc
->GetFormula( nPosX
, nPosY
, nTab
, aString
);
647 else if (eType
== CELLTYPE_EDIT
)
649 pObject
= pDoc
->GetEditText(aPos
);
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();
663 pDoc
->GetNumberFormat( nPosX
, nPosY
, nTab
, nNumFmt
);
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
),
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();
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();
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
);
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
);
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
);
767 GetViewData().SetOptions(aViewOptions
);
770 void ScTabViewShell::GetDrawOptState( SfxItemSet
& rSet
)
774 const ScViewOptions
& rViewOptions
= GetViewData().GetOptions();
775 const ScGridOptions
& rGridOptions
= rViewOptions
.GetGridOptions();
777 aBool
.SetValue(rGridOptions
.GetGridVisible());
778 aBool
.SetWhich( SID_GRID_VISIBLE
);
781 aBool
.SetValue(rGridOptions
.GetUseGridSnap());
782 aBool
.SetWhich( SID_GRID_USE
);
785 aBool
.SetValue(rViewOptions
.GetOption( VOPT_HELPLINES
));
786 aBool
.SetWhich( SID_HELPLINES_MOVE
);
790 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */