diff options
Diffstat (limited to 'sc/source/filter/oox/excelfilter.cxx')
-rw-r--r-- | sc/source/filter/oox/excelfilter.cxx | 69 |
1 files changed, 67 insertions, 2 deletions
diff --git a/sc/source/filter/oox/excelfilter.cxx b/sc/source/filter/oox/excelfilter.cxx index 171f5ff67cf7..55cee4841b7f 100644 --- a/sc/source/filter/oox/excelfilter.cxx +++ b/sc/source/filter/oox/excelfilter.cxx @@ -30,6 +30,15 @@ #include <workbookfragment.hxx> #include <xestream.hxx> +#include <addressconverter.hxx> +#include <document.hxx> +#include <docsh.hxx> +#include <scerrors.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/vclptr.hxx> +#include <svtools/sfxecode.hxx> +#include <tools/urlobj.hxx> + namespace oox { namespace xls { @@ -97,9 +106,65 @@ bool ExcelFilter::importDocument() the class WorkbookHelper, and execute the import filter by constructing an instance of WorkbookFragment and loading the file. */ WorkbookGlobalsRef xBookGlob(WorkbookHelper::constructGlobals(*this)); - if (xBookGlob.get() && importFragment(new WorkbookFragment(*xBookGlob, aWorkbookPath))) + if (xBookGlob.get()) { - return true; + rtl::Reference<FragmentHandler> xWorkbookFragment( new WorkbookFragment(*xBookGlob, aWorkbookPath)); + bool bRet = importFragment( xWorkbookFragment); + if (bRet) + { + const WorkbookFragment* pWF = static_cast<const WorkbookFragment*>(xWorkbookFragment.get()); + const AddressConverter& rAC = pWF->getAddressConverter(); + if (rAC.isTabOverflow() || rAC.isColOverflow() || rAC.isRowOverflow()) + { + const ScDocument& rDoc = pWF->getScDocument(); + if (rDoc.IsUserInteractionEnabled()) + { + // Show data loss warning. + + INetURLObject aURL( getFileUrl()); + SfxErrorContext aContext( ERRCTX_SFX_OPENDOC, + aURL.getName( INetURLObject::LAST_SEGMENT, true, + INetURLObject::DecodeMechanism::WithCharset), + nullptr, getRID_ERRCTX()); + + OUString aWarning; + aContext.GetString( ERRCODE_NONE.MakeWarning(), aWarning); + aWarning += ":\n"; + + OUString aMsg; + if (rAC.isTabOverflow()) + { + if (ErrorHandler::GetErrorString( SCWARN_IMPORT_SHEET_OVERFLOW, aMsg)) + aWarning += aMsg; + } + if (rAC.isColOverflow()) + { + if (!aMsg.isEmpty()) + aWarning += "\n"; + if (ErrorHandler::GetErrorString( SCWARN_IMPORT_COLUMN_OVERFLOW, aMsg)) + aWarning += aMsg; + } + if (rAC.isRowOverflow()) + { + if (!aMsg.isEmpty()) + aWarning += "\n"; + if (ErrorHandler::GetErrorString( SCWARN_IMPORT_ROW_OVERFLOW, aMsg)) + aWarning += aMsg; + } + + /* XXX displaying a dialog here is ugly and should + * rather happen at UI level instead of at the filter + * level, but it seems there's no way to transport + * detailed information other than returning true or + * false at this point? */ + + ScopedVclPtrInstance<WarningBox> pBox( ScDocShell::GetActiveDialogParent(), + MessBoxStyle::Ok | MessBoxStyle::DefaultOk, aWarning); + pBox->Execute(); + } + } + } + return bRet; } } catch (...) |