[Libreoffice-commits] core.git: sc/inc sc/source vcl/workben
Caolán McNamara
caolanm at redhat.com
Fri Jun 2 10:22:46 UTC 2017
sc/inc/filter.hxx | 2 +-
sc/source/filter/excel/excel.cxx | 17 ++++++++++-------
sc/source/filter/inc/ftools.hxx | 2 +-
sc/source/filter/inc/qpro.hxx | 2 +-
sc/source/filter/qpro/qpro.cxx | 8 ++++----
sc/source/ui/docshell/docsh.cxx | 2 +-
sc/source/ui/docshell/impex.cxx | 2 +-
vcl/workben/fftester.cxx | 23 ++++++++++++++++++-----
8 files changed, 37 insertions(+), 21 deletions(-)
New commits:
commit 2b61ae38d410e0748e53ac3c0d361ab622da1fb5
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Jun 2 11:19:36 2017 +0100
rework ScQProReader to take SvStream instead of SfxMedium
its only uses the stream anyway and this makes it far
easier to build a fuzzer on
Change-Id: I4aa8b56d4b041708c4de1730d503641ab23c14e8
diff --git a/sc/inc/filter.hxx b/sc/inc/filter.hxx
index c96e9c20e49b..ce4fac78d442 100644
--- a/sc/inc/filter.hxx
+++ b/sc/inc/filter.hxx
@@ -75,7 +75,7 @@ class SAL_DLLPUBLIC_RTTI ScFormatFilterPlugin {
public:
// various import filters
virtual FltError ScImportLotus123( SfxMedium&, ScDocument*, rtl_TextEncoding eSrc ) = 0;
- virtual FltError ScImportQuattroPro( SfxMedium &rMedium, ScDocument *pDoc ) = 0;
+ virtual FltError ScImportQuattroPro(SvStream* pStream, ScDocument *pDoc) = 0;
virtual FltError ScImportExcel( SfxMedium&, ScDocument*, const EXCIMPFORMAT ) = 0;
// eFormat == EIF_AUTO -> matching filter is used automatically
// eFormat == EIF_BIFF5 -> only Biff5 stream is read successfully (in an Excel97 doc, too)
diff --git a/sc/source/filter/excel/excel.cxx b/sc/source/filter/excel/excel.cxx
index e5462e838a0e..8988935f80f0 100644
--- a/sc/source/filter/excel/excel.cxx
+++ b/sc/source/filter/excel/excel.cxx
@@ -219,18 +219,21 @@ FltError ScFormatFilterPluginImpl::ScExportExcel5( SfxMedium& rMedium, ScDocumen
return eRet;
}
-extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportSpreadsheet(const OUString &rURL, const OUString &rFlt)
+extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportQPW(SvStream &rStream)
+{
+ ScDLL::Init();
+ ScDocument aDocument;
+ aDocument.MakeTable(0);
+ return ScFormatFilter::Get().ScImportQuattroPro(&rStream, &aDocument) == eERR_OK;
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportXLS(const OUString &rURL)
{
ScDLL::Init();
SfxMedium aMedium(rURL, StreamMode::READ);
ScDocument aDocument;
aDocument.MakeTable(0);
- FltError eError(eERR_OK);
- if (rFlt == "xls")
- eError = ScFormatFilter::Get().ScImportExcel(aMedium, &aDocument, EIF_AUTO);
- else if (rFlt == "wb2")
- eError = ScFormatFilter::Get().ScImportQuattroPro(aMedium, &aDocument);
- return eError == eERR_OK;
+ return ScFormatFilter::Get().ScImportExcel(aMedium, &aDocument, EIF_AUTO) == eERR_OK;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/inc/ftools.hxx b/sc/source/filter/inc/ftools.hxx
index ea2ce501ac67..c1403dea28f1 100644
--- a/sc/source/filter/inc/ftools.hxx
+++ b/sc/source/filter/inc/ftools.hxx
@@ -264,7 +264,7 @@ public:
virtual ~ScFormatFilterPluginImpl();
// various import filters
virtual FltError ScImportLotus123( SfxMedium&, ScDocument*, rtl_TextEncoding eSrc ) override;
- virtual FltError ScImportQuattroPro( SfxMedium &rMedium, ScDocument *pDoc ) override;
+ virtual FltError ScImportQuattroPro(SvStream* pStream, ScDocument *pDoc) override;
virtual FltError ScImportExcel( SfxMedium&, ScDocument*, const EXCIMPFORMAT ) override;
// eFormat == EIF_AUTO -> matching filter is used automatically
// eFormat == EIF_BIFF5 -> only Biff5 stream leads to success (even in an Excel97 doc)
diff --git a/sc/source/filter/inc/qpro.hxx b/sc/source/filter/inc/qpro.hxx
index 751ec859109b..55e5e7ccd1bb 100644
--- a/sc/source/filter/inc/qpro.hxx
+++ b/sc/source/filter/inc/qpro.hxx
@@ -40,7 +40,7 @@ class ScQProReader
bool mbEndOfFile;
public:
- ScQProReader( SfxMedium &rMedium );
+ ScQProReader(SvStream* pStream);
~ScQProReader();
bool recordsLeft();
diff --git a/sc/source/filter/qpro/qpro.cxx b/sc/source/filter/qpro/qpro.cxx
index 07adc4d4ccfd..5b35e3b155c8 100644
--- a/sc/source/filter/qpro/qpro.cxx
+++ b/sc/source/filter/qpro/qpro.cxx
@@ -123,20 +123,20 @@ FltError ScQProReader::readSheet( SCTAB nTab, ScDocument* pDoc, ScQProStyle *pSt
return eRet;
}
-FltError ScFormatFilterPluginImpl::ScImportQuattroPro( SfxMedium &rMedium, ScDocument *pDoc )
+FltError ScFormatFilterPluginImpl::ScImportQuattroPro(SvStream *pStream, ScDocument *pDoc)
{
- ScQProReader aReader( rMedium );
+ ScQProReader aReader(pStream);
FltError eRet = aReader.import( pDoc );
return eRet;
}
-ScQProReader::ScQProReader( SfxMedium &rMedium )
+ScQProReader::ScQProReader(SvStream* pStream)
: mnId(0)
, mnLength(0)
, mnOffset(0)
+ , mpStream(pStream)
, mbEndOfFile(false)
{
- mpStream = rMedium.GetInStream();
if( mpStream )
{
mpStream->SetBufferSize( 65535 );
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 03131b4be5cd..a1011779ea2f 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -1372,7 +1372,7 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium )
}
else if (aFltName == pFilterQPro6)
{
- FltError eError = ScFormatFilter::Get().ScImportQuattroPro( rMedium, &aDocument);
+ FltError eError = ScFormatFilter::Get().ScImportQuattroPro(rMedium.GetInStream(), &aDocument);
if (eError != eERR_OK)
{
if (!GetError())
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 70288a814c8b..22b9a1b3f5d7 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -2217,7 +2217,7 @@ class ScFormatFilterMissing : public ScFormatFilterPlugin {
}
virtual ~ScFormatFilterMissing() {}
virtual FltError ScImportLotus123( SfxMedium&, ScDocument*, rtl_TextEncoding ) override { return eERR_INTERN; }
- virtual FltError ScImportQuattroPro( SfxMedium &, ScDocument * ) override { return eERR_INTERN; }
+ virtual FltError ScImportQuattroPro(SvStream*, ScDocument *) override { return eERR_INTERN; }
virtual FltError ScImportExcel( SfxMedium&, ScDocument*, const EXCIMPFORMAT ) override { return eERR_INTERN; }
virtual FltError ScImportStarCalc10( SvStream&, ScDocument* ) override { return eERR_INTERN; }
virtual FltError ScImportDif( SvStream&, ScDocument*, const ScAddress&,
diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx
index 0251274b0ee9..eae827a81e9f 100644
--- a/vcl/workben/fftester.cxx
+++ b/vcl/workben/fftester.cxx
@@ -66,7 +66,7 @@ using namespace cppu;
extern "C" { static void SAL_CALL thisModule() {} }
#endif
-typedef bool (*WFilterCall)(const OUString &rUrl, const OUString &rFlt);
+typedef bool (*WFilterCall)(const OUString &rUrl);
typedef bool (*FFilterCall)(SvStream &rStream);
/* This constant specifies the number of inputs to process before restarting.
@@ -379,8 +379,7 @@ try_again:
SvFileStream aFileStream(out, StreamMode::READ);
ret = (int) (*pfnImport)(aFileStream);
}
- else if ( (strcmp(argv[2], "xls") == 0) ||
- (strcmp(argv[2], "wb2") == 0) )
+ else if (strcmp(argv[2], "xls") == 0)
{
static WFilterCall pfnImport(nullptr);
if (!pfnImport)
@@ -388,10 +387,24 @@ try_again:
osl::Module aLibrary;
aLibrary.loadRelative(&thisModule, "libscfiltlo.so", SAL_LOADMODULE_LAZY);
pfnImport = reinterpret_cast<WFilterCall>(
- aLibrary.getFunctionSymbol("TestImportSpreadsheet"));
+ aLibrary.getFunctionSymbol("TestImportXLS"));
aLibrary.release();
}
- ret = (int) (*pfnImport)(out, OUString(argv[2], strlen(argv[2]), RTL_TEXTENCODING_UTF8));
+ ret = (int) (*pfnImport)(out);
+ }
+ else if (strcmp(argv[2], "ww2") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ osl::Module aLibrary;
+ aLibrary.loadRelative(&thisModule, "libscfiltlo.so", SAL_LOADMODULE_LAZY);
+ pfnImport = reinterpret_cast<FFilterCall>(
+ aLibrary.getFunctionSymbol("TestImportQPW"));
+ aLibrary.release();
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = (int) (*pfnImport)(aFileStream);
}
else if (strcmp(argv[2], "hwp") == 0)
{
More information about the Libreoffice-commits
mailing list