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: tabvwshf.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 #include "scitems.hxx"
39 #include <sfx2/request.hxx>
40 #include <sfx2/bindings.hxx>
41 #include <sfx2/viewfrm.hxx>
42 #include <basic/sbstar.hxx>
43 #include <layout/layout.hxx>
44 #include <svtools/languageoptions.hxx>
45 #include <svtools/stritem.hxx>
46 #include <svtools/whiter.hxx>
47 #include <vcl/msgbox.hxx>
49 #include "tabvwsh.hxx"
52 #include "document.hxx"
53 #include "shtabdlg.hxx"
54 #include "scresid.hxx"
55 //CHINA001 #include "instbdlg.hxx"
56 #include "globstr.hrc"
57 //CHINA001 #include "strindlg.hxx"
58 //CHINA001 #include "mvtabdlg.hxx"
59 #include "docfunc.hxx"
61 #include "scabstdlg.hxx" //CHINA001
63 #include "tabbgcolor.hxx" //DBW
64 #include "tabbgcolordlg.hxx" //DBW
65 #include <svx/colritem.hxx> //DBW
67 #define IS_AVAILABLE(WhichId,ppItem) \
68 (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET)
70 //------------------------------------------------------------------
72 void ScTabViewShell::ExecuteTable( SfxRequest
& rReq
)
74 ScViewData
* pViewData
= GetViewData();
75 ScDocument
* pDoc
= pViewData
->GetDocument();
77 SCTAB nCurrentTab
= pViewData
->GetTabNo();
78 SCTAB nTabCount
= pDoc
->GetTableCount();
79 USHORT nSlot
= rReq
.GetSlot();
80 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
82 HideListBox(); // Autofilter-DropDown-Listbox
86 case FID_TABLE_VISIBLE
:
89 pDoc
->GetName( nCurrentTab
, aName
);
92 if( pReqArgs
!= NULL
)
94 const SfxPoolItem
* pItem
;
95 if( IS_AVAILABLE( FID_TABLE_VISIBLE
, &pItem
) )
96 bVisible
= ((const SfxBoolItem
*)pItem
)->GetValue();
99 if( ! bVisible
) // ausblenden
101 ScMarkData
& rMark
= pViewData
->GetMarkData();
102 SCTAB nTabSelCount
= rMark
.GetSelectCount();
104 for ( SCTAB i
=0; i
< nTabCount
&& nVis
<2; i
++ )
105 if (pDoc
->IsVisible(i
))
107 if ( nVis
<2 || !pDoc
->IsDocEditable() || nTabSelCount
> 1 )
111 if (pDoc
->GetTable( aName
, nHideTab
))
112 HideTable( nHideTab
);
123 ScMarkData
& rMark
= pViewData
->GetMarkData();
124 SCTAB nTabSelCount
= rMark
.GetSelectCount();
126 for ( SCTAB i
=0; i
< nTabCount
&& nVis
<2; i
++ )
127 if (pDoc
->IsVisible(i
))
129 if ( nVis
<2 || !pDoc
->IsDocEditable() || nTabSelCount
> 1 )
134 if( pReqArgs
!= NULL
)
136 const SfxPoolItem
* pItem
;
137 if( IS_AVAILABLE( FID_TABLE_HIDE
, &pItem
) )
138 aName
= ((const SfxStringItem
*)pItem
)->GetValue();
143 pDoc
->GetName( nCurrentTab
, aName
); // aktuelle Tabelle
144 rReq
.AppendItem( SfxStringItem( FID_TABLE_HIDE
, aName
) );
148 if (pDoc
->GetTable( aName
, nHideTab
))
149 HideTable( nHideTab
);
161 const SfxPoolItem
* pItem
;
162 if( IS_AVAILABLE( FID_TABLE_SHOW
, &pItem
) )
164 aName
= ((const SfxStringItem
*)pItem
)->GetValue();
174 //CHINA001 ScShowTabDlg* pDlg = new ScShowTabDlg( GetDialogParent() );
175 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
176 DBG_ASSERT(pFact
, "ScAbstractFactory create fail!");//CHINA001
178 AbstractScShowTabDlg
* pDlg
= pFact
->CreateScShowTabDlg( GetDialogParent(), RID_SCDLG_SHOW_TAB
);
179 DBG_ASSERT(pDlg
, "Dialog create fail!");//CHINA001
183 for ( SCTAB i
=0; i
!= nTabCount
; i
++ )
185 if (!pDoc
->IsVisible(i
))
187 pDoc
->GetName( i
, aTabName
);
188 pDlg
->Insert( aTabName
, bFirst
);
193 if ( pDlg
->Execute() == RET_OK
)
195 USHORT nCount
= pDlg
->GetSelectEntryCount();
196 for (USHORT nPos
=0; nPos
<nCount
; nPos
++)
198 aName
= pDlg
->GetSelectEntry(nPos
);
201 rReq
.AppendItem( SfxStringItem( FID_TABLE_SHOW
, aName
) );
210 case FID_INS_TABLE_EXT
:
212 ScMarkData
& rMark
= pViewData
->GetMarkData();
213 SCTAB nTabSelCount
= rMark
.GetSelectCount();
214 SCTAB nTabNr
= nCurrentTab
;
216 if ( !pDoc
->IsDocEditable() )
219 if ( pReqArgs
!= NULL
) // von Basic
222 const SfxPoolItem
* pTabItem
;
223 const SfxPoolItem
* pNameItem
;
226 if ( IS_AVAILABLE( FN_PARAM_1
, &pTabItem
) &&
227 IS_AVAILABLE( nSlot
, &pNameItem
) )
229 // Tabellennr. von Basic: 1-basiert
231 aName
= ((const SfxStringItem
*)pNameItem
)->GetValue();
232 nTabNr
= ((const SfxUInt16Item
*)pTabItem
)->GetValue() - 1;
233 if ( nTabNr
< nTabCount
)
234 bOk
= InsertTable( aName
, nTabNr
);
238 rReq
.Done( *pReqArgs
);
239 //! sonst Fehler setzen
243 //CHINA001 ScInsertTableDlg* pDlg = new ScInsertTableDlg(
244 //CHINA001 GetDialogParent(),
245 //CHINA001 *pViewData,nTabSelCount);
246 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
247 DBG_ASSERT(pFact
, "ScAbstractFactory create fail!");//CHINA001
249 AbstractScInsertTableDlg
* pDlg
= pFact
->CreateScInsertTableDlg( GetDialogParent(), *pViewData
,
250 nTabSelCount
, nSlot
== FID_INS_TABLE_EXT
,
251 RID_SCDLG_INSERT_TABLE
);
252 DBG_ASSERT(pDlg
, "Dialog create fail!");//CHINA001
253 if ( RET_OK
== pDlg
->Execute() )
255 if (pDlg
->GetTablesFromFile())
257 SCTAB nTabs
[MAXTABCOUNT
];
260 const String
* pStr
= pDlg
->GetFirstTable( &n
);
263 nTabs
[nCount
++] = static_cast<SCTAB
>(n
);
264 pStr
= pDlg
->GetNextTable( &n
);
266 BOOL bLink
= pDlg
->GetTablesAsLink();
269 if(pDlg
->IsTableBefore())
271 ImportTables( pDlg
->GetDocShellTables(), nCount
, nTabs
,
276 SCTAB nTabAfter
= nTabNr
+1;
278 for(SCTAB j
=nCurrentTab
+1;j
<nTabCount
;j
++)
280 if(!pDoc
->IsScenario(j
))
287 ImportTables( pDlg
->GetDocShellTables(), nCount
, nTabs
,
294 SCTAB nCount
=pDlg
->GetTableCount();
295 if(pDlg
->IsTableBefore())
297 if(nCount
==1 && pDlg
->GetFirstTable()->Len()>0)
299 rReq
.AppendItem( SfxStringItem( FID_INS_TABLE
, *pDlg
->GetFirstTable() ) );
300 rReq
.AppendItem( SfxUInt16Item( FN_PARAM_1
, static_cast<sal_uInt16
>(nTabNr
) + 1 ) ); // 1-based
303 InsertTable( *pDlg
->GetFirstTable(), nTabNr
);
306 InsertTables( NULL
, nTabNr
,nCount
);
310 SCTAB nTabAfter
= nTabNr
+1;
313 for(SCTAB i
=0;i
<nTabCount
;i
++)
315 if(rMark
.GetTableSelect(i
))
321 for(SCTAB j
=nSelHigh
+1;j
<nTabCount
;j
++)
323 if(!pDoc
->IsScenario(j
))
328 else // #101672#; increase nTabAfter, because it is possible that the scenario tables are the last
332 if(nCount
==1 && pDlg
->GetFirstTable()->Len()>0)
334 rReq
.AppendItem( SfxStringItem( FID_INS_TABLE
, *pDlg
->GetFirstTable() ) );
335 rReq
.AppendItem( SfxUInt16Item( FN_PARAM_1
, static_cast<sal_uInt16
>(nTabAfter
) + 1 ) ); // 1-based
338 InsertTable( *pDlg
->GetFirstTable(), nTabAfter
);
342 InsertTables( NULL
, nTabAfter
,nCount
);
355 case FID_TAB_MENU_RENAME
:
357 // FID_TAB_MENU_RENAME - "umbenennen" im Menu
358 // FID_TAB_RENAME - "Name"-Property fuer Basic
359 // Execute ist gleich, aber im GetState wird MENU_RENAME evtl. disabled
361 if ( nSlot
== FID_TAB_MENU_RENAME
)
362 nSlot
= FID_TAB_RENAME
; // Execute ist gleich
364 SCTAB nTabNr
= pViewData
->GetTabNo();
365 ScMarkData
& rMark
= pViewData
->GetMarkData();
366 SCTAB nTabSelCount
= rMark
.GetSelectCount();
368 if ( !pDoc
->IsDocEditable() )
369 break; // alles gesperrt
371 if ( nSlot
!= FID_TAB_APPEND
&&
372 ( pDoc
->IsTabProtected( nTabNr
) || nTabSelCount
> 1 ) )
373 break; // kein Rename
376 // ScSbxObject wird nicht mehr benutzt, stattdessen aus dem
377 // ScSbxTable::Notify die richtige Tabelle an der Basic-View eingestellt
380 SbxObject
* pObj
= GetScSbxObject();
381 ScSbxTable
* pSbxTab
= PTR_CAST( ScSbxTable
, pObj
);
382 DBG_ASSERT( pSbxTab
, "pSbxTab???" );
385 nTabNr
= pSbxTab
->GetTableNr();
389 if( pReqArgs
!= NULL
)
392 const SfxPoolItem
* pItem
;
395 if( IS_AVAILABLE( FN_PARAM_1
, &pItem
) )
396 nTabNr
= ((const SfxUInt16Item
*)pItem
)->GetValue();
398 if( IS_AVAILABLE( nSlot
, &pItem
) )
399 aName
= ((const SfxStringItem
*)pItem
)->GetValue();
404 bDone
= AppendTable( aName
);
407 bDone
= RenameTable( aName
, nTabNr
);
413 rReq
.Done( *pReqArgs
);
418 USHORT nRet
= RET_OK
;
420 String
aErrMsg ( ScGlobal::GetRscString( STR_INVALIDTABNAME
) );
427 aDlgTitle
= String(ScResId(SCSTR_APDTABLE
));
428 pDoc
->CreateValidTabName( aName
);
432 aDlgTitle
= String(ScResId(SCSTR_RENAMETAB
));
433 pDoc
->GetName( pViewData
->GetTabNo(), aName
);
437 //CHINA001 ScStringInputDlg* pDlg =
438 //CHINA001 new ScStringInputDlg( GetDialogParent(),
439 //CHINA001 aDlgTitle,
440 //CHINA001 String(ScResId(SCSTR_NAME)),
443 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
444 DBG_ASSERT(pFact
, "ScAbstractFactory create fail!");//CHINA001
446 AbstractScStringInputDlg
* pDlg
= pFact
->CreateScStringInputDlg( GetDialogParent(),
448 String(ScResId(SCSTR_NAME
)),
450 nSlot
,RID_SCDLG_STRINPUT
);
451 DBG_ASSERT(pDlg
, "Dialog create fail!");//CHINA001
453 while ( !bDone
&& nRet
== RET_OK
)
455 nRet
= pDlg
->Execute();
457 if ( nRet
== RET_OK
)
459 pDlg
->GetInputString( aName
);
465 bDone
= AppendTable( aName
);
468 bDone
= RenameTable( aName
, nTabNr
);
474 rReq
.AppendItem( SfxStringItem( nSlot
, aName
) );
481 StarBASIC::Error( SbERR_SETPROP_FAILED
); // XXX Fehlerbehandlung???
485 nRet
= ErrorBox( GetDialogParent(),
486 WinBits( WB_OK
| WB_DEF_OK
),
500 if ( pDoc
->GetChangeTrack() != NULL
)
501 break; // bei aktiviertem ChangeTracking kein TabMove
505 SCTAB nTab
= pViewData
->GetTabNo();
509 if( pReqArgs
!= NULL
)
511 SCTAB nTableCount
= pDoc
->GetTableCount();
512 const SfxPoolItem
* pItem
;
514 if( IS_AVAILABLE( FID_TAB_MOVE
, &pItem
) )
515 aDocName
= ((const SfxStringItem
*)pItem
)->GetValue();
516 if( IS_AVAILABLE( FN_PARAM_1
, &pItem
) )
518 // Tabelle ist 1-basiert
519 nTab
= ((const SfxUInt16Item
*)pItem
)->GetValue() - 1;
520 if ( nTab
>= nTableCount
)
521 nTab
= SC_TAB_APPEND
;
523 if( IS_AVAILABLE( FN_PARAM_2
, &pItem
) )
524 bCpy
= ((const SfxBoolItem
*)pItem
)->GetValue();
528 SfxObjectShell
* pSh
= SfxObjectShell::GetFirst();
529 ScDocShell
* pScSh
= NULL
;
534 pScSh
= PTR_CAST( ScDocShell
, pSh
);
540 if( pScSh
->GetTitle() == aDocName
)
543 ScDocument
* pDestDoc
= pScSh
->GetDocument();
544 nTableCount
= pDestDoc
->GetTableCount();
545 bDoIt
= pDestDoc
->IsDocEditable();
549 i
++; // nur die ScDocShell's zaehlen
551 pSh
= SfxObjectShell::GetNext( *pSh
);
554 else // Kein Dokumentname -> neues Dokument
560 if ( bDoIt
&& nTab
>= nTableCount
) // ggf. anhaengen
561 nTab
= SC_TAB_APPEND
;
565 //CHINA001 ScMoveTableDlg* pDlg = new ScMoveTableDlg( GetDialogParent() );
566 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
567 DBG_ASSERT(pFact
, "ScAbstractFactory create fail!");//CHINA001
569 AbstractScMoveTableDlg
* pDlg
= pFact
->CreateScMoveTableDlg( GetDialogParent(), RID_SCDLG_MOVETAB
);
570 DBG_ASSERT(pDlg
, "Dialog create fail!");//CHINA001
572 SCTAB nTableCount
= pDoc
->GetTableCount();
573 ScMarkData
& rMark
= GetViewData()->GetMarkData();
574 SCTAB nTabSelCount
= rMark
.GetSelectCount();
577 if(nTableCount
==nTabSelCount
)
579 pDlg
->SetCopyTable();
580 pDlg
->EnableCopyTable(FALSE
);
582 if ( pDlg
->Execute() == RET_OK
)
584 nDoc
= pDlg
->GetSelectedDocument();
585 nTab
= pDlg
->GetSelectedTable();
586 bCpy
= pDlg
->GetCopyTable();
589 String aFoundDocName
;
590 if ( nDoc
!= SC_DOC_NEW
)
592 ScDocShell
* pSh
= ScDocShell::GetShellByNum( nDoc
);
595 aFoundDocName
= pSh
->GetTitle();
596 if ( !pSh
->GetDocument()->IsDocEditable() )
598 ErrorMessage(STR_READONLYERR
);
603 rReq
.AppendItem( SfxStringItem( FID_TAB_MOVE
, aFoundDocName
) );
604 // Tabelle ist 1-basiert, wenn nicht APPEND
605 SCTAB nBasicTab
= ( nTab
<= MAXTAB
) ? (nTab
+1) : nTab
;
606 rReq
.AppendItem( SfxUInt16Item( FN_PARAM_1
, static_cast<sal_uInt16
>(nBasicTab
) ) );
607 rReq
.AppendItem( SfxBoolItem( FN_PARAM_2
, bCpy
) );
614 rReq
.Done(); // aufzeichnen, solange das Dokument noch aktiv ist
616 MoveTable( nDoc
, nTab
, bCpy
);
621 case FID_DELETE_TABLE
:
623 // Parameter war ueberfluessig, weil die Methode an der Table haengt
625 BOOL bDoIt
= rReq
.IsAPI();
628 // wenn's nicht von Basic kommt, nochmal nachfragen:
631 // Using layout::QueryBox without client code modification is
632 // deprecated, rather add HIG-complient buttons with verbs.
633 #define QueryBox( parent, winbits, question ) layout::QueryBox (parent, question, ScGlobal::GetRscString (STR_UNDO_DELETE_TAB))
634 #endif /* ENABLE_LAYOUT */
637 QueryBox( GetDialogParent(),
638 WinBits( WB_YES_NO
| WB_DEF_YES
),
639 ScGlobal::GetRscString(STR_QUERY_DELTAB
)
644 SCTAB nNewTab
= nCurrentTab
;
647 ScMarkData
& rMark
= pViewData
->GetMarkData();
649 for(SCTAB i
=0;i
<nTabCount
;i
++)
651 if(rMark
.GetTableSelect(i
) &&!pDoc
->IsTabProtected(i
))
653 TheTabs
.Insert(i
,TheTabs
.Count());
655 if(nNewTab
==i
) nNewTab
++;
657 if(!bTabFlag
) nFirstTab
=i
;
659 if(nNewTab
>=nTabCount
) nNewTab
=nFirstTab
;
661 pViewData
->SetTabNo(nNewTab
);
662 DeleteTables(TheTabs
);
663 TheTabs
.Remove(0,TheTabs
.Count());
671 ScDocShell
* pDocSh
= pViewData
->GetDocShell();
672 ScDocFunc
aFunc(*pDocSh
);
673 BOOL bSet
= !pDoc
->IsLayoutRTL( nCurrentTab
);
675 const ScMarkData
& rMark
= pViewData
->GetMarkData();
676 if ( rMark
.GetSelectCount() != 0 )
678 // handle several sheets
680 SfxUndoManager
* pUndoManager
= pDocSh
->GetUndoManager();
681 String aUndo
= ScGlobal::GetRscString( STR_UNDO_TAB_RTL
);
682 pUndoManager
->EnterListAction( aUndo
, aUndo
);
684 for (SCTAB nTab
=0; nTab
<nTabCount
; nTab
++)
685 if ( rMark
.GetTableSelect(nTab
) )
686 aFunc
.SetLayoutRTL( nTab
, bSet
, FALSE
);
688 pUndoManager
->LeaveListAction();
691 aFunc
.SetLayoutRTL( nCurrentTab
, bSet
, FALSE
);
695 case FID_TAB_TOGGLE_GRID
:
697 bool bShowGrid
= pViewData
->GetShowGrid();
698 pViewData
->SetShowGrid(!bShowGrid
);
699 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
700 rBindings
.Invalidate( FID_TAB_TOGGLE_GRID
);
706 case FID_TAB_SET_TAB_BG_COLOR
:
707 case FID_TAB_MENU_SET_TAB_BG_COLOR
:
709 if ( nSlot
== FID_TAB_MENU_SET_TAB_BG_COLOR
)
710 nSlot
= FID_TAB_SET_TAB_BG_COLOR
;
712 SCTAB nTabNr
= pViewData
->GetTabNo();
713 ScMarkData
& rMark
= pViewData
->GetMarkData();
714 SCTAB nTabSelCount
= rMark
.GetSelectCount();
716 ScUndoSetTabBgColorInfo
* aTabBgColorUndoInfo
=NULL
;
717 ScUndoSetTabBgColorInfoList
* aTabBgColorUndoInfoList
=NULL
;
719 if ( !pDoc
->IsDocEditable() )
722 if ( pDoc
->IsTabProtected( nTabNr
) ) // ||nTabSelCount > 1
725 if( pReqArgs
!= NULL
)
728 const SfxPoolItem
* pItem
;
730 if( IS_AVAILABLE( FN_PARAM_1
, &pItem
) )
731 nTabNr
= ((const SfxUInt16Item
*)pItem
)->GetValue();
733 if( IS_AVAILABLE( nSlot
, &pItem
) )
734 aColor
= ((const SvxColorItem
*)pItem
)->GetValue();
736 if ( nTabSelCount
> 1 )
738 aTabBgColorUndoInfoList
= new ScUndoSetTabBgColorInfoList();
739 for (SCTAB nTab
=0; nTab
<nTabCount
; nTab
++)
741 if ( rMark
.GetTableSelect(nTab
) && !pDoc
->IsTabProtected(nTab
) )
743 aTabBgColorUndoInfo
= new ScUndoSetTabBgColorInfo();
744 aTabBgColorUndoInfo
->nTabId
= nTab
;
745 aTabBgColorUndoInfo
->aNewTabBgColor
= aColor
;
746 aTabBgColorUndoInfoList
->Insert(aTabBgColorUndoInfo
);
749 bDone
= SetTabBgColor( aTabBgColorUndoInfoList
);
753 bDone
= SetTabBgColor( aColor
, nCurrentTab
); //ScViewFunc.SetTabBgColor
757 rReq
.Done( *pReqArgs
);
762 USHORT nRet
= RET_OK
; /// temp
763 BOOL bDone
= FALSE
; /// temp
765 Color aNewTabBgColor
;
767 aTabBgColor
= pViewData
->GetTabBgColor( nCurrentTab
);
768 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
769 DBG_ASSERT(pFact
, "ScAbstractFactory create fail!");
770 AbstractScTabBgColorDlg
* pDlg
= pFact
->CreateScTabBgColorDlg(
772 String(ScResId(SCSTR_SET_TAB_BG_COLOR
)),
773 String(ScResId(SCSTR_NO_TAB_BG_COLOR
)),
775 nSlot
,RID_SCDLG_TAB_BG_COLOR
);
776 while ( !bDone
&& nRet
== RET_OK
)
778 nRet
= pDlg
->Execute();
781 Color aSelectedColor
;
782 pDlg
->GetSelectedColor(aSelectedColor
);
783 aTabBgColorUndoInfoList
= new ScUndoSetTabBgColorInfoList();
784 if ( nTabSelCount
> 1 )
786 for (SCTAB nTab
=0; nTab
<nTabCount
; nTab
++)
788 if ( rMark
.GetTableSelect(nTab
) && !pDoc
->IsTabProtected(nTab
) )
790 aTabBgColorUndoInfo
= new ScUndoSetTabBgColorInfo();
791 aTabBgColorUndoInfo
->nTabId
= nTab
;
792 aTabBgColorUndoInfo
->aNewTabBgColor
= aSelectedColor
;
793 aTabBgColorUndoInfoList
->Insert(aTabBgColorUndoInfo
);
796 bDone
= SetTabBgColor( aTabBgColorUndoInfoList
);
800 bDone
= SetTabBgColor( aSelectedColor
, nCurrentTab
); //ScViewFunc.SetTabBgColor
804 rReq
.AppendItem( SvxColorItem( aTabBgColor
, nSlot
) );
811 StarBASIC::Error( SbERR_SETPROP_FAILED
);
821 DBG_ERROR("Unbekannte Message bei ViewShell");
826 //------------------------------------------------------------------
828 void ScTabViewShell::GetStateTable( SfxItemSet
& rSet
)
830 ScViewData
* pViewData
= GetViewData();
831 ScDocument
* pDoc
= pViewData
->GetDocument();
832 ScDocShell
* pDocShell
= pViewData
->GetDocShell();
833 ScMarkData
& rMark
= GetViewData()->GetMarkData();
834 SCTAB nTab
= pViewData
->GetTabNo();
836 SCTAB nTabCount
= pDoc
->GetTableCount();
837 SCTAB nTabSelCount
= rMark
.GetSelectCount();
839 SfxWhichIter
aIter(rSet
);
840 USHORT nWhich
= aIter
.FirstWhich();
847 case FID_TABLE_VISIBLE
:
848 rSet
.Put( SfxBoolItem( nWhich
, pDoc
->IsVisible(nTab
) ));
854 for ( SCTAB i
=0; i
< nTabCount
&& nVis
<2; i
++ )
855 if (pDoc
->IsVisible(i
))
858 if ( nVis
<2 || !pDoc
->IsDocEditable() || nTabSelCount
> 1 )
859 rSet
.DisableItem( nWhich
);
865 BOOL bHasHidden
= FALSE
;
866 for ( SCTAB i
=0; i
< nTabCount
&& !bHasHidden
; i
++ )
867 if (!pDoc
->IsVisible(i
))
869 if ( !bHasHidden
|| pDoc
->IsDocProtected() || nTabSelCount
> 1 )
870 rSet
.DisableItem( nWhich
);
874 case FID_DELETE_TABLE
:
876 if ( pDoc
->GetChangeTrack() )
877 rSet
.DisableItem( nWhich
);
881 for ( SCTAB i
=0; i
< nTabCount
&& nVis
<2; i
++ )
882 if (pDoc
->IsVisible(i
))
884 if ( pDoc
->IsTabProtected(nTab
)
885 || !pDoc
->IsDocEditable()
887 || nTabSelCount
== nTabCount
)
888 rSet
.DisableItem( nWhich
);
894 case FID_INS_TABLE_EXT
:
896 if ( !pDoc
->IsDocEditable() ||
897 nTabCount
> MAXTAB
||
898 ( nWhich
== FID_INS_TABLE_EXT
&& pDocShell
&& pDocShell
->IsDocShared() ) )
899 rSet
.DisableItem( nWhich
);
903 if ( !pDoc
->IsDocEditable()
904 || pDoc
->GetChangeTrack() != NULL
905 || nTabCount
> MAXTAB
)
906 rSet
.DisableItem( nWhich
);
909 // FID_TAB_MENU_RENAME - "umbenennen" im Menu
910 // FID_TAB_RENAME - "Name"-Property fuer Basic
912 case FID_TAB_MENU_RENAME
:
913 if ( !pDoc
->IsDocEditable() ||
914 pDoc
->IsTabProtected(nTab
) ||nTabSelCount
> 1 ||
915 ( pDocShell
&& pDocShell
->IsDocShared() ) )
916 rSet
.DisableItem( nWhich
);
922 pDoc
->GetName( nTab
, aTabName
);
924 rSet
.Put( SfxStringItem( nWhich
, aTabName
));
931 SvtLanguageOptions aLangOpt
;
932 if ( !aLangOpt
.IsCTLFontEnabled() )
933 rSet
.DisableItem( nWhich
);
935 rSet
.Put( SfxBoolItem( nWhich
, pDoc
->IsLayoutRTL( nTab
) ) );
939 case FID_TAB_MENU_SET_TAB_BG_COLOR
:
941 if ( !pDoc
->IsDocEditable()
942 || ( pDocShell
&& pDocShell
->IsDocShared() )
943 || pDoc
->IsTabProtected(nTab
) )
944 rSet
.DisableItem( nWhich
);
948 case FID_TAB_SET_TAB_BG_COLOR
:
951 aColor
= pViewData
->GetTabBgColor( nTab
);
952 rSet
.Put( SvxColorItem( aColor
, nWhich
) );
956 case FID_TAB_TOGGLE_GRID
:
957 rSet
.Put( SfxBoolItem(nWhich
, pViewData
->GetShowGrid()) );
960 nWhich
= aIter
.NextWhich();