/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// if new filter has been selected, forget options if (aFilterName != rNewFilter)
aOptions.clear(); if ( pNewOptions ) // options hard-specified?
aOptions = *pNewOptions;
// always create ItemSet, so that DocShell can set the options auto pSet = std::make_shared<SfxAllItemSet>( SfxGetpApp()->GetPool() ); if (!aOptions.isEmpty())
pSet->Put( SfxStringItem( SID_FILE_FILTEROPTIONS, aOptions ) );
SfxMedium* pMed = new SfxMedium(aNewUrl, StreamMode::STD_READ, std::move(pFilter), std::move(pSet));
if ( bInEdit ) // only if using the edit dialog,
pMed->UseInteractionHandler(true); // enable the filter options dialog
// aRef->DoClose() will be called explicitly, but it is still more safe to use SfxObjectShellLock here
rtl::Reference<ScDocShell> pSrcShell = new ScDocShell(SfxModelFlags::EMBEDDED_OBJECT | SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS);
pSrcShell->DoLoad(pMed);
// options might have been set
OUString aNewOpt = ScDocumentLoader::GetOptions(*pMed); if (aNewOpt.isEmpty())
aNewOpt = aOptions;
// from text filters that don't set the table name, // use the one table regardless of link table name bool bAutoTab = (rSrcDoc.GetTableCount() == 1) &&
ScDocShell::HasAutomaticTableName( rNewFilter );
SCTAB nSrcTab = 0; bool bFound = false; /* #i71497# check if external document is loaded successfully, otherwise we may find the empty default sheet "Sheet1" in
rSrcDoc, even if the document does not exist. */ if( pMed->GetErrorIgnoreWarning() == ERRCODE_NONE )
{ // no sheet name -> use first sheet if ( !aTabName.isEmpty() && !bAutoTab )
bFound = rSrcDoc.GetTable( aTabName, nSrcTab ); else
bFound = true;
}
bool bShowError = true; if ( nMode == ScLinkMode::VALUE )
{ // Value link (used with external references in formulas): // Look for formulas that reference the sheet, and put errors in the referenced cells.
ScRangeList aErrorCells; // cells on the linked sheets that need error values
ScCellIterator aIter(rDoc, ScRange(0,0,0,rDoc.MaxCol(),rDoc.MaxRow(),MAXTAB)); // all sheets for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
{ if (aIter.getType() != CELLTYPE_FORMULA) continue;
ScFormulaCell* pCell = aIter.getFormulaCell();
ScDetectiveRefIter aRefIter(rDoc, pCell);
ScRange aRefRange; while ( aRefIter.GetNextRef( aRefRange ) )
{ if ( aRefRange.aStart.Tab() <= nTab && aRefRange.aEnd.Tab() >= nTab )
{ // use first cell of range references (don't fill potentially large ranges)
// notify Uno objects (for XRefreshListener) //! also notify Uno objects if file name was changed!
ScLinkRefreshedHint aHint;
aHint.SetSheetLink( aFileName );
rDoc.BroadcastUno( aHint );
OUString aNew = GetOptions(*pMedium); // options are set per dialog on load if (!aNew.isEmpty() && aNew != rOptions)
rOptions = aNew;
}
ScDocumentLoader::~ScDocumentLoader()
{ if (pDocShell)
pDocShell->DoClose(); else delete pMedium;
}
void ScDocumentLoader::ReleaseDocRef()
{ if (pDocShell)
{ // release reference without calling DoClose - caller must // have another reference to the doc and call DoClose later
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.