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
);
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
<OUString
> rNames
;
96 rNames
.push_back(aName
);
104 if ( pDoc
->IsDocEditable() )
106 ScMarkData
& rMark
= pViewData
->GetMarkData();
115 std::vector
<OUString
> 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 boost::scoped_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 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
);
166 case FID_INS_TABLE_EXT
:
168 ScMarkData
& rMark
= pViewData
->GetMarkData();
169 SCTAB nTabSelCount
= rMark
.GetSelectCount();
170 SCTAB nTabNr
= nCurrentTab
;
172 if ( !pDoc
->IsDocEditable() )
175 if ( pReqArgs
!= NULL
) // von Basic
178 const SfxPoolItem
* pTabItem
;
179 const SfxPoolItem
* pNameItem
;
182 if ( pReqArgs
->HasItem( FN_PARAM_1
, &pTabItem
) &&
183 pReqArgs
->HasItem( nSlot
, &pNameItem
) )
185 // Tabellennr. von Basic: 1-basiert
187 aName
= ((const SfxStringItem
*)pNameItem
)->GetValue();
188 nTabNr
= ((const SfxUInt16Item
*)pTabItem
)->GetValue() - 1;
189 if ( nTabNr
< nTabCount
)
190 bOk
= InsertTable( aName
, nTabNr
);
194 rReq
.Done( *pReqArgs
);
195 //! sonst Fehler setzen
199 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
200 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
202 boost::scoped_ptr
<AbstractScInsertTableDlg
> pDlg(pFact
->CreateScInsertTableDlg(GetDialogParent(), *pViewData
,
203 nTabSelCount
, nSlot
== FID_INS_TABLE_EXT
));
204 OSL_ENSURE(pDlg
, "Dialog create fail!");
205 if ( RET_OK
== pDlg
->Execute() )
207 if (pDlg
->GetTablesFromFile())
209 std::vector
<SCTAB
> nTabs
;
211 const OUString
* pStr
= pDlg
->GetFirstTable( &n
);
214 nTabs
.push_back( static_cast<SCTAB
>(n
) );
215 pStr
= pDlg
->GetNextTable( &n
);
217 bool bLink
= pDlg
->GetTablesAsLink();
220 if(pDlg
->IsTableBefore())
222 ImportTables( pDlg
->GetDocShellTables(), nTabs
.size(), &nTabs
[0],
227 SCTAB nTabAfter
= nTabNr
+1;
229 for(SCTAB j
=nCurrentTab
+1;j
<nTabCount
;j
++)
231 if(!pDoc
->IsScenario(j
))
238 ImportTables( pDlg
->GetDocShellTables(), nTabs
.size(), &nTabs
[0],
245 SCTAB nCount
=pDlg
->GetTableCount();
246 if(pDlg
->IsTableBefore())
248 if(nCount
==1 && !pDlg
->GetFirstTable()->isEmpty())
250 rReq
.AppendItem( SfxStringItem( FID_INS_TABLE
, *pDlg
->GetFirstTable() ) );
251 rReq
.AppendItem( SfxUInt16Item( FN_PARAM_1
, static_cast<sal_uInt16
>(nTabNr
) + 1 ) ); // 1-based
254 InsertTable( *pDlg
->GetFirstTable(), nTabNr
);
258 std::vector
<OUString
> aNames(0);
259 InsertTables( aNames
, nTabNr
,nCount
);
264 SCTAB nTabAfter
= nTabNr
+1;
265 SCTAB nSelHigh
= rMark
.GetLastSelected();
267 for(SCTAB j
=nSelHigh
+1;j
<nTabCount
;j
++)
269 if(!pDoc
->IsScenario(j
))
274 else // #101672#; increase nTabAfter, because it is possible that the scenario tables are the last
278 if(nCount
==1 && !pDlg
->GetFirstTable()->isEmpty())
280 rReq
.AppendItem( SfxStringItem( FID_INS_TABLE
, *pDlg
->GetFirstTable() ) );
281 rReq
.AppendItem( SfxUInt16Item( FN_PARAM_1
, static_cast<sal_uInt16
>(nTabAfter
) + 1 ) ); // 1-based
284 InsertTable( *pDlg
->GetFirstTable(), nTabAfter
);
288 std::vector
<OUString
> aNames(0);
289 InsertTables( aNames
, nTabAfter
,nCount
);
300 case FID_TAB_MENU_RENAME
:
302 // FID_TAB_MENU_RENAME - "umbenennen" im Menu
303 // FID_TAB_RENAME - "Name"-Property fuer Basic
304 // Execute ist gleich, aber im GetState wird MENU_RENAME evtl. disabled
306 if ( nSlot
== FID_TAB_MENU_RENAME
)
307 nSlot
= FID_TAB_RENAME
; // Execute ist gleich
309 SCTAB nTabNr
= pViewData
->GetTabNo();
310 ScMarkData
& rMark
= pViewData
->GetMarkData();
311 SCTAB nTabSelCount
= rMark
.GetSelectCount();
313 if ( !pDoc
->IsDocEditable() )
314 break; // alles gesperrt
316 if ( nSlot
!= FID_TAB_APPEND
&&
317 ( pDoc
->IsTabProtected( nTabNr
) || nTabSelCount
> 1 ) )
318 break; // kein Rename
320 if( pReqArgs
!= NULL
)
323 const SfxPoolItem
* pItem
;
326 if( pReqArgs
->HasItem( FN_PARAM_1
, &pItem
) )
327 nTabNr
= ((const SfxUInt16Item
*)pItem
)->GetValue();
329 if( pReqArgs
->HasItem( nSlot
, &pItem
) )
330 aName
= ((const SfxStringItem
*)pItem
)->GetValue();
335 bDone
= AppendTable( aName
);
338 bDone
= RenameTable( aName
, nTabNr
);
344 rReq
.Done( *pReqArgs
);
349 sal_uInt16 nRet
= RET_OK
;
351 OUString
aErrMsg ( ScGlobal::GetRscString( STR_INVALIDTABNAME
) );
354 const sal_Char
* pHelpId
= 0;
359 aDlgTitle
= OUString(ScResId(SCSTR_APDTABLE
));
360 pDoc
->CreateValidTabName( aName
);
361 pHelpId
= HID_SC_APPEND_NAME
;
365 aDlgTitle
= OUString(ScResId(SCSTR_RENAMETAB
));
366 pDoc
->GetName( pViewData
->GetTabNo(), aName
);
367 pHelpId
= HID_SC_RENAME_NAME
;
371 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
372 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
374 boost::scoped_ptr
<AbstractScStringInputDlg
> pDlg(pFact
->CreateScStringInputDlg(
375 GetDialogParent(), aDlgTitle
, OUString(ScResId(SCSTR_NAME
)),
376 aName
, GetStaticInterface()->GetSlot(nSlot
)->GetCommand(),
379 OSL_ENSURE(pDlg
, "Dialog create fail!");
381 while ( !bDone
&& nRet
== RET_OK
)
383 nRet
= pDlg
->Execute();
385 if ( nRet
== RET_OK
)
387 aName
= pDlg
->GetInputString();
393 bDone
= AppendTable( aName
);
396 bDone
= RenameTable( aName
, nTabNr
);
402 rReq
.AppendItem( SfxStringItem( nSlot
, aName
) );
409 #ifndef DISABLE_SCRIPTING
410 StarBASIC::Error( SbERR_SETPROP_FAILED
); // XXX Fehlerbehandlung???
415 nRet
= ErrorBox( GetDialogParent(),
416 WinBits( WB_OK
| WB_DEF_OK
),
429 if ( pDoc
->GetChangeTrack() != NULL
)
430 break; // bei aktiviertem ChangeTracking kein TabMove
434 SCTAB nTab
= pViewData
->GetTabNo();
439 if( pReqArgs
!= NULL
)
441 SCTAB nTableCount
= pDoc
->GetTableCount();
442 const SfxPoolItem
* pItem
;
444 if( pReqArgs
->HasItem( FID_TAB_MOVE
, &pItem
) )
445 aDocName
= ((const SfxStringItem
*)pItem
)->GetValue();
446 if( pReqArgs
->HasItem( FN_PARAM_1
, &pItem
) )
448 // Tabelle ist 1-basiert
449 nTab
= ((const SfxUInt16Item
*)pItem
)->GetValue() - 1;
450 if ( nTab
>= nTableCount
)
451 nTab
= SC_TAB_APPEND
;
453 if( pReqArgs
->HasItem( FN_PARAM_2
, &pItem
) )
454 bCpy
= ((const SfxBoolItem
*)pItem
)->GetValue();
456 if (!aDocName
.isEmpty())
458 SfxObjectShell
* pSh
= SfxObjectShell::GetFirst();
459 ScDocShell
* pScSh
= NULL
;
464 pScSh
= PTR_CAST( ScDocShell
, pSh
);
470 if (aDocName
.equals(pScSh
->GetTitle()))
473 ScDocument
* pDestDoc
= pScSh
->GetDocument();
474 nTableCount
= pDestDoc
->GetTableCount();
475 bDoIt
= pDestDoc
->IsDocEditable();
479 i
++; // nur die ScDocShell's zaehlen
481 pSh
= SfxObjectShell::GetNext( *pSh
);
484 else // Kein Dokumentname -> neues Dokument
490 if ( bDoIt
&& nTab
>= nTableCount
) // ggf. anhaengen
491 nTab
= SC_TAB_APPEND
;
495 OUString aDefaultName
;
496 pDoc
->GetName( pViewData
->GetTabNo(), aDefaultName
);
498 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
499 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
501 boost::scoped_ptr
<AbstractScMoveTableDlg
> pDlg(pFact
->CreateScMoveTableDlg(GetDialogParent(),
503 OSL_ENSURE(pDlg
, "Dialog create fail!");
505 SCTAB nTableCount
= pDoc
->GetTableCount();
506 ScMarkData
& rMark
= GetViewData()->GetMarkData();
507 SCTAB nTabSelCount
= rMark
.GetSelectCount();
510 if(nTableCount
==nTabSelCount
)
512 pDlg
->SetForceCopyTable();
515 // We support direct renaming of sheet only when one sheet
517 pDlg
->EnableRenameTable(nTabSelCount
== 1);
519 if ( pDlg
->Execute() == RET_OK
)
521 nDoc
= pDlg
->GetSelectedDocument();
522 nTab
= pDlg
->GetSelectedTable();
523 bCpy
= pDlg
->GetCopyTable();
524 bool bRna
= pDlg
->GetRenameTable();
525 // Leave aTabName string empty, when Rename is FALSE.
528 pDlg
->GetTabNameString( aTabName
);
532 OUString aFoundDocName
;
533 if ( nDoc
!= SC_DOC_NEW
)
535 ScDocShell
* pSh
= ScDocShell::GetShellByNum( nDoc
);
538 aFoundDocName
= pSh
->GetTitle();
539 if ( !pSh
->GetDocument()->IsDocEditable() )
541 ErrorMessage(STR_READONLYERR
);
546 rReq
.AppendItem( SfxStringItem( FID_TAB_MOVE
, aFoundDocName
) );
547 // Tabelle ist 1-basiert, wenn nicht APPEND
548 SCTAB nBasicTab
= ( nTab
<= MAXTAB
) ? (nTab
+1) : nTab
;
549 rReq
.AppendItem( SfxUInt16Item( FN_PARAM_1
, static_cast<sal_uInt16
>(nBasicTab
) ) );
550 rReq
.AppendItem( SfxBoolItem( FN_PARAM_2
, bCpy
) );
556 rReq
.Done(); // aufzeichnen, solange das Dokument noch aktiv ist
558 MoveTable( nDoc
, nTab
, bCpy
, &aTabName
);
563 case FID_DELETE_TABLE
:
565 // Parameter war ueberfluessig, weil die Methode an der Table haengt
567 bool bDoIt
= rReq
.IsAPI();
570 // wenn's nicht von Basic kommt, nochmal nachfragen:
573 QueryBox( GetDialogParent(),
574 WinBits( WB_YES_NO
| WB_DEF_YES
),
575 ScGlobal::GetRscString(STR_QUERY_DELTAB
)
580 SCTAB nNewTab
= nCurrentTab
;
583 ScMarkData
& rMark
= pViewData
->GetMarkData();
584 std::vector
<SCTAB
> TheTabs
;
585 for(SCTAB i
=0;i
<nTabCount
;i
++)
587 if(rMark
.GetTableSelect(i
) &&!pDoc
->IsTabProtected(i
))
589 TheTabs
.push_back(i
);
591 if(nNewTab
==i
) nNewTab
++;
593 if(!bTabFlag
) nFirstTab
=i
;
595 if(nNewTab
>=nTabCount
) nNewTab
=nFirstTab
;
597 pViewData
->SetTabNo(nNewTab
);
598 DeleteTables(TheTabs
);
607 ScDocShell
* pDocSh
= pViewData
->GetDocShell();
608 ScDocFunc
&rFunc
= pDocSh
->GetDocFunc();
609 bool bSet
= !pDoc
->IsLayoutRTL( nCurrentTab
);
611 const ScMarkData
& rMark
= pViewData
->GetMarkData();
612 if ( rMark
.GetSelectCount() != 0 )
614 // handle several sheets
616 ::svl::IUndoManager
* pUndoManager
= pDocSh
->GetUndoManager();
617 OUString aUndo
= ScGlobal::GetRscString( STR_UNDO_TAB_RTL
);
618 pUndoManager
->EnterListAction( aUndo
, aUndo
);
620 ScMarkData::const_iterator itr
= rMark
.begin(), itrEnd
= rMark
.end();
621 for (; itr
!= itrEnd
; ++itr
)
622 rFunc
.SetLayoutRTL( *itr
, bSet
, false );
624 pUndoManager
->LeaveListAction();
627 rFunc
.SetLayoutRTL( nCurrentTab
, bSet
, false );
631 case FID_TAB_TOGGLE_GRID
:
633 bool bShowGrid
= pViewData
->GetShowGrid();
634 pViewData
->SetShowGrid(!bShowGrid
);
635 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
636 rBindings
.Invalidate( FID_TAB_TOGGLE_GRID
);
642 case FID_TAB_SET_TAB_BG_COLOR
:
643 case FID_TAB_MENU_SET_TAB_BG_COLOR
:
645 if ( nSlot
== FID_TAB_MENU_SET_TAB_BG_COLOR
)
646 nSlot
= FID_TAB_SET_TAB_BG_COLOR
;
647 SCTAB nTabNr
= pViewData
->GetTabNo();
648 ScMarkData
& rMark
= pViewData
->GetMarkData();
649 SCTAB nTabSelCount
= rMark
.GetSelectCount();
650 if ( !pDoc
->IsDocEditable() )
653 if ( pDoc
->IsTabProtected( nTabNr
) ) // ||nTabSelCount > 1
656 if( pReqArgs
!= NULL
)
659 const SfxPoolItem
* pItem
;
661 if( pReqArgs
->HasItem( FN_PARAM_1
, &pItem
) )
662 nTabNr
= ((const SfxUInt16Item
*)pItem
)->GetValue();
664 if( pReqArgs
->HasItem( nSlot
, &pItem
) )
665 aColor
= ((const SvxColorItem
*)pItem
)->GetValue();
667 if ( nTabSelCount
> 1 )
669 scoped_ptr
<ScUndoTabColorInfo::List
>
670 pTabColorList(new ScUndoTabColorInfo::List
);
671 ScMarkData::iterator itr
= rMark
.begin(), itrEnd
= rMark
.end();
672 for (; itr
!= itrEnd
; ++itr
)
674 if ( !pDoc
->IsTabProtected(*itr
) )
676 ScUndoTabColorInfo
aTabColorInfo(*itr
);
677 aTabColorInfo
.maNewTabBgColor
= aColor
;
678 pTabColorList
->push_back(aTabColorInfo
);
681 bDone
= SetTabBgColor( *pTabColorList
);
685 bDone
= SetTabBgColor( aColor
, nCurrentTab
); //ScViewFunc.SetTabBgColor
689 rReq
.Done( *pReqArgs
);
694 sal_uInt16 nRet
= RET_OK
; /// temp
695 bool bDone
= false; /// temp
698 aTabBgColor
= pDoc
->GetTabBgColor( nCurrentTab
);
699 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
700 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
701 boost::scoped_ptr
<AbstractScTabBgColorDlg
> pDlg(pFact
->CreateScTabBgColorDlg(
703 OUString(ScResId(SCSTR_SET_TAB_BG_COLOR
)),
704 OUString(ScResId(SCSTR_NO_TAB_BG_COLOR
)),
706 CMD_FID_TAB_SET_TAB_BG_COLOR
));
707 while ( !bDone
&& nRet
== RET_OK
)
709 nRet
= pDlg
->Execute();
712 Color aSelectedColor
;
713 pDlg
->GetSelectedColor(aSelectedColor
);
714 scoped_ptr
<ScUndoTabColorInfo::List
>
715 pTabColorList(new ScUndoTabColorInfo::List
);
716 if ( nTabSelCount
> 1 )
718 ScMarkData::iterator itr
= rMark
.begin(), itrEnd
= rMark
.end();
719 for (; itr
!= itrEnd
; ++itr
)
721 if ( !pDoc
->IsTabProtected(*itr
) )
723 ScUndoTabColorInfo
aTabColorInfo(*itr
);
724 aTabColorInfo
.maNewTabBgColor
= aSelectedColor
;
725 pTabColorList
->push_back(aTabColorInfo
);
728 bDone
= SetTabBgColor( *pTabColorList
);
732 bDone
= SetTabBgColor( aSelectedColor
, nCurrentTab
); //ScViewFunc.SetTabBgColor
736 rReq
.AppendItem( SvxColorItem( aTabBgColor
, nSlot
) );
743 #ifndef DISABLE_SCRIPTING
744 StarBASIC::Error( SbERR_SETPROP_FAILED
);
756 ScDocShell
* pDocSh
= pViewData
->GetDocShell();
757 uno::Reference
<container::XNameReplace
> xEvents( new ScSheetEventsObj( pDocSh
, nCurrentTab
) );
758 uno::Reference
<frame::XFrame
> xFrame
= GetViewFrame()->GetFrame().GetFrameInterface();
759 SvxAbstractDialogFactory
* pDlgFactory
= SvxAbstractDialogFactory::Create();
762 boost::scoped_ptr
<VclAbstractDialog
> pDialog( pDlgFactory
->CreateSvxMacroAssignDlg(
763 GetDialogParent(), xFrame
, false, xEvents
, 0 ) );
764 if ( pDialog
.get() && pDialog
->Execute() == RET_OK
)
766 // the dialog modifies the settings directly
773 OSL_FAIL("Unbekannte Message bei ViewShell");
778 void ScTabViewShell::GetStateTable( SfxItemSet
& rSet
)
780 ScViewData
* pViewData
= GetViewData();
781 ScDocument
* pDoc
= pViewData
->GetDocument();
782 ScDocShell
* pDocShell
= pViewData
->GetDocShell();
783 ScMarkData
& rMark
= GetViewData()->GetMarkData();
784 SCTAB nTab
= pViewData
->GetTabNo();
786 SCTAB nTabCount
= pDoc
->GetTableCount();
787 SCTAB nTabSelCount
= rMark
.GetSelectCount();
789 SfxWhichIter
aIter(rSet
);
790 sal_uInt16 nWhich
= aIter
.FirstWhich();
797 case FID_TABLE_VISIBLE
:
798 rSet
.Put( SfxBoolItem( nWhich
, pDoc
->IsVisible(nTab
) ));
804 // enable menu : check to make sure we won't hide all sheets. we need at least one visible at all times.
805 for ( SCTAB i
=0; i
< nTabCount
&& nVis
<nTabSelCount
+ 1; i
++ )
806 if (pDoc
->IsVisible(i
))
808 if ( nVis
<=nTabSelCount
|| !pDoc
->IsDocEditable() )
809 rSet
.DisableItem( nWhich
);
815 bool bHasHidden
= false;
816 for ( SCTAB i
=0; i
< nTabCount
&& !bHasHidden
; i
++ )
817 if (!pDoc
->IsVisible(i
))
819 if ( !bHasHidden
|| pDoc
->IsDocProtected() || nTabSelCount
> 1 )
820 rSet
.DisableItem( nWhich
);
824 case FID_DELETE_TABLE
:
826 if ( pDoc
->GetChangeTrack() )
827 rSet
.DisableItem( nWhich
);
831 for ( SCTAB i
=0; i
< nTabCount
&& nVis
<2; i
++ )
832 if (pDoc
->IsVisible(i
))
834 if ( pDoc
->IsTabProtected(nTab
)
835 || !pDoc
->IsDocEditable()
837 || nTabSelCount
== nTabCount
)
838 rSet
.DisableItem( nWhich
);
844 case FID_INS_TABLE_EXT
:
846 if ( !pDoc
->IsDocEditable() ||
847 nTabCount
> MAXTAB
||
848 ( nWhich
== FID_INS_TABLE_EXT
&& pDocShell
&& pDocShell
->IsDocShared() ) )
849 rSet
.DisableItem( nWhich
);
853 if ( !pDoc
->IsDocEditable()
854 || pDoc
->GetChangeTrack() != NULL
855 || nTabCount
> MAXTAB
)
856 rSet
.DisableItem( nWhich
);
859 // FID_TAB_MENU_RENAME - "umbenennen" im Menu
860 // FID_TAB_RENAME - "Name"-Property fuer Basic
862 case FID_TAB_MENU_RENAME
:
863 if ( !pDoc
->IsDocEditable() ||
864 pDoc
->IsTabProtected(nTab
) ||nTabSelCount
> 1 ||
865 ( pDocShell
&& pDocShell
->IsDocShared() ) )
866 rSet
.DisableItem( nWhich
);
872 pDoc
->GetName( nTab
, aTabName
);
874 rSet
.Put( SfxStringItem( nWhich
, aTabName
));
881 SvtLanguageOptions aLangOpt
;
882 if ( !aLangOpt
.IsCTLFontEnabled() )
883 rSet
.DisableItem( nWhich
);
885 rSet
.Put( SfxBoolItem( nWhich
, pDoc
->IsLayoutRTL( nTab
) ) );
889 case FID_TAB_MENU_SET_TAB_BG_COLOR
:
891 if ( !pDoc
->IsDocEditable()
892 || ( pDocShell
&& pDocShell
->IsDocShared() )
893 || pDoc
->IsTabProtected(nTab
) )
894 rSet
.DisableItem( nWhich
);
898 case FID_TAB_SET_TAB_BG_COLOR
:
901 aColor
= pDoc
->GetTabBgColor( nTab
);
902 rSet
.Put( SvxColorItem( aColor
, nWhich
) );
906 case FID_TAB_TOGGLE_GRID
:
907 rSet
.Put( SfxBoolItem(nWhich
, pViewData
->GetShowGrid()) );
910 nWhich
= aIter
.NextWhich();
915 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */