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 <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>
36 #include "patattr.hxx"
37 #include "document.hxx"
38 #include "formulacell.hxx"
39 #include "globstr.hrc"
41 #include "inputhdl.hxx"
42 #include "inputwin.hxx"
44 #include "viewdata.hxx"
45 #include "appoptio.hxx"
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 #include <boost/scoped_ptr.hpp>
58 sal_Bool
ScTabViewShell::GetFunction( OUString
& rFuncStr
, sal_uInt16 nErrCode
)
62 ScSubTotalFunc eFunc
= (ScSubTotalFunc
) SC_MOD()->GetAppOptions().GetStatusFunc();
63 ScViewData
* pViewData
= GetViewData();
64 ScMarkData
& rMark
= pViewData
->GetMarkData();
65 bool bIgnoreError
= (rMark
.IsMarked() || rMark
.IsMultiMarked());
67 if (bIgnoreError
&& (eFunc
== SUBTOTAL_FUNC_CNT
|| eFunc
== SUBTOTAL_FUNC_CNT2
))
72 rFuncStr
= ScGlobal::GetLongErrorString(nErrCode
);
76 sal_uInt16 nGlobStrId
= 0;
79 case SUBTOTAL_FUNC_AVE
: nGlobStrId
= STR_FUN_TEXT_AVG
; break;
80 case SUBTOTAL_FUNC_CNT
: nGlobStrId
= STR_FUN_TEXT_COUNT
; break;
81 case SUBTOTAL_FUNC_CNT2
: nGlobStrId
= STR_FUN_TEXT_COUNT2
; break;
82 case SUBTOTAL_FUNC_MAX
: nGlobStrId
= STR_FUN_TEXT_MAX
; break;
83 case SUBTOTAL_FUNC_MIN
: nGlobStrId
= STR_FUN_TEXT_MIN
; break;
84 case SUBTOTAL_FUNC_SUM
: nGlobStrId
= STR_FUN_TEXT_SUM
; break;
85 case SUBTOTAL_FUNC_SELECTION_COUNT
: nGlobStrId
= STR_FUN_TEXT_SELECTION_COUNT
; break;
89 // added to avoid warnings
94 ScDocument
* pDoc
= pViewData
->GetDocument();
95 SCCOL nPosX
= pViewData
->GetCurX();
96 SCROW nPosY
= pViewData
->GetCurY();
97 SCTAB nTab
= pViewData
->GetTabNo();
99 aStr
= ScGlobal::GetRscString(nGlobStrId
);
102 ScAddress
aCursor( nPosX
, nPosY
, nTab
);
104 if ( pDoc
->GetSelectionFunction( eFunc
, aCursor
, rMark
, nVal
) )
110 // Number in the standard format, the other on the cursor position
111 SvNumberFormatter
* pFormatter
= pDoc
->GetFormatTable();
112 sal_uInt32 nNumFmt
= 0;
113 if ( eFunc
!= SUBTOTAL_FUNC_CNT
&& eFunc
!= SUBTOTAL_FUNC_CNT2
&& eFunc
!= SUBTOTAL_FUNC_SELECTION_COUNT
)
115 // Zahlformat aus Attributen oder Formel
116 pDoc
->GetNumberFormat( nPosX
, nPosY
, nTab
, nNumFmt
);
121 pFormatter
->GetOutputString( nVal
, nNumFmt
, aValStr
, &pDummy
);
135 // Functions that are disabled, depending on the selection
138 // SID_DELETE_CONTENTS,
143 void ScTabViewShell::GetState( SfxItemSet
& rSet
)
145 ScViewData
* pViewData
= GetViewData();
146 ScDocument
* pDoc
= pViewData
->GetDocument();
147 ScDocShell
* pDocShell
= pViewData
->GetDocShell();
148 ScMarkData
& rMark
= pViewData
->GetMarkData();
149 SCCOL nPosX
= pViewData
->GetCurX();
150 SCROW nPosY
= pViewData
->GetCurY();
151 SCTAB nTab
= pViewData
->GetTabNo();
152 sal_uInt16 nMyId
= 0;
154 SfxViewFrame
* pThisFrame
= GetViewFrame();
155 sal_Bool bOle
= GetViewFrame()->GetFrame().IsInPlace();
157 SCTAB nTabCount
= pDoc
->GetTableCount();
158 SCTAB nTabSelCount
= rMark
.GetSelectCount();
160 SfxWhichIter
aIter(rSet
);
161 sal_uInt16 nWhich
= aIter
.FirstWhich();
167 case FID_CHG_COMMENT
:
169 ScDocShell
* pDocSh
= GetViewData()->GetDocShell();
170 ScAddress
aPos( nPosX
, nPosY
, nTab
);
171 if ( pDocSh
->IsReadOnly() || !pDocSh
->GetChangeAction(aPos
) || pDocSh
->IsDocShared() )
172 rSet
.DisableItem( nWhich
);
176 case SID_OPENDLG_EDIT_PRINTAREA
:
177 case SID_ADD_PRINTAREA
:
178 case SID_DEFINE_PRINTAREA
:
180 if ( pDocShell
&& pDocShell
->IsDocShared() )
182 rSet
.DisableItem( nWhich
);
187 case SID_DELETE_PRINTAREA
:
188 if ( nTabSelCount
> 1 )
190 // #i22589# also take "Print Entire Sheet" into account here
191 sal_Bool bHas
= false;
192 for (SCTAB i
=0; !bHas
&& i
<nTabCount
; i
++)
193 bHas
= rMark
.GetTableSelect(i
) && (pDoc
->GetPrintRangeCount(i
) || pDoc
->IsPrintEntireSheet(i
));
195 rSet
.DisableItem( nWhich
);
197 else if ( !pDoc
->GetPrintRangeCount( nTab
) && !pDoc
->IsPrintEntireSheet( nTab
) )
198 rSet
.DisableItem( nWhich
);
199 if ( pDocShell
&& pDocShell
->IsDocShared() )
201 rSet
.DisableItem( nWhich
);
205 case SID_STATUS_PAGESTYLE
:
207 GetViewData()->GetDocShell()->GetStatePageStyle( *this, rSet
, nTab
);
210 case SID_SEARCH_ITEM
:
212 SvxSearchItem
aItem(ScGlobal::GetSearchItem()); // make a copy.
213 // Search on current selection if a range is marked.
214 aItem
.SetSelection(rMark
.IsMarked());
219 case SID_SEARCH_OPTIONS
:
222 sal_uInt16 nOptions
= 0xffff;
224 // No replacement if ReadOnly
225 if (GetViewData()->GetDocShell()->IsReadOnly())
226 nOptions
&= ~( SEARCH_OPTIONS_REPLACE
| SEARCH_OPTIONS_REPLACE_ALL
);
227 rSet
.Put( SfxUInt16Item( nWhich
, nOptions
) );
231 case SID_CURRENTCELL
:
233 ScAddress
aScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), 0 );
234 OUString
aAddr(aScAddress
.Format(SCA_ABS
, NULL
, pDoc
->GetAddressConvention()));
235 SfxStringItem
aPosItem( SID_CURRENTCELL
, aAddr
);
237 rSet
.Put( aPosItem
);
242 // Table for Basic is 1-based
243 rSet
.Put( SfxUInt16Item( nWhich
, static_cast<sal_uInt16
>(GetViewData()->GetTabNo()) + 1 ) );
247 rSet
.Put( SfxStringItem( nWhich
, GetViewData()->GetDocShell()->GetTitle() ) );
250 case FID_TOGGLEINPUTLINE
:
252 sal_uInt16 nId
= ScInputWindowWrapper::GetChildWindowId();
254 if ( pThisFrame
->KnowsChildWindow( nId
) )
256 SfxChildWindow
* pWnd
= pThisFrame
->GetChildWindow( nId
);
257 rSet
.Put( SfxBoolItem( nWhich
, pWnd
? sal_True
: false ) );
260 rSet
.DisableItem( nWhich
);
264 case FID_DEL_MANUALBREAKS
:
265 if (!pDoc
->HasManualBreaks(nTab
))
266 rSet
.DisableItem( nWhich
);
269 case FID_RESET_PRINTZOOM
:
271 // disable if already set to default
273 OUString aStyleName
= pDoc
->GetPageStyle( nTab
);
274 ScStyleSheetPool
* pStylePool
= pDoc
->GetStyleSheetPool();
275 SfxStyleSheetBase
* pStyleSheet
= pStylePool
->Find( aStyleName
,
276 SFX_STYLE_FAMILY_PAGE
);
277 OSL_ENSURE( pStyleSheet
, "PageStyle not found" );
280 SfxItemSet
& rStyleSet
= pStyleSheet
->GetItemSet();
281 sal_uInt16 nScale
= ((const SfxUInt16Item
&)
282 rStyleSet
.Get(ATTR_PAGE_SCALE
)).GetValue();
283 sal_uInt16 nPages
= ((const SfxUInt16Item
&)
284 rStyleSet
.Get(ATTR_PAGE_SCALETOPAGES
)).GetValue();
285 if ( nScale
== 100 && nPages
== 0 )
286 rSet
.DisableItem( nWhich
);
294 rSet
.DisableItem( nWhich
);
297 const Fraction
& rOldY
= GetViewData()->GetZoomY();
298 sal_uInt16 nZoom
= (sal_uInt16
)(( rOldY
.GetNumerator() * 100 )
299 / rOldY
.GetDenominator());
300 rSet
.Put( SvxZoomItem( SVX_ZOOM_PERCENT
, nZoom
, nWhich
) );
304 case SID_ATTR_ZOOMSLIDER
:
307 rSet
.DisableItem( nWhich
);
310 const Fraction
& rOldY
= GetViewData()->GetZoomY();
311 sal_uInt16 nCurrentZoom
= (sal_uInt16
)(( rOldY
.GetNumerator() * 100 ) / rOldY
.GetDenominator());
315 SvxZoomSliderItem
aZoomSliderItem( nCurrentZoom
, MINZOOM
, MAXZOOM
, SID_ATTR_ZOOMSLIDER
);
316 aZoomSliderItem
.AddSnappingPoint( 100 );
317 rSet
.Put( aZoomSliderItem
);
323 case FID_TOGGLESYNTAX
:
324 rSet
.Put(SfxBoolItem(nWhich
, GetViewData()->IsSyntaxMode()));
327 case FID_TOGGLEHEADERS
:
328 rSet
.Put(SfxBoolItem(nWhich
, GetViewData()->IsHeaderMode()));
331 case FID_TOGGLEFORMULA
:
333 const ScViewOptions
& rOpts
= pViewData
->GetOptions();
334 sal_Bool bFormulaMode
= rOpts
.GetOption( VOPT_FORMULAS
);
335 rSet
.Put(SfxBoolItem(nWhich
, bFormulaMode
));
339 case FID_NORMALVIEWMODE
:
340 case FID_PAGEBREAKMODE
:
341 // always handle both slots - they exclude each other
344 rSet
.DisableItem( FID_NORMALVIEWMODE
);
345 rSet
.DisableItem( FID_PAGEBREAKMODE
);
349 rSet
.Put(SfxBoolItem(FID_NORMALVIEWMODE
, !GetViewData()->IsPagebreakMode()));
350 rSet
.Put(SfxBoolItem(FID_PAGEBREAKMODE
, GetViewData()->IsPagebreakMode()));
354 case FID_FUNCTION_BOX
:
355 nMyId
= ScFunctionChildWindow::GetChildWindowId();
356 rSet
.Put(SfxBoolItem(FID_FUNCTION_BOX
, pThisFrame
->HasChildWindow(nMyId
)));
359 case FID_PROTECT_DOC
:
361 if ( pDocShell
&& pDocShell
->IsDocShared() )
363 rSet
.DisableItem( nWhich
);
367 rSet
.Put( SfxBoolItem( nWhich
, pDoc
->IsDocProtected() ) );
372 case FID_PROTECT_TABLE
:
374 if ( pDocShell
&& pDocShell
->IsDocShared() )
376 rSet
.DisableItem( nWhich
);
380 rSet
.Put( SfxBoolItem( nWhich
, pDoc
->IsTabProtected( nTab
) ) );
385 case SID_AUTO_OUTLINE
:
387 if (pDoc
->GetChangeTrack()!=NULL
|| GetViewData()->IsMultiMarked())
389 rSet
.DisableItem( nWhich
);
394 case SID_OUTLINE_DELETEALL
:
396 SCTAB nOlTab
= GetViewData()->GetTabNo();
397 ScOutlineTable
* pOlTable
= pDoc
->GetOutlineTable( nOlTab
);
398 if (pOlTable
== NULL
)
399 rSet
.DisableItem( nWhich
);
403 case SID_WINDOW_SPLIT
:
404 rSet
.Put(SfxBoolItem(nWhich
,
405 pViewData
->GetHSplitMode() == SC_SPLIT_NORMAL
||
406 pViewData
->GetVSplitMode() == SC_SPLIT_NORMAL
));
410 rSet
.Put(SfxBoolItem(nWhich
,
411 pViewData
->GetHSplitMode() == SC_SPLIT_FIX
||
412 pViewData
->GetVSplitMode() == SC_SPLIT_FIX
));
417 if ( pDoc
->GetChangeTrack() == NULL
|| ( pDocShell
&& pDocShell
->IsDocShared() ) )
418 rSet
.DisableItem( nWhich
);
423 rSet
.Put(SfxBoolItem(FID_CHG_ACCEPT
,
424 pThisFrame
->HasChildWindow(FID_CHG_ACCEPT
)));
425 if(pDoc
->GetChangeTrack()==NULL
)
427 if ( !pThisFrame
->HasChildWindow(FID_CHG_ACCEPT
) )
429 rSet
.DisableItem( nWhich
);
432 if ( pDocShell
&& pDocShell
->IsDocShared() )
434 rSet
.DisableItem( nWhich
);
440 // in protected tables
441 if ( pDocShell
&& ( pDocShell
->IsReadOnly() || pDocShell
->IsDocShared() ) )
442 rSet
.DisableItem( nWhich
);
445 case SID_PRINTPREVIEW
:
446 // Toggle slot needs a State
447 rSet
.Put( SfxBoolItem( nWhich
, false ) );
450 case SID_READONLY_MODE
:
451 rSet
.Put( SfxBoolItem( nWhich
, GetViewData()->GetDocShell()->IsReadOnly() ) );
454 case FID_TAB_DESELECTALL
:
455 if ( nTabSelCount
== 1 )
456 rSet
.DisableItem( nWhich
); // enabled only if several sheets are selected
459 } // switch ( nWitch )
460 nWhich
= aIter
.NextWhich();
461 } // while ( nWitch )
464 //------------------------------------------------------------------
465 void ScTabViewShell::ExecuteCellFormatDlg(SfxRequest
& rReq
, const OString
&rName
)
467 SfxAbstractTabDialog
* pDlg
= NULL
;
468 ScDocument
* pDoc
= GetViewData()->GetDocument();
470 SvxBoxItem
aLineOuter( ATTR_BORDER
);
471 SvxBoxInfoItem
aLineInner( ATTR_BORDER_INNER
);
473 SvxNumberInfoItem
* pNumberInfoItem
= NULL
;
474 const ScPatternAttr
* pOldAttrs
= GetSelectionPattern();
475 SfxItemSet
* pOldSet
= new SfxItemSet(
476 pOldAttrs
->GetItemSet() );
479 // Get border items and put them in the set:
480 GetSelectionFrame( aLineOuter
, aLineInner
);
481 //Fix border incorrect for RTL fdo#62399
482 if( pDoc
->IsLayoutRTL( GetViewData()->GetTabNo() ) )
484 SvxBoxItem
aNewFrame( aLineOuter
);
485 SvxBoxInfoItem
aTempInfo( aLineInner
);
487 if ( aLineInner
.IsValid(VALID_LEFT
) )
488 aNewFrame
.SetLine( aLineOuter
.GetLeft(), BOX_LINE_RIGHT
);
489 if ( aLineInner
.IsValid(VALID_RIGHT
) )
490 aNewFrame
.SetLine( aLineOuter
.GetRight(), BOX_LINE_LEFT
);
492 aLineInner
.SetValid( VALID_LEFT
, aTempInfo
.IsValid(VALID_RIGHT
));
493 aLineInner
.SetValid( VALID_RIGHT
, aTempInfo
.IsValid(VALID_LEFT
));
495 pOldSet
->Put( aNewFrame
);
498 pOldSet
->Put( aLineOuter
);
500 pOldSet
->Put( aLineInner
);
502 // Generate NumberFormat Value from Value and Language and box it.
503 pOldSet
->Put( SfxUInt32Item( ATTR_VALUE_FORMAT
,
504 pOldAttrs
->GetNumberFormat( pDoc
->GetFormatTable() ) ) );
506 MakeNumberInfoItem( pDoc
, GetViewData(), &pNumberInfoItem
);
508 pOldSet
->MergeRange( SID_ATTR_NUMBERFORMAT_INFO
, SID_ATTR_NUMBERFORMAT_INFO
);
509 pOldSet
->Put(*pNumberInfoItem
);
511 bInFormatDialog
= true;
512 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
513 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
515 pDlg
= pFact
->CreateScAttrDlg(GetViewFrame(), GetDialogParent(), pOldSet
);
516 OSL_ENSURE(pDlg
, "Dialog create fail!");
517 if (!rName
.isEmpty())
518 pDlg
->SetCurPageId(rName
);
519 short nResult
= pDlg
->Execute();
520 bInFormatDialog
= false;
522 if ( nResult
== RET_OK
)
524 const SfxItemSet
* pOutSet
= pDlg
->GetOutputItemSet();
526 const SfxPoolItem
* pItem
=NULL
;
527 if(pOutSet
->GetItemState(SID_ATTR_NUMBERFORMAT_INFO
,sal_True
,&pItem
)==SFX_ITEM_SET
)
530 UpdateNumberFormatter((const SvxNumberInfoItem
&)*pItem
);
533 ApplyAttributes( pOutSet
, pOldSet
);
535 rReq
.Done( *pOutSet
);
538 delete pNumberInfoItem
;
542 //------------------------------------------------------------------
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
* pViewData
= GetViewData();
563 ScDocument
* pDoc
= pViewData
->GetDocument();
566 const ScAddress
aPos( pViewData
->GetCurPos() );
567 ScCompiler
aComp( pDoc
, aPos
);
568 aComp
.SetGrammar(pDoc
->GetGrammar());
569 aComp
.SetCloseBrackets( false );
570 boost::scoped_ptr
<ScTokenArray
> pArr(aComp
.CompileString(aString
));
571 if ( pArr
&& pArr
->MayReferenceFollow() )
589 //------------------------------------------------------------------
591 void ScTabViewShell::ExecuteInputDirect()
593 if ( !IsRefInputMode() )
595 ScModule
* pScMod
= SC_MOD();
598 pScMod
->InputEnterHandler();
603 //------------------------------------------------------------------
605 void ScTabViewShell::UpdateInputHandler( sal_Bool bForce
/* = sal_False */, sal_Bool bStopEditing
/* = sal_True */ )
607 ScInputHandler
* pHdl
= pInputHandler
? pInputHandler
: SC_MOD()->GetInputHdl();
612 const EditTextObject
* pObject
= NULL
;
613 ScViewData
* pViewData
= GetViewData();
614 ScDocument
* pDoc
= pViewData
->GetDocument();
616 SCCOL nPosX
= pViewData
->GetCurX();
617 SCROW nPosY
= pViewData
->GetCurY();
618 SCTAB nTab
= pViewData
->GetTabNo();
625 ScAddress aPos
= pViewData
->GetCurPos();
627 pViewData
->GetSimpleArea( nStartCol
, nStartRow
, nStartTab
,
628 nEndCol
, nEndRow
, nEndTab
);
630 PutInOrder( nStartCol
, nEndCol
);
631 PutInOrder( nStartRow
, nEndRow
);
632 PutInOrder( nStartTab
, nEndTab
);
634 bool bHideFormula
= false;
635 bool bHideAll
= false;
637 if (pDoc
->IsTabProtected(nTab
))
639 const ScProtectionAttr
* pProt
= (const ScProtectionAttr
*)
640 pDoc
->GetAttr( nPosX
,nPosY
,nTab
,
642 bHideFormula
= pProt
->GetHideFormula();
643 bHideAll
= pProt
->GetHideCell();
648 eType
= pDoc
->GetCellType(aPos
);
649 if (eType
== CELLTYPE_FORMULA
)
652 pDoc
->GetFormula( nPosX
, nPosY
, nTab
, aString
);
654 else if (eType
== CELLTYPE_EDIT
)
656 pObject
= pDoc
->GetEditText(aPos
);
660 pDoc
->GetInputString( nPosX
, nPosY
, nTab
, aString
);
661 if (eType
== CELLTYPE_STRING
)
663 // Bei Bedarf ein ' vorneweg, damit der String nicht ungewollt
664 // als Zahl interpretiert wird, und um dem Benutzer zu zeigen,
665 // dass es ein String ist (#35060#).
666 //! Auch bei Zahlformat "Text"? -> dann beim Editieren wegnehmen
668 SvNumberFormatter
* pFormatter
= pDoc
->GetFormatTable();
670 pDoc
->GetNumberFormat( nPosX
, nPosY
, nTab
, nNumFmt
);
672 if ( pFormatter
->IsNumberFormat(aString
, nNumFmt
, fDummy
) )
673 aString
= "'" + aString
;
678 ScInputHdlState
aState( ScAddress( nPosX
, nPosY
, nTab
),
679 ScAddress( nStartCol
, nStartRow
, nTab
),
680 ScAddress( nEndCol
, nEndRow
, nTab
),
684 // if using the view's local input handler, this view can always be set
685 // as current view inside NotifyChange.
686 ScTabViewShell
* pSourceSh
= pInputHandler
? this : NULL
;
688 pHdl
->NotifyChange( &aState
, bForce
, pSourceSh
, bStopEditing
);
691 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
692 rBindings
.Invalidate( SID_STATUS_SUM
); // immer zusammen mit Eingabezeile
693 rBindings
.Invalidate( SID_ATTR_SIZE
);
694 rBindings
.Invalidate( SID_TABLE_CELL
);
697 void ScTabViewShell::UpdateInputHandlerCellAdjust( SvxCellHorJustify eJust
)
699 if( ScInputHandler
* pHdl
= pInputHandler
? pInputHandler
: SC_MOD()->GetInputHdl() )
700 pHdl
->UpdateCellAdjust( eJust
);
703 //------------------------------------------------------------------
705 void ScTabViewShell::ExecuteSave( SfxRequest
& rReq
)
707 // only SID_SAVEDOC / SID_SAVEASDOC
709 // Finish entering in any case, even if a formula is being processed
710 SC_MOD()->InputEnterHandler();
712 if ( GetViewData()->GetDocShell()->IsDocShared() )
714 GetViewData()->GetDocShell()->SetDocumentModified();
717 // otherwise as normal
718 GetViewData()->GetDocShell()->ExecuteSlot( rReq
);
721 void ScTabViewShell::GetSaveState( SfxItemSet
& rSet
)
723 SfxShell
* pDocSh
= GetViewData()->GetDocShell();
725 SfxWhichIter
aIter(rSet
);
726 sal_uInt16 nWhich
= aIter
.FirstWhich();
729 if ( nWhich
!= SID_SAVEDOC
|| !GetViewData()->GetDocShell()->IsDocShared() )
731 // get state from DocShell
732 pDocSh
->GetSlotState( nWhich
, NULL
, &rSet
);
734 nWhich
= aIter
.NextWhich();
738 void ScTabViewShell::ExecDrawOpt( SfxRequest
& rReq
)
740 ScViewOptions aViewOptions
= GetViewData()->GetOptions();
741 ScGridOptions aGridOptions
= aViewOptions
.GetGridOptions();
743 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
744 const SfxItemSet
* pArgs
= rReq
.GetArgs();
745 const SfxPoolItem
* pItem
;
746 sal_uInt16 nSlotId
= rReq
.GetSlot();
749 case SID_GRID_VISIBLE
:
750 if ( pArgs
&& pArgs
->GetItemState(nSlotId
,sal_True
,&pItem
) == SFX_ITEM_SET
)
752 aGridOptions
.SetGridVisible( ((const SfxBoolItem
*)pItem
)->GetValue() );
753 aViewOptions
.SetGridOptions(aGridOptions
);
754 rBindings
.Invalidate(SID_GRID_VISIBLE
);
759 if ( pArgs
&& pArgs
->GetItemState(nSlotId
,sal_True
,&pItem
) == SFX_ITEM_SET
)
761 aGridOptions
.SetUseGridSnap( ((const SfxBoolItem
*)pItem
)->GetValue() );
762 aViewOptions
.SetGridOptions(aGridOptions
);
763 rBindings
.Invalidate(SID_GRID_USE
);
767 case SID_HELPLINES_MOVE
:
768 if ( pArgs
&& pArgs
->GetItemState(nSlotId
,sal_True
,&pItem
) == SFX_ITEM_SET
)
770 aViewOptions
.SetOption( VOPT_HELPLINES
, ((const SfxBoolItem
*)pItem
)->GetValue() );
771 rBindings
.Invalidate(SID_HELPLINES_MOVE
);
776 GetViewData()->SetOptions(aViewOptions
);
779 void ScTabViewShell::GetDrawOptState( SfxItemSet
& rSet
)
783 const ScViewOptions
& rViewOptions
= GetViewData()->GetOptions();
784 const ScGridOptions
& rGridOptions
= rViewOptions
.GetGridOptions();
786 aBool
.SetValue(rGridOptions
.GetGridVisible());
787 aBool
.SetWhich( SID_GRID_VISIBLE
);
790 aBool
.SetValue(rGridOptions
.GetUseGridSnap());
791 aBool
.SetWhich( SID_GRID_USE
);
794 aBool
.SetValue(rViewOptions
.GetOption( VOPT_HELPLINES
));
795 aBool
.SetWhich( SID_HELPLINES_MOVE
);
802 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */