From c3e3bed2db816bf2c929f9c3bde76b2af57a4d76 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Tue, 16 Feb 2021 09:16:55 +0900 Subject: vcl: condense the description and rename the peek format function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit remove "Imp" from ImpPeekGraphicFormat function name and condense the description of the function. Change-Id: Ie7cc42645318c0035f082ae68087ca3c7077d365 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111090 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- vcl/inc/graphic/GraphicFormatDetector.hxx | 2 +- vcl/qa/cppunit/GraphicFormatDetectorTest.cxx | 32 ++++++++++----------- vcl/source/filter/graphicfilter.cxx | 43 +++++++++------------------- 3 files changed, 30 insertions(+), 47 deletions(-) diff --git a/vcl/inc/graphic/GraphicFormatDetector.hxx b/vcl/inc/graphic/GraphicFormatDetector.hxx index e914ee64a3ca..b38561f790c3 100644 --- a/vcl/inc/graphic/GraphicFormatDetector.hxx +++ b/vcl/inc/graphic/GraphicFormatDetector.hxx @@ -23,7 +23,7 @@ #include #include -VCL_DLLPUBLIC bool ImpPeekGraphicFormat(SvStream& rStream, OUString& rFormatExtension, bool bTest); +VCL_DLLPUBLIC bool peekGraphicFormat(SvStream& rStream, OUString& rFormatExtension, bool bTest); namespace vcl { diff --git a/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx b/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx index f4f4698b28a9..1fb2fe0cb4ee 100644 --- a/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx +++ b/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx @@ -83,7 +83,7 @@ void GraphicFormatDetectorTest::testDetectMET() aFileStream.Seek(aDetector.mnStreamPosition); OUString rFormatExtension; - CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false)); + CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false)); CPPUNIT_ASSERT_EQUAL(OUString("MET"), rFormatExtension); } @@ -98,7 +98,7 @@ void GraphicFormatDetectorTest::testDetectBMP() aFileStream.Seek(aDetector.mnStreamPosition); OUString rFormatExtension; - CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false)); + CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false)); CPPUNIT_ASSERT_EQUAL(OUString("BMP"), rFormatExtension); } @@ -113,7 +113,7 @@ void GraphicFormatDetectorTest::testDetectWMF() aFileStream.Seek(aDetector.mnStreamPosition); OUString rFormatExtension; - CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false)); + CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false)); CPPUNIT_ASSERT_EQUAL(OUString("WMF"), rFormatExtension); } @@ -128,7 +128,7 @@ void GraphicFormatDetectorTest::testDetectPCX() aFileStream.Seek(aDetector.mnStreamPosition); OUString rFormatExtension; - CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false)); + CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false)); CPPUNIT_ASSERT_EQUAL(OUString("PCX"), rFormatExtension); } @@ -143,7 +143,7 @@ void GraphicFormatDetectorTest::testDetectJPG() aFileStream.Seek(aDetector.mnStreamPosition); OUString rFormatExtension; - CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false)); + CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false)); CPPUNIT_ASSERT_EQUAL(OUString("JPG"), rFormatExtension); } @@ -158,7 +158,7 @@ void GraphicFormatDetectorTest::testDetectPNG() aFileStream.Seek(aDetector.mnStreamPosition); OUString rFormatExtension; - CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false)); + CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false)); CPPUNIT_ASSERT_EQUAL(OUString("PNG"), rFormatExtension); } @@ -173,7 +173,7 @@ void GraphicFormatDetectorTest::testDetectGIF() aFileStream.Seek(aDetector.mnStreamPosition); OUString rFormatExtension; - CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false)); + CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false)); CPPUNIT_ASSERT_EQUAL(OUString("GIF"), rFormatExtension); } @@ -188,7 +188,7 @@ void GraphicFormatDetectorTest::testDetectPSD() aFileStream.Seek(aDetector.mnStreamPosition); OUString rFormatExtension; - CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false)); + CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false)); CPPUNIT_ASSERT_EQUAL(OUString("PSD"), rFormatExtension); } @@ -203,7 +203,7 @@ void GraphicFormatDetectorTest::testDetectTGA() aFileStream.Seek(aDetector.mnStreamPosition); OUString rFormatExtension("TGA"); // detection is based on extension only - CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false)); + CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false)); CPPUNIT_ASSERT_EQUAL(OUString("TGA"), rFormatExtension); } @@ -218,7 +218,7 @@ void GraphicFormatDetectorTest::testDetectTIF() aFileStream.Seek(aDetector.mnStreamPosition); OUString rFormatExtension; - CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false)); + CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false)); CPPUNIT_ASSERT_EQUAL(OUString("TIF"), rFormatExtension); } @@ -233,7 +233,7 @@ void GraphicFormatDetectorTest::testDetectXBM() aFileStream.Seek(aDetector.mnStreamPosition); OUString rFormatExtension; - CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false)); + CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false)); CPPUNIT_ASSERT_EQUAL(OUString("XBM"), rFormatExtension); } @@ -248,7 +248,7 @@ void GraphicFormatDetectorTest::testDetectXPM() aFileStream.Seek(aDetector.mnStreamPosition); OUString rFormatExtension; - CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false)); + CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false)); CPPUNIT_ASSERT_EQUAL(OUString("XPM"), rFormatExtension); } @@ -263,7 +263,7 @@ void GraphicFormatDetectorTest::testDetectSVG() aFileStream.Seek(aDetector.mnStreamPosition); OUString rFormatExtension; - CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false)); + CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false)); CPPUNIT_ASSERT_EQUAL(OUString("SVG"), rFormatExtension); } @@ -278,7 +278,7 @@ void GraphicFormatDetectorTest::testDetectSVGZ() aFileStream.Seek(aDetector.mnStreamPosition); OUString rFormatExtension; - CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false)); + CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false)); CPPUNIT_ASSERT_EQUAL(OUString("SVG"), rFormatExtension); } @@ -293,7 +293,7 @@ void GraphicFormatDetectorTest::testDetectPDF() aFileStream.Seek(aDetector.mnStreamPosition); OUString rFormatExtension; - CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false)); + CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false)); CPPUNIT_ASSERT_EQUAL(OUString("PDF"), rFormatExtension); } @@ -308,7 +308,7 @@ void GraphicFormatDetectorTest::testDetectEPS() aFileStream.Seek(aDetector.mnStreamPosition); OUString rFormatExtension; - CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false)); + CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false)); CPPUNIT_ASSERT_EQUAL(OUString("EPS"), rFormatExtension); } diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 09cc67c6c4bd..08e0454db1a2 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -181,34 +181,17 @@ bool isPCT(SvStream& rStream, sal_uLong nStreamPos, sal_uLong nStreamLen) return false; } -/************************************************************************* - * - * ImpPeekGraphicFormat() - * - * Description: - * This function is two-fold: - * 1.) Start reading file, determine the file format: - * Input parameters: - * rPath - file path - * rFormatExtension - content matter - * bTest - set false - * Output parameters: - * Return value - true if success - * rFormatExtension - on success: normal file extension in capitals - * 2.) Start reading file, verify file format - * Input parameters: - * rPath - file path - * rFormatExtension - normal file extension in capitals - * bTest - set true - * Output parameters: - * Return value - false, if cannot verify the file type - * passed to the function - * true, when the format is PROBABLY verified or - * WHEN THE FORMAT IS NOT KNOWN! - * - *************************************************************************/ - -bool ImpPeekGraphicFormat( SvStream& rStream, OUString& rFormatExtension, bool bTest ) +/*** + * This function is has two modes: + * - determine the file format when bTest = false + * returns true, success + * out rFormatExtension - on success: file format string + * - verify file format when bTest = true + * returns false, if file type can't be verified + * true, if the format is PROBABLY verified + * or WHEN THE FORMAT IS NOT KNOWN! + */ +bool peekGraphicFormat( SvStream& rStream, OUString& rFormatExtension, bool bTest ) { vcl::GraphicFormatDetector aDetector(rStream, rFormatExtension); if (!aDetector.detect()) @@ -468,7 +451,7 @@ ErrCode GraphicFilter::ImpTestOrFindFormat( const OUString& rPath, SvStream& rSt if( rFormat == GRFILTER_FORMAT_DONTKNOW ) { OUString aFormatExt; - if( ImpPeekGraphicFormat( rStream, aFormatExt, false ) ) + if( peekGraphicFormat( rStream, aFormatExt, false ) ) { rFormat = pConfig->GetImportFormatNumberForExtension( aFormatExt ); if( rFormat != GRFILTER_FORMAT_DONTKNOW ) @@ -488,7 +471,7 @@ ErrCode GraphicFilter::ImpTestOrFindFormat( const OUString& rPath, SvStream& rSt { OUString aTmpStr( pConfig->GetImportFormatExtension( rFormat ) ); aTmpStr = aTmpStr.toAsciiUpperCase(); - if( !ImpPeekGraphicFormat( rStream, aTmpStr, true ) ) + if( !peekGraphicFormat( rStream, aTmpStr, true ) ) return ERRCODE_GRFILTER_FORMATERROR; if ( pConfig->GetImportFormatExtension( rFormat ).equalsIgnoreAsciiCase( "pcd" ) ) { -- cgit