LibreOffice Module sc (master)  1
tablink.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <sal/config.h>
21 
22 #include <com/sun/star/task/InteractionHandler.hpp>
23 
24 #include <sfx2/sfxsids.hrc>
25 #include <sfx2/app.hxx>
26 #include <svl/itemset.hxx>
27 #include <svl/stritem.hxx>
28 #include <sfx2/docfile.hxx>
29 #include <sfx2/docfilt.hxx>
30 #include <sfx2/fcontnr.hxx>
31 #include <sfx2/frame.hxx>
32 #include <sfx2/linkmgr.hxx>
33 #include <vcl/weld.hxx>
34 #include <tools/urlobj.hxx>
36 #include <unotools/configmgr.hxx>
38 
39 #include <tablink.hxx>
40 
41 #include <scextopt.hxx>
42 #include <document.hxx>
43 #include <docsh.hxx>
44 #include <globstr.hrc>
45 #include <scresid.hxx>
46 #include <undoblk.hxx>
47 #include <undotab.hxx>
48 #include <global.hxx>
49 #include <hints.hxx>
50 #include <dociter.hxx>
51 #include <formula/opcode.hxx>
52 #include <formulaiter.hxx>
53 #include <tokenarray.hxx>
54 
56 {
59 
60  TableLink_Impl() : m_pDocSh( nullptr ) {}
61 };
62 
63 
64 ScTableLink::ScTableLink(ScDocShell* pDocSh, const OUString& rFile,
65  const OUString& rFilter, const OUString& rOpt,
66  sal_uLong nRefresh ):
68  ScRefreshTimer( nRefresh ),
69  pImpl( new TableLink_Impl ),
70  aFileName(rFile),
71  aFilterName(rFilter),
72  aOptions(rOpt),
73  bInCreate( false ),
74  bInEdit( false ),
75  bAddUndo( true )
76 {
77  pImpl->m_pDocSh = pDocSh;
78 }
79 
80 ScTableLink::ScTableLink(SfxObjectShell* pShell, const OUString& rFile,
81  const OUString& rFilter, const OUString& rOpt,
82  sal_uLong nRefresh ):
84  ScRefreshTimer( nRefresh ),
85  pImpl( new TableLink_Impl ),
86  aFileName(rFile),
87  aFilterName(rFilter),
88  aOptions(rOpt),
89  bInCreate( false ),
90  bInEdit( false ),
91  bAddUndo( true )
92 {
93  pImpl->m_pDocSh = static_cast< ScDocShell* >( pShell );
94  SetRefreshHandler( LINK( this, ScTableLink, RefreshHdl ) );
95  SetRefreshControl( &pImpl->m_pDocSh->GetDocument().GetRefreshTimerControlAddress() );
96 }
97 
99 {
100  // cancel connection
101 
103  ScDocument& rDoc = pImpl->m_pDocSh->GetDocument();
104  SCTAB nCount = rDoc.GetTableCount();
105  for (SCTAB nTab=0; nTab<nCount; nTab++)
106  if (rDoc.IsLinked(nTab) && aFileName == rDoc.GetLinkDoc(nTab))
107  rDoc.SetLink( nTab, ScLinkMode::NONE, "", "", "", "", 0 );
108 }
109 
110 void ScTableLink::Edit(weld::Window* pParent, const Link<SvBaseLink&,void>& rEndEditHdl)
111 {
112  pImpl->m_aEndEditLink = rEndEditHdl;
113 
114  bInEdit = true;
115  SvBaseLink::Edit( pParent, LINK( this, ScTableLink, TableEndEditHdl ) );
116 }
117 
119  const OUString&, const css::uno::Any& )
120 {
121  sfx2::LinkManager* pLinkManager=pImpl->m_pDocSh->GetDocument().GetLinkManager();
122  if (pLinkManager!=nullptr)
123  {
124  OUString aFile, aFilter;
125  sfx2::LinkManager::GetDisplayNames(this, nullptr, &aFile, nullptr, &aFilter);
126 
127  // the file dialog returns the filter name with the application prefix
128  // -> remove prefix
130 
131  if (!bInCreate)
132  Refresh( aFile, aFilter, nullptr, GetRefreshDelay() ); // don't load twice
133  }
134  return SUCCESS;
135 }
136 
138 {
139  // delete link: Undo
140  ScDocument& rDoc = pImpl->m_pDocSh->GetDocument();
141  bool bUndo (rDoc.IsUndoEnabled());
142 
143  if (bAddUndo && bUndo)
144  {
145  pImpl->m_pDocSh->GetUndoManager()->AddUndoAction(
146  std::make_unique<ScUndoRemoveLink>( pImpl->m_pDocSh, aFileName ) );
147 
148  bAddUndo = false; // only once
149  }
150 
151  // connection gets cancelled in the dtor
152 
153  SvBaseLink::Closed();
154 }
155 
157 {
158  return pImpl->m_pDocSh->GetDocument().HasLink( aFileName, aFilterName, aOptions );
159 }
160 
161 bool ScTableLink::Refresh(const OUString& rNewFile, const OUString& rNewFilter,
162  const OUString* pNewOptions, sal_uLong nNewRefresh )
163 {
164  // load document
165 
166  if (rNewFile.isEmpty() || rNewFilter.isEmpty())
167  return false;
168 
169  OUString aNewUrl = ScGlobal::GetAbsDocName(rNewFile, pImpl->m_pDocSh);
170  bool bNewUrlName = aFileName != aNewUrl;
171 
172  std::shared_ptr<const SfxFilter> pFilter = pImpl->m_pDocSh->GetFactory().GetFilterContainer()->GetFilter4FilterName(rNewFilter);
173  if (!pFilter)
174  return false;
175 
176  ScDocument& rDoc = pImpl->m_pDocSh->GetDocument();
177  rDoc.SetInLinkUpdate( true );
178 
179  bool bUndo(rDoc.IsUndoEnabled());
180 
181  // if new filter has been selected, forget options
182  if (aFilterName != rNewFilter)
183  aOptions.clear();
184  if ( pNewOptions ) // options hard-specified?
185  aOptions = *pNewOptions;
186 
187  // always create ItemSet, so that DocShell can set the options
188  auto pSet = std::make_shared<SfxAllItemSet>( SfxGetpApp()->GetPool() );
189  if (!aOptions.isEmpty())
190  pSet->Put( SfxStringItem( SID_FILE_FILTEROPTIONS, aOptions ) );
191 
192  SfxMedium* pMed = new SfxMedium(aNewUrl, StreamMode::STD_READ, pFilter, std::move(pSet));
193 
194  if ( bInEdit ) // only if using the edit dialog,
195  pMed->UseInteractionHandler(true); // enable the filter options dialog
196 
197  // aRef->DoClose() will be called explicitly, but it is still more safe to use SfxObjectShellLock here
198  ScDocShell* pSrcShell = new ScDocShell(SfxModelFlags::EMBEDDED_OBJECT | SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS);
199  SfxObjectShellLock aRef = pSrcShell;
200  pSrcShell->DoLoad(pMed);
201 
202  // options might have been set
203  OUString aNewOpt = ScDocumentLoader::GetOptions(*pMed);
204  if (aNewOpt.isEmpty())
205  aNewOpt = aOptions;
206 
207  // Undo...
208 
209  ScDocumentUniquePtr pUndoDoc;
210  bool bFirst = true;
211  if (bAddUndo && bUndo)
212  pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
213 
214  // copy tables
215 
216  ScDocShellModificator aModificator( *pImpl->m_pDocSh );
217 
218  bool bNotFound = false;
219  ScDocument& rSrcDoc = pSrcShell->GetDocument();
220 
221  // from text filters that don't set the table name,
222  // use the one table regardless of link table name
223  bool bAutoTab = (rSrcDoc.GetTableCount() == 1) &&
224  ScDocShell::HasAutomaticTableName( rNewFilter );
225 
226  SCTAB nCount = rDoc.GetTableCount();
227  for (SCTAB nTab=0; nTab<nCount; nTab++)
228  {
229  ScLinkMode nMode = rDoc.GetLinkMode(nTab);
230  if (nMode != ScLinkMode::NONE && aFileName == rDoc.GetLinkDoc(nTab))
231  {
232  OUString aTabName = rDoc.GetLinkTab(nTab);
233 
234  // Undo
235 
236  if (bAddUndo && bUndo)
237  {
238  if (bFirst)
239  pUndoDoc->InitUndo( rDoc, nTab, nTab, true, true );
240  else
241  pUndoDoc->AddUndoTab( nTab, nTab, true, true );
242  bFirst = false;
243  ScRange aRange(0,0,nTab,rDoc.MaxCol(),rDoc.MaxRow(),nTab);
244  rDoc.CopyToDocument(aRange, InsertDeleteFlags::ALL, false, *pUndoDoc);
245  pUndoDoc->TransferDrawPage( rDoc, nTab, nTab );
246  pUndoDoc->SetLink( nTab, nMode, aFileName, aFilterName,
247  aOptions, aTabName, GetRefreshDelay() );
248  pUndoDoc->SetTabBgColor( nTab, rDoc.GetTabBgColor(nTab) );
249  }
250 
251  // adjust table name of an ExtDocRef
252 
253  if ( bNewUrlName && nMode == ScLinkMode::VALUE )
254  {
255  OUString aName;
256  rDoc.GetName( nTab, aName );
257  if ( ScGlobal::GetpTransliteration()->isEqual(
258  ScGlobal::GetDocTabName( aFileName, aTabName ), aName ) )
259  {
260  rDoc.RenameTab( nTab,
261  ScGlobal::GetDocTabName( aNewUrl, aTabName ),
262  true/*bExternalDocument*/ );
263  }
264  }
265 
266  // copy
267 
268  SCTAB nSrcTab = 0;
269  bool bFound = false;
270  /* #i71497# check if external document is loaded successfully,
271  otherwise we may find the empty default sheet "Sheet1" in
272  rSrcDoc, even if the document does not exist. */
273  if( pMed->GetError() == ERRCODE_NONE )
274  {
275  // no sheet name -> use first sheet
276  if ( !aTabName.isEmpty() && !bAutoTab )
277  bFound = rSrcDoc.GetTable( aTabName, nSrcTab );
278  else
279  bFound = true;
280  }
281 
282  if (bFound)
283  rDoc.TransferTab( rSrcDoc, nSrcTab, nTab, false, // don't insert anew
284  (nMode == ScLinkMode::VALUE) ); // only values?
285  else
286  {
287  rDoc.DeleteAreaTab( 0,0,rDoc.MaxCol(),rDoc.MaxRow(), nTab, InsertDeleteFlags::ALL );
288 
289  bool bShowError = true;
290  if ( nMode == ScLinkMode::VALUE )
291  {
292  // Value link (used with external references in formulas):
293  // Look for formulas that reference the sheet, and put errors in the referenced cells.
294 
295  ScRangeList aErrorCells; // cells on the linked sheets that need error values
296 
297  ScCellIterator aIter(rDoc, ScRange(0,0,0,rDoc.MaxCol(),rDoc.MaxRow(),MAXTAB)); // all sheets
298  for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
299  {
300  if (aIter.getType() != CELLTYPE_FORMULA)
301  continue;
302 
303  ScFormulaCell* pCell = aIter.getFormulaCell();
304  ScDetectiveRefIter aRefIter(rDoc, pCell);
305  ScRange aRefRange;
306  while ( aRefIter.GetNextRef( aRefRange ) )
307  {
308  if ( aRefRange.aStart.Tab() <= nTab && aRefRange.aEnd.Tab() >= nTab )
309  {
310  // use first cell of range references (don't fill potentially large ranges)
311 
312  aErrorCells.Join( ScRange( aRefRange.aStart ) );
313  }
314  }
315  }
316 
317  size_t nRanges = aErrorCells.size();
318  if ( nRanges ) // found any?
319  {
320  ScTokenArray aTokenArr(rDoc);
321  aTokenArr.AddOpCode( ocNotAvail );
322  aTokenArr.AddOpCode( ocOpen );
323  aTokenArr.AddOpCode( ocClose );
324  aTokenArr.AddOpCode( ocStop );
325 
326  for (size_t nPos=0; nPos < nRanges; nPos++)
327  {
328  const ScRange & rRange = aErrorCells[ nPos ];
329  SCCOL nStartCol = rRange.aStart.Col();
330  SCROW nStartRow = rRange.aStart.Row();
331  SCCOL nEndCol = rRange.aEnd.Col();
332  SCROW nEndRow = rRange.aEnd.Row();
333  for (SCROW nRow=nStartRow; nRow<=nEndRow; nRow++)
334  for (SCCOL nCol=nStartCol; nCol<=nEndCol; nCol++)
335  {
336  ScAddress aDestPos( nCol, nRow, nTab );
337  rDoc.SetFormula(aDestPos, aTokenArr);
338  }
339  }
340 
341  bShowError = false;
342  }
343  // if no references were found, insert error message (don't leave the sheet empty)
344  }
345 
346  if ( bShowError )
347  {
348  // Normal link or no references: put error message on sheet.
349 
350  rDoc.SetString( 0,0,nTab, ScResId(STR_LINKERROR) );
351  rDoc.SetString( 0,1,nTab, ScResId(STR_LINKERRORFILE) );
352  rDoc.SetString( 1,1,nTab, aNewUrl );
353  rDoc.SetString( 0,2,nTab, ScResId(STR_LINKERRORTAB) );
354  rDoc.SetString( 1,2,nTab, aTabName );
355  }
356 
357  bNotFound = true;
358  }
359 
360  if ( bNewUrlName || aFilterName != rNewFilter ||
361  aOptions != aNewOpt || pNewOptions ||
362  nNewRefresh != GetRefreshDelay() )
363  rDoc.SetLink( nTab, nMode, aNewUrl, rNewFilter, aNewOpt,
364  aTabName, nNewRefresh );
365  }
366  }
367 
368  // memorize new settings
369 
370  if ( bNewUrlName )
371  aFileName = aNewUrl;
372  if (aFilterName != rNewFilter)
373  aFilterName = rNewFilter;
374  if (aOptions != aNewOpt)
375  aOptions = aNewOpt;
376 
377  // clean up
378 
379  aRef->DoClose();
380 
381  // Undo
382 
383  if (bAddUndo && bUndo)
384  pImpl->m_pDocSh->GetUndoManager()->AddUndoAction(
385  std::make_unique<ScUndoRefreshLink>( pImpl->m_pDocSh, std::move(pUndoDoc) ) );
386 
387  // Paint (may be several tables)
388 
389  pImpl->m_pDocSh->PostPaint( ScRange(0,0,0,rDoc.MaxCol(),rDoc.MaxRow(),MAXTAB),
391  aModificator.SetDocumentModified();
392 
393  if (bNotFound)
394  {
396  }
397 
398  rDoc.SetInLinkUpdate( false );
399 
400  // notify Uno objects (for XRefreshListener)
402  ScLinkRefreshedHint aHint;
403  aHint.SetSheetLink( aFileName );
404  rDoc.BroadcastUno( aHint );
405 
406  return true;
407 }
408 
409 IMPL_LINK_NOARG(ScTableLink, RefreshHdl, Timer *, void)
410 {
411  Refresh( aFileName, aFilterName, nullptr, GetRefreshDelay() );
412 }
413 
414 IMPL_LINK( ScTableLink, TableEndEditHdl, ::sfx2::SvBaseLink&, rLink, void )
415 {
416  pImpl->m_aEndEditLink.Call( rLink );
417  bInEdit = false;
418 }
419 
420 // === ScDocumentLoader ==================================================
421 
422 OUString ScDocumentLoader::GetOptions( const SfxMedium& rMedium )
423 {
424  SfxItemSet* pSet = rMedium.GetItemSet();
425  const SfxPoolItem* pItem;
426  if ( pSet && SfxItemState::SET == pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
427  return static_cast<const SfxStringItem*>(pItem)->GetValue();
428 
429  return EMPTY_OUSTRING;
430 }
431 
432 bool ScDocumentLoader::GetFilterName( const OUString& rFileName,
433  OUString& rFilter, OUString& rOptions,
434  bool bWithContent, bool bWithInteraction )
435 {
436  SfxObjectShell* pDocSh = SfxObjectShell::GetFirst( checkSfxObjectShell<ScDocShell> );
437  while ( pDocSh )
438  {
439  if ( pDocSh->HasName() )
440  {
441  SfxMedium* pMed = pDocSh->GetMedium();
442  if ( pMed->GetName() == rFileName )
443  {
444  rFilter = pMed->GetFilter()->GetFilterName();
445  rOptions = GetOptions(*pMed);
446  return true;
447  }
448  }
449  pDocSh = SfxObjectShell::GetNext( *pDocSh, checkSfxObjectShell<ScDocShell> );
450  }
451 
452  INetURLObject aUrl( rFileName );
453  INetProtocol eProt = aUrl.GetProtocol();
454  if ( eProt == INetProtocol::NotValid ) // invalid URL?
455  return false; // abort without creating a medium
456 
457  // Filter detection
458 
459  std::shared_ptr<const SfxFilter> pSfxFilter;
460  auto pMedium = std::make_unique<SfxMedium>( rFileName, StreamMode::STD_READ );
462  {
463  if ( bWithInteraction )
464  pMedium->UseInteractionHandler(true); // #i73992# no longer called from GuessFilter
465 
466  SfxFilterMatcher aMatcher("scalc");
467  if( bWithContent )
468  aMatcher.GuessFilter( *pMedium, pSfxFilter );
469  else
470  aMatcher.GuessFilterIgnoringContent( *pMedium, pSfxFilter );
471  }
472 
473  bool bOK = false;
474  if ( pMedium->GetError() == ERRCODE_NONE )
475  {
476  if ( pSfxFilter )
477  rFilter = pSfxFilter->GetFilterName();
478  else
479  rFilter = ScDocShell::GetOwnFilterName(); // otherwise Calc file
480  bOK = !rFilter.isEmpty();
481  }
482 
483  return bOK;
484 }
485 
486 void ScDocumentLoader::RemoveAppPrefix( OUString& rFilterName )
487 {
488  OUString aAppPrefix( STRING_SCAPP ": ");
489  if (rFilterName.startsWith( aAppPrefix))
490  rFilterName = rFilterName.copy( aAppPrefix.getLength());
491 }
492 
493 SfxMedium* ScDocumentLoader::CreateMedium( const OUString& rFileName, std::shared_ptr<const SfxFilter> const & pFilter,
494  const OUString& rOptions, weld::Window* pInteractionParent )
495 {
496  // Always create SfxItemSet so ScDocShell can set options.
497  auto pSet = std::make_shared<SfxAllItemSet>( SfxGetpApp()->GetPool() );
498  if ( !rOptions.isEmpty() )
499  pSet->Put( SfxStringItem( SID_FILE_FILTEROPTIONS, rOptions ) );
500 
501  if (pInteractionParent)
502  {
503  css::uno::Reference<css::uno::XComponentContext> xContext = comphelper::getProcessComponentContext();
504  css::uno::Reference<css::task::XInteractionHandler> xIHdl(css::task::InteractionHandler::createWithParent(xContext,
505  pInteractionParent->GetXWindow()), css::uno::UNO_QUERY_THROW);
506  pSet->Put(SfxUnoAnyItem(SID_INTERACTIONHANDLER, makeAny(xIHdl)));
507  }
508 
509  SfxMedium *pRet = new SfxMedium( rFileName, StreamMode::STD_READ, pFilter, std::move(pSet) );
510  if (pInteractionParent)
511  pRet->UseInteractionHandler(true); // to enable the filter options dialog
512  return pRet;
513 }
514 
515 ScDocumentLoader::ScDocumentLoader(const OUString& rFileName,
516  OUString& rFilterName, OUString& rOptions,
517  sal_uInt32 nRekCnt, weld::Window* pInteractionParent,
518  css::uno::Reference<css::io::XInputStream> xInputStream)
519  : pDocShell(nullptr)
520  , pMedium(nullptr)
521 {
522  if ( rFilterName.isEmpty() )
523  GetFilterName(rFileName, rFilterName, rOptions, true, pInteractionParent != nullptr);
524 
525  std::shared_ptr<const SfxFilter> pFilter = ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName( rFilterName );
526 
527  pMedium = CreateMedium(rFileName, pFilter, rOptions, pInteractionParent);
528  if (xInputStream.is())
529  pMedium->setStreamToLoadFrom(xInputStream, true);
530  if ( pMedium->GetError() != ERRCODE_NONE )
531  return ;
532 
533  pDocShell = new ScDocShell( SfxModelFlags::EMBEDDED_OBJECT | SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS );
534  aRef = pDocShell;
535 
536  ScDocument& rDoc = pDocShell->GetDocument();
537  ScExtDocOptions* pExtDocOpt = rDoc.GetExtDocOptions();
538  if( !pExtDocOpt )
539  {
540  rDoc.SetExtDocOptions( std::make_unique<ScExtDocOptions>() );
541  pExtDocOpt = rDoc.GetExtDocOptions();
542  }
543  pExtDocOpt->GetDocSettings().mnLinkCnt = nRekCnt;
544 
546 
547  OUString aNew = GetOptions(*pMedium); // options are set per dialog on load
548  if (!aNew.isEmpty() && aNew != rOptions)
549  rOptions = aNew;
550 }
551 
553 {
554  if ( aRef.is() )
555  aRef->DoClose();
556  else
557  delete pMedium;
558 }
559 
561 {
562  if ( aRef.is() )
563  {
564  // release reference without calling DoClose - caller must
565  // have another reference to the doc and call DoClose later
566 
567  pDocShell = nullptr;
568  pMedium = nullptr;
569  aRef.clear();
570  }
571 }
572 
574 {
575  return pDocShell ? &pDocShell->GetDocument() : nullptr;
576 }
577 
579 {
580  if ( pDocShell && pMedium )
581  return pMedium->GetError() != ERRCODE_NONE;
582  else
583  return true;
584 }
585 
587 {
588  if ( pDocShell )
589  return pDocShell->GetTitle();
590  else
591  return EMPTY_OUSTRING;
592 }
593 
594 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SC_DLLPUBLIC OUString GetLinkDoc(SCTAB nTab) const
Definition: documen3.cxx:506
bool is() const
ocStop
static OUString GetOwnFilterName()
Definition: docsh.cxx:2677
ScAddress aStart
Definition: address.hxx:500
virtual css::uno::Reference< css::awt::XWindow > GetXWindow()=0
static SC_DLLPUBLIC OUString GetDocTabName(const OUString &rFileName, const OUString &rTabName)
Definition: global2.cxx:321
SC_DLLPUBLIC ScLinkMode GetLinkMode(SCTAB nTab) const
Definition: documen3.cxx:499
#define STRING_SCAPP
Definition: global.hxx:54
#define EMPTY_OUSTRING
Definition: global.hxx:214
SCROW Row() const
Definition: address.hxx:262
OUString GetTitle(sal_uInt16 nMaxLen=0) const
static SC_DLLPUBLIC::utl::TransliterationWrapper * GetpTransliteration()
Definition: global.cxx:976
void SetInLinkUpdate(bool bSet)
Definition: documen8.cxx:774
static void RemoveAppPrefix(OUString &rFilterName)
Definition: tablink.cxx:486
const OUString & GetName() const
sal_uIntPtr sal_uLong
void ReleaseDocRef()
Definition: tablink.cxx:560
ocOpen
const ScExtDocSettings & GetDocSettings() const
Definition: scextopt.cxx:170
ErrCode GuessFilter(SfxMedium &rMedium, std::shared_ptr< const SfxFilter > &, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
ScAddress aEnd
Definition: address.hxx:501
Extended options held by an ScDocument containing additional settings for filters.
Definition: scextopt.hxx:77
bool IsLinked(SCTAB nTab) const
Definition: documen3.cxx:480
ScFormulaCell * getFormulaCell()
Definition: dociter.hxx:239
ErrCode GetError() const
SfxApplication * SfxGetpApp()
CellType getType() const
Definition: dociter.hxx:236
SC_DLLPUBLIC bool RenameTab(SCTAB nTab, const OUString &rName, bool bExternalDocument=false)
Definition: document.cxx:853
OUString GetTitle() const
Definition: tablink.cxx:586
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:873
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:314
static bool IsFuzzing()
int nCount
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)
Definition: document.cxx:2076
SC_DLLPUBLIC bool GetTable(const OUString &rName, SCTAB &rTab) const
Definition: document.cxx:260
Walk through all cells in an area.
Definition: dociter.hxx:208
ScLinkMode
Definition: global.hxx:225
SCTAB Tab() const
Definition: address.hxx:271
SotClipboardFormatId
INetProtocol
static OUString GetOptions(const SfxMedium &rMedium)
Definition: tablink.cxx:422
sal_uInt32 mnLinkCnt
Recursive counter for loading external documents.
Definition: scextopt.hxx:32
SfxItemPool & GetPool() const
SC_DLLPUBLIC bool SetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const ScSetStringParam *pParam=nullptr)
Definition: document.cxx:3363
static SC_DLLPUBLIC OUString GetAbsDocName(const OUString &rFileName, const SfxObjectShell *pShell)
Definition: global2.cxx:284
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:872
ScDocument * GetDocument()
Definition: tablink.cxx:573
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
Definition: document.hxx:2613
sal_Int16 SCCOL
Definition: types.hxx:22
void UseInteractionHandler(bool)
Iterator for references in a formula cell.
Definition: formulaiter.hxx:32
SC_DLLPUBLIC sal_uLong TransferTab(ScDocument &rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos, bool bInsertNew=true, bool bResultsOnly=false)
Definition: documen2.cxx:906
size_t size() const
Definition: rangelst.hxx:90
ocNotAvail
OUString ScResId(const char *pId)
Definition: scdll.cxx:95
void SetLink(SCTAB nTab, ScLinkMode nMode, const OUString &rDoc, const OUString &rFilter, const OUString &rOptions, const OUString &rTabName, sal_uLong nRefreshDelay)
Definition: documen3.cxx:541
SfxItemSet * GetItemSet() const
void BroadcastUno(const SfxHint &rHint)
Definition: documen3.cxx:944
bool HasName() const
const SCTAB MAXTAB
Definition: address.hxx:71
SfxMedium * pMedium
Definition: tablink.hxx:82
SfxObjectShellRef aRef
Definition: tablink.hxx:81
const std::shared_ptr< const SfxFilter > & GetFilter() const
void StopRefreshTimer()
SCCOL Col() const
Definition: address.hxx:267
bool IsError() const
Definition: tablink.cxx:578
ScDocShell * pDocShell
Definition: tablink.hxx:80
virtual formula::FormulaToken * AddOpCode(OpCode eCode) override
Definition: token.cxx:2195
static bool GetDisplayNames(const SvBaseLink *, OUString *pType, OUString *pFile=nullptr, OUString *pLink=nullptr, OUString *pFilter=nullptr)
SC_DLLPUBLIC Color GetTabBgColor(SCTAB nTab) const
Definition: documen3.cxx:443
sal_Int32 SCROW
Definition: types.hxx:18
bool GetNextRef(ScRange &rRange)
Definition: formulaiter.cxx:52
#define ERRCODE_NONE
void Join(const ScRange &, bool bIsInList=false)
Definition: rangelst.cxx:166
static SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
void SetRefreshControl(std::unique_ptr< ScRefreshTimerControl > const *pp)
OUString aName
INetProtocol GetProtocol() const
ScExtDocOptions * GetExtDocOptions()
Definition: document.hxx:639
Reference< XComponentContext > getProcessComponentContext()
void SetSheetLink(const OUString &rSourceUrl)
Definition: hints.cxx:62
SC_DLLPUBLIC OUString GetLinkTab(SCTAB nTab) const
Definition: documen3.cxx:527
const ScDocument & GetDocument() const
Definition: docsh.hxx:216
void SetDocumentModified()
Definition: docsh.cxx:3158
static bool GetFilterName(const OUString &rFileName, OUString &rFilter, OUString &rOptions, bool bWithContent, bool bWithInteraction)
Returns the filter name and options from a file name.
Definition: tablink.cxx:432
bool IsUndoEnabled() const
Definition: document.hxx:1531
static SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
static bool HasAutomaticTableName(const OUString &rFilter)
Definition: docsh.cxx:2712
bool DoLoad(SfxMedium *pMedium)
SC_DLLPUBLIC void SetExtDocOptions(std::unique_ptr< ScExtDocOptions > pNewOptions)
Definition: documen3.cxx:2005
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...
Definition: tablink.cxx:493
SC_DLLPUBLIC void DeleteAreaTab(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCTAB nTab, InsertDeleteFlags nDelFlag)
Definition: document.cxx:1955
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
Definition: document.cxx:213
sal_uLong GetRefreshDelay() const
ocClose
SC_DLLPUBLIC void SetFormula(const ScAddress &rPos, const ScTokenArray &rArray)
Definition: documen2.cxx:1063
Create before modifications of the document and destroy thereafter.
Definition: docsh.hxx:450
SfxLinkUpdateMode
sal_uInt16 nPos
sal_Int16 SCTAB
Definition: types.hxx:23
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 >())
Definition: tablink.cxx:515
SfxMedium * GetMedium() const
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)