25 #include <osl/diagnose.h>
32 #include <com/sun/star/script/vba/XVBACompatibility.hpp>
36 #include <globstr.hrc>
47 #include <progress.hxx>
52 #include <uiitems.hxx>
59 using com::sun::star::script::XLibraryContainer;
60 using com::sun::star::script::vba::XVBACompatibility;
61 using com::sun::star::container::XNameContainer;
63 using com::sun::star::uno::UNO_QUERY;
65 using ::std::unique_ptr;
76 bool bFocus = pParent && pParent->
has_focus();
78 if (pGlobStrId && strcmp(pGlobStrId, STR_PROTECTIONERR) == 0)
82 pGlobStrId = STR_READONLYERR;
87 VclMessageType::Info, VclButtonsType::Ok,
120 SCCOL nStartCol = nCol;
121 SCROW nStartRow = nRow;
122 SCTAB nStartTab = nTab;
136 bool bUseThis =
false;
146 pData->
GetArea( nDummy, nOldCol1,nOldRow1, nOldCol2,nOldRow2 );
169 if ( nOldCol1 != nStartCol || nOldCol2 != nEndCol || nOldRow1 != nStartRow )
171 else if ( nOldRow2 != nEndRow )
174 pData->
SetArea( nTab, nOldCol1,nOldRow1, nOldCol2,nEndRow );
180 if ( nOldCol1 == nStartCol && nOldRow1 == nStartRow &&
181 nOldCol2 == nEndCol && nOldRow2 == nEndRow )
195 pData->
GetArea( nStartTab, nStartCol,nStartRow, nEndCol,nEndRow );
229 bool bSheetLocal =
true;
237 nTab, nStartCol, nStartRow, nEndCol, nEndRow,
true, bHasHeader) ) );
263 pNoNameData->
GetArea( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 );
269 if (!bHasHeader && pNoNameData->
HasHeader() && nTab == nOldTab && nStartRow == nOldY1 &&
270 nStartCol <= nOldY2 && nOldY1 <= nEndCol)
282 pNoNameData->
SetArea( nTab, nStartCol,nStartRow, nEndCol,nEndRow );
289 std::unique_ptr<ScDBCollection> pUndoColl;
296 OUString aImport =
ScResId( STR_DBNAME_IMPORT );
304 aNewName = aImport + OUString::number( nCount );
308 pNoNameData =
new ScDBData( aNewName, nTab,
309 nStartCol,nStartRow, nEndCol,nEndRow,
311 bool ins = rDBs.
insert(std::unique_ptr<ScDBData>(pNoNameData));
317 nStartCol,nStartRow, nEndCol,nEndRow,
327 std::move(pUndoColl),
328 std::make_unique<ScDBCollection>( *pColl ) ) );
384 pDBData->
GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 );
440 if ( nUpdateTab >= nTabCount )
441 nUpdateTab = nTabCount-1;
445 for (nTab=0; nTab<=nUpdateTab; ++nTab)
449 if (aUpdateSheets.GetSelectCount())
452 for (nTab=0; nTab<=nUpdateTab; ++nTab)
453 if ( aUpdateSheets.GetTableSelect( nTab ) )
524 VclMessageType::Info, VclButtonsType::Ok,
525 ScResId(STR_CONSOLIDATE_ERR1)));
540 aData.
SetSize( nColSize, nRowSize );
558 aData.
GetSize( nColSize, nRowSize );
559 if (bRecord && nColSize > 0 && nRowSize > 0)
561 std::unique_ptr<ScDBData> pUndoData(pDestData ?
new ScDBData(*pDestData) :
nullptr);
565 rParam.
nCol+nColSize-1, rParam.
nRow+nRowSize-1 );
576 std::unique_ptr<ScOutlineTable> pUndoTab(pTable ?
new ScOutlineTable( *pTable ) :
nullptr);
579 pUndoDoc->InitUndo(
m_aDocument, 0, nTabCount-1,
false,
true );
599 std::make_unique<ScUndoConsolidate>(
this, aDestArea, rParam, std::move(pUndoDoc),
600 true, nInsertCount, std::move(pUndoTab), std::move(pUndoData) ) );
616 std::make_unique<ScUndoConsolidate>(
this, aDestArea, rParam, std::move(pUndoDoc),
617 false, 0,
nullptr, std::move(pUndoData) ) );
625 rParam.
nCol + nColSize - 1, rParam.
nRow + nRowSize - 1 );
633 SCCOL nPaintEndCol = nPaintStartCol + nColSize - 1;
634 SCROW nPaintEndRow = nPaintStartRow + nRowSize - 1;
649 if ( aOldDest.
aEnd.
Col() > nPaintEndCol )
650 nPaintEndCol = aOldDest.
aEnd.
Col();
651 if ( aOldDest.
aEnd.
Row() > nPaintEndRow )
652 nPaintEndRow = aOldDest.
aEnd.
Row();
655 nPaintEndCol, nPaintEndRow, rParam.
nTab, nPaintFlags );
665 SCTAB nEndTab = nTab;
673 if (aCompare == rName)
685 aScenMark.GetMultiMarkArea( aMultiRange );
698 true, *pUndoDoc, &aScenMark);
700 for (
SCTAB i=nTab+1;
i<=nEndTab;
i++)
702 pUndoDoc->SetScenario(
i,
true );
707 pUndoDoc->SetScenarioData(
i, aComment, aColor, nScenFlags );
709 pUndoDoc->SetActiveScenario(
i, bActive );
717 std::make_unique<ScUndoUseScenario>(
this, aScenMark,
718 ScArea( nTab,nStartCol,nStartRow,nEndCol,nEndRow ),
719 std::move(pUndoDoc), rName ) );
735 VclMessageType::Info, VclButtonsType::Ok,
743 VclMessageType::Info, VclButtonsType::Ok,
744 ScResId(STR_SCENARIO_NOTFOUND)));
750 OSL_FAIL(
"UseScenario on Scenario-Sheet" );
760 OUString aOldComment;
765 std::make_unique<ScUndoScenarioFlags>(
this, nTab,
766 aOldName, rName, aOldComment, rComment,
767 aOldColor, rColor, nOldFlags, nFlags) );
776 if (aOldName != rName)
791 SCTAB nNewTab = nTab + 1;
810 std::make_unique<ScUndoMakeScenario>(
this, nTab, nNewTab,
811 rName, rComment, rColor, nFlags, rMark ));
855 SCTAB nDestPos,
bool bInsertNew,
856 bool bNotifyAndPaint )
870 if ( nErrVal > 0 && !bInsertNew)
873 if(nErrVal>0 && rSrcDoc.
IsScenario( nSrcPos ))
892 if ( bNotifyAndPaint )
915 OUString sSrcCodeName;
924 SCTAB nAdjSource = nSrcTab;
925 if ( nDestTab <= nSrcTab )
933 unique_ptr< vector<SCTAB> > pSrcList(
new vector<SCTAB>(1, nSrcTab));
934 unique_ptr< vector<SCTAB> > pDestList(
new vector<SCTAB>(1, nDestTab));
936 std::make_unique<ScUndoCopyTab>(
this, std::move(pSrcList), std::move(pDestList)));
942 OUString aLibName(
"Standard" );
946 if ( xVBACompat.is() )
948 aLibName = xVBACompat->getProjectName();
951 SCTAB nTabToUse = nDestTab;
958 if( xLibContainer.is() )
960 css::uno::Any aLibAny = xLibContainer->getByName( aLibName );
965 xLib->getByName( sSrcCodeName ) >>= sSource;
968 catch (
const css::uno::Exception& )
984 if ( nSrcTab == nDestTab )
990 std::unique_ptr<ScProgress> pProgress(
new ScProgress(
this,
ScResId(STR_UNDO_MOVE_TAB),
1000 unique_ptr< vector<SCTAB> > pSrcList(
new vector<SCTAB>(1, nSrcTab));
1001 unique_ptr< vector<SCTAB> > pDestList(
new vector<SCTAB>(1, nDestTab));
1003 std::make_unique<ScUndoMoveTab>(
this, std::move(pSrcList), std::move(pDestList)));
1033 RefreshPivotTables(aRange);
void AddName(const OUString &rName)
void UpdatePageBreaks(SCTAB nTab, const ScRange *pUserArea=nullptr)
bool insert(std::unique_ptr< ScDBData > p)
Takes ownership of p and attempts to insert it into the collection.
bool HasAutoFilter() const
SC_DLLPUBLIC bool HasColHeader(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab)
SC_DLLPUBLIC ScDBCollection * GetDBCollection() const
SC_DLLPUBLIC void SetScenario(SCTAB nTab, bool bFlag)
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
void UpdatePendingRowHeights(SCTAB nUpdateTab, bool bBefore=false)
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
std::unique_ptr< ScDBData > GetOldAutoDBRange()
SC_DLLPUBLIC size_t GetCount() const
SC_DLLPUBLIC ScDBData * GetAnonymousDBData(SCTAB nTab)
SC_DLLPUBLIC void SetSortParam(const ScSortParam &rSortParam)
std::unique_ptr< ScDBData > m_pOldAutoDBRange
bool AdjustRowHeight(SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
merge with docfunc
ScDBData * GetAnonymousDBData(const ScRange &rRange)
SC_DLLPUBLIC void SetTabProtection(SCTAB nTab, const ScTableProtection *pProtect)
std::unique_ptr< ContentProperties > pData
static weld::Window * GetActiveDialogParent()
SfxBindings * GetViewBindings()
SC_DLLPUBLIC bool IsActiveScenario(SCTAB nTab) const
SC_DLLPUBLIC void SetAnonymousDBData(SCTAB nTab, std::unique_ptr< ScDBData > pDBData)
SC_DLLPUBLIC void SetDrawPageSize(SCTAB nTab)
void CopyScenario(SCTAB nSrcTab, SCTAB nDestTab, bool bNewScenario=false)
SC_DLLPUBLIC bool Intersects(const ScRange &rRange) const
SC_DLLPUBLIC void CompileHybridFormula()
Call this immediately after updating named ranges.
#define STR_DB_LOCAL_NONAME
SC_DLLPUBLIC bool ApplyFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
SC_DLLPUBLIC ScDPCollection * GetDPCollection()
bool DoImport(SCTAB nTab, const ScImportParam &rParam, const svx::ODataAccessDescriptor *pDescriptor)
void RefreshPivotTables(const ScRange &rSource)
void SetPendingRowHeights(SCTAB nTab, bool bSet)
sal_uLong GetCodeCount() const
const SfxItemSet & GetItemSet() const
sal_uInt16 nDataAreaCount
SC_DLLPUBLIC const ScDBData * GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const
create "Importx" (if necessary)
std::unique_ptr< ScArea[]> pDataAreas
void Invalidate(sal_uInt16 nId)
ScDBData * GetDBData(const ScRange &rMarked, ScGetDBMode eMode, ScGetDBSelection eSel)
SC_DLLPUBLIC void SetVisible(SCTAB nTab, bool bVisible)
sal_uLong TransferTab(ScDocShell &rSrcDocShell, SCTAB nSrcPos, SCTAB nDestPos, bool bInsertNew, bool bNotifyAndPaint)
Use structure ScDocument if a certain size is exceeded?
ScDBData * GetDBNearCursor(SCCOL nCol, SCROW nRow, SCTAB nTab)
void SetClipParam(const ScClipParam &rParam)
void UpdateAllRowHeights(const ScMarkData *pTabMark=nullptr)
SfxApplication * SfxGetpApp()
bool UpdatePivotTable(ScDPObject &rDPObj, bool bRecord, bool bApi)
SC_DLLPUBLIC ScDocumentPool * GetPool()
virtual SfxUndoManager * GetUndoManager() override
void SetAllFormulasDirty(const sc::SetFormulaDirtyContext &rCxt)
bool IsPendingRowHeights(SCTAB nTab) const
ScDBData * getByRange(const ScRange &rRange)
bool RepeatDB(const OUString &rDBName, bool bApi, bool bIsUnnamed, SCTAB aTab=0)
SC_DLLPUBLIC bool RenameTab(SCTAB nTab, const OUString &rName, bool bExternalDocument=false)
SC_DLLPUBLIC SCROW MaxRow() const
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
SC_DLLPUBLIC SCTAB GetTableCount() const
bool IsMultiMarked() const
void GetSize(SCCOL &rCols, SCROW &rRows) const
void CopyToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, InsertDeleteFlags nFlags, bool bMarked, ScDocument &rDestDoc, const ScMarkData *pMarks=nullptr, bool bColRowFlags=true)
SC_DLLPUBLIC void TransferDrawPage(const ScDocument &rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos)
void push_back(const ScRange &rRange)
SC_DLLPUBLIC void SetQueryParam(const ScQueryParam &rQueryParam)
SC_DLLPUBLIC const ScRange & GetSourceRange() const
Get the range that contains the source data.
void CopyTabProtection(SCTAB nTabSrc, SCTAB nTabDest)
SCTAB GetMaxTableNumber() const
void SetFlags(ScSubTotalFunc eFunc, bool bColName, bool bRowName, bool bRef)
IMPL_LINK(ScDocShell, RefreshDBDataHdl, Timer *, pRefreshTimer, void)
If only one row or portion thereof is selected, shrink row to used data columns and select further ro...
ScChangeTrack * GetChangeTrack() const
OutputDevice * GetDevice() const
create "untitled" (if necessary)
constexpr OUStringLiteral aData
void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
void AddFields(const ScDocument *pSrcDoc, SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
SC_DLLPUBLIC void GetDataArea(SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow, bool bIncludeOld, bool bOnlyDown) const
Return the smallest area containing at least all contiguous cells having data.
SC_DLLPUBLIC void SetScenarioData(SCTAB nTab, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags)
SC_DLLPUBLIC SCCOL MaxCol() const
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
bool CopyTab(SCTAB nOldPos, SCTAB nNewPos, const ScMarkData *pOnlyMarked=nullptr)
bool IsImportingXML() const
void DBAreaDeleted(SCTAB nTab, SCCOL nX1, SCROW nY1, SCCOL nX2)
const SCTAB SC_TAB_APPEND
void UpdateAllRowHeights(sc::RowHeightContext &rCxt, const ScMarkData *pTabMark)
SC_DLLPUBLIC void SetActiveScenario(SCTAB nTab, bool bActive)
void SelectTable(SCTAB nTab, bool bNew)
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
void OutputToDocument(ScDocument &rDestDoc, SCCOL nCol, SCROW nRow, SCTAB nTab)
SC_DLLPUBLIC bool SetOptimalHeight(sc::RowHeightContext &rCxt, SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
ScSheetLimits & GetSheetLimits() const
SC_DLLPUBLIC sal_uLong TransferTab(ScDocument &rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos, bool bInsertNew=true, bool bResultsOnly=false)
void ModifyScenario(SCTAB nTab, const OUString &rName, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags)
void SelectOneTable(SCTAB nTab)
void MarkScenario(SCTAB nSrcTab, SCTAB nDestTab, ScMarkData &rDestMark, bool bResetMark=true, ScScenarioFlags nNeededBits=ScScenarioFlags::NONE) const
OUString ScResId(const char *pId)
const OUString & GetName() const
void AddData(ScDocument *pSrcDoc, SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
void GetImportParam(ScImportParam &rImportParam) const
SC_DLLPUBLIC void ApplyPatternAreaTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, const ScPatternAttr &rAttr)
void BroadcastUno(const SfxHint &rHint)
void UseScenario(SCTAB nTab, const OUString &rName, bool bRecord=true)
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
void GetArea(SCTAB &rTab, SCCOL &rCol1, SCROW &rRow1, SCCOL &rCol2, SCROW &rRow2) const
void SetHeader(bool bHasH)
void LockStreamValid(bool bLock)
ScDBData * findByUpperName(const OUString &rName)
SC_DLLPUBLIC void GetScenarioData(SCTAB nTab, OUString &rComment, Color &rColor, ScScenarioFlags &rFlags) const
void VBA_InsertModule(ScDocument &rDoc, SCTAB nTab, const OUString &sSource)
static OUString lcl_GetAreaName(ScDocument *pDoc, const ScArea *pArea)
Stores global named database ranges.
SCROW GetInsertCount() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
Behave as if the range corresponding to a ScDBData area was selected, for API use.
void SetSize(SCCOL nCols, SCROW nRows)
ScGetDBSelection
For ScDBFunc::GetDBData()
bool MoveTab(SCTAB nOldPos, SCTAB nNewPos, ScProgress *pProgress=nullptr)
SC_DLLPUBLIC bool IsScenario(SCTAB nTab) const
void ErrorMessage(const char *pGlobStrId)
SCTAB MakeScenario(SCTAB nTab, const OUString &rName, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags, ScMarkData &rMark, bool bRecord=true)
field button for datapilot
SC_DLLPUBLIC bool RemoveFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
SC_DLLPUBLIC void ApplySelectionPattern(const ScPatternAttr &rAttr, const ScMarkData &rMark, ScEditDataArray *pDataArray=nullptr, bool *pIsChanged=nullptr)
const ScSheetSourceDesc * GetSheetDesc() const
SC_DLLPUBLIC ScOutlineTable * GetOutlineTable(SCTAB nTab, bool bCreate=false)
static SC_DLLPUBLIC const CharClass * getCharClassPtr()
force use of sheet-local instead of document global anonymous range
const ScDocument & GetDocument() const
SC_DLLPUBLIC void PreprocessDBDataUpdate()
bool HasImportSelection() const
void SetDocumentModified()
void DoConsolidate(const ScConsolidateParam &rParam, bool bRecord=true)
bool MoveTable(SCTAB nSrcTab, SCTAB nDestTab, bool bCopy, bool bRecord)
void SetSubTotalParam(const ScSubTotalParam &rSubTotalParam)
SC_DLLPUBLIC bool IsVisible(SCTAB nTab) const
bool IsUndoEnabled() const
const OUString & GetCodeName() const
bool TestCopyScenario(SCTAB nSrcTab, SCTAB nDestTab) const
const ScDBData * GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const
This struct stores general clipboard parameters associated with a ScDocument instance created in clip...
SC_DLLPUBLIC void DeleteAreaTab(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCTAB nTab, InsertDeleteFlags nDelFlag)
SC_DLLPUBLIC void EnableUndo(bool bVal)
This class contains authoritative information on the internal reference used as the data source for d...
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
bool ValidTab(SCTAB nTab)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
Create before modifications of the document and destroy thereafter.
void SetAutoFilter(bool bSet)
bool IsChangeReadOnlyEnabled() const
css::uno::Reference< css::script::XLibraryContainer > GetBasicContainer()
SC_DLLPUBLIC const ScTableProtection * GetTabProtection(SCTAB nTab) const