1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tabvwsha.cxx,v $
10 * $Revision: 1.28.14.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 // INCLUDE ---------------------------------------------------------------
38 #define _ZFORLIST_DECLARE_TABLE
39 #include "scitems.hxx"
40 #include <svtools/slstitm.hxx>
41 #include <svtools/stritem.hxx>
42 #include <svtools/whiter.hxx>
43 #include <svtools/zformat.hxx>
44 #include <svx/boxitem.hxx>
45 #include <svx/numinf.hxx>
46 #include <svx/srchitem.hxx>
47 #include <svx/zoomslideritem.hxx>
48 #include <sfx2/bindings.hxx>
49 #include <sfx2/viewfrm.hxx>
50 #include <sfx2/dispatch.hxx>
51 #include <sfx2/request.hxx>
52 #include <vcl/msgbox.hxx>
56 #include "patattr.hxx"
57 #include "document.hxx"
58 #include "cell.hxx" // Input Status Edit-Zellen
59 #include "globstr.hrc"
61 #include "inputhdl.hxx"
62 #include "inputwin.hxx"
64 #include "viewdata.hxx"
65 //CHINA001 #include "attrdlg.hxx"
66 #include "appoptio.hxx"
68 #include "stlpool.hxx"
69 #include "tabvwsh.hxx"
70 #include "dwfunctr.hxx"
71 #include "scabstdlg.hxx" //CHINA001
72 #include "compiler.hxx"
75 BOOL
ScTabViewShell::GetFunction( String
& rFuncStr
, sal_uInt16 nErrCode
)
79 ScSubTotalFunc eFunc
= (ScSubTotalFunc
) SC_MOD()->GetAppOptions().GetStatusFunc();
81 if (eFunc
== SUBTOTAL_FUNC_CNT
|| eFunc
== SUBTOTAL_FUNC_CNT2
)
86 rFuncStr
= ScGlobal::GetLongErrorString(nErrCode
);
90 USHORT nGlobStrId
= 0;
93 case SUBTOTAL_FUNC_AVE
: nGlobStrId
= STR_FUN_TEXT_AVG
; break;
94 case SUBTOTAL_FUNC_CNT
: nGlobStrId
= STR_FUN_TEXT_COUNT
; break;
95 case SUBTOTAL_FUNC_CNT2
: nGlobStrId
= STR_FUN_TEXT_COUNT2
; break;
96 case SUBTOTAL_FUNC_MAX
: nGlobStrId
= STR_FUN_TEXT_MAX
; break;
97 case SUBTOTAL_FUNC_MIN
: nGlobStrId
= STR_FUN_TEXT_MIN
; break;
98 case SUBTOTAL_FUNC_SUM
: nGlobStrId
= STR_FUN_TEXT_SUM
; break;
101 // added to avoid warnings
106 ScViewData
* pViewData
= GetViewData();
107 ScDocument
* pDoc
= pViewData
->GetDocument();
108 ScMarkData
& rMark
= pViewData
->GetMarkData();
109 SCCOL nPosX
= pViewData
->GetCurX();
110 SCROW nPosY
= pViewData
->GetCurY();
111 SCTAB nTab
= pViewData
->GetTabNo();
113 aStr
= ScGlobal::GetRscString(nGlobStrId
);
116 ScAddress
aCursor( nPosX
, nPosY
, nTab
);
118 if ( pDoc
->GetSelectionFunction( eFunc
, aCursor
, rMark
, nVal
) )
124 // Anzahl im Standardformat, die anderen nach Cursorposition
125 SvNumberFormatter
* pFormatter
= pDoc
->GetFormatTable();
126 sal_uInt32 nNumFmt
= 0;
127 if ( eFunc
!= SUBTOTAL_FUNC_CNT
&& eFunc
!= SUBTOTAL_FUNC_CNT2
)
129 // Zahlformat aus Attributen oder Formel
130 pDoc
->GetNumberFormat( nPosX
, nPosY
, nTab
, nNumFmt
);
131 if ( (nNumFmt
% SV_COUNTRY_LANGUAGE_OFFSET
) == 0 )
134 pDoc
->GetCell( nPosX
, nPosY
, nTab
, pCell
);
135 if (pCell
&& pCell
->GetCellType() == CELLTYPE_FORMULA
)
138 nNumFmt
= ((ScFormulaCell
*)pCell
)->GetStandardFormat(*pFormatter
, nNumFmt
);
145 pFormatter
->GetOutputString( nVal
, nNumFmt
, aValStr
, &pDummy
);
159 // Funktionen, die je nach Selektion disabled sind
162 // SID_DELETE_CONTENTS,
167 void __EXPORT
ScTabViewShell::GetState( SfxItemSet
& rSet
)
169 ScViewData
* pViewData
= GetViewData();
170 ScDocument
* pDoc
= pViewData
->GetDocument();
171 ScDocShell
* pDocShell
= pViewData
->GetDocShell();
172 ScMarkData
& rMark
= pViewData
->GetMarkData();
173 SCCOL nPosX
= pViewData
->GetCurX();
174 SCROW nPosY
= pViewData
->GetCurY();
175 SCTAB nTab
= pViewData
->GetTabNo();
178 SfxViewFrame
* pThisFrame
= GetViewFrame();
179 BOOL bOle
= GetViewFrame()->GetFrame()->IsInPlace();
181 SCTAB nTabCount
= pDoc
->GetTableCount();
182 SCTAB nTabSelCount
= rMark
.GetSelectCount();
184 SfxWhichIter
aIter(rSet
);
185 USHORT nWhich
= aIter
.FirstWhich();
191 case FID_CHG_COMMENT
:
193 ScDocShell
* pDocSh
= GetViewData()->GetDocShell();
194 ScAddress
aPos( nPosX
, nPosY
, nTab
);
195 if ( pDocSh
->IsReadOnly() || !pDocSh
->GetChangeAction(aPos
) || pDocSh
->IsDocShared() )
196 rSet
.DisableItem( nWhich
);
200 case SID_OPENDLG_EDIT_PRINTAREA
:
201 case SID_ADD_PRINTAREA
:
202 case SID_DEFINE_PRINTAREA
:
204 if ( pDocShell
&& pDocShell
->IsDocShared() )
206 rSet
.DisableItem( nWhich
);
211 case SID_DELETE_PRINTAREA
:
212 if ( nTabSelCount
> 1 )
214 // #i22589# also take "Print Entire Sheet" into account here
216 for (SCTAB i
=0; !bHas
&& i
<nTabCount
; i
++)
217 bHas
= rMark
.GetTableSelect(i
) && (pDoc
->GetPrintRangeCount(i
) || pDoc
->IsPrintEntireSheet(i
));
219 rSet
.DisableItem( nWhich
);
221 else if ( !pDoc
->GetPrintRangeCount( nTab
) && !pDoc
->IsPrintEntireSheet( nTab
) )
222 rSet
.DisableItem( nWhich
);
223 if ( pDocShell
&& pDocShell
->IsDocShared() )
225 rSet
.DisableItem( nWhich
);
229 case SID_STATUS_PAGESTYLE
:
231 GetViewData()->GetDocShell()->GetStatePageStyle( *this, rSet
, nTab
);
234 case SID_SEARCH_ITEM
:
236 SvxSearchItem
aItem(ScGlobal::GetSearchItem()); // make a copy.
237 // Search on current selection if a range is marked.
238 aItem
.SetSelection(rMark
.IsMarked());
243 case SID_SEARCH_OPTIONS
:
245 USHORT nOptions
= 0xffff; // alles erlaubt
246 // wenn ReadOnly, kein Ersetzen:
247 if (GetViewData()->GetDocShell()->IsReadOnly())
248 nOptions
&= ~( SEARCH_OPTIONS_REPLACE
| SEARCH_OPTIONS_REPLACE_ALL
);
249 rSet
.Put( SfxUInt16Item( nWhich
, nOptions
) );
253 case SID_CURRENTCELL
:
255 ScAddress
aScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), 0 );
257 aScAddress
.Format( aAddr
, SCA_ABS
, NULL
, pDoc
->GetAddressConvention() );
258 SfxStringItem
aPosItem( SID_CURRENTCELL
, aAddr
);
260 rSet
.Put( aPosItem
);
265 // Tabelle fuer Basic ist 1-basiert
266 rSet
.Put( SfxUInt16Item( nWhich
, static_cast<sal_uInt16
>(GetViewData()->GetTabNo()) + 1 ) );
270 rSet
.Put( SfxStringItem( nWhich
, GetViewData()->GetDocShell()->GetTitle() ) );
273 case FID_TOGGLEINPUTLINE
:
275 USHORT nId
= ScInputWindowWrapper::GetChildWindowId();
277 if ( pThisFrame
->KnowsChildWindow( nId
) )
279 SfxChildWindow
* pWnd
= pThisFrame
->GetChildWindow( nId
);
280 rSet
.Put( SfxBoolItem( nWhich
, pWnd
? TRUE
: FALSE
) );
283 rSet
.DisableItem( nWhich
);
287 case FID_DEL_MANUALBREAKS
:
288 if (!pDoc
->HasManualBreaks(nTab
))
289 rSet
.DisableItem( nWhich
);
292 case FID_RESET_PRINTZOOM
:
294 // disablen, wenn schon Default eingestellt
296 String aStyleName
= pDoc
->GetPageStyle( nTab
);
297 ScStyleSheetPool
* pStylePool
= pDoc
->GetStyleSheetPool();
298 SfxStyleSheetBase
* pStyleSheet
= pStylePool
->Find( aStyleName
,
299 SFX_STYLE_FAMILY_PAGE
);
300 DBG_ASSERT( pStyleSheet
, "PageStyle not found" );
303 SfxItemSet
& rStyleSet
= pStyleSheet
->GetItemSet();
304 USHORT nScale
= ((const SfxUInt16Item
&)
305 rStyleSet
.Get(ATTR_PAGE_SCALE
)).GetValue();
306 USHORT nPages
= ((const SfxUInt16Item
&)
307 rStyleSet
.Get(ATTR_PAGE_SCALETOPAGES
)).GetValue();
308 if ( nScale
== 100 && nPages
== 0 )
309 rSet
.DisableItem( nWhich
);
317 rSet
.DisableItem( nWhich
);
320 const Fraction
& rOldY
= GetViewData()->GetZoomY();
321 USHORT nZoom
= (USHORT
)(( rOldY
.GetNumerator() * 100 )
322 / rOldY
.GetDenominator());
323 rSet
.Put( SvxZoomItem( SVX_ZOOM_PERCENT
, nZoom
, nWhich
) );
327 case SID_ATTR_ZOOMSLIDER
:
330 rSet
.DisableItem( nWhich
);
333 const Fraction
& rOldY
= GetViewData()->GetZoomY();
334 USHORT nCurrentZoom
= (USHORT
)(( rOldY
.GetNumerator() * 100 ) / rOldY
.GetDenominator());
338 SvxZoomSliderItem
aZoomSliderItem( nCurrentZoom
, MINZOOM
, MAXZOOM
, SID_ATTR_ZOOMSLIDER
);
339 aZoomSliderItem
.AddSnappingPoint( 100 );
340 rSet
.Put( aZoomSliderItem
);
346 case FID_TOGGLESYNTAX
:
347 rSet
.Put(SfxBoolItem(nWhich
, GetViewData()->IsSyntaxMode()));
350 case FID_TOGGLEHEADERS
:
351 rSet
.Put(SfxBoolItem(nWhich
, GetViewData()->IsHeaderMode()));
354 case FID_TOGGLEFORMULA
:
356 const ScViewOptions
& rOpts
= pViewData
->GetOptions();
357 BOOL bFormulaMode
= rOpts
.GetOption( VOPT_FORMULAS
);
358 rSet
.Put(SfxBoolItem(nWhich
, bFormulaMode
));
362 case FID_NORMALVIEWMODE
:
363 case FID_PAGEBREAKMODE
:
364 // always handle both slots - they exclude each other
367 rSet
.DisableItem( FID_NORMALVIEWMODE
);
368 rSet
.DisableItem( FID_PAGEBREAKMODE
);
372 rSet
.Put(SfxBoolItem(FID_NORMALVIEWMODE
, !GetViewData()->IsPagebreakMode()));
373 rSet
.Put(SfxBoolItem(FID_PAGEBREAKMODE
, GetViewData()->IsPagebreakMode()));
377 case FID_FUNCTION_BOX
:
378 nMyId
= ScFunctionChildWindow::GetChildWindowId();
379 rSet
.Put(SfxBoolItem(FID_FUNCTION_BOX
, pThisFrame
->HasChildWindow(nMyId
)));
382 case FID_PROTECT_DOC
:
384 if ( pDocShell
&& pDocShell
->IsDocShared() )
386 rSet
.DisableItem( nWhich
);
390 rSet
.Put( SfxBoolItem( nWhich
, pDoc
->IsDocProtected() ) );
395 case FID_PROTECT_TABLE
:
397 if ( pDocShell
&& pDocShell
->IsDocShared() )
399 rSet
.DisableItem( nWhich
);
403 rSet
.Put( SfxBoolItem( nWhich
, pDoc
->IsTabProtected( nTab
) ) );
408 case SID_AUTO_OUTLINE
:
410 if (pDoc
->GetChangeTrack()!=NULL
|| GetViewData()->IsMultiMarked())
412 rSet
.DisableItem( nWhich
);
417 case SID_OUTLINE_DELETEALL
:
419 SCTAB nOlTab
= GetViewData()->GetTabNo();
420 ScOutlineTable
* pOlTable
= pDoc
->GetOutlineTable( nOlTab
);
421 if (pOlTable
== NULL
)
422 rSet
.DisableItem( nWhich
);
426 case SID_WINDOW_SPLIT
:
427 rSet
.Put(SfxBoolItem(nWhich
,
428 pViewData
->GetHSplitMode() == SC_SPLIT_NORMAL
||
429 pViewData
->GetVSplitMode() == SC_SPLIT_NORMAL
));
433 rSet
.Put(SfxBoolItem(nWhich
,
434 pViewData
->GetHSplitMode() == SC_SPLIT_FIX
||
435 pViewData
->GetVSplitMode() == SC_SPLIT_FIX
));
440 if ( pDoc
->GetChangeTrack() == NULL
|| ( pDocShell
&& pDocShell
->IsDocShared() ) )
441 rSet
.DisableItem( nWhich
);
446 rSet
.Put(SfxBoolItem(FID_CHG_ACCEPT
,
447 pThisFrame
->HasChildWindow(FID_CHG_ACCEPT
)));
448 if(pDoc
->GetChangeTrack()==NULL
)
450 if ( !pThisFrame
->HasChildWindow(FID_CHG_ACCEPT
) )
452 rSet
.DisableItem( nWhich
);
455 if ( pDocShell
&& pDocShell
->IsDocShared() )
457 rSet
.DisableItem( nWhich
);
463 //! bei geschuetzten Tabellen ???
464 if ( pDocShell
&& ( pDocShell
->IsReadOnly() || pDocShell
->IsDocShared() ) )
465 rSet
.DisableItem( nWhich
);
468 case SID_PRINTPREVIEW
:
469 // #58924# Toggle-Slot braucht einen State
470 rSet
.Put( SfxBoolItem( nWhich
, FALSE
) );
473 case SID_READONLY_MODE
:
474 rSet
.Put( SfxBoolItem( nWhich
, GetViewData()->GetDocShell()->IsReadOnly() ) );
477 case FID_TAB_DESELECTALL
:
478 if ( nTabSelCount
== 1 )
479 rSet
.DisableItem( nWhich
); // enabled only if several sheets are selected
482 } // switch ( nWitch )
483 nWhich
= aIter
.NextWhich();
484 } // while ( nWitch )
487 //------------------------------------------------------------------
488 void ScTabViewShell::ExecuteCellFormatDlg( SfxRequest
& rReq
, USHORT nTabPage
)
490 //CHINA001 ScAttrDlg* pDlg = NULL;
491 SfxAbstractTabDialog
* pDlg
= NULL
; //CHINA001
492 ScDocument
* pDoc
= GetViewData()->GetDocument();
494 SvxBoxItem
aLineOuter( ATTR_BORDER
);
495 SvxBoxInfoItem
aLineInner( ATTR_BORDER_INNER
);
497 SvxNumberInfoItem
* pNumberInfoItem
= NULL
;
498 const ScPatternAttr
* pOldAttrs
= GetSelectionPattern();
499 SfxItemSet
* pOldSet
= new SfxItemSet(
500 pOldAttrs
->GetItemSet() );
503 // Umrandungs-Items holen und in den Set packen:
504 GetSelectionFrame( aLineOuter
, aLineInner
);
505 pOldSet
->Put( aLineOuter
);
506 pOldSet
->Put( aLineInner
);
508 // NumberFormat Value aus Value und Language erzeugen und eintueten
509 pOldSet
->Put( SfxUInt32Item( ATTR_VALUE_FORMAT
,
510 pOldAttrs
->GetNumberFormat( pDoc
->GetFormatTable() ) ) );
512 MakeNumberInfoItem( pDoc
, GetViewData(), &pNumberInfoItem
);
514 pOldSet
->MergeRange( SID_ATTR_NUMBERFORMAT_INFO
, SID_ATTR_NUMBERFORMAT_INFO
);
515 pOldSet
->Put(*pNumberInfoItem
);
517 bInFormatDialog
= TRUE
;
518 //CHINA001 pDlg = new ScAttrDlg( GetViewFrame(), GetDialogParent(), pOldSet );
519 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
520 DBG_ASSERT(pFact
, "ScAbstractFactory create fail!");//CHINA001
522 pDlg
= pFact
->CreateScAttrDlg( GetViewFrame(), GetDialogParent(), pOldSet
, RID_SCDLG_ATTR
);
523 DBG_ASSERT(pDlg
, "Dialog create fail!");//CHINA001
524 if ( nTabPage
!= 0xffff )
525 pDlg
->SetCurPageId( nTabPage
);
526 short nResult
= pDlg
->Execute();
527 bInFormatDialog
= FALSE
;
529 if ( nResult
== RET_OK
)
531 const SfxItemSet
* pOutSet
= pDlg
->GetOutputItemSet();
533 const SfxPoolItem
* pItem
=NULL
;
534 if(pOutSet
->GetItemState(SID_ATTR_NUMBERFORMAT_INFO
,TRUE
,&pItem
)==SFX_ITEM_SET
)
537 UpdateNumberFormatter( pDoc
,(const SvxNumberInfoItem
&)*pItem
);
540 ApplyAttributes( pOutSet
, pOldSet
);
542 rReq
.Done( *pOutSet
);
545 delete pNumberInfoItem
;
549 //------------------------------------------------------------------
551 bool ScTabViewShell::IsRefInputMode() const
553 ScModule
* pScMod
= SC_MOD();
556 if( pScMod
->IsRefDialogOpen() )
557 return pScMod
->IsFormulaMode();
558 if( pScMod
->IsFormulaMode() )
560 ScInputHandler
* pHdl
= pScMod
->GetInputHdl();
563 String aString
= pHdl
->GetEditString();
564 if ( !pHdl
->GetSelIsRef() && aString
.Len() > 1 &&
565 ( aString
.GetChar(0) == '+' || aString
.GetChar(0) == '-' ) )
567 const ScViewData
* pViewData
= GetViewData();
570 ScDocument
* pDoc
= pViewData
->GetDocument();
573 const ScAddress
aPos( pViewData
->GetCurPos() );
574 ScCompiler
aComp( pDoc
, aPos
);
575 aComp
.SetGrammar(pDoc
->GetGrammar());
576 aComp
.SetCloseBrackets( false );
577 ScTokenArray
* pArr
= aComp
.CompileString( aString
);
578 if ( pArr
&& pArr
->MayReferenceFollow() )
596 //------------------------------------------------------------------
598 void ScTabViewShell::ExecuteInputDirect()
600 if ( !IsRefInputMode() )
602 ScModule
* pScMod
= SC_MOD();
605 pScMod
->InputEnterHandler();
610 //------------------------------------------------------------------
612 void ScTabViewShell::UpdateInputHandler( BOOL bForce
/* = FALSE */, BOOL bStopEditing
/* = TRUE */ )
614 ScInputHandler
* pHdl
= pInputHandler
? pInputHandler
: SC_MOD()->GetInputHdl();
619 const EditTextObject
* pObject
= NULL
;
620 ScViewData
* pViewData
= GetViewData();
621 ScDocument
* pDoc
= pViewData
->GetDocument();
623 SCCOL nPosX
= pViewData
->GetCurX();
624 SCROW nPosY
= pViewData
->GetCurY();
625 SCTAB nTab
= pViewData
->GetTabNo();
633 pViewData
->GetSimpleArea( nStartCol
, nStartRow
, nStartTab
,
634 nEndCol
, nEndRow
, nEndTab
);
636 PutInOrder( nStartCol
, nEndCol
);
637 PutInOrder( nStartRow
, nEndRow
);
638 PutInOrder( nStartTab
, nEndTab
);
640 BOOL bHideFormula
= FALSE
;
641 BOOL bHideAll
= FALSE
;
643 if (pDoc
->IsTabProtected(nTab
))
645 const ScProtectionAttr
* pProt
= (const ScProtectionAttr
*)
646 pDoc
->GetAttr( nPosX
,nPosY
,nTab
,
648 bHideFormula
= pProt
->GetHideFormula();
649 bHideAll
= pProt
->GetHideCell();
654 pDoc
->GetCellType( nPosX
, nPosY
, nTab
, eType
);
655 if (eType
== CELLTYPE_FORMULA
)
658 pDoc
->GetFormula( nPosX
, nPosY
, nTab
, aString
);
660 else if (eType
== CELLTYPE_EDIT
)
663 pDoc
->GetCell( nPosX
, nPosY
, nTab
, pCell
);
664 ((ScEditCell
*)pCell
)->GetData( pObject
);
668 pDoc
->GetInputString( nPosX
, nPosY
, nTab
, aString
);
669 if (eType
== CELLTYPE_STRING
)
671 // Bei Bedarf ein ' vorneweg, damit der String nicht ungewollt
672 // als Zahl interpretiert wird, und um dem Benutzer zu zeigen,
673 // dass es ein String ist (#35060#).
674 //! Auch bei Zahlformat "Text"? -> dann beim Editieren wegnehmen
676 SvNumberFormatter
* pFormatter
= pDoc
->GetFormatTable();
678 pDoc
->GetNumberFormat( nPosX
, nPosY
, nTab
, nNumFmt
);
680 if ( pFormatter
->IsNumberFormat(aString
, nNumFmt
, fDummy
) )
681 aString
.Insert('\'',0);
686 ScInputHdlState
aState( ScAddress( nPosX
, nPosY
, nTab
),
687 ScAddress( nStartCol
, nStartRow
, nTab
),
688 ScAddress( nEndCol
, nEndRow
, nTab
),
692 // if using the view's local input handler, this view can always be set
693 // as current view inside NotifyChange.
694 ScTabViewShell
* pSourceSh
= pInputHandler
? this : NULL
;
696 pHdl
->NotifyChange( &aState
, bForce
, pSourceSh
, bStopEditing
);
699 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
700 rBindings
.Invalidate( SID_STATUS_SUM
); // immer zusammen mit Eingabezeile
701 rBindings
.Invalidate( SID_ATTR_SIZE
);
702 rBindings
.Invalidate( SID_TABLE_CELL
);
705 void ScTabViewShell::UpdateInputHandlerCellAdjust( SvxCellHorJustify eJust
)
707 if( ScInputHandler
* pHdl
= pInputHandler
? pInputHandler
: SC_MOD()->GetInputHdl() )
708 pHdl
->UpdateCellAdjust( eJust
);
711 //------------------------------------------------------------------
713 void __EXPORT
ScTabViewShell::ExecuteSave( SfxRequest
& rReq
)
715 // nur SID_SAVEDOC / SID_SAVEASDOC
717 // Eingabe auf jeden Fall abschliessen, auch wenn eine Formel bearbeitet wird
718 SC_MOD()->InputEnterHandler();
720 if ( GetViewData()->GetDocShell()->IsDocShared() )
722 GetViewData()->GetDocShell()->SetDocumentModified();
725 // ansonsten normal weiter
726 GetViewData()->GetDocShell()->ExecuteSlot( rReq
);
729 void __EXPORT
ScTabViewShell::GetSaveState( SfxItemSet
& rSet
)
731 SfxShell
* pDocSh
= GetViewData()->GetDocShell();
733 SfxWhichIter
aIter(rSet
);
734 USHORT nWhich
= aIter
.FirstWhich();
737 if ( nWhich
!= SID_SAVEDOC
|| !GetViewData()->GetDocShell()->IsDocShared() )
739 // get state from DocShell
740 pDocSh
->GetSlotState( nWhich
, NULL
, &rSet
);
742 nWhich
= aIter
.NextWhich();
746 //------------------------------------------------------------------
748 void ScTabViewShell::ExecuteUndo(SfxRequest
& rReq
)
750 SfxShell
* pSh
= GetViewData()->GetDispatcher().GetShell(0);
751 SfxUndoManager
* pUndoManager
= pSh
->GetUndoManager();
753 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
754 ScDocShell
* pDocSh
= GetViewData()->GetDocShell();
756 USHORT nSlot
= rReq
.GetSlot();
763 BOOL bIsUndo
= ( nSlot
== SID_UNDO
);
766 const SfxPoolItem
* pItem
;
767 if ( pReqArgs
&& pReqArgs
->GetItemState( nSlot
, TRUE
, &pItem
) == SFX_ITEM_SET
)
768 nCount
= ((const SfxUInt16Item
*)pItem
)->GetValue();
770 // lock paint for more than one cell undo action (not for editing within a cell)
771 BOOL bLockPaint
= ( nCount
> 1 && pUndoManager
== GetUndoManager() );
775 for (USHORT i
=0; i
<nCount
; i
++)
778 pUndoManager
->Undo(0);
780 pUndoManager
->Redo(0);
784 pDocSh
->UnlockPaint();
786 GetViewFrame()->GetBindings().InvalidateAll(sal_False
);
790 // GetViewFrame()->ExecuteSlot( rReq );
794 void ScTabViewShell::GetUndoState(SfxItemSet
&rSet
)
796 SfxShell
* pSh
= GetViewData()->GetDispatcher().GetShell(0);
797 SfxUndoManager
* pUndoManager
= pSh
->GetUndoManager();
799 SfxWhichIter
aIter(rSet
);
800 USHORT nWhich
= aIter
.FirstWhich();
805 case SID_GETUNDOSTRINGS
:
806 case SID_GETREDOSTRINGS
:
808 SfxStringListItem
aStrLst( nWhich
);
811 List
* pList
= aStrLst
.GetList();
812 BOOL bIsUndo
= ( nWhich
== SID_GETUNDOSTRINGS
);
813 USHORT nCount
= bIsUndo
? pUndoManager
->GetUndoActionCount() : pUndoManager
->GetRedoActionCount();
814 for (USHORT i
=0; i
<nCount
; i
++)
815 pList
->Insert( new String( bIsUndo
? pUndoManager
->GetUndoActionComment(i
) :
816 pUndoManager
->GetRedoActionComment(i
) ),
823 // get state from sfx view frame
824 GetViewFrame()->GetSlotState( nWhich
, NULL
, &rSet
);
827 nWhich
= aIter
.NextWhich();
832 //------------------------------------------------------------------
834 void ScTabViewShell::ExecDrawOpt( SfxRequest
& rReq
)
836 ScViewOptions aViewOptions
= GetViewData()->GetOptions();
837 ScGridOptions aGridOptions
= aViewOptions
.GetGridOptions();
839 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
840 const SfxItemSet
* pArgs
= rReq
.GetArgs();
841 const SfxPoolItem
* pItem
;
842 USHORT nSlotId
= rReq
.GetSlot();
845 case SID_GRID_VISIBLE
:
846 if ( pArgs
&& pArgs
->GetItemState(nSlotId
,TRUE
,&pItem
) == SFX_ITEM_SET
)
848 aGridOptions
.SetGridVisible( ((const SfxBoolItem
*)pItem
)->GetValue() );
849 aViewOptions
.SetGridOptions(aGridOptions
);
850 rBindings
.Invalidate(SID_GRID_VISIBLE
);
855 if ( pArgs
&& pArgs
->GetItemState(nSlotId
,TRUE
,&pItem
) == SFX_ITEM_SET
)
857 aGridOptions
.SetUseGridSnap( ((const SfxBoolItem
*)pItem
)->GetValue() );
858 aViewOptions
.SetGridOptions(aGridOptions
);
859 rBindings
.Invalidate(SID_GRID_USE
);
863 case SID_HELPLINES_MOVE
:
864 if ( pArgs
&& pArgs
->GetItemState(nSlotId
,TRUE
,&pItem
) == SFX_ITEM_SET
)
866 aViewOptions
.SetOption( VOPT_HELPLINES
, ((const SfxBoolItem
*)pItem
)->GetValue() );
867 rBindings
.Invalidate(SID_HELPLINES_MOVE
);
872 GetViewData()->SetOptions(aViewOptions
);
875 void ScTabViewShell::GetDrawOptState( SfxItemSet
& rSet
)
879 const ScViewOptions
& rViewOptions
= GetViewData()->GetOptions();
880 const ScGridOptions
& rGridOptions
= rViewOptions
.GetGridOptions();
882 aBool
.SetValue(rGridOptions
.GetGridVisible());
883 aBool
.SetWhich( SID_GRID_VISIBLE
);
886 aBool
.SetValue(rGridOptions
.GetUseGridSnap());
887 aBool
.SetWhich( SID_GRID_USE
);
890 aBool
.SetValue(rViewOptions
.GetOption( VOPT_HELPLINES
));
891 aBool
.SetWhich( SID_HELPLINES_MOVE
);