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 $
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 // Anzahl im Standardformat, die anderen nach Cursorposition
117 sal_uInt32 nNumFmt
= 0;
118 SvNumberFormatter
* pFormatter
= pDoc
->GetFormatTable();
119 if ( eFunc
!= SUBTOTAL_FUNC_CNT
&& eFunc
!= SUBTOTAL_FUNC_CNT2
)
121 // Zahlformat aus Attributen oder Formel
122 pDoc
->GetNumberFormat( nPosX
, nPosY
, nTab
, nNumFmt
);
123 if ( (nNumFmt
% SV_COUNTRY_LANGUAGE_OFFSET
) == 0 )
126 pDoc
->GetCell( nPosX
, nPosY
, nTab
, pCell
);
127 if (pCell
&& pCell
->GetCellType() == CELLTYPE_FORMULA
)
128 nNumFmt
= ((ScFormulaCell
*)pCell
)->GetStandardFormat(
129 *pFormatter
, nNumFmt
);
132 ScAddress
aCursor( nPosX
, nPosY
, nTab
);
134 if ( pDoc
->GetSelectionFunction( eFunc
, aCursor
, rMark
, nVal
) )
138 pFormatter
->GetOutputString( nVal
, nNumFmt
, aValStr
, &pDummy
);
151 // Funktionen, die je nach Selektion disabled sind
154 // SID_DELETE_CONTENTS,
159 void __EXPORT
ScTabViewShell::GetState( SfxItemSet
& rSet
)
161 ScViewData
* pViewData
= GetViewData();
162 ScDocument
* pDoc
= pViewData
->GetDocument();
163 ScDocShell
* pDocShell
= pViewData
->GetDocShell();
164 ScMarkData
& rMark
= pViewData
->GetMarkData();
165 SCCOL nPosX
= pViewData
->GetCurX();
166 SCROW nPosY
= pViewData
->GetCurY();
167 SCTAB nTab
= pViewData
->GetTabNo();
170 SfxViewFrame
* pThisFrame
= GetViewFrame();
171 BOOL bOle
= GetViewFrame()->GetFrame()->IsInPlace();
173 SCTAB nTabCount
= pDoc
->GetTableCount();
174 SCTAB nTabSelCount
= rMark
.GetSelectCount();
176 SfxWhichIter
aIter(rSet
);
177 USHORT nWhich
= aIter
.FirstWhich();
183 case FID_CHG_COMMENT
:
185 ScDocShell
* pDocSh
= GetViewData()->GetDocShell();
186 ScAddress
aPos( nPosX
, nPosY
, nTab
);
187 if ( pDocSh
->IsReadOnly() || !pDocSh
->GetChangeAction(aPos
) || pDocSh
->IsDocShared() )
188 rSet
.DisableItem( nWhich
);
192 case SID_OPENDLG_EDIT_PRINTAREA
:
193 case SID_ADD_PRINTAREA
:
194 case SID_DEFINE_PRINTAREA
:
196 if ( pDocShell
&& pDocShell
->IsDocShared() )
198 rSet
.DisableItem( nWhich
);
203 case SID_DELETE_PRINTAREA
:
204 if ( nTabSelCount
> 1 )
206 // #i22589# also take "Print Entire Sheet" into account here
208 for (SCTAB i
=0; !bHas
&& i
<nTabCount
; i
++)
209 bHas
= rMark
.GetTableSelect(i
) && (pDoc
->GetPrintRangeCount(i
) || pDoc
->IsPrintEntireSheet(i
));
211 rSet
.DisableItem( nWhich
);
213 else if ( !pDoc
->GetPrintRangeCount( nTab
) && !pDoc
->IsPrintEntireSheet( nTab
) )
214 rSet
.DisableItem( nWhich
);
215 if ( pDocShell
&& pDocShell
->IsDocShared() )
217 rSet
.DisableItem( nWhich
);
221 case SID_STATUS_PAGESTYLE
:
223 GetViewData()->GetDocShell()->GetStatePageStyle( *this, rSet
, nTab
);
226 case SID_SEARCH_ITEM
:
228 SvxSearchItem
aItem(ScGlobal::GetSearchItem()); // make a copy.
229 // Search on current selection if a range is marked.
230 aItem
.SetSelection(rMark
.IsMarked());
235 case SID_SEARCH_OPTIONS
:
237 USHORT nOptions
= 0xffff; // alles erlaubt
238 // wenn ReadOnly, kein Ersetzen:
239 if (GetViewData()->GetDocShell()->IsReadOnly())
240 nOptions
&= ~( SEARCH_OPTIONS_REPLACE
| SEARCH_OPTIONS_REPLACE_ALL
);
241 rSet
.Put( SfxUInt16Item( nWhich
, nOptions
) );
245 case SID_CURRENTCELL
:
247 ScAddress
aScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), 0 );
249 aScAddress
.Format( aAddr
, SCA_ABS
, NULL
, pDoc
->GetAddressConvention() );
250 SfxStringItem
aPosItem( SID_CURRENTCELL
, aAddr
);
252 rSet
.Put( aPosItem
);
257 // Tabelle fuer Basic ist 1-basiert
258 rSet
.Put( SfxUInt16Item( nWhich
, static_cast<sal_uInt16
>(GetViewData()->GetTabNo()) + 1 ) );
262 rSet
.Put( SfxStringItem( nWhich
, GetViewData()->GetDocShell()->GetTitle() ) );
265 case FID_TOGGLEINPUTLINE
:
267 USHORT nId
= ScInputWindowWrapper::GetChildWindowId();
269 if ( pThisFrame
->KnowsChildWindow( nId
) )
271 SfxChildWindow
* pWnd
= pThisFrame
->GetChildWindow( nId
);
272 rSet
.Put( SfxBoolItem( nWhich
, pWnd
? TRUE
: FALSE
) );
275 rSet
.DisableItem( nWhich
);
279 case FID_DEL_MANUALBREAKS
:
280 if (!pDoc
->HasManualBreaks(nTab
))
281 rSet
.DisableItem( nWhich
);
284 case FID_RESET_PRINTZOOM
:
286 // disablen, wenn schon Default eingestellt
288 String aStyleName
= pDoc
->GetPageStyle( nTab
);
289 ScStyleSheetPool
* pStylePool
= pDoc
->GetStyleSheetPool();
290 SfxStyleSheetBase
* pStyleSheet
= pStylePool
->Find( aStyleName
,
291 SFX_STYLE_FAMILY_PAGE
);
292 DBG_ASSERT( pStyleSheet
, "PageStyle not found" );
295 SfxItemSet
& rStyleSet
= pStyleSheet
->GetItemSet();
296 USHORT nScale
= ((const SfxUInt16Item
&)
297 rStyleSet
.Get(ATTR_PAGE_SCALE
)).GetValue();
298 USHORT nPages
= ((const SfxUInt16Item
&)
299 rStyleSet
.Get(ATTR_PAGE_SCALETOPAGES
)).GetValue();
300 if ( nScale
== 100 && nPages
== 0 )
301 rSet
.DisableItem( nWhich
);
309 rSet
.DisableItem( nWhich
);
312 const Fraction
& rOldY
= GetViewData()->GetZoomY();
313 USHORT nZoom
= (USHORT
)(( rOldY
.GetNumerator() * 100 )
314 / rOldY
.GetDenominator());
315 rSet
.Put( SvxZoomItem( SVX_ZOOM_PERCENT
, nZoom
, nWhich
) );
319 case SID_ATTR_ZOOMSLIDER
:
322 rSet
.DisableItem( nWhich
);
325 const Fraction
& rOldY
= GetViewData()->GetZoomY();
326 USHORT nCurrentZoom
= (USHORT
)(( rOldY
.GetNumerator() * 100 ) / rOldY
.GetDenominator());
330 SvxZoomSliderItem
aZoomSliderItem( nCurrentZoom
, MINZOOM
, MAXZOOM
, SID_ATTR_ZOOMSLIDER
);
331 aZoomSliderItem
.AddSnappingPoint( 100 );
332 rSet
.Put( aZoomSliderItem
);
338 case FID_TOGGLESYNTAX
:
339 rSet
.Put(SfxBoolItem(nWhich
, GetViewData()->IsSyntaxMode()));
342 case FID_TOGGLEHEADERS
:
343 rSet
.Put(SfxBoolItem(nWhich
, GetViewData()->IsHeaderMode()));
346 case FID_TOGGLEFORMULA
:
348 const ScViewOptions
& rOpts
= pViewData
->GetOptions();
349 BOOL bFormulaMode
= rOpts
.GetOption( VOPT_FORMULAS
);
350 rSet
.Put(SfxBoolItem(nWhich
, bFormulaMode
));
354 case FID_NORMALVIEWMODE
:
355 case FID_PAGEBREAKMODE
:
356 // always handle both slots - they exclude each other
359 rSet
.DisableItem( FID_NORMALVIEWMODE
);
360 rSet
.DisableItem( FID_PAGEBREAKMODE
);
364 rSet
.Put(SfxBoolItem(FID_NORMALVIEWMODE
, !GetViewData()->IsPagebreakMode()));
365 rSet
.Put(SfxBoolItem(FID_PAGEBREAKMODE
, GetViewData()->IsPagebreakMode()));
369 case FID_FUNCTION_BOX
:
370 nMyId
= ScFunctionChildWindow::GetChildWindowId();
371 rSet
.Put(SfxBoolItem(FID_FUNCTION_BOX
, pThisFrame
->HasChildWindow(nMyId
)));
374 case FID_PROTECT_DOC
:
376 if ( pDocShell
&& pDocShell
->IsDocShared() )
378 rSet
.DisableItem( nWhich
);
382 rSet
.Put( SfxBoolItem( nWhich
, pDoc
->IsDocProtected() ) );
387 case FID_PROTECT_TABLE
:
389 if ( pDocShell
&& pDocShell
->IsDocShared() )
391 rSet
.DisableItem( nWhich
);
395 rSet
.Put( SfxBoolItem( nWhich
, pDoc
->IsTabProtected( nTab
) ) );
400 case SID_AUTO_OUTLINE
:
402 if (pDoc
->GetChangeTrack()!=NULL
|| GetViewData()->IsMultiMarked())
404 rSet
.DisableItem( nWhich
);
409 case SID_OUTLINE_DELETEALL
:
411 SCTAB nOlTab
= GetViewData()->GetTabNo();
412 ScOutlineTable
* pOlTable
= pDoc
->GetOutlineTable( nOlTab
);
413 if (pOlTable
== NULL
)
414 rSet
.DisableItem( nWhich
);
418 case SID_WINDOW_SPLIT
:
419 rSet
.Put(SfxBoolItem(nWhich
,
420 pViewData
->GetHSplitMode() == SC_SPLIT_NORMAL
||
421 pViewData
->GetVSplitMode() == SC_SPLIT_NORMAL
));
425 rSet
.Put(SfxBoolItem(nWhich
,
426 pViewData
->GetHSplitMode() == SC_SPLIT_FIX
||
427 pViewData
->GetVSplitMode() == SC_SPLIT_FIX
));
432 if ( pDoc
->GetChangeTrack() == NULL
|| ( pDocShell
&& pDocShell
->IsDocShared() ) )
433 rSet
.DisableItem( nWhich
);
438 rSet
.Put(SfxBoolItem(FID_CHG_ACCEPT
,
439 pThisFrame
->HasChildWindow(FID_CHG_ACCEPT
)));
440 if(pDoc
->GetChangeTrack()==NULL
)
442 if ( !pThisFrame
->HasChildWindow(FID_CHG_ACCEPT
) )
444 rSet
.DisableItem( nWhich
);
447 if ( pDocShell
&& pDocShell
->IsDocShared() )
449 rSet
.DisableItem( nWhich
);
455 //! bei geschuetzten Tabellen ???
456 if ( pDocShell
&& ( pDocShell
->IsReadOnly() || pDocShell
->IsDocShared() ) )
457 rSet
.DisableItem( nWhich
);
460 case SID_PRINTPREVIEW
:
461 // #58924# Toggle-Slot braucht einen State
462 rSet
.Put( SfxBoolItem( nWhich
, FALSE
) );
465 case SID_READONLY_MODE
:
466 rSet
.Put( SfxBoolItem( nWhich
, GetViewData()->GetDocShell()->IsReadOnly() ) );
469 } // switch ( nWitch )
470 nWhich
= aIter
.NextWhich();
471 } // while ( nWitch )
474 //------------------------------------------------------------------
475 void ScTabViewShell::ExecuteCellFormatDlg( SfxRequest
& rReq
, USHORT nTabPage
)
477 //CHINA001 ScAttrDlg* pDlg = NULL;
478 SfxAbstractTabDialog
* pDlg
= NULL
; //CHINA001
479 ScDocument
* pDoc
= GetViewData()->GetDocument();
481 SvxBoxItem
aLineOuter( ATTR_BORDER
);
482 SvxBoxInfoItem
aLineInner( ATTR_BORDER_INNER
);
484 SvxNumberInfoItem
* pNumberInfoItem
= NULL
;
485 const ScPatternAttr
* pOldAttrs
= GetSelectionPattern();
486 SfxItemSet
* pOldSet
= new SfxItemSet(
487 pOldAttrs
->GetItemSet() );
490 // Umrandungs-Items holen und in den Set packen:
491 GetSelectionFrame( aLineOuter
, aLineInner
);
492 pOldSet
->Put( aLineOuter
);
493 pOldSet
->Put( aLineInner
);
495 // NumberFormat Value aus Value und Language erzeugen und eintueten
496 pOldSet
->Put( SfxUInt32Item( ATTR_VALUE_FORMAT
,
497 pOldAttrs
->GetNumberFormat( pDoc
->GetFormatTable() ) ) );
499 MakeNumberInfoItem( pDoc
, GetViewData(), &pNumberInfoItem
);
501 pOldSet
->MergeRange( SID_ATTR_NUMBERFORMAT_INFO
, SID_ATTR_NUMBERFORMAT_INFO
);
502 pOldSet
->Put(*pNumberInfoItem
);
504 bInFormatDialog
= TRUE
;
505 //CHINA001 pDlg = new ScAttrDlg( GetViewFrame(), GetDialogParent(), pOldSet );
506 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
507 DBG_ASSERT(pFact
, "ScAbstractFactory create fail!");//CHINA001
509 pDlg
= pFact
->CreateScAttrDlg( GetViewFrame(), GetDialogParent(), pOldSet
, RID_SCDLG_ATTR
);
510 DBG_ASSERT(pDlg
, "Dialog create fail!");//CHINA001
511 if ( nTabPage
!= 0xffff )
512 pDlg
->SetCurPageId( nTabPage
);
513 short nResult
= pDlg
->Execute();
514 bInFormatDialog
= FALSE
;
516 if ( nResult
== RET_OK
)
518 const SfxItemSet
* pOutSet
= pDlg
->GetOutputItemSet();
520 const SfxPoolItem
* pItem
=NULL
;
521 if(pOutSet
->GetItemState(SID_ATTR_NUMBERFORMAT_INFO
,TRUE
,&pItem
)==SFX_ITEM_SET
)
524 UpdateNumberFormatter( pDoc
,(const SvxNumberInfoItem
&)*pItem
);
527 ApplyAttributes( pOutSet
, pOldSet
);
529 rReq
.Done( *pOutSet
);
532 delete pNumberInfoItem
;
536 //------------------------------------------------------------------
538 bool ScTabViewShell::IsRefInputMode() const
540 ScModule
* pScMod
= SC_MOD();
543 if( pScMod
->IsRefDialogOpen() )
544 return pScMod
->IsFormulaMode();
545 if( pScMod
->IsFormulaMode() )
547 ScInputHandler
* pHdl
= pScMod
->GetInputHdl();
550 String aString
= pHdl
->GetEditString();
551 if ( !pHdl
->GetSelIsRef() && aString
.Len() > 1 &&
552 ( aString
.GetChar(0) == '+' || aString
.GetChar(0) == '-' ) )
554 const ScViewData
* pViewData
= GetViewData();
557 ScDocument
* pDoc
= pViewData
->GetDocument();
560 const ScAddress
aPos( pViewData
->GetCurPos() );
561 ScCompiler
aComp( pDoc
, aPos
);
562 aComp
.SetGrammar(pDoc
->GetGrammar());
563 aComp
.SetCloseBrackets( false );
564 ScTokenArray
* pArr
= aComp
.CompileString( aString
);
565 if ( pArr
&& pArr
->MayReferenceFollow() )
583 //------------------------------------------------------------------
585 void ScTabViewShell::ExecuteInputDirect()
587 if ( !IsRefInputMode() )
589 ScModule
* pScMod
= SC_MOD();
592 pScMod
->InputEnterHandler();
597 //------------------------------------------------------------------
599 void ScTabViewShell::UpdateInputHandler( BOOL bForce
/* = FALSE */, BOOL bStopEditing
/* = TRUE */ )
601 ScInputHandler
* pHdl
= pInputHandler
? pInputHandler
: SC_MOD()->GetInputHdl();
606 const EditTextObject
* pObject
= NULL
;
607 ScViewData
* pViewData
= GetViewData();
608 ScDocument
* pDoc
= pViewData
->GetDocument();
610 SCCOL nPosX
= pViewData
->GetCurX();
611 SCROW nPosY
= pViewData
->GetCurY();
612 SCTAB nTab
= pViewData
->GetTabNo();
620 pViewData
->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
= (const ScProtectionAttr
*)
633 pDoc
->GetAttr( nPosX
,nPosY
,nTab
,
635 bHideFormula
= pProt
->GetHideFormula();
636 bHideAll
= pProt
->GetHideCell();
641 pDoc
->GetCellType( nPosX
, nPosY
, nTab
, eType
);
642 if (eType
== CELLTYPE_FORMULA
)
645 pDoc
->GetFormula( nPosX
, nPosY
, nTab
, aString
);
647 else if (eType
== CELLTYPE_EDIT
)
650 pDoc
->GetCell( nPosX
, nPosY
, nTab
, pCell
);
651 ((ScEditCell
*)pCell
)->GetData( pObject
);
655 pDoc
->GetInputString( nPosX
, nPosY
, nTab
, aString
);
656 if (eType
== CELLTYPE_STRING
)
658 // Bei Bedarf ein ' vorneweg, damit der String nicht ungewollt
659 // als Zahl interpretiert wird, und um dem Benutzer zu zeigen,
660 // dass es ein String ist (#35060#).
661 //! Auch bei Zahlformat "Text"? -> dann beim Editieren wegnehmen
663 SvNumberFormatter
* pFormatter
= pDoc
->GetFormatTable();
665 pDoc
->GetNumberFormat( nPosX
, nPosY
, nTab
, nNumFmt
);
667 if ( pFormatter
->IsNumberFormat(aString
, nNumFmt
, fDummy
) )
668 aString
.Insert('\'',0);
673 ScInputHdlState
aState( ScAddress( nPosX
, nPosY
, nTab
),
674 ScAddress( nStartCol
, nStartRow
, nTab
),
675 ScAddress( nEndCol
, nEndRow
, nTab
),
679 // if using the view's local input handler, this view can always be set
680 // as current view inside NotifyChange.
681 ScTabViewShell
* pSourceSh
= pInputHandler
? this : NULL
;
683 pHdl
->NotifyChange( &aState
, bForce
, pSourceSh
, bStopEditing
);
686 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
687 rBindings
.Invalidate( SID_STATUS_SUM
); // immer zusammen mit Eingabezeile
688 rBindings
.Invalidate( SID_ATTR_SIZE
);
689 rBindings
.Invalidate( SID_TABLE_CELL
);
692 //------------------------------------------------------------------
694 void __EXPORT
ScTabViewShell::ExecuteSave( SfxRequest
& rReq
)
696 // nur SID_SAVEDOC / SID_SAVEASDOC
698 // Eingabe auf jeden Fall abschliessen, auch wenn eine Formel bearbeitet wird
699 SC_MOD()->InputEnterHandler();
701 if ( GetViewData()->GetDocShell()->IsDocShared() )
703 GetViewData()->GetDocShell()->SetDocumentModified();
706 // ansonsten normal weiter
707 GetViewData()->GetDocShell()->ExecuteSlot( rReq
);
710 void __EXPORT
ScTabViewShell::GetSaveState( SfxItemSet
& rSet
)
712 SfxShell
* pDocSh
= GetViewData()->GetDocShell();
714 SfxWhichIter
aIter(rSet
);
715 USHORT nWhich
= aIter
.FirstWhich();
718 if ( nWhich
!= SID_SAVEDOC
|| !GetViewData()->GetDocShell()->IsDocShared() )
720 // get state from DocShell
721 pDocSh
->GetSlotState( nWhich
, NULL
, &rSet
);
723 nWhich
= aIter
.NextWhich();
727 //------------------------------------------------------------------
729 void ScTabViewShell::ExecuteUndo(SfxRequest
& rReq
)
731 SfxShell
* pSh
= GetViewData()->GetDispatcher().GetShell(0);
732 SfxUndoManager
* pUndoManager
= pSh
->GetUndoManager();
734 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
735 ScDocShell
* pDocSh
= GetViewData()->GetDocShell();
737 USHORT nSlot
= rReq
.GetSlot();
744 BOOL bIsUndo
= ( nSlot
== SID_UNDO
);
747 const SfxPoolItem
* pItem
;
748 if ( pReqArgs
&& pReqArgs
->GetItemState( nSlot
, TRUE
, &pItem
) == SFX_ITEM_SET
)
749 nCount
= ((const SfxUInt16Item
*)pItem
)->GetValue();
751 // lock paint for more than one cell undo action (not for editing within a cell)
752 BOOL bLockPaint
= ( nCount
> 1 && pUndoManager
== GetUndoManager() );
756 for (USHORT i
=0; i
<nCount
; i
++)
759 pUndoManager
->Undo(0);
761 pUndoManager
->Redo(0);
765 pDocSh
->UnlockPaint();
767 GetViewFrame()->GetBindings().InvalidateAll(sal_False
);
771 // GetViewFrame()->ExecuteSlot( rReq );
775 void ScTabViewShell::GetUndoState(SfxItemSet
&rSet
)
777 SfxShell
* pSh
= GetViewData()->GetDispatcher().GetShell(0);
778 SfxUndoManager
* pUndoManager
= pSh
->GetUndoManager();
780 SfxWhichIter
aIter(rSet
);
781 USHORT nWhich
= aIter
.FirstWhich();
786 case SID_GETUNDOSTRINGS
:
787 case SID_GETREDOSTRINGS
:
789 SfxStringListItem
aStrLst( nWhich
);
792 List
* pList
= aStrLst
.GetList();
793 BOOL bIsUndo
= ( nWhich
== SID_GETUNDOSTRINGS
);
794 USHORT nCount
= bIsUndo
? pUndoManager
->GetUndoActionCount() : pUndoManager
->GetRedoActionCount();
795 for (USHORT i
=0; i
<nCount
; i
++)
796 pList
->Insert( new String( bIsUndo
? pUndoManager
->GetUndoActionComment(i
) :
797 pUndoManager
->GetRedoActionComment(i
) ),
804 // get state from sfx view frame
805 GetViewFrame()->GetSlotState( nWhich
, NULL
, &rSet
);
808 nWhich
= aIter
.NextWhich();
813 //------------------------------------------------------------------
815 void ScTabViewShell::ExecDrawOpt( SfxRequest
& rReq
)
817 ScViewOptions aViewOptions
= GetViewData()->GetOptions();
818 ScGridOptions aGridOptions
= aViewOptions
.GetGridOptions();
820 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
821 const SfxItemSet
* pArgs
= rReq
.GetArgs();
822 const SfxPoolItem
* pItem
;
823 USHORT nSlotId
= rReq
.GetSlot();
826 case SID_GRID_VISIBLE
:
827 if ( pArgs
&& pArgs
->GetItemState(nSlotId
,TRUE
,&pItem
) == SFX_ITEM_SET
)
829 aGridOptions
.SetGridVisible( ((const SfxBoolItem
*)pItem
)->GetValue() );
830 aViewOptions
.SetGridOptions(aGridOptions
);
831 rBindings
.Invalidate(SID_GRID_VISIBLE
);
836 if ( pArgs
&& pArgs
->GetItemState(nSlotId
,TRUE
,&pItem
) == SFX_ITEM_SET
)
838 aGridOptions
.SetUseGridSnap( ((const SfxBoolItem
*)pItem
)->GetValue() );
839 aViewOptions
.SetGridOptions(aGridOptions
);
840 rBindings
.Invalidate(SID_GRID_USE
);
844 case SID_HELPLINES_MOVE
:
845 if ( pArgs
&& pArgs
->GetItemState(nSlotId
,TRUE
,&pItem
) == SFX_ITEM_SET
)
847 aViewOptions
.SetOption( VOPT_HELPLINES
, ((const SfxBoolItem
*)pItem
)->GetValue() );
848 rBindings
.Invalidate(SID_HELPLINES_MOVE
);
853 GetViewData()->SetOptions(aViewOptions
);
856 void ScTabViewShell::GetDrawOptState( SfxItemSet
& rSet
)
860 const ScViewOptions
& rViewOptions
= GetViewData()->GetOptions();
861 const ScGridOptions
& rGridOptions
= rViewOptions
.GetGridOptions();
863 aBool
.SetValue(rGridOptions
.GetGridVisible());
864 aBool
.SetWhich( SID_GRID_VISIBLE
);
867 aBool
.SetValue(rGridOptions
.GetUseGridSnap());
868 aBool
.SetWhich( SID_GRID_USE
);
871 aBool
.SetValue(rViewOptions
.GetOption( VOPT_HELPLINES
));
872 aBool
.SetWhich( SID_HELPLINES_MOVE
);