introduce graphic format detector (and basic metadata)

Desktop / LibreOffice - Toma┼ż Vajngerl [collabora.co.uk] - 10 May 2019 07:00 EDT

Currently we detect a graphic format in a ImpPeekGraphicFormat method, which is called when reading a graphic from a stream. The code is quite convoluted and doesn't help with readability of graphicfilter.cxx

Additionally there exists an detection code written for the UNO class GraphicDescriptor, which duplicates the detection, but can in addition also extract other metadata at the same time.

This introduces the initial implementation of GraphicFormatDetector class. It will first replace the code in ImpPeekGraphicFormat to detect the graphic format and then later also be extended to do what the GraphicDescriptor is doing. But currently it only duplicates the implementation of ImpPeekGraphicFormat.

The problem with both of the current solution is that there are not any tests written. For the GraphicFormatDetector however the approach is to add test cases to check the current implementation and only then refactor the code.

Change-Id: Idb9d3859b4380e3f15237d97aff969ce81e631dd Reviewed-on: https://gerrit.libreoffice.org/72086

e16641769df8 introduce graphic format detector (and basic metadata)
vcl/CppunitTest_vcl_graphic_test.mk | 1 +
vcl/Library_vcl.mk | 1 +
vcl/inc/graphic/GraphicFormatDetector.hxx | 76 ++++
vcl/qa/cppunit/GraphicFormatDetectorTest.cxx | 300 ++++++++++++++
vcl/qa/cppunit/data/TypeDetectionExample.bmp | Bin 0 -> 442 bytes
vcl/qa/cppunit/data/TypeDetectionExample.gif | Bin 0 -> 50 bytes
vcl/qa/cppunit/data/TypeDetectionExample.jpg | Bin 0 -> 992 bytes
vcl/qa/cppunit/data/TypeDetectionExample.met | Bin 0 -> 629 bytes
vcl/qa/cppunit/data/TypeDetectionExample.pcx | Bin 0 -> 284 bytes
vcl/qa/cppunit/data/TypeDetectionExample.pdf | Bin 0 -> 962 bytes
vcl/qa/cppunit/data/TypeDetectionExample.png | Bin 0 -> 94 bytes
vcl/qa/cppunit/data/TypeDetectionExample.psd | Bin 0 -> 1338 bytes
vcl/qa/cppunit/data/TypeDetectionExample.svg | 4 +
vcl/qa/cppunit/data/TypeDetectionExample.svgz | Bin 0 -> 166 bytes
vcl/qa/cppunit/data/TypeDetectionExample.tga | Bin 0 -> 148 bytes
vcl/qa/cppunit/data/TypeDetectionExample.tif | Bin 0 -> 603 bytes
vcl/qa/cppunit/data/TypeDetectionExample.wmf | Bin 0 -> 290 bytes
vcl/qa/cppunit/data/TypeDetectionExample.xbm | 5 +
vcl/qa/cppunit/data/TypeDetectionExample.xpm | 15 +
vcl/source/filter/GraphicFormatDetector.cxx | 565 ++++++++++++++++++++++++++
vcl/source/filter/graphicfilter.cxx | 52 +--
21 files changed, 977 insertions(+), 42 deletions(-)

Upstream: cgit.freedesktop.org


  • Share