SwFiltersTest::filter: detect import filter on export test
This allows e.g. crash-testing the RTF export, even if the input source is not RTF but ODT. Change-Id: I3cf6afd1bc44bb475f1bd8da622d10dac0d3baa6
This commit is contained in:
@@ -73,6 +73,8 @@ $(eval $(call gb_CppunitTest_use_components,sw_filters_test,\
|
|||||||
svtools/util/svt \
|
svtools/util/svt \
|
||||||
sw/util/msword \
|
sw/util/msword \
|
||||||
sw/util/sw \
|
sw/util/sw \
|
||||||
|
sw/util/swd \
|
||||||
|
uui/util/uui \
|
||||||
toolkit/util/tk \
|
toolkit/util/tk \
|
||||||
ucb/source/core/ucb1 \
|
ucb/source/core/ucb1 \
|
||||||
ucb/source/ucp/file/ucpfile1 \
|
ucb/source/ucp/file/ucpfile1 \
|
||||||
|
@@ -91,7 +91,18 @@ bool SwFiltersTest::filter(const OUString &rFilter, const OUString &rURL,
|
|||||||
|
|
||||||
SwDocShellRef xDocShRef = new SwDocShell;
|
SwDocShellRef xDocShRef = new SwDocShell;
|
||||||
SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ);
|
SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ);
|
||||||
pSrcMed->SetFilter(pFilter);
|
|
||||||
|
const SfxFilter* pImportFilter = 0;
|
||||||
|
SfxFilter* pExportFilter = 0;
|
||||||
|
if (bExport)
|
||||||
|
{
|
||||||
|
SFX_APP()->GetFilterMatcher().GuessFilter(*pSrcMed, &pImportFilter, SFX_FILTER_IMPORT, 0);
|
||||||
|
pExportFilter = pFilter;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pImportFilter = pFilter;
|
||||||
|
|
||||||
|
pSrcMed->SetFilter(pImportFilter);
|
||||||
|
|
||||||
if (rUserData == FILTER_TEXT_DLG)
|
if (rUserData == FILTER_TEXT_DLG)
|
||||||
{
|
{
|
||||||
@@ -107,10 +118,14 @@ bool SwFiltersTest::filter(const OUString &rFilter, const OUString &rURL,
|
|||||||
return bLoaded;
|
return bLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// How come an error may be set, and still DoLoad() returns success? Strange...
|
||||||
|
if (bLoaded)
|
||||||
|
xDocShRef->ResetError();
|
||||||
|
|
||||||
utl::TempFile aTempFile;
|
utl::TempFile aTempFile;
|
||||||
aTempFile.EnableKillingFile();
|
aTempFile.EnableKillingFile();
|
||||||
SfxMedium aDstMed(aTempFile.GetURL(), STREAM_STD_WRITE);
|
SfxMedium aDstMed(aTempFile.GetURL(), STREAM_STD_WRITE);
|
||||||
aDstMed.SetFilter(pFilter);
|
aDstMed.SetFilter(pExportFilter);
|
||||||
bool bSaved = xDocShRef->DoSaveAs(aDstMed);
|
bool bSaved = xDocShRef->DoSaveAs(aDstMed);
|
||||||
if (xDocShRef.Is())
|
if (xDocShRef.Is())
|
||||||
xDocShRef->DoClose();
|
xDocShRef->DoClose();
|
||||||
|
@@ -579,11 +579,6 @@ DECLARE_RTFEXPORT_TEST(testFdo66743, "fdo66743.rtf")
|
|||||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(0xd8d8d8), getProperty<sal_Int32>(xCell, "BackColor"));
|
CPPUNIT_ASSERT_EQUAL(sal_Int32(0xd8d8d8), getProperty<sal_Int32>(xCell, "BackColor"));
|
||||||
}
|
}
|
||||||
|
|
||||||
DECLARE_RTFEXPORT_TEST(testI23357, "i23357.odt")
|
|
||||||
{
|
|
||||||
// crashtest
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
Reference in New Issue
Block a user