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 .
21 #include <boost/scoped_ptr.hpp>
23 #include "scitems.hxx"
24 #include <sfx2/request.hxx>
25 #include <sfx2/bindings.hxx>
26 #include <sfx2/viewfrm.hxx>
27 #include <basic/sbstar.hxx>
28 #include <svl/languageoptions.hxx>
29 #include <svl/stritem.hxx>
30 #include <svl/whiter.hxx>
31 #include <vcl/msgbox.hxx>
32 #include <sfx2/objface.hxx>
33 #include <svx/svxdlg.hxx>
34 #include <editeng/colritem.hxx>
36 #include "tabvwsh.hxx"
39 #include "document.hxx"
40 #include "shtabdlg.hxx"
41 #include "scresid.hxx"
42 #include "globstr.hrc"
43 #include "docfunc.hxx"
44 #include "eventuno.hxx"
46 #include "scabstdlg.hxx"
48 #include "tabbgcolor.hxx"
49 #include "tabbgcolordlg.hxx"
50 #include "sccommands.h"
51 #include "markdata.hxx"
55 using ::boost::scoped_ptr
;
56 using namespace com::sun::star
;
58 void ScTabViewShell::ExecuteTable( SfxRequest
& rReq
)
60 ScViewData
* pViewData
= GetViewData();
61 ScDocument
* pDoc
= pViewData
->GetDocument();
63 SCTAB nCurrentTab
= pViewData
->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
);
77 sal_Bool bVisible
=sal_True
;
78 if( pReqArgs
!= NULL
)
80 const SfxPoolItem
* pItem
;
81 if( pReqArgs
->HasItem( FID_TABLE_VISIBLE
, &pItem
) )
82 bVisible
= ((const SfxBoolItem
*)pItem
)->GetValue();
85 if( ! bVisible
) // ausblenden
87 if ( pDoc
->IsDocEditable() )
89 ScMarkData
& rMark
= pViewData
->GetMarkData();
95 std::vector
<String
> rNames
;
96 rNames
.push_back(aName
);
104 if ( pDoc
->IsDocEditable() )
106 ScMarkData
& rMark
= pViewData
->GetMarkData();
115 std::vector
<String
> rNames
;
118 const SfxPoolItem
* pItem
;
119 if( pReqArgs
->HasItem( FID_TABLE_SHOW
, &pItem
) )
121 aName
= ((const SfxStringItem
*)pItem
)->GetValue();
122 rNames
.push_back(aName
);
131 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
132 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
134 AbstractScShowTabDlg
* pDlg
= pFact
->CreateScShowTabDlg( GetDialogParent(), RID_SCDLG_SHOW_TAB
);
135 OSL_ENSURE(pDlg
, "Dialog create fail!");
138 sal_Bool bFirst
= sal_True
;
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 sal_uInt16 nCount
= pDlg
->GetSelectEntryCount();
152 for (sal_uInt16 nPos
=0; nPos
<nCount
; nPos
++)
154 aName
= pDlg
->GetSelectEntry(nPos
);
155 rReq
.AppendItem( SfxStringItem( FID_TABLE_SHOW
, aName
) );
156 rNames
.push_back(aName
);
167 case FID_INS_TABLE_EXT
:
169 ScMarkData
& rMark
= pViewData
->GetMarkData();
170 SCTAB nTabSelCount
= rMark
.GetSelectCount();
171 SCTAB nTabNr
= nCurrentTab
;
173 if ( !pDoc
->IsDocEditable() )
176 if ( pReqArgs
!= NULL
) // von Basic
178 sal_Bool bOk
= false;
179 const SfxPoolItem
* pTabItem
;
180 const SfxPoolItem
* pNameItem
;
183 if ( pReqArgs
->HasItem( FN_PARAM_1
, &pTabItem
) &&
184 pReqArgs
->HasItem( nSlot
, &pNameItem
) )
186 // Tabellennr. von Basic: 1-basiert
188 aName
= ((const SfxStringItem
*)pNameItem
)->GetValue();
189 nTabNr
= ((const SfxUInt16Item
*)pTabItem
)->GetValue() - 1;
190 if ( nTabNr
< nTabCount
)
191 bOk
= InsertTable( aName
, nTabNr
);
195 rReq
.Done( *pReqArgs
);
196 //! sonst Fehler setzen
200 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
201 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
203 AbstractScInsertTableDlg
* pDlg
= pFact
->CreateScInsertTableDlg(GetDialogParent(), *pViewData
,
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 String
* pStr
= pDlg
->GetFirstTable( &n
);
215 nTabs
.push_back( static_cast<SCTAB
>(n
) );
216 pStr
= pDlg
->GetNextTable( &n
);
218 sal_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()->Len()>0)
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()->Len()>0)
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
);
303 case FID_TAB_MENU_RENAME
:
305 // FID_TAB_MENU_RENAME - "umbenennen" im Menu
306 // FID_TAB_RENAME - "Name"-Property fuer Basic
307 // Execute ist gleich, aber im GetState wird MENU_RENAME evtl. disabled
309 if ( nSlot
== FID_TAB_MENU_RENAME
)
310 nSlot
= FID_TAB_RENAME
; // Execute ist gleich
312 SCTAB nTabNr
= pViewData
->GetTabNo();
313 ScMarkData
& rMark
= pViewData
->GetMarkData();
314 SCTAB nTabSelCount
= rMark
.GetSelectCount();
316 if ( !pDoc
->IsDocEditable() )
317 break; // alles gesperrt
319 if ( nSlot
!= FID_TAB_APPEND
&&
320 ( pDoc
->IsTabProtected( nTabNr
) || nTabSelCount
> 1 ) )
321 break; // kein Rename
323 if( pReqArgs
!= NULL
)
325 sal_Bool bDone
= false;
326 const SfxPoolItem
* pItem
;
329 if( pReqArgs
->HasItem( FN_PARAM_1
, &pItem
) )
330 nTabNr
= ((const SfxUInt16Item
*)pItem
)->GetValue();
332 if( pReqArgs
->HasItem( nSlot
, &pItem
) )
333 aName
= ((const SfxStringItem
*)pItem
)->GetValue();
338 bDone
= AppendTable( aName
);
341 bDone
= RenameTable( aName
, nTabNr
);
347 rReq
.Done( *pReqArgs
);
352 sal_uInt16 nRet
= RET_OK
;
353 sal_Bool bDone
= false;
354 String
aErrMsg ( ScGlobal::GetRscString( STR_INVALIDTABNAME
) );
357 const sal_Char
* pHelpId
= 0;
362 aDlgTitle
= String(ScResId(SCSTR_APDTABLE
));
363 pDoc
->CreateValidTabName( aName
);
364 pHelpId
= HID_SC_APPEND_NAME
;
368 aDlgTitle
= String(ScResId(SCSTR_RENAMETAB
));
369 pDoc
->GetName( pViewData
->GetTabNo(), aName
);
370 pHelpId
= HID_SC_RENAME_NAME
;
374 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
375 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
377 AbstractScStringInputDlg
* pDlg
= pFact
->CreateScStringInputDlg(
378 GetDialogParent(), aDlgTitle
, String(ScResId(SCSTR_NAME
)),
379 aName
, GetStaticInterface()->GetSlot(nSlot
)->GetCommand(),
380 pHelpId
, RID_SCDLG_STRINPUT
);
382 OSL_ENSURE(pDlg
, "Dialog create fail!");
384 while ( !bDone
&& nRet
== RET_OK
)
386 nRet
= pDlg
->Execute();
388 if ( nRet
== RET_OK
)
390 pDlg
->GetInputString( aName
);
396 bDone
= AppendTable( aName
);
399 bDone
= RenameTable( aName
, nTabNr
);
405 rReq
.AppendItem( SfxStringItem( nSlot
, aName
) );
412 #ifndef DISABLE_SCRIPTING
413 StarBASIC::Error( SbERR_SETPROP_FAILED
); // XXX Fehlerbehandlung???
418 nRet
= ErrorBox( GetDialogParent(),
419 WinBits( WB_OK
| WB_DEF_OK
),
433 if ( pDoc
->GetChangeTrack() != NULL
)
434 break; // bei aktiviertem ChangeTracking kein TabMove
436 sal_Bool bDoIt
= false;
438 SCTAB nTab
= pViewData
->GetTabNo();
439 sal_Bool bCpy
= false;
443 if( pReqArgs
!= NULL
)
445 SCTAB nTableCount
= pDoc
->GetTableCount();
446 const SfxPoolItem
* pItem
;
448 if( pReqArgs
->HasItem( FID_TAB_MOVE
, &pItem
) )
449 aDocName
= ((const SfxStringItem
*)pItem
)->GetValue();
450 if( pReqArgs
->HasItem( FN_PARAM_1
, &pItem
) )
452 // Tabelle ist 1-basiert
453 nTab
= ((const SfxUInt16Item
*)pItem
)->GetValue() - 1;
454 if ( nTab
>= nTableCount
)
455 nTab
= SC_TAB_APPEND
;
457 if( pReqArgs
->HasItem( FN_PARAM_2
, &pItem
) )
458 bCpy
= ((const SfxBoolItem
*)pItem
)->GetValue();
460 if (!aDocName
.isEmpty())
462 SfxObjectShell
* pSh
= SfxObjectShell::GetFirst();
463 ScDocShell
* pScSh
= NULL
;
468 pScSh
= PTR_CAST( ScDocShell
, pSh
);
474 if (aDocName
.equals(pScSh
->GetTitle()))
477 ScDocument
* pDestDoc
= pScSh
->GetDocument();
478 nTableCount
= pDestDoc
->GetTableCount();
479 bDoIt
= pDestDoc
->IsDocEditable();
483 i
++; // nur die ScDocShell's zaehlen
485 pSh
= SfxObjectShell::GetNext( *pSh
);
488 else // Kein Dokumentname -> neues Dokument
494 if ( bDoIt
&& nTab
>= nTableCount
) // ggf. anhaengen
495 nTab
= SC_TAB_APPEND
;
499 OUString aDefaultName
;
500 pDoc
->GetName( pViewData
->GetTabNo(), aDefaultName
);
502 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
503 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
505 AbstractScMoveTableDlg
* pDlg
= pFact
->CreateScMoveTableDlg( GetDialogParent(),
508 OSL_ENSURE(pDlg
, "Dialog create fail!");
510 SCTAB nTableCount
= pDoc
->GetTableCount();
511 ScMarkData
& rMark
= GetViewData()->GetMarkData();
512 SCTAB nTabSelCount
= rMark
.GetSelectCount();
515 if(nTableCount
==nTabSelCount
)
517 pDlg
->SetForceCopyTable();
520 // We support direct renaming of sheet only when one sheet
522 pDlg
->EnableRenameTable(nTabSelCount
== 1);
524 if ( pDlg
->Execute() == RET_OK
)
526 nDoc
= pDlg
->GetSelectedDocument();
527 nTab
= pDlg
->GetSelectedTable();
528 bCpy
= pDlg
->GetCopyTable();
529 bool bRna
= pDlg
->GetRenameTable();
530 // Leave aTabName string empty, when Rename is FALSE.
533 pDlg
->GetTabNameString( aTabName
);
537 String aFoundDocName
;
538 if ( nDoc
!= SC_DOC_NEW
)
540 ScDocShell
* pSh
= ScDocShell::GetShellByNum( nDoc
);
543 aFoundDocName
= pSh
->GetTitle();
544 if ( !pSh
->GetDocument()->IsDocEditable() )
546 ErrorMessage(STR_READONLYERR
);
551 rReq
.AppendItem( SfxStringItem( FID_TAB_MOVE
, aFoundDocName
) );
552 // Tabelle ist 1-basiert, wenn nicht APPEND
553 SCTAB nBasicTab
= ( nTab
<= MAXTAB
) ? (nTab
+1) : nTab
;
554 rReq
.AppendItem( SfxUInt16Item( FN_PARAM_1
, static_cast<sal_uInt16
>(nBasicTab
) ) );
555 rReq
.AppendItem( SfxBoolItem( FN_PARAM_2
, bCpy
) );
562 rReq
.Done(); // aufzeichnen, solange das Dokument noch aktiv ist
564 MoveTable( nDoc
, nTab
, bCpy
, &aTabName
);
569 case FID_DELETE_TABLE
:
571 // Parameter war ueberfluessig, weil die Methode an der Table haengt
573 sal_Bool bDoIt
= rReq
.IsAPI();
576 // wenn's nicht von Basic kommt, nochmal nachfragen:
579 QueryBox( GetDialogParent(),
580 WinBits( WB_YES_NO
| WB_DEF_YES
),
581 ScGlobal::GetRscString(STR_QUERY_DELTAB
)
586 SCTAB nNewTab
= nCurrentTab
;
589 ScMarkData
& rMark
= pViewData
->GetMarkData();
590 std::vector
<SCTAB
> TheTabs
;
591 for(SCTAB i
=0;i
<nTabCount
;i
++)
593 if(rMark
.GetTableSelect(i
) &&!pDoc
->IsTabProtected(i
))
595 TheTabs
.push_back(i
);
597 if(nNewTab
==i
) nNewTab
++;
599 if(!bTabFlag
) nFirstTab
=i
;
601 if(nNewTab
>=nTabCount
) nNewTab
=nFirstTab
;
603 pViewData
->SetTabNo(nNewTab
);
604 DeleteTables(TheTabs
);
613 ScDocShell
* pDocSh
= pViewData
->GetDocShell();
614 ScDocFunc
&rFunc
= pDocSh
->GetDocFunc();
615 sal_Bool bSet
= !pDoc
->IsLayoutRTL( nCurrentTab
);
617 const ScMarkData
& rMark
= pViewData
->GetMarkData();
618 if ( rMark
.GetSelectCount() != 0 )
620 // handle several sheets
622 ::svl::IUndoManager
* pUndoManager
= pDocSh
->GetUndoManager();
623 String aUndo
= ScGlobal::GetRscString( STR_UNDO_TAB_RTL
);
624 pUndoManager
->EnterListAction( aUndo
, aUndo
);
626 ScMarkData::const_iterator itr
= rMark
.begin(), itrEnd
= rMark
.end();
627 for (; itr
!= itrEnd
; ++itr
)
628 rFunc
.SetLayoutRTL( *itr
, bSet
, false );
630 pUndoManager
->LeaveListAction();
633 rFunc
.SetLayoutRTL( nCurrentTab
, bSet
, false );
637 case FID_TAB_TOGGLE_GRID
:
639 bool bShowGrid
= pViewData
->GetShowGrid();
640 pViewData
->SetShowGrid(!bShowGrid
);
641 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
642 rBindings
.Invalidate( FID_TAB_TOGGLE_GRID
);
648 case FID_TAB_SET_TAB_BG_COLOR
:
649 case FID_TAB_MENU_SET_TAB_BG_COLOR
:
651 if ( nSlot
== FID_TAB_MENU_SET_TAB_BG_COLOR
)
652 nSlot
= FID_TAB_SET_TAB_BG_COLOR
;
653 SCTAB nTabNr
= pViewData
->GetTabNo();
654 ScMarkData
& rMark
= pViewData
->GetMarkData();
655 SCTAB nTabSelCount
= rMark
.GetSelectCount();
656 if ( !pDoc
->IsDocEditable() )
659 if ( pDoc
->IsTabProtected( nTabNr
) ) // ||nTabSelCount > 1
662 if( pReqArgs
!= NULL
)
664 sal_Bool bDone
= false;
665 const SfxPoolItem
* pItem
;
667 if( pReqArgs
->HasItem( FN_PARAM_1
, &pItem
) )
668 nTabNr
= ((const SfxUInt16Item
*)pItem
)->GetValue();
670 if( pReqArgs
->HasItem( nSlot
, &pItem
) )
671 aColor
= ((const SvxColorItem
*)pItem
)->GetValue();
673 if ( nTabSelCount
> 1 )
675 scoped_ptr
<ScUndoTabColorInfo::List
>
676 pTabColorList(new ScUndoTabColorInfo::List
);
677 ScMarkData::iterator itr
= rMark
.begin(), itrEnd
= rMark
.end();
678 for (; itr
!= itrEnd
; ++itr
)
680 if ( !pDoc
->IsTabProtected(*itr
) )
682 ScUndoTabColorInfo
aTabColorInfo(*itr
);
683 aTabColorInfo
.maNewTabBgColor
= aColor
;
684 pTabColorList
->push_back(aTabColorInfo
);
687 bDone
= SetTabBgColor( *pTabColorList
);
691 bDone
= SetTabBgColor( aColor
, nCurrentTab
); //ScViewFunc.SetTabBgColor
695 rReq
.Done( *pReqArgs
);
700 sal_uInt16 nRet
= RET_OK
; /// temp
701 sal_Bool bDone
= false; /// temp
704 aTabBgColor
= pDoc
->GetTabBgColor( nCurrentTab
);
705 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
706 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
707 AbstractScTabBgColorDlg
* pDlg
= pFact
->CreateScTabBgColorDlg(
709 String(ScResId(SCSTR_SET_TAB_BG_COLOR
)),
710 String(ScResId(SCSTR_NO_TAB_BG_COLOR
)),
712 CMD_FID_TAB_SET_TAB_BG_COLOR
,
713 RID_SCDLG_TAB_BG_COLOR
);
714 while ( !bDone
&& nRet
== RET_OK
)
716 nRet
= pDlg
->Execute();
719 Color aSelectedColor
;
720 pDlg
->GetSelectedColor(aSelectedColor
);
721 scoped_ptr
<ScUndoTabColorInfo::List
>
722 pTabColorList(new ScUndoTabColorInfo::List
);
723 if ( nTabSelCount
> 1 )
725 ScMarkData::iterator itr
= rMark
.begin(), itrEnd
= rMark
.end();
726 for (; itr
!= itrEnd
; ++itr
)
728 if ( !pDoc
->IsTabProtected(*itr
) )
730 ScUndoTabColorInfo
aTabColorInfo(*itr
);
731 aTabColorInfo
.maNewTabBgColor
= aSelectedColor
;
732 pTabColorList
->push_back(aTabColorInfo
);
735 bDone
= SetTabBgColor( *pTabColorList
);
739 bDone
= SetTabBgColor( aSelectedColor
, nCurrentTab
); //ScViewFunc.SetTabBgColor
743 rReq
.AppendItem( SvxColorItem( aTabBgColor
, nSlot
) );
750 #ifndef DISABLE_SCRIPTING
751 StarBASIC::Error( SbERR_SETPROP_FAILED
);
764 ScDocShell
* pDocSh
= pViewData
->GetDocShell();
765 uno::Reference
<container::XNameReplace
> xEvents( new ScSheetEventsObj( pDocSh
, nCurrentTab
) );
766 uno::Reference
<frame::XFrame
> xFrame
= GetViewFrame()->GetFrame().GetFrameInterface();
767 SvxAbstractDialogFactory
* pDlgFactory
= SvxAbstractDialogFactory::Create();
770 std::auto_ptr
<VclAbstractDialog
> pDialog( pDlgFactory
->CreateSvxMacroAssignDlg(
771 GetDialogParent(), xFrame
, false, xEvents
, 0 ) );
772 if ( pDialog
.get() && pDialog
->Execute() == RET_OK
)
774 // the dialog modifies the settings directly
781 OSL_FAIL("Unbekannte Message bei ViewShell");
786 //------------------------------------------------------------------
788 void ScTabViewShell::GetStateTable( SfxItemSet
& rSet
)
790 ScViewData
* pViewData
= GetViewData();
791 ScDocument
* pDoc
= pViewData
->GetDocument();
792 ScDocShell
* pDocShell
= pViewData
->GetDocShell();
793 ScMarkData
& rMark
= GetViewData()->GetMarkData();
794 SCTAB nTab
= pViewData
->GetTabNo();
796 SCTAB nTabCount
= pDoc
->GetTableCount();
797 SCTAB nTabSelCount
= rMark
.GetSelectCount();
799 SfxWhichIter
aIter(rSet
);
800 sal_uInt16 nWhich
= aIter
.FirstWhich();
807 case FID_TABLE_VISIBLE
:
808 rSet
.Put( SfxBoolItem( nWhich
, pDoc
->IsVisible(nTab
) ));
814 // enable menu : check to make sure we won't hide all sheets. we need at least one visible at all times.
815 for ( SCTAB i
=0; i
< nTabCount
&& nVis
<nTabSelCount
+ 1; i
++ )
816 if (pDoc
->IsVisible(i
))
818 if ( nVis
<=nTabSelCount
|| !pDoc
->IsDocEditable() )
819 rSet
.DisableItem( nWhich
);
825 sal_Bool bHasHidden
= false;
826 for ( SCTAB i
=0; i
< nTabCount
&& !bHasHidden
; i
++ )
827 if (!pDoc
->IsVisible(i
))
828 bHasHidden
= sal_True
;
829 if ( !bHasHidden
|| pDoc
->IsDocProtected() || nTabSelCount
> 1 )
830 rSet
.DisableItem( nWhich
);
834 case FID_DELETE_TABLE
:
836 if ( pDoc
->GetChangeTrack() )
837 rSet
.DisableItem( nWhich
);
841 for ( SCTAB i
=0; i
< nTabCount
&& nVis
<2; i
++ )
842 if (pDoc
->IsVisible(i
))
844 if ( pDoc
->IsTabProtected(nTab
)
845 || !pDoc
->IsDocEditable()
847 || nTabSelCount
== nTabCount
)
848 rSet
.DisableItem( nWhich
);
854 case FID_INS_TABLE_EXT
:
856 if ( !pDoc
->IsDocEditable() ||
857 nTabCount
> MAXTAB
||
858 ( nWhich
== FID_INS_TABLE_EXT
&& pDocShell
&& pDocShell
->IsDocShared() ) )
859 rSet
.DisableItem( nWhich
);
863 if ( !pDoc
->IsDocEditable()
864 || pDoc
->GetChangeTrack() != NULL
865 || nTabCount
> MAXTAB
)
866 rSet
.DisableItem( nWhich
);
869 // FID_TAB_MENU_RENAME - "umbenennen" im Menu
870 // FID_TAB_RENAME - "Name"-Property fuer Basic
872 case FID_TAB_MENU_RENAME
:
873 if ( !pDoc
->IsDocEditable() ||
874 pDoc
->IsTabProtected(nTab
) ||nTabSelCount
> 1 ||
875 ( pDocShell
&& pDocShell
->IsDocShared() ) )
876 rSet
.DisableItem( nWhich
);
882 pDoc
->GetName( nTab
, aTabName
);
884 rSet
.Put( SfxStringItem( nWhich
, aTabName
));
891 SvtLanguageOptions aLangOpt
;
892 if ( !aLangOpt
.IsCTLFontEnabled() )
893 rSet
.DisableItem( nWhich
);
895 rSet
.Put( SfxBoolItem( nWhich
, pDoc
->IsLayoutRTL( nTab
) ) );
899 case FID_TAB_MENU_SET_TAB_BG_COLOR
:
901 if ( !pDoc
->IsDocEditable()
902 || ( pDocShell
&& pDocShell
->IsDocShared() )
903 || pDoc
->IsTabProtected(nTab
) )
904 rSet
.DisableItem( nWhich
);
908 case FID_TAB_SET_TAB_BG_COLOR
:
911 aColor
= pDoc
->GetTabBgColor( nTab
);
912 rSet
.Put( SvxColorItem( aColor
, nWhich
) );
916 case FID_TAB_TOGGLE_GRID
:
917 rSet
.Put( SfxBoolItem(nWhich
, pViewData
->GetShowGrid()) );
920 nWhich
= aIter
.NextWhich();
927 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */