25#include <osl/diagnose.h>
32#include <com/sun/star/script/vba/XVBACompatibility.hpp>
48#include <progress.hxx>
60using com::sun::star::script::XLibraryContainer;
61using com::sun::star::script::vba::XVBACompatibility;
62using com::sun::star::container::XNameContainer;
64using com::sun::star::uno::UNO_QUERY;
66using ::std::unique_ptr;
77 bool bFocus = pParent && pParent->
has_focus();
79 if (pGlobStrId && pGlobStrId == STR_PROTECTIONERR)
83 pGlobStrId = STR_READONLYERR;
88 VclMessageType::Info, VclButtonsType::Ok,
121 SCCOL nStartCol = nCol;
122 SCROW nStartRow = nRow;
123 SCTAB nStartTab = nTab;
137 bool bUseThis =
false;
147 pData->GetArea( nDummy, nOldCol1,nOldRow1, nOldCol2,nOldRow2 );
169 m_pDocument->GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow,
false, bOnlyDown );
170 if ( nOldCol1 != nStartCol || nOldCol2 != nEndCol || nOldRow1 != nStartRow )
172 else if ( nOldRow2 != nEndRow )
175 pData->SetArea( nTab, nOldCol1,nOldRow1, nOldCol2,nEndRow );
181 if ( nOldCol1 == nStartCol && nOldRow1 == nStartRow &&
182 nOldCol2 == nEndCol && nOldRow2 == nEndRow )
196 pData->GetArea( nStartTab, nStartCol,nStartRow, nEndCol,nEndRow );
218 m_pDocument->GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow,
false, bOnlyDown );
221 bool bHasHeader =
m_pDocument->HasColHeader( nStartCol,nStartRow, nEndCol,nEndRow, nTab );
230 bool bSheetLocal =
true;
238 nTab, nStartCol, nStartRow, nEndCol, nEndRow,
true, bHasHeader) ) );
264 pNoNameData->
GetArea( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 );
270 if (!bHasHeader && pNoNameData->
HasHeader() && nTab == nOldTab && nStartRow == nOldY1 &&
271 nStartCol <= nOldY2 && nOldY1 <= nEndCol)
283 pNoNameData->
SetArea( nTab, nStartCol,nStartRow, nEndCol,nEndRow );
290 std::unique_ptr<ScDBCollection> pUndoColl;
297 OUString aImport =
ScResId( STR_DBNAME_IMPORT );
305 aNewName = aImport + OUString::number(
nCount );
309 pNoNameData =
new ScDBData( aNewName, nTab,
310 nStartCol,nStartRow, nEndCol,nEndRow,
312 bool ins = rDBs.
insert(std::unique_ptr<ScDBData>(pNoNameData));
313 assert(ins); (void)ins;
318 nStartCol,nStartRow, nEndCol,nEndRow,
320 m_pDocument->SetAnonymousDBData(nTab, std::unique_ptr<ScDBData>(pNoNameData));
328 std::move(pUndoColl),
329 std::make_unique<ScDBCollection>( *pColl ) ) );
354 if (!
pData->HasHeader())
358 pData->SetHeader(bHasHeader);
385 pDBData->
GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 );
410 bool bChange =
m_pDocument->SetOptimalHeight(aCxt, nStartRow,nEndRow, nTab,
true);
439 aUpdater.
update(bOnlyUsedRows);
444 bool bIsUndoEnabled =
m_pDocument->IsUndoEnabled();
450 if ( nUpdateTab >= nTabCount )
451 nUpdateTab = nTabCount-1;
455 for (nTab=0; nTab<=nUpdateTab; ++nTab)
462 for (nTab=0; nTab<=nUpdateTab; ++nTab)
471 if (
m_pDocument->IsPendingRowHeights( nUpdateTab ) )
475 m_pDocument->SetPendingRowHeights( nUpdateTab,
false );
504 return pData->GetName();
534 VclMessageType::Info, VclButtonsType::Ok,
535 ScResId(STR_CONSOLIDATE_ERR1)));
550 aData.SetSize( nColSize, nRowSize );
568 aData.GetSize( nColSize, nRowSize );
569 if (bRecord && nColSize > 0 && nRowSize > 0)
571 std::unique_ptr<ScDBData> pUndoData(pDestData ?
new ScDBData(*pDestData) :
nullptr);
575 rParam.
nCol+nColSize-1, rParam.
nRow+nRowSize-1 );
586 std::unique_ptr<ScOutlineTable> pUndoTab(pTable ?
new ScOutlineTable( *pTable ) :
nullptr);
589 pUndoDoc->InitUndo( *
m_pDocument, 0, nTabCount-1,
false,
true );
609 std::make_unique<ScUndoConsolidate>(
this, aDestArea, rParam, std::move(pUndoDoc),
610 true, nInsertCount, std::move(pUndoTab), std::move(pUndoData) ) );
626 std::make_unique<ScUndoConsolidate>(
this, aDestArea, rParam, std::move(pUndoDoc),
627 false, 0,
nullptr, std::move(pUndoData) ) );
635 rParam.
nCol + nColSize - 1, rParam.
nRow + nRowSize - 1 );
643 SCCOL nPaintEndCol = nPaintStartCol + nColSize - 1;
644 SCROW nPaintEndRow = nPaintStartRow + nRowSize - 1;
659 if ( aOldDest.
aEnd.
Col() > nPaintEndCol )
660 nPaintEndCol = aOldDest.
aEnd.
Col();
661 if ( aOldDest.
aEnd.
Row() > nPaintEndRow )
662 nPaintEndRow = aOldDest.
aEnd.
Row();
665 nPaintEndCol, nPaintEndRow, rParam.
nTab, nPaintFlags );
675 SCTAB nEndTab = nTab;
677 while ( nEndTab+1 < nTabCount &&
m_pDocument->IsScenario(nEndTab+1) )
683 if (aCompare == rName)
689 if (
m_pDocument->TestCopyScenario( nSrcTab, nTab ) )
693 m_pDocument->MarkScenario( nSrcTab, nTab, aScenMark );
705 m_pDocument->CopyToDocument(nStartCol, nStartRow, nTab,
707 true, *pUndoDoc, &aScenMark);
709 for (
SCTAB i=nTab+1;
i<=nEndTab;
i++)
711 pUndoDoc->SetScenario(
i,
true );
715 m_pDocument->GetScenarioData(
i, aComment, aColor, nScenFlags );
716 pUndoDoc->SetScenarioData(
i, aComment, aColor, nScenFlags );
718 pUndoDoc->SetActiveScenario(
i, bActive );
726 std::make_unique<ScUndoUseScenario>(
this, aScenMark,
727 ScArea( nTab,nStartCol,nStartRow,nEndCol,nEndRow ),
728 std::move(pUndoDoc), rName ) );
744 VclMessageType::Info, VclButtonsType::Ok,
752 VclMessageType::Info, VclButtonsType::Ok,
753 ScResId(STR_SCENARIO_NOTFOUND)));
759 OSL_FAIL(
"UseScenario on Scenario-Sheet" );
769 OUString aOldComment;
772 m_pDocument->GetScenarioData( nTab, aOldComment, aOldColor, nOldFlags );
774 std::make_unique<ScUndoScenarioFlags>(
this, nTab,
775 aOldName, rName, aOldComment, rComment,
776 aOldColor, rColor, nOldFlags, nFlags) );
781 m_pDocument->SetScenarioData( nTab, rComment, rColor, nFlags );
785 if (aOldName != rName)
800 SCTAB nNewTab = nTab + 1;
814 if (
m_pDocument->CopyTab( nTab, nNewTab, pCopyMark ))
819 std::make_unique<ScUndoMakeScenario>(
this, nTab, nNewTab,
820 rName, rComment, rColor, nFlags, rMark ));
825 m_pDocument->SetScenarioData( nNewTab, rComment, rColor, nFlags );
839 m_pDocument->ApplySelectionPattern( aPattern, aDestMark );
864 SCTAB nDestPos,
bool bInsertNew,
865 bool bNotifyAndPaint )
879 if ( nErrVal > 0 && !bInsertNew)
880 m_pDocument->TransferDrawPage( rSrcDoc, nSrcPos, nDestPos );
882 if(nErrVal>0 && rSrcDoc.
IsScenario( nSrcPos ))
890 m_pDocument->SetScenarioData(nDestPos,aComment,aColor,nFlags);
892 m_pDocument->SetActiveScenario(nDestPos, bActive );
901 if ( bNotifyAndPaint )
924 OUString sSrcCodeName;
933 SCTAB nAdjSource = nSrcTab;
934 if ( nDestTab <= nSrcTab )
938 m_pDocument->CopyTabProtection(nAdjSource, nDestTab);
942 unique_ptr< vector<SCTAB> > pSrcList(
new vector<SCTAB>(1, nSrcTab));
943 unique_ptr< vector<SCTAB> > pDestList(
new vector<SCTAB>(1, nDestTab));
945 std::make_unique<ScUndoCopyTab>(
this, std::move(pSrcList), std::move(pDestList)));
951 OUString aLibName(
"Standard" );
955 if ( xVBACompat.is() )
957 aLibName = xVBACompat->getProjectName();
960 SCTAB nTabToUse = nDestTab;
967 if( xLibContainer.is() )
969 css::uno::Any aLibAny = xLibContainer->getByName( aLibName );
974 xLib->getByName( sSrcCodeName ) >>= sSource;
977 catch (
const css::uno::Exception& )
993 if ( nSrcTab == nDestTab )
999 std::optional<ScProgress> pProgress(std::in_place,
this,
ScResId(STR_UNDO_MOVE_TAB),
1001 bool bDone =
m_pDocument->MoveTab( nSrcTab, nDestTab, &*pProgress );
1009 unique_ptr< vector<SCTAB> > pSrcList(
new vector<SCTAB>(1, nSrcTab));
1010 unique_ptr< vector<SCTAB> > pDestList(
new vector<SCTAB>(1, nDestTab));
1012 std::make_unique<ScUndoMoveTab>(
this, std::move(pSrcList), std::move(pDestList)));
1042 RefreshPivotTables(aRange);
bool ValidTab(SCTAB nTab)
const SCTAB SC_TAB_APPEND
SfxApplication * SfxGetpApp()
@ Scenario
field button for datapilot
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
Use structure ScDocument if a certain size is exceeded?
ScDBData * getByRange(const ScRange &rRange)
Stores global named database ranges.
bool insert(std::unique_ptr< ScDBData > p)
Takes ownership of p and attempts to insert it into the collection.
ScDBData * findByUpperName(const OUString &rName)
ScDBData * GetDBNearCursor(SCCOL nCol, SCROW nRow, SCTAB nTab)
void GetImportParam(ScImportParam &rImportParam) const
bool HasAutoFilter() const
const OUString & GetName() const
void GetArea(SCTAB &rTab, SCCOL &rCol1, SCROW &rRow1, SCCOL &rCol2, SCROW &rRow2) const
void SetAutoFilter(bool bSet)
void SetSubTotalParam(const ScSubTotalParam &rSubTotalParam)
void SetHeader(bool bHasH)
SC_DLLPUBLIC void SetSortParam(const ScSortParam &rSortParam)
bool HasImportSelection() const
SC_DLLPUBLIC void SetQueryParam(const ScQueryParam &rQueryParam)
void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
bool UpdatePivotTable(ScDPObject &rDPObj, bool bRecord, bool bApi)
bool RepeatDB(const OUString &rDBName, bool bApi, bool bIsUnnamed, SCTAB aTab=0)
bool DoImport(SCTAB nTab, const ScImportParam &rParam, const svx::ODataAccessDescriptor *pDescriptor)
SC_DLLPUBLIC size_t GetCount() const
const ScSheetSourceDesc * GetSheetDesc() const
void update(const bool bOnlyUsedRows=false)
Create before modifications of the document and destroy thereafter.
void SetDocumentModified()
SCTAB MakeScenario(SCTAB nTab, const OUString &rName, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags, ScMarkData &rMark, bool bRecord=true)
static weld::Window * GetActiveDialogParent()
SfxBindings * GetViewBindings()
void ErrorMessage(TranslateId pGlobStrId)
void UseScenario(SCTAB nTab, const OUString &rName, bool bRecord=true)
const ScDocument & GetDocument() const
std::shared_ptr< ScDocument > m_pDocument
void UpdateAllRowHeights(const ScMarkData *pTabMark=nullptr)
std::unique_ptr< ScDBData > GetOldAutoDBRange()
void UpdatePendingRowHeights(SCTAB nUpdateTab, bool bBefore=false)
void ModifyScenario(SCTAB nTab, const OUString &rName, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags)
ScDBData * GetDBData(const ScRange &rMarked, ScGetDBMode eMode, ScGetDBSelection eSel)
ScDBData * GetAnonymousDBData(const ScRange &rRange)
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
void DoConsolidate(const ScConsolidateParam &rParam, bool bRecord=true)
bool MoveTable(SCTAB nSrcTab, SCTAB nDestTab, bool bCopy, bool bRecord)
std::unique_ptr< ScDBData > m_pOldAutoDBRange
sal_uLong TransferTab(ScDocShell &rSrcDocShell, SCTAB nSrcPos, SCTAB nDestPos, bool bInsertNew, bool bNotifyAndPaint)
void DBAreaDeleted(SCTAB nTab, SCCOL nX1, SCROW nY1, SCCOL nX2)
bool AdjustRowHeight(SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
merge with docfunc
virtual SfxUndoManager * GetUndoManager() override
void RefreshPivotTables(const ScRange &rSource)
SC_DLLPUBLIC bool IsScenario(SCTAB nTab) const
SC_DLLPUBLIC const ScTableProtection * GetTabProtection(SCTAB nTab) const
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
SC_DLLPUBLIC const ScDBData * GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const
SC_DLLPUBLIC void GetScenarioData(SCTAB nTab, OUString &rComment, Color &rColor, ScScenarioFlags &rFlags) const
SC_DLLPUBLIC bool IsVisible(SCTAB nTab) const
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
void SetClipParam(const ScClipParam &rParam)
SC_DLLPUBLIC bool IsActiveScenario(SCTAB nTab) const
static SC_DLLPUBLIC const CharClass & getCharClass()
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
const ScRange & GetMultiMarkArea() const
void SelectTable(SCTAB nTab, bool bNew)
void SelectOneTable(SCTAB nTab)
bool IsMultiMarked() const
bool GetTableSelect(SCTAB nTab) const
SCTAB GetSelectCount() const
SfxItemSet & GetItemSet()
void push_back(const ScRange &rRange)
bool Intersects(const ScRange &rRange) 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.
OutputDevice * GetDevice() const
void Invalidate(sal_uInt16 nId)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
css::uno::Reference< css::script::XLibraryContainer > GetBasicContainer()
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
@ TOP_LEFT
top left cell of area
void VBA_InsertModule(ScDocument &rDoc, SCTAB nTab, const OUString &sSource)
IMPL_LINK(ScDocShell, RefreshDBDataHdl, Timer *, pRefreshTimer, void)
static OUString lcl_GetAreaName(ScDocument *pDoc, const ScArea *pArea)
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
ScGetDBSelection
For ScDBFunc::GetDBData()
@ RowDown
If only one row or portion thereof is selected, shrink row to used data columns and select further ro...
@ ForceMark
Behave as if the range corresponding to a ScDBData area was selected, for API use.
@ SC_DB_AUTOFILTER
force use of sheet-local instead of document global anonymous range
@ SC_DB_IMPORT
create "Importx" (if necessary)
@ SC_DB_MAKE
create "untitled" (if necessary)
constexpr OUStringLiteral STR_DB_LOCAL_NONAME
std::unique_ptr< sal_Int32[]> pData
constexpr OUStringLiteral aData
OUString ScResId(TranslateId aId)
This struct stores general clipboard parameters associated with a ScDocument instance created in clip...
sal_uInt16 nDataAreaCount
std::unique_ptr< ScArea[]> pDataAreas