[Libreoffice-commits] core.git: 2 commits - vcl/qa vcl/source
Tomaž Vajngerl
quikee at gmail.com
Sat Jun 22 04:57:33 PDT 2013
vcl/qa/cppunit/graphicfilter/filters-test.cxx | 64 +++++++++++++++++++++++---
vcl/source/filter/graphicfilter.cxx | 2
2 files changed, 58 insertions(+), 8 deletions(-)
New commits:
commit d88b434e10ef356d6937da0bcb2b3e33e6ab4bb5
Author: Tomaž Vajngerl <quikee at gmail.com>
Date: Sat Jun 22 13:53:32 2013 +0200
Export-Import GraphicFilter Test
Change-Id: Ic24543ea62bf1ab922ff49fb0f2c82feb1782e83
diff --git a/vcl/qa/cppunit/graphicfilter/filters-test.cxx b/vcl/qa/cppunit/graphicfilter/filters-test.cxx
index 7d73e2c..47d4fe6 100644
--- a/vcl/qa/cppunit/graphicfilter/filters-test.cxx
+++ b/vcl/qa/cppunit/graphicfilter/filters-test.cxx
@@ -22,28 +22,36 @@ using namespace ::com::sun::star;
/* Implementation of Filters test */
-class VclFiltersTest
- : public test::FiltersTest
- , public test::BootstrapFixture
+class VclFiltersTest :
+ public test::FiltersTest,
+ public test::BootstrapFixture
{
+ GraphicFilter mGraphicFilter;
public:
- VclFiltersTest() : BootstrapFixture(true, false) {}
+ VclFiltersTest() :
+ BootstrapFixture(true, false),
+ mGraphicFilter(GraphicFilter(false))
+ {}
virtual bool load(const OUString &,
const OUString &rURL, const OUString &,
unsigned int, unsigned int, unsigned int);
+ void checkExportImport(OUString aFilterShortName);
+
/**
* Ensure CVEs remain unbroken
*/
void testCVEs();
- /// test scaling
void testScaling();
+ void testExportImport();
+
CPPUNIT_TEST_SUITE(VclFiltersTest);
CPPUNIT_TEST(testCVEs);
CPPUNIT_TEST(testScaling);
+ CPPUNIT_TEST(testExportImport);
CPPUNIT_TEST_SUITE_END();
};
@@ -51,10 +59,9 @@ bool VclFiltersTest::load(const OUString &,
const OUString &rURL, const OUString &,
unsigned int, unsigned int, unsigned int)
{
- GraphicFilter aGraphicFilter(false);
SvFileStream aFileStream(rURL, STREAM_READ);
Graphic aGraphic;
- return aGraphicFilter.ImportGraphic(aGraphic, rURL, aFileStream) == 0;
+ return mGraphicFilter.ImportGraphic(aGraphic, rURL, aFileStream) == 0;
}
void VclFiltersTest::testScaling()
@@ -73,6 +80,49 @@ void VclFiltersTest::testScaling()
}
}
+void VclFiltersTest::checkExportImport(OUString aFilterShortName)
+{
+ Bitmap aBitmap( Size( 100, 100 ), 24 );
+ aBitmap.Erase(COL_WHITE);
+
+ SvMemoryStream aStream;
+ aStream.SetVersion( SOFFICE_FILEFORMAT_CURRENT );
+
+ css::uno::Sequence< css::beans::PropertyValue > aFilterData( 3 );
+ aFilterData[ 0 ].Name = "Interlaced";
+ aFilterData[ 0 ].Value <<= (sal_Int32) 0;
+ aFilterData[ 1 ].Name = "Compression";
+ aFilterData[ 1 ].Value <<= (sal_Int32) 1;
+ aFilterData[ 2 ].Name = "Quality";
+ aFilterData[ 2 ].Value <<= (sal_Int32) 90;
+
+ sal_uInt16 aFilterType = mGraphicFilter.GetExportFormatNumberForShortName(aFilterShortName);
+ mGraphicFilter.ExportGraphic( aBitmap, OUString(), aStream, aFilterType, &aFilterData );
+
+ CPPUNIT_ASSERT(aStream.Tell() > 0);
+
+ aStream.Seek( STREAM_SEEK_TO_BEGIN );
+
+ Graphic aLoadedGraphic;
+ mGraphicFilter.ImportGraphic( aLoadedGraphic, OUString(), aStream );
+
+ BitmapEx aLoadedBitmapEx = aLoadedGraphic.GetBitmapEx();
+ Size aSize = aLoadedBitmapEx.GetSizePixel();
+
+ CPPUNIT_ASSERT_EQUAL(100L, aSize.Width());
+ CPPUNIT_ASSERT_EQUAL(100L, aSize.Height());
+}
+
+void VclFiltersTest::testExportImport()
+{
+ fprintf(stderr, "Check ExportImport JPG\n");
+ checkExportImport(OUString("jpg"));
+ fprintf(stderr, "Check ExportImport PNG\n");
+ checkExportImport(OUString("png"));
+ fprintf(stderr, "Check ExportImport BMP\n");
+ checkExportImport(OUString("bmp"));
+}
+
void VclFiltersTest::testCVEs()
{
#ifndef DISABLE_CVE_TESTS
commit 4449a227c86807af70abf4837d32fcd17181340d
Author: Tomaž Vajngerl <quikee at gmail.com>
Date: Sat Jun 22 13:31:21 2013 +0200
fdo#65934 and fdo#64189 External export graphic filter name fix
Change-Id: I798fac589abeac61115210cd4805e6b53a8767c6
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 82287f4..d2198d3 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -2057,7 +2057,7 @@ sal_uInt16 GraphicFilter::ExportGraphic( const Graphic& rGraphic, const String&
String aPhysicalName( ImpCreateFullFilterPath( getToken(aFilterPath, i, ';'), aFilterName ) );
osl::Module aLibrary( aPhysicalName );
- PFilterCall pFunc = (PFilterCall) aLibrary.getFunctionSymbol(OUString(aFilterName+EXPORT_FUNCTION_NAME));
+ PFilterCall pFunc = (PFilterCall) aLibrary.getFunctionSymbol(OUString(EXPORT_FUNCTION_NAME));
// Execute dialog in DLL
#else
PFilterCall pFunc = NULL;
More information about the Libreoffice-commits
mailing list