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();
80 ScViewData
* pViewData
= GetViewData();
81 ScMarkData
& rMark
= pViewData
->GetMarkData();
82 bool bIgnoreError
= (rMark
.IsMarked() || rMark
.IsMultiMarked());
84 if (bIgnoreError
&& (eFunc
== SUBTOTAL_FUNC_CNT
|| eFunc
== SUBTOTAL_FUNC_CNT2
))
89 rFuncStr
= ScGlobal::GetLongErrorString(nErrCode
);
93 USHORT nGlobStrId
= 0;
96 case SUBTOTAL_FUNC_AVE
: nGlobStrId
= STR_FUN_TEXT_AVG
; break;
97 case SUBTOTAL_FUNC_CNT
: nGlobStrId
= STR_FUN_TEXT_COUNT
; break;
98 case SUBTOTAL_FUNC_CNT2
: nGlobStrId
= STR_FUN_TEXT_COUNT2
; break;
99 case SUBTOTAL_FUNC_MAX
: nGlobStrId
= STR_FUN_TEXT_MAX
; break;
100 case SUBTOTAL_FUNC_MIN
: nGlobStrId
= STR_FUN_TEXT_MIN
; break;
101 case SUBTOTAL_FUNC_SUM
: nGlobStrId
= STR_FUN_TEXT_SUM
; break;
104 // added to avoid warnings
109 ScDocument
* pDoc
= pViewData
->GetDocument();
110 SCCOL nPosX
= pViewData
->GetCurX();
111 SCROW nPosY
= pViewData
->GetCurY();
112 SCTAB nTab
= pViewData
->GetTabNo();
114 aStr
= ScGlobal::GetRscString(nGlobStrId
);
117 ScAddress
aCursor( nPosX
, nPosY
, nTab
);
119 if ( pDoc
->GetSelectionFunction( eFunc
, aCursor
, rMark
, nVal
) )
125 // Anzahl im Standardformat, die anderen nach Cursorposition
126 SvNumberFormatter
* pFormatter
= pDoc
->GetFormatTable();
127 sal_uInt32 nNumFmt
= 0;
128 if ( eFunc
!= SUBTOTAL_FUNC_CNT
&& eFunc
!= SUBTOTAL_FUNC_CNT2
)
130 // Zahlformat aus Attributen oder Formel
131 pDoc
->GetNumberFormat( nPosX
, nPosY
, nTab
, nNumFmt
);
132 if ( (nNumFmt
% SV_COUNTRY_LANGUAGE_OFFSET
) == 0 )
135 pDoc
->GetCell( nPosX
, nPosY
, nTab
, pCell
);
136 if (pCell
&& pCell
->GetCellType() == CELLTYPE_FORMULA
)
139 nNumFmt
= ((ScFormulaCell
*)pCell
)->GetStandardFormat(*pFormatter
, nNumFmt
);
146 pFormatter
->GetOutputString( nVal
, nNumFmt
, aValStr
, &pDummy
);
160 // Funktionen, die je nach Selektion disabled sind
163 // SID_DELETE_CONTENTS,
168 void __EXPORT
ScTabViewShell::GetState( SfxItemSet
& rSet
)
170 ScViewData
* pViewData
= GetViewData();
171 ScDocument
* pDoc
= pViewData
->GetDocument();
172 ScDocShell
* pDocShell
= pViewData
->GetDocShell();
173 ScMarkData
& rMark
= pViewData
->GetMarkData();
174 SCCOL nPosX
= pViewData
->GetCurX();
175 SCROW nPosY
= pViewData
->GetCurY();
176 SCTAB nTab
= pViewData
->GetTabNo();
179 SfxViewFrame
* pThisFrame
= GetViewFrame();
180 BOOL bOle
= GetViewFrame()->GetFrame()->IsInPlace();
182 SCTAB nTabCount
= pDoc
->GetTableCount();
183 SCTAB nTabSelCount
= rMark
.GetSelectCount();
185 SfxWhichIter
aIter(rSet
);
186 USHORT nWhich
= aIter
.FirstWhich();
192 case FID_CHG_COMMENT
:
194 ScDocShell
* pDocSh
= GetViewData()->GetDocShell();
195 ScAddress
aPos( nPosX
, nPosY
, nTab
);
196 if ( pDocSh
->IsReadOnly() || !pDocSh
->GetChangeAction(aPos
) || pDocSh
->IsDocShared() )
197 rSet
.DisableItem( nWhich
);
201 case SID_OPENDLG_EDIT_PRINTAREA
:
202 case SID_ADD_PRINTAREA
:
203 case SID_DEFINE_PRINTAREA
:
205 if ( pDocShell
&& pDocShell
->IsDocShared() )
207 rSet
.DisableItem( nWhich
);
212 case SID_DELETE_PRINTAREA
:
213 if ( nTabSelCount
> 1 )
215 // #i22589# also take "Print Entire Sheet" into account here
217 for (SCTAB i
=0; !bHas
&& i
<nTabCount
; i
++)
218 bHas
= rMark
.GetTableSelect(i
) && (pDoc
->GetPrintRangeCount(i
) || pDoc
->IsPrintEntireSheet(i
));
220 rSet
.DisableItem( nWhich
);
222 else if ( !pDoc
->GetPrintRangeCount( nTab
) && !pDoc
->IsPrintEntireSheet( nTab
) )
223 rSet
.DisableItem( nWhich
);
224 if ( pDocShell
&& pDocShell
->IsDocShared() )
226 rSet
.DisableItem( nWhich
);
230 case SID_STATUS_PAGESTYLE
:
232 GetViewData()->GetDocShell()->GetStatePageStyle( *this, rSet
, nTab
);
235 case SID_SEARCH_ITEM
:
237 SvxSearchItem
aItem(ScGlobal::GetSearchItem()); // make a copy.
238 // Search on current selection if a range is marked.
239 aItem
.SetSelection(rMark
.IsMarked());
244 case SID_SEARCH_OPTIONS
:
246 USHORT nOptions
= 0xffff; // alles erlaubt
247 // wenn ReadOnly, kein Ersetzen:
248 if (GetViewData()->GetDocShell()->IsReadOnly())
249 nOptions
&= ~( SEARCH_OPTIONS_REPLACE
| SEARCH_OPTIONS_REPLACE_ALL
);
250 rSet
.Put( SfxUInt16Item( nWhich
, nOptions
) );
254 case SID_CURRENTCELL
:
256 ScAddress
aScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), 0 );
258 aScAddress
.Format( aAddr
, SCA_ABS
, NULL
, pDoc
->GetAddressConvention() );
259 SfxStringItem
aPosItem( SID_CURRENTCELL
, aAddr
);
261 rSet
.Put( aPosItem
);
266 // Tabelle fuer Basic ist 1-basiert
267 rSet
.Put( SfxUInt16Item( nWhich
, static_cast<sal_uInt16
>(GetViewData()->GetTabNo()) + 1 ) );
271 rSet
.Put( SfxStringItem( nWhich
, GetViewData()->GetDocShell()->GetTitle() ) );
274 case FID_TOGGLEINPUTLINE
:
276 USHORT nId
= ScInputWindowWrapper::GetChildWindowId();
278 if ( pThisFrame
->KnowsChildWindow( nId
) )
280 SfxChildWindow
* pWnd
= pThisFrame
->GetChildWindow( nId
);
281 rSet
.Put( SfxBoolItem( nWhich
, pWnd
? TRUE
: FALSE
) );
284 rSet
.DisableItem( nWhich
);
288 case FID_DEL_MANUALBREAKS
:
289 if (!pDoc
->HasManualBreaks(nTab
))
290 rSet
.DisableItem( nWhich
);
293 case FID_RESET_PRINTZOOM
:
295 // disablen, wenn schon Default eingestellt
297 String aStyleName
= pDoc
->GetPageStyle( nTab
);
298 ScStyleSheetPool
* pStylePool
= pDoc
->GetStyleSheetPool();
299 SfxStyleSheetBase
* pStyleSheet
= pStylePool
->Find( aStyleName
,
300 SFX_STYLE_FAMILY_PAGE
);
301 DBG_ASSERT( pStyleSheet
, "PageStyle not found" );
304 SfxItemSet
& rStyleSet
= pStyleSheet
->GetItemSet();
305 USHORT nScale
= ((const SfxUInt16Item
&)
306 rStyleSet
.Get(ATTR_PAGE_SCALE
)).GetValue();
307 USHORT nPages
= ((const SfxUInt16Item
&)
308 rStyleSet
.Get(ATTR_PAGE_SCALETOPAGES
)).GetValue();
309 if ( nScale
== 100 && nPages
== 0 )
310 rSet
.DisableItem( nWhich
);
318 rSet
.DisableItem( nWhich
);
321 const Fraction
& rOldY
= GetViewData()->GetZoomY();
322 USHORT nZoom
= (USHORT
)(( rOldY
.GetNumerator() * 100 )
323 / rOldY
.GetDenominator());
324 rSet
.Put( SvxZoomItem( SVX_ZOOM_PERCENT
, nZoom
, nWhich
) );
328 case SID_ATTR_ZOOMSLIDER
:
331 rSet
.DisableItem( nWhich
);
334 const Fraction
& rOldY
= GetViewData()->GetZoomY();
335 USHORT nCurrentZoom
= (USHORT
)(( rOldY
.GetNumerator() * 100 ) / rOldY
.GetDenominator());
339 SvxZoomSliderItem
aZoomSliderItem( nCurrentZoom
, MINZOOM
, MAXZOOM
, SID_ATTR_ZOOMSLIDER
);
340 aZoomSliderItem
.AddSnappingPoint( 100 );
341 rSet
.Put( aZoomSliderItem
);
347 case FID_TOGGLESYNTAX
:
348 rSet
.Put(SfxBoolItem(nWhich
, GetViewData()->IsSyntaxMode()));
351 case FID_TOGGLEHEADERS
:
352 rSet
.Put(SfxBoolItem(nWhich
, GetViewData()->IsHeaderMode()));
355 case FID_TOGGLEFORMULA
:
357 const ScViewOptions
& rOpts
= pViewData
->GetOptions();
358 BOOL bFormulaMode
= rOpts
.GetOption( VOPT_FORMULAS
);
359 rSet
.Put(SfxBoolItem(nWhich
, bFormulaMode
));
363 case FID_NORMALVIEWMODE
:
364 case FID_PAGEBREAKMODE
:
365 // always handle both slots - they exclude each other
368 rSet
.DisableItem( FID_NORMALVIEWMODE
);
369 rSet
.DisableItem( FID_PAGEBREAKMODE
);
373 rSet
.Put(SfxBoolItem(FID_NORMALVIEWMODE
, !GetViewData()->IsPagebreakMode()));
374 rSet
.Put(SfxBoolItem(FID_PAGEBREAKMODE
, GetViewData()->IsPagebreakMode()));
378 case FID_FUNCTION_BOX
:
379 nMyId
= ScFunctionChildWindow::GetChildWindowId();
380 rSet
.Put(SfxBoolItem(FID_FUNCTION_BOX
, pThisFrame
->HasChildWindow(nMyId
)));
383 case FID_PROTECT_DOC
:
385 if ( pDocShell
&& pDocShell
->IsDocShared() )
387 rSet
.DisableItem( nWhich
);
391 rSet
.Put( SfxBoolItem( nWhich
, pDoc
->IsDocProtected() ) );
396 case FID_PROTECT_TABLE
:
398 if ( pDocShell
&& pDocShell
->IsDocShared() )
400 rSet
.DisableItem( nWhich
);
404 rSet
.Put( SfxBoolItem( nWhich
, pDoc
->IsTabProtected( nTab
) ) );
409 case SID_AUTO_OUTLINE
:
411 if (pDoc
->GetChangeTrack()!=NULL
|| GetViewData()->IsMultiMarked())
413 rSet
.DisableItem( nWhich
);
418 case SID_OUTLINE_DELETEALL
:
420 SCTAB nOlTab
= GetViewData()->GetTabNo();
421 ScOutlineTable
* pOlTable
= pDoc
->GetOutlineTable( nOlTab
);
422 if (pOlTable
== NULL
)
423 rSet
.DisableItem( nWhich
);
427 case SID_WINDOW_SPLIT
:
428 rSet
.Put(SfxBoolItem(nWhich
,
429 pViewData
->GetHSplitMode() == SC_SPLIT_NORMAL
||
430 pViewData
->GetVSplitMode() == SC_SPLIT_NORMAL
));
434 rSet
.Put(SfxBoolItem(nWhich
,
435 pViewData
->GetHSplitMode() == SC_SPLIT_FIX
||
436 pViewData
->GetVSplitMode() == SC_SPLIT_FIX
));
441 if ( pDoc
->GetChangeTrack() == NULL
|| ( pDocShell
&& pDocShell
->IsDocShared() ) )
442 rSet
.DisableItem( nWhich
);
447 rSet
.Put(SfxBoolItem(FID_CHG_ACCEPT
,
448 pThisFrame
->HasChildWindow(FID_CHG_ACCEPT
)));
449 if(pDoc
->GetChangeTrack()==NULL
)
451 if ( !pThisFrame
->HasChildWindow(FID_CHG_ACCEPT
) )
453 rSet
.DisableItem( nWhich
);
456 if ( pDocShell
&& pDocShell
->IsDocShared() )
458 rSet
.DisableItem( nWhich
);
464 //! bei geschuetzten Tabellen ???
465 if ( pDocShell
&& ( pDocShell
->IsReadOnly() || pDocShell
->IsDocShared() ) )
466 rSet
.DisableItem( nWhich
);
469 case SID_PRINTPREVIEW
:
470 // #58924# Toggle-Slot braucht einen State
471 rSet
.Put( SfxBoolItem( nWhich
, FALSE
) );
474 case SID_READONLY_MODE
:
475 rSet
.Put( SfxBoolItem( nWhich
, GetViewData()->GetDocShell()->IsReadOnly() ) );
478 case FID_TAB_DESELECTALL
:
479 if ( nTabSelCount
== 1 )
480 rSet
.DisableItem( nWhich
); // enabled only if several sheets are selected
483 } // switch ( nWitch )
484 nWhich
= aIter
.NextWhich();
485 } // while ( nWitch )
488 //------------------------------------------------------------------
489 void ScTabViewShell::ExecuteCellFormatDlg( SfxRequest
& rReq
, USHORT nTabPage
)
491 //CHINA001 ScAttrDlg* pDlg = NULL;
492 SfxAbstractTabDialog
* pDlg
= NULL
; //CHINA001
493 ScDocument
* pDoc
= GetViewData()->GetDocument();
495 SvxBoxItem
aLineOuter( ATTR_BORDER
);
496 SvxBoxInfoItem
aLineInner( ATTR_BORDER_INNER
);
498 SvxNumberInfoItem
* pNumberInfoItem
= NULL
;
499 const ScPatternAttr
* pOldAttrs
= GetSelectionPattern();
500 SfxItemSet
* pOldSet
= new SfxItemSet(
501 pOldAttrs
->GetItemSet() );
504 // Umrandungs-Items holen und in den Set packen:
505 GetSelectionFrame( aLineOuter
, aLineInner
);
506 pOldSet
->Put( aLineOuter
);
507 pOldSet
->Put( aLineInner
);
509 // NumberFormat Value aus Value und Language erzeugen und eintueten
510 pOldSet
->Put( SfxUInt32Item( ATTR_VALUE_FORMAT
,
511 pOldAttrs
->GetNumberFormat( pDoc
->GetFormatTable() ) ) );
513 MakeNumberInfoItem( pDoc
, GetViewData(), &pNumberInfoItem
);
515 pOldSet
->MergeRange( SID_ATTR_NUMBERFORMAT_INFO
, SID_ATTR_NUMBERFORMAT_INFO
);
516 pOldSet
->Put(*pNumberInfoItem
);
518 bInFormatDialog
= TRUE
;
519 //CHINA001 pDlg = new ScAttrDlg( GetViewFrame(), GetDialogParent(), pOldSet );
520 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
521 DBG_ASSERT(pFact
, "ScAbstractFactory create fail!");//CHINA001
523 pDlg
= pFact
->CreateScAttrDlg( GetViewFrame(), GetDialogParent(), pOldSet
, RID_SCDLG_ATTR
);
524 DBG_ASSERT(pDlg
, "Dialog create fail!");//CHINA001
525 if ( nTabPage
!= 0xffff )
526 pDlg
->SetCurPageId( nTabPage
);
527 short nResult
= pDlg
->Execute();
528 bInFormatDialog
= FALSE
;
530 if ( nResult
== RET_OK
)
532 const SfxItemSet
* pOutSet
= pDlg
->GetOutputItemSet();
534 const SfxPoolItem
* pItem
=NULL
;
535 if(pOutSet
->GetItemState(SID_ATTR_NUMBERFORMAT_INFO
,TRUE
,&pItem
)==SFX_ITEM_SET
)
538 UpdateNumberFormatter( pDoc
,(const SvxNumberInfoItem
&)*pItem
);
541 ApplyAttributes( pOutSet
, pOldSet
);
543 rReq
.Done( *pOutSet
);
546 delete pNumberInfoItem
;
550 //------------------------------------------------------------------
552 bool ScTabViewShell::IsRefInputMode() const
554 ScModule
* pScMod
= SC_MOD();
557 if( pScMod
->IsRefDialogOpen() )
558 return pScMod
->IsFormulaMode();
559 if( pScMod
->IsFormulaMode() )
561 ScInputHandler
* pHdl
= pScMod
->GetInputHdl();
564 String aString
= pHdl
->GetEditString();
565 if ( !pHdl
->GetSelIsRef() && aString
.Len() > 1 &&
566 ( aString
.GetChar(0) == '+' || aString
.GetChar(0) == '-' ) )
568 const ScViewData
* pViewData
= GetViewData();
571 ScDocument
* pDoc
= pViewData
->GetDocument();
574 const ScAddress
aPos( pViewData
->GetCurPos() );
575 ScCompiler
aComp( pDoc
, aPos
);
576 aComp
.SetGrammar(pDoc
->GetGrammar());
577 aComp
.SetCloseBrackets( false );
578 ScTokenArray
* pArr
= aComp
.CompileString( aString
);
579 if ( pArr
&& pArr
->MayReferenceFollow() )
597 //------------------------------------------------------------------
599 void ScTabViewShell::ExecuteInputDirect()
601 if ( !IsRefInputMode() )
603 ScModule
* pScMod
= SC_MOD();
606 pScMod
->InputEnterHandler();
611 //------------------------------------------------------------------
613 void ScTabViewShell::UpdateInputHandler( BOOL bForce
/* = FALSE */, BOOL bStopEditing
/* = TRUE */ )
615 ScInputHandler
* pHdl
= pInputHandler
? pInputHandler
: SC_MOD()->GetInputHdl();
620 const EditTextObject
* pObject
= NULL
;
621 ScViewData
* pViewData
= GetViewData();
622 ScDocument
* pDoc
= pViewData
->GetDocument();
624 SCCOL nPosX
= pViewData
->GetCurX();
625 SCROW nPosY
= pViewData
->GetCurY();
626 SCTAB nTab
= pViewData
->GetTabNo();
634 pViewData
->GetSimpleArea( nStartCol
, nStartRow
, nStartTab
,
635 nEndCol
, nEndRow
, nEndTab
);
637 PutInOrder( nStartCol
, nEndCol
);
638 PutInOrder( nStartRow
, nEndRow
);
639 PutInOrder( nStartTab
, nEndTab
);
641 BOOL bHideFormula
= FALSE
;
642 BOOL bHideAll
= FALSE
;
644 if (pDoc
->IsTabProtected(nTab
))
646 const ScProtectionAttr
* pProt
= (const ScProtectionAttr
*)
647 pDoc
->GetAttr( nPosX
,nPosY
,nTab
,
649 bHideFormula
= pProt
->GetHideFormula();
650 bHideAll
= pProt
->GetHideCell();
655 pDoc
->GetCellType( nPosX
, nPosY
, nTab
, eType
);
656 if (eType
== CELLTYPE_FORMULA
)
659 pDoc
->GetFormula( nPosX
, nPosY
, nTab
, aString
);
661 else if (eType
== CELLTYPE_EDIT
)
664 pDoc
->GetCell( nPosX
, nPosY
, nTab
, pCell
);
665 ((ScEditCell
*)pCell
)->GetData( pObject
);
669 pDoc
->GetInputString( nPosX
, nPosY
, nTab
, aString
);
670 if (eType
== CELLTYPE_STRING
)
672 // Bei Bedarf ein ' vorneweg, damit der String nicht ungewollt
673 // als Zahl interpretiert wird, und um dem Benutzer zu zeigen,
674 // dass es ein String ist (#35060#).
675 //! Auch bei Zahlformat "Text"? -> dann beim Editieren wegnehmen
677 SvNumberFormatter
* pFormatter
= pDoc
->GetFormatTable();
679 pDoc
->GetNumberFormat( nPosX
, nPosY
, nTab
, nNumFmt
);
681 if ( pFormatter
->IsNumberFormat(aString
, nNumFmt
, fDummy
) )
682 aString
.Insert('\'',0);
687 ScInputHdlState
aState( ScAddress( nPosX
, nPosY
, nTab
),
688 ScAddress( nStartCol
, nStartRow
, nTab
),
689 ScAddress( nEndCol
, nEndRow
, nTab
),
693 // if using the view's local input handler, this view can always be set
694 // as current view inside NotifyChange.
695 ScTabViewShell
* pSourceSh
= pInputHandler
? this : NULL
;
697 pHdl
->NotifyChange( &aState
, bForce
, pSourceSh
, bStopEditing
);
700 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
701 rBindings
.Invalidate( SID_STATUS_SUM
); // immer zusammen mit Eingabezeile
702 rBindings
.Invalidate( SID_ATTR_SIZE
);
703 rBindings
.Invalidate( SID_TABLE_CELL
);
706 void ScTabViewShell::UpdateInputHandlerCellAdjust( SvxCellHorJustify eJust
)
708 if( ScInputHandler
* pHdl
= pInputHandler
? pInputHandler
: SC_MOD()->GetInputHdl() )
709 pHdl
->UpdateCellAdjust( eJust
);
712 //------------------------------------------------------------------
714 void __EXPORT
ScTabViewShell::ExecuteSave( SfxRequest
& rReq
)
716 // nur SID_SAVEDOC / SID_SAVEASDOC
718 // Eingabe auf jeden Fall abschliessen, auch wenn eine Formel bearbeitet wird
719 SC_MOD()->InputEnterHandler();
721 if ( GetViewData()->GetDocShell()->IsDocShared() )
723 GetViewData()->GetDocShell()->SetDocumentModified();
726 // ansonsten normal weiter
727 GetViewData()->GetDocShell()->ExecuteSlot( rReq
);
730 void __EXPORT
ScTabViewShell::GetSaveState( SfxItemSet
& rSet
)
732 SfxShell
* pDocSh
= GetViewData()->GetDocShell();
734 SfxWhichIter
aIter(rSet
);
735 USHORT nWhich
= aIter
.FirstWhich();
738 if ( nWhich
!= SID_SAVEDOC
|| !GetViewData()->GetDocShell()->IsDocShared() )
740 // get state from DocShell
741 pDocSh
->GetSlotState( nWhich
, NULL
, &rSet
);
743 nWhich
= aIter
.NextWhich();
747 //------------------------------------------------------------------
749 void ScTabViewShell::ExecuteUndo(SfxRequest
& rReq
)
751 SfxShell
* pSh
= GetViewData()->GetDispatcher().GetShell(0);
752 SfxUndoManager
* pUndoManager
= pSh
->GetUndoManager();
754 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
755 ScDocShell
* pDocSh
= GetViewData()->GetDocShell();
757 USHORT nSlot
= rReq
.GetSlot();
764 BOOL bIsUndo
= ( nSlot
== SID_UNDO
);
767 const SfxPoolItem
* pItem
;
768 if ( pReqArgs
&& pReqArgs
->GetItemState( nSlot
, TRUE
, &pItem
) == SFX_ITEM_SET
)
769 nCount
= ((const SfxUInt16Item
*)pItem
)->GetValue();
771 // lock paint for more than one cell undo action (not for editing within a cell)
772 BOOL bLockPaint
= ( nCount
> 1 && pUndoManager
== GetUndoManager() );
776 for (USHORT i
=0; i
<nCount
; i
++)
779 pUndoManager
->Undo(0);
781 pUndoManager
->Redo(0);
785 pDocSh
->UnlockPaint();
787 GetViewFrame()->GetBindings().InvalidateAll(sal_False
);
791 // GetViewFrame()->ExecuteSlot( rReq );
795 void ScTabViewShell::GetUndoState(SfxItemSet
&rSet
)
797 SfxShell
* pSh
= GetViewData()->GetDispatcher().GetShell(0);
798 SfxUndoManager
* pUndoManager
= pSh
->GetUndoManager();
800 SfxWhichIter
aIter(rSet
);
801 USHORT nWhich
= aIter
.FirstWhich();
806 case SID_GETUNDOSTRINGS
:
807 case SID_GETREDOSTRINGS
:
809 SfxStringListItem
aStrLst( nWhich
);
812 List
* pList
= aStrLst
.GetList();
813 BOOL bIsUndo
= ( nWhich
== SID_GETUNDOSTRINGS
);
814 USHORT nCount
= bIsUndo
? pUndoManager
->GetUndoActionCount() : pUndoManager
->GetRedoActionCount();
815 for (USHORT i
=0; i
<nCount
; i
++)
816 pList
->Insert( new String( bIsUndo
? pUndoManager
->GetUndoActionComment(i
) :
817 pUndoManager
->GetRedoActionComment(i
) ),
824 // get state from sfx view frame
825 GetViewFrame()->GetSlotState( nWhich
, NULL
, &rSet
);
828 nWhich
= aIter
.NextWhich();
833 //------------------------------------------------------------------
835 void ScTabViewShell::ExecDrawOpt( SfxRequest
& rReq
)
837 ScViewOptions aViewOptions
= GetViewData()->GetOptions();
838 ScGridOptions aGridOptions
= aViewOptions
.GetGridOptions();
840 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
841 const SfxItemSet
* pArgs
= rReq
.GetArgs();
842 const SfxPoolItem
* pItem
;
843 USHORT nSlotId
= rReq
.GetSlot();
846 case SID_GRID_VISIBLE
:
847 if ( pArgs
&& pArgs
->GetItemState(nSlotId
,TRUE
,&pItem
) == SFX_ITEM_SET
)
849 aGridOptions
.SetGridVisible( ((const SfxBoolItem
*)pItem
)->GetValue() );
850 aViewOptions
.SetGridOptions(aGridOptions
);
851 rBindings
.Invalidate(SID_GRID_VISIBLE
);
856 if ( pArgs
&& pArgs
->GetItemState(nSlotId
,TRUE
,&pItem
) == SFX_ITEM_SET
)
858 aGridOptions
.SetUseGridSnap( ((const SfxBoolItem
*)pItem
)->GetValue() );
859 aViewOptions
.SetGridOptions(aGridOptions
);
860 rBindings
.Invalidate(SID_GRID_USE
);
864 case SID_HELPLINES_MOVE
:
865 if ( pArgs
&& pArgs
->GetItemState(nSlotId
,TRUE
,&pItem
) == SFX_ITEM_SET
)
867 aViewOptions
.SetOption( VOPT_HELPLINES
, ((const SfxBoolItem
*)pItem
)->GetValue() );
868 rBindings
.Invalidate(SID_HELPLINES_MOVE
);
873 GetViewData()->SetOptions(aViewOptions
);
876 void ScTabViewShell::GetDrawOptState( SfxItemSet
& rSet
)
880 const ScViewOptions
& rViewOptions
= GetViewData()->GetOptions();
881 const ScGridOptions
& rGridOptions
= rViewOptions
.GetGridOptions();
883 aBool
.SetValue(rGridOptions
.GetGridVisible());
884 aBool
.SetWhich( SID_GRID_VISIBLE
);
887 aBool
.SetValue(rGridOptions
.GetUseGridSnap());
888 aBool
.SetWhich( SID_GRID_USE
);
891 aBool
.SetValue(rViewOptions
.GetOption( VOPT_HELPLINES
));
892 aBool
.SetWhich( SID_HELPLINES_MOVE
);