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>
22 #include <boost/scoped_ptr.hpp>
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 "sccommands.h"
52 #include "markdata.hxx"
56 using ::boost::scoped_ptr
;
57 using namespace com::sun::star
;
59 void ScTabViewShell::ExecuteTable( SfxRequest
& rReq
)
61 ScViewData
& rViewData
= GetViewData();
62 ScDocument
* pDoc
= rViewData
.GetDocument();
64 SCTAB nCurrentTab
= rViewData
.GetTabNo();
65 SCTAB nTabCount
= pDoc
->GetTableCount();
66 sal_uInt16 nSlot
= rReq
.GetSlot();
67 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
69 HideListBox(); // Autofilter-DropDown-Listbox
73 case FID_TABLE_VISIBLE
:
76 pDoc
->GetName( nCurrentTab
, aName
);
79 if( pReqArgs
!= NULL
)
81 const SfxPoolItem
* pItem
;
82 if( pReqArgs
->HasItem( FID_TABLE_VISIBLE
, &pItem
) )
83 bVisible
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
86 if( ! bVisible
) // fade out
88 if ( pDoc
->IsDocEditable() )
90 ScMarkData
& rMark
= rViewData
.GetMarkData();
96 std::vector
<OUString
> rNames
;
97 rNames
.push_back(aName
);
105 if ( pDoc
->IsDocEditable() )
107 ScMarkData
& rMark
= rViewData
.GetMarkData();
116 std::vector
<OUString
> rNames
;
119 const SfxPoolItem
* pItem
;
120 if( pReqArgs
->HasItem( FID_TABLE_SHOW
, &pItem
) )
122 aName
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
123 rNames
.push_back(aName
);
132 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
133 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
135 boost::scoped_ptr
<AbstractScShowTabDlg
> pDlg(pFact
->CreateScShowTabDlg(GetDialogParent()));
136 OSL_ENSURE(pDlg
, "Dialog create fail!");
140 for ( SCTAB i
=0; i
!= nTabCount
; i
++ )
142 if (!pDoc
->IsVisible(i
))
144 pDoc
->GetName( i
, aTabName
);
145 pDlg
->Insert( aTabName
, bFirst
);
150 if ( pDlg
->Execute() == RET_OK
)
152 sal_uInt16 nCount
= pDlg
->GetSelectEntryCount();
153 for (sal_uInt16 nPos
=0; nPos
<nCount
; nPos
++)
155 aName
= pDlg
->GetSelectEntry(nPos
);
156 rReq
.AppendItem( SfxStringItem( FID_TABLE_SHOW
, aName
) );
157 rNames
.push_back(aName
);
167 case FID_INS_TABLE_EXT
:
169 ScMarkData
& rMark
= rViewData
.GetMarkData();
170 SCTAB nTabSelCount
= rMark
.GetSelectCount();
171 SCTAB nTabNr
= nCurrentTab
;
173 if ( !pDoc
->IsDocEditable() )
176 if ( pReqArgs
!= NULL
) // from basic
179 const SfxPoolItem
* pTabItem
;
180 const SfxPoolItem
* pNameItem
;
183 if ( pReqArgs
->HasItem( FN_PARAM_1
, &pTabItem
) &&
184 pReqArgs
->HasItem( nSlot
, &pNameItem
) )
186 // tablenumber from basic: 1-based
188 aName
= static_cast<const SfxStringItem
*>(pNameItem
)->GetValue();
189 nTabNr
= static_cast<const SfxUInt16Item
*>(pTabItem
)->GetValue() - 1;
190 if ( nTabNr
< nTabCount
)
191 bOk
= InsertTable( aName
, nTabNr
);
195 rReq
.Done( *pReqArgs
);
200 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
201 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
203 boost::scoped_ptr
<AbstractScInsertTableDlg
> pDlg(pFact
->CreateScInsertTableDlg(GetDialogParent(), rViewData
,
204 nTabSelCount
, nSlot
== FID_INS_TABLE_EXT
));
205 OSL_ENSURE(pDlg
, "Dialog create fail!");
206 if ( RET_OK
== pDlg
->Execute() )
208 if (pDlg
->GetTablesFromFile())
210 std::vector
<SCTAB
> nTabs
;
212 const OUString
* pStr
= pDlg
->GetFirstTable( &n
);
215 nTabs
.push_back( static_cast<SCTAB
>(n
) );
216 pStr
= pDlg
->GetNextTable( &n
);
218 bool bLink
= pDlg
->GetTablesAsLink();
221 if(pDlg
->IsTableBefore())
223 ImportTables( pDlg
->GetDocShellTables(), nTabs
.size(), &nTabs
[0],
228 SCTAB nTabAfter
= nTabNr
+1;
230 for(SCTAB j
=nCurrentTab
+1;j
<nTabCount
;j
++)
232 if(!pDoc
->IsScenario(j
))
239 ImportTables( pDlg
->GetDocShellTables(), nTabs
.size(), &nTabs
[0],
246 SCTAB nCount
=pDlg
->GetTableCount();
247 if(pDlg
->IsTableBefore())
249 if(nCount
==1 && !pDlg
->GetFirstTable()->isEmpty())
251 rReq
.AppendItem( SfxStringItem( FID_INS_TABLE
, *pDlg
->GetFirstTable() ) );
252 rReq
.AppendItem( SfxUInt16Item( FN_PARAM_1
, static_cast<sal_uInt16
>(nTabNr
) + 1 ) ); // 1-based
255 InsertTable( *pDlg
->GetFirstTable(), nTabNr
);
259 std::vector
<OUString
> aNames(0);
260 InsertTables( aNames
, nTabNr
,nCount
);
265 SCTAB nTabAfter
= nTabNr
+1;
266 SCTAB nSelHigh
= rMark
.GetLastSelected();
268 for(SCTAB j
=nSelHigh
+1;j
<nTabCount
;j
++)
270 if(!pDoc
->IsScenario(j
))
275 else // #101672#; increase nTabAfter, because it is possible that the scenario tables are the last
279 if(nCount
==1 && !pDlg
->GetFirstTable()->isEmpty())
281 rReq
.AppendItem( SfxStringItem( FID_INS_TABLE
, *pDlg
->GetFirstTable() ) );
282 rReq
.AppendItem( SfxUInt16Item( FN_PARAM_1
, static_cast<sal_uInt16
>(nTabAfter
) + 1 ) ); // 1-based
285 InsertTable( *pDlg
->GetFirstTable(), nTabAfter
);
289 std::vector
<OUString
> aNames(0);
290 InsertTables( aNames
, nTabAfter
,nCount
);
301 case FID_TAB_MENU_RENAME
:
303 // FID_TAB_MENU_RENAME - "rename" in menu
304 // FID_TAB_RENAME - "name"-property for basic
305 // equal execute, but MENU_RENAME may be disabled inside GetState
307 if ( nSlot
== FID_TAB_MENU_RENAME
)
308 nSlot
= FID_TAB_RENAME
; // equal execute
310 SCTAB nTabNr
= rViewData
.GetTabNo();
311 ScMarkData
& rMark
= rViewData
.GetMarkData();
312 SCTAB nTabSelCount
= rMark
.GetSelectCount();
314 if ( !pDoc
->IsDocEditable() )
315 break; // evrything locked
317 if ( nSlot
!= FID_TAB_APPEND
&&
318 ( pDoc
->IsTabProtected( nTabNr
) || nTabSelCount
> 1 ) )
321 if( pReqArgs
!= NULL
)
324 const SfxPoolItem
* pItem
;
327 if( pReqArgs
->HasItem( FN_PARAM_1
, &pItem
) )
328 nTabNr
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
330 if( pReqArgs
->HasItem( nSlot
, &pItem
) )
331 aName
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
336 bDone
= AppendTable( aName
);
339 bDone
= RenameTable( aName
, nTabNr
);
345 rReq
.Done( *pReqArgs
);
350 sal_uInt16 nRet
= RET_OK
;
352 OUString
aErrMsg ( ScGlobal::GetRscString( STR_INVALIDTABNAME
) );
355 const sal_Char
* pHelpId
= 0;
360 aDlgTitle
= OUString(ScResId(SCSTR_APDTABLE
));
361 pDoc
->CreateValidTabName( aName
);
362 pHelpId
= HID_SC_APPEND_NAME
;
366 aDlgTitle
= OUString(ScResId(SCSTR_RENAMETAB
));
367 pDoc
->GetName( rViewData
.GetTabNo(), aName
);
368 pHelpId
= HID_SC_RENAME_NAME
;
372 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
373 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
375 boost::scoped_ptr
<AbstractScStringInputDlg
> pDlg(pFact
->CreateScStringInputDlg(
376 GetDialogParent(), aDlgTitle
, OUString(ScResId(SCSTR_NAME
)),
377 aName
, GetStaticInterface()->GetSlot(nSlot
)->GetCommand(),
380 OSL_ENSURE(pDlg
, "Dialog create fail!");
382 while ( !bDone
&& nRet
== RET_OK
)
384 nRet
= pDlg
->Execute();
386 if ( nRet
== RET_OK
)
388 aName
= pDlg
->GetInputString();
393 bDone
= AppendTable( aName
);
396 bDone
= RenameTable( aName
, nTabNr
);
402 rReq
.AppendItem( SfxStringItem( nSlot
, aName
) );
409 #if HAVE_FEATURE_SCRIPTING
410 StarBASIC::Error( SbERR_SETPROP_FAILED
); // XXX error handling???
415 nRet
= ScopedVclPtr
<MessageDialog
>::Create(GetDialogParent(),
428 if ( pDoc
->GetChangeTrack() != NULL
)
429 break; // if ChangeTracking is active, then no TabMove
433 SCTAB nTab
= rViewData
.GetTabNo();
438 if( pReqArgs
!= NULL
)
440 SCTAB nTableCount
= pDoc
->GetTableCount();
441 const SfxPoolItem
* pItem
;
443 if( pReqArgs
->HasItem( FID_TAB_MOVE
, &pItem
) )
444 aDocName
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
445 if( pReqArgs
->HasItem( FN_PARAM_1
, &pItem
) )
448 nTab
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue() - 1;
449 if ( nTab
>= nTableCount
)
450 nTab
= SC_TAB_APPEND
;
452 if( pReqArgs
->HasItem( FN_PARAM_2
, &pItem
) )
453 bCpy
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
455 if (!aDocName
.isEmpty())
457 SfxObjectShell
* pSh
= SfxObjectShell::GetFirst();
458 ScDocShell
* pScSh
= NULL
;
463 pScSh
= PTR_CAST( ScDocShell
, pSh
);
469 if (aDocName
.equals(pScSh
->GetTitle()))
472 ScDocument
& rDestDoc
= pScSh
->GetDocument();
473 nTableCount
= rDestDoc
.GetTableCount();
474 bDoIt
= rDestDoc
.IsDocEditable();
478 i
++; // only count ScDocShell
480 pSh
= SfxObjectShell::GetNext( *pSh
);
483 else // no doc-name -> new doc
489 if ( bDoIt
&& nTab
>= nTableCount
) // if necessary append
490 nTab
= SC_TAB_APPEND
;
494 OUString aDefaultName
;
495 pDoc
->GetName( rViewData
.GetTabNo(), aDefaultName
);
497 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
498 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
500 boost::scoped_ptr
<AbstractScMoveTableDlg
> pDlg(pFact
->CreateScMoveTableDlg(GetDialogParent(),
502 OSL_ENSURE(pDlg
, "Dialog create fail!");
504 SCTAB nTableCount
= pDoc
->GetTableCount();
505 ScMarkData
& rMark
= GetViewData().GetMarkData();
506 SCTAB nTabSelCount
= rMark
.GetSelectCount();
508 if(nTableCount
==nTabSelCount
)
510 pDlg
->SetForceCopyTable();
513 // We support direct renaming of sheet only when one sheet
515 pDlg
->EnableRenameTable(nTabSelCount
== 1);
517 if ( pDlg
->Execute() == RET_OK
)
519 nDoc
= pDlg
->GetSelectedDocument();
520 nTab
= pDlg
->GetSelectedTable();
521 bCpy
= pDlg
->GetCopyTable();
522 bool bRna
= pDlg
->GetRenameTable();
523 // Leave aTabName string empty, when Rename is FALSE.
526 pDlg
->GetTabNameString( aTabName
);
530 OUString aFoundDocName
;
531 if ( nDoc
!= SC_DOC_NEW
)
533 ScDocShell
* pSh
= ScDocShell::GetShellByNum( nDoc
);
536 aFoundDocName
= pSh
->GetTitle();
537 if ( !pSh
->GetDocument().IsDocEditable() )
539 ErrorMessage(STR_READONLYERR
);
544 rReq
.AppendItem( SfxStringItem( FID_TAB_MOVE
, aFoundDocName
) );
545 // 1-based table, if not APPEND
546 SCTAB nBasicTab
= ( nTab
<= MAXTAB
) ? (nTab
+1) : nTab
;
547 rReq
.AppendItem( SfxUInt16Item( FN_PARAM_1
, static_cast<sal_uInt16
>(nBasicTab
) ) );
548 rReq
.AppendItem( SfxBoolItem( FN_PARAM_2
, bCpy
) );
554 rReq
.Done(); // record, while doc is active
556 MoveTable( nDoc
, nTab
, bCpy
, &aTabName
);
561 case FID_DELETE_TABLE
:
563 // unnecessary parameter -> method depends on table
565 bool bDoIt
= rReq
.IsAPI();
568 // source isn't basic -> ask again
571 ScopedVclPtr
<QueryBox
>::Create( GetDialogParent(),
572 WinBits( WB_YES_NO
| WB_DEF_YES
),
573 ScGlobal::GetRscString(STR_QUERY_DELTAB
)
578 SCTAB nNewTab
= nCurrentTab
;
581 ScMarkData
& rMark
= rViewData
.GetMarkData();
582 std::vector
<SCTAB
> TheTabs
;
583 for(SCTAB i
=0;i
<nTabCount
;i
++)
585 if(rMark
.GetTableSelect(i
) &&!pDoc
->IsTabProtected(i
))
587 TheTabs
.push_back(i
);
589 if(nNewTab
==i
) nNewTab
++;
591 if(!bTabFlag
) nFirstTab
=i
;
593 if(nNewTab
>=nTabCount
) nNewTab
=nFirstTab
;
595 rViewData
.SetTabNo(nNewTab
);
596 DeleteTables(TheTabs
);
605 ScDocShell
* pDocSh
= rViewData
.GetDocShell();
606 ScDocFunc
&rFunc
= pDocSh
->GetDocFunc();
607 bool bSet
= !pDoc
->IsLayoutRTL( nCurrentTab
);
609 const ScMarkData
& rMark
= rViewData
.GetMarkData();
610 if ( rMark
.GetSelectCount() != 0 )
612 // handle several sheets
614 ::svl::IUndoManager
* pUndoManager
= pDocSh
->GetUndoManager();
615 OUString aUndo
= ScGlobal::GetRscString( STR_UNDO_TAB_RTL
);
616 pUndoManager
->EnterListAction( aUndo
, aUndo
);
618 ScMarkData::const_iterator itr
= rMark
.begin(), itrEnd
= rMark
.end();
619 for (; itr
!= itrEnd
; ++itr
)
620 rFunc
.SetLayoutRTL( *itr
, bSet
, false );
622 pUndoManager
->LeaveListAction();
625 rFunc
.SetLayoutRTL( nCurrentTab
, bSet
, false );
629 case FID_TAB_TOGGLE_GRID
:
631 bool bShowGrid
= rViewData
.GetShowGrid();
632 rViewData
.SetShowGrid(!bShowGrid
);
633 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
634 rBindings
.Invalidate( FID_TAB_TOGGLE_GRID
);
640 case FID_TAB_SET_TAB_BG_COLOR
:
641 case FID_TAB_MENU_SET_TAB_BG_COLOR
:
643 if ( nSlot
== FID_TAB_MENU_SET_TAB_BG_COLOR
)
644 nSlot
= FID_TAB_SET_TAB_BG_COLOR
;
645 SCTAB nTabNr
= rViewData
.GetTabNo();
646 ScMarkData
& rMark
= rViewData
.GetMarkData();
647 SCTAB nTabSelCount
= rMark
.GetSelectCount();
648 if ( !pDoc
->IsDocEditable() )
651 if ( pDoc
->IsTabProtected( nTabNr
) ) // ||nTabSelCount > 1
654 if( pReqArgs
!= NULL
)
657 const SfxPoolItem
* pItem
;
659 if( pReqArgs
->HasItem( FN_PARAM_1
, &pItem
) )
660 nTabNr
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
662 if( pReqArgs
->HasItem( nSlot
, &pItem
) )
663 aColor
= static_cast<const SvxColorItem
*>(pItem
)->GetValue();
665 if ( nTabSelCount
> 1 )
667 scoped_ptr
<ScUndoTabColorInfo::List
>
668 pTabColorList(new ScUndoTabColorInfo::List
);
669 ScMarkData::iterator itr
= rMark
.begin(), itrEnd
= rMark
.end();
670 for (; itr
!= itrEnd
; ++itr
)
672 if ( !pDoc
->IsTabProtected(*itr
) )
674 ScUndoTabColorInfo
aTabColorInfo(*itr
);
675 aTabColorInfo
.maNewTabBgColor
= aColor
;
676 pTabColorList
->push_back(aTabColorInfo
);
679 bDone
= SetTabBgColor( *pTabColorList
);
683 bDone
= SetTabBgColor( aColor
, nCurrentTab
); //ScViewFunc.SetTabBgColor
687 rReq
.Done( *pReqArgs
);
692 sal_uInt16 nRet
= RET_OK
; /// temp
693 bool bDone
= false; /// temp
696 aTabBgColor
= pDoc
->GetTabBgColor( nCurrentTab
);
697 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
698 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
699 boost::scoped_ptr
<AbstractScTabBgColorDlg
> pDlg(pFact
->CreateScTabBgColorDlg(
701 OUString(ScResId(SCSTR_SET_TAB_BG_COLOR
)),
702 OUString(ScResId(SCSTR_NO_TAB_BG_COLOR
)),
704 CMD_FID_TAB_SET_TAB_BG_COLOR
));
705 while ( !bDone
&& nRet
== RET_OK
)
707 nRet
= pDlg
->Execute();
710 Color aSelectedColor
;
711 pDlg
->GetSelectedColor(aSelectedColor
);
712 scoped_ptr
<ScUndoTabColorInfo::List
>
713 pTabColorList(new ScUndoTabColorInfo::List
);
714 if ( nTabSelCount
> 1 )
716 ScMarkData::iterator itr
= rMark
.begin(), itrEnd
= rMark
.end();
717 for (; itr
!= itrEnd
; ++itr
)
719 if ( !pDoc
->IsTabProtected(*itr
) )
721 ScUndoTabColorInfo
aTabColorInfo(*itr
);
722 aTabColorInfo
.maNewTabBgColor
= aSelectedColor
;
723 pTabColorList
->push_back(aTabColorInfo
);
726 bDone
= SetTabBgColor( *pTabColorList
);
730 bDone
= SetTabBgColor( aSelectedColor
, nCurrentTab
); //ScViewFunc.SetTabBgColor
734 rReq
.AppendItem( SvxColorItem( aTabBgColor
, nSlot
) );
741 #if HAVE_FEATURE_SCRIPTING
742 StarBASIC::Error( SbERR_SETPROP_FAILED
);
754 ScDocShell
* pDocSh
= rViewData
.GetDocShell();
755 uno::Reference
<container::XNameReplace
> xEvents( new ScSheetEventsObj( pDocSh
, nCurrentTab
) );
756 uno::Reference
<frame::XFrame
> xFrame
= GetViewFrame()->GetFrame().GetFrameInterface();
757 SvxAbstractDialogFactory
* pDlgFactory
= SvxAbstractDialogFactory::Create();
760 boost::scoped_ptr
<VclAbstractDialog
> pDialog( pDlgFactory
->CreateSvxMacroAssignDlg(
761 GetDialogParent(), xFrame
, false, xEvents
, 0 ) );
762 if ( pDialog
.get() && pDialog
->Execute() == RET_OK
)
764 // the dialog modifies the settings directly
771 OSL_FAIL("Unbekannte Message bei ViewShell");
776 void ScTabViewShell::GetStateTable( SfxItemSet
& rSet
)
778 ScViewData
& rViewData
= GetViewData();
779 ScDocument
* pDoc
= rViewData
.GetDocument();
780 ScDocShell
* pDocShell
= rViewData
.GetDocShell();
781 ScMarkData
& rMark
= GetViewData().GetMarkData();
782 SCTAB nTab
= rViewData
.GetTabNo();
784 SCTAB nTabCount
= pDoc
->GetTableCount();
785 SCTAB nTabSelCount
= rMark
.GetSelectCount();
787 SfxWhichIter
aIter(rSet
);
788 sal_uInt16 nWhich
= aIter
.FirstWhich();
795 case FID_TABLE_VISIBLE
:
796 rSet
.Put( SfxBoolItem( nWhich
, pDoc
->IsVisible(nTab
) ));
802 // enable menu : check to make sure we won't hide all sheets. we need at least one visible at all times.
803 for ( SCTAB i
=0; i
< nTabCount
&& nVis
<nTabSelCount
+ 1; i
++ )
804 if (pDoc
->IsVisible(i
))
806 if ( nVis
<=nTabSelCount
|| !pDoc
->IsDocEditable() )
807 rSet
.DisableItem( nWhich
);
813 bool bHasHidden
= false;
814 for ( SCTAB i
=0; i
< nTabCount
&& !bHasHidden
; i
++ )
815 if (!pDoc
->IsVisible(i
))
817 if ( !bHasHidden
|| pDoc
->IsDocProtected() || nTabSelCount
> 1 )
818 rSet
.DisableItem( nWhich
);
822 case FID_DELETE_TABLE
:
824 if ( pDoc
->GetChangeTrack() )
825 rSet
.DisableItem( nWhich
);
829 for ( SCTAB i
=0; i
< nTabCount
&& nVis
<2; i
++ )
830 if (pDoc
->IsVisible(i
))
832 if ( pDoc
->IsTabProtected(nTab
)
833 || !pDoc
->IsDocEditable()
835 || nTabSelCount
== nTabCount
)
836 rSet
.DisableItem( nWhich
);
842 case FID_INS_TABLE_EXT
:
844 if ( !pDoc
->IsDocEditable() ||
845 nTabCount
> MAXTAB
||
846 ( nWhich
== FID_INS_TABLE_EXT
&& pDocShell
&& pDocShell
->IsDocShared() ) )
847 rSet
.DisableItem( nWhich
);
851 if ( !pDoc
->IsDocEditable()
852 || pDoc
->GetChangeTrack() != NULL
853 || nTabCount
> MAXTAB
)
854 rSet
.DisableItem( nWhich
);
857 // FID_TAB_MENU_RENAME - "rename" from Menu
858 // FID_TAB_RENAME - "name"-property for Basic
860 case FID_TAB_MENU_RENAME
:
861 if ( !pDoc
->IsDocEditable() ||
862 pDoc
->IsTabProtected(nTab
) ||nTabSelCount
> 1 ||
863 ( pDocShell
&& pDocShell
->IsDocShared() ) )
864 rSet
.DisableItem( nWhich
);
870 pDoc
->GetName( nTab
, aTabName
);
872 rSet
.Put( SfxStringItem( nWhich
, aTabName
));
879 SvtLanguageOptions aLangOpt
;
880 if ( !aLangOpt
.IsCTLFontEnabled() )
881 rSet
.DisableItem( nWhich
);
883 rSet
.Put( SfxBoolItem( nWhich
, pDoc
->IsLayoutRTL( nTab
) ) );
887 case FID_TAB_MENU_SET_TAB_BG_COLOR
:
889 if ( !pDoc
->IsDocEditable()
890 || ( pDocShell
&& pDocShell
->IsDocShared() )
891 || pDoc
->IsTabProtected(nTab
) )
892 rSet
.DisableItem( nWhich
);
896 case FID_TAB_SET_TAB_BG_COLOR
:
899 aColor
= pDoc
->GetTabBgColor( nTab
);
900 rSet
.Put( SvxColorItem( aColor
, nWhich
) );
904 case FID_TAB_TOGGLE_GRID
:
905 rSet
.Put( SfxBoolItem(nWhich
, rViewData
.GetShowGrid()) );
908 nWhich
= aIter
.NextWhich();
912 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */