20 #include <config_features.h>
42 #include <document.hxx>
44 #include <globstr.hrc>
45 #include <strings.hrc>
46 #include <docfunc.hxx>
58 using std::unique_ptr;
68 sal_uInt16 nSlot = rReq.
GetSlot();
75 case FID_TABLE_VISIBLE:
78 rDoc.
GetName( nCurrentTab, aName );
81 if( pReqArgs !=
nullptr )
84 if( pReqArgs->
HasItem( FID_TABLE_VISIBLE, &pItem ) )
85 bVisible = static_cast<const SfxBoolItem*>(pItem)->GetValue();
98 std::vector<OUString> rNames;
99 rNames.push_back(aName);
110 SCTAB nActiveTab = -1;
115 if( pReqArgs->
HasItem( FID_TABLE_HIDE, &pItem ) )
119 std::set<SCTAB>::iterator it = rMark.
GetSelectedTabs().find(nTabNumber);
123 nActiveTab = GetViewData().GetTabNo();
128 HideTable( rMark, nActiveTab );
135 std::vector<OUString> rNames;
139 if( pReqArgs->
HasItem( FID_TABLE_SHOW, &pItem ) )
142 rNames.push_back(aName);
157 for (
SCTAB i=0;
i != nTabCount;
i++ )
162 pDlg->Insert( aTabName, bFirst );
167 std::shared_ptr<SfxRequest> pReq = std::make_shared<SfxRequest>(rReq);
168 pDlg->StartExecuteAsync([
this, pDlg, pReq](sal_Int32 nResult){
169 std::vector<OUString> sTables;
172 std::vector<sal_Int32> aSelectedRows = pDlg->GetSelectedRows();
173 for (
auto a : aSelectedRows)
175 OUString sTable = pDlg->GetEntry(
a);
177 sTables.push_back(sTable);
179 ShowTable( sTables );
190 case FID_INS_TABLE_EXT:
194 SCTAB nTabNr = nCurrentTab;
199 if ( pReqArgs !=
nullptr )
205 if ( pReqArgs->
HasItem( FN_PARAM_1, &pTabItem ) &&
206 pReqArgs->
HasItem( nSlot, &pNameItem ) )
219 if (nTabNr > nTabCount)
222 bOk = InsertTable(aName, nTabNr);
226 rReq.
Done( *pReqArgs );
234 nTabSelCount, nSlot == FID_INS_TABLE_EXT));
235 if (
RET_OK == pDlg->Execute() )
237 if (pDlg->GetTablesFromFile())
239 std::vector<SCTAB> nTabs;
241 const OUString* pStr = pDlg->GetFirstTable( &n );
244 nTabs.push_back( static_cast<SCTAB>(n) );
245 pStr = pDlg->GetNextTable( &n );
247 bool bLink = pDlg->GetTablesAsLink();
250 if(pDlg->IsTableBefore())
252 ImportTables( pDlg->GetDocShellTables(), nTabs.size(), nTabs.data(),
257 SCTAB nTabAfter = nTabNr+1;
259 for(
SCTAB j=nCurrentTab+1;j<nTabCount;j++)
268 ImportTables( pDlg->GetDocShellTables(), nTabs.size(), nTabs.data(),
276 if(pDlg->IsTableBefore())
278 if(nCount==1 && !pDlg->GetFirstTable()->isEmpty())
284 InsertTable( *pDlg->GetFirstTable(), nTabNr );
288 std::vector<OUString> aNames(0);
289 InsertTables( aNames, nTabNr,nCount );
294 SCTAB nTabAfter = nTabNr+1;
297 for(
SCTAB j=nSelHigh+1;j<nTabCount;j++)
308 if(nCount==1 && !pDlg->GetFirstTable()->isEmpty())
314 InsertTable( *pDlg->GetFirstTable(), nTabAfter);
318 std::vector<OUString> aNames(0);
319 InsertTables( aNames, nTabAfter,nCount);
330 case FID_TAB_MENU_RENAME:
336 if ( nSlot == FID_TAB_MENU_RENAME )
337 nSlot = FID_TAB_RENAME;
346 if ( nSlot != FID_TAB_APPEND &&
350 if( pReqArgs !=
nullptr )
356 if( pReqArgs->
HasItem( FN_PARAM_1, &pItem ) )
365 if( pReqArgs->
HasItem( nSlot, &pItem ) )
366 aName = static_cast<const SfxStringItem*>(pItem)->GetValue();
371 bDone = AppendTable( aName );
374 bDone = RenameTable( aName, nTabNr );
380 rReq.
Done( *pReqArgs );
387 OUString aErrMsg (
ScResId( STR_INVALIDTABNAME ) );
390 const char* pHelpId =
nullptr;
395 aDlgTitle =
ScResId(SCSTR_APDTABLE);
401 aDlgTitle =
ScResId(SCSTR_RENAMETAB);
411 aName, GetStaticInterface()->GetSlot(nSlot)->GetCommand(),
415 while ( !bDone && nRet ==
RET_OK )
417 nRet = pDlg->Execute();
421 aName = pDlg->GetInputString();
426 bDone = AppendTable( aName );
429 bDone = RenameTable( aName, nTabNr );
442 #if HAVE_FEATURE_SCRIPTING
449 VclMessageType::Warning, VclButtonsType::Ok, aErrMsg));
467 bool bCpy =
false, bUseCurrentDocument =
false;
471 if( pReqArgs !=
nullptr )
477 if( pReqArgs->
HasItem( FN_PARAM_3, &pItem ) )
478 bUseCurrentDocument = static_cast<const SfxBoolItem*>(pItem)->GetValue();
480 if (bUseCurrentDocument)
481 aDocName = GetViewData().GetDocShell()->GetTitle();
482 else if(pReqArgs->
HasItem( FID_TAB_MOVE, &pItem ))
483 aDocName = static_cast<const SfxStringItem*>(pItem)->GetValue();
485 if( pReqArgs->
HasItem( FN_PARAM_1, &pItem ) )
489 if ( nTab >= nTableCount )
492 if( pReqArgs->
HasItem( FN_PARAM_2, &pItem ) )
493 bCpy = static_cast<const SfxBoolItem*>(pItem)->GetValue();
495 if (!aDocName.isEmpty())
529 if ( bDoIt && nTab >= nTableCount )
534 OUString aDefaultName;
543 ScMarkData& rMark = GetViewData().GetMarkData();
546 if(nTableCount==nTabSelCount)
548 pDlg->SetForceCopyTable();
553 pDlg->EnableRenameTable(nTabSelCount == 1);
555 if ( pDlg->Execute() ==
RET_OK )
557 nDoc = pDlg->GetSelectedDocument();
558 nTab = pDlg->GetSelectedTable();
559 bCpy = pDlg->GetCopyTable();
560 bool bRna = pDlg->GetRenameTable();
564 pDlg->GetTabNameString( aTabName );
568 OUString aFoundDocName;
577 ErrorMessage(STR_READONLYERR);
584 SCTAB nBasicTab = ( nTab <=
MAXTAB ) ? (nTab+1) : nTab;
594 MoveTable( nDoc, nTab, bCpy, &aTabName );
599 case FID_DELETE_TABLE:
601 bool bHasIndex = (pReqArgs !=
nullptr);
604 SCTAB nTabNr = nCurrentTab;
608 if (pReqArgs->
HasItem(FID_DELETE_TABLE, &pItem))
618 bool bDoIt = bHasIndex;
621 bool bTabWithPivotTable =
false;
628 for (
const SCTAB nSelTab : rSelectedTabs)
631 for (
size_t i = 0;
i < nCount; ++
i)
636 bTabWithPivotTable =
true;
638 if (bTabWithPivotTable)
644 if (bTabWithPivotTable)
647 VclMessageType::Question, VclButtonsType::YesNo,
648 ScResId(STR_QUERY_PIVOTTABLE_DELTAB)));
649 xQueryBox->set_default_response(
RET_NO);
652 bDoIt = (
RET_YES == xQueryBox->run());
657 VclMessageType::Question, VclButtonsType::YesNo,
659 xQueryBox->set_default_response(
RET_YES);
662 bDoIt = (
RET_YES == xQueryBox->run());
668 SCTAB nNewTab = nCurrentTab;
669 std::vector<SCTAB> TheTabs;
674 TheTabs.push_back(nTabNr);
675 if (nNewTab > nTabNr && nNewTab > 0)
681 bool bTabFlag =
false;
683 for (
SCTAB i = 0;
i < nTabCount;
i++)
687 TheTabs.push_back(
i);
689 if (nNewTab ==
i &&
i+1 < nTabCount)
695 if (nNewTab >= nTabCount - static_cast<SCTAB>(TheTabs.size()))
700 DeleteTables(TheTabs);
719 OUString aUndo =
ScResId( STR_UNDO_TAB_RTL );
722 for (
const auto& rTab : rMark)
732 case FID_TAB_TOGGLE_GRID:
736 SfxBindings& rBindings = GetViewFrame()->GetBindings();
743 case FID_TAB_SET_TAB_BG_COLOR:
744 case FID_TAB_MENU_SET_TAB_BG_COLOR:
746 if ( nSlot == FID_TAB_MENU_SET_TAB_BG_COLOR )
747 nSlot = FID_TAB_SET_TAB_BG_COLOR;
757 if( pReqArgs !=
nullptr )
763 if( pReqArgs->
HasItem( nSlot, &pItem ) )
764 aColor = static_cast<const SvxColorItem*>(pItem)->GetValue();
766 if ( nTabSelCount > 1 )
768 std::unique_ptr<ScUndoTabColorInfo::List>
770 for (
const auto& rTab : rMark)
776 pTabColorList->push_back(aTabColorInfo);
779 bDone = SetTabBgColor( *pTabColorList );
783 bDone = SetTabBgColor( aColor, nCurrentTab );
787 rReq.
Done( *pReqArgs );
799 ScResId(SCSTR_SET_TAB_BG_COLOR),
800 ScResId(SCSTR_NO_TAB_BG_COLOR),
802 while ( !bDone && nRet ==
RET_OK )
804 nRet = pDlg->Execute();
807 Color aSelectedColor;
808 pDlg->GetSelectedColor(aSelectedColor);
809 std::unique_ptr<ScUndoTabColorInfo::List>
811 if ( nTabSelCount > 1 )
813 for (
const auto& rTab : rMark)
819 pTabColorList->push_back(aTabColorInfo);
822 bDone = SetTabBgColor( *pTabColorList );
826 bDone = SetTabBgColor( aSelectedColor, nCurrentTab );
838 #if HAVE_FEATURE_SCRIPTING
852 uno::Reference<container::XNameReplace> xEvents(
new ScSheetEventsObj( pDocSh, nCurrentTab ) );
853 uno::Reference<frame::XFrame>
xFrame = GetViewFrame()->GetFrame().GetFrameInterface();
857 if ( pDialog->Execute() ==
RET_OK )
865 OSL_FAIL(
"unknown message for ViewShell");
875 ScMarkData& rMark = GetViewData().GetMarkData();
889 case FID_TABLE_VISIBLE:
897 for (
SCTAB i=0;
i < nTabCount && nVis<nTabSelCount + 1;
i++ )
907 bool bHasHidden =
false;
908 for (
SCTAB i=0;
i < nTabCount && !bHasHidden;
i++ )
916 case FID_DELETE_TABLE:
923 for (
SCTAB i=0;
i < nTabCount && nVis<2;
i++ )
929 || nTabSelCount == nTabCount)
936 case FID_INS_TABLE_EXT:
940 ( nWhich == FID_INS_TABLE_EXT && pDocShell && pDocShell->
IsDocShared() ) )
954 case FID_TAB_MENU_RENAME:
964 rDoc.
GetName( nTab, aTabName );
981 case FID_TAB_MENU_SET_TAB_BG_COLOR:
990 case FID_TAB_SET_TAB_BG_COLOR:
997 case FID_TAB_TOGGLE_GRID:
SC_DLLPUBLIC bool IsDocProtected() const
ScMarkData & GetMarkData()
#define HID_SC_APPEND_NAME
ScDocShell * GetDocShell() const
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
SC_DLLPUBLIC size_t GetCount() const
OUString GetTitle(sal_uInt16 nMaxLen=0) const
static SvxAbstractDialogFactory * Create()
Reference< XFrame > xFrame
virtual VclPtr< AbstractScStringInputDlg > CreateScStringInputDlg(weld::Window *pParent, const OUString &rTitle, const OUString &rEditTitle, const OUString &rDefault, const OString &rHelpId, const OString &rEditHelpId)=0
SC_DLLPUBLIC ScDPCollection * GetDPCollection()
virtual VclPtr< AbstractScInsertTableDlg > CreateScInsertTableDlg(weld::Window *pParent, ScViewData &rViewData, SCTAB nTabCount, bool bFromFile)=0
void Done(bool bRemove=false)
ScDocument & GetDocument() const
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
const MarkedTabsType & GetSelectedTabs() const
virtual SfxUndoManager * GetUndoManager() override
#define ERRCODE_BASIC_SETPROP_FAILED
SC_DLLPUBLIC SCTAB GetTableCount() const
SCTAB GetSelectCount() const
SC_DLLPUBLIC const ScRange & GetSourceRange() const
Get the range that contains the source data.
ScChangeTrack * GetChangeTrack() const
ScTabViewShell * GetViewShell() const
void SetTabNo(SCTAB nNewTab)
const SCTAB SC_TAB_APPEND
SC_DLLPUBLIC bool HasPivotTable() const
virtual VclPtr< AbstractScMoveTableDlg > CreateScMoveTableDlg(weld::Window *pParent, const OUString &rDefault)=0
virtual VclPtr< AbstractScTabBgColorDlg > CreateScTabBgColorDlg(weld::Window *pParent, const OUString &rTitle, const OUString &rTabBgColorNoColorText, const Color &rDefaultColor)=0
virtual VclPtr< AbstractScShowTabDlg > CreateScShowTabDlg(weld::Window *pParent)=0
SC_DLLPUBLIC void CreateValidTabName(OUString &rName) const
void SelectOneTable(SCTAB nTab)
OUString ScResId(const char *pId)
void GetStateTable(SfxItemSet &rSet)
virtual VclPtr< VclAbstractDialog > CreateSvxMacroAssignDlg(weld::Window *_pParent, const css::uno::Reference< css::frame::XFrame > &_rxDocumentFrame, const bool _bUnoDialogMode, const css::uno::Reference< css::container::XNameReplace > &_rxEvents, const sal_uInt16 _nInitiallySelectedEvent)=0
static ScDocShell * GetShellByNum(sal_uInt16 nDocNo)
#define HID_SC_RENAME_NAME
SC_DLLPUBLIC Color GetTabBgColor(SCTAB nTab) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
static void Error(ErrCode)
bool SetLayoutRTL(SCTAB nTab, bool bRTL)
void DisableItem(sal_uInt16 nWhich)
SC_DLLPUBLIC bool IsScenario(SCTAB nTab) const
static SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
bool IsDocEditable() const
bool IsCTLFontEnabled() const
SCTAB GetLastSelected() const
const ScSheetSourceDesc * GetSheetDesc() const
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
virtual void EnterListAction(const OUString &rComment, const OUString &rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId)
const ScDocument & GetDocument() const
void ExecuteTable(SfxRequest &rReq)
SC_DLLPUBLIC bool IsLayoutRTL(SCTAB nTab) const
SC_DLLPUBLIC bool IsVisible(SCTAB nTab) const
void AppendItem(const SfxPoolItem &)
void SetShowGrid(bool bShow)
static SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
bool GetTableSelect(SCTAB nTab) const
std::set< SCTAB > MarkedTabsType
This class contains authoritative information on the internal reference used as the data source for d...
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
::std::vector< ScUndoTabColorInfo > List
ViewShellId GetViewShellId() const override