20#include <config_features.h>
42#include <document.hxx>
68 sal_uInt16 nSlot = rReq.
GetSlot();
75 case FID_TABLE_VISIBLE:
81 if( pReqArgs !=
nullptr )
84 if( pReqArgs->
HasItem( FID_TABLE_VISIBLE, &pItem ) )
98 std::vector<OUString> rNames {
aName };
109 SCTAB nActiveTab = -1;
114 if( pReqArgs->
HasItem( FID_TABLE_HIDE, &pItem ) )
118 std::set<SCTAB>::iterator it = rMark.
GetSelectedTabs().find(nTabNumber);
134 std::vector<OUString> rNames;
138 if( pReqArgs->
HasItem( FID_TABLE_SHOW, &pItem ) )
141 rNames.push_back(
aName);
156 for (
SCTAB i=0;
i != nTabCount;
i++ )
161 pDlg->Insert( aTabName, bFirst );
166 std::shared_ptr<SfxRequest> pReq = std::make_shared<SfxRequest>(rReq);
167 pDlg->StartExecuteAsync([
this, pDlg, pReq](sal_Int32 nResult){
168 std::vector<OUString> sTables;
171 std::vector<sal_Int32> aSelectedRows = pDlg->GetSelectedRows();
172 for (
auto a : aSelectedRows)
174 OUString sTable = pDlg->GetEntry(
a);
176 sTables.push_back(sTable);
189 case FID_INS_TABLE_EXT:
193 SCTAB nTabNr = nCurrentTab;
198 if ( pReqArgs !=
nullptr )
204 if ( pReqArgs->
HasItem( FN_PARAM_1, &pTabItem ) &&
205 pReqArgs->
HasItem( nSlot, &pNameItem ) )
218 if (nTabNr > nTabCount)
225 rReq.
Done( *pReqArgs );
233 nTabSelCount, nSlot == FID_INS_TABLE_EXT));
234 if (
RET_OK == pDlg->Execute() )
236 if (pDlg->GetTablesFromFile())
238 std::vector<SCTAB> nTabs;
240 const OUString* pStr = pDlg->GetFirstTable( &
n );
243 nTabs.push_back(
static_cast<SCTAB>(
n) );
244 pStr = pDlg->GetNextTable( &
n );
246 bool bLink = pDlg->GetTablesAsLink();
249 if(pDlg->IsTableBefore())
251 ImportTables( pDlg->GetDocShellTables(), nTabs.size(), nTabs.data(),
256 SCTAB nTabAfter = nTabNr+1;
258 for(
SCTAB j=nCurrentTab+1;j<nTabCount;j++)
267 ImportTables( pDlg->GetDocShellTables(), nTabs.size(), nTabs.data(),
275 if(pDlg->IsTableBefore())
277 if(
nCount==1 && !pDlg->GetFirstTable()->isEmpty())
287 std::vector<OUString> aNames(0);
293 SCTAB nTabAfter = nTabNr+1;
296 for(
SCTAB j=nSelHigh+1;j<nTabCount;j++)
307 if(
nCount==1 && !pDlg->GetFirstTable()->isEmpty())
317 std::vector<OUString> aNames(0);
329 case FID_TAB_MENU_RENAME:
335 if ( nSlot == FID_TAB_MENU_RENAME )
336 nSlot = FID_TAB_RENAME;
345 if ( nSlot != FID_TAB_APPEND &&
349 if( pReqArgs !=
nullptr )
355 if( pReqArgs->
HasItem( FN_PARAM_1, &pItem ) )
364 if( pReqArgs->
HasItem( nSlot, &pItem ) )
379 rReq.
Done( *pReqArgs );
386 OUString aErrMsg (
ScResId( STR_INVALIDTABNAME ) );
394 aDlgTitle =
ScResId(SCSTR_APDTABLE);
400 aDlgTitle =
ScResId(SCSTR_RENAMETAB);
414 while ( !bDone && nRet ==
RET_OK )
416 nRet = pDlg->Execute();
420 aName = pDlg->GetInputString();
441#if HAVE_FEATURE_SCRIPTING
448 VclMessageType::Warning, VclButtonsType::Ok, aErrMsg));
466 bool bCpy =
false, bUseCurrentDocument =
false;
470 if( pReqArgs !=
nullptr )
476 if( pReqArgs->
HasItem( FN_PARAM_3, &pItem ) )
479 if (bUseCurrentDocument)
481 else if(pReqArgs->
HasItem( FID_TAB_MOVE, &pItem ))
484 if( pReqArgs->
HasItem( FN_PARAM_1, &pItem ) )
488 if ( nTab >= nTableCount )
491 if( pReqArgs->
HasItem( FN_PARAM_2, &pItem ) )
494 if (!aDocName.isEmpty())
528 if ( bDoIt && nTab >= nTableCount )
533 OUString aDefaultName;
545 if(nTableCount==nTabSelCount)
547 pDlg->SetForceCopyTable();
552 pDlg->EnableRenameTable(nTabSelCount == 1);
554 if ( pDlg->Execute() ==
RET_OK )
556 nDoc = pDlg->GetSelectedDocument();
557 nTab = pDlg->GetSelectedTable();
558 bCpy = pDlg->GetCopyTable();
559 bool bRna = pDlg->GetRenameTable();
563 pDlg->GetTabNameString( aTabName );
567 OUString aFoundDocName;
583 SCTAB nBasicTab = ( nTab <=
MAXTAB ) ? (nTab+1) : nTab;
593 MoveTable( nDoc, nTab, bCpy, &aTabName );
598 case FID_TAB_DUPLICATE:
634 case FID_DELETE_TABLE:
636 bool bHasIndex = (pReqArgs !=
nullptr);
639 SCTAB nTabNr = nCurrentTab;
643 if (pReqArgs->
HasItem(FID_DELETE_TABLE, &pItem))
653 bool bDoIt = bHasIndex;
656 bool bTabWithPivotTable =
false;
668 if (pSheetSourceDesc)
672 bool bTabOutSel =
false;
673 for (
const SCTAB nSelTab : rSelectedTabs)
675 if (nSelTab == nTabSource)
676 bTabWithPivotTable =
true;
677 if (nSelTab == nTabOut)
679 if (bTabWithPivotTable && bTabOutSel)
684 if (bTabWithPivotTable && bTabOutSel)
685 bTabWithPivotTable =
false;
686 if (bTabWithPivotTable)
695 OUString aQueryDeleteTab =
ScResId( STR_QUERY_DELTAB, nTabSelCnt )
696 .replaceAll(
"%d", aTabSelCnt );
697 if (bTabWithPivotTable)
699 OUString
aStr =
ScResId( STR_QUERY_PIVOTTABLE_DELTAB, nTabSelCnt )
700 .replaceAll(
"%d", aTabSelCnt )
701 +
" " + aQueryDeleteTab;
704 VclMessageType::Question, VclButtonsType::YesNo,
706 xQueryBox->set_default_response(
RET_NO);
709 bDoIt = (
RET_YES == xQueryBox->run());
713 bool bHasData =
false;
715 for (
SCTAB i = 0;
i < nTabCount && !bHasData;
i++ )
728 VclMessageType::Question, VclButtonsType::YesNo,
730 xQueryBox->set_default_response(
RET_YES);
733 bDoIt = (
RET_YES == xQueryBox->run());
742 SCTAB nNewTab = nCurrentTab;
743 std::vector<SCTAB> TheTabs;
748 TheTabs.push_back(nTabNr);
749 if (nNewTab > nTabNr && nNewTab > 0)
755 bool bTabFlag =
false;
757 for (
SCTAB i = 0;
i < nTabCount;
i++)
761 TheTabs.push_back(
i);
763 if (nNewTab ==
i &&
i+1 < nTabCount)
769 if (nNewTab >= nTabCount -
static_cast<SCTAB>(TheTabs.size()))
793 OUString aUndo =
ScResId( STR_UNDO_TAB_RTL );
796 for (
const auto& rTab : rMark)
806 case FID_TAB_TOGGLE_GRID:
819 case FID_TAB_SET_TAB_BG_COLOR:
820 case FID_TAB_MENU_SET_TAB_BG_COLOR:
822 if ( nSlot == FID_TAB_MENU_SET_TAB_BG_COLOR )
823 nSlot = FID_TAB_SET_TAB_BG_COLOR;
833 if( pReqArgs !=
nullptr )
839 if( pReqArgs->
HasItem( nSlot, &pItem ) )
842 if ( nTabSelCount > 1 )
844 std::unique_ptr<ScUndoTabColorInfo::List>
846 for (
const auto& rTab : rMark)
852 pTabColorList->push_back(aTabColorInfo);
863 rReq.
Done( *pReqArgs );
875 ScResId(SCSTR_SET_TAB_BG_COLOR),
876 ScResId(SCSTR_NO_TAB_BG_COLOR),
878 while ( !bDone && nRet ==
RET_OK )
880 nRet = pDlg->Execute();
883 Color aSelectedColor;
884 pDlg->GetSelectedColor(aSelectedColor);
885 std::unique_ptr<ScUndoTabColorInfo::List>
887 if ( nTabSelCount > 1 )
889 for (
const auto& rTab : rMark)
895 pTabColorList->push_back(aTabColorInfo);
914#if HAVE_FEATURE_SCRIPTING
928 uno::Reference<container::XNameReplace> xEvents(
new ScSheetEventsObj( pDocSh, nCurrentTab ) );
933 if ( pDialog->Execute() ==
RET_OK )
939 case FID_TOGGLEHIDDENCOLROW:
948 OSL_FAIL(
"unknown message for ViewShell");
972 case FID_TABLE_VISIBLE:
980 for (
SCTAB i=0;
i < nTabCount && nVis<nTabSelCount + 1;
i++ )
990 bool bHasHidden =
false;
991 for (
SCTAB i=0;
i < nTabCount && !bHasHidden;
i++ )
999 case FID_DELETE_TABLE:
1005 sal_uInt16 nVis = 0;
1006 for (
SCTAB i=0;
i < nTabCount && nVis<2;
i++ )
1012 || nTabSelCount == nTabCount)
1019 case FID_INS_TABLE_EXT:
1020 case FID_TAB_APPEND:
1023 ( nWhich == FID_INS_TABLE_EXT && pDocShell && pDocShell->
IsDocShared() ) )
1034 case FID_TAB_DUPLICATE:
1044 case FID_TAB_MENU_RENAME:
1051 case FID_TAB_RENAME:
1054 rDoc.
GetName( nTab, aTabName );
1070 case FID_TAB_MENU_SET_TAB_BG_COLOR:
1079 case FID_TAB_SET_TAB_BG_COLOR:
1086 case FID_TAB_TOGGLE_GRID:
const SCTAB SC_TAB_APPEND
const LocaleDataWrapper & GetUILocaleDataWrapper() const
static const AllSettings & GetSettings()
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
const OUString & GetValue() const
OUString getNum(sal_Int64 nNumber, sal_uInt16 nDecimals, bool bUseThousandSep=true, bool bTrailingZeros=true) const
virtual VclPtr< AbstractScShowTabDlg > CreateScShowTabDlg(weld::Window *pParent)=0
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< AbstractScStringInputDlg > CreateScStringInputDlg(weld::Window *pParent, const OUString &rTitle, const OUString &rEditTitle, const OUString &rDefault, const OUString &rHelpId, const OUString &rEditHelpId)=0
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
virtual VclPtr< AbstractScInsertTableDlg > CreateScInsertTableDlg(weld::Window *pParent, ScViewData &rViewData, SCTAB nTabCount, bool bFromFile)=0
SC_DLLPUBLIC size_t GetCount() const
const ScRange & GetOutRange() const
const ScSheetSourceDesc * GetSheetDesc() const
bool SetLayoutRTL(SCTAB nTab, bool bRTL)
Create before modifications of the document and destroy thereafter.
void SetDocumentModified()
const ScDocument & GetDocument() const
static ScDocShell * GetShellByNum(sal_uInt16 nDocNo)
virtual SfxUndoManager * GetUndoManager() override
SC_DLLPUBLIC bool IsScenario(SCTAB nTab) const
SC_DLLPUBLIC bool IsDocProtected() const
SC_DLLPUBLIC Color GetTabBgColor(SCTAB nTab) const
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
SC_DLLPUBLIC bool HasPivotTable() const
bool IsDocEditable() const
SC_DLLPUBLIC void CreateValidTabName(OUString &rName) const
SC_DLLPUBLIC bool IsVisible(SCTAB nTab) const
ScChangeTrack * GetChangeTrack() const
SC_DLLPUBLIC bool IsLayoutRTL(SCTAB nTab) const
SC_DLLPUBLIC bool GetDataStart(SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow) const
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
SC_DLLPUBLIC ScDPCollection * GetDPCollection()
SC_DLLPUBLIC SCTAB GetTableCount() const
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
void SelectOneTable(SCTAB nTab)
SCTAB GetLastSelected() const
bool GetTableSelect(SCTAB nTab) const
std::set< SCTAB > MarkedTabsType
SCTAB GetSelectCount() const
const MarkedTabsType & GetSelectedTabs() const
This class contains authoritative information on the internal reference used as the data source for d...
SC_DLLPUBLIC const ScRange & GetSourceRange() const
Get the range that contains the source data.
void ExecuteTable(SfxRequest &rReq)
void GetStateTable(SfxItemSet &rSet)
void ErrorMessage(TranslateId pGlobStrId)
ScViewData & GetViewData()
ScMarkData & GetMarkData()
void SetTabNo(SCTAB nNewTab)
ScDocument & GetDocument() const
ScDocShell * GetDocShell() const
ScTabViewShell * GetViewShell() const
void SetShowGrid(bool bShow)
bool AppendTable(const OUString &rName, bool bRecord=true)
bool DeleteTables(const std::vector< SCTAB > &TheTabs, bool bRecord=true)
bool SetTabBgColor(const Color &rColor, SCTAB nTabNr)
void ImportTables(ScDocShell *pSrcShell, SCTAB nCount, const SCTAB *pSrcTabs, bool bLink, SCTAB nTab)
void HideTable(const ScMarkData &rMark, SCTAB nTabToSelect=-1)
void ShowTable(const std::vector< OUString > &rNames)
void MoveTable(sal_uInt16 nDestDocNo, SCTAB nDestTab, bool bCopy, const OUString *pNewTabName=nullptr)
void InsertTables(std::vector< OUString > &aNames, SCTAB nTab, SCTAB nCount, bool bRecord=true)
bool RenameTable(const OUString &rName, SCTAB nTabNr)
bool InsertTable(const OUString &rName, SCTAB nTabNr, bool bRecord=true)
void Invalidate(sal_uInt16 nId)
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void DisableItem(sal_uInt16 nWhich)
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
OUString GetTitle(sal_uInt16 nMaxLen=0) const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
void AppendItem(const SfxPoolItem &)
void Done(bool bRemove=false)
static SfxInterface * GetStaticInterface()
virtual void EnterListAction(const OUString &rComment, const OUString &rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId)
SfxBindings & GetBindings()
SfxFrame & GetFrame() const
weld::Window * GetFrameWeld() const
ViewShellId GetViewShellId() const override
SfxViewFrame & GetViewFrame() const
static void Error(ErrCode, const OUString &rMsg={})
static bool IsCTLFontEnabled()
static SvxAbstractDialogFactory * Create()
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
constexpr OUStringLiteral HID_SC_APPEND_NAME
constexpr OUStringLiteral HID_SC_RENAME_NAME
#define ERRCODE_BASIC_SETPROP_FAILED
OUString ScResId(TranslateId aId)
::std::vector< ScUndoTabColorInfo > List
Reference< XFrame > xFrame