22 #include <com/sun/star/task/InteractionHandler.hpp>
24 #include <sfx2/sfxsids.hrc>
42 #include <document.hxx>
44 #include <globstr.hrc>
53 #include <tokenarray.hxx>
65 const OUString& rFilter,
const OUString& rOpt,
77 pImpl->m_pDocSh = pDocSh;
81 const OUString& rFilter,
const OUString& rOpt,
105 for (
SCTAB nTab=0; nTab<nCount; nTab++)
112 pImpl->m_aEndEditLink = rEndEditHdl;
115 SvBaseLink::Edit( pParent,
LINK(
this,
ScTableLink, TableEndEditHdl ) );
119 const OUString&,
const css::uno::Any& )
122 if (pLinkManager!=
nullptr)
124 OUString aFile, aFilter;
145 pImpl->m_pDocSh->GetUndoManager()->AddUndoAction(
146 std::make_unique<ScUndoRemoveLink>(
pImpl->m_pDocSh,
aFileName ) );
153 SvBaseLink::Closed();
162 const OUString* pNewOptions,
sal_uLong nNewRefresh )
166 if (rNewFile.isEmpty() || rNewFilter.isEmpty())
172 std::shared_ptr<const SfxFilter> pFilter =
pImpl->m_pDocSh->GetFactory().GetFilterContainer()->GetFilter4FilterName(rNewFilter);
192 SfxMedium* pMed =
new SfxMedium(aNewUrl, StreamMode::STD_READ, pFilter, std::move(pSet));
198 ScDocShell* pSrcShell =
new ScDocShell(SfxModelFlags::EMBEDDED_OBJECT | SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS);
204 if (aNewOpt.isEmpty())
218 bool bNotFound =
false;
227 for (
SCTAB nTab=0; nTab<nCount; nTab++)
239 pUndoDoc->InitUndo( rDoc, nTab, nTab,
true,
true );
241 pUndoDoc->AddUndoTab( nTab, nTab,
true,
true );
245 pUndoDoc->TransferDrawPage( rDoc, nTab, nTab );
276 if ( !aTabName.isEmpty() && !bAutoTab )
277 bFound = rSrcDoc.
GetTable( aTabName, nSrcTab );
289 bool bShowError =
true;
298 for (
bool bHas = aIter.
first(); bHas; bHas = aIter.
next())
317 size_t nRanges = aErrorCells.
size();
333 for (
SCROW nRow=nStartRow; nRow<=nEndRow; nRow++)
334 for (
SCCOL nCol=nStartCol; nCol<=nEndCol; nCol++)
361 aOptions != aNewOpt || pNewOptions ||
363 rDoc.
SetLink( nTab, nMode, aNewUrl, rNewFilter, aNewOpt,
364 aTabName, nNewRefresh );
384 pImpl->m_pDocSh->GetUndoManager()->AddUndoAction(
385 std::make_unique<ScUndoRefreshLink>(
pImpl->m_pDocSh, std::move(pUndoDoc) ) );
411 Refresh( aFileName, aFilterName,
nullptr, GetRefreshDelay() );
416 pImpl->m_aEndEditLink.Call( rLink );
426 if ( pSet && SfxItemState::SET == pSet->
GetItemState( SID_FILE_FILTEROPTIONS,
true, &pItem ) )
427 return static_cast<const SfxStringItem*>(pItem)->GetValue();
433 OUString& rFilter, OUString& rOptions,
434 bool bWithContent,
bool bWithInteraction )
442 if ( pMed->
GetName() == rFileName )
444 rFilter = pMed->
GetFilter()->GetFilterName();
454 if ( eProt == INetProtocol::NotValid )
459 std::shared_ptr<const SfxFilter> pSfxFilter;
460 auto pMedium = std::make_unique<SfxMedium>( rFileName, StreamMode::STD_READ );
463 if ( bWithInteraction )
477 rFilter = pSfxFilter->GetFilterName();
480 bOK = !rFilter.isEmpty();
489 if (rFilterName.startsWith( aAppPrefix))
490 rFilterName = rFilterName.copy( aAppPrefix.getLength());
494 const OUString& rOptions,
weld::Window* pInteractionParent )
498 if ( !rOptions.isEmpty() )
499 pSet->Put(
SfxStringItem( SID_FILE_FILTEROPTIONS, rOptions ) );
501 if (pInteractionParent)
504 css::uno::Reference<css::task::XInteractionHandler> xIHdl(css::task::InteractionHandler::createWithParent(xContext,
505 pInteractionParent->
GetXWindow()), css::uno::UNO_QUERY_THROW);
509 SfxMedium *pRet =
new SfxMedium( rFileName, StreamMode::STD_READ, pFilter, std::move(pSet) );
510 if (pInteractionParent)
516 OUString& rFilterName, OUString& rOptions,
518 css::uno::Reference<css::io::XInputStream> xInputStream)
522 if ( rFilterName.isEmpty() )
523 GetFilterName(rFileName, rFilterName, rOptions,
true, pInteractionParent !=
nullptr);
525 std::shared_ptr<const SfxFilter> pFilter = ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName( rFilterName );
528 if (xInputStream.is())
533 pDocShell =
new ScDocShell( SfxModelFlags::EMBEDDED_OBJECT | SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS );
548 if (!aNew.isEmpty() && aNew != rOptions)
SC_DLLPUBLIC OUString GetLinkDoc(SCTAB nTab) const
#define LINK(Instance, Class, Member)
bool Refresh(const OUString &rNewFile, const OUString &rNewFilter, const OUString *pNewOptions, sal_uLong nNewRefresh)
static OUString GetOwnFilterName()
virtual css::uno::Reference< css::awt::XWindow > GetXWindow()=0
SC_DLLPUBLIC ScLinkMode GetLinkMode(SCTAB nTab) const
OUString GetTitle(sal_uInt16 nMaxLen=0) const
static SC_DLLPUBLIC::utl::TransliterationWrapper * GetpTransliteration()
void SetInLinkUpdate(bool bSet)
static void RemoveAppPrefix(OUString &rFilterName)
const OUString & GetName() const
const ScExtDocSettings & GetDocSettings() const
ErrCode GuessFilter(SfxMedium &rMedium, std::shared_ptr< const SfxFilter > &, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
ScTableLink(ScDocShell *pDocSh, const OUString &rFile, const OUString &rFilter, const OUString &rOpt, sal_uLong nRefresh)
Extended options held by an ScDocument containing additional settings for filters.
bool IsLinked(SCTAB nTab) const
ScFormulaCell * getFormulaCell()
SfxApplication * SfxGetpApp()
SC_DLLPUBLIC bool RenameTab(SCTAB nTab, const OUString &rName, bool bExternalDocument=false)
OUString GetTitle() const
SC_DLLPUBLIC SCROW MaxRow() const
SC_DLLPUBLIC SCTAB GetTableCount() 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 bool GetTable(const OUString &rName, SCTAB &rTab) const
Walk through all cells in an area.
static OUString GetOptions(const SfxMedium &rMedium)
sal_uInt32 mnLinkCnt
Recursive counter for loading external documents.
SfxItemPool & GetPool() const
static bool HasAutomaticTableName(std::u16string_view rFilter)
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 SCCOL MaxCol() const
ScDocument * GetDocument()
IMPL_LINK_NOARG(ScTableLink, RefreshHdl, Timer *, void)
void SetRefreshHandler(const Link< Timer *, void > &rLink)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
void UseInteractionHandler(bool)
virtual void Edit(weld::Window *, const Link< SvBaseLink &, void > &rEndEditHdl) override
Iterator for references in a formula cell.
SC_DLLPUBLIC sal_uLong TransferTab(ScDocument &rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos, bool bInsertNew=true, bool bResultsOnly=false)
OUString ScResId(const char *pId)
void SetLink(SCTAB nTab, ScLinkMode nMode, const OUString &rDoc, const OUString &rFilter, const OUString &rOptions, const OUString &rTabName, sal_uLong nRefreshDelay)
SfxItemSet * GetItemSet() const
void BroadcastUno(const SfxHint &rHint)
const std::shared_ptr< const SfxFilter > & GetFilter() const
virtual formula::FormulaToken * AddOpCode(OpCode eCode) override
static bool GetDisplayNames(const SvBaseLink *, OUString *pType, OUString *pFile=nullptr, OUString *pLink=nullptr, OUString *pFilter=nullptr)
SC_DLLPUBLIC Color GetTabBgColor(SCTAB nTab) const
bool GetNextRef(ScRange &rRange)
static SC_DLLPUBLIC OUString GetDocTabName(std::u16string_view rFileName, std::u16string_view rTabName)
void Join(const ScRange &, bool bIsInList=false)
static SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
void SetRefreshControl(std::unique_ptr< ScRefreshTimerControl > const *pp)
INetProtocol GetProtocol() const
ScExtDocOptions * GetExtDocOptions()
virtual ~ScTableLink() override
Reference< XComponentContext > getProcessComponentContext()
void SetSheetLink(const OUString &rSourceUrl)
SC_DLLPUBLIC OUString GetLinkTab(SCTAB nTab) const
const ScDocument & GetDocument() const
void SetDocumentModified()
static bool GetFilterName(const OUString &rFileName, OUString &rFilter, OUString &rOptions, bool bWithContent, bool bWithInteraction)
Returns the filter name and options from a file name.
Link< sfx2::SvBaseLink &, void > m_aEndEditLink
bool IsUndoEnabled() const
static SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
bool DoLoad(SfxMedium *pMedium)
SC_DLLPUBLIC void SetExtDocOptions(std::unique_ptr< ScExtDocOptions > pNewOptions)
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...
SC_DLLPUBLIC void DeleteAreaTab(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCTAB nTab, InsertDeleteFlags nDelFlag)
std::unique_ptr< TableLink_Impl > pImpl
virtual void Closed() override
IMPL_LINK(ScTableLink, TableEndEditHdl,::sfx2::SvBaseLink &, rLink, void)
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
sal_uLong GetRefreshDelay() const
SC_DLLPUBLIC void SetFormula(const ScAddress &rPos, const ScTokenArray &rArray)
virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(const OUString &rMimeType, const css::uno::Any &rValue) override
Create before modifications of the document and destroy thereafter.
ErrCode GuessFilterIgnoringContent(SfxMedium const &rMedium, std::shared_ptr< const SfxFilter > &) const
void setStreamToLoadFrom(const css::uno::Reference< css::io::XInputStream > &xInputStream, bool bIsReadOnly)
ScDocumentLoader(const OUString &rFileName, OUString &rFilterName, OUString &rOptions, sal_uInt32 nRekCnt=0, weld::Window *pInteractionParent=nullptr, css::uno::Reference< css::io::XInputStream > xInputStream=css::uno::Reference< css::io::XInputStream >())
SfxMedium * GetMedium() const
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)