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 <config_features.h>
24 #include "scitems.hxx"
25 #include <sfx2/request.hxx>
26 #include <sfx2/bindings.hxx>
27 #include <sfx2/viewfrm.hxx>
28 #include <basic/sbstar.hxx>
29 #include <svl/languageoptions.hxx>
30 #include <svl/stritem.hxx>
31 #include <svl/whiter.hxx>
32 #include <vcl/msgbox.hxx>
33 #include <sfx2/objface.hxx>
34 #include <svx/svxdlg.hxx>
35 #include <editeng/colritem.hxx>
37 #include "tabvwsh.hxx"
40 #include "document.hxx"
41 #include "shtabdlg.hxx"
42 #include "scresid.hxx"
43 #include "globstr.hrc"
44 #include "docfunc.hxx"
45 #include "eventuno.hxx"
47 #include "scabstdlg.hxx"
49 #include "tabbgcolor.hxx"
50 #include "tabbgcolordlg.hxx"
51 #include "markdata.hxx"
55 using std::unique_ptr
;
56 using namespace com::sun::star
;
58 void ScTabViewShell::ExecuteTable( SfxRequest
& rReq
)
60 ScViewData
& rViewData
= GetViewData();
61 ScDocument
* pDoc
= rViewData
.GetDocument();
63 SCTAB nCurrentTab
= rViewData
.GetTabNo();
64 SCTAB nTabCount
= pDoc
->GetTableCount();
65 sal_uInt16 nSlot
= rReq
.GetSlot();
66 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
68 HideListBox(); // Autofilter-DropDown-Listbox
72 case FID_TABLE_VISIBLE
:
75 pDoc
->GetName( nCurrentTab
, aName
);
78 if( pReqArgs
!= nullptr )
80 const SfxPoolItem
* pItem
;
81 if( pReqArgs
->HasItem( FID_TABLE_VISIBLE
, &pItem
) )
82 bVisible
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
85 if( ! bVisible
) // fade out
87 if ( pDoc
->IsDocEditable() )
89 ScMarkData
& rMark
= rViewData
.GetMarkData();
95 std::vector
<OUString
> rNames
;
96 rNames
.push_back(aName
);
104 if ( pDoc
->IsDocEditable() )
106 ScMarkData
& rMark
= rViewData
.GetMarkData();
115 std::vector
<OUString
> rNames
;
118 const SfxPoolItem
* pItem
;
119 if( pReqArgs
->HasItem( FID_TABLE_SHOW
, &pItem
) )
121 aName
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
122 rNames
.push_back(aName
);
131 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
132 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
134 std::unique_ptr
<AbstractScShowTabDlg
> pDlg(pFact
->CreateScShowTabDlg(GetDialogParent()));
135 OSL_ENSURE(pDlg
, "Dialog create fail!");
139 for ( SCTAB i
=0; i
!= nTabCount
; i
++ )
141 if (!pDoc
->IsVisible(i
))
143 pDoc
->GetName( i
, aTabName
);
144 pDlg
->Insert( aTabName
, bFirst
);
149 if ( pDlg
->Execute() == RET_OK
)
151 const sal_Int32 nCount
= pDlg
->GetSelectEntryCount();
152 for (sal_Int32 nPos
=0; nPos
<nCount
; ++nPos
)
154 aName
= pDlg
->GetSelectEntry(nPos
);
155 rReq
.AppendItem( SfxStringItem( FID_TABLE_SHOW
, aName
) );
156 rNames
.push_back(aName
);
166 case FID_INS_TABLE_EXT
:
168 ScMarkData
& rMark
= rViewData
.GetMarkData();
169 SCTAB nTabSelCount
= rMark
.GetSelectCount();
170 SCTAB nTabNr
= nCurrentTab
;
172 if ( !pDoc
->IsDocEditable() )
175 if ( pReqArgs
!= nullptr ) // from basic
178 const SfxPoolItem
* pTabItem
;
179 const SfxPoolItem
* pNameItem
;
181 if ( pReqArgs
->HasItem( FN_PARAM_1
, &pTabItem
) &&
182 pReqArgs
->HasItem( nSlot
, &pNameItem
) )
184 OUString aName
= static_cast<const SfxStringItem
*>(pNameItem
)->GetValue();
185 pDoc
->CreateValidTabName(aName
);
187 // sheet number from basic: 1-based
188 // 0 is special, means adding at the end
189 nTabNr
= static_cast<const SfxUInt16Item
*>(pTabItem
)->GetValue();
195 if (nTabNr
> nTabCount
)
198 bOk
= InsertTable(aName
, nTabNr
);
202 rReq
.Done( *pReqArgs
);
207 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
208 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
210 std::unique_ptr
<AbstractScInsertTableDlg
> pDlg(pFact
->CreateScInsertTableDlg(GetDialogParent(), rViewData
,
211 nTabSelCount
, nSlot
== FID_INS_TABLE_EXT
));
212 OSL_ENSURE(pDlg
, "Dialog create fail!");
213 if ( RET_OK
== pDlg
->Execute() )
215 if (pDlg
->GetTablesFromFile())
217 std::vector
<SCTAB
> nTabs
;
219 const OUString
* pStr
= pDlg
->GetFirstTable( &n
);
222 nTabs
.push_back( static_cast<SCTAB
>(n
) );
223 pStr
= pDlg
->GetNextTable( &n
);
225 bool bLink
= pDlg
->GetTablesAsLink();
228 if(pDlg
->IsTableBefore())
230 ImportTables( pDlg
->GetDocShellTables(), nTabs
.size(), &nTabs
[0],
235 SCTAB nTabAfter
= nTabNr
+1;
237 for(SCTAB j
=nCurrentTab
+1;j
<nTabCount
;j
++)
239 if(!pDoc
->IsScenario(j
))
246 ImportTables( pDlg
->GetDocShellTables(), nTabs
.size(), &nTabs
[0],
253 SCTAB nCount
=pDlg
->GetTableCount();
254 if(pDlg
->IsTableBefore())
256 if(nCount
==1 && !pDlg
->GetFirstTable()->isEmpty())
258 rReq
.AppendItem( SfxStringItem( FID_INS_TABLE
, *pDlg
->GetFirstTable() ) );
259 rReq
.AppendItem( SfxUInt16Item( FN_PARAM_1
, static_cast<sal_uInt16
>(nTabNr
) + 1 ) ); // 1-based
262 InsertTable( *pDlg
->GetFirstTable(), nTabNr
);
266 std::vector
<OUString
> aNames(0);
267 InsertTables( aNames
, nTabNr
,nCount
);
272 SCTAB nTabAfter
= nTabNr
+1;
273 SCTAB nSelHigh
= rMark
.GetLastSelected();
275 for(SCTAB j
=nSelHigh
+1;j
<nTabCount
;j
++)
277 if(!pDoc
->IsScenario(j
))
282 else // #101672#; increase nTabAfter, because it is possible that the scenario tables are the last
286 if(nCount
==1 && !pDlg
->GetFirstTable()->isEmpty())
288 rReq
.AppendItem( SfxStringItem( FID_INS_TABLE
, *pDlg
->GetFirstTable() ) );
289 rReq
.AppendItem( SfxUInt16Item( FN_PARAM_1
, static_cast<sal_uInt16
>(nTabAfter
) + 1 ) ); // 1-based
292 InsertTable( *pDlg
->GetFirstTable(), nTabAfter
);
296 std::vector
<OUString
> aNames(0);
297 InsertTables( aNames
, nTabAfter
,nCount
);
308 case FID_TAB_MENU_RENAME
:
310 // FID_TAB_MENU_RENAME - "rename" in menu
311 // FID_TAB_RENAME - "name"-property for basic
312 // equal execute, but MENU_RENAME may be disabled inside GetState
314 if ( nSlot
== FID_TAB_MENU_RENAME
)
315 nSlot
= FID_TAB_RENAME
; // equal execute
317 SCTAB nTabNr
= rViewData
.GetTabNo();
318 ScMarkData
& rMark
= rViewData
.GetMarkData();
319 SCTAB nTabSelCount
= rMark
.GetSelectCount();
321 if ( !pDoc
->IsDocEditable() )
322 break; // everything locked
324 if ( nSlot
!= FID_TAB_APPEND
&&
325 ( pDoc
->IsTabProtected( nTabNr
) || nTabSelCount
> 1 ) )
328 if( pReqArgs
!= nullptr )
331 const SfxPoolItem
* pItem
;
334 if( pReqArgs
->HasItem( FN_PARAM_1
, &pItem
) )
336 nTabNr
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
338 // inserting is 1-based, let's be consistent
343 if( pReqArgs
->HasItem( nSlot
, &pItem
) )
344 aName
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
349 bDone
= AppendTable( aName
);
352 bDone
= RenameTable( aName
, nTabNr
);
358 rReq
.Done( *pReqArgs
);
363 sal_uInt16 nRet
= RET_OK
;
365 OUString
aErrMsg ( ScGlobal::GetRscString( STR_INVALIDTABNAME
) );
368 const sal_Char
* pHelpId
= nullptr;
373 aDlgTitle
= OUString(ScResId(SCSTR_APDTABLE
));
374 pDoc
->CreateValidTabName( aName
);
375 pHelpId
= HID_SC_APPEND_NAME
;
379 aDlgTitle
= OUString(ScResId(SCSTR_RENAMETAB
));
380 pDoc
->GetName( rViewData
.GetTabNo(), aName
);
381 pHelpId
= HID_SC_RENAME_NAME
;
385 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
386 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
388 std::unique_ptr
<AbstractScStringInputDlg
> pDlg(pFact
->CreateScStringInputDlg(
389 GetDialogParent(), aDlgTitle
, OUString(ScResId(SCSTR_NAME
)),
390 aName
, GetStaticInterface()->GetSlot(nSlot
)->GetCommand(),
393 OSL_ENSURE(pDlg
, "Dialog create fail!");
395 while ( !bDone
&& nRet
== RET_OK
)
397 nRet
= pDlg
->Execute();
399 if ( nRet
== RET_OK
)
401 aName
= pDlg
->GetInputString();
406 bDone
= AppendTable( aName
);
409 bDone
= RenameTable( aName
, nTabNr
);
415 rReq
.AppendItem( SfxStringItem( nSlot
, aName
) );
422 #if HAVE_FEATURE_SCRIPTING
423 StarBASIC::Error( ERRCODE_BASIC_SETPROP_FAILED
); // XXX error handling???
428 nRet
= ScopedVclPtrInstance
<MessageDialog
>(GetDialogParent(),
441 if ( pDoc
->GetChangeTrack() != nullptr )
442 break; // if ChangeTracking is active, then no TabMove
446 SCTAB nTab
= rViewData
.GetTabNo();
451 if( pReqArgs
!= nullptr )
453 SCTAB nTableCount
= pDoc
->GetTableCount();
454 const SfxPoolItem
* pItem
;
456 if( pReqArgs
->HasItem( FID_TAB_MOVE
, &pItem
) )
457 aDocName
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
458 if( pReqArgs
->HasItem( FN_PARAM_1
, &pItem
) )
461 nTab
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue() - 1;
462 if ( nTab
>= nTableCount
)
463 nTab
= SC_TAB_APPEND
;
465 if( pReqArgs
->HasItem( FN_PARAM_2
, &pItem
) )
466 bCpy
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
468 if (!aDocName
.isEmpty())
470 SfxObjectShell
* pSh
= SfxObjectShell::GetFirst();
471 ScDocShell
* pScSh
= nullptr;
476 pScSh
= dynamic_cast<ScDocShell
*>( pSh
);
482 if (aDocName
.equals(pScSh
->GetTitle()))
485 ScDocument
& rDestDoc
= pScSh
->GetDocument();
486 nTableCount
= rDestDoc
.GetTableCount();
487 bDoIt
= rDestDoc
.IsDocEditable();
491 i
++; // only count ScDocShell
493 pSh
= SfxObjectShell::GetNext( *pSh
);
496 else // no doc-name -> new doc
502 if ( bDoIt
&& nTab
>= nTableCount
) // if necessary append
503 nTab
= SC_TAB_APPEND
;
507 OUString aDefaultName
;
508 pDoc
->GetName( rViewData
.GetTabNo(), aDefaultName
);
510 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
511 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
513 std::unique_ptr
<AbstractScMoveTableDlg
> pDlg(pFact
->CreateScMoveTableDlg(GetDialogParent(),
515 OSL_ENSURE(pDlg
, "Dialog create fail!");
517 SCTAB nTableCount
= pDoc
->GetTableCount();
518 ScMarkData
& rMark
= GetViewData().GetMarkData();
519 SCTAB nTabSelCount
= rMark
.GetSelectCount();
521 if(nTableCount
==nTabSelCount
)
523 pDlg
->SetForceCopyTable();
526 // We support direct renaming of sheet only when one sheet
528 pDlg
->EnableRenameTable(nTabSelCount
== 1);
530 if ( pDlg
->Execute() == RET_OK
)
532 nDoc
= pDlg
->GetSelectedDocument();
533 nTab
= pDlg
->GetSelectedTable();
534 bCpy
= pDlg
->GetCopyTable();
535 bool bRna
= pDlg
->GetRenameTable();
536 // Leave aTabName string empty, when Rename is FALSE.
539 pDlg
->GetTabNameString( aTabName
);
543 OUString aFoundDocName
;
544 if ( nDoc
!= SC_DOC_NEW
)
546 ScDocShell
* pSh
= ScDocShell::GetShellByNum( nDoc
);
549 aFoundDocName
= pSh
->GetTitle();
550 if ( !pSh
->GetDocument().IsDocEditable() )
552 ErrorMessage(STR_READONLYERR
);
557 rReq
.AppendItem( SfxStringItem( FID_TAB_MOVE
, aFoundDocName
) );
558 // 1-based table, if not APPEND
559 SCTAB nBasicTab
= ( nTab
<= MAXTAB
) ? (nTab
+1) : nTab
;
560 rReq
.AppendItem( SfxUInt16Item( FN_PARAM_1
, static_cast<sal_uInt16
>(nBasicTab
) ) );
561 rReq
.AppendItem( SfxBoolItem( FN_PARAM_2
, bCpy
) );
567 rReq
.Done(); // record, while doc is active
569 MoveTable( nDoc
, nTab
, bCpy
, &aTabName
);
574 case FID_DELETE_TABLE
:
576 bool bHasIndex
= (pReqArgs
!= nullptr);
578 // allow removing via the Index/FID_DELETE_TABLE parameter
579 SCTAB nTabNr
= nCurrentTab
;
582 const SfxPoolItem
* pItem
;
583 if (pReqArgs
->HasItem(FID_DELETE_TABLE
, &pItem
))
585 nTabNr
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
587 // inserting is 1-based, let's be consistent
593 bool bDoIt
= bHasIndex
;
596 // no parameter given, ask for confirmation
598 ScopedVclPtrInstance
<QueryBox
>( GetDialogParent(),
599 WinBits( WB_YES_NO
| WB_DEF_YES
),
600 ScGlobal::GetRscString(STR_QUERY_DELTAB
)
606 SCTAB nNewTab
= nCurrentTab
;
607 std::vector
<SCTAB
> TheTabs
;
611 // sheet no. provided by the parameter
612 TheTabs
.push_back(nTabNr
);
613 if (nNewTab
> nTabNr
&& nNewTab
> 0)
619 bool bTabFlag
= false;
620 ScMarkData
& rMark
= rViewData
.GetMarkData();
621 for (SCTAB i
= 0; i
< nTabCount
; i
++)
623 if (rMark
.GetTableSelect(i
) && !pDoc
->IsTabProtected(i
))
625 TheTabs
.push_back(i
);
633 if (nNewTab
>= nTabCount
)
637 rViewData
.SetTabNo(nNewTab
);
638 DeleteTables(TheTabs
);
647 ScDocShell
* pDocSh
= rViewData
.GetDocShell();
648 ScDocFunc
&rFunc
= pDocSh
->GetDocFunc();
649 bool bSet
= !pDoc
->IsLayoutRTL( nCurrentTab
);
651 const ScMarkData
& rMark
= rViewData
.GetMarkData();
652 if ( rMark
.GetSelectCount() != 0 )
654 // handle several sheets
656 ::svl::IUndoManager
* pUndoManager
= pDocSh
->GetUndoManager();
657 OUString aUndo
= ScGlobal::GetRscString( STR_UNDO_TAB_RTL
);
658 pUndoManager
->EnterListAction( aUndo
, aUndo
);
660 ScMarkData::const_iterator itr
= rMark
.begin(), itrEnd
= rMark
.end();
661 for (; itr
!= itrEnd
; ++itr
)
662 rFunc
.SetLayoutRTL( *itr
, bSet
, false );
664 pUndoManager
->LeaveListAction();
667 rFunc
.SetLayoutRTL( nCurrentTab
, bSet
, false );
671 case FID_TAB_TOGGLE_GRID
:
673 bool bShowGrid
= rViewData
.GetShowGrid();
674 rViewData
.SetShowGrid(!bShowGrid
);
675 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
676 rBindings
.Invalidate( FID_TAB_TOGGLE_GRID
);
682 case FID_TAB_SET_TAB_BG_COLOR
:
683 case FID_TAB_MENU_SET_TAB_BG_COLOR
:
685 if ( nSlot
== FID_TAB_MENU_SET_TAB_BG_COLOR
)
686 nSlot
= FID_TAB_SET_TAB_BG_COLOR
;
687 SCTAB nTabNr
= rViewData
.GetTabNo();
688 ScMarkData
& rMark
= rViewData
.GetMarkData();
689 SCTAB nTabSelCount
= rMark
.GetSelectCount();
690 if ( !pDoc
->IsDocEditable() )
693 if ( pDoc
->IsTabProtected( nTabNr
) ) // ||nTabSelCount > 1
696 if( pReqArgs
!= nullptr )
699 const SfxPoolItem
* pItem
;
702 if( pReqArgs
->HasItem( nSlot
, &pItem
) )
703 aColor
= static_cast<const SvxColorItem
*>(pItem
)->GetValue();
705 if ( nTabSelCount
> 1 )
707 std::unique_ptr
<ScUndoTabColorInfo::List
>
708 pTabColorList(new ScUndoTabColorInfo::List
);
709 ScMarkData::iterator itr
= rMark
.begin(), itrEnd
= rMark
.end();
710 for (; itr
!= itrEnd
; ++itr
)
712 if ( !pDoc
->IsTabProtected(*itr
) )
714 ScUndoTabColorInfo
aTabColorInfo(*itr
);
715 aTabColorInfo
.maNewTabBgColor
= aColor
;
716 pTabColorList
->push_back(aTabColorInfo
);
719 bDone
= SetTabBgColor( *pTabColorList
);
723 bDone
= SetTabBgColor( aColor
, nCurrentTab
); //ScViewFunc.SetTabBgColor
727 rReq
.Done( *pReqArgs
);
732 sal_uInt16 nRet
= RET_OK
; /// temp
733 bool bDone
= false; /// temp
736 aTabBgColor
= pDoc
->GetTabBgColor( nCurrentTab
);
737 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
738 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
739 std::unique_ptr
<AbstractScTabBgColorDlg
> pDlg(pFact
->CreateScTabBgColorDlg(
741 OUString(ScResId(SCSTR_SET_TAB_BG_COLOR
)),
742 OUString(ScResId(SCSTR_NO_TAB_BG_COLOR
)),
745 while ( !bDone
&& nRet
== RET_OK
)
747 nRet
= pDlg
->Execute();
750 Color aSelectedColor
;
751 pDlg
->GetSelectedColor(aSelectedColor
);
752 std::unique_ptr
<ScUndoTabColorInfo::List
>
753 pTabColorList(new ScUndoTabColorInfo::List
);
754 if ( nTabSelCount
> 1 )
756 ScMarkData::iterator itr
= rMark
.begin(), itrEnd
= rMark
.end();
757 for (; itr
!= itrEnd
; ++itr
)
759 if ( !pDoc
->IsTabProtected(*itr
) )
761 ScUndoTabColorInfo
aTabColorInfo(*itr
);
762 aTabColorInfo
.maNewTabBgColor
= aSelectedColor
;
763 pTabColorList
->push_back(aTabColorInfo
);
766 bDone
= SetTabBgColor( *pTabColorList
);
770 bDone
= SetTabBgColor( aSelectedColor
, nCurrentTab
); //ScViewFunc.SetTabBgColor
774 rReq
.AppendItem( SvxColorItem( aTabBgColor
, nSlot
) );
781 #if HAVE_FEATURE_SCRIPTING
782 StarBASIC::Error( ERRCODE_BASIC_SETPROP_FAILED
);
794 ScDocShell
* pDocSh
= rViewData
.GetDocShell();
795 uno::Reference
<container::XNameReplace
> xEvents( new ScSheetEventsObj( pDocSh
, nCurrentTab
) );
796 uno::Reference
<frame::XFrame
> xFrame
= GetViewFrame()->GetFrame().GetFrameInterface();
797 SvxAbstractDialogFactory
* pDlgFactory
= SvxAbstractDialogFactory::Create();
800 std::unique_ptr
<VclAbstractDialog
> pDialog( pDlgFactory
->CreateSvxMacroAssignDlg(
801 GetDialogParent(), xFrame
, false, xEvents
, 0 ) );
802 if ( pDialog
.get() && pDialog
->Execute() == RET_OK
)
804 // the dialog modifies the settings directly
811 OSL_FAIL("unknown message for ViewShell");
816 void ScTabViewShell::GetStateTable( SfxItemSet
& rSet
)
818 ScViewData
& rViewData
= GetViewData();
819 ScDocument
* pDoc
= rViewData
.GetDocument();
820 ScDocShell
* pDocShell
= rViewData
.GetDocShell();
821 ScMarkData
& rMark
= GetViewData().GetMarkData();
822 SCTAB nTab
= rViewData
.GetTabNo();
824 SCTAB nTabCount
= pDoc
->GetTableCount();
825 SCTAB nTabSelCount
= rMark
.GetSelectCount();
827 SfxWhichIter
aIter(rSet
);
828 sal_uInt16 nWhich
= aIter
.FirstWhich();
835 case FID_TABLE_VISIBLE
:
836 rSet
.Put( SfxBoolItem( nWhich
, pDoc
->IsVisible(nTab
) ));
842 // enable menu : check to make sure we won't hide all sheets. we need at least one visible at all times.
843 for ( SCTAB i
=0; i
< nTabCount
&& nVis
<nTabSelCount
+ 1; i
++ )
844 if (pDoc
->IsVisible(i
))
846 if ( nVis
<=nTabSelCount
|| !pDoc
->IsDocEditable() )
847 rSet
.DisableItem( nWhich
);
853 bool bHasHidden
= false;
854 for ( SCTAB i
=0; i
< nTabCount
&& !bHasHidden
; i
++ )
855 if (!pDoc
->IsVisible(i
))
857 if ( !bHasHidden
|| pDoc
->IsDocProtected() || nTabSelCount
> 1 )
858 rSet
.DisableItem( nWhich
);
862 case FID_DELETE_TABLE
:
864 if ( pDoc
->GetChangeTrack() )
865 rSet
.DisableItem( nWhich
);
869 for ( SCTAB i
=0; i
< nTabCount
&& nVis
<2; i
++ )
870 if (pDoc
->IsVisible(i
))
872 if ( pDoc
->IsTabProtected(nTab
)
873 || !pDoc
->IsDocEditable()
875 || nTabSelCount
== nTabCount
)
876 rSet
.DisableItem( nWhich
);
882 case FID_INS_TABLE_EXT
:
884 if ( !pDoc
->IsDocEditable() ||
885 nTabCount
> MAXTAB
||
886 ( nWhich
== FID_INS_TABLE_EXT
&& pDocShell
&& pDocShell
->IsDocShared() ) )
887 rSet
.DisableItem( nWhich
);
891 if ( !pDoc
->IsDocEditable()
892 || pDoc
->GetChangeTrack() != nullptr
893 || nTabCount
> MAXTAB
)
894 rSet
.DisableItem( nWhich
);
897 // FID_TAB_MENU_RENAME - "rename" from Menu
898 // FID_TAB_RENAME - "name"-property for Basic
900 case FID_TAB_MENU_RENAME
:
901 if ( !pDoc
->IsDocEditable() ||
902 pDoc
->IsTabProtected(nTab
) ||nTabSelCount
> 1 ||
903 ( pDocShell
&& pDocShell
->IsDocShared() ) )
904 rSet
.DisableItem( nWhich
);
910 pDoc
->GetName( nTab
, aTabName
);
912 rSet
.Put( SfxStringItem( nWhich
, aTabName
));
919 SvtLanguageOptions aLangOpt
;
920 if ( !aLangOpt
.IsCTLFontEnabled() )
921 rSet
.DisableItem( nWhich
);
923 rSet
.Put( SfxBoolItem( nWhich
, pDoc
->IsLayoutRTL( nTab
) ) );
927 case FID_TAB_MENU_SET_TAB_BG_COLOR
:
929 if ( !pDoc
->IsDocEditable()
930 || ( pDocShell
&& pDocShell
->IsDocShared() )
931 || pDoc
->IsTabProtected(nTab
) )
932 rSet
.DisableItem( nWhich
);
936 case FID_TAB_SET_TAB_BG_COLOR
:
939 aColor
= pDoc
->GetTabBgColor( nTab
);
940 rSet
.Put( SvxColorItem( aColor
, nWhich
) );
944 case FID_TAB_TOGGLE_GRID
:
945 rSet
.Put( SfxBoolItem(nWhich
, rViewData
.GetShowGrid()) );
948 nWhich
= aIter
.NextWhich();
952 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */