sc/source/filter/excel/excel.cxx | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
New commits: commit b6937a5c9d99dd1e7110d01f69923f45047259fe Author: Caolán McNamara <caol...@redhat.com> Date: Mon Nov 20 09:46:23 2017 +0000 ofz#4306 Null-dereference READ Change-Id: Iccbaed9ab6252ac8c61104ac0e6a9b8972913f6c Reviewed-on: https://gerrit.libreoffice.org/44954 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/sc/source/filter/excel/excel.cxx b/sc/source/filter/excel/excel.cxx index 1954b02035be..536207f2e00a 100644 --- a/sc/source/filter/excel/excel.cxx +++ b/sc/source/filter/excel/excel.cxx @@ -38,6 +38,7 @@ #include <optuno.hxx> #include <xistream.hxx> +#include <docsh.hxx> #include <scerrors.hxx> #include <root.hxx> #include <imp_op.hxx> @@ -252,20 +253,31 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportXLS(SvStream& rStream) SfxMedium aMedium; css::uno::Reference<css::io::XInputStream> xStm(new utl::OInputStreamWrapper(rStream)); aMedium.GetItemSet()->Put(SfxUsrAnyItem(SID_INPUTSTREAM, css::uno::makeAny(xStm))); - ScDocument aDocument; - ScDocOptions aDocOpt = aDocument.GetDocOptions(); + + ScDocShellRef xDocShell = new ScDocShell(SfxModelFlags::EMBEDDED_OBJECT | + SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS | + SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); + + xDocShell->DoInitNew(); + + ScDocument& rDoc = xDocShell->GetDocument(); + + ScDocOptions aDocOpt = rDoc.GetDocOptions(); aDocOpt.SetLookUpColRowNames(false); - aDocument.SetDocOptions(aDocOpt); - aDocument.MakeTable(0); - aDocument.EnableExecuteLink(false); + rDoc.SetDocOptions(aDocOpt); + rDoc.MakeTable(0); + rDoc.EnableExecuteLink(false); + rDoc.InitDrawLayer(xDocShell.get()); bool bRet(false); try { - bRet = ScFormatFilter::Get().ScImportExcel(aMedium, &aDocument, EIF_AUTO) == ERRCODE_NONE; + bRet = ScFormatFilter::Get().ScImportExcel(aMedium, &rDoc, EIF_AUTO) == ERRCODE_NONE; } catch (const css::ucb::ContentCreationException &) { } + xDocShell->DoClose(); + xDocShell.clear(); return bRet; } @@ -293,7 +305,6 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportDIF(SvStream &rStream) aDocument.SetDocOptions(aDocOpt); aDocument.MakeTable(0); aDocument.EnableExecuteLink(false); - aDocument.InitDrawLayer(nullptr); return ScFormatFilter::Get().ScImportDif(rStream, &aDocument, ScAddress(0, 0, 0), RTL_TEXTENCODING_IBM_850) == ERRCODE_NONE; }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits