25 #include <osl/diagnose.h>
30 #include <document.hxx>
35 #include <globstr.hrc>
50 const OUString& rFilter,
const OUString& rOpt,
51 const OUString& rArea,
const ScRange& rDest,
57 aFilterName (rFilter),
65 OSL_ENSURE(dynamic_cast< const ScDocShell *>( pShell ) !=
nullptr,
"ScAreaLink with wrong ObjectShell");
82 if ( pDlg->Execute() ==
RET_OK )
85 Refresh( pDlg->GetURL(), pDlg->GetFilter(),
86 pDlg->GetSource(), pDlg->GetRefresh() );
89 OUString aNewLinkName;
96 const OUString&,
const css::uno::Any& )
105 if (pLinkManager!=
nullptr)
107 OUString aFile, aArea, aFilter;
120 OUString aNewLinkName;
121 OUString aTmp = aFilter;
152 SvBaseLink::Closed();
161 const OUString& rArea)
169 OUString aNewLinkName;
174 bool ScAreaLink::IsEqual( std::u16string_view rFile, std::u16string_view rFilter, std::u16string_view rOpt,
175 std::u16string_view rSource,
const ScRange& rDest )
const
204 pDB->
GetArea(nTab,nCol1,nRow1,nCol2,nRow2);
205 rRange =
ScRange( nCol1,nRow1,nTab, nCol2,nRow2,nTab );
222 const OUString& rNewArea,
sal_uLong nNewRefresh )
226 if (rNewFile.isEmpty() || rNewFilter.isEmpty())
230 bool bNewUrlName = (aNewUrl !=
aFileName);
248 ScDocShell* pSrcShell =
new ScDocShell(SfxModelFlags::EMBEDDED_OBJECT | SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS);
256 if (aNewOpt.isEmpty())
265 aTempArea = rNewArea;
282 nWidth = nEndCol + 1;
283 nHeight = nEndRow + 2;
287 if (!aTempArea.isEmpty())
293 if(
FindExtRange( aTokenRange, rSrcDoc, aTempArea.getToken( 0,
';', nIdx ) ) )
297 nWidth = std::max( nWidth, static_cast<SCCOL>(aTokenRange.
aEnd.
Col() - aTokenRange.
aStart.
Col() + 1) );
314 if (nWidth > 0 && nHeight > 0)
332 ScAddress(std::max(nOldEndX,nNewEndX), std::max(nOldEndY,nNewEndY), nDestTab) );
342 if ( nNewEndX != nOldEndX || nNewEndY != nOldEndY )
349 pUndoDoc->InitUndo( rDoc, nDestTab, nDestTab );
354 pUndoDoc->InitUndo( rDoc, nDestTab, nDestTab );
363 rDoc.
FitBlock( aOldRange, aNewRange );
369 if (nWidth > 0 && nHeight > 0)
373 for (
size_t nRange = 0; nRange < aSourceRanges.
size(); ++nRange)
375 ScRange const & rTokenRange( aSourceRanges[nRange]);
379 aSourceMark.SetMarkArea( rTokenRange );
382 rSrcDoc.
CopyToClip(aClipParam, &aClipDoc, &aSourceMark,
false,
false);
399 aDestMark.SetMarkArea( aNewTokenRange );
406 OUString aErr =
ScResId(STR_LINKERROR);
415 pRedoDoc->InitUndo( rDoc, nDestTab, nDestTab );
419 std::make_unique<ScUndoUpdateAreaLink>(
m_pDocSh,
422 aNewUrl, rNewFilter, aNewOpt,
423 rNewArea, aNewRange, nNewRefresh,
424 std::move(pUndoDoc), std::move(pRedoDoc),
bDoInsert ) );
448 nPaintEndX = rDoc.
MaxCol();
450 nPaintEndY = rDoc.
MaxRow();
454 ScRange(aDestPos.
Col(), aDestPos.
Row(), nDestTab, nPaintEndX, nPaintEndY, nDestTab),
467 VclMessageType::Info, VclButtonsType::Ok,
468 ScResId(STR_MSSG_DOSUBTOTALS_2)));
492 Refresh( aFileName, aFilterName, aSourceArea, GetRefreshDelay() );
SC_DLLPUBLIC ScRefFlags ParseAny(const OUString &, const ScDocument &, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1)
#define LINK(Instance, Class, Member)
bool CanFitBlock(const ScRange &rOld, const ScRange &rNew)
virtual SfxObjectFactory & GetFactory() const =0
void FitBlock(const ScRange &rOld, const ScRange &rNew, bool bClear=true)
SC_DLLPUBLIC ScDBCollection * GetDBCollection() const
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
bool AdjustRowHeight(SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
merge with docfunc
std::unique_ptr< ScRefreshTimerControl > const & GetRefreshTimerControlAddress() const
SC_DLLPUBLIC void CopyFromClip(const ScRange &rDestRange, const ScMarkData &rMark, InsertDeleteFlags nInsFlag, ScDocument *pRefUndoDoc, ScDocument *pClipDoc, bool bResetCut=true, bool bAsLink=false, bool bIncludeFiltered=true, bool bSkipAttrForEmpty=false, const ScRangeList *pDestRanges=nullptr)
If pDestRanges is given it overrides rDestRange, rDestRange in this case is the overall encompassing ...
void SetSource(const OUString &rDoc, const OUString &rFlt, const OUString &rOpt, const OUString &rArea)
void SetInLinkUpdate(bool bSet)
static void RemoveAppPrefix(OUString &rFilterName)
void SetRefreshDelay(sal_uLong nSeconds)
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
const SfxItemSet & GetItemSet() const
static OUString GetWebQueryFilterName()
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
SC_DLLPUBLIC bool HasAttrib(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, HasAttrFlags nMask) const
virtual VclPtr< AbstractScLinkedAreaDlg > CreateScLinkedAreaDlg(weld::Widget *pParent)=0
SC_DLLPUBLIC ScDocumentPool * GetPool()
virtual SfxUndoManager * GetUndoManager() override
SC_DLLPUBLIC SCROW MaxRow() const
SC_DLLPUBLIC SCTAB GetTableCount() const
ScAreaLink(SfxObjectShell *pShell, const OUString &rFile, const OUString &rFilter, const OUString &rOpt, const OUString &rArea, const ScRange &rDest, sal_uLong nRefresh)
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)
void push_back(const ScRange &rRange)
static OUString GetOptions(const SfxMedium &rMedium)
virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(const OUString &rMimeType, const css::uno::Any &rValue) override
SC_DLLPUBLIC bool GetCellArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow) const
void SetDestArea(const ScRange &rNew)
virtual ~ScAreaLink() override
SC_DLLPUBLIC bool SetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const ScSetStringParam *pParam=nullptr)
static SC_DLLPUBLIC OUString GetAbsDocName(const OUString &rFileName, const SfxObjectShell *pShell)
SC_DLLPUBLIC ScRangeData * findByUpperName(const OUString &rName)
SC_DLLPUBLIC SCCOL MaxCol() const
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
void SetRefreshHandler(const Link< Timer *, void > &rLink)
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
ScSheetLimits & GetSheetLimits() const
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
OUString uppercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
void SelectOneTable(SCTAB nTab)
OUString ScResId(const char *pId)
virtual void Edit(weld::Window *, const Link< SvBaseLink &, void > &rEndEditHdl) override
SC_DLLPUBLIC void ApplyPatternAreaTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, const ScPatternAttr &rAttr)
void BroadcastUno(const SfxHint &rHint)
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
ScDBData * findByUpperName(const OUString &rName)
void MakeLnkName(OUString &rName, const OUString *pType, std::u16string_view rFile, std::u16string_view rLink, const OUString *pFilter)
bool ValidColRow(SCCOL nCol, SCROW nRow) const
void SetAreaLink(const ScAddress &rPos)
static bool GetDisplayNames(const SvBaseLink *, OUString *pType, OUString *pFile=nullptr, OUString *pLink=nullptr, OUString *pFilter=nullptr)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void SetName(const OUString &rLn)
bool Refresh(const OUString &rNewFile, const OUString &rNewFilter, const OUString &rNewArea, sal_uLong nNewRefresh)
void SetStreamValid(SCTAB nTab, bool bSet, bool bIgnoreLock=false)
css::uno::Reference< css::awt::XWindow > GetDialogParent(SfxMedium const *pMedium=nullptr)
void SetRefreshControl(std::unique_ptr< ScRefreshTimerControl > const *pp)
std::shared_ptr< const SfxFilter > GetFilter4FilterName(const OUString &rName, SfxFilterFlags nMust=SfxFilterFlags::NONE, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
IMPL_LINK_NOARG(ScAreaLink, RefreshHdl, Timer *, void)
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
#define SC_TEXT_CSV_FILTER_NAME
static SC_DLLPUBLIC const CharClass * getCharClassPtr()
const ScDocument & GetDocument() const
SC_DLLPUBLIC bool IsValidReference(ScRange &rRef) const
void SetDocumentModified()
virtual void Closed() override
bool IsUndoEnabled() const
bool DoLoad(SfxMedium *pMedium)
static SfxMedium * CreateMedium(const OUString &rFileName, std::shared_ptr< const SfxFilter > const &pFilter, const OUString &rOptions, weld::Window *pInteractionParent=nullptr)
Create SfxMedium for stream read with SfxFilter and filter options set at the medium's SfxItemSet...
SfxFilterContainer * GetFilterContainer() 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 sfx2::LinkManager * GetLinkManager()
static bool FindExtRange(ScRange &rRange, const ScDocument &rSrcDoc, const OUString &rAreaName)
sal_uLong GetRefreshDelay() const
Strings (and string results if InsertDeleteFlags::FORMULA is not set).
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.
SC_DLLPUBLIC void CopyToClip(const ScClipParam &rClipParam, ScDocument *pClipDoc, const ScMarkData *pMarks, bool bKeepScenarioFlags, bool bIncludeObjects)
bool IsEqual(std::u16string_view rFile, std::u16string_view rFilter, std::u16string_view rOpt, std::u16string_view rSource, const ScRange &rDest) const